@tachybase/module-workflow 0.23.20 → 0.23.35
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 +48 -48
- package/dist/client/nodes/query.d.ts +42 -27
- package/dist/client/schemas/collection.d.ts +42 -27
- package/dist/client/schemas/executions.d.ts +24 -0
- package/dist/externalVersion.js +15 -15
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/zh-CN.json +5 -1
- package/dist/node_modules/@babel/core/lib/index.js +76 -76
- package/dist/node_modules/@babel/core/node_modules/.bin/parser +4 -4
- package/dist/node_modules/@babel/core/package.json +1 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/form-data/package.json +1 -1
- package/dist/node_modules/jsonata/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/qrcode/package.json +1 -1
- package/dist/server/Plugin.js +1 -1
- package/dist/server/actions/workflows.js +2 -4
- package/dist/server/features/trigger-instruction/TriggerInstruction.js +2 -1
- package/dist/server/instructions/CreateInstruction.js +51 -10
- package/dist/server/instructions/DestroyInstruction.js +3 -1
- package/dist/server/instructions/QueryInstruction.js +3 -7
- package/dist/server/instructions/UpdateInstruction.js +51 -10
- package/package.json +17 -17
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@ant-design/icons"),require("@tachybase/schema"),require("lodash"),require("@tachybase/components"),require("@tachybase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@ant-design/icons","@tachybase/schema","lodash","@tachybase/components","@tachybase/evaluators/client"],s):(S=typeof globalThis!="undefined"?globalThis:S||self,s(S["@tachybase/module-workflow"]={},S["@tachybase/client"],S["@tachybase/utils"],S.jsxRuntime,S.antd,S["react-router-dom"],S["react-i18next"],S.react,S["@ant-design/icons"],S["@tachybase/schema"],S.lodash,S["@tachybase/components"],S["@tachybase/evaluators"]))})(this,function(S,s,B,r,b,oe,R,v,z,A,ge,ve,Qe){"use strict";var kl=Object.defineProperty,Sl=Object.defineProperties;var Al=Object.getOwnPropertyDescriptors;var Bt=Object.getOwnPropertySymbols;var
|
|
1
|
+
(function(S,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@ant-design/icons"),require("@tachybase/schema"),require("lodash"),require("@tachybase/components"),require("@tachybase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@ant-design/icons","@tachybase/schema","lodash","@tachybase/components","@tachybase/evaluators/client"],s):(S=typeof globalThis!="undefined"?globalThis:S||self,s(S["@tachybase/module-workflow"]={},S["@tachybase/client"],S["@tachybase/utils"],S.jsxRuntime,S.antd,S["react-router-dom"],S["react-i18next"],S.react,S["@ant-design/icons"],S["@tachybase/schema"],S.lodash,S["@tachybase/components"],S["@tachybase/evaluators"]))})(this,function(S,s,B,r,b,oe,R,v,z,A,ge,ve,Qe){"use strict";var kl=Object.defineProperty,Sl=Object.defineProperties;var Al=Object.getOwnPropertyDescriptors;var Bt=Object.getOwnPropertySymbols;var Wn=Object.prototype.hasOwnProperty,zn=Object.prototype.propertyIsEnumerable;var so=(S,s,B)=>s in S?kl(S,s,{enumerable:!0,configurable:!0,writable:!0,value:B}):S[s]=B,w=(S,s)=>{for(var B in s||(s={}))Wn.call(s,B)&&so(S,B,s[B]);if(Bt)for(var B of Bt(s))zn.call(s,B)&&so(S,B,s[B]);return S},F=(S,s)=>Sl(S,Al(s));var Ln=S=>typeof S=="symbol"?S:S+"",G=(S,s)=>{var B={};for(var r in S)Wn.call(S,r)&&s.indexOf(r)<0&&(B[r]=S[r]);if(S!=null&&Bt)for(var r of Bt(S))s.indexOf(r)<0&&zn.call(S,r)&&(B[r]=S[r]);return B};var f=(S,s,B)=>so(S,typeof s!="symbol"?s+"":s,B);var E=(S,s,B)=>new Promise((r,b)=>{var oe=z=>{try{v(B.next(z))}catch(A){b(A)}},R=z=>{try{v(B.throw(z))}catch(A){b(A)}},v=z=>z.done?r(z.value):Promise.resolve(z.value).then(oe,R);v((B=B.apply(S,s)).next())});const m="workflow";function N(e,t={}){return s.i18n.t(e,F(w({},t),{ns:[m,"core"]}))}function ke(){return R.useTranslation([m,"core"])}const D=(e,t={})=>s.tval(e,w({ns:[m,"core"]},t)),qn=()=>{const{t:e}=ke(),t=oe.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},pt=(e,t)=>({getAriaLabel:v.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])}),Ue=v.createContext({});function L(){return v.useContext(Ue)}var Ke=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(Ke||{});class Q{constructor(){f(this,"title");f(this,"type");f(this,"group");f(this,"icon");f(this,"color");f(this,"isHot");f(this,"description");f(this,"options");f(this,"fieldset");f(this,"view");f(this,"scope");f(this,"components");f(this,"end")}}function Un(e){var y;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(Z),a=s.useCompile(),i=s.useAPIClient(),{workflow:l,refresh:d}=(y=L())!=null?y:{},c=Array.from(n.instructions.getValues()),p=v.useMemo(()=>Gn(c,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:a}),[o,n,c,t,l]),u=v.useCallback(h=>E(this,[h],function*({keyPath:x}){var O,V,$;const C=x.pop(),k={},[T]=x,I=n.instructions.get(C);if(T){const{value:P}=(V=(O=I.options)==null?void 0:O.find(j=>j.key===T))!=null?V:{};Object.assign(k,typeof P=="function"?P():P)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:C,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:a(I.title),config:k}}),d())}),[i,o,n.instructions,d,t==null?void 0:t.id,l]),g=v.useMemo(()=>({onClick:u,items:p}),[p,u]);return{workflow:l,menu:g}}const ao=[{key:Ke.CONTROL,label:N("Control")},{key:Ke.COLLECTION,label:N("Collection operations")},{key:Ke.MANUAL,label:N("Manual")},{key:Ke.EXTENDED,label:N("Extended types")}],Kn={key:"hot",label:N("Hot tools")};function Gn(e,{engine:t,workflow:o,upstream:n,branchIndex:a,compile:i}){const l=[],d=[];for(const c of ao){const p=e.filter(y=>{var x,h;return y.group===c.key&&((h=(x=y.isAvailable)==null?void 0:x.call(y,{engine:t,workflow:o,upstream:n,branchIndex:a}))!=null?h:!0)});let u=[];for(const y of p){const{type:x,title:h,icon:C,color:k,options:T,isHot:I}=y,O=_n(C,k),V={role:"button","aria-label":x,key:x,label:i(h),type:T?"subMenu":null,icon:O,children:T?T.map($=>({role:"button","aria-label":$.key,key:$.key,label:i($.label)})):null};u.push(V),I&&d.push(V)}const g=F(w({},c),{type:"group",children:u});l.push(g)}return l.unshift(F(w({},Kn),{type:"group",children:d})),l.filter(c=>c.children.length)}function _n(e,t){return r.jsx("div",{className:s.css`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: center;
|
|
4
4
|
align-items: center;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
width: 100%;
|
|
14
14
|
height: 100%;
|
|
15
15
|
}
|
|
16
|
-
`,children:r.jsx(s.Icon,{type:e})})}const
|
|
16
|
+
`,children:r.jsx(s.Icon,{type:e})})}const Hn=s.createStyles(({css:e,token:t})=>({addButtonClass:e`
|
|
17
17
|
flex-shrink: 0;
|
|
18
18
|
padding: 2em 0;
|
|
19
19
|
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
border-radius: 8px;
|
|
33
33
|
overflow-y: auto;
|
|
34
34
|
}
|
|
35
|
-
`,iconContainerClass:e``})),Vt=e=>{const{styles:t}=
|
|
35
|
+
`,iconContainerClass:e``})),Vt=e=>{const{styles:t}=Hn(),{workflow:o,menu:n}=Un(e);return o?r.jsx("div",{className:t.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],disabled:o.executed,overlayClassName:t.dropDownClass,menu:n,children:r.jsx(b.Button,{className:"add-btn",icon:r.jsx(z.PlusOutlined,{}),type:"primary","aria-label":e["aria-label"]||"add-button"})})}):null};function $e(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}const io=v.createContext({}),lo=io.Provider;function ye(){return v.useContext(io)}const Jn=s.createStyles(({css:e,token:t})=>({nodeBlockClass:e`
|
|
36
36
|
flex-grow: 1;
|
|
37
37
|
flex-shrink: 0;
|
|
38
38
|
display: flex;
|
|
39
39
|
flex-direction: column;
|
|
40
40
|
align-items: center;
|
|
41
41
|
position: relative;
|
|
42
|
-
`})),co=({data:e})=>{const{styles:t}=
|
|
42
|
+
`})),co=({data:e})=>{const{styles:t}=Jn(),{getAriaLabel:o}=pt(e),n=s.usePlugin(Z),{Component:a=rt,end:i,group:l}=n.instructions.get(e.type);return r.jsx(lo,{value:F(w({},e),{group:l}),children:r.jsxs("div",{className:s.cx(t.nodeBlockClass),children:[r.jsx(a,{data:e}),!i||typeof i=="function"&&!i(e)?r.jsx(Vt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(z.CloseOutlined,{})})]})})},he=s.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
43
43
|
flex-grow: 1;
|
|
44
44
|
overflow: hidden;
|
|
45
45
|
display: flex;
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
.workflow-node-config-button {
|
|
330
330
|
display: none;
|
|
331
331
|
}
|
|
332
|
-
`}));function Be({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:a,end:i}){const{styles:l}=he(),{getAriaLabel:d}=pt(e,o),c=[];for(let p=t;p;p=p.downstream)c.push(p);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,a),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Vt,{"aria-label":d(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:c.map(p=>r.jsx(co,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(z.CloseOutlined,{})}):null]})}const
|
|
332
|
+
`}));function Be({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:a,end:i}){const{styles:l}=he(),{getAriaLabel:d}=pt(e,o),c=[];for(let p=t;p;p=p.downstream)c.push(p);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,a),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Vt,{"aria-label":d(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:c.map(p=>r.jsx(co,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(z.CloseOutlined,{})}):null]})}const Yn=s.createStyles(({css:e,token:t})=>({container:e`
|
|
333
333
|
margin-bottom: 1.5em;
|
|
334
334
|
padding: 1em;
|
|
335
335
|
background-color: ${t.colorFillAlter};
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
p {
|
|
355
355
|
color: ${t.colorTextDescription};
|
|
356
356
|
}
|
|
357
|
-
`}));function po(e){const{label:t,title:o,description:n,workflowKey:a,createdAt:i,createdBy:l}=e,{styles:d}=
|
|
357
|
+
`}));function po(e){const{label:t,title:o,description:n,workflowKey:a,createdAt:i,createdBy:l}=e,{styles:d}=Yn(),{t:c}=ke();return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:s.cx(d.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]}),a||i||l?r.jsxs("div",{className:s.cx(d.container,e.className),children:[a?r.jsx("p",{children:`${c("Key")}: ${a}`}):null,i?r.jsx("p",{children:`${c("Created at")}: ${B.convertUTCToLocal(i)}`}):null,l?r.jsx("p",{children:`${c("Created by")}: ${l}`}):null]}):null]})}const uo="json-parse",mo="js-parse",fo="data-mapping",Ge="deprecated",Qn=e=>{var c;const{className:t}=e,{t:o}=ke(),{styles:n}=Zn(),a=s.useCompile(),{instructions:i}=s.usePlugin(Z),{nodes:l}=(c=L())!=null?c:{},d=v.useMemo(()=>l==null?void 0:l.reduce((p,u)=>{const g=i.get(u.type),{group:y,title:x}=g,h=ao.find(T=>T.key===y),C={key:y,title:x,groupLabel:h!=null&&h.label?h==null?void 0:h.label:o("Unkown group"),count:1,isDeprecated:y===Ge},k=p.findIndex(T=>T.key===y);return k>0?p[k].count++:p.push(C),p},[]),[l]);return r.jsxs("div",{className:s.cx(n.container,t),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o("Node list")}),r.jsx("dd",{children:o("group-title-count")})]}),d.map(({key:p,title:u,groupLabel:g,count:y,isDeprecated:x},h)=>r.jsx("p",{className:x?n.deprecated:"",children:`${h+1}: ${g}:${a(u)}-${y} ${x?o("Deprecated, please do not use it"):""}`},p))]})},Zn=s.createStyles(({css:e,token:t})=>({container:e`
|
|
358
358
|
margin-bottom: 1.5em;
|
|
359
359
|
padding: 1em;
|
|
360
360
|
background-color: ${t.colorFillAlter};
|
|
@@ -381,23 +381,23 @@
|
|
|
381
381
|
}
|
|
382
382
|
`,deprecated:e`
|
|
383
383
|
background-color: yellow;
|
|
384
|
-
`}));function
|
|
384
|
+
`}));function Xn(){var i;const e=A.useForm(),t=s.useAPIClient(),{workflow:o}=(i=L())!=null?i:{},n=s.useActionContext(),{refresh:a}=s.useResourceActionContext();return{run(){return E(this,null,function*(){if(o.executed){b.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),b.message.success("success"),a()})}}}class Ze{constructor(){f(this,"sync");f(this,"title");f(this,"description");f(this,"fieldset");f(this,"view");f(this,"scope");f(this,"components");f(this,"initializers");f(this,"isActionTriggerable")}}const Rn=()=>{const e=s.useCompile(),{workflow:t,execution:o}=L(),{styles:n}=he(),a=Xe();return o?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(s.Icon,{type:"InfoOutlined"}),shape:"circle",size:"small",className:s.cx(n.nodeJobButtonClass,s.css`
|
|
385
385
|
position: absolute;
|
|
386
386
|
top: 50%;
|
|
387
387
|
right: -50px;
|
|
388
388
|
transform: translateY(-50%);
|
|
389
|
-
`),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:F(w({},o),{context:JSON.stringify(o.context||{},null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(a.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"string",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:i}=s.useTranslation();return{run(){return E(this,null,function*(){try{const d=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(d),b.message.success(i("Copied"))}catch(d){b.message.error(i("Copy failed"))}})}}}}}}}}}}}}):null};function
|
|
389
|
+
`),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:F(w({},o),{context:JSON.stringify(o.context||{},null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(a.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"string",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:i}=s.useTranslation();return{run(){return E(this,null,function*(){try{const d=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(d),b.message.success(i("Copied"))}catch(d){b.message.error(i("Copy failed"))}})}}}}}}}}}}}}):null};function er(){return{form:A.useForm()}}const tr=()=>{var $;const e=s.useAPIClient(),{workflow:t,refresh:o}=L(),[n,a]=v.useState(""),[i,l]=v.useState(!1),[d,c]=v.useState(!1),{styles:p}=he(),u=s.useCompile(),g=Xe(),y=u(g.title),{fieldset:x,scope:h,components:C}=g,k=t.executed?'{{t("View")}}':'{{t("Configure")}}',T=N("Trigger");v.useEffect(()=>{var P,j;t&&a((j=(P=t.triggerTitle)!=null?P:t.title)!=null?j:y)},[t]);const I=v.useMemo(()=>{const P=ge.cloneDeep(t.config);return A.createForm({initialValues:P,disabled:t.executed})},[t]),O=v.useCallback(P=>{l(P),P||I.reset()},[I]);v.useCallback(function(P){return E(this,null,function*(){const j=P||y;a(j),j!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:j}}),o())})},[t]);const V=v.useCallback(function(P){var H;if(P.target===P.currentTarget){l(!0);return}const j=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let M=P.target;M&&M!==P.currentTarget;M=M.parentNode)if(Array.from((H=M.classList)!=null?H:[]).some(_=>j.has(_))){l(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{role:"button","aria-label":`${T}-${n}`,className:s.cx(p.terminalClass),onClick:V,children:[N("Start"),r.jsx(s.ActionContextProvider,{value:{visible:i,setVisible:O,formValueChanged:d,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:I,children:r.jsx(s.SchemaComponent,{scope:F(w({},h),{useFormProviderProps:er}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":k,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:T,"x-component":"Action.Area","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:F(w({},g.description?{description:{type:"void","x-component":po,"x-component-props":{label:N("Trigger type"),title:g.title,description:g.description,workflowKey:t.key,createdAt:t.createdAt,createdBy:($=t.createdBy)==null?void 0:$.nickname}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
|
|
390
390
|
.ant-select.auto-width {
|
|
391
391
|
width: auto;
|
|
392
392
|
min-width: 6em;
|
|
393
393
|
}
|
|
394
|
-
`},properties:x},actions:t.executed?{}:{type:"void","x-component":"ActionArea.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:
|
|
394
|
+
`},properties:x},actions:t.executed?{}:{type:"void","x-component":"ActionArea.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:Xn}}}},showNodes:{type:"void","x-component":Qn}})}}}})})})]}),r.jsx(Rn,{})]})};function Xe(){const e=s.usePlugin(Z),{workflow:t}=L();return e.triggers.get(t.type)}const go="workflow-zoom";function or({entry:e}){const{styles:t}=he(),{workflow:o}=L(),[n,a]=v.useState(100),i=ge.debounce(l=>{localStorage.setItem(go,l)});return v.useEffect(()=>{const l=localStorage.getItem(go);l&&Number(l)>0&&a(Number(l))},[]),r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
|
|
395
395
|
margin-top: 0 !important;
|
|
396
396
|
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:N("Executed workflow cannot be modified"),showIcon:!0,className:s.css`
|
|
397
397
|
margin-bottom: 1em;
|
|
398
|
-
`}):null,r.jsx(
|
|
398
|
+
`}):null,r.jsx(tr,{}),r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
|
|
399
399
|
margin-top: 0 !important;
|
|
400
|
-
`),children:r.jsx(Be,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{a(l),i(l)}})})]})}const yo="workflow-splitter",ho=({entry:e})=>{const t=L(),[o,n]=v.useState(600),a=ge.debounce(i=>{localStorage.setItem(yo,i)});return v.useEffect(()=>{const i=localStorage.getItem(yo);i&&Number(i)>0&&n(Number(i))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(b.Splitter,{onResize:i=>{n(i[1]),a(String(i[1]))},children:[r.jsx(b.Splitter.Panel,{collapsible:!0,children:r.jsx(
|
|
400
|
+
`),children:r.jsx(Be,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{a(l),i(l)}})})]})}const yo="workflow-splitter",ho=({entry:e})=>{const t=L(),[o,n]=v.useState(600),a=ge.debounce(i=>{localStorage.setItem(yo,i)});return v.useEffect(()=>{const i=localStorage.getItem(yo);i&&Number(i)>0&&n(Number(i))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(b.Splitter,{onResize:i=>{n(i[1]),a(String(i[1]))},children:[r.jsx(b.Splitter.Panel,{collapsible:!0,children:r.jsx(or,{entry:e})}),r.jsx(b.Splitter.Panel,{size:o,min:"240",collapsible:!0,className:"workflow-operator-area",children:r.jsx(s.ActionAreaStub,{})})]})})};function jt(e){if(e>=86313600)return"999 D";const n=Math.floor(e/(24*60*60)),a=Math.floor(e%(24*60*60)/3600),i=Math.floor(e%3600/60),l=e%60;let d="";return n>0&&(d+=`${n} D `),(a>0||n>0)&&(d+=`${a} h `),(i>0||a>0||n>0)&&(d+=`${i} m `),e>=60?d+=`${Math.floor(l)} s`:d+=`${l.toFixed(3)} s`,d.trim()}function Wt(){const e=s.useCollectionRecordData(),{createdAt:t,updatedAt:o,status:n}=e||{},[a,i]=v.useState("");return v.useEffect(()=>{const l=t?new Date(t):null,d=o?new Date(o):null;let c=null;const p=()=>{let u=0;if(l&&!isNaN(l.getTime())){const g=l.getTime();if(n===0){const y=Date.now();u=Math.max((y-g)/1e3,0)}else if(d&&!isNaN(d.getTime())){const y=d.getTime();u=Math.max((y-g)/1e3,0)}i(jt(u))}else i("Invalid timestamps")};return p(),n===0&&(c=setInterval(p,1e3)),()=>{c&&clearInterval(c)}},[t,o,n]),r.jsx("div",{children:a})}const xo=e=>{const t=oe.useNavigate();return r.jsx(b.Button,w({type:"text",icon:r.jsx(s.Icon,{type:"ArrowLeftOutlined"}),onClick:()=>{t(-1)}},e))},nr=s.createStyles(({css:e})=>({statusButtonClass:e`
|
|
401
401
|
border: none;
|
|
402
402
|
.ant-tag {
|
|
403
403
|
display: inline-grid;
|
|
@@ -411,10 +411,10 @@
|
|
|
411
411
|
}
|
|
412
412
|
`,noStatusButtonClass:e`
|
|
413
413
|
border-width: 2px;
|
|
414
|
-
`}));function Re(e){var n;const{styles:t}=or();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:a,color:i}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:i,children:a})}return r.jsx(b.Button,F(w({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ut=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(z.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(z.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(z.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],mt=ut.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var xe=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(xe||{});const ft=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],et=ft.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function gt(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 yt(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return yt(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[a]=Object.keys(o[n]);return!(!a||typeof o[n][a]=="undefined")}):!1}function ht(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{ht(e.properties[o],t)})}function Ve(e){return`/_admin/business-components/workflow/${e}/workflow`}function xt(e){return`/_admin/business-components/workflow/${e}/executions`}function nr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const a=o.get(n.nodeId);a.jobs.push(n),n.node={id:a.id,key:a.key,title:a.title,type:a.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((a,i)=>a.id-i.id)})}function rr(){const{instructions:e}=s.usePlugin(Z),t=s.useCompile(),{viewJob:o,setViewJob:n}=L();if(!o)return;o.cost=jt(o.cost/1e3);const{styles:a}=he(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.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:F(w({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:a.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:ft,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:d}=R.useTranslation();return{run(){return E(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),b.message.success(d("Copied"))}catch(p){b.message.error(d("Copy failed"))}})}}}}}}}}}}}})})}function sr(e){const{execution:t}=L(),o=s.useAPIClient(),n=oe.useNavigate(),{styles:a}=he(),[i,l]=v.useState([]),[d,c]=v.useState([]);v.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),v.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{c(u.data.reverse())}).catch(()=>{})},[t]);const p=v.useCallback(({key:u})=>{u!==t.id&&n(xt(u))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(a.dropdownClass,a.executionsDropdownRowClass),items:[...d,t,...i].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:B.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Re,{statusMap:mt,status:u.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(z.DownOutlined,{})]})}):null}function ar(){var I;const{t:e}=R.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:a}=s.useResourceActionContext(),{setTitle:i}=s.useDocumentTitle(),[l,d]=v.useState(null),c=s.useApp(),p=s.useAPIClient();v.useEffect(()=>{var j;const{workflow:O}=(j=o==null?void 0:o.data)!=null?j:{};i==null||i(`${O!=null&&O.title?`${O.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const u=v.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(z.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),a()}).catch(O=>{console.error(O.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const P=(I=o==null?void 0:o.data)!=null?I:{},{jobs:g=[],workflow:V={}}=P,$=V,{nodes:y=[],revisions:x=[]}=$,h=G($,["nodes","revisions"]),C=G(P,["jobs","workflow"]);gt(y),nr(y,g);const k=y.find(O=>!O.upstream),T=mt[C.status];return r.jsxs(Ue.Provider,{value:{workflow:h.type?h:null,nodes:y,execution:C,viewJob:l,setViewJob:d},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(xo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:c.systemSettingsManager.getRoutePath(`business-components.${m}`),children:N("Workflow")})},{title:r.jsx(oe.Link,{to:Ve(h.id),children:h.title})},{title:r.jsx(sr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:T.color,children:t(T.label)}),C.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(z.StopOutlined,{})})}),r.jsx("time",{children:B.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(ho,{entry:k}),r.jsx(rr,{})]})}const bo=()=>{const e=oe.useParams(),{styles:t}=he();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:ar}})})};function ir(e){return["hasMany","belongsToMany"].includes(e.type)}function lr(){const e=s.useCompile();return[bt,vt].map(t=>{var n;const o=(n=t.useOptions({types:[ir],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function cr(n){var a=n,{value:e,onChange:t}=a,o=G(a,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),d=lr(),[c,p]=v.useState(d),{associatedKey:u="",name:g}=e!=null?e:{};let y=[];const x=u.match(/^{{(.*)}}$/);x&&(y=[...x[1].trim().split(".").slice(0,-1),g]);const h=k=>E(this,null,function*(){var I;const T=k[k.length-1];!((I=T.children)!=null&&I.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(P=>[...P]))});v.useEffect(()=>{E(this,null,function*(){var I;if(!y||c.length<=1)return;let T=null;for(let P=0;P<y.length;P++){const V=y[P];try{P===0?T=c.find($=>$.value===V):(T.loadChildren&&!((I=T.children)!=null&&I.length)&&(yield T.loadChildren(T)),T=T.children.find($=>$.value===V))}catch($){console.error($)}}p([...c])})},[e,c.length]);const C=v.useCallback((k,T)=>{if(!(k!=null&&k.length)){i("collection",null),t({});return}const{field:I}=T.pop();if(!I||!["hasMany","belongsToMany"].includes(I.type))return;const{collectionName:P,target:V,name:$,dataSourceKey:O}=I,H=l(P,O).fields.find(M=>M.primaryKey);i("collection",`${O}:${V}`),t({name:$,associatedKey:`{{${k.slice(0,-1).join(".")}.${H.name}}}`,associatedCollection:s.joinCollectionName(O,P)})},[t]);return r.jsx(b.Cascader,F(w({},o),{value:y,options:c,changeOnSelect:!0,onChange:C,loadData:h}))}class dr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Aggregate", { ns: "${m}" })}}`);f(this,"type","aggregate");f(this,"group","collection");f(this,"icon","SearchOutlined");f(this,"color","#19e8aa");f(this,"description",`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`);f(this,"fieldset",{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(o){return!o.hidden&&o.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:o}=A.useForm(),[n,a]=s.parseCollectionName(o==null?void 0:o.collection);return{options:s.useCollectionFilterOptions(a,n),className:s.css`
|
|
414
|
+
`}));function Re(e){var n;const{styles:t}=nr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:a,color:i}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:i,children:a})}return r.jsx(b.Button,F(w({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ut=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(z.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(z.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(z.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(z.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(z.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],mt=ut.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var xe=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(xe||{});const ft=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],et=ft.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function gt(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 yt(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return yt(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[a]=Object.keys(o[n]);return!(!a||typeof o[n][a]=="undefined")}):!1}function ht(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{ht(e.properties[o],t)})}function Ve(e){return`/_admin/business-components/workflow/${e}/workflow`}function xt(e){return`/_admin/business-components/workflow/${e}/executions`}function rr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const a=o.get(n.nodeId);a.jobs.push(n),n.node={id:a.id,key:a.key,title:a.title,type:a.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((a,i)=>a.id-i.id)})}function sr(){const{instructions:e}=s.usePlugin(Z),t=s.useCompile(),{viewJob:o,setViewJob:n}=L();if(!o)return;o.cost=jt(o.cost/1e3);const{styles:a}=he(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.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:F(w({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:a.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:ft,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:d}=R.useTranslation();return{run(){return E(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),b.message.success(d("Copied"))}catch(p){b.message.error(d("Copy failed"))}})}}}}}}}}}}}})})}function ar(e){const{execution:t}=L(),o=s.useAPIClient(),n=oe.useNavigate(),{styles:a}=he(),[i,l]=v.useState([]),[d,c]=v.useState([]);v.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),v.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{c(u.data.reverse())}).catch(()=>{})},[t]);const p=v.useCallback(({key:u})=>{u!==t.id&&n(xt(u))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(a.dropdownClass,a.executionsDropdownRowClass),items:[...d,t,...i].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:B.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Re,{statusMap:mt,status:u.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(z.DownOutlined,{})]})}):null}function ir(){var I;const{t:e}=R.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:a}=s.useResourceActionContext(),{setTitle:i}=s.useDocumentTitle(),[l,d]=v.useState(null),c=s.useApp(),p=s.useAPIClient();v.useEffect(()=>{var j;const{workflow:P}=(j=o==null?void 0:o.data)!=null?j:{};i==null||i(`${P!=null&&P.title?`${P.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const u=v.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(z.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),a()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const O=(I=o==null?void 0:o.data)!=null?I:{},{jobs:g=[],workflow:V={}}=O,$=V,{nodes:y=[],revisions:x=[]}=$,h=G($,["nodes","revisions"]),C=G(O,["jobs","workflow"]);gt(y),rr(y,g);const k=y.find(P=>!P.upstream),T=mt[C.status];return r.jsxs(Ue.Provider,{value:{workflow:h.type?h:null,nodes:y,execution:C,viewJob:l,setViewJob:d},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(xo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:c.systemSettingsManager.getRoutePath(`business-components.${m}`),children:N("Workflow")})},{title:r.jsx(oe.Link,{to:Ve(h.id),children:h.title})},{title:r.jsx(ar,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:T.color,children:t(T.label)}),C.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(z.StopOutlined,{})})}),r.jsx("time",{children:B.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(ho,{entry:k}),r.jsx(sr,{})]})}const bo=()=>{const e=oe.useParams(),{styles:t}=he();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:ir}})})};function lr(e){return["hasMany","belongsToMany"].includes(e.type)}function cr(){const e=s.useCompile();return[bt,vt].map(t=>{var n;const o=(n=t.useOptions({types:[lr],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function dr(n){var a=n,{value:e,onChange:t}=a,o=G(a,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),d=cr(),[c,p]=v.useState(d),{associatedKey:u="",name:g}=e!=null?e:{};let y=[];const x=u.match(/^{{(.*)}}$/);x&&(y=[...x[1].trim().split(".").slice(0,-1),g]);const h=k=>E(this,null,function*(){var I;const T=k[k.length-1];!((I=T.children)!=null&&I.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(O=>[...O]))});v.useEffect(()=>{E(this,null,function*(){var I;if(!y||c.length<=1)return;let T=null;for(let O=0;O<y.length;O++){const V=y[O];try{O===0?T=c.find($=>$.value===V):(T.loadChildren&&!((I=T.children)!=null&&I.length)&&(yield T.loadChildren(T)),T=T.children.find($=>$.value===V))}catch($){console.error($)}}p([...c])})},[e,c.length]);const C=v.useCallback((k,T)=>{if(!(k!=null&&k.length)){i("collection",null),t({});return}const{field:I}=T.pop();if(!I||!["hasMany","belongsToMany"].includes(I.type))return;const{collectionName:O,target:V,name:$,dataSourceKey:P}=I,H=l(O,P).fields.find(M=>M.primaryKey);i("collection",`${P}:${V}`),t({name:$,associatedKey:`{{${k.slice(0,-1).join(".")}.${H.name}}}`,associatedCollection:s.joinCollectionName(P,O)})},[t]);return r.jsx(b.Cascader,F(w({},o),{value:y,options:c,changeOnSelect:!0,onChange:C,loadData:h}))}class pr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Aggregate", { ns: "${m}" })}}`);f(this,"type","aggregate");f(this,"group","collection");f(this,"icon","SearchOutlined");f(this,"color","#19e8aa");f(this,"description",`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`);f(this,"fieldset",{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(o){return!o.hidden&&o.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:o}=A.useForm(),[n,a]=s.parseCollectionName(o==null?void 0:o.collection);return{options:s.useCollectionFilterOptions(a,n),className:s.css`
|
|
415
415
|
position: relative;
|
|
416
416
|
width: 100%;
|
|
417
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Pe,FieldsSelect:tt,ValueBlock:Ae,AssociatedConfig:cr})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return a&&!a.some(l=>l in De||Object.values(De).some(d=>d.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var a;const n=N("Query result");return o.config.collection?{name:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ae.Initializer,node:o,resultTitle:n}:null}}class pr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",dr)})}}const vo=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function ur(e){return vo.slice().reverse().find(t=>!(e%t.value))}function mr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=ur(e),a=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:a,onChange:i=>t(Math.round(i*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:i=>t(Math.round(a*i)),className:"auto-width",options:vo.map(i=>({value:i.value,label:o(i.label)}))})]})}class fr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Delay", { ns: "${m}" })}}`);f(this,"type","delay");f(this,"group","control");f(this,"icon","ClockCircleOutlined");f(this,"color","#cf9247");f(this,"description",`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`);f(this,"fieldset",{duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:xe.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:xe.FAILED}],required:!0,default:xe.RESOLVED}});f(this,"components",{Duration:mr})}isAvailable({engine:o,workflow:n,upstream:a,branchIndex:i}){return!o.isWorkflowSync(n)}}class gr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",fr)})}}function yr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function hr({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),a=ce({types:[yr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:a})}class xr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${m}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","extended");f(this,"icon","CalculatorOutlined");f(this,"color","#2f79b9");f(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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`);f(this,"fieldset",{expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}});f(this,"components",{DynamicExpression:hr,WorkflowVariableInput:Se,ValueBlock:Ae})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return a&&!a.some(l=>l in De||Object.values(De).some(d=>d.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var n;return{name:`#${o.id}`,type:"item",title:(n=o.title)!=null?n:`#${o.id}`,Component:Ae.Initializer,node:o,resultTitle:N("Calculation result")}}}const br=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),i=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,d]=v.useState(n.getValuesIn(i)),c=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(g=>{d(g.getValuesIn(i))}),A.onFieldInputValueChange(i,g=>{d(g.value),t(null)})});const u=me({collection:l,compile:c,getCollectionFields:p});return r.jsx(s.Variable.TextArea,F(w({},e),{scope:u}))},{displayName:"InternalExpression"});function vr(e){const{t}=R.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=v.useMemo(()=>me({collection:o.sourceCollection,compile:n,getCollectionFields:a}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,F(w({},e),{scope:i})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const wr=A.connect(br,A.mapReadPretty(vr)),{defaultProps:Cr}=s.interfacesProperties;class kr extends s.CollectionFieldInterface{constructor(){super(...arguments);f(this,"name","expression");f(this,"type","string");f(this,"group","advanced");f(this,"order",1);f(this,"title",`{{t("Expression", { ns: "${m}" })}}`);f(this,"description",`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`);f(this,"sortable",!0);f(this,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}});f(this,"properties",w({},Cr))}}class Sr extends s.Plugin{load(){return E(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([kr]),this.app.addComponents({DynamicExpression:wr});const t=this.app.pm.get("workflow"),o=new xr;t.instructions.register(o.type,o)})}}function Ar(n){var a=n,{collection:e,dataPath:t}=a,o=G(a,["collection","dataPath"]);const{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:d}=s.useCollectionManager_deprecated(),c=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[g,y]=s.parseCollectionName(e);p=d(y,g)}else p=e;function u(y){return E(this,arguments,function*({item:g}){const x=g.template?yield l(g):null,h={type:"void",name:A.uid(),title:p.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:{}}}}}};ht(h,C=>{C["x-uid"]&&delete C["x-uid"]}),i(h)})}return r.jsx(s.SchemaInitializerItem,F(w({},o),{onClick:u,items:c}))}function Ne(e){var i;const t=s.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let n,a;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],a=l[1]}else a=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:a,children:r.jsx(Ar,w(w({},t),e))})}function Ir(e){const{execution:t,nodes:o}=L(),n=v.useMemo(()=>o.reduce((l,d)=>Object.assign(l,{[d.id]:d.key}),{}),[o]),a=v.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((d,c)=>Object.assign(d,{[n[c.nodeId]]:c.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return v.useMemo(()=>ge.get(a,e),[a,e])}function zt({collection:e,dataPath:t,children:o}){const n=A.useField(),a=v.useRef(null),{getAssociationAppends:i}=s.useAssociationNames(),{appends:l,updateAssociationValues:d}=i(),c=Ir(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const g=v.useMemo(()=>A.createForm({values:c,readPretty:!0}),[c]),y={appends:l},x={loading:!1,data:{data:c}},C=s.useAPIClient().resource(u),k=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:x,resource:C,__parent:k},children:r.jsx(s.FormBlockContext.Provider,{value:{params:y,form:g,field:n,service:x,updateAssociationValues:d,formBlockRef:a},children:o})})})})}function Fr(){return!0}const tt=A.observer(e=>{const p=e,{filter:t=Fr}=p,o=G(p,["filter"]),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm(),[l,d]=s.parseCollectionName(i==null?void 0:i.collection),c=a(d,l);return r.jsx(b.Select,F(w({popupMatchSelectWidth:!1},o),{options:c.filter(t).map(u=>{var g;return{label:n((g=u.uiSchema)==null?void 0:g.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Tr(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}const ue={label:"label",value:"value",children:"children"},wo={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var i;const t=ye(),n=s.usePlugin(Z).instructions.get(t.type);return((i=n.useCurrentFormVariables)==null?void 0:i.call(n,t,e))||[]}},bt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=ye(),n=$e(o),a=[];return n.forEach(i=>{var c;const l=t.get(i.type),d=(c=l.useVariables)==null?void 0:c.call(l,i,e);d&&a.push(d)}),a}},vt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var a,i;const{triggers:t}=s.usePlugin(Z),{workflow:o}=L(),n=t.get(o.type);return(i=(a=n==null?void 0:n.useVariables)==null?void 0:a.call(n,o.config,e))!=null?i:null}},Lt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ue,current:o}=e,{instructions:n}=s.usePlugin(Z),a=ye(),i=o!=null?o:a,l=Tr(i),d=[];return l.forEach(c=>{var g,y;const p=n.get(c.type),u=(g=p.useScopeVariables)==null?void 0:g.call(p,c,e);u&&d.push({key:c.key,[t.value]:c.key,[t.label]:(y=c.title)!=null?y:`#${c.id}`,[t.children]:u})}),d}},Co={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ue}){return!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]}},De={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 ko(e,t){var o,n,a,i,l,d;return typeof t=="string"?(o=De[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?qt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((a=t.options)==null?void 0:a.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((d=t.options)==null?void 0:d.collection):!1:typeof t=="function"?t(e):!1}function qt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ut(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:a,getCollectionFields:i}){return e.filter(l=>{const d=t!=null&&t.length?t.some(c=>ko(l,c)):!0;if(qt(l)){if(o===null)return n?d||Kt({fields:Gt(l.target,{compile:a,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:a,getCollectionFields:i}):!1;const c=Ut(l,o),p=o.includes(l.name);return d?p:((c==null?void 0:c.length)||p)&&Kt({fields:Gt(l.target,{compile:a,getCollectionFields:i}),types:t,appends:c,compile:a,getCollectionFields:i}).length}else return d})}function ot(e,t){var i,l;const o=s.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:a}=t;return{[a.label]:o(e.label),[a.value]:e.value,key:e[a.value],[a.children]:n,disabled:!n||!n.length}}function ce(e={}){var a;const t=Object.assign({},ue,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[ot(Lt,o),ot(bt,o),ot(vt,o),ot(Co,o)]}function So(e={}){var a;const t=Object.assign({},ue,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[ot(wo,o)]}function Gt(e,{compile:t,getCollectionFields:o}){var c,p,u,g,y,x,h;const[n,a]=s.parseCollectionName(e),i=o(a,n),l=[],d=[];i.forEach(C=>{C.isForeignKey?l.push(C):d.push(C)});for(let C=d.length-1;C>=0;C--){const k=d[C];if(k.type==="belongsTo"){const T=l.find(I=>I.name===k.foreignKey);T?d.splice(C,0,F(w(w({},k),T),{uiSchema:F(w({},k.uiSchema),{title:(c=k.uiSchema)!=null&&c.title?`${t((p=k.uiSchema)==null?void 0:p.title)} ID`:T.name})})):d.splice(C,0,F(w({},k),{name:k.foreignKey,type:"bigInt",isForeignKey:!0,interface:k.interface,uiSchema:F(w({},k.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?`${t((g=k.uiSchema)==null?void 0:g.title)} ID`:k.name})}))}else if(k.type==="context"&&k.collectionName==="users"){const T=(y=d.find(I=>I.type==="belongsTo"&&I.target==="users"&&I.foreignKey===k.name))!=null?y:{};d.splice(C,0,F(w({},k),{type:k.dataType,interface:T.interface,uiSchema:F(w({},T.uiSchema),{title:(x=T.uiSchema)!=null&&x.title?`${t((h=T.uiSchema)==null?void 0:h.title)} ID`:k.name})}))}}return d.filter(C=>C.interface&&!C.hidden)}function Nr(e){const t=Ut(e.field,e.appends),o=me(w({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(a=>ko(e.field,a))||(e.disabled=!0))}function me(e){const{fields:t,collection:o,types:n,appends:a=[],depth:i=1,compile:l,getCollectionFields:d,fieldNames:c=ue}=e,p=t!=null?t:Gt(o,{compile:l,getCollectionFields:d}),u=Nr.bind({compile:l,getCollectionFields:d,fieldNames:c});return Kt({fields:p,types:n,depth:i,appends:a,compile:l,getCollectionFields:d}).map(y=>{var k;const x=l(((k=y.uiSchema)==null?void 0:k.title)||y.name),h=Ut(y,a),C=!qt(y)||h&&!h.length&&!a.includes(y.name)||!1;return{[c.label]:x,key:y.name,[c.value]:y.name,isLeaf:C,loadChildren:C?null:u,field:y,depth:i,appends:a,types:n}})}function Se(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.Input,w({scope:a},t))}function nt(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.TextArea,w({scope:a},t))}function Ao(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.RawTextArea,w({scope:a},t))}function Io(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.JSON,w({scope:a},t))}function Dr(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const{options:a=[]}=t,i=So(e),l=ce(e);return r.jsx(s.Variable.CodeMirror,w({scope:[...i,...l,...a]},t))}function Pe({value:e,onChange:t,renderSchemaComponent:o}){const n=ce();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Oe(e){const i=e,{options:t=[],direction:o}=i,n=G(i,["options","direction"]),a=s.useCompile();return r.jsx(b.Radio.Group,F(w({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Radio,{value:l.value,children:[r.jsx("span",{className:s.css`
|
|
417
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Oe,FieldsSelect:tt,ValueBlock:Ae,AssociatedConfig:dr})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return a&&!a.some(l=>l in De||Object.values(De).some(d=>d.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var a;const n=N("Query result");return o.config.collection?{name:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ae.Initializer,node:o,resultTitle:n}:null}}class ur extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",pr)})}}const vo=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function mr(e){return vo.slice().reverse().find(t=>!(e%t.value))}function fr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=mr(e),a=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:a,onChange:i=>t(Math.round(i*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:i=>t(Math.round(a*i)),className:"auto-width",options:vo.map(i=>({value:i.value,label:o(i.label)}))})]})}class gr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Delay", { ns: "${m}" })}}`);f(this,"type","delay");f(this,"group","control");f(this,"icon","ClockCircleOutlined");f(this,"color","#cf9247");f(this,"description",`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`);f(this,"fieldset",{duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:xe.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:xe.FAILED}],required:!0,default:xe.RESOLVED}});f(this,"components",{Duration:fr})}isAvailable({engine:o,workflow:n,upstream:a,branchIndex:i}){return!o.isWorkflowSync(n)}}class yr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",gr)})}}function hr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function xr({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),a=ce({types:[hr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:a})}class br extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${m}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","extended");f(this,"icon","CalculatorOutlined");f(this,"color","#2f79b9");f(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. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`);f(this,"fieldset",{expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}});f(this,"components",{DynamicExpression:xr,WorkflowVariableInput:Se,ValueBlock:Ae})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return a&&!a.some(l=>l in De||Object.values(De).some(d=>d.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var n;return{name:`#${o.id}`,type:"item",title:(n=o.title)!=null?n:`#${o.id}`,Component:Ae.Initializer,node:o,resultTitle:N("Calculation result")}}}const vr=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),i=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,d]=v.useState(n.getValuesIn(i)),c=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(g=>{d(g.getValuesIn(i))}),A.onFieldInputValueChange(i,g=>{d(g.value),t(null)})});const u=me({collection:l,compile:c,getCollectionFields:p});return r.jsx(s.Variable.TextArea,F(w({},e),{scope:u}))},{displayName:"InternalExpression"});function wr(e){const{t}=R.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=v.useMemo(()=>me({collection:o.sourceCollection,compile:n,getCollectionFields:a}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,F(w({},e),{scope:i})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const Cr=A.connect(vr,A.mapReadPretty(wr)),{defaultProps:kr}=s.interfacesProperties;class Sr extends s.CollectionFieldInterface{constructor(){super(...arguments);f(this,"name","expression");f(this,"type","string");f(this,"group","advanced");f(this,"order",1);f(this,"title",`{{t("Expression", { ns: "${m}" })}}`);f(this,"description",`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`);f(this,"sortable",!0);f(this,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}});f(this,"properties",w({},kr))}}class Ar extends s.Plugin{load(){return E(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Sr]),this.app.addComponents({DynamicExpression:Cr});const t=this.app.pm.get("workflow"),o=new br;t.instructions.register(o.type,o)})}}function Ir(n){var a=n,{collection:e,dataPath:t}=a,o=G(a,["collection","dataPath"]);const{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:d}=s.useCollectionManager_deprecated(),c=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[g,y]=s.parseCollectionName(e);p=d(y,g)}else p=e;function u(y){return E(this,arguments,function*({item:g}){const x=g.template?yield l(g):null,h={type:"void",name:A.uid(),title:p.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:{}}}}}};ht(h,C=>{C["x-uid"]&&delete C["x-uid"]}),i(h)})}return r.jsx(s.SchemaInitializerItem,F(w({},o),{onClick:u,items:c}))}function Ne(e){var i;const t=s.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let n,a;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],a=l[1]}else a=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:a,children:r.jsx(Ir,w(w({},t),e))})}function Fr(e){const{execution:t,nodes:o}=L(),n=v.useMemo(()=>o.reduce((l,d)=>Object.assign(l,{[d.id]:d.key}),{}),[o]),a=v.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((d,c)=>Object.assign(d,{[n[c.nodeId]]:c.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return v.useMemo(()=>ge.get(a,e),[a,e])}function zt({collection:e,dataPath:t,children:o}){const n=A.useField(),a=v.useRef(null),{getAssociationAppends:i}=s.useAssociationNames(),{appends:l,updateAssociationValues:d}=i(),c=Fr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const g=v.useMemo(()=>A.createForm({values:c,readPretty:!0}),[c]),y={appends:l},x={loading:!1,data:{data:c}},C=s.useAPIClient().resource(u),k=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:x,resource:C,__parent:k},children:r.jsx(s.FormBlockContext.Provider,{value:{params:y,form:g,field:n,service:x,updateAssociationValues:d,formBlockRef:a},children:o})})})})}function Tr(){return!0}const tt=A.observer(e=>{const p=e,{filter:t=Tr}=p,o=G(p,["filter"]),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm(),[l,d]=s.parseCollectionName(i==null?void 0:i.collection),c=a(d,l);return r.jsx(b.Select,F(w({popupMatchSelectWidth:!1},o),{options:c.filter(t).map(u=>{var g;return{label:n((g=u.uiSchema)==null?void 0:g.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Nr(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}const ue={label:"label",value:"value",children:"children"},wo={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var i;const t=ye(),n=s.usePlugin(Z).instructions.get(t.type);return((i=n.useCurrentFormVariables)==null?void 0:i.call(n,t,e))||[]}},bt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=ye(),n=$e(o),a=[];return n.forEach(i=>{var c;const l=t.get(i.type),d=(c=l.useVariables)==null?void 0:c.call(l,i,e);d&&a.push(d)}),a}},vt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var a,i;const{triggers:t}=s.usePlugin(Z),{workflow:o}=L(),n=t.get(o.type);return(i=(a=n==null?void 0:n.useVariables)==null?void 0:a.call(n,o.config,e))!=null?i:null}},Lt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ue,current:o}=e,{instructions:n}=s.usePlugin(Z),a=ye(),i=o!=null?o:a,l=Nr(i),d=[];return l.forEach(c=>{var g,y;const p=n.get(c.type),u=(g=p.useScopeVariables)==null?void 0:g.call(p,c,e);u&&d.push({key:c.key,[t.value]:c.key,[t.label]:(y=c.title)!=null?y:`#${c.id}`,[t.children]:u})}),d}},Co={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ue}){return!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]}},De={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 ko(e,t){var o,n,a,i,l,d;return typeof t=="string"?(o=De[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?qt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((a=t.options)==null?void 0:a.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((d=t.options)==null?void 0:d.collection):!1:typeof t=="function"?t(e):!1}function qt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ut(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:a,getCollectionFields:i}){return e.filter(l=>{const d=t!=null&&t.length?t.some(c=>ko(l,c)):!0;if(qt(l)){if(o===null)return n?d||Kt({fields:Gt(l.target,{compile:a,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:a,getCollectionFields:i}):!1;const c=Ut(l,o),p=o.includes(l.name);return d?p:((c==null?void 0:c.length)||p)&&Kt({fields:Gt(l.target,{compile:a,getCollectionFields:i}),types:t,appends:c,compile:a,getCollectionFields:i}).length}else return d})}function ot(e,t){var i,l;const o=s.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:a}=t;return{[a.label]:o(e.label),[a.value]:e.value,key:e[a.value],[a.children]:n,disabled:!n||!n.length}}function ce(e={}){var a;const t=Object.assign({},ue,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[ot(Lt,o),ot(bt,o),ot(vt,o),ot(Co,o)]}function So(e={}){var a;const t=Object.assign({},ue,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[ot(wo,o)]}function Gt(e,{compile:t,getCollectionFields:o}){var c,p,u,g,y,x,h;const[n,a]=s.parseCollectionName(e),i=o(a,n),l=[],d=[];i.forEach(C=>{C.isForeignKey?l.push(C):d.push(C)});for(let C=d.length-1;C>=0;C--){const k=d[C];if(k.type==="belongsTo"){const T=l.find(I=>I.name===k.foreignKey);T?d.splice(C,0,F(w(w({},k),T),{uiSchema:F(w({},k.uiSchema),{title:(c=k.uiSchema)!=null&&c.title?`${t((p=k.uiSchema)==null?void 0:p.title)} ID`:T.name})})):d.splice(C,0,F(w({},k),{name:k.foreignKey,type:"bigInt",isForeignKey:!0,interface:k.interface,uiSchema:F(w({},k.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?`${t((g=k.uiSchema)==null?void 0:g.title)} ID`:k.name})}))}else if(k.type==="context"&&k.collectionName==="users"){const T=(y=d.find(I=>I.type==="belongsTo"&&I.target==="users"&&I.foreignKey===k.name))!=null?y:{};d.splice(C,0,F(w({},k),{type:k.dataType,interface:T.interface,uiSchema:F(w({},T.uiSchema),{title:(x=T.uiSchema)!=null&&x.title?`${t((h=T.uiSchema)==null?void 0:h.title)} ID`:k.name})}))}}return d.filter(C=>C.interface&&!C.hidden)}function Dr(e){const t=Ut(e.field,e.appends),o=me(w({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(a=>ko(e.field,a))||(e.disabled=!0))}function me(e){const{fields:t,collection:o,types:n,appends:a=[],depth:i=1,compile:l,getCollectionFields:d,fieldNames:c=ue}=e,p=t!=null?t:Gt(o,{compile:l,getCollectionFields:d}),u=Dr.bind({compile:l,getCollectionFields:d,fieldNames:c});return Kt({fields:p,types:n,depth:i,appends:a,compile:l,getCollectionFields:d}).map(y=>{var k;const x=l(((k=y.uiSchema)==null?void 0:k.title)||y.name),h=Ut(y,a),C=!qt(y)||h&&!h.length&&!a.includes(y.name)||!1;return{[c.label]:x,key:y.name,[c.value]:y.name,isLeaf:C,loadChildren:C?null:u,field:y,depth:i,appends:a,types:n}})}function Se(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.Input,w({scope:a},t))}function nt(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.TextArea,w({scope:a},t))}function Ao(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.RawTextArea,w({scope:a},t))}function Io(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const a=ce(e);return r.jsx(s.Variable.JSON,w({scope:a},t))}function Or(o){var n=o,{variableOptions:e}=n,t=G(n,["variableOptions"]);const{options:a=[]}=t,i=So(e),l=ce(e);return r.jsx(s.Variable.CodeMirror,w({scope:[...i,...l,...a]},t))}function Oe({value:e,onChange:t,renderSchemaComponent:o}){const n=ce();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Pe(e){const i=e,{options:t=[],direction:o}=i,n=G(i,["options","direction"]),a=s.useCompile();return r.jsx(b.Radio.Group,F(w({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Radio,{value:l.value,children:[r.jsx("span",{className:s.css`
|
|
418
418
|
& + .anticon {
|
|
419
419
|
margin-left: 0.25em;
|
|
420
420
|
}
|
|
@@ -422,11 +422,11 @@
|
|
|
422
422
|
& + .anticon {
|
|
423
423
|
margin-left: 0.25em;
|
|
424
424
|
}
|
|
425
|
-
`,children:a(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:a(l.tooltip),children:r.jsx(z.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function _t(){const e=A.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ae=()=>null;function Pr(){const i=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=G(i,["node","resultTitle"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(w({},n),{onClick:()=>{var l;a({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
|
|
425
|
+
`,children:a(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:a(l.tooltip),children:r.jsx(z.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function _t(){const e=A.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ae=()=>null;function Pr(){const i=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=G(i,["node","resultTitle"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(w({},n),{onClick:()=>{var l;a({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 Er({dataSource:e}){var a;const t=A.useFieldSchema(),{execution:o}=L();if(!o)return t.title;const n=B.parse(e)({$jobsMapByNodeKey:((a=o.jobs)!=null?a:[]).reduce((i,l)=>Object.assign(i,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
|
|
426
426
|
margin: 0;
|
|
427
|
-
`,children:JSON.stringify(n,null,2)})}Ae.Initializer=Pr,Ae.Result=
|
|
427
|
+
`,children:JSON.stringify(n,null,2)})}Ae.Initializer=Pr,Ae.Result=Er,Ae.Designer=_t;function To(n){var a=n,{component:e="div",children:t}=a,o=G(a,["component","children"]);const[i,l]=v.useState(!1),d=A.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:d},children:[v.createElement(e,F(w({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:d,onlyRenderProperties:!0})]})}function No(e){var i;const o=s.useCompile()(e.label),n=v.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:a}=(i=mt[e.value])!=null?i:{};return r.jsx(b.Tag,{color:a,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function Mr(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(No,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Do(t){var e=G(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:No,children:ut.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,F(w({},n),{children:r.jsx(Mr,w({},n))}),n.value))}))}function Ht(e){const{t}=R.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useCollectionRecordData(),i=v.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(z.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:a.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[a]);return r.jsxs("div",{className:s.css`
|
|
428
428
|
display: flex;
|
|
429
|
-
`,children:[e.children,a.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(z.StopOutlined,{})})})]})}const
|
|
429
|
+
`,children:[e.children,a.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(z.StopOutlined,{})})})]})}const Oo=t=>{var e=G(t,[]);const[o,n]=v.useState(30),a=v.useRef(null),i=l=>{var d;n(a.current.offsetWidth+50),(d=e.onChange)==null||d.call(e,l)};return v.useEffect(()=>{n(a.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,F(w({},e),{onChange:i,style:{width:`${o}px`}})),r.jsx("span",{ref:a,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},$r=e=>e.value&&typeof e.value=="object"?r.jsx(Vr,w({},e)):r.jsx(Br,w({},e)),Br=({value:e,onChange:t})=>{const o=ce({types:[jr]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},Vr=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Oe}}}}})})};function jr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Jt(){const{workflow:e}=L();return!!(e!=null&&e.executed)}function Po(){const{workflow:e}=L();return!!(e!=null&&e.allExecuted)}const Wr=()=>{const e=Jt(),t=ve.ArrayItems.useArray()||{field:[]},{t:o}=ke(),[n,a]=v.useState(!1),i=v.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=v.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:a,content:r.jsx(zr,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},zr=({onSlecet:e,onQuery:t})=>{const{t:o}=ke();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Lr=e=>{const{t}=ke(),[o,n]=v.useState(!1),a=v.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})};function qr(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:N("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:N("Values submitted"),value:"values",children:me(F(w({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class Ur extends Ze{constructor(){super(...arguments);f(this,"sync",!0);f(this,"title",N("Interceptor"));f(this,"description",N('Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.'));f(this,"fieldset",{collection:{type:"string",title:D("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:D("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:D("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:D("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:D("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:D("Create record action"),value:"create"},{label:D("Update record action"),value:"update"},{label:D("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{FieldsSelect:tt,RadioWithTooltip:Pe,CheckboxGroupWithTooltip:Fo});f(this,"isActionTriggerable",(o,n)=>{const{global:a}=o;return!a&&!n.direct})}useVariables(o,n){const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=me(F(w({appends:["user"]},n),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:D("User acted")}}],compile:a,getCollectionFields:i})),d=[{label:N("Parameters"),value:"params",children:qr(o,n)}];return[...l,{label:N("Role of user acted"),value:"roleName"},...d]}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:D("Trigger data"),Component:Ne,collection:o.collection,dataPath:"$context.params.values"}:null}}class Kr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get(Z).registerTrigger("request-interception",Ur)})}}class Gr extends Q{constructor(){super(...arguments);f(this,"title",D("JS Parse"));f(this,"type",mo);f(this,"group",Ge);f(this,"description",D("Get specific data from JSON result of any node BY js code;"));f(this,"fieldset",{source:{type:"string",title:D("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:D("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
|
|
430
430
|
ctx.body
|
|
431
431
|
__ctx
|
|
432
432
|
lib.JSON
|
|
@@ -440,14 +440,14 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:D("P
|
|
|
440
440
|
button {
|
|
441
441
|
padding: 0;
|
|
442
442
|
}
|
|
443
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}isAvailable(){return!1}}class
|
|
443
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}isAvailable(){return!1}}class _r extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get(Z).registerInstruction(mo,Gr)})}}class Hr extends Q{constructor(){super(...arguments);f(this,"title",D("JSON Parse"));f(this,"type",uo);f(this,"group",Ge);f(this,"description",D("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"));f(this,"fieldset",{source:{type:"string",title:D("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:D("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:D("Properties mapping"),description:D("If the type of query result is object or array of object, could map the properties which to be accessed in subsequent nodes."),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{path:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:D("Property path")},properties:{path:{type:"string",name:"path",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},alias:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:D("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:D("Label")},properties:{label:{type:"string",name:"label",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
|
|
444
444
|
> *:not(:last-child) {
|
|
445
445
|
margin-right: 0.5em;
|
|
446
446
|
}
|
|
447
447
|
button {
|
|
448
448
|
padding: 0;
|
|
449
449
|
}
|
|
450
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}isAvailable(){return!1}}class
|
|
450
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}isAvailable(){return!1}}class Jr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get(Z).registerInstruction(uo,Hr)})}}function Yr(e,t){let o=e,n=null;for(let a=0;a<t.length;a++){const i=t[a],l=o.find(d=>d.value===i);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class Qr extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Loop", { ns: "${m}" })}}`);f(this,"type","loop");f(this,"group","control");f(this,"icon","RetweetOutlined");f(this,"color","#0ed6ec");f(this,"description",`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${m}" })}}`);f(this,"fieldset",{target:{type:"string",title:`{{t("Loop target", { ns: "${m}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:s.css`
|
|
451
451
|
width: 100%;
|
|
452
452
|
|
|
453
453
|
.variable {
|
|
@@ -459,23 +459,23 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:D("P
|
|
|
459
459
|
}
|
|
460
460
|
`},required:!0}});f(this,"components",{WorkflowVariableInput:Se})}Component({data:o}){var l;const{nodes:n}=L(),{styles:a}=he(),i=n.find(d=>d.upstreamId===o.id&&d.branchIndex!=null);return r.jsx(rt,{data:o,children:r.jsx("div",{className:a.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(a.branchBlockClass,s.css`
|
|
461
461
|
padding-left: 20em;
|
|
462
|
-
`),children:[r.jsx(Be,{from:o,entry:i,branchIndex:(l=i==null?void 0:i.branchIndex)!=null?l:0}),r.jsxs("div",{className:a.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(a.addButtonClass,a.loopLineClass),children:r.jsx(z.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(o,n){const a=s.useCompile(),i=N("Loop target"),l=N("Loop index"),d=N("Loop length"),{target:c}=o.config;if(!c)return null;const{fieldNames:p=ue}=n;let u={key:"item",[p.value]:"item",[p.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const g=c.slice(2,-2).split(".").map(h=>h.trim()),y=[Lt,bt,vt].map(h=>{const C=h.useOptions(F(w({},n),{current:o})).filter(Boolean);return{[p.label]:a(h.label),[p.value]:h.value,key:h.value,[p.children]:C,disabled:C&&!C.length}}),x=
|
|
462
|
+
`),children:[r.jsx(Be,{from:o,entry:i,branchIndex:(l=i==null?void 0:i.branchIndex)!=null?l:0}),r.jsxs("div",{className:a.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(a.addButtonClass,a.loopLineClass),children:r.jsx(z.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(o,n){const a=s.useCompile(),i=N("Loop target"),l=N("Loop index"),d=N("Loop length"),{target:c}=o.config;if(!c)return null;const{fieldNames:p=ue}=n;let u={key:"item",[p.value]:"item",[p.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const g=c.slice(2,-2).split(".").map(h=>h.trim()),y=[Lt,bt,vt].map(h=>{const C=h.useOptions(F(w({},n),{current:o})).filter(Boolean);return{[p.label]:a(h.label),[p.value]:h.value,key:h.value,[p.children]:C,disabled:C&&!C.length}}),x=Yr(y,g);u=Object.assign({},x,u)}return[u,{key:"index",[p.value]:"index",[p.label]:l},{key:"length",[p.value]:"length",[p.label]:d}]}}class Zr extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",Qr)})}}function Xr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Rr({multiple:e=!1,value:t=[],onChange:o}){const n=ce({types:[Xr]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:a=>{o([a])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:a=>{o(a!=null?[a]:[])}})})}function es({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(ve.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:N("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:N("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:N("All pass")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:N("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:N("Any pass")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
|
|
463
463
|
.ant-radio-group {
|
|
464
464
|
.anticon {
|
|
465
465
|
margin-left: 0.5em;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:N("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:N("Separately")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:N("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:N("Collaboratively")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Eo(e){var $,O,j;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),a=v.useRef(null),i=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(i),{appends:d,updateAssociationValues:c}=l(),[p]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(O=t==null?void 0:t.result)==null?void 0:O[p],{findComponent:g}=s.useDesignable(),y=g((j=n.component)==null?void 0:j[0])||v.Fragment,x=v.useMemo(()=>A.createForm({initialValues:u}),[u]),h=v.useMemo(()=>w({appends:d},e.params),[d,e.params]),C=v.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=s.useAPIClient(),T=s.useDataSourceHeaders(i),I=k.resource(e.collection,void 0,T),P=s.useBlockRequestContext(),V=v.useMemo(()=>({params:h,form:x,field:n,service:C,updateAssociationValues:c,formBlockRef:a}),[n,x,h,C,c]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:i,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:u,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:C,resource:I,__parent:P},children:r.jsx(s.FormBlockContext.Provider,{value:V,children:r.jsxs(y,F(w({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:x}),r.jsx("div",{ref:a,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function es(e){return s.createFormBlockSchema(e)}function ts(o){var n=o,{schema:e}=n,t=G(n,["schema"]);const{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),{insert:i}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function d(p){return E(this,arguments,function*({item:c}){var h;const u=c.template?yield a(c):null,g=es(F(w({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:xe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:u}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[y]=Object.keys(g.properties),x=((h=Object.entries(g.properties[y].properties).find(([C,k])=>k["x-component"]==="ActionBar"))==null?void 0:h[0])||"actions";g.properties[y].properties[x]["x-decorator"]="ActionBarProvider",g.properties[y].properties[x]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ht(g,C=>{C["x-uid"]&&delete C["x-uid"]}),i(g)})}return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:d,items:l}))}function Mo(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(ts,w({},e))})}function Ee(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(a=>{n.push(...Ee(e.properties[a],t))}),n):n}function os(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ns={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=v.useMemo(()=>e.map(({key:i,displayName:l,collections:d})=>({key:i,name:i,label:l,type:"subMenu",children:d.map(c=>({name:ge.camelCase(`createRecordForm-child-${c.name}`),type:"item",title:c.title||c.tableName,schema:{collection:c.name,dataSource:i,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Mo}))})),[e]),[o,n]=v.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{CreateFormDesigner:os},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var d,c;const[a]=Object.keys(n.properties),i=n.properties[a],l=((d=Object.entries(i.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]={type:"create",title:((c=n["x-component-props"])==null?void 0:c.title)||a,actions:Ee(i.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,g;return{status:p["x-decorator-props"].value,values:(g=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:g.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function $o(e){var p,u,g,y;const[t,o]=v.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),a=A.useField(),i=A.useFieldSchema(),[l]=Object.keys((g=i.toJSON().properties)!=null?g:{}),d=(y=n==null?void 0:n.result)==null?void 0:y[l],c=v.useMemo(()=>A.createForm({initialValues:d}),[d]);return!n.status||d?r.jsx(s.CollectionProvider_deprecated,{collection:F(w({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:c,field:a,setCollectionFields:o},children:e.children})})}):null}function rs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:B.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[B.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:xe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Bo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function ss(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:a="others"}=n;t[a]=t[a]||{},ge.set(t,[a,o],n)}),Object.keys(Bo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Bo[o],children:Object.keys(t[o]||{}).map(n=>{const a=t[o][n];return w({value:n,title:a.title,name:n},t[o][n])}).sort((n,a)=>n.order-a.order)}))}function as(){const{interfaces:e}=s.useCollectionManager_deprecated();return ss(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:cs,fieldInterface:n.name}))}))}const Vo=v.createContext({}),is=e=>{const[t,o]=v.useState(null),[n,a]=v.useState(),i=as(),l=s.useCollection_deprecated(),{setCollectionFields:d}=v.useContext(s.FormBlockContext),c=v.useMemo(()=>A.createForm(),[t]);return r.jsxs(Vo.Provider,{value:{onAddField(p){const u=ge.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,I=T,{unique:g,type:y,layout:x,autoIncrement:h}=I,C=G(I,["unique","type","layout","autoIncrement"]);u.properties=C;const k=ge.cloneDeep(u);delete k.properties.name["x-disabled"],o(k)},setCallback:a},children:[r.jsx(s.SchemaInitializerItems,F(w({},e),{items:i})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(p){p||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:c},"x-component":"Action.Drawer",properties:F(w({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const p=A.useForm();return{run(){return E(this,null,function*(){a(null),o(null),p.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:p,query:u,reset:g}=A.useForm(),y=[N("Field name existed in form")];return{run(){return E(this,null,function*(){var I,P,V,$;const{default:h}=t,C=B.uid();if(h.name=(I=p.name)!=null?I:C,h.uiSchema.title=(V=(P=p.uiSchema)==null?void 0:P.title)!=null?V:C,h.interface=t.name,($=l.fields)==null?void 0:$.find(O=>O.name===h.name)){u("name").take().setFeedback({type:"error",messages:y});return}const T=B.merge(h,p);d([...l.fields,T]),n({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${h.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),g(),a(null),o(null)})}}}}}}}})},components:{ArrayTable:ve.ArrayTable}}):null})]})},ls=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:is});function cs(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:a}=v.useContext(Vo),{getInterface:i}=s.useCollectionManager_deprecated(),l=i(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,w({onClick:()=>{a(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const jo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:rs}},initializers:{},components:{CustomFormBlockProvider:$o},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c,p;const[a]=Object.keys(n.properties),i=n.properties[a],l=Ee(i.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var g,y;return(y=(g=u["x-component-props"])==null?void 0:g.field)!=null?y:u["x-interface-options"]});const d=((c=Object.entries(i.properties).find(([u,g])=>g["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||a,actions:Ee(i.properties[d],u=>u["x-component"]==="Action").map(u=>{var g,y;return{status:u["x-decorator-props"].value,values:(y=(g=u["x-action-settings"])==null?void 0:g.assignedValues)==null?void 0:y.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:$o}}};function ds(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=R.useTranslation(),{dn:a}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:i})=>{o["x-decorator-props"].filter=i,a.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),a.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ps={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=v.useMemo(()=>e.map(({key:i,displayName:l,collections:d})=>({key:i,name:i,label:l,type:"subMenu",children:d.map(c=>({name:ge.camelCase(`updateRecordForm-child-${c.name}`),type:"item",title:c.title||c.tableName,schema:{collection:c.name,dataSource:i,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Mo}))})),[e]),[o,n]=v.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{FilterDynamicComponent:Pe,UpdateFormDesigner:ds},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var d,c;const[a]=Object.keys(n.properties),i=n.properties[a],l=((d=Object.entries(i.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]=F(w({},n["x-decorator-props"]),{type:"update",title:((c=n["x-component-props"])==null?void 0:c.title)||a,actions:Ee(i.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,g;return{status:p["x-decorator-props"].value,values:(g=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:g.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Me=new B.Registry;Me.register("customForm",jo),Me.register("createForm",ns),Me.register("updateForm",ps);function us(){const{workflow:e}=L(),t=Xe();return t.useInitializers?t.useInitializers(e.config):null}jo.title,`${m}`;const ms=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(Z),t=ye(),o=$e(t),n=[us()].filter(Boolean),a=o.map(l=>{var c;const d=e.instructions.get(l.type);return(c=d==null?void 0:d.useInitializers)==null?void 0:c.call(d,l)}).filter(Boolean);return[...n,...a.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:a}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Me.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function fs(){var k,T,I;const e=v.useContext(s.SchemaComponentContext),{t}=R.useTranslation(),o=A.useFieldSchema(),n=ce(),[a,i]=v.useState(!1),[l,d]=v.useState((I=(T=(k=o==null?void 0:o["x-action-settings"])==null?void 0:k.assignedValues)==null?void 0:T.schema)!=null?I:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[c,p]=v.useState(null),{components:u}=s.useSchemaOptionsContext();v.useEffect(()=>{p(new A.Schema({properties:{grid:l}}))},[l]);const g=v.useMemo(()=>{var V,$;const P=($=(V=o==null?void 0:o["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:$.values;return A.createForm({initialValues:B.lodash.cloneDeep(P),values:B.lodash.cloneDeep(P)})},[o]),y=s.useFormActiveFields(),x=t("Assign field values");function h(){i(!1)}function C(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=g.values,i(!1),setTimeout(()=>{var P;(P=e.refresh)==null||P.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:x,onClick:()=>i(!0),children:x}),r.jsx(b.Modal,{width:"50%",title:x,open:a,onCancel:h,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:h,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:C,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:y==null?void 0:y.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:g,children:r.jsxs(ve.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:N("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),a&&c&&r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},e),{refresh(){d(B.lodash.get(c.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:c,components:u})})]})})})})})})]})}function gs(e){return r.jsxs(s.GeneralSchemaDesigner,F(w({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(fs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function ys(){const i=s.useSchemaInitializerItem(),{action:t,actionProps:o}=i,n=G(i,["action","actionProps"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(w({},n),{onClick:()=>{a({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Wo(){const e=s.useSchemaInitializerItem(),a=e,{action:t,actionProps:o}=a,n=G(a,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,F(w({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const hs=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:ys,action:xe.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Wo,action:xe.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Wo,action:xe.PENDING}]});function xs(){return{run(){}}}function bs({value:e,onChange:t}){const o=s.usePlugin(Z),n=v.useContext(s.SchemaComponentContext),a=ye(),i=$e(a),l=A.useForm(),{workflow:d}=L(),c={};i.forEach(g=>{const y=o.instructions.get(g.type);Object.assign(c,y.components)});const p=v.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
|
|
468
|
+
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:N("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:N("Separately")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:N("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:N("Collaboratively")}),r.jsx(z.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Eo(e){var $,P,j;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),a=v.useRef(null),i=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(i),{appends:d,updateAssociationValues:c}=l(),[p]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[p],{findComponent:g}=s.useDesignable(),y=g((j=n.component)==null?void 0:j[0])||v.Fragment,x=v.useMemo(()=>A.createForm({initialValues:u}),[u]),h=v.useMemo(()=>w({appends:d},e.params),[d,e.params]),C=v.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=s.useAPIClient(),T=s.useDataSourceHeaders(i),I=k.resource(e.collection,void 0,T),O=s.useBlockRequestContext(),V=v.useMemo(()=>({params:h,form:x,field:n,service:C,updateAssociationValues:c,formBlockRef:a}),[n,x,h,C,c]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:i,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:u,parent:null,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:n,service:C,resource:I,__parent:O},children:r.jsx(s.FormBlockContext.Provider,{value:V,children:r.jsxs(y,F(w({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:x}),r.jsx("div",{ref:a,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function ts(e){return s.createFormBlockSchema(e)}function os(o){var n=o,{schema:e}=n,t=G(n,["schema"]);const{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),{insert:i}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function d(p){return E(this,arguments,function*({item:c}){var h;const u=c.template?yield a(c):null,g=ts(F(w({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:xe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:u}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[y]=Object.keys(g.properties),x=((h=Object.entries(g.properties[y].properties).find(([C,k])=>k["x-component"]==="ActionBar"))==null?void 0:h[0])||"actions";g.properties[y].properties[x]["x-decorator"]="ActionBarProvider",g.properties[y].properties[x]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ht(g,C=>{C["x-uid"]&&delete C["x-uid"]}),i(g)})}return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:d,items:l}))}function Mo(){var t,o;const e=s.useSchemaInitializerItem();return r.jsx(s.CollectionProvider_deprecated,{dataSource:(t=e.schema)==null?void 0:t.dataSource,collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(os,w({},e))})}function Ee(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(a=>{n.push(...Ee(e.properties[a],t))}),n):n}function ns(){const{name:e,title:t}=s.useCollection_deprecated();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDataTemplates,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const rs={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=v.useMemo(()=>e.map(({key:i,displayName:l,collections:d})=>({key:i,name:i,label:l,type:"subMenu",children:d.map(c=>({name:ge.camelCase(`createRecordForm-child-${c.name}`),type:"item",title:c.title||c.tableName,schema:{collection:c.name,dataSource:i,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Mo}))})),[e]),[o,n]=v.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{CreateFormDesigner:ns},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var d,c;const[a]=Object.keys(n.properties),i=n.properties[a],l=((d=Object.entries(i.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]={type:"create",title:((c=n["x-component-props"])==null?void 0:c.title)||a,actions:Ee(i.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,g;return{status:p["x-decorator-props"].value,values:(g=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:g.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function $o(e){var p,u,g,y;const[t,o]=v.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),a=A.useField(),i=A.useFieldSchema(),[l]=Object.keys((g=i.toJSON().properties)!=null?g:{}),d=(y=n==null?void 0:n.result)==null?void 0:y[l],c=v.useMemo(()=>A.createForm({initialValues:d}),[d]);return!n.status||d?r.jsx(s.CollectionProvider_deprecated,{collection:F(w({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:c,field:a,setCollectionFields:o},children:e.children})})}):null}function ss(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:B.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[B.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:xe.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Bo={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function as(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:a="others"}=n;t[a]=t[a]||{},ge.set(t,[a,o],n)}),Object.keys(Bo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Bo[o],children:Object.keys(t[o]||{}).map(n=>{const a=t[o][n];return w({value:n,title:a.title,name:n},t[o][n])}).sort((n,a)=>n.order-a.order)}))}function is(){const{interfaces:e}=s.useCollectionManager_deprecated();return as(e).map(o=>({name:o.title,type:"itemGroup",title:o.title,children:o.children.map(n=>({name:n.name,type:"item",title:n.title,Component:ds,fieldInterface:n.name}))}))}const Vo=v.createContext({}),ls=e=>{const[t,o]=v.useState(null),[n,a]=v.useState(),i=is(),l=s.useCollection_deprecated(),{setCollectionFields:d}=v.useContext(s.FormBlockContext),c=v.useMemo(()=>A.createForm(),[t]);return r.jsxs(Vo.Provider,{value:{onAddField(p){const u=ge.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,I=T,{unique:g,type:y,layout:x,autoIncrement:h}=I,C=G(I,["unique","type","layout","autoIncrement"]);u.properties=C;const k=ge.cloneDeep(u);delete k.properties.name["x-disabled"],o(k)},setCallback:a},children:[r.jsx(s.SchemaInitializerItems,F(w({},e),{items:i})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(p){p||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:c},"x-component":"Action.Drawer",properties:F(w({},t.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const p=A.useForm();return{run(){return E(this,null,function*(){a(null),o(null),p.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:p,query:u,reset:g}=A.useForm(),y=[N("Field name existed in form")];return{run(){return E(this,null,function*(){var I,O,V,$;const{default:h}=t,C=B.uid();if(h.name=(I=p.name)!=null?I:C,h.uiSchema.title=(V=(O=p.uiSchema)==null?void 0:O.title)!=null?V:C,h.interface=t.name,($=l.fields)==null?void 0:$.find(P=>P.name===h.name)){u("name").take().setFeedback({type:"error",messages:y});return}const T=B.merge(h,p);d([...l.fields,T]),n({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${h.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),g(),a(null),o(null)})}}}}}}}})},components:{ArrayTable:ve.ArrayTable}}):null})]})},cs=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:ls});function ds(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:a}=v.useContext(Vo),{getInterface:i}=s.useCollectionManager_deprecated(),l=i(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,w({onClick:()=>{a(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const jo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:ss}},initializers:{},components:{CustomFormBlockProvider:$o},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var c,p;const[a]=Object.keys(n.properties),i=n.properties[a],l=Ee(i.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var g,y;return(y=(g=u["x-component-props"])==null?void 0:g.field)!=null?y:u["x-interface-options"]});const d=((c=Object.entries(i.properties).find(([u,g])=>g["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||a,actions:Ee(i.properties[d],u=>u["x-component"]==="Action").map(u=>{var g,y;return{status:u["x-decorator-props"].value,values:(y=(g=u["x-action-settings"])==null?void 0:g.assignedValues)==null?void 0:y.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:$o}}};function ps(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=R.useTranslation(),{dn:a}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:i})=>{o["x-decorator-props"].filter=i,a.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),a.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const us={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=v.useMemo(()=>e.map(({key:i,displayName:l,collections:d})=>({key:i,name:i,label:l,type:"subMenu",children:d.map(c=>({name:ge.camelCase(`updateRecordForm-child-${c.name}`),type:"item",title:c.title||c.tableName,schema:{collection:c.name,dataSource:i,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Mo}))})),[e]),[o,n]=v.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{FilterDynamicComponent:Oe,UpdateFormDesigner:ps},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var d,c;const[a]=Object.keys(n.properties),i=n.properties[a],l=((d=Object.entries(i.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]=F(w({},n["x-decorator-props"]),{type:"update",title:((c=n["x-component-props"])==null?void 0:c.title)||a,actions:Ee(i.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,g;return{status:p["x-decorator-props"].value,values:(g=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:g.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Me=new B.Registry;Me.register("customForm",jo),Me.register("createForm",rs),Me.register("updateForm",us);function ms(){const{workflow:e}=L(),t=Xe();return t.useInitializers?t.useInitializers(e.config):null}jo.title,`${m}`;const fs=new s.SchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:s.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const e=s.usePlugin(Z),t=ye(),o=$e(t),n=[ms()].filter(Boolean),a=o.map(l=>{var c;const d=e.instructions.get(l.type);return(c=d==null?void 0:d.useInitializers)==null?void 0:c.call(d,l)}).filter(Boolean);return[...n,...a.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:a}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Me.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function gs(){var k,T,I;const e=v.useContext(s.SchemaComponentContext),{t}=R.useTranslation(),o=A.useFieldSchema(),n=ce(),[a,i]=v.useState(!1),[l,d]=v.useState((I=(T=(k=o==null?void 0:o["x-action-settings"])==null?void 0:k.assignedValues)==null?void 0:T.schema)!=null?I:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[c,p]=v.useState(null),{components:u}=s.useSchemaOptionsContext();v.useEffect(()=>{p(new A.Schema({properties:{grid:l}}))},[l]);const g=v.useMemo(()=>{var V,$;const O=($=(V=o==null?void 0:o["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:$.values;return A.createForm({initialValues:B.lodash.cloneDeep(O),values:B.lodash.cloneDeep(O)})},[o]),y=s.useFormActiveFields(),x=t("Assign field values");function h(){i(!1)}function C(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=g.values,i(!1),setTimeout(()=>{var O;(O=e.refresh)==null||O.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:x,onClick:()=>i(!0),children:x}),r.jsx(b.Modal,{width:"50%",title:x,open:a,onCancel:h,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:h,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:C,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:y==null?void 0:y.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:g,children:r.jsxs(ve.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:N("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),a&&c&&r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},e),{refresh(){d(B.lodash.get(c.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:c,components:u})})]})})})})})})]})}function ys(e){return r.jsxs(s.GeneralSchemaDesigner,F(w({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(gs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function hs(){const i=s.useSchemaInitializerItem(),{action:t,actionProps:o}=i,n=G(i,["action","actionProps"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(w({},n),{onClick:()=>{a({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Wo(){const e=s.useSchemaInitializerItem(),a=e,{action:t,actionProps:o}=a,n=G(a,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,F(w({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const xs=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:hs,action:xe.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Wo,action:xe.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Wo,action:xe.PENDING}]});function bs(){return{run(){}}}function vs({value:e,onChange:t}){const o=s.usePlugin(Z),n=v.useContext(s.SchemaComponentContext),a=ye(),i=$e(a),l=A.useForm(),{workflow:d}=L(),c={};i.forEach(g=>{const y=o.instructions.get(g.type);Object.assign(c,y.components)});const p=v.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
|
|
469
469
|
.ant-drawer-body {
|
|
470
470
|
background: var(--tb-box-bg);
|
|
471
471
|
}
|
|
472
|
-
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),u=v.useCallback(function(){const{tabs:y}=B.lodash.get(p.toJSON(),"properties.drawer.properties"),x=Array.from(Me.getValues()).reduce((h,C)=>Object.assign(h,C.config.parseFormOptions(y)),{});l.setValuesIn("forms",x),t(y.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},n),{designable:!d.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:F(w(w({},c),Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.config.components),{})),{FormBlockProvider:Eo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(g){return g.children},ActionBarProvider(g){return g.children},SimpleDesigner:_t,ManualActionDesigner:gs}),scope:{useSubmit:xs,useDetailsBlockProps:s.useFormBlockContext}})})}function vs(e){const{workflow:t}=L(),[o,n]=v.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:N(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class ws extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Manual", { ns: "${m}" })}}`);f(this,"type","manual");f(this,"group","manual");f(this,"icon","CoffeeOutlined");f(this,"color","#a3243b");f(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`);f(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});f(this,"components",{SchemaConfigButton:vs,SchemaConfig:bs,ModeConfig:Rr,AssigneesSelect:Xr})}useVariables({key:o,title:n,config:a},{types:i,fieldNames:l=ue}){var g;const d=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),p=Object.keys((g=a.forms)!=null?g:{});if(!p.length)return null;const u=p.map(y=>{var k;const x=a.forms[y],h=me({fields:(k=x.collection)==null?void 0:k.fields,collection:x.collection,types:i,compile:d,getCollectionFields:c}),C=d(x.title)||y;return h.length?{key:y,value:y,label:C,title:C,children:h}:null}).filter(Boolean);return u.length?{[l.value]:o,[l.label]:n,[l.children]:u}:null}useInitializers(o){var l;const{getCollection:n}=s.useCollectionManager_deprecated(),a=Object.keys((l=o.config.forms)!=null?l:{});if(!a.length||o.config.mode)return null;const i=a.map(d=>{var u,g;const c=o.config.forms[d],{fields:p=[]}=n(c.collection);return p.length?{name:(u=c.title)!=null?u:d,type:"item",title:(g=c.title)!=null?g:d,Component:Ne,collection:c.collection,dataPath:`$jobsMapByNodeKey.${o.key}.${d}`}:null}).filter(Boolean);return i.length?{name:`#${o.id}`,key:"forms",type:"subMenu",title:o.title,children:i}:null}isAvailable({engine:o,workflow:n,upstream:a,branchIndex:i}){return!o.isWorkflowSync(n)}}const Cs={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},ks={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Ss={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:ft}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},As=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Is=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Fs=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function Ts(e){const t=s.useRecord(),o=N("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Yt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:As,WorkflowColumn:Is,UserColumn:Fs,UserJobStatusColumn:Ts},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Ns(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=L(),{status:n,result:a,userId:i}=o,l=A.useFieldSchema(),{name:d}=l.parent.toJSON();let{children:c}=e;return n?a[d]||(c=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==i&&(c=null),c}const zo=v.createContext(null);zo.displayName="ManualActionStatusContext";function Ds({value:e,children:t}){const{userJob:o,execution:n}=L(),a=A.useField(),i=A.useFieldSchema();return v.useEffect(()=>{(n.status||o.status)&&(a.disabled=!0,a.visible=o.status===e&&o.result._===i.name)},[n,o,e,a,i.name]),r.jsx(zo.Provider,{value:e,children:t})}function Ps(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),a=A.useFieldSchema(),{service:i}=s.useTableBlockContext(),{userJob:l,execution:d}=L(),{name:c}=a,{name:p}=a.parent.parent;return{run(){return E(this,null,function*(){d.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:c}}}),t(!1),i.refresh())})}}}function Os(e){var u;const t=s.usePlugin(Z),o=s.useAPIClient(),{id:n}=s.useRecord(),[a,i]=v.useState(null),[l,d]=v.useState(null);v.useEffect(()=>{var g,y;n&&((y=(g=o.resource("users_jobs")).get)==null||y.call(g,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:x})=>{var P;const V=(P=x==null?void 0:x.data)!=null?P:{},{node:h,workflow:$={}}=V,O=$,{nodes:C=[]}=O,k=G(O,["nodes"]),j=V,{execution:T}=j,I=G(j,["node","workflow","execution"]);gt(C),d(h),i({userJob:I,workflow:k,nodes:C,execution:T})}))},[o,n]);const p=$e(a==null?void 0:a.nodes.find(g=>g.id===l.id)).reduce((g,{type:y})=>{var x;return Object.assign(g,(x=t.instructions.get(y))==null?void 0:x.components)},{});return l&&a?r.jsx(Ue.Provider,{value:a,children:r.jsx(s.SchemaComponent,{components:w(w({FormBlockProvider:Eo,DetailsBlockProvider:zt,ActionBarProvider:Ns,ManualActionStatusProvider:Ds},Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.block.components),{})),p),scope:w({useSubmit:Ps,useFormBlockProps:Es,useDetailsBlockProps:Ms},Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(b.Spin,{})}function Es(){var l;const{userJob:e,execution:t}=L(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:a}=s.useFormBlockContext(),i=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return v.useEffect(()=>{a==null||a.setPattern(i)},[i,a]),{form:a}}function Ms(){const{form:e}=s.useFormBlockContext();return{form:e}}function $s(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=et[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
|
|
472
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${m}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),u=v.useCallback(function(){const{tabs:y}=B.lodash.get(p.toJSON(),"properties.drawer.properties"),x=Array.from(Me.getValues()).reduce((h,C)=>Object.assign(h,C.config.parseFormOptions(y)),{});l.setValuesIn("forms",x),t(y.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},n),{designable:!d.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:F(w(w({},c),Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.config.components),{})),{FormBlockProvider:Eo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(g){return g.children},ActionBarProvider(g){return g.children},SimpleDesigner:_t,ManualActionDesigner:ys}),scope:{useSubmit:bs,useDetailsBlockProps:s.useFormBlockContext}})})}function ws(e){const{workflow:t}=L(),[o,n]=v.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:N(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class Cs extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Manual", { ns: "${m}" })}}`);f(this,"type","manual");f(this,"group","manual");f(this,"icon","CoffeeOutlined");f(this,"color","#a3243b");f(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${m}" })}}`);f(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});f(this,"components",{SchemaConfigButton:ws,SchemaConfig:vs,ModeConfig:es,AssigneesSelect:Rr})}useVariables({key:o,title:n,config:a},{types:i,fieldNames:l=ue}){var g;const d=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),p=Object.keys((g=a.forms)!=null?g:{});if(!p.length)return null;const u=p.map(y=>{var k;const x=a.forms[y],h=me({fields:(k=x.collection)==null?void 0:k.fields,collection:x.collection,types:i,compile:d,getCollectionFields:c}),C=d(x.title)||y;return h.length?{key:y,value:y,label:C,title:C,children:h}:null}).filter(Boolean);return u.length?{[l.value]:o,[l.label]:n,[l.children]:u}:null}useInitializers(o){var l;const{getCollection:n}=s.useCollectionManager_deprecated(),a=Object.keys((l=o.config.forms)!=null?l:{});if(!a.length||o.config.mode)return null;const i=a.map(d=>{var u,g;const c=o.config.forms[d],{fields:p=[]}=n(c.collection);return p.length?{name:(u=c.title)!=null?u:d,type:"item",title:(g=c.title)!=null?g:d,Component:Ne,collection:c.collection,dataPath:`$jobsMapByNodeKey.${o.key}.${d}`}:null}).filter(Boolean);return i.length?{name:`#${o.id}`,key:"forms",type:"subMenu",title:o.title,children:i}:null}isAvailable({engine:o,workflow:n,upstream:a,branchIndex:i}){return!o.isWorkflowSync(n)}}const ks={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Ss={title:`{{t("Workflow", { ns: "${m}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},As={title:`{{t("Workflow todos", { ns: "${m}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${m}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-component":"Select",enum:ft}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Is=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Fs=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Ts=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function Ns(e){const t=s.useRecord(),o=N("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Yt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:Is,WorkflowColumn:Fs,UserColumn:Ts,UserJobStatusColumn:Ns},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${m}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${m}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Ds(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=L(),{status:n,result:a,userId:i}=o,l=A.useFieldSchema(),{name:d}=l.parent.toJSON();let{children:c}=e;return n?a[d]||(c=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==i&&(c=null),c}const zo=v.createContext(null);zo.displayName="ManualActionStatusContext";function Os({value:e,children:t}){const{userJob:o,execution:n}=L(),a=A.useField(),i=A.useFieldSchema();return v.useEffect(()=>{(n.status||o.status)&&(a.disabled=!0,a.visible=o.status===e&&o.result._===i.name)},[n,o,e,a,i.name]),r.jsx(zo.Provider,{value:e,children:t})}function Ps(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),a=A.useFieldSchema(),{service:i}=s.useTableBlockContext(),{userJob:l,execution:d}=L(),{name:c}=a,{name:p}=a.parent.parent;return{run(){return E(this,null,function*(){d.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:c}}}),t(!1),i.refresh())})}}}function Es(e){var u;const t=s.usePlugin(Z),o=s.useAPIClient(),{id:n}=s.useRecord(),[a,i]=v.useState(null),[l,d]=v.useState(null);v.useEffect(()=>{var g,y;n&&((y=(g=o.resource("users_jobs")).get)==null||y.call(g,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:x})=>{var O;const V=(O=x==null?void 0:x.data)!=null?O:{},{node:h,workflow:$={}}=V,P=$,{nodes:C=[]}=P,k=G(P,["nodes"]),j=V,{execution:T}=j,I=G(j,["node","workflow","execution"]);gt(C),d(h),i({userJob:I,workflow:k,nodes:C,execution:T})}))},[o,n]);const p=$e(a==null?void 0:a.nodes.find(g=>g.id===l.id)).reduce((g,{type:y})=>{var x;return Object.assign(g,(x=t.instructions.get(y))==null?void 0:x.components)},{});return l&&a?r.jsx(Ue.Provider,{value:a,children:r.jsx(s.SchemaComponent,{components:w(w({FormBlockProvider:Eo,DetailsBlockProvider:zt,ActionBarProvider:Ds,ManualActionStatusProvider:Os},Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.block.components),{})),p),scope:w({useSubmit:Ps,useFormBlockProps:Ms,useDetailsBlockProps:$s},Array.from(Me.getValues()).reduce((g,y)=>Object.assign(g,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(b.Spin,{})}function Ms(){var l;const{userJob:e,execution:t}=L(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:a}=s.useFormBlockContext(),i=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return v.useEffect(()=>{a==null||a.setPattern(i)},[i,a]),{form:a}}function $s(){const{form:e}=s.useFormBlockContext();return{form:e}}function Bs(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=et[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
|
|
473
473
|
margin-right: 0.5em;
|
|
474
|
-
`,children:B.dayjs(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function
|
|
474
|
+
`,children:B.dayjs(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Vs(){var i;const e=v.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:a}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:Bs,FlowContextProvider:Es},schema:{type:"void",name:`drawer-${t}-${a}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(i=o.title)!=null?i:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function js({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(w({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[ks,Ss,As],children:r.jsx(s.TableBlockProvider,F(w({name:"workflow-todo"},o),{children:t}))})}Yt.Drawer=Vs,Yt.Decorator=js;const Ws=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(w({icon:r.jsx(z.TableOutlined,{})},e),{onClick:()=>{t({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class zs extends s.Plugin{load(){return E(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Cs),this.app.schemaInitializerManager.add(fs),this.app.schemaInitializerManager.add(xs),this.app.schemaInitializerManager.add(cs),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(z.PartitionOutlined,{}),children:[{name:"common",title:`{{t("Common", { ns: "${m}" })}}`,type:"itemGroup",children:[{name:"todos",title:`{{t("Workflow todos", { ns: "${m}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"}]}]})})}addComponents(){this.app.addComponents({WorkflowTodo:Yt,WorkflowTodoBlockInitializer:Ws})}}const Lo="notice",Qt="workflowNotice",Fe="workflow";function _e(){return{t:(t,o={})=>s.i18n.t(t,w({ns:Fe},o))}}const se=e=>s.tval(e,{ns:Fe});function Ls(){const e=s.useAPIClient(),t=A.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=oe.useNavigate(),l=A.useFieldSchema(),d=A.useField(),c=s.useCompile(),{modal:p}=b.App.useApp(),u=s.useCollectValuesToSubmit(),g=d.componentProps.filterKeys||[];return{onClick(){return E(this,null,function*(){var T,I,O;const{onSuccess:x,skipValidator:h,triggerWorkflows:C}=(T=l==null?void 0:l["x-action-settings"])!=null?T:{};h||(yield t.submit());const k=yield u();d.data=o.data||{},d.data.loading=!0;try{const V=yield e.resource("workflows").trigger({values:k,filterKeys:g,triggerWorkflows:C!=null&&C.length?C.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.loading=!1,d.data.data=V,(O=(I=n==null?void 0:n.service)==null?void 0:I.refresh)==null||O.call(I),a==null||a(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?p.success({title:c(x==null?void 0:x.successMessage),onOk:()=>E(this,null,function*(){yield t.reset(),x!=null&&x.redirecting&&(x!=null&&x.redirectTo)&&(B.isURL(x.redirectTo)?window.location.href=x.redirectTo:i(x.redirectTo))})}):b.message.success(c(x==null?void 0:x.successMessage))}catch(V){d.data.loading=!1}})}}}function qs(){var y;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=A.useField(),a=A.useFieldSchema(),{field:i,__parent:l}=s.useBlockRequestContext(),{setVisible:d}=s.useActionContext(),{modal:c}=b.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:g}=(y=a==null?void 0:a["x-action-settings"])!=null?y:{};return{onClick(){return E(this,null,function*(){var h,C;n.data=i.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:g!=null&&g.length?g.map(k=>[k.workflowKey,k.context].filter(Boolean).join("!")).join(","):void 0}),(C=(h=l==null?void 0:l.service)==null?void 0:h.refresh)==null||C.call(h),d==null||d(!1),!(u!=null&&u.successMessage))return;if(u!=null&&u.manualClose){let k;c.success({title:e(u==null?void 0:u.successMessage),onOk(){return E(this,null,function*(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(B.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))})}})}else b.message.success(e(u==null?void 0:u.successMessage))}catch(k){console.error(k)}finally{n.data.loading=!1}})}}}const Us=()=>{const e=Jt(),t=ve.ArrayItems.useArray()||{field:[]},{t:o}=_e(),[n,a]=v.useState(!1),i=v.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=v.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:a,content:r.jsx(Ks,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Ks=({onSlecet:e,onQuery:t})=>{const{t:o}=_e();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Gs=e=>{const{t}=_e(),[o,n]=v.useState(!1),a=v.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},_s=e=>e.value&&typeof e.value=="object"?r.jsx(Js,w({},e)):r.jsx(Hs,w({},e)),Hs=({value:e,onChange:t})=>{const o=ce({types:[Ys]});return r.jsx(s.Variable.Input,{scope:o,value:e,onChange:t,children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:t})})},Js=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Oe}}}}})})};function Ys(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const Qs=()=>{var c;const{workflow:e}=L(),[t,o]=s.parseCollectionName((c=e.config)==null?void 0:c.collection),n=s.useSchemaInitializerItem(),{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),d=u=>E(this,[u],function*({item:p}){const g=p.template?yield i(p):null,y=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:g,settings:"blockSettings:details"});ge.unset(y,["x-acl-action","x-acl-action-props"]);const[x]=Object.keys(y.properties);ge.set(y.properties[x],"x-component-props.useProps","usePropsNoticeDetail"),a(y)});return r.jsx(s.SchemaInitializerItem,F(w({},n),{onClick:d,items:l}))},Zs=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:se("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Qs}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var d;const e=s.usePlugin(Z),{workflow:t}=L(),o=Xe(),n=ye(),a=$e(n),i=[(d=o.useInitializers)==null?void 0:d.call(o,t.config)].filter(Boolean),l=a.map(c=>{var u;const p=e.instructions.get(c.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,c)}).filter(Boolean);return[...i,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class Xs extends s.Plugin{load(){return E(this,null,function*(){this.app.schemaInitializerManager.add(Zs)})}}function Rs(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const ea=e=>{const{schemaData:t,loading:o,handleChange:n}=ta(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function ta(e){const{value:t,onChange:o}=e,n=s.useAPIClient();A.useForm();const{data:a,loading:i}=s.useRequest(()=>E(this,null,function*(){if(t){const p=yield oa(n,t);if(p["x-uid"]===t)return p}const d=t!=null?t:B.uid(),c=Rs(d);return yield na(n,c),o(d),c}));return{schemaData:a,loading:i,handleChange:d=>{}}}function oa(e,t){return E(this,null,function*(){var a;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(a=o.data)!=null?a:{}})}function na(e,t){return E(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const ra={ActionStyle:s.css`
|
|
475
475
|
.ant-drawer-body {
|
|
476
476
|
background: var(--tb-box-bg);
|
|
477
477
|
}
|
|
478
|
-
`},
|
|
478
|
+
`},sa=()=>{const e=v.useContext(s.SchemaComponentContext),[,t]=v.useState(B.uid()),{workflow:o}=L(),n=v.useMemo(()=>F(w({},e),{refresh:()=>t(B.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:ea},schema:aa})})},aa={name:"drawer",type:"void",title:se("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:ra.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const qo={ArrayItemsStyle:s.css`
|
|
479
479
|
&[disabled] {
|
|
480
480
|
> .ant-formily-array-base-addition {
|
|
481
481
|
display: none;
|
|
@@ -492,19 +492,19 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:D("P
|
|
|
492
492
|
> .ant-space-item:nth-child(2) {
|
|
493
493
|
flex-grow: 1;
|
|
494
494
|
}
|
|
495
|
-
`};class
|
|
495
|
+
`};class ia extends Q{constructor(){super(...arguments);f(this,"title",se("Notice"));f(this,"type",Lo);f(this,"group",Ge);f(this,"icon","MessageOutlined");f(this,"color","#82e29c");f(this,"description",se("In the workflow, notification messages can be viewed by the notified person in the notification center."));f(this,"components",{ArrayItems:ve.ArrayItems,SelectNotifiedPerson:_s,AdditionNotifiedPerson:Us,ConfigButtonNotice:Gs,ShowNoticeDetail:sa});f(this,"fieldset",{notifiedPerson:{type:"array",title:se("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:qo.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:qo.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:se("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:se("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}})}isAvailable(o){return!0}}class la extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(Xs)})}load(){return E(this,null,function*(){this.app.pm.get(Z).registerInstruction(Lo,ia),this.app.addComponents({ArrayItems:ve.ArrayItems})})}}const ca={title:se("Node"),name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},da=A.observer(()=>{const{value:e}=A.useField(),t=s.useRecord();return r.jsx(pa,{value:e,record:t})},{displayName:"ColumnStatus"}),pa=e=>{const{value:t,record:o}=e,n=ge.omit(e,["value","record"]),a=s.useCompile(),{t:i}=_e(),{option:l=ua[t]}=n,{workflow:d,execution:c,job:p}=o!=null?o:{};return(!(d!=null&&d.enabled)||c!=null&&c.stauts||p!=null&&p.status)&&[].includes(t)?r.jsx(b.Tag,{children:i("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:a(l==null?void 0:l.label)})},Uo=[{value:pe.QUEUEING,label:`{{t("Assigned", { ns: "${Fe}" })}}`,color:"blue"},{value:pe.STARTED,label:`{{t("Pending", { ns: "${Fe}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${Fe}" })}}`,color:"green"},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${Fe}" })}}`,color:"red"}],ua=Uo.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ma={title:se("Notice Center"),name:Qt,fields:[{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:se("The Notified Person"),"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task node", { ns: "${Fe}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:Uo}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${Fe}" })}}`}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{type:"string",name:"summary",interface:"input",uiSchema:{type:"string",title:se("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},fa={title:se("Workflow"),name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"select",uiSchema:{type:"boolean",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:[{label:'{{t("On", { ns: "workflow" })}}',value:!0},{label:'{{t("Off", { ns: "workflow" })}}',value:!1}]}}]},ga=o=>{var n=o,{children:e}=n,t=G(n,["children"]);const{collection:a,params:i={filter:{}},action:l="list"}=t,d=s.useRecord(),c={collection:a,resource:a,action:l,params:F(w({pageSize:20,sort:["-createdAt"]},i),{filter:d!=null&&d.id?w({dataKey:`${d.id}`},i.filter):w({},i.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[fa,ca,ma],children:r.jsx(s.TableBlockProvider,F(w({name:a},c),{children:e}))})},Ko=v.createContext({}),ya=Ko.Provider;function ha(){return v.useContext(Ko)}const Go=v.createContext({}),xa=Go.Provider;function ba(){return v.useContext(Go)}function va(){const{snapshot:e}=ba(),{form:t}=s.useFormBlockContext();return v.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function _o({children:e,workflow:t,execution:o,nodes:n}){const a=s.usePlugin(Z),i=a.triggers.get(t.type).components,l=n.reduce((d,{type:c})=>{var p;return Object.assign(d,(p=a.instructions.get(c))==null?void 0:p.components)},{});return r.jsx(Ue.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:w(w({},i),l),children:e})})}const Ho=o=>{var n=o,{children:e}=n,t=G(n,["children"]);const a=s.useSchemaComponentContext(),{t:i}=_e(),{id:l}=s.useCollectionRecordData(),{loading:d,data:c}=wa(l);if(d)return r.jsx(b.Spin,{});if(!(c!=null&&c.data))return r.jsx(b.Result,{status:"error",title:i("Submission may be withdrawn, please try refresh the list.")});const p=c.data,{node:u,workflow:g,execution:y}=p,x=u==null?void 0:u.config.showNoticeDetail,{designable:h}=t;return r.jsx(_o,{workflow:g,nodes:g.nodes,execution:y,children:r.jsx(xa,{value:p,children:r.jsx(ya,{value:{id:l,schemaId:x},children:r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},a),{designable:h}),children:e})})})})};function wa(e){const{loading:t,data:o}=s.useRequest({resource:Qt,action:"get",params:{filterByTk:e,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs","user"],except:["workflow.config","workflow.options","nodes.config"],sort:["-createdAt"]}},{refreshDeps:[e]});return{loading:t,data:o}}const Ca=()=>r.jsx(Ho,{children:r.jsx(ka,{})}),ka=e=>{const{id:t,schemaId:o}=ha();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:Ho,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:zt},scope:{usePropsNoticeDetail:va,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:se("Content Detail"),"x-component":"Tabs.TabPane",properties:{detail:{type:"void","x-decorator":"NoticeDetailProvider","x-decorator-props":{designable:!1},"x-component":"RemoteSchemaComponent","x-component-props":{uid:o,noForm:!0}}}}}}})},Sa=({record:e})=>{const{id:t}=e;return{name:`notice-view-${t}`,type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{content:{type:"void","x-component":"NoticeDetailContent"}}}}}},Aa=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:Ca},schema:Sa({record:e})})},Ia=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),Fa=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),Ta=A.observer(()=>{const{t:e}=_e(),{value:t}=A.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
|
|
496
496
|
text-decoration: line-through;
|
|
497
|
-
`,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),
|
|
497
|
+
`,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),Na={ActionbarStyle:s.css`
|
|
498
498
|
margin-bottom: 16px;
|
|
499
499
|
`,TableV2Style:s.css`
|
|
500
500
|
.ant-table-cell {
|
|
501
501
|
text-align: center;
|
|
502
502
|
}
|
|
503
|
-
`},
|
|
503
|
+
`},Da=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:Ia,ColumnWorkflow:Ta,ColumnUser:Fa,ColumnStatus:da,ColumnAction:Aa},schema:Oa}),Oa={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:Na.ActionbarStyle},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",tableLayout:"fixed",className:s.css`
|
|
504
504
|
.ant-table-cell {
|
|
505
505
|
text-align: center;
|
|
506
506
|
}
|
|
507
|
-
`},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:se("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:se("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:se("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Fe}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Pa extends s.Plugin{load(){return E(this,null,function*(){this.app.addComponents({NoticeBlockProvider:fa,NoticeCenter:Na})})}}function Jo(){const e=B.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Qt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Oa=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=v.useCallback(()=>{const n=Jo();e(n)},[e,Jo]);return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:o}))};class Ea extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(Pa)})}load(){return E(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Oa}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:se("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Ma extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(ia),yield this.app.pm.add(Ea)})}}class $a extends Ze{constructor(){super(...arguments);f(this,"title",D("General event"));f(this,"description",D("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."));f(this,"fieldset",{bindCollection:{type:"boolean",title:D("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:D("Yes"),value:!0},{label:D("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:D("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:D("Associations to use"),description:D("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var n;return(n=A.useForm().values)==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{});f(this,"isActionTriggerable",(o,n={})=>{const{buttonAction:a}=n;return[a==="customize:triggerWorkflows",a==="submit"].some(d=>d===!0)})}useVariables(o,n){var d;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=me(F(w({appends:["user"]},n),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User acted")}}],compile:a,getCollectionFields:i}));return[...me({appends:["data",...((d=o.appends)==null?void 0:d.map(c=>`data.${c}`))||[]],fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}],compile:a,getCollectionFields:i}),...l,{label:N("Role of user acted"),value:"roleName"}]}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:D("Trigger data"),Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const Ba=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,F(w({},e),{schema:Va,item:e}))},Va={type:"void",title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},ja=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Wa=new s.SchemaSettings({name:"actionSettings:APIRegular",items:ja}),za=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),a=A.useFieldSchema(),i=v.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:d}=l,{t:c}=R.useTranslation();oe.useNavigate(),s.useCompile();const p=A.useField(),{modal:u,notification:g}=b.App.useApp(),y=s.useVariables(),{name:x,getField:h}=s.useCollection_deprecated(),C=s.useLocalVariables(),{run:k}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",I=>{I.msg==="start"?g.info({key:"workflow:regular",message:c("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0}):I.msg==="progress"?g.info({key:"workflow:regular",message:c("Processing..."),description:r.jsx(b.Progress,{percent:Math.floor(I.current/I.total*100)}),duration:0}):I.msg==="done"&&(g.success({key:"workflow:regular",message:c("Done"),description:r.jsx(b.Progress,{percent:100})}),n.refresh())}),{onClick(){return E(this,null,function*(){var Y,ae,W,q,K,ie,X;const I=(q=(W=(ae=(Y=l.field)==null?void 0:Y.data)==null?void 0:ae.selectedRowKeys)!=null?W:i==null?void 0:i.selectedRecordKeys)!=null?q:[],{filter:P}=(ie=(K=n.params)==null?void 0:K[0])!=null?ie:{},{bindWorkflow:V=!1,triggerWorkflows:$=!1,assignedValues:O={},updateMode:j}=(X=a==null?void 0:a["x-action-settings"])!=null?X:{},H=j==="selected",M={primaryKey:d||"id",targetKeys:I};if(p.data=e.data||{},p.data.loading=!0,!$&&!V)return u.info({title:N("Not bind workflow!")});const _=Object.keys(O).map(J=>E(this,null,function*(){const re=O[J],qe=h(J);if(s.isVariable(re)){const be=yield y==null?void 0:y.parseVariable(re,C);be&&s.transformVariableValue(be,{targetCollectionField:qe})}}));yield Promise.all(_),u.confirm({title:N("Confirm",{ns:"core"}),content:N("Trigger workflow?",{ns:"core"}),onOk(){return E(this,null,function*(){if(V){const J={filterByTk:V,updateData:encodeURIComponent(JSON.stringify(M))};k(J)}else $&&(H?yield t.trigger({filterByTk:I,triggerWorkflows:$&&$.length>0?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):[]}):yield t.trigger({filter:P,triggerWorkflows:$&&$.length>0?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):[]}));p.data.loading=!1})},onCancel(){return E(this,null,function*(){p.data.loading=!1})}})})}}};class La extends s.Plugin{load(){return E(this,null,function*(){this.app.addComponents({APIRegularInitializer:Ba}),this.app.addScopes({usePropsAPIRegular:za}),this.app.schemaSettingsManager.add(Wa),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:D("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function qa(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=s.useFilterByTk(),l=oe.useNavigate(),d=A.useFieldSchema(),c=A.useField(),p=s.useCompile(),{modal:u}=b.App.useApp(),g=s.useCollectValuesToSubmit();return c.componentProps.filterKeys,{onClick(){return E(this,null,function*(){var T,I;const{onSuccess:x,skipValidator:h,triggerWorkflows:C}=(d==null?void 0:d["x-action-settings"])||{};h||(yield e.submit());const k=yield g();c.data=t.data||{},c.data.loading=!0;try{const P=yield n.trigger({values:k,filterByTk:i,triggerWorkflows:C!=null&&C.length?C.map(V=>[V.workflowKey,V.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.data=P,(I=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||I.call(T),a==null||a(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?u.success({title:p(x==null?void 0:x.successMessage),onOk:()=>E(this,null,function*(){return yield e.reset(),(x==null?void 0:x.redirecting)&&(x==null?void 0:x.redirectTo)&&(B.isURL(x.redirectTo)?window.location.href=x.redirectTo:l(x.redirectTo))})}):b.message.success(p(x==null?void 0:x.successMessage))}catch(P){console.error(P)}finally{c.data.loading=!1}})}}}function Ua(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:a,resource:i}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:d}=s.useActionContext(),{modal:c}=b.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:g}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(x,h){return E(this,null,function*(){o.data=a.data||{},o.data.loading=!0;try{if(yield i.trigger({filterByTk:t,triggerWorkflows:g!=null&&g.length?g.map(C=>[C.workflowKey,C.context].filter(Boolean).join("!")).join(","):void 0}),h==null||h(),l==null||l(!1),d==null||d(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?c.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(B.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):b.message.success(e(u==null?void 0:u.successMessage))}catch(C){console.error(C)}finally{o.data.loading=!1}})}}}const Zt={name:"triggerWorkflow",title:D("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:D("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},wt={name:"triggerWorkflow",title:D("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:D("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Xt=F(w({},wt),{schema:F(w({},wt.schema),{"x-component":"Action.Link"})});class Ka extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(La)})}load(){return E(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",$a),this.app.addScopes({useFormWorkflowCustomActionProps:qa,useRecordWorkflowCustomTriggerActionProps:Ua}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",wt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",wt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Xt)})}}class Ga extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Parallel branch", { ns: "${m}" })}}`);f(this,"type","parallel");f(this,"group","control");f(this,"icon","MergeOutlined");f(this,"color","#6e93e8");f(this,"description",`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`);f(this,"fieldset",{mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"}});f(this,"components",{RadioWithTooltip:Oe})}Component({data:o}){const{styles:n}=he(),{id:a,config:{mode:i}}=o,{workflow:l,nodes:d}=L(),c=d.reduce((C,k)=>k.upstreamId===a&&k.branchIndex!=null?C.concat(k):C,[]).sort((C,k)=>C.branchIndex-k.branchIndex),[p,u]=v.useState(Math.max(2,c.length)),{getAriaLabel:g}=pt(o),y=N("Add branch"),x=Array(Math.max(0,p-c.length)).fill(null),h=c[c.length-1];return r.jsx(rt,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(C=>r.jsx(Be,{from:o,entry:C,branchIndex:C.branchIndex},C.id)),x.map((C,k)=>r.jsx(Be,{from:o,branchIndex:(h?h.branchIndex:0)+k+1,controller:c.length+k>1?r.jsx("div",{className:s.css`
|
|
507
|
+
`},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:se("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:se("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:se("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Fe}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Pa extends s.Plugin{load(){return E(this,null,function*(){this.app.addComponents({NoticeBlockProvider:ga,NoticeCenter:Da})})}}function Jo(){const e=B.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Qt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Ea=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=v.useCallback(()=>{const n=Jo();e(n)},[e,Jo]);return r.jsx(s.SchemaInitializerItem,F(w({},t),{onClick:o}))};class Ma extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(Pa)})}load(){return E(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Ea}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:se("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class $a extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(la),yield this.app.pm.add(Ma)})}}class Ba extends Ze{constructor(){super(...arguments);f(this,"title",D("General event"));f(this,"description",D("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."));f(this,"fieldset",{bindCollection:{type:"boolean",title:D("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:D("Yes"),value:!0},{label:D("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:D("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:D("Associations to use"),description:D("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var n;return(n=A.useForm().values)==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{});f(this,"isActionTriggerable",(o,n={})=>{const{buttonAction:a}=n;return[a==="customize:triggerWorkflows",a==="submit"].some(d=>d===!0)})}useVariables(o,n){var d;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=me(F(w({appends:["user"]},n),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User acted")}}],compile:a,getCollectionFields:i}));return[...me({appends:["data",...((d=o.appends)==null?void 0:d.map(c=>`data.${c}`))||[]],fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}],compile:a,getCollectionFields:i}),...l,{label:N("Role of user acted"),value:"roleName"}]}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:D("Trigger data"),Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const Va=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,F(w({},e),{schema:ja,item:e}))},ja={type:"void",title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},Wa=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],za=new s.SchemaSettings({name:"actionSettings:APIRegular",items:Wa}),La=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),a=A.useFieldSchema(),i=v.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:d}=l,{t:c}=R.useTranslation();oe.useNavigate(),s.useCompile();const p=A.useField(),{modal:u,notification:g}=b.App.useApp(),y=s.useVariables(),{name:x,getField:h}=s.useCollection_deprecated(),C=s.useLocalVariables(),{run:k}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",I=>{I.msg==="start"?g.info({key:"workflow:regular",message:c("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0}):I.msg==="progress"?g.info({key:"workflow:regular",message:c("Processing..."),description:r.jsx(b.Progress,{percent:Math.floor(I.current/I.total*100)}),duration:0}):I.msg==="done"&&(g.success({key:"workflow:regular",message:c("Done"),description:r.jsx(b.Progress,{percent:100})}),n.refresh())}),{onClick(){return E(this,null,function*(){var Y,ae,W,q,K,ie,X;const I=(q=(W=(ae=(Y=l.field)==null?void 0:Y.data)==null?void 0:ae.selectedRowKeys)!=null?W:i==null?void 0:i.selectedRecordKeys)!=null?q:[],{filter:O}=(ie=(K=n.params)==null?void 0:K[0])!=null?ie:{},{bindWorkflow:V=!1,triggerWorkflows:$=!1,assignedValues:P={},updateMode:j}=(X=a==null?void 0:a["x-action-settings"])!=null?X:{},H=j==="selected",M={primaryKey:d||"id",targetKeys:I};if(p.data=e.data||{},p.data.loading=!0,!$&&!V)return u.info({title:N("Not bind workflow!")});const _=Object.keys(P).map(J=>E(this,null,function*(){const re=P[J],qe=h(J);if(s.isVariable(re)){const be=yield y==null?void 0:y.parseVariable(re,C);be&&s.transformVariableValue(be,{targetCollectionField:qe})}}));yield Promise.all(_),u.confirm({title:N("Confirm",{ns:"core"}),content:N("Trigger workflow?",{ns:"core"}),onOk(){return E(this,null,function*(){if(V){const J={filterByTk:V,updateData:encodeURIComponent(JSON.stringify(M))};k(J)}else $&&(H?yield t.trigger({filterByTk:I,triggerWorkflows:$&&$.length>0?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):[]}):yield t.trigger({filter:O,triggerWorkflows:$&&$.length>0?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):[]}));p.data.loading=!1})},onCancel(){return E(this,null,function*(){p.data.loading=!1})}})})}}};class qa extends s.Plugin{load(){return E(this,null,function*(){this.app.addComponents({APIRegularInitializer:Va}),this.app.addScopes({usePropsAPIRegular:La}),this.app.schemaSettingsManager.add(za),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:D("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function Ua(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=s.useFilterByTk(),l=oe.useNavigate(),d=A.useFieldSchema(),c=A.useField(),p=s.useCompile(),{modal:u}=b.App.useApp(),g=s.useCollectValuesToSubmit();return c.componentProps.filterKeys,{onClick(){return E(this,null,function*(){var T,I;const{onSuccess:x,skipValidator:h,triggerWorkflows:C}=(d==null?void 0:d["x-action-settings"])||{};h||(yield e.submit());const k=yield g();c.data=t.data||{},c.data.loading=!0;try{const O=yield n.trigger({values:k,filterByTk:i,triggerWorkflows:C!=null&&C.length?C.map(V=>[V.workflowKey,V.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.data=O,(I=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||I.call(T),a==null||a(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?u.success({title:p(x==null?void 0:x.successMessage),onOk:()=>E(this,null,function*(){return yield e.reset(),(x==null?void 0:x.redirecting)&&(x==null?void 0:x.redirectTo)&&(B.isURL(x.redirectTo)?window.location.href=x.redirectTo:l(x.redirectTo))})}):b.message.success(p(x==null?void 0:x.successMessage))}catch(O){console.error(O)}finally{c.data.loading=!1}})}}}function Ka(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:a,resource:i}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:d}=s.useActionContext(),{modal:c}=b.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:g}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(x,h){return E(this,null,function*(){o.data=a.data||{},o.data.loading=!0;try{if(yield i.trigger({filterByTk:t,triggerWorkflows:g!=null&&g.length?g.map(C=>[C.workflowKey,C.context].filter(Boolean).join("!")).join(","):void 0}),h==null||h(),l==null||l(!1),d==null||d(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?c.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(B.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):b.message.success(e(u==null?void 0:u.successMessage))}catch(C){console.error(C)}finally{o.data.loading=!1}})}}}const Zt={name:"triggerWorkflow",title:D("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:D("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},wt={name:"triggerWorkflow",title:D("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:D("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:D("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Xt=F(w({},wt),{schema:F(w({},wt.schema),{"x-component":"Action.Link"})});class Ga extends s.Plugin{afterAdd(){return E(this,null,function*(){yield this.app.pm.add(qa)})}load(){return E(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Ba),this.app.addScopes({useFormWorkflowCustomActionProps:Ua,useRecordWorkflowCustomTriggerActionProps:Ka}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",wt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",wt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Xt)})}}class _a extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Parallel branch", { ns: "${m}" })}}`);f(this,"type","parallel");f(this,"group","control");f(this,"icon","MergeOutlined");f(this,"color","#6e93e8");f(this,"description",`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`);f(this,"fieldset",{mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"}});f(this,"components",{RadioWithTooltip:Pe})}Component({data:o}){const{styles:n}=he(),{id:a,config:{mode:i}}=o,{workflow:l,nodes:d}=L(),c=d.reduce((C,k)=>k.upstreamId===a&&k.branchIndex!=null?C.concat(k):C,[]).sort((C,k)=>C.branchIndex-k.branchIndex),[p,u]=v.useState(Math.max(2,c.length)),{getAriaLabel:g}=pt(o),y=N("Add branch"),x=Array(Math.max(0,p-c.length)).fill(null),h=c[c.length-1];return r.jsx(rt,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(C=>r.jsx(Be,{from:o,entry:C,branchIndex:C.branchIndex},C.id)),x.map((C,k)=>r.jsx(Be,{from:o,branchIndex:(h?h.branchIndex:0)+k+1,controller:c.length+k>1?r.jsx("div",{className:s.css`
|
|
508
508
|
padding-top: 2em;
|
|
509
509
|
|
|
510
510
|
> button {
|
|
@@ -524,7 +524,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:D("P
|
|
|
524
524
|
transform-origin: center;
|
|
525
525
|
transform: rotate(-45deg);
|
|
526
526
|
}
|
|
527
|
-
`,onClick:()=>u(p+1),disabled:l.executed})})]})})}}class
|
|
527
|
+
`,onClick:()=>u(p+1),disabled:l.executed})})]})})}}class Ha extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get(Z).registerInstruction("parallel",_a)})}}class Ja extends Q{constructor(){super(...arguments);f(this,"title",`{{t("HTTP request", { ns: "${m}" })}}`);f(this,"type","request");f(this,"group","extended");f(this,"icon","ApiOutlined");f(this,"color","#e1ed5b");f(this,"description",`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`);f(this,"fieldset",{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},comment:{type:"string",title:`{{t("Comment", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input body comment", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}});f(this,"components",{ArrayItems:ve.ArrayItems,WorkflowVariableInput:Se,WorkflowVariableTextArea:nt,WorkflowVariableJSON:Io})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return{[i.value]:o,[i.label]:n}}}class Ya extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Ja)})}}class Qa extends Q{constructor(){super(...arguments);f(this,"title",D("Response message"));f(this,"type","response-message");f(this,"group","extended");f(this,"icon","SunOutlined");f(this,"color","#07d629");f(this,"description",D("Add response message, will be send to client when process of request ends."));f(this,"fieldset",{message:{type:"string",title:D("Message content"),description:D("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"}});f(this,"scope",{});f(this,"components",{RadioWithTooltip:Pe,WorkflowVariableTextArea:nt,WorkflowVariableInput:Se})}isAvailable({workflow:o}){return o.type==="request-interception"||["action","general-action"].includes(o.type)&&o.sync}}class Za extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Qa)})}}class Xa extends Q{constructor(){super(...arguments);f(this,"title",D("Data Mapping"));f(this,"type",fo);f(this,"group","extended");f(this,"icon","FunctionOutlined");f(this,"color","#d93a13");f(this,"isHot",!0);f(this,"description",D("Get specific data from JSON result of any node BY js code or json code;"));f(this,"fieldset",{sourceArray:{type:"array",title:D("Data source map"),description:D("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:D("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:D("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
|
|
528
528
|
> *:not(:last-child) {
|
|
529
529
|
margin-right: 0.5em;
|
|
530
530
|
}
|
|
@@ -553,23 +553,23 @@ export default async function (
|
|
|
553
553
|
button {
|
|
554
554
|
padding: 0;
|
|
555
555
|
}
|
|
556
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}}class
|
|
556
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:D("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}});f(this,"components",{ArrayTable:ve.ArrayTable,WorkflowVariableInput:Se})}useVariables(o,n){const{key:a,title:i,config:l}=o,{types:d,fieldNames:c}=n,p=l.model||[];return{[c.label]:i,[c.value]:a,[c.children]:p.map(g=>({[c.label]:g.label,[c.value]:g.alias||g.path}))}}}class Ra extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get(Z).registerInstruction(fo,Xa)})}}class ei extends Q{constructor(){super(...arguments);f(this,"title",`{{t("SQL action", { ns: "${m}" })}}`);f(this,"type","sql");f(this,"group","collection");f(this,"icon","ConsoleSqlOutlined");f(this,"color","#e9bf36");f(this,"description",`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`);f(this,"fieldset",{dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(o){return o.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
|
|
557
557
|
font-size: 80%;
|
|
558
558
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
559
|
-
`}}});f(this,"components",{WorkflowVariableRawTextArea:Ao})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return{[i.value]:o,[i.label]:n}}}class
|
|
559
|
+
`}}});f(this,"components",{WorkflowVariableRawTextArea:Ao})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return{[i.value]:o,[i.label]:n}}}class ti extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",ei)})}}const oi=()=>{const{workflow:e}=L();return{parentSync:e==null?void 0:e.sync,parentKey:e==null?void 0:e.key}};class ni extends Q{constructor(){super(...arguments);f(this,"title",D("Workflow"));f(this,"type","trigger-instruction");f(this,"group","extended");f(this,"icon","NodeIndexOutlined");f(this,"color","#0a72e9");f(this,"fieldset",{workflowKey:{type:"string",title:D("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":oi,required:!0},bindCollection:{type:"boolean",title:D("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:D("Yes"),value:!0},{label:D("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:D("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:D("Associations to use"),description:D("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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var n;return(n=A.useForm().values)==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}})}useVariables({key:o,title:n,config:a},i){var p,u;const l=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),[c]=me(F(w({appends:[o,...((u=(p=a.params)==null?void 0:p.appends)==null?void 0:u.map(g=>`${o}.${g}`))||[]]},i),{fields:[{collectionName:a.collection,name:o,type:"hasOne",target:a.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:d}));return c}}class ri extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",ni)})}}const si=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
|
|
560
560
|
color: ${t.colorTextDescription};
|
|
561
561
|
|
|
562
562
|
&:before {
|
|
563
563
|
content: '#';
|
|
564
564
|
}
|
|
565
|
-
`}));function
|
|
565
|
+
`}));function ai({value:e,onChange:t}){const o=e==null,n=ye(),a=$e(n,c=>c.type==="variable"&&!c.config.target),{styles:i}=si(),l=v.useCallback(({target:c})=>{if(c.value)return t(null);a.length&&t(a[0].key)},[t,a]),d=v.useCallback((c,p)=>p.label.toLowerCase().indexOf(c.toLowerCase())>=0||`#${p.data.id}`.indexOf(c)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:N("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!a.length,children:N("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:a.map(c=>({label:c.title,value:c.key,data:c})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:d,optionRender:({label:c,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:c}),r.jsx("span",{className:i.nodeIdClass,children:p.data.id})]})})]})]})})})}class ii extends Q{constructor(){super(...arguments);f(this,"title",D("Variable"));f(this,"type","variable");f(this,"group","control");f(this,"icon","StrikethroughOutlined");f(this,"color","#a35ae8");f(this,"description",D("Assign value to a variable, for later use."));f(this,"fieldset",{target:{type:"string",title:D("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:D("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{WorkflowVariableInput:Se,VariableTargetSelect:ai})}useVariables({key:o,title:n,config:a},{types:i,fieldNames:l=ue}){return a.target?null:{[l.value]:o,[l.label]:n}}}class li extends s.Plugin{load(){return E(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",ii)})}}const Yo=e=>{const t=Qe.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
|
|
566
566
|
&:after {
|
|
567
567
|
content: ':';
|
|
568
568
|
}
|
|
569
569
|
& + a {
|
|
570
570
|
margin-left: 0.25em;
|
|
571
571
|
}
|
|
572
|
-
`,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class
|
|
572
|
+
`,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class ci extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Calculation", { ns: "${m}" })}}`);f(this,"type","calculation");f(this,"group","control");f(this,"icon","PlusOutlined");f(this,"color","#c3e584");f(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`);f(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Qe.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:a}){const{values:i}=a,{evaluate:l}=Qe.evaluators.get(i.engine),d=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(d),""}catch(c){return N("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]}});f(this,"scope",{renderEngineReference:Yo});f(this,"components",{WorkflowVariableTextArea:nt,RadioWithTooltip:Pe,ValueBlock:Ae})}useVariables({key:o,title:n},{types:a,fieldNames:i=ue}){return a&&!a.some(l=>l in De||Object.values(De).some(d=>d.has(l)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var n,a;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ae.Initializer,node:o,resultTitle:N("Calculation result")}}}const di=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:a,children:i}=e,[l,d]=v.useState(!1),c=v.useMemo(()=>{const u=ge.cloneDeep(n.config);return A.createForm({initialValues:u,disabled:a.executed})},[n,a]),p=v.useCallback(u=>{o(u),u||c.reset()},[c]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:d},children:r.jsx(s.FormProvider,{form:c,children:i})})};function pi(){return{form:A.useForm()}}function ui(){const e=A.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),a=ye(),{workflow:i}=L();return{run(){return E(this,null,function*(){var d,c;if(i.executed){b.message.error(N("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(c=(d=t.resource("flow_nodes")).update)==null?void 0:c.call(d,{filterByTk:a.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const mi=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ge;return r.jsxs("div",{className:s.css`
|
|
573
573
|
display: flex;
|
|
574
574
|
justify-content: space-between;
|
|
575
575
|
|
|
@@ -584,7 +584,7 @@ export default async function (
|
|
|
584
584
|
code {
|
|
585
585
|
font-weight: normal;
|
|
586
586
|
}
|
|
587
|
-
`,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",N("Deprecated"),") "]}),t.title]}),r.
|
|
587
|
+
`,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",N("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:N("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function fi(e,t){return r.jsx(mi,{data:e,instruction:t})}const gi=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e;return{type:"void",properties:F(w({},t.view?{view:t.view}:{}),{button:{type:"void","x-content":n,"x-component":"Button","x-component-props":{type:"link",className:"workflow-node-config-button"}},[o.id]:{type:"void",title:fi(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area",properties:F(w({},t.description?{description:{type:"void","x-component":po,"x-component-props":{label:N("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
|
|
588
588
|
.ant-input,
|
|
589
589
|
.ant-select,
|
|
590
590
|
.ant-cascader-picker,
|
|
@@ -596,7 +596,7 @@ export default async function (
|
|
|
596
596
|
min-width: 6em;
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
-
`},properties:t.fieldset},actions:a.executed?null:{type:"void","x-component":"ActionArea.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:
|
|
599
|
+
`},properties:t.fieldset},actions:a.executed?null:{type:"void","x-component":"ActionArea.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:ui}}}}})}})}},yi=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e,i=gi({instruction:t,data:o,detailText:n,workflow:a});return r.jsx(s.SchemaComponent,{schema:i,components:t.components,scope:F(w({},t.scope),{useFormProviderProps:pi})})},hi=e=>{const{instruction:t,data:o,detailText:n,workflow:a,editingConfig:i,setEditingConfig:l}=e;return r.jsx(di,{editingConfig:i,setEditingConfig:l,data:o,workflow:a,children:r.jsx(yi,{instruction:t,data:o,detailText:n,workflow:a})})},xi=s.createStyles(({css:e,token:t})=>({nodeClass:e`
|
|
600
600
|
flex-shrink: 0;
|
|
601
601
|
display: flex;
|
|
602
602
|
flex-direction: column;
|
|
@@ -629,7 +629,7 @@ export default async function (
|
|
|
629
629
|
padding: 0;
|
|
630
630
|
display: none;
|
|
631
631
|
}
|
|
632
|
-
`})),
|
|
632
|
+
`})),bi=()=>{var d;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(d=L())!=null?d:{},a=ye();if(!t)return null;const i=e.resource("flow_nodes");function l(){return E(this,null,function*(){var c;yield(c=i.moveUp)==null?void 0:c.call(i,{filterByTk:a.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(z.HolderOutlined,{}),onClick:l})},vi=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
|
|
633
633
|
background-color: red;
|
|
634
634
|
max-height: 50vh;
|
|
635
635
|
overflow-y: auto;
|
|
@@ -651,7 +651,7 @@ export default async function (
|
|
|
651
651
|
display: inline-flex;
|
|
652
652
|
justify-content: center;
|
|
653
653
|
align-items: center;
|
|
654
|
-
`})),
|
|
654
|
+
`})),wi=()=>{var i;const{execution:e,setViewJob:t}=L(),{jobs:o}=(i=ye())!=null?i:{},{styles:n}=vi();if(!e)return null;if(!o.length)return r.jsx(Re,{className:n.nodeJobButtonClass,disabled:!0});const a=l=>{const{key:d}=l,c=o.find(p=>p.id===+d);t(c)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Re,{statusMap:et,status:l.status}),r.jsx("time",{children:B.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:a},children:r.jsx(Re,{statusMap:et,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Re,{statusMap:et,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},Ci=()=>{var p;const{t:e}=R.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:a}=(p=L())!=null?p:{},i=ye(),{modal:l}=b.App.useApp();if(!o)return null;const d=t.resource("flow_nodes");function c(){return E(this,null,function*(){function u(){return E(this,null,function*(){var h;yield(h=d.destroy)==null?void 0:h.call(d,{filterByTk:i.id}),a()})}const g=n.filter(h=>h===i?!1:B.parse(h.config).parameters.filter(({key:T})=>T.startsWith(`$jobsMapByNodeKey.${i.key}.`)||T===`$jobsMapByNodeKey.${i.key}`).length);if(g.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:g.map(h=>`#${h.id}`).join(", ")})});return}const x=!n.find(h=>h.upstream===i&&h.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:x,onOk:u})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(z.DeleteOutlined,{}),onClick:c})},ki=s.createStyles(({css:e,token:t})=>({nodePoint:e`
|
|
655
655
|
position: relative;
|
|
656
656
|
display: flex;
|
|
657
657
|
flex-direction: row;
|
|
@@ -775,16 +775,16 @@ export default async function (
|
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
`})),
|
|
778
|
+
`})),Si=e=>{const{color:t,icon:o,workflow:n,editingTitle:a,configuring:i,setEditingTitle:l,onChangeTitle:d}=e,c=ye(),{styles:p}=ki(),[u,g]=v.useState(!1),y=n.executed||!u,x=(c==null?void 0:c.group)===Ge,h=()=>{i&&g(!0)},C=k=>{d(k.target.value),g(!1)};return r.jsxs("div",{className:s.cx(p.nodePoint,{deprecated:x,configuring:i}),children:[r.jsx(Ai,{color:t,icon:o}),r.jsx(Oo,{className:`workflow-node-edit ${y?"node-executed":""}`,readOnly:y,value:a,onChange:k=>l(k.target.value),onBlur:C,onClick:h}),r.jsx(Ii,{isExecuted:n.executed})]})},Ai=e=>{const{color:t,icon:o}=e;return r.jsx("div",{className:"workflow-node-prefix",style:{backgroundColor:t},children:r.jsx(s.Icon,{type:o!=null?o:"dispatcher"})})},Ii=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(wi,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(Ci,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(bi,{})})]})})},rt=e=>{var V,$;const{data:t,children:o}=e,n=s.useCompile(),a=s.useAPIClient(),{workflow:i,refresh:l}=(V=L())!=null?V:{},{styles:d}=xi(),p=s.usePlugin(Z).instructions.get(t.type),u=i.executed?'{{t("View")}}':'{{t("Configure")}}',g=n(p.title),{color:y,icon:x}=p,[h,C]=v.useState(($=t.title)!=null?$:g),[k,T]=v.useState(!1),I=v.useCallback(function(P){return E(this,null,function*(){var H,M;const j=P||g;C(j),j!==t.title&&(yield(M=(H=a.resource("flow_nodes")).update)==null?void 0:M.call(H,{filterByTk:t.id,values:{title:j}}),l())})},[t]),O=v.useCallback(function(P){var H,M;if(P.target===P.currentTarget){T(!0);return}(M=(H=P.target)==null?void 0:H.classList)!=null&&M.contains("workflow-node-edit")&&T(!0);const j=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let _=P.target;_&&_!==P.currentTarget&&_!==document.documentElement;_=_.parentNode)if(Array.from(_.classList).some(Y=>j.has(Y))){T(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(d.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(d.nodeCardClass),role:"button","aria-label":`${g}-${h}`,onClick:O,children:[r.jsx(Si,{color:y,icon:x,workflow:i,editingTitle:h,configuring:k,setEditingTitle:C,onChangeTitle:I}),r.jsx(hi,{instruction:p,data:t,detailText:u,workflow:i,editingConfig:k,setEditingConfig:T})]}),o]})},ne=new B.Registry;ne.register("equal",{name:"=",type:"boolean",group:"boolean"}),ne.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ne.register("gt",{name:">",type:"boolean",group:"boolean"}),ne.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ne.register("lt",{name:"<",type:"boolean",group:"boolean"}),ne.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ne.register("add",{name:"+",type:"number",group:"number"}),ne.register("minus",{name:"-",type:"number",group:"number"}),ne.register("multiple",{name:"*",type:"number",group:"number"}),ne.register("divide",{name:"/",type:"number",group:"number"}),ne.register("mod",{name:"%",type:"number",group:"number"}),ne.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ne.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ne.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ne.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ne.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ne.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ne.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"});const Fi=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`}];function Qo(e){return Array.from(ne.getEntities()).filter(([t,o])=>o.group===e)}function Ti({calculator:e,operands:t=[],onChange:o}){const n=s.useCompile(),a=ce();return r.jsxs("fieldset",{className:s.css`
|
|
779
779
|
display: flex;
|
|
780
780
|
gap: 0.5em;
|
|
781
781
|
align-items: center;
|
|
782
782
|
flex-wrap: wrap;
|
|
783
|
-
`,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:a,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:
|
|
783
|
+
`,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:a,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Fi.filter(i=>!!Qo(i.value).length).map(i=>r.jsx(b.Select.OptGroup,{label:n(i.title),children:Qo(i.value).map(([l,{name:d}])=>r.jsx(b.Select.Option,{value:l,children:n(d)},l))},i.value))}),r.jsx(s.Variable.Input,{value:t[1],onChange:i=>o({calculator:e,operands:[t[0],i]}),scope:a,useTypedConstant:!0})]})}function Ni({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:a=[]}=e;return r.jsxs("div",{className:s.css`
|
|
784
784
|
display: flex;
|
|
785
785
|
position: relative;
|
|
786
786
|
margin: 0.5em 0;
|
|
787
|
-
`,children:[e.group?r.jsx(Zo,{value:e.group,onChange:i=>t(F(w({},e),{group:i}))}):r.jsx(
|
|
787
|
+
`,children:[e.group?r.jsx(Zo,{value:e.group,onChange:i=>t(F(w({},e),{group:i}))}):r.jsx(Ti,{operands:a,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(z.CloseCircleOutlined,{})})]})}function Zo({value:e,onChange:t}){const{t:o}=R.useTranslation(),{type:n="and",calculations:a=[]}=e;function i(){t(F(w({},e),{calculations:[...a,{not:!1,calculator:"equal"}]}))}function l(){t(F(w({},e),{calculations:[...a,{not:!1,group:{type:"and",calculations:[]}}]}))}function d(p){a.splice(p,1),t(F(w({},e),{calculations:[...a]}))}function c(p,u){a.splice(p,1,u),t(F(w({},e),{calculations:[...a]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
|
|
788
788
|
position: relative;
|
|
789
789
|
width: 100%;
|
|
790
790
|
.node-type-condition-group {
|
|
@@ -803,14 +803,14 @@ export default async function (
|
|
|
803
803
|
width: auto;
|
|
804
804
|
min-width: 6em;
|
|
805
805
|
}
|
|
806
|
-
`,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(F(w({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:a.map((p,u)=>r.jsx(
|
|
806
|
+
`,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(F(w({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:a.map((p,u)=>r.jsx(Ni,{value:p,onChange:c.bind(this,u),onRemove:()=>d(u)},`${p.calculator}_${u}`))}),r.jsxs("div",{className:s.css`
|
|
807
807
|
button {
|
|
808
808
|
padding: 0;
|
|
809
809
|
&:not(:last-child) {
|
|
810
810
|
margin-right: 1em;
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function
|
|
813
|
+
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Di({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Zo,{value:o.group,onChange:n=>t(F(w({},o),{group:n}))})}class Oi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Condition", { ns: "${m}" })}}`);f(this,"type","condition");f(this,"group","control");f(this,"icon","QuestionOutlined");f(this,"color","#1ab287");f(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`);f(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(Qe.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[n,a])=>o.concat(w({value:n},a)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(o,n,{form:a}){const{values:i}=a,{evaluate:l}=Qe.evaluators.get(i.engine),d=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(d),""}catch(c){return N("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});f(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);f(this,"scope",{renderEngineReference:Yo,useWorkflowVariableOptions:ce});f(this,"components",{CalculationConfig:Di,WorkflowVariableTextArea:nt,RadioWithTooltip:Pe})}Component({data:o}){const{t:n}=R.useTranslation(),{nodes:a}=L(),{styles:i}=he(),{id:l,config:{rejectOnFalse:d}}=o,c=a.find(u=>u.upstreamId===l&&u.branchIndex===1),p=a.find(u=>u.upstreamId===l&&u.branchIndex===0);return r.jsx(rt,{data:o,children:d?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Be,{from:o,entry:c,branchIndex:1}),r.jsx(Be,{from:o,entry:p,branchIndex:0})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:n("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:n("No")})]})]})})}}function Pi(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=A.useField(),n=o.segments[o.segments.length-1],{values:a}=A.useForm(),[i,l]=s.parseCollectionName(a==null?void 0:a.collection),d=t(l,i),{type:c}=d.find(g=>g.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(g){const y=g.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(c)?y:y.split(/[,\s]+/))}return r.jsx(b.Input,F(w({},e),{value:p,onChange:u}))}const Xo=A.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:a}=s.useToken(),{t:i}=R.useTranslation(),l=s.useCompile(),d=A.useForm(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),p=ce(),{values:u}=d,[g,y]=s.parseCollectionName(u==null?void 0:u.collection),x=c(y,g).filter(I=>I.uiSchema),h=n?x.filter(n.bind(u)):x,C=v.useMemo(()=>h.filter(I=>!e||!(I.name in e)),[h,e]),k=t||d.disabled,T=v.useMemo(()=>({onClick:({key:I})=>{o(F(w({},e),{[I]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(I=>{var O,V;return{key:I.name,label:l((V=(O=I.uiSchema)==null?void 0:O.title)!=null?V:I.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:s.css`
|
|
814
814
|
margin-top: 0.5em;
|
|
815
815
|
|
|
816
816
|
> .ant-formily-item {
|
|
@@ -820,22 +820,22 @@ export default async function (
|
|
|
820
820
|
line-height: 32px;
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
-
`,children:h.length?r.jsxs(s.CollectionProvider_deprecated,{name:y,dataSource:g,children:[h.filter(I=>e&&I.name in e).map(I=>{var V,$;const
|
|
823
|
+
`,children:h.length?r.jsxs(s.CollectionProvider_deprecated,{name:y,dataSource:g,children:[h.filter(I=>e&&I.name in e).map(I=>{var V,$;const O=["belongsTo","hasOne","hasMany","belongsToMany"].includes(I.type)?Pi:s.CollectionField;return r.jsxs(b.Form.Item,{label:l(($=(V=I.uiSchema)==null?void 0:V.title)!=null?$:I.name),labelAlign:"left",className:s.css`
|
|
824
824
|
.ant-form-item-control-input-content {
|
|
825
825
|
display: flex;
|
|
826
826
|
}
|
|
827
|
-
`,children:[r.jsx(s.Variable.Input,{scope:p,value:e[I.name],changeOnSelect:!0,onChange:
|
|
827
|
+
`,children:[r.jsx(s.Variable.Input,{scope:p,value:e[I.name],changeOnSelect:!0,onChange:P=>{o(F(w({},e),{[I.name]:P}))},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[I.name]:{"x-component":O,"x-validator"(){return""}}}}})}),k?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(z.CloseCircleOutlined,{}),onClick:()=>{var H;const M=e,{[H=I.name]:P}=M,j=G(M,[Ln(H)]);o(j)}})]},I.name)}),C.length?r.jsx(b.Dropdown,{menu:T,children:r.jsx(b.Button,{icon:r.jsx(z.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:a.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"}),we={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Ro={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: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:s.css`
|
|
828
828
|
flex-direction: column;
|
|
829
829
|
`},"x-component":"CollectionFieldset"},Ct={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=A.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
|
|
830
830
|
position: relative;
|
|
831
831
|
width: 100%;
|
|
832
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Oi={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"}}},Ei={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}}}}}}},st={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Mi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Create record", { ns: "${m}" })}}`);f(this,"type","create");f(this,"group","collection");f(this,"icon","FileAddOutlined");f(this,"color","#07fa0f");f(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Ro,appends:st}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{CollectionFieldset:Xo})}useVariables({key:o,title:n,config:a},i){var p,u;const l=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),[c]=me(F(w({appends:[o,...((u=(p=a.params)==null?void 0:p.appends)==null?void 0:u.map(g=>`${o}.${g}`))||[]]},i),{fields:[{collectionName:a.collection,name:o,type:"hasOne",target:a.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:d}));return c}useInitializers(o){var n,a;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ne,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class $i extends Q{constructor(){super(...arguments);f(this,"title",'{{t("Delete record")}}');f(this,"type","destroy");f(this,"group","collection");f(this,"icon","ClockCircleOutlined");f(this,"color","#fa0b07");f(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(w({},Ct),{"x-validator"(o){return yt(o)?"":N("Please add at least one condition")}})}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{FilterDynamicComponent:Pe})}}class Bi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("End process", { ns: "${m}" })}}`);f(this,"type","end");f(this,"group","control");f(this,"icon","LogoutOutlined");f(this,"color","#2659a1");f(this,"description",`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`);f(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:xe.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:xe.FAILED}],required:!0,default:xe.RESOLVED}});f(this,"end",!0)}}class Vi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Query record", { ns: "${m}" })}}`);f(this,"type","query");f(this,"group","collection");f(this,"icon","FileSearchOutlined");f(this,"color","#55e2d1");f(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Ct,sort:Oi,pagination:Ei,appends:st},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const o=s.useCompile(),{getCollectionFields:n,getInterface:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm();return n(i.collection).filter(d=>{if(!d.interface)return!1;const c=a(d.interface);return!!(c!=null&&c.sortable)}).map(d=>{var c,p;return{value:d.name,label:(c=d==null?void 0:d.uiSchema)!=null&&c.title?o((p=d==null?void 0:d.uiSchema)==null?void 0:p.title):d.name}})}});f(this,"components",{ArrayItems:ve.ArrayItems,FilterDynamicComponent:Pe,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:Se})}useVariables({key:o,title:n,config:a},i){var p,u;const l=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),[c]=me(F(w({appends:[o,...((u=(p=a.params)==null?void 0:p.appends)==null?void 0:u.map(g=>`${o}.${g}`))||[]]},i),{fields:[{collectionName:a.collection,name:o,type:"hasOne",target:a.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:d}));return c}useInitializers(o){var n,a;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ne,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function ji(o){var n=o,{onChange:e}=n,t=G(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,d=a(l),c=A.useField();function p({target:u}){const g=c.query(".values").take();if(!g)return;const y=d.reduce((x,h)=>(h.name in g.value&&(u.value||![].includes(h.type))&&(x[h.name]=g.value[h.name]),x),{});i.setValuesIn("params.values",y),e(u.value)}return r.jsx(Oe,F(w({},t),{onChange:p}))}class Wi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Update record", { ns: "${m}" })}}`);f(this,"type","update");f(this,"group","collection");f(this,"icon","SignatureOutlined");f(this,"color","#f4952f");f(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:F(w({},Ct),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(o){return yt(o)?"":N("Please add at least one condition")}}),values:F(w({},Ro),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||![].includes(o.type)}}})}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{FilterDynamicComponent:Pe,CollectionFieldset:Xo,IndividualHooksRadioWithTooltip:ji})}}const zi=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),je={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Li=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:je.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:je.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:je.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:je.DELETED}];class qi extends Ze{constructor(){super(...arguments);f(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);f(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...we["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:Li,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${je.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${je.UPDATED})}}`}}}]},condition:F(w({},Ct),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(w({},st),{"x-reactions":[...st["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${je.DELETED})}}`}}}]})});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Oo});f(this,"components",{FieldsSelect:tt})}useVariables(o,n){var c;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}];return me(F(w({appends:["data",...((c=o.appends)==null?void 0:c.map(p=>`data.${p}`))||[]]},n),{fields:l,compile:a,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function Ui(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function en({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=R.useTranslation(),[a,i]=v.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
|
|
832
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Ei={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"}}},Mi={type:"void",properties:{paginate:{type:"boolean",title:D("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":D("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],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}}}}}}}}},st={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class $i extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Create record", { ns: "${m}" })}}`);f(this,"type","create");f(this,"group","collection");f(this,"icon","FileAddOutlined");f(this,"color","#07fa0f");f(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Ro,appends:st}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{CollectionFieldset:Xo})}useVariables({key:o,title:n,config:a},i){var p,u;const l=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),[c]=me(F(w({appends:[o,...((u=(p=a.params)==null?void 0:p.appends)==null?void 0:u.map(g=>`${o}.${g}`))||[]]},i),{fields:[{collectionName:a.collection,name:o,type:"hasOne",target:a.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:d}));return c}useInitializers(o){var n,a;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ne,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Bi extends Q{constructor(){super(...arguments);f(this,"title",'{{t("Delete record")}}');f(this,"type","destroy");f(this,"group","collection");f(this,"icon","ClockCircleOutlined");f(this,"color","#fa0b07");f(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(w({},Ct),{"x-validator"(o){return yt(o)?"":N("Please add at least one condition")}})}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{FilterDynamicComponent:Oe})}}class Vi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("End process", { ns: "${m}" })}}`);f(this,"type","end");f(this,"group","control");f(this,"icon","LogoutOutlined");f(this,"color","#2659a1");f(this,"description",`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`);f(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:xe.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:xe.FAILED}],required:!0,default:xe.RESOLVED}});f(this,"end",!0)}}class ji extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Query record", { ns: "${m}" })}}`);f(this,"type","query");f(this,"group","collection");f(this,"icon","FileSearchOutlined");f(this,"color","#55e2d1");f(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Ct,sort:Ei,pagination:Mi,appends:st},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const o=s.useCompile(),{getCollectionFields:n,getInterface:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm();return n(i.collection).filter(d=>{if(!d.interface)return!1;const c=a(d.interface);return!!(c!=null&&c.sortable)}).map(d=>{var c,p;return{value:d.name,label:(c=d==null?void 0:d.uiSchema)!=null&&c.title?o((p=d==null?void 0:d.uiSchema)==null?void 0:p.title):d.name}})}});f(this,"components",{ArrayItems:ve.ArrayItems,FilterDynamicComponent:Oe,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:Se})}useVariables({key:o,title:n,config:a},i){var p,u;const l=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),[c]=me(F(w({appends:[o,...((u=(p=a.params)==null?void 0:p.appends)==null?void 0:u.map(g=>`${o}.${g}`))||[]]},i),{fields:[{collectionName:a.collection,name:o,type:"hasOne",target:a.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:d}));return c}useInitializers(o){var n,a;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(a=o.title)!=null?a:`#${o.id}`,Component:Ne,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function Wi(o){var n=o,{onChange:e}=n,t=G(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,d=a(l),c=A.useField();function p({target:u}){const g=c.query(".values").take();if(!g)return;const y=d.reduce((x,h)=>(h.name in g.value&&(u.value||![].includes(h.type))&&(x[h.name]=g.value[h.name]),x),{});i.setValuesIn("params.values",y),e(u.value)}return r.jsx(Pe,F(w({},t),{onChange:p}))}class zi extends Q{constructor(){super(...arguments);f(this,"title",`{{t("Update record", { ns: "${m}" })}}`);f(this,"type","update");f(this,"group","collection");f(this,"icon","SignatureOutlined");f(this,"color","#f4952f");f(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-reactions":[...we["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:F(w({},Ct),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(o){return yt(o)?"":N("Please add at least one condition")}}),values:F(w({},Ro),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||![].includes(o.type)}}})}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{FilterDynamicComponent:Oe,CollectionFieldset:Xo,IndividualHooksRadioWithTooltip:Wi})}}const Li=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),je={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},qi=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:je.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:je.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:je.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:je.DELETED}];class Ui extends Ze{constructor(){super(...arguments);f(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);f(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);f(this,"fieldset",{collection:F(w({},we),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...we["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:qi,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${je.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${je.UPDATED})}}`}}}]},condition:F(w({},Ct),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(w({},st),{"x-reactions":[...st["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${je.DELETED})}}`}}}]})});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Po});f(this,"components",{FieldsSelect:tt})}useVariables(o,n){var c;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}];return me(F(w({appends:["data",...((c=o.appends)==null?void 0:c.map(p=>`data.${p}`))||[]]},n),{fields:l,compile:a,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function Ki(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function en({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=R.useTranslation(),[a,i]=v.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
|
|
833
833
|
display: flex;
|
|
834
834
|
gap: 0.5em;
|
|
835
|
-
`,children:[r.jsx(tt,{value:o.field,onChange:l=>t(F(w({},o),{field:l})),filter:
|
|
835
|
+
`,children:[r.jsx(tt,{value:o.field,onChange:l=>t(F(w({},o),{field:l})),filter:Ki,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:a,onChange:l=>{i(l),t(F(w({},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,a?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(F(w({},o),{offset:(l!=null?l:0)*a}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(F(w({},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 Gi({value:e,onChange:t}){const{t:o}=ke(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
|
|
836
836
|
display: flex;
|
|
837
837
|
gap: 0.5em;
|
|
838
|
-
`,children:[r.jsxs(b.Select,{value:n,onChange:a=>{t(a?a==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(en,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:B.dayjs(e),onChange:a=>{t(a?a.toDate():null)}}):null]})}var de=function(){return de=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var a in t=arguments[o])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},de.apply(this,arguments)};function tn(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 a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(o[n[a]]=e[n[a]])}return o}function kt(e,t,o){if(o||arguments.length===2)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}var Gi=[{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 * * * *"}],ze=[{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"]}],U={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 on(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function St(e){return e.sort(function(t,o){return t-o}),e}function nn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function Ce(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function rn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function At(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function sn(e,t,o,n,a,i,l,d,c,p,u,g,y,x){o&&o(void 0),t(!1);var h=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;h=!0}if(!h){if(d&&(d===!0||d.includes(e))){if(e==="@reboot")return void x("reboot");var C=Gi.find(function(I){return I.name===e});C&&(e=C.value)}try{var k=function(I){if(typeof I!="string")throw new Error("Invalid cron string");var P=I.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(V,$){return function(O,j){if(O==="*"||O==="*/1")return[];var H=St(nn(dn(function(_,Y,ae){if(ae){_=_.toUpperCase();for(var W=0;W<ae.length;W++)_=_.replace(ae[W],"".concat(W+Y))}return _}(O,j.min,j.alt).split(",").map(function(_){var Y,ae=_.split("/");if(ae.length>2)throw new Error('Invalid value "'.concat(O,' for "').concat(j.type,'"'));var W=ae[0],q=ae[1];Y=W==="*"?on(j.min,j.max):function(X,ee,J){var re=X.split("-");if(re.length===1){var qe=At(re[0]);if(isNaN(qe))throw new Error('Invalid value "'.concat(ee,'" for ').concat(J.type));return[qe]}if(re.length===2){var be=At(re[0]),Je=At(re[1]);if(isNaN(be)||isNaN(Je))throw new Error('Invalid value "'.concat(ee,'" for ').concat(J.type));if(Je<be)throw new Error('Max range is less than min range in "'.concat(X,'" for ').concat(J.type));return on(be,Je)}throw new Error('Invalid value "'.concat(X,'" for ').concat(J.type))}(W,O,j);var K=function(X,ee){if(X!==void 0){var J=At(X);if(isNaN(J)||J<1)throw new Error('Invalid interval step value "'.concat(X,'" for ').concat(ee.type));return J}}(q,j),ie=function(X,ee){if(ee){var J=X[0];X=X.filter(function(re){return re%ee==J%ee||re===J})}return X}(Y,K);return ie}).flat(),j))),M=pn(H,j);if(M!==void 0)throw new Error('Value "'.concat(M,'" out of range for ').concat(j.type));return H.length===j.total?[]:H}(V,ze[$])});throw new Error("Invalid cron string format")}(e),T=function(I){return I[3].length>0?"year":I[2].length>0?"month":I[4].length>0?"week":I[1].length>0?"day":I[0].length>0?"hour":"minute"}(k);x(T),c(k[0]),p(k[1]),u(k[2]),g(k[3]),y(k[4])}catch(I){h=!0}}h&&(a.current=e,t(!0),rn(o,l))}function an(e,t,o,n,a,i,l){if(e==="reboot")return"@reboot";var d=function(c,p){return c.map(function(u,g){var y=ze[g];return ln(cn(u,y),y,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&a?a:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return d.join(" ")}function ln(e,t,o,n,a){var i="";if(function(d,c){return d.length===c.max-c.min+1}(e,t)||e.length===0)i="*";else{var l=function(d){if(d.length>2){var c=d[1]-d[0];if(c>1)return c}}(e);i=l&&function(d,c){for(var p=1;p<d.length;p++){var u=d[p-1];if(d[p]-u!==c)return!1}return!0}(e,l)?function(d,c,p){var u=un(d),g=mn(d),y=d.length===(g-u)/p+1;return!!(u===c.min&&g+p>c.max&&y)}(e,t,l)?"*/".concat(l):"".concat(He(un(e),t,o,n,a),"-").concat(He(mn(e),t,o,n,a),"/").concat(l):function(d){var c=[],p=null;return d.forEach(function(u,g,y){u!==y[g+1]-1?p!==null?(c.push([p,u]),p=null):c.push(u):p===null&&(p=u)}),c}(e).map(function(d){return Array.isArray(d)?"".concat(He(d[0],t,o,n,a),"-").concat(He(d[1],t,o,n,a)):He(d,t,o,n,a)}).join(",")}return i}function He(e,t,o,n,a){var i=e.toString(),l=t.type,d=t.alt,c=t.min,p=n&&(n===!0||n.includes(l)),u=a==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=d[e-c]:e<10&&(p||u)&&(i=i.padStart(2,"0")),l==="hours"&&a==="12-hour-clock"){var g=e>=12?"PM":"AM",y=e%12||12;y<10&&p&&(y=y.toString().padStart(2,"0")),i="".concat(y).concat(g)}return i}function cn(e,t){var o=St(nn(dn(e,t)));if(o.length===0)return o;var n=pn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function dn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function pn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function un(e){return e[0]}function mn(e){return e[e.length-1]}function at(e){var t=e.value,o=e.grid,n=o===void 0||o,a=e.optionsList,i=e.setValue,l=e.locale,d=e.className,c=e.humanizeLabels,p=e.disabled,u=e.readOnly,g=e.leadingZero,y=e.clockFormat,x=e.period,h=e.unit,C=e.periodicityOnDoubleClick,k=e.mode,T=tn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),I=v.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(W){return W.toString()})},[t]),P=v.useMemo(function(){return a?a.map(function(W,q){return{value:(h.min===0?q:q+1).toString(),label:W}}):kt([],Array(h.total),!0).map(function(W,q){var K=h.min===0?q:q+1;return{value:K.toString(),label:He(K,h,c,g,y)}})},[a,g,c,y]),V=JSON.stringify(l),$=v.useCallback(function(W){var q=W.value;if(!t||t[0]!==Number(q))return r.jsx(r.Fragment,{});var K=ln(cn(t,h),h,c,g,y),ie=K.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ie[1]?"".concat(l.everyText||U.everyText," ").concat(ie[1]):K})},[t,V,c,g,y]),O=v.useCallback(function(W){var q=Array.isArray(W)?St(W):[W],K=q;t&&(K=k==="single"?[]:kt([],t,!0),q.forEach(function(ie){var X=Number(ie);K=t.some(function(ee){return ee===X})?K.filter(function(ee){return ee!==X}):St(kt(kt([],K,!0),[X],!1))})),K.length===h.total?i([]):i(K)},[i,t]),j=v.useCallback(function(W){if(W!==0&&W!==1){for(var q=h.total+h.min,K=[],ie=h.min;ie<q;ie++)ie%W==0&&K.push(ie);var X=t&&K&&t.length===K.length&&t.every(function(J,re){return J===K[re]}),ee=K.length===P.length;i(ee||X?[]:K)}else i([])},[t,P,i]),H=v.useRef([]),M=v.useCallback(function(W){if(!u){var q=H.current;q.push({time:new Date().getTime(),value:Number(W)});var K=window.setTimeout(function(){C&&q.length>1&&q[q.length-1].time-q[q.length-2].time<300?q[q.length-1].value===q[q.length-2].value?j(Number(W)):O([q[q.length-2].value,q[q.length-1].value]):O(Number(W)),H.current=[]},300);return function(){window.clearTimeout(K)}}},[H,O,j,u,C]),_=v.useCallback(function(){u||i([])},[i,u]),Y=v.useMemo(function(){var W;return Ce(((W={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(d,"-select")]=!!d,W))},[d]),ae=v.useMemo(function(){var W;return Ce(((W={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(h.type)]=!0,W["react-js-cron-custom-select-dropdown"]=!0,W["react-js-cron-custom-select-dropdown-".concat(h.type)]=!0,W["react-js-cron-custom-select-dropdown-minutes-large"]=h.type==="minutes"&&x!=="hour"&&x!=="day",W["react-js-cron-custom-select-dropdown-minutes-medium"]=h.type==="minutes"&&(x==="day"||x==="hour"),W["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=h.type==="hours"&&y==="12-hour-clock",W["react-js-cron-custom-select-dropdown-grid"]=!!n,W["".concat(d,"-select-dropdown")]=!!d,W["".concat(d,"-select-dropdown-").concat(h.type)]=!!d,W))},[d,n,y,x]);return r.jsx(b.Select,de({mode:k!=="single"||C?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:I,onClear:_,tagRender:$,className:Y,popupClassName:ae,options:P,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:M,onDeselect:M,disabled:p,dropdownAlign:h.type!=="minutes"&&h.type!=="hours"||x==="day"||x==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(h.type)},T))}function _i(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.leadingZero,c=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-hours")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(at,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:ze[1],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:d,clockFormat:c,period:p,periodicityOnDoubleClick:u,mode:g})]}))}function Hi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.leadingZero,c=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-minutes")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||U.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||U.prefixMinutes}),r.jsx(at,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:ze[0],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:d,clockFormat:c,period:p,periodicityOnDoubleClick:u,mode:g}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function Ji(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.weekDays,l=e.disabled,d=e.readOnly,c=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=!i||i.length===0,x=v.useMemo(function(){var k;return Ce(((k={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!y})["".concat(a,"-field")]=!!a,k["".concat(a,"-month-days")]=!!a,k))},[a,y]),h=JSON.stringify(n),C=v.useMemo(function(){return y?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[y,h]);return!d||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",de({className:x},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(at,{placeholder:C,value:t,setValue:o,unit:ze[2],locale:n,className:a,disabled:l,readOnly:d,leadingZero:c,period:p,periodicityOnDoubleClick:u,mode:g})]})):null}function Yi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.disabled,d=e.readOnly,c=e.period,p=e.periodicityOnDoubleClick,u=e.mode,g=n.months||U.months,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-months")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(at,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:g,grid:!1,value:t,unit:de(de({},ze[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:l,readOnly:d,period:c,periodicityOnDoubleClick:p,mode:u})]}))}function Qi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.shortcuts,c=e.allowedPeriods,p=[];c.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),c.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),c.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),c.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),c.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),c.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),c.includes("reboot")&&d&&(d===!0||d.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=v.useCallback(function(h){l||o(h)},[o,l]),g=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-period")]=!!a,h))},[a]),y=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(a,"-select")]=!!a,h))},[a,n.prefixPeriod]),x=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(a,"-select-dropdown")]=!!a,h["".concat(a,"-select-dropdown-period")]=!!a,h))},[a]);return r.jsxs("div",de({className:g},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:u,options:p,className:y,popupClassName:x,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Zi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.monthDays,d=e.disabled,c=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=n.weekDays||U.weekDays,x=p==="week"||!l||l.length===0,h=v.useMemo(function(){var P;return Ce(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!x})["".concat(a,"-field")]=!!a,P["".concat(a,"-week-days")]=!!a,P))},[a,x]),C=JSON.stringify(n),k=v.useMemo(function(){return x?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[x,C]),T=p==="week"||!c||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),I=!c||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",de({className:h},{children:[n.prefixWeekDays!==""&&(p==="week"||!I)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&I&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(at,{placeholder:k,optionsList:y,grid:!1,value:t,unit:de(de({},ze[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:d,readOnly:c,period:p,periodicityOnDoubleClick:u,mode:g})]})):null}function Xi(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,a=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,d=e.locale,c=d===void 0?U:d,p=e.value,u=p===void 0?"":p,g=e.setValue,y=e.displayError,x=y===void 0||y,h=e.onError,C=e.className,k=e.defaultPeriod,T=k===void 0?"day":k,I=e.allowEmpty,P=I===void 0?"for-default-value":I,V=e.humanizeLabels,$=V===void 0||V,O=e.humanizeValue,j=O!==void 0&&O,H=e.disabled,M=H!==void 0&&H,_=e.readOnly,Y=_!==void 0&&_,ae=e.leadingZero,W=ae!==void 0&&ae,q=e.shortcuts,K=q===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:q,ie=e.clockFormat,X=e.periodicityOnDoubleClick,ee=X===void 0||X,J=e.mode,re=J===void 0?"multiple":J,qe=e.allowedDropdowns,be=qe===void 0?["period","months","month-days","week-days","hours","minutes"]:qe,Je=e.allowedPeriods,bl=Je===void 0?["year","month","week","day","hour","minute","reboot"]:Je,Ye=v.useRef(u),oo=v.useRef(T),Sn=v.useState(),Te=Sn[0],It=Sn[1],An=v.useState(),lt=An[0],Ft=An[1],In=v.useState(),Tt=In[0],Nt=In[1],Fn=v.useState(),ct=Fn[0],Dt=Fn[1],Tn=v.useState(),Pt=Tn[0],Ot=Tn[1],Nn=v.useState(),Et=Nn[0],Mt=Nn[1],Dn=v.useState(!1),no=Dn[0],dt=Dn[1],Pn=v.useState(!1),$t=Pn[0],On=Pn[1],vl=function(te){var Ie=v.useRef(te);return v.useEffect(function(){Ie.current=te},[te]),Ie.current}($t),En=JSON.stringify(c);v.useEffect(function(){sn(u,dt,h,P,Ye,!0,c,K,Mt,Ot,Ft,Nt,Dt,It)},[]),v.useEffect(function(){u!==Ye.current&&sn(u,dt,h,P,Ye,!1,c,K,Mt,Ot,Ft,Nt,Dt,It)},[u,Ye,En,P,K]),v.useEffect(function(){if(!(Te||Et||Tt||lt||ct||Pt)||$t||vl)$t&&On(!1);else{var te=Te||oo.current,Ie=an(te,Tt,lt,ct,Pt,Et,j);g(Ie,{selectedPeriod:te}),Ye.current=Ie,h&&h(void 0),dt(!1)}},[Te,lt,Tt,ct,Pt,Et,j,$t]);var Mn=v.useCallback(function(){Ft(void 0),Nt(void 0),Dt(void 0),Ot(void 0),Mt(void 0);var te="",Ie=Te!=="reboot"&&Te?Te:oo.current;Ie!==Te&&It(Ie),l==="fill-with-every"&&(te=an(Ie,void 0,void 0,void 0,void 0,void 0)),g(te,{selectedPeriod:Ie}),Ye.current=te,On(!0),P==="never"&&l==="empty"?(dt(!0),rn(h,c)):(h&&h(void 0),dt(!1))},[Te,g,h,l]),wl=v.useMemo(function(){var te;return Ce(((te={"react-js-cron":!0,"react-js-cron-error":no&&x,"react-js-cron-disabled":M,"react-js-cron-read-only":Y})["".concat(C)]=!!C,te["".concat(C,"-error")]=no&&x&&!!C,te["".concat(C,"-disabled")]=M&&!!C,te["".concat(C,"-read-only")]=Y&&!!C,te))},[C,no,x,M,Y]),ro=a.className,$n=tn(a,["className"]),Bn=v.useMemo(function(){var te;return Ce(((te={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,te["".concat(ro)]=!!ro,te))},[C,ro]),Cl=JSON.stringify($n),Vn=v.useMemo(function(){return o&&!Y?r.jsx(b.Button,de({className:Bn,danger:!0,type:"primary",disabled:M},$n,{onClick:Mn},{children:c.clearButtonText||U.clearButtonText})):null},[o,Y,En,Bn,M,Cl,Mn]),le=Te||oo.current;return r.jsxs("div",de({className:wl},{children:[be.includes("period")&&r.jsx(Qi,{value:le,setValue:It,locale:c,className:C,disabled:M,readOnly:Y,shortcuts:K,allowedPeriods:bl}),le==="reboot"?Vn:r.jsxs(r.Fragment,{children:[le==="year"&&be.includes("months")&&r.jsx(Yi,{value:Tt,setValue:Nt,locale:c,className:C,humanizeLabels:$,disabled:M,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:re}),(le==="year"||le==="month")&&be.includes("month-days")&&r.jsx(Ji,{value:lt,setValue:Ft,locale:c,className:C,weekDays:ct,disabled:M,readOnly:Y,leadingZero:W,period:le,periodicityOnDoubleClick:ee,mode:re}),(le==="year"||le==="month"||le==="week")&&be.includes("week-days")&&r.jsx(Zi,{value:ct,setValue:Dt,locale:c,className:C,humanizeLabels:$,monthDays:lt,disabled:M,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:re}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&be.includes("hours")&&r.jsx(_i,{value:Pt,setValue:Ot,locale:c,className:C,disabled:M,readOnly:Y,leadingZero:W,clockFormat:ie,period:le,periodicityOnDoubleClick:ee,mode:re}),le!=="minute"&&be.includes("minutes")&&r.jsx(Hi,{value:Et,setValue:Mt,locale:c,period:le,className:C,disabled:M,readOnly:Y,leadingZero:W,clockFormat:ie,periodicityOnDoubleClick:ee,mode:re}),Vn]})]})]}))}const Ri={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fn=[{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 gn(e){return fn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function el(e){let t;switch(typeof e){case"number":return t=gn(e),t?t.value:"none";case"string":return"cron"}return"none"}function tl({value:e,onChange:t}){const{t:o}=ke(),n=gn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:a=>t(a*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function ol({value:e=null,onChange:t}){const{t:o}=ke(),n=el(e);function a(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=Ri[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
|
|
838
|
+
`,children:[r.jsxs(b.Select,{value:n,onChange:a=>{t(a?a==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(en,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:B.dayjs(e),onChange:a=>{t(a?a.toDate():null)}}):null]})}var de=function(){return de=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var a in t=arguments[o])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},de.apply(this,arguments)};function tn(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 a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(o[n[a]]=e[n[a]])}return o}function kt(e,t,o){if(o||arguments.length===2)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}var _i=[{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 * * * *"}],ze=[{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"]}],U={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 on(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function St(e){return e.sort(function(t,o){return t-o}),e}function nn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function Ce(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function rn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function At(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function sn(e,t,o,n,a,i,l,d,c,p,u,g,y,x){o&&o(void 0),t(!1);var h=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;h=!0}if(!h){if(d&&(d===!0||d.includes(e))){if(e==="@reboot")return void x("reboot");var C=_i.find(function(I){return I.name===e});C&&(e=C.value)}try{var k=function(I){if(typeof I!="string")throw new Error("Invalid cron string");var O=I.replace(/\s+/g," ").trim().split(" ");if(O.length===5)return O.map(function(V,$){return function(P,j){if(P==="*"||P==="*/1")return[];var H=St(nn(dn(function(_,Y,ae){if(ae){_=_.toUpperCase();for(var W=0;W<ae.length;W++)_=_.replace(ae[W],"".concat(W+Y))}return _}(P,j.min,j.alt).split(",").map(function(_){var Y,ae=_.split("/");if(ae.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat(j.type,'"'));var W=ae[0],q=ae[1];Y=W==="*"?on(j.min,j.max):function(X,ee,J){var re=X.split("-");if(re.length===1){var qe=At(re[0]);if(isNaN(qe))throw new Error('Invalid value "'.concat(ee,'" for ').concat(J.type));return[qe]}if(re.length===2){var be=At(re[0]),Je=At(re[1]);if(isNaN(be)||isNaN(Je))throw new Error('Invalid value "'.concat(ee,'" for ').concat(J.type));if(Je<be)throw new Error('Max range is less than min range in "'.concat(X,'" for ').concat(J.type));return on(be,Je)}throw new Error('Invalid value "'.concat(X,'" for ').concat(J.type))}(W,P,j);var K=function(X,ee){if(X!==void 0){var J=At(X);if(isNaN(J)||J<1)throw new Error('Invalid interval step value "'.concat(X,'" for ').concat(ee.type));return J}}(q,j),ie=function(X,ee){if(ee){var J=X[0];X=X.filter(function(re){return re%ee==J%ee||re===J})}return X}(Y,K);return ie}).flat(),j))),M=pn(H,j);if(M!==void 0)throw new Error('Value "'.concat(M,'" out of range for ').concat(j.type));return H.length===j.total?[]:H}(V,ze[$])});throw new Error("Invalid cron string format")}(e),T=function(I){return I[3].length>0?"year":I[2].length>0?"month":I[4].length>0?"week":I[1].length>0?"day":I[0].length>0?"hour":"minute"}(k);x(T),c(k[0]),p(k[1]),u(k[2]),g(k[3]),y(k[4])}catch(I){h=!0}}h&&(a.current=e,t(!0),rn(o,l))}function an(e,t,o,n,a,i,l){if(e==="reboot")return"@reboot";var d=function(c,p){return c.map(function(u,g){var y=ze[g];return ln(cn(u,y),y,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&a?a:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return d.join(" ")}function ln(e,t,o,n,a){var i="";if(function(d,c){return d.length===c.max-c.min+1}(e,t)||e.length===0)i="*";else{var l=function(d){if(d.length>2){var c=d[1]-d[0];if(c>1)return c}}(e);i=l&&function(d,c){for(var p=1;p<d.length;p++){var u=d[p-1];if(d[p]-u!==c)return!1}return!0}(e,l)?function(d,c,p){var u=un(d),g=mn(d),y=d.length===(g-u)/p+1;return!!(u===c.min&&g+p>c.max&&y)}(e,t,l)?"*/".concat(l):"".concat(He(un(e),t,o,n,a),"-").concat(He(mn(e),t,o,n,a),"/").concat(l):function(d){var c=[],p=null;return d.forEach(function(u,g,y){u!==y[g+1]-1?p!==null?(c.push([p,u]),p=null):c.push(u):p===null&&(p=u)}),c}(e).map(function(d){return Array.isArray(d)?"".concat(He(d[0],t,o,n,a),"-").concat(He(d[1],t,o,n,a)):He(d,t,o,n,a)}).join(",")}return i}function He(e,t,o,n,a){var i=e.toString(),l=t.type,d=t.alt,c=t.min,p=n&&(n===!0||n.includes(l)),u=a==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=d[e-c]:e<10&&(p||u)&&(i=i.padStart(2,"0")),l==="hours"&&a==="12-hour-clock"){var g=e>=12?"PM":"AM",y=e%12||12;y<10&&p&&(y=y.toString().padStart(2,"0")),i="".concat(y).concat(g)}return i}function cn(e,t){var o=St(nn(dn(e,t)));if(o.length===0)return o;var n=pn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function dn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function pn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function un(e){return e[0]}function mn(e){return e[e.length-1]}function at(e){var t=e.value,o=e.grid,n=o===void 0||o,a=e.optionsList,i=e.setValue,l=e.locale,d=e.className,c=e.humanizeLabels,p=e.disabled,u=e.readOnly,g=e.leadingZero,y=e.clockFormat,x=e.period,h=e.unit,C=e.periodicityOnDoubleClick,k=e.mode,T=tn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),I=v.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(W){return W.toString()})},[t]),O=v.useMemo(function(){return a?a.map(function(W,q){return{value:(h.min===0?q:q+1).toString(),label:W}}):kt([],Array(h.total),!0).map(function(W,q){var K=h.min===0?q:q+1;return{value:K.toString(),label:He(K,h,c,g,y)}})},[a,g,c,y]),V=JSON.stringify(l),$=v.useCallback(function(W){var q=W.value;if(!t||t[0]!==Number(q))return r.jsx(r.Fragment,{});var K=ln(cn(t,h),h,c,g,y),ie=K.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ie[1]?"".concat(l.everyText||U.everyText," ").concat(ie[1]):K})},[t,V,c,g,y]),P=v.useCallback(function(W){var q=Array.isArray(W)?St(W):[W],K=q;t&&(K=k==="single"?[]:kt([],t,!0),q.forEach(function(ie){var X=Number(ie);K=t.some(function(ee){return ee===X})?K.filter(function(ee){return ee!==X}):St(kt(kt([],K,!0),[X],!1))})),K.length===h.total?i([]):i(K)},[i,t]),j=v.useCallback(function(W){if(W!==0&&W!==1){for(var q=h.total+h.min,K=[],ie=h.min;ie<q;ie++)ie%W==0&&K.push(ie);var X=t&&K&&t.length===K.length&&t.every(function(J,re){return J===K[re]}),ee=K.length===O.length;i(ee||X?[]:K)}else i([])},[t,O,i]),H=v.useRef([]),M=v.useCallback(function(W){if(!u){var q=H.current;q.push({time:new Date().getTime(),value:Number(W)});var K=window.setTimeout(function(){C&&q.length>1&&q[q.length-1].time-q[q.length-2].time<300?q[q.length-1].value===q[q.length-2].value?j(Number(W)):P([q[q.length-2].value,q[q.length-1].value]):P(Number(W)),H.current=[]},300);return function(){window.clearTimeout(K)}}},[H,P,j,u,C]),_=v.useCallback(function(){u||i([])},[i,u]),Y=v.useMemo(function(){var W;return Ce(((W={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(d,"-select")]=!!d,W))},[d]),ae=v.useMemo(function(){var W;return Ce(((W={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(h.type)]=!0,W["react-js-cron-custom-select-dropdown"]=!0,W["react-js-cron-custom-select-dropdown-".concat(h.type)]=!0,W["react-js-cron-custom-select-dropdown-minutes-large"]=h.type==="minutes"&&x!=="hour"&&x!=="day",W["react-js-cron-custom-select-dropdown-minutes-medium"]=h.type==="minutes"&&(x==="day"||x==="hour"),W["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=h.type==="hours"&&y==="12-hour-clock",W["react-js-cron-custom-select-dropdown-grid"]=!!n,W["".concat(d,"-select-dropdown")]=!!d,W["".concat(d,"-select-dropdown-").concat(h.type)]=!!d,W))},[d,n,y,x]);return r.jsx(b.Select,de({mode:k!=="single"||C?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:I,onClear:_,tagRender:$,className:Y,popupClassName:ae,options:O,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:M,onDeselect:M,disabled:p,dropdownAlign:h.type!=="minutes"&&h.type!=="hours"||x==="day"||x==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(h.type)},T))}function Hi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.leadingZero,c=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-hours")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(at,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:ze[1],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:d,clockFormat:c,period:p,periodicityOnDoubleClick:u,mode:g})]}))}function Ji(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.leadingZero,c=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-minutes")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||U.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||U.prefixMinutes}),r.jsx(at,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:ze[0],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:d,clockFormat:c,period:p,periodicityOnDoubleClick:u,mode:g}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function Yi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.weekDays,l=e.disabled,d=e.readOnly,c=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=!i||i.length===0,x=v.useMemo(function(){var k;return Ce(((k={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!y})["".concat(a,"-field")]=!!a,k["".concat(a,"-month-days")]=!!a,k))},[a,y]),h=JSON.stringify(n),C=v.useMemo(function(){return y?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[y,h]);return!d||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",de({className:x},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(at,{placeholder:C,value:t,setValue:o,unit:ze[2],locale:n,className:a,disabled:l,readOnly:d,leadingZero:c,period:p,periodicityOnDoubleClick:u,mode:g})]})):null}function Qi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.disabled,d=e.readOnly,c=e.period,p=e.periodicityOnDoubleClick,u=e.mode,g=n.months||U.months,y=v.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(a,"-field")]=!!a,x["".concat(a,"-months")]=!!a,x))},[a]);return r.jsxs("div",de({className:y},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(at,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:g,grid:!1,value:t,unit:de(de({},ze[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:l,readOnly:d,period:c,periodicityOnDoubleClick:p,mode:u})]}))}function Zi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,d=e.shortcuts,c=e.allowedPeriods,p=[];c.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),c.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),c.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),c.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),c.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),c.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),c.includes("reboot")&&d&&(d===!0||d.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=v.useCallback(function(h){l||o(h)},[o,l]),g=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-period")]=!!a,h))},[a]),y=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(a,"-select")]=!!a,h))},[a,n.prefixPeriod]),x=v.useMemo(function(){var h;return Ce(((h={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(a,"-select-dropdown")]=!!a,h["".concat(a,"-select-dropdown-period")]=!!a,h))},[a]);return r.jsxs("div",de({className:g},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:u,options:p,className:y,popupClassName:x,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Xi(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.monthDays,d=e.disabled,c=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,g=e.mode,y=n.weekDays||U.weekDays,x=p==="week"||!l||l.length===0,h=v.useMemo(function(){var O;return Ce(((O={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!x})["".concat(a,"-field")]=!!a,O["".concat(a,"-week-days")]=!!a,O))},[a,x]),C=JSON.stringify(n),k=v.useMemo(function(){return x?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[x,C]),T=p==="week"||!c||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),I=!c||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",de({className:h},{children:[n.prefixWeekDays!==""&&(p==="week"||!I)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&I&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(at,{placeholder:k,optionsList:y,grid:!1,value:t,unit:de(de({},ze[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:d,readOnly:c,period:p,periodicityOnDoubleClick:u,mode:g})]})):null}function Ri(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,a=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,d=e.locale,c=d===void 0?U:d,p=e.value,u=p===void 0?"":p,g=e.setValue,y=e.displayError,x=y===void 0||y,h=e.onError,C=e.className,k=e.defaultPeriod,T=k===void 0?"day":k,I=e.allowEmpty,O=I===void 0?"for-default-value":I,V=e.humanizeLabels,$=V===void 0||V,P=e.humanizeValue,j=P!==void 0&&P,H=e.disabled,M=H!==void 0&&H,_=e.readOnly,Y=_!==void 0&&_,ae=e.leadingZero,W=ae!==void 0&&ae,q=e.shortcuts,K=q===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:q,ie=e.clockFormat,X=e.periodicityOnDoubleClick,ee=X===void 0||X,J=e.mode,re=J===void 0?"multiple":J,qe=e.allowedDropdowns,be=qe===void 0?["period","months","month-days","week-days","hours","minutes"]:qe,Je=e.allowedPeriods,bl=Je===void 0?["year","month","week","day","hour","minute","reboot"]:Je,Ye=v.useRef(u),oo=v.useRef(T),An=v.useState(),Te=An[0],It=An[1],In=v.useState(),lt=In[0],Ft=In[1],Fn=v.useState(),Tt=Fn[0],Nt=Fn[1],Tn=v.useState(),ct=Tn[0],Dt=Tn[1],Nn=v.useState(),Ot=Nn[0],Pt=Nn[1],Dn=v.useState(),Et=Dn[0],Mt=Dn[1],On=v.useState(!1),no=On[0],dt=On[1],Pn=v.useState(!1),$t=Pn[0],En=Pn[1],vl=function(te){var Ie=v.useRef(te);return v.useEffect(function(){Ie.current=te},[te]),Ie.current}($t),Mn=JSON.stringify(c);v.useEffect(function(){sn(u,dt,h,O,Ye,!0,c,K,Mt,Pt,Ft,Nt,Dt,It)},[]),v.useEffect(function(){u!==Ye.current&&sn(u,dt,h,O,Ye,!1,c,K,Mt,Pt,Ft,Nt,Dt,It)},[u,Ye,Mn,O,K]),v.useEffect(function(){if(!(Te||Et||Tt||lt||ct||Ot)||$t||vl)$t&&En(!1);else{var te=Te||oo.current,Ie=an(te,Tt,lt,ct,Ot,Et,j);g(Ie,{selectedPeriod:te}),Ye.current=Ie,h&&h(void 0),dt(!1)}},[Te,lt,Tt,ct,Ot,Et,j,$t]);var $n=v.useCallback(function(){Ft(void 0),Nt(void 0),Dt(void 0),Pt(void 0),Mt(void 0);var te="",Ie=Te!=="reboot"&&Te?Te:oo.current;Ie!==Te&&It(Ie),l==="fill-with-every"&&(te=an(Ie,void 0,void 0,void 0,void 0,void 0)),g(te,{selectedPeriod:Ie}),Ye.current=te,En(!0),O==="never"&&l==="empty"?(dt(!0),rn(h,c)):(h&&h(void 0),dt(!1))},[Te,g,h,l]),wl=v.useMemo(function(){var te;return Ce(((te={"react-js-cron":!0,"react-js-cron-error":no&&x,"react-js-cron-disabled":M,"react-js-cron-read-only":Y})["".concat(C)]=!!C,te["".concat(C,"-error")]=no&&x&&!!C,te["".concat(C,"-disabled")]=M&&!!C,te["".concat(C,"-read-only")]=Y&&!!C,te))},[C,no,x,M,Y]),ro=a.className,Bn=tn(a,["className"]),Vn=v.useMemo(function(){var te;return Ce(((te={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,te["".concat(ro)]=!!ro,te))},[C,ro]),Cl=JSON.stringify(Bn),jn=v.useMemo(function(){return o&&!Y?r.jsx(b.Button,de({className:Vn,danger:!0,type:"primary",disabled:M},Bn,{onClick:$n},{children:c.clearButtonText||U.clearButtonText})):null},[o,Y,Mn,Vn,M,Cl,$n]),le=Te||oo.current;return r.jsxs("div",de({className:wl},{children:[be.includes("period")&&r.jsx(Zi,{value:le,setValue:It,locale:c,className:C,disabled:M,readOnly:Y,shortcuts:K,allowedPeriods:bl}),le==="reboot"?jn:r.jsxs(r.Fragment,{children:[le==="year"&&be.includes("months")&&r.jsx(Qi,{value:Tt,setValue:Nt,locale:c,className:C,humanizeLabels:$,disabled:M,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:re}),(le==="year"||le==="month")&&be.includes("month-days")&&r.jsx(Yi,{value:lt,setValue:Ft,locale:c,className:C,weekDays:ct,disabled:M,readOnly:Y,leadingZero:W,period:le,periodicityOnDoubleClick:ee,mode:re}),(le==="year"||le==="month"||le==="week")&&be.includes("week-days")&&r.jsx(Xi,{value:ct,setValue:Dt,locale:c,className:C,humanizeLabels:$,monthDays:lt,disabled:M,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:re}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&be.includes("hours")&&r.jsx(Hi,{value:Ot,setValue:Pt,locale:c,className:C,disabled:M,readOnly:Y,leadingZero:W,clockFormat:ie,period:le,periodicityOnDoubleClick:ee,mode:re}),le!=="minute"&&be.includes("minutes")&&r.jsx(Ji,{value:Et,setValue:Mt,locale:c,period:le,className:C,disabled:M,readOnly:Y,leadingZero:W,clockFormat:ie,periodicityOnDoubleClick:ee,mode:re}),jn]})]})]}))}const el={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fn=[{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 gn(e){return fn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function tl(e){let t;switch(typeof e){case"number":return t=gn(e),t?t.value:"none";case"string":return"cron"}return"none"}function ol({value:e,onChange:t}){const{t:o}=ke(),n=gn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:a=>t(a*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function nl({value:e=null,onChange:t}){const{t:o}=ke(),n=tl(e);function a(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=el[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
|
|
839
839
|
display: flex;
|
|
840
840
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
841
841
|
align-items: flex-start;
|
|
@@ -864,7 +864,7 @@ export default async function (
|
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
|
-
`,children:[r.jsx(b.Select,{value:n,onChange:a,className:"auto-width",children:fn.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(
|
|
867
|
+
`,children:[r.jsx(b.Select,{value:n,onChange:a,className:"auto-width",children:fn.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(ol,{value:e,onChange:t}):null,n==="cron"?r.jsx(Ri,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const rl={[We.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[We.DATE_FIELD]:{collection:F(w({},we),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...we["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:F(w({},st),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${We.DATE_FIELD} && $deps[1]}}`}}}]})}},sl=[{value:We.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:We.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],al=()=>{const{values:e={},clearFormGraph:t}=A.useForm(),[o,n]=v.useState(e.mode);return A.useFormEffects(()=>{A.onFieldValueChange("mode",a=>{n(a.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:sl},required:!0,default:We.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
|
|
868
868
|
.ant-input-number {
|
|
869
869
|
width: auto;
|
|
870
870
|
min-width: 6em;
|
|
@@ -873,4 +873,4 @@ export default async function (
|
|
|
873
873
|
.ant-picker {
|
|
874
874
|
width: auto;
|
|
875
875
|
}
|
|
876
|
-
`},properties:nl[o]}}},components:{OnField:en,RepeatField:ol,EndsByField:Ki}})]})};class al extends Ze{constructor(){super(...arguments);f(this,"sync",!1);f(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);f(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`);f(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{ScheduleConfig:sl})}useVariables(o,n){var d;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:N("Trigger time")}),o.mode===We.DATE_FIELD){const[c]=me(F(w({appends:["data",...((d=o.appends)==null?void 0:d.map(p=>`data.${p}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}],compile:a,getCollectionFields:i}));c&&l.push(c)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const Rt=()=>{const{t:e}=R.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(oe.Link,{to:xt(t),onClick:()=>o(!1),children:e("View")})},il={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.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: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:ut}}]},yn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:il,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=ke(),{refresh:n,params:a}=s.useDataBlockRequest(),i=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return E(this,null,function*(){yield i.destroy({filter:a==null?void 0:a.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionTime:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionTime:{type:"string","x-decorator":"ExecutionTime","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},eo=yn();function ll(n){var a=n,{params:e,filter:t={}}=a,o=G(a,["params","filter"]);const{workflow:i}=L(),l=F(w({},o),{params:F(w({},e),{filter:F(w({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,w({},l))}function cl(){var j;const e=oe.useNavigate(),{t}=R.useTranslation(),o=s.useApp(),{data:n,refresh:a,loading:i}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:d}=s.useDocumentTitle(),[c,p]=v.useState(!1),{styles:u}=he(),{modal:g}=b.App.useApp();if(v.useEffect(()=>{var _;const{title:M}=(_=n==null?void 0:n.data)!=null?_:{};d==null||d(`${N("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const H=(j=n==null?void 0:n.data)!=null?j:{},{nodes:y=[],revisions:x=[]}=H,h=G(H,["nodes","revisions"]);gt(y);const C=y.find(M=>!M.upstream);function k({key:M}){M!==h.id&&e(Ve(M))}function T(M){return E(this,null,function*(){yield l.update({filterByTk:h.id,values:{enabled:M}}),a()})}function I(){return E(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:h.id,filter:{key:h.key}});e(xt(M.executionId))})}function P(){return E(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:h.id,filter:{key:h.key}});b.message.success(t("Operation succeeded")),e(Ve(M.id))})}function V(){return E(this,null,function*(){const M=h.current?N("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return E(this,null,function*(){var Y;yield l.destroy({filterByTk:h.id}),b.message.success(t("Operation succeeded")),e(h.current?o.systemSettingsManager.getRoutePath("workflow"):Ve((Y=x.find(ae=>ae.current))==null?void 0:Y.id))})}})})}function $(_){return E(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return I();case"revision":return P();case"delete":return V()}})}const O=h.executed&&!x.find(M=>!M.executed&&new Date(M.createdAt)>new Date(h.createdAt));return r.jsxs(Ue.Provider,{value:{workflow:h,nodes:y,refresh:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(xo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:N("Workflow")})},{title:r.jsx("strong",{children:h.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:k,defaultSelectedKeys:[`${h.id}`],className:s.cx(u.dropdownClass,u.workflowVersionDropdownClass),items:x.sort((M,_)=>_.id-M.id).map((M,_)=>({role:"button","aria-label":`version-${_}`,key:`${M.id}`,icon:M.current?r.jsx(z.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:B.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:h!=null&&h.id?`#${h.id}`:null}),r.jsx(z.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:h.enabled,onChange:T,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!h.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:N("Retry"),disabled:!h.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!O},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:$},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(z.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:eo,components:{ExecutionResourceProvider:ll,ExecutionLink:Rt,ExecutionStatusColumn:Ht,ExecutionTime:Wt}})})]})]}),r.jsx(ho,{entry:C})]})}const hn=()=>{const e=oe.useParams(),{styles:t}=he();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:cl}})})},dl=()=>{var i;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(i=e.config)==null?void 0:i.collection,n=t.getCollection(o),a=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:a})},pl=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:a,title:i}=e,l=n.find(d=>d.value===a);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:i})})},ul=n=>{var a=n,{params:e,filter:t={}}=a,o=G(a,["params","filter"]);const i=s.useCollectionRecordData(),l=F(w({},o),{params:F(w({},e),{filter:F(w({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,w({},l))};var it=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},xn={exports:{}};(function(e,t){(function(o,n){n()})(it,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,g){var y=new XMLHttpRequest;y.open("GET",p),y.responseType="blob",y.onload=function(){c(y.response,u,g)},y.onerror=function(){console.error("could not download file")},y.send()}function a(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(g){}return 200<=u.status&&299>=u.status}function i(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(g){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof it=="object"&&it.global===it?it:void 0,d=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(p,u,g){var y=l.URL||l.webkitURL,x=document.createElement("a");u=u||p.name||"download",x.download=u,x.rel="noopener",typeof p=="string"?(x.href=p,x.origin===location.origin?i(x):a(x.href)?n(p,u,g):i(x,x.target="_blank")):(x.href=y.createObjectURL(p),setTimeout(function(){y.revokeObjectURL(x.href)},4e4),setTimeout(function(){i(x)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,g){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,g),u);else if(a(p))n(p,u,g);else{var y=document.createElement("a");y.href=p,y.target="_blank",setTimeout(function(){i(y)})}}:function(p,u,g,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,g);var x=p.type==="application/octet-stream",h=/constructor/i.test(l.HTMLElement)||l.safari,C=/CriOS\/[\d]+/.test(navigator.userAgent);if((C||x&&h||d)&&typeof FileReader!="undefined"){var k=new FileReader;k.onloadend=function(){var P=k.result;P=C?P:P.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=P:location=P,y=null},k.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,I=T.createObjectURL(p);y?y.location=I:location.href=I,y=null,setTimeout(function(){T.revokeObjectURL(I)},4e4)}});l.saveAs=c.saveAs=c,e.exports=c})})(xn);var ml=xn.exports;const to=A.observable({value:""}),bn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],Le={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"array",name:"tags",interface:"multipleSelect",uiSchema:{title:'{{t("Tags")}}',type:"array",enum:bn,"x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:D("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},tags:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},vn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Le.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:fe.title,tags:fe.tags,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options}}}}}}}},wn={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Le.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:fe.title,tags:fe.tags,type:fe.type,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options}}}}}}}},fl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=R.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),a=s.useFilterByTk(),{values:i}=A.useForm();return{run(){return E(this,null,function*(){yield o.revision({filterByTk:a,values:i}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},gl={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',"x-decorator":"FormItem",default:{data:{},ctx:{}},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:20,maxRows:50}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){R.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:a}=A.useForm();return{run(){return E(this,null,function*(){yield t.test({filterByTk:n,values:a}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},yl=({children:e})=>r.jsx(b.Tabs,{type:"card",onChange:t=>{to.value=t},items:[{value:"",label:N("All")}].concat(bn).map(({label:t,value:o},n)=>({label:t,key:o,children:r.jsx(s.CardItem,{children:e})}))}),Cn={type:"void",properties:{provider:{type:"void","x-decorator":A.observer(e=>{const t={collection:Le,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return to.value&&(t.params.filter.tags={$anyOf:[to.value]}),r.jsx(s.TableBlockProvider,w(w({},e),t))}),"x-component":yl,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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},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}=R.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useFilterByTk(),{setVisible:i}=s.useActionContext(),{values:l}=A.useForm();return{run(){return E(this,null,function*(){const{data:c}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:a,values:F(w({},l),{workflow:c})}),b.message.success(e("Operation succeeded")),o(),i(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:vn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},tags:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:'{{t("Tags")}}',properties:{tags:{type:"array","x-component":"CollectionField","x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:D("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return v.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:eo}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:wn,revision:fl,test:gl,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=R.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return E(this,null,function*(){const{data:a}=yield t.dump({filterByTk:o}),i=new Blob([JSON.stringify(a.data,null,2)],{type:"application/json"});ml.saveAs(i,a.data.title+"-"+a.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},hl=()=>{const{t:e}=R.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:Ve(t),onClick:()=>o(!1),children:e("Configure")})};function xl(e){const t=A.useField(),o=s.usePlugin(Z);return A.useFormEffects(()=>{A.onFieldChange("type",n=>{let a=!n.value;if(n.value){const i=o.triggers.get(n.value);i.sync!=null&&(a=!0,t.setValue(i.sync))}t.setPattern(a?"disabled":"editable")})}),r.jsx(Oe,w({},e))}function kn(e){const{schema:t=Cn}=e,o=v.useContext(s.SchemaComponentContext),{getTriggersOptions:n}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[Le],children:r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},o),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:{WorkflowLink:hl,ExecutionResourceProvider:ul,ExecutionLink:Rt,OpenDrawer:To,ExecutionStatusSelect:Do,SyncOptionSelect:xl,ExecutionStatusColumn:Ht,ExecutionTime:Wt,ColumnShowTitle:pl,ColumnShowCollection:dl},scope:{getTriggersOptions:n}})})})}class Z extends s.Plugin{constructor(){super(...arguments);f(this,"triggers",new B.Registry);f(this,"instructions",new B.Registry);f(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,l]=i,d=l,{title:n}=d,a=G(d,["title"]);return{value:o,label:n,color:"gold",options:a}}))}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 Q)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}afterAdd(){return E(this,null,function*(){yield this.pm.add(ei),yield this.pm.add(Ja),yield this.pm.add(_a),yield this.pm.add(Ws),yield this.pm.add(Qr),yield this.pm.add(Sr),yield this.pm.add(gr),yield this.pm.add(pr),yield this.pm.add(Xa),yield this.pm.add(Ur),yield this.pm.add(ii),yield this.pm.add(Qa),yield this.pm.add(Ka),yield this.pm.add(ni),yield this.pm.add(Ma),yield this.pm.add(Hr),yield this.pm.add(Gr)})}load(){return E(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:kn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:hn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:bo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(zi),this.registerTrigger("collection",qi),this.registerTrigger("schedule",al),this.registerInstruction("calculation",li),this.registerInstruction("condition",Di),this.registerInstruction("end",Bi),this.registerInstruction("query",Vi),this.registerInstruction("create",Mi),this.registerInstruction("update",Wi),this.registerInstruction("destroy",$i)})}addComponents(){this.app.addComponents({WorkflowLink:Ln,WorkflowPage:hn,ExecutionPage:bo})}}S.AddButton=Vt,S.AdditionNotifiedPerson=jr,S.AutoResizeInput=Po,S.BaseTypeSets=De,S.Branch=Be,S.BuiltinGroupType=Ke,S.CheckboxGroupWithTooltip=Fo,S.CollectionBlockInitializer=Ne,S.ConfigButtonMessage=zr,S.DetailsBlockProvider=zt,S.EXECUTION_STATUS=pe,S.ExecutionContextProvider=_o,S.ExecutionLink=Rt,S.ExecutionStatusColumn=Ht,S.ExecutionStatusOptions=ut,S.ExecutionStatusOptionsMap=mt,S.ExecutionStatusSelect=Do,S.ExecutionTime=Wt,S.FieldsSelect=tt,S.FilterDynamicComponent=Pe,S.FlowContext=Ue,S.Instruction=Q,S.JOB_STATUS=xe,S.JobStatusOptions=ft,S.JobStatusOptionsMap=et,S.Node=co,S.NodeDefaultView=rt,S.OpenDrawer=To,S.ProviderContextNode=lo,S.RadioWithTooltip=Oe,S.SelectNotifiedPerson=Mr,S.SimpleDesigner=_t,S.Trigger=Ze,S.ValueBlock=Ae,S.WorkflowPane=kn,S.WorkflowVariableCodeMirror=Dr,S.WorkflowVariableInput=Se,S.WorkflowVariableJSON=Io,S.WorkflowVariableRawTextArea=Ao,S.WorkflowVariableTextArea=nt,S.collectionWorkflows=Le,S.createWorkflow=vn,S.currentFormOptions=wo,S.default=Z,S.defaultFieldNames=ue,S.executionSchema=eo,S.formatDuration=jt,S.getCollectionFieldOptions=me,S.getExecutionSchema=yn,S.getWorkflowDetailPath=Ve,S.getWorkflowExecutionsPath=xt,S.isValidFilter=yt,S.linkNodes=gt,S.nodesOptions=bt,S.scopeOptions=Lt,S.systemOptions=Co,S.traverseSchema=ht,S.triggerOptions=vt,S.updateWorkflow=wn,S.useAvailableUpstreams=$e,S.useContextNode=ye,S.useFlowContext=L,S.useGetAriaLabelOfAddButton=pt,S.useRecordTriggerWorkflowsActionProps=Ls,S.useStyles=he,S.useTrigger=Xe,S.useTriggerWorkflowsActionProps=zs,S.useWorkflowAnyExecuted=Oo,S.useWorkflowExecuted=Jt,S.useWorkflowVariableFormOptions=So,S.useWorkflowVariableOptions=ce,S.workflowFieldset=fe,S.workflowSchema=Cn,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
876
|
+
`},properties:rl[o]}}},components:{OnField:en,RepeatField:nl,EndsByField:Gi}})]})};class il extends Ze{constructor(){super(...arguments);f(this,"sync",!1);f(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);f(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`);f(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});f(this,"scope",{useCollectionDataSource:s.useCollectionDataSource});f(this,"components",{ScheduleConfig:al})}useVariables(o,n){var d;const a=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:N("Trigger time")}),o.mode===We.DATE_FIELD){const[c]=me(F(w({appends:["data",...((d=o.appends)==null?void 0:d.map(p=>`data.${p}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}],compile:a,getCollectionFields:i}));c&&l.push(c)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataPath:"$context.data"}:null}}const Rt=()=>{const{t:e}=R.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(oe.Link,{to:xt(t),onClick:()=>o(!1),children:e("View")})},yn={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.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: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:ut}}]},hn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:yn,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=ke(),{refresh:n,params:a}=s.useDataBlockRequest(),i=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return E(this,null,function*(){yield i.destroy({filter:a==null?void 0:a.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionTime:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionTime:{type:"string","x-decorator":"ExecutionTime","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},eo=hn();function ll(n){var a=n,{params:e,filter:t={}}=a,o=G(a,["params","filter"]);const{workflow:i}=L(),l=F(w({},o),{params:F(w({},e),{filter:F(w({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,w({},l))}function cl(){var j;const e=oe.useNavigate(),{t}=R.useTranslation(),o=s.useApp(),{data:n,refresh:a,loading:i}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:d}=s.useDocumentTitle(),[c,p]=v.useState(!1),{styles:u}=he(),{modal:g}=b.App.useApp();if(v.useEffect(()=>{var _;const{title:M}=(_=n==null?void 0:n.data)!=null?_:{};d==null||d(`${N("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const H=(j=n==null?void 0:n.data)!=null?j:{},{nodes:y=[],revisions:x=[]}=H,h=G(H,["nodes","revisions"]);gt(y);const C=y.find(M=>!M.upstream);function k({key:M}){M!==h.id&&e(Ve(M))}function T(M){return E(this,null,function*(){yield l.update({filterByTk:h.id,values:{enabled:M}}),a()})}function I(){return E(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:h.id,filter:{key:h.key}});e(xt(M.executionId))})}function O(){return E(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:h.id,filter:{key:h.key}});b.message.success(t("Operation succeeded")),e(Ve(M.id))})}function V(){return E(this,null,function*(){const M=h.current?N("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return E(this,null,function*(){var Y;yield l.destroy({filterByTk:h.id}),b.message.success(t("Operation succeeded")),e(h.current?o.systemSettingsManager.getRoutePath("workflow"):Ve((Y=x.find(ae=>ae.current))==null?void 0:Y.id))})}})})}function $(_){return E(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return I();case"revision":return O();case"delete":return V()}})}const P=h.executed&&!x.find(M=>!M.executed&&new Date(M.createdAt)>new Date(h.createdAt));return r.jsxs(Ue.Provider,{value:{workflow:h,nodes:y,refresh:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(xo,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:N("Workflow")})},{title:r.jsx("strong",{children:h.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:k,defaultSelectedKeys:[`${h.id}`],className:s.cx(u.dropdownClass,u.workflowVersionDropdownClass),items:x.sort((M,_)=>_.id-M.id).map((M,_)=>({role:"button","aria-label":`version-${_}`,key:`${M.id}`,icon:M.current?r.jsx(z.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:B.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:h!=null&&h.id?`#${h.id}`:null}),r.jsx(z.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:h.enabled,onChange:T,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!h.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:N("Retry"),disabled:!h.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!P},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:$},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(z.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:eo,components:{ExecutionResourceProvider:ll,ExecutionLink:Rt,ExecutionStatusColumn:Ht,ExecutionTime:Wt}})})]})]}),r.jsx(ho,{entry:C})]})}const xn=()=>{const e=oe.useParams(),{styles:t}=he();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.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:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:cl}})})},dl=()=>{var i;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(i=e.config)==null?void 0:i.collection,n=t.getCollection(o),a=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:a})},pl=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:a,title:i}=e,l=n.find(d=>d.value===a);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:i})})},ul=n=>{var a=n,{params:e,filter:t={}}=a,o=G(a,["params","filter"]);const i=s.useCollectionRecordData(),l=F(w({},o),{params:F(w({},e),{filter:F(w({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,w({},l))};var it=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},bn={exports:{}};(function(e,t){(function(o,n){n()})(it,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,g){var y=new XMLHttpRequest;y.open("GET",p),y.responseType="blob",y.onload=function(){c(y.response,u,g)},y.onerror=function(){console.error("could not download file")},y.send()}function a(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(g){}return 200<=u.status&&299>=u.status}function i(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(g){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof it=="object"&&it.global===it?it:void 0,d=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(p,u,g){var y=l.URL||l.webkitURL,x=document.createElement("a");u=u||p.name||"download",x.download=u,x.rel="noopener",typeof p=="string"?(x.href=p,x.origin===location.origin?i(x):a(x.href)?n(p,u,g):i(x,x.target="_blank")):(x.href=y.createObjectURL(p),setTimeout(function(){y.revokeObjectURL(x.href)},4e4),setTimeout(function(){i(x)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,g){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,g),u);else if(a(p))n(p,u,g);else{var y=document.createElement("a");y.href=p,y.target="_blank",setTimeout(function(){i(y)})}}:function(p,u,g,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,g);var x=p.type==="application/octet-stream",h=/constructor/i.test(l.HTMLElement)||l.safari,C=/CriOS\/[\d]+/.test(navigator.userAgent);if((C||x&&h||d)&&typeof FileReader!="undefined"){var k=new FileReader;k.onloadend=function(){var O=k.result;O=C?O:O.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=O:location=O,y=null},k.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,I=T.createObjectURL(p);y?y.location=I:location.href=I,y=null,setTimeout(function(){T.revokeObjectURL(I)},4e4)}});l.saveAs=c.saveAs=c,e.exports=c})})(bn);var ml=bn.exports;const to=A.observable({value:""}),vn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],Le={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"array",name:"tags",interface:"multipleSelect",uiSchema:{title:'{{t("Tags")}}',type:"array",enum:vn,"x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:D("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,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: "${m}" }) }}`}]}},tags:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},wn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${Le.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:fe.title,tags:fe.tags,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options}}}}}}}},Cn={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${Le.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Le},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:fe.title,tags:fe.tags,type:fe.type,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options}}}}}}}},fl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=R.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),a=s.useFilterByTk(),{values:i}=A.useForm();return{run(){return E(this,null,function*(){yield o.revision({filterByTk:a,values:i}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},gl={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:{data:{}},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:20,maxRows:50}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){R.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:a}=A.useForm();return{run(){return E(this,null,function*(){yield t.test({filterByTk:n,values:a.params}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},yl=({children:e})=>r.jsx(b.Tabs,{type:"card",onChange:t=>{to.value=t},items:[{value:"",label:N("All")}].concat(vn).map(({label:t,value:o},n)=>({label:t,key:o,children:r.jsx(s.CardItem,{children:e})}))}),kn={type:"void",properties:{provider:{type:"void","x-decorator":A.observer(e=>{const t={collection:Le,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return to.value&&(t.params.filter.tags={$anyOf:[to.value]}),r.jsx(s.TableBlockProvider,w(w({},e),t))}),"x-component":yl,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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},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}=R.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useFilterByTk(),{setVisible:i}=s.useActionContext(),{values:l}=A.useForm();return{run(){return E(this,null,function*(){const{data:c}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:a,values:F(w({},l),{workflow:c})}),b.message.success(e("Operation succeeded")),o(),i(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:wn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},tags:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:'{{t("Tags")}}',properties:{tags:{type:"array","x-component":"CollectionField","x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:D("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return v.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:eo}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:Cn,revision:fl,test:gl,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=R.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return E(this,null,function*(){const{data:a}=yield t.dump({filterByTk:o}),i=new Blob([JSON.stringify(a.data,null,2)],{type:"application/json"});ml.saveAs(i,a.data.title+"-"+a.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},hl=()=>{const{t:e}=R.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:Ve(t),onClick:()=>o(!1),children:e("Configure")})};function xl(e){const t=A.useField(),o=s.usePlugin(Z);return A.useFormEffects(()=>{A.onFieldChange("type",n=>{let a=!n.value;if(n.value){const i=o.triggers.get(n.value);i.sync!=null&&(a=!0,t.setValue(i.sync))}t.setPattern(a?"disabled":"editable")})}),r.jsx(Pe,w({},e))}function Sn(e){const{schema:t=kn}=e,o=v.useContext(s.SchemaComponentContext),{getTriggersOptions:n}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[Le,yn],children:r.jsx(s.SchemaComponentContext.Provider,{value:F(w({},o),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:{WorkflowLink:hl,ExecutionResourceProvider:ul,ExecutionLink:Rt,OpenDrawer:To,ExecutionStatusSelect:Do,SyncOptionSelect:xl,ExecutionStatusColumn:Ht,ExecutionTime:Wt,ColumnShowTitle:pl,ColumnShowCollection:dl},scope:{getTriggersOptions:n}})})})}class Z extends s.Plugin{constructor(){super(...arguments);f(this,"triggers",new B.Registry);f(this,"instructions",new B.Registry);f(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,l]=i,d=l,{title:n}=d,a=G(d,["title"]);return{value:o,label:n,color:"gold",options:a}}))}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 Q)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}afterAdd(){return E(this,null,function*(){yield this.pm.add(ti),yield this.pm.add(Ya),yield this.pm.add(Ha),yield this.pm.add(zs),yield this.pm.add(Zr),yield this.pm.add(Ar),yield this.pm.add(yr),yield this.pm.add(ur),yield this.pm.add(Ra),yield this.pm.add(Kr),yield this.pm.add(li),yield this.pm.add(Za),yield this.pm.add(Ga),yield this.pm.add(ri),yield this.pm.add($a),yield this.pm.add(Jr),yield this.pm.add(_r)})}load(){return E(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Sn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:xn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:bo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(Li),this.registerTrigger("collection",Ui),this.registerTrigger("schedule",il),this.registerInstruction("calculation",ci),this.registerInstruction("condition",Oi),this.registerInstruction("end",Vi),this.registerInstruction("query",ji),this.registerInstruction("create",$i),this.registerInstruction("update",zi),this.registerInstruction("destroy",Bi)})}addComponents(){this.app.addComponents({WorkflowLink:qn,WorkflowPage:xn,ExecutionPage:bo})}}S.AddButton=Vt,S.AdditionNotifiedPerson=Wr,S.AutoResizeInput=Oo,S.BaseTypeSets=De,S.Branch=Be,S.BuiltinGroupType=Ke,S.CheckboxGroupWithTooltip=Fo,S.CollectionBlockInitializer=Ne,S.ConfigButtonMessage=Lr,S.DetailsBlockProvider=zt,S.EXECUTION_STATUS=pe,S.ExecutionContextProvider=_o,S.ExecutionLink=Rt,S.ExecutionStatusColumn=Ht,S.ExecutionStatusOptions=ut,S.ExecutionStatusOptionsMap=mt,S.ExecutionStatusSelect=Do,S.ExecutionTime=Wt,S.FieldsSelect=tt,S.FilterDynamicComponent=Oe,S.FlowContext=Ue,S.Instruction=Q,S.JOB_STATUS=xe,S.JobStatusOptions=ft,S.JobStatusOptionsMap=et,S.Node=co,S.NodeDefaultView=rt,S.OpenDrawer=To,S.ProviderContextNode=lo,S.RadioWithTooltip=Pe,S.SelectNotifiedPerson=$r,S.SimpleDesigner=_t,S.Trigger=Ze,S.ValueBlock=Ae,S.WorkflowPane=Sn,S.WorkflowVariableCodeMirror=Or,S.WorkflowVariableInput=Se,S.WorkflowVariableJSON=Io,S.WorkflowVariableRawTextArea=Ao,S.WorkflowVariableTextArea=nt,S.collectionWorkflows=Le,S.createWorkflow=wn,S.currentFormOptions=wo,S.default=Z,S.defaultFieldNames=ue,S.executionSchema=eo,S.formatDuration=jt,S.getCollectionFieldOptions=me,S.getExecutionSchema=hn,S.getWorkflowDetailPath=Ve,S.getWorkflowExecutionsPath=xt,S.isValidFilter=yt,S.linkNodes=gt,S.nodesOptions=bt,S.scopeOptions=Lt,S.systemOptions=Co,S.traverseSchema=ht,S.triggerOptions=vt,S.updateWorkflow=Cn,S.useAvailableUpstreams=$e,S.useContextNode=ye,S.useFlowContext=L,S.useGetAriaLabelOfAddButton=pt,S.useRecordTriggerWorkflowsActionProps=qs,S.useStyles=he,S.useTrigger=Xe,S.useTriggerWorkflowsActionProps=Ls,S.useWorkflowAnyExecuted=Po,S.useWorkflowExecuted=Jt,S.useWorkflowVariableFormOptions=So,S.useWorkflowVariableOptions=ce,S.workflowFieldset=fe,S.workflowSchema=kn,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|