@tachybase/module-workflow 0.23.58 → 1.0.18
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/NodeContext.d.ts +3 -0
- package/dist/client/index.js +52 -52
- package/dist/client/nodes/default-node/components/AddButton.props.d.ts +3 -0
- package/dist/client/nodes/default-node/components/ViewUploadForm.d.ts +1 -0
- package/dist/client/nodes/default-node/components/ViewUploadForm.schema.d.ts +46 -0
- package/dist/client/nodes/default-node/hooks/useCancelActionProps.d.ts +3 -0
- package/dist/client/nodes/default-node/hooks/useCreateActionProps.d.ts +3 -0
- package/dist/client/nodes/updateOrCreate.d.ts +82 -0
- package/dist/externalVersion.js +15 -15
- package/dist/locale/zh-CN.json +11 -0
- 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 +6 -3
- package/dist/server/features/omni-trigger/CustomActionTrigger.js +17 -6
- package/dist/server/instructions/ConditionInstruction.js +16 -0
- package/dist/server/instructions/UpdateOrCreateInstruction.d.ts +10 -0
- package/dist/server/instructions/UpdateOrCreateInstruction.js +232 -0
- package/package.json +18 -17
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(k,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):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tachybase/utils"],k.jsxRuntime,k.antd,k["react-router-dom"],k["react-i18next"],k.react,k["@ant-design/icons"],k["@tachybase/schema"],k.lodash,k["@tachybase/components"],k["@tachybase/evaluators"]))})(this,function(k,s,W,r,x,
|
|
1
|
+
(function(k,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):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tachybase/utils"],k.jsxRuntime,k.antd,k["react-router-dom"],k["react-i18next"],k.react,k["@ant-design/icons"],k["@tachybase/schema"],k.lodash,k["@tachybase/components"],k["@tachybase/evaluators"]))})(this,function(k,s,W,r,x,ne,X,b,j,S,ge,we,Ye){"use strict";var Bl=Object.defineProperty,Vl=Object.defineProperties;var Wl=Object.getOwnPropertyDescriptors;var $t=Object.getOwnPropertySymbols;var zn=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable;var jn=(k,s,W)=>s in k?Bl(k,s,{enumerable:!0,configurable:!0,writable:!0,value:W}):k[s]=W,w=(k,s)=>{for(var W in s||(s={}))zn.call(s,W)&&jn(k,W,s[W]);if($t)for(var W of $t(s))Ln.call(s,W)&&jn(k,W,s[W]);return k},A=(k,s)=>Vl(k,Wl(s));var qn=k=>typeof k=="symbol"?k:k+"",_=(k,s)=>{var W={};for(var r in k)zn.call(k,r)&&s.indexOf(r)<0&&(W[r]=k[r]);if(k!=null&&$t)for(var r of $t(k))s.indexOf(r)<0&&Ln.call(k,r)&&(W[r]=k[r]);return W};var D=(k,s,W)=>new Promise((r,x)=>{var ne=j=>{try{b(W.next(j))}catch(S){x(S)}},X=j=>{try{b(W.throw(j))}catch(S){x(S)}},b=j=>j.done?r(j.value):Promise.resolve(j.value).then(ne,X);b((W=W.apply(k,s)).next())});const m="workflow";function F(e,t={}){return s.i18n.t(e,A(w({},t),{ns:[m,"core"]}))}function ve(){return X.useTranslation([m,"core"])}const N=(e,t={})=>s.tval(e,w({ns:[m,"core"]},t)),Un=()=>{const{t:e}=ve(),t=ne.useNavigate(),{token:o}=s.useToken();return r.jsx(x.Tooltip,{title:e("Workflow"),children:r.jsx(x.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},ut=(e,t)=>({getAriaLabel:b.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),io=b.createContext({}),_n=io.Provider;function Kn(){return b.useContext(io)}const qe=b.createContext({});function q(){return b.useContext(qe)}var Ue=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(Ue||{});class H{}function Gn(e){var h;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(Z),i=s.useCompile(),a=s.useAPIClient(),{workflow:l,refresh:c}=(h=q())!=null?h:{},d=Array.from(n.instructions.getValues()),p=b.useMemo(()=>Yn(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:i}),[o,n,d,t,l]),[u,f]=b.useState(!1),g=b.useCallback(I=>D(this,[I],function*({keyPath:v}){var E,P,$;const T=v.pop(),C={},[O]=v,B=n.instructions.get(T);if(O){const{value:K}=(P=(E=B.options)==null?void 0:E.find(z=>z.key===O))!=null?P:{};Object.assign(C,typeof K=="function"?K():K)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:T,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:i(B.title),config:C}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),y=b.useMemo(()=>({onClick:v=>{const{keyPath:I}=v||{};(I==null?void 0:I[0])==="load"?f(!0):g(v)},items:p}),[p,g]);return{workflow:l,menu:y,isShowUploadModal:u,setIsShowUploadModal:f}}const ao=[{key:Ue.CONTROL,label:F("Control")},{key:Ue.COLLECTION,label:F("Collection operations")},{key:Ue.MANUAL,label:F("Manual")},{key:Ue.EXTENDED,label:F("Extended types")}],Hn={key:"hot",label:F("Hot tools")},Jn={key:"load",label:F("Load")};function Yn(e,{engine:t,workflow:o,upstream:n,branchIndex:i,compile:a}){const l=[],c=[];for(const d of ao){const p=e.filter(g=>{var y,h;return g.group===d.key&&((h=(y=g.isAvailable)==null?void 0:y.call(g,{engine:t,workflow:o,upstream:n,branchIndex:i}))!=null?h:!0)});let u=[];for(const g of p){const{type:y,title:h,icon:v,color:I,options:T,isHot:C}=g,O=lo(v,I),B={role:"button","aria-label":y,key:y,label:a(h),type:T?"subMenu":null,icon:O,children:T?T.map(E=>({role:"button","aria-label":E.key,key:E.key,label:a(E.label)})):null};u.push(B),C&&c.push(B)}const f=A(w({},d),{type:"group",children:u});l.push(f)}return l.unshift(A(w({},Jn),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:F("Upload node"),icon:lo("ToTopOutlined","#ff92ca")}]})),l.unshift(A(w({},Hn),{type:"group",children:c})),l.filter(d=>d.children.length)}function lo(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 Qn=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``})),Bt=e=>{const{styles:
|
|
35
|
+
`,iconContainerClass:e``}));function Zn(){const e=s.useActionContext(),t=S.useForm();return{onClick(){return D(this,null,function*(){var n;(n=e==null?void 0:e.setVisible)==null||n.call(e,!1),t.reset()})}}}function Xn(){var d;const{t:e}=ve(),t=s.useAPIClient(),o=s.useActionContext(),{workflow:n,refresh:i}=(d=q())!=null?d:{},a=S.useForm(),{upstream:l,branchIndex:c}=Kn();return{onClick(){return D(this,null,function*(){var u;try{const g=yield(yield fetch(a.values.file.url)).json();n&&(yield t.resource("workflows.nodes",n.id).create({values:{type:g.type,upstreamId:(u=l==null?void 0:l.id)!=null?u:null,branchIndex:c,title:g.title,config:g.config}}),o.setVisible(!1),x.message.success(e("Operation succeeded")),i(),a.reset())}catch(f){o.setVisible(!1),console.error("JSON解析失败:",f),i()}})}}}const Rn={type:"void","x-decorator":"FormV2",properties:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1,style:{marginTop:"20px"}}},footer:{type:"void","x-component":"ActionBar","x-component-props":{style:{justifyContent:"right"}},properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useCreateActionProps"}}}}},er=()=>r.jsx(s.SchemaComponent,{schema:Rn,scope:{useCancelActionProps:Zn,useCreateActionProps:Xn}}),Bt=e=>{const{t}=ve(),{styles:o}=Qn(),{upstream:n,branchIndex:i=null}=e,{workflow:a,menu:l,isShowUploadModal:c,setIsShowUploadModal:d}=Gn(e);return a?r.jsxs("div",{className:o.addButtonClass,children:[r.jsx(x.Dropdown,{trigger:["click"],disabled:a.executed,overlayClassName:o.dropDownClass,menu:l,children:r.jsx(x.Button,{className:"add-btn",icon:r.jsx(j.PlusOutlined,{}),type:"primary","aria-label":e["aria-label"]||"add-button"})}),r.jsx(x.Modal,{footer:null,closable:!1,title:t("Upload node"),open:c,children:r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:d},children:r.jsx(_n,{value:{upstream:n,branchIndex:i},children:r.jsx(er,{})})})})]}):null};function Ee(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 co=b.createContext({}),po=co.Provider;function he(){return b.useContext(co)}const tr=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
|
-
`})),
|
|
42
|
+
`})),uo=({data:e})=>{const{styles:t}=tr(),{getAriaLabel:o}=ut(e),n=s.usePlugin(Z),{Component:i=st,end:a,group:l}=n.instructions.get(e.type);return r.jsx(po,{value:A(w({},e),{group:l}),children:r.jsxs("div",{className:s.cx(t.nodeBlockClass),children:[r.jsx(i,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Bt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})})]})})},ye=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 $e({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:i,end:a}){const{styles:l}=
|
|
332
|
+
`}));function $e({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:i,end:a}){const{styles:l}=ye(),{getAriaLabel:c}=ut(e,o),d=[];for(let p=t;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,i),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Bt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(uo,{data:p},p.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(j.CloseOutlined,{})}):null]})}const or=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
|
|
357
|
+
`}));function mo(e){const{label:t,title:o,description:n,workflowKey:i,createdAt:a,createdBy:l}=e,{styles:c}=or(),{t:d}=ve();return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:s.cx(c.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(x.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]}),i||a||l?r.jsxs("div",{className:s.cx(c.container,e.className),children:[i?r.jsx("p",{children:`${d("Key")}: ${i}`}):null,a?r.jsx("p",{children:`${d("Created at")}: ${W.convertUTCToLocal(a)}`}):null,l?r.jsx("p",{children:`${d("Created by")}: ${l}`}):null]}):null]})}const fo="json-parse",go="js-parse",ho="data-mapping",_e="deprecated",nr=e=>{var d;const{className:t}=e,{t:o}=ve(),{styles:n}=rr(),i=s.useCompile(),{instructions:a}=s.usePlugin(Z),{nodes:l}=(d=q())!=null?d:{},c=b.useMemo(()=>l==null?void 0:l.reduce((p,u)=>{const f=a.get(u.type),{group:g,title:y}=f,h=ao.find(T=>T.key===g),v={key:g,title:y,groupLabel:h!=null&&h.label?h==null?void 0:h.label:o("Unkown group"),count:1,isDeprecated:g===_e},I=p.findIndex(T=>T.key===g);return I>0?p[I].count++:p.push(v),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")})]}),c.map(({key:p,title:u,groupLabel:f,count:g,isDeprecated:y},h)=>r.jsx("p",{className:y?n.deprecated:"",children:`${h+1}: ${f}:${i(u)}-${g} ${y?o("Deprecated, please do not use it"):""}`},p))]})},rr=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 sr(){var a;const e=S.useForm(),t=s.useAPIClient(),{workflow:o}=(a=q())!=null?a:{},n=s.useActionContext(),{refresh:i}=s.useResourceActionContext();return{run(){return D(this,null,function*(){if(o.executed){x.message.error(F("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),x.message.success("success"),i()})}}}class Qe{}const ir=()=>{const e=s.useCompile(),{workflow:t,execution:o}=q(),{styles:n}=ye(),i=Ze();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:
|
|
389
|
+
`),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:A(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(x.Tag,{children:e(i.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:a}=s.useTranslation();return{run(){return D(this,null,function*(){try{const c=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(c),x.message.success(a("Copied"))}catch(c){x.message.error(a("Copy failed"))}})}}}}}}}}}}}}):null};function ar(){return{form:S.useForm()}}const lr=()=>{var E;const e=s.useAPIClient(),{workflow:t,refresh:o}=q(),[n,i]=b.useState(""),[a,l]=b.useState(!1),[c,d]=b.useState(!1),{styles:p}=ye(),u=s.useCompile(),f=Ze(),g=u(f.title),{fieldset:y,scope:h,components:v}=f,I=t.executed?'{{t("View")}}':'{{t("Configure")}}',T=F("Trigger");b.useEffect(()=>{var P,$;t&&i(($=(P=t.triggerTitle)!=null?P:t.title)!=null?$:g)},[t]);const C=b.useMemo(()=>{const P=ge.cloneDeep(t.config);return S.createForm({initialValues:P,disabled:t.executed})},[t]),O=b.useCallback(P=>{l(P),P||C.reset()},[C]);b.useCallback(function(P){return D(this,null,function*(){const $=P||g;i($),$!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:$}}),o())})},[t]);const B=b.useCallback(function(P){var K;if(P.target===P.currentTarget){l(!0);return}const $=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let z=P.target;z&&z!==P.currentTarget;z=z.parentNode)if(Array.from((K=z.classList)!=null?K:[]).some(J=>$.has(J))){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:B,children:[F("Start"),r.jsx(s.ActionContextProvider,{value:{visible:a,setVisible:O,formValueChanged:c,setFormValueChanged:d},children:r.jsx(s.FormProvider,{form:C,children:r.jsx(s.SchemaComponent,{scope:A(w({},h),{useFormProviderProps:ar}),components:v,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":I,"x-component":x.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:A(w({},f.description?{description:{type:"void","x-component":mo,"x-component-props":{label:F("Trigger type"),title:f.title,description:f.description,workflowKey:t.key,createdAt:t.createdAt,createdBy:(E=t.createdBy)==null?void 0:E.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:
|
|
394
|
+
`},properties:y},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:sr}}}},showNodes:{type:"void","x-component":nr}})}}}})})})]}),r.jsx(ir,{})]})};function Ze(){const e=s.usePlugin(Z),{workflow:t}=q();return e.triggers.get(t.type)}const yo="workflow-zoom";function cr({entry:e}){const{styles:t}=ye(),{workflow:o}=q(),[n,i]=b.useState(100),a=ge.debounce(l=>{localStorage.setItem(yo,l)});return b.useEffect(()=>{const l=localStorage.getItem(yo);l&&Number(l)>0&&i(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(x.Alert,{type:"warning",message:F("Executed workflow cannot be modified"),showIcon:!0,className:s.css`
|
|
397
397
|
margin-bottom: 1em;
|
|
398
|
-
`}):null,r.jsx(
|
|
398
|
+
`}):null,r.jsx(lr,{}),r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
|
|
399
399
|
margin-top: 0 !important;
|
|
400
|
-
`),children:r.jsx($e,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:F("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(x.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{i(l),a(l)}})})]})}const
|
|
400
|
+
`),children:r.jsx($e,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:F("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(x.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{i(l),a(l)}})})]})}const xo="workflow-splitter",bo=({entry:e})=>{const t=q(),[o,n]=b.useState(600),i=ge.debounce(a=>{localStorage.setItem(xo,a)});return b.useEffect(()=>{const a=localStorage.getItem(xo);a&&Number(a)>0&&n(Number(a))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(x.Splitter,{onResize:a=>{n(a[1]),i(String(a[1]))},children:[r.jsx(x.Splitter.Panel,{collapsible:!0,children:r.jsx(cr,{entry:e})}),r.jsx(x.Splitter.Panel,{size:o,min:"240",collapsible:!0,className:"workflow-operator-area",children:r.jsx(s.ActionAreaStub,{})})]})})};function dr(e){if(e>=86313600)return"999 D";const n=Math.floor(e/(24*60*60)),i=Math.floor(e%(24*60*60)/3600),a=Math.floor(e%3600/60),l=e%60;let c="";return n>0&&(c+=`${n} D `),(i>0||n>0)&&(c+=`${i} h `),(a>0||i>0||n>0)&&(c+=`${a} m `),e>=60?c+=`${Math.floor(l)} s`:c+=`${l.toFixed(3)} s`,c.trim()}function pr(e){if(!e)return;const a=e/1e3,l=999*86400;if(a>=l)return"999 D";if(e<6e5){const g=Math.floor(a/60),y=Math.floor(a%60),h=e%1e3;let v=`${h} ms`;return g>0?v=`${g} m ${y} s ${h} ms`:y>0&&(v=`${y} s ${h} ms`),v}const c=Math.floor(a/86400),d=Math.floor(a%86400/3600),p=Math.floor(a%3600/60),u=a%60;let f="";return c>0&&(f+=`${c} D `),(d>0||c>0)&&(f+=`${d} h `),(p>0||d>0||c>0)&&(f+=`${p} m `),a>=60?f+=`${Math.floor(u)} s`:f+=`${u} s`,f.trim()}function ur(e,t){const o=()=>{const a=Date.now(),l=new Date(t.createdAt).getTime();return a-l},[n,i]=b.useState(e||o());return b.useEffect(()=>{let a;return t.status===0?a=setInterval(()=>{i(o())},1e3):i(e),()=>{a&&clearInterval(a)}},[e,t.status]),pr(n)}const wo=e=>{const t=ne.useNavigate();return r.jsx(x.Button,w({type:"text",icon:r.jsx(s.Icon,{type:"ArrowLeftOutlined"}),onClick:()=>{t(-1)}},e))},mr=s.createStyles(({css:e})=>({statusButtonClass:e`
|
|
401
401
|
border: none;
|
|
402
402
|
.ant-tag {
|
|
403
403
|
display: inline-grid;
|
|
@@ -411,22 +411,22 @@
|
|
|
411
411
|
}
|
|
412
412
|
`,noStatusButtonClass:e`
|
|
413
413
|
border-width: 2px;
|
|
414
|
-
`}));function Xe(e){var n;const{styles:t}=rr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:i,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:i})}return r.jsx(x.Button,I(v({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},pt=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(j.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(j.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ut=pt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var ye=(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))(ye||{});const mt=[{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"})}],Re=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function ft(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 ht(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return ht(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[i]=Object.keys(o[n]);return!(!i||typeof o[n][i]=="undefined")}):!1}function gt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{gt(e.properties[o],t)})}function Be(e){return`/_admin/business-components/workflow/${e}/workflow`}function yt(e){return`/_admin/business-components/workflow/${e}/executions`}function sr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const i=o.get(n.nodeId);i.jobs.push(n),n.node={id:i.id,key:i.key,title:i.title,type:i.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((i,a)=>i.id-a.id)})}function ir(){const{instructions:e}=s.usePlugin(Z),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=tr(o.cost/1e3);const{styles:i}=ge(),{node:a={}}=o!=null?o:{},l=e.get(a.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:I(v({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.nodeTitleClass,children:[r.jsx(x.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},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:c}=X.useTranslation();return{run(){return O(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),x.message.success(c("Copied"))}catch(p){x.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function ar(e){const{execution:t}=q(),o=s.useAPIClient(),n=oe.useNavigate(),{styles:i}=ge(),[a,l]=b.useState([]),[c,d]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{d(u.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:u})=>{u!==t.id&&n(yt(u))},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(i.dropdownClass,i.executionsDropdownRowClass),items:[...c,t,...a].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:W.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Xe,{statusMap:ut,status:u.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function lr(){var C;const{t:e}=X.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=b.useState(null),d=s.useApp(),p=s.useAPIClient();b.useEffect(()=>{var B;const{workflow:P}=(B=o==null?void 0:o.data)!=null?B:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${F("Execution history")}`)},[o==null?void 0:o.data]);const u=b.useCallback(()=>{x.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{x.message.success(e("Operation succeeded")),i()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const D=(C=o==null?void 0:o.data)!=null?C:{},{jobs:f=[],workflow:$={}}=D,E=$,{nodes:h=[],revisions:g=[]}=E,y=K(E,["nodes","revisions"]),w=K(D,["jobs","workflow"]);ft(h),sr(h,f);const A=h.find(P=>!P.upstream),T=ut[w.status];return r.jsxs(qe.Provider,{value:{workflow:y.type?y:null,nodes:h,execution:w,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(go,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx(oe.Link,{to:Be(y.id),children:y.title})},{title:r.jsx(ar,{})}]})]}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:T.color,children:t(T.label)}),w.status?null:r.jsx(x.Tooltip,{title:F("Cancel the execution"),children:r.jsx(x.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:W.str2moment(w.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(ho,{entry:A}),r.jsx(ir,{})]})}const yo=()=>{const e=oe.useParams(),{styles:t}=ge();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:lr}})})};function cr(e){return["hasMany","belongsToMany"].includes(e.type)}function dr(){const e=s.useCompile();return[xt,bt].map(t=>{var n;const o=(n=t.useOptions({types:[cr],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 pr(n){var i=n,{value:e,onChange:t}=i,o=K(i,["value","onChange"]);const{setValuesIn:a}=S.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=dr(),[d,p]=b.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let h=[];const g=u.match(/^{{(.*)}}$/);g&&(h=[...g[1].trim().split(".").slice(0,-1),f]);const y=A=>O(this,null,function*(){var C;const T=A[A.length-1];!((C=T.children)!=null&&C.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(D=>[...D]))});b.useEffect(()=>{O(this,null,function*(){var C;if(!h||d.length<=1)return;let T=null;for(let D=0;D<h.length;D++){const $=h[D];try{D===0?T=d.find(E=>E.value===$):(T.loadChildren&&!((C=T.children)!=null&&C.length)&&(yield T.loadChildren(T)),T=T.children.find(E=>E.value===$))}catch(E){console.error(E)}}p([...d])})},[e,d.length]);const w=b.useCallback((A,T)=>{if(!(A!=null&&A.length)){a("collection",null),t({});return}const{field:C}=T.pop();if(!C||!["hasMany","belongsToMany"].includes(C.type))return;const{collectionName:D,target:$,name:E,dataSourceKey:P}=C,_=l(D,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${$}`),t({name:E,associatedKey:`{{${A.slice(0,-1).join(".")}.${_.name}}}`,associatedCollection:s.joinCollectionName(P,D)})},[t]);return r.jsx(x.Cascader,I(v({},o),{value:h,options:d,changeOnSelect:!0,onChange:w,loadData:y}))}class ur extends Q{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",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}" })}}`,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(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.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:t}=S.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
|
|
414
|
+
`}));function Xe(e){var n;const{styles:t}=mr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:i,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:i})}return r.jsx(x.Button,A(w({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(j.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(j.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ft=mt.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 gt=[{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"})}],Re=gt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function ht(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 et(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return et(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[i]=Object.keys(o[n]);return!(!i||typeof o[n][i]=="undefined")}):!1}function yt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{yt(e.properties[o],t)})}function Be(e){return`/_admin/business-components/workflow/${e}/workflow`}function xt(e){return`/_admin/business-components/workflow/${e}/executions`}function fr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const i=o.get(n.nodeId);i.jobs.push(n),n.node={id:i.id,key:i.key,title:i.title,type:i.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((i,a)=>i.id-a.id)})}function gr(){const{instructions:e}=s.usePlugin(Z),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=dr(o.cost/1e3);const{styles:i}=ye(),{node:a={}}=o!=null?o:{},l=e.get(a.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:A(w({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.nodeTitleClass,children:[r.jsx(x.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:gt,"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:c}=X.useTranslation();return{run(){return D(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),x.message.success(c("Copied"))}catch(p){x.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function hr(e){const{execution:t}=q(),o=s.useAPIClient(),n=ne.useNavigate(),{styles:i}=ye(),[a,l]=b.useState([]),[c,d]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{d(u.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:u})=>{u!==t.id&&n(xt(u))},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(i.dropdownClass,i.executionsDropdownRowClass),items:[...c,t,...a].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:W.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Xe,{statusMap:ft,status:u.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function yr(){var C;const{t:e}=X.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=b.useState(null),d=s.useApp(),p=s.useAPIClient();b.useEffect(()=>{var $;const{workflow:P}=($=o==null?void 0:o.data)!=null?$:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${F("Execution history")}`)},[o==null?void 0:o.data]);const u=b.useCallback(()=>{x.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{x.message.success(e("Operation succeeded")),i()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const O=(C=o==null?void 0:o.data)!=null?C:{},{jobs:f=[],workflow:B={}}=O,E=B,{nodes:g=[],revisions:y=[]}=E,h=_(E,["nodes","revisions"]),v=_(O,["jobs","workflow"]);ht(g),fr(g,f);const I=g.find(P=>!P.upstream),T=ft[v.status];return r.jsxs(qe.Provider,{value:{workflow:h.type?h:null,nodes:g,execution:v,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(wo,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(ne.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx(ne.Link,{to:Be(h.id),children:h.title})},{title:r.jsx(hr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:T.color,children:t(T.label)}),v.status?null:r.jsx(x.Tooltip,{title:F("Cancel the execution"),children:r.jsx(x.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:W.str2moment(v.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(bo,{entry:I}),r.jsx(gr,{})]})}const vo=()=>{const e=ne.useParams(),{styles:t}=ye();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:yr}})})};function xr(e){return["hasMany","belongsToMany"].includes(e.type)}function br(){const e=s.useCompile();return[bt,wt].map(t=>{var n;const o=(n=t.useOptions({types:[xr],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 wr(n){var i=n,{value:e,onChange:t}=i,o=_(i,["value","onChange"]);const{setValuesIn:a}=S.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=br(),[d,p]=b.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let g=[];const y=u.match(/^{{(.*)}}$/);y&&(g=[...y[1].trim().split(".").slice(0,-1),f]);const h=I=>D(this,null,function*(){var C;const T=I[I.length-1];!((C=T.children)!=null&&C.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(O=>[...O]))});b.useEffect(()=>{D(this,null,function*(){var C;if(!g||d.length<=1)return;let T=null;for(let O=0;O<g.length;O++){const B=g[O];try{O===0?T=d.find(E=>E.value===B):(T.loadChildren&&!((C=T.children)!=null&&C.length)&&(yield T.loadChildren(T)),T=T.children.find(E=>E.value===B))}catch(E){console.error(E)}}p([...d])})},[e,d.length]);const v=b.useCallback((I,T)=>{if(!(I!=null&&I.length)){a("collection",null),t({});return}const{field:C}=T.pop();if(!C||!["hasMany","belongsToMany"].includes(C.type))return;const{collectionName:O,target:B,name:E,dataSourceKey:P}=C,K=l(O,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${B}`),t({name:E,associatedKey:`{{${I.slice(0,-1).join(".")}.${K.name}}}`,associatedCollection:s.joinCollectionName(P,O)})},[t]);return r.jsx(x.Cascader,A(w({},o),{value:g,options:d,changeOnSelect:!0,onChange:v,loadData:h}))}class vr extends H{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",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}" })}}`,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(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.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:t}=S.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),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]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:De,FieldsSelect:et,ValueBlock:Se,AssociatedConfig:pr}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:o}:null}}class mr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",ur)})}}const xo=[{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 fr(e){return xo.slice().reverse().find(t=>!(e%t.value))}function hr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=fr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(x.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(x.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:xo.map(a=>({value:a.value,label:o(a.label)}))})]})}class gr extends Q{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",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}" })}}`,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:ye.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED}},this.components={Duration:hr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class yr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",gr)})}}function xr(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 br({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=le({types:[xr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class vr extends Q{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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}" })}}`,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]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:br,WorkflowVariableInput:ke,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const wr=S.observer(e=>{const{onChange:t}=e,o=S.useField(),n=S.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();S.useFormEffects(()=>{S.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),S.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=ue({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,I(v({},e),{scope:u}))},{displayName:"InternalExpression"});function Cr(e){const{t}=X.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=b.useMemo(()=>ue({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,I(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:m})})}const kr=S.connect(wr,S.mapReadPretty(Cr)),{defaultProps:Sr}=s.interfacesProperties;class Ar extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=v({},Sr)}}class Ir extends s.Plugin{load(){return O(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Ar]),this.app.addComponents({DynamicExpression:kr});const t=this.app.pm.get("workflow"),o=new vr;t.instructions.register(o.type,o)})}}function Fr(n){var i=n,{collection:e,dataPath:t}=i,o=K(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,h]=s.parseCollectionName(e);p=c(h,f)}else p=e;function u(h){return O(this,arguments,function*({item:f}){const g=f.template?yield l(f):null,y={type:"void",name:S.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:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};gt(y,w=>{w["x-uid"]&&delete w["x-uid"]}),a(y)})}return r.jsx(s.SchemaInitializerItem,I(v({},o),{onClick:u,items:d}))}function Te(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(Fr,v(v({},t),e))})}function Tr(e){const{execution:t,nodes:o}=q(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=b.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return b.useMemo(()=>fe.get(i,e),[i,e])}function Vt({collection:e,dataPath:t,children:o}){const n=S.useField(),i=b.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Tr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=b.useMemo(()=>S.createForm({values:d,readPretty:!0}),[d]),h={appends:l},g={loading:!1,data:{data:d}},w=s.useAPIClient().resource(u),A=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:w,__parent:A},children:r.jsx(s.FormBlockContext.Provider,{value:{params:h,form:f,field:n,service:g,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Nr(){return!0}const et=S.observer(e=>{const p=e,{filter:t=Nr}=p,o=K(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=S.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(x.Select,I(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Dr(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 pe={label:"label",value:"value",children:"children"},bo={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=he(),n=s.usePlugin(Z).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},xt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=he(),n=Ee(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},bt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(Z),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},Wt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=pe,current:o}=e,{instructions:n}=s.usePlugin(Z),i=he(),a=o!=null?o:i,l=Dr(a),c=[];return l.forEach(d=>{var f,h;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(h=d.title)!=null?h:`#${d.id}`,[t.children]:u})}),c}},vo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=pe}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},Ne={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 wo(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=Ne[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?jt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function jt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function zt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Lt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>wo(l,d)):!0;if(jt(l)){if(o===null)return n?c||Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=zt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function tt(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function le(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(Wt,o),tt(xt,o),tt(bt,o),tt(vo,o),s.useGlobalVariable("$env")].filter(Boolean)}function Co(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(bo,o)]}function qt(e,{compile:t,getCollectionFields:o}){var d,p,u,f,h,g,y;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const A=c[w];if(A.type==="belongsTo"){const T=l.find(C=>C.name===A.foreignKey);T?c.splice(w,0,I(v(v({},A),T),{uiSchema:I(v({},A.uiSchema),{title:(d=A.uiSchema)!=null&&d.title?`${t((p=A.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(w,0,I(v({},A),{name:A.foreignKey,type:"bigInt",isForeignKey:!0,interface:A.interface,uiSchema:I(v({},A.uiSchema),{title:(u=A.uiSchema)!=null&&u.title?`${t((f=A.uiSchema)==null?void 0:f.title)} ID`:A.name})}))}else if(A.type==="context"&&A.collectionName==="users"){const T=(h=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===A.name))!=null?h:{};c.splice(w,0,I(v({},A),{type:A.dataType,interface:T.interface,uiSchema:I(v({},T.uiSchema),{title:(g=T.uiSchema)!=null&&g.title?`${t((y=T.uiSchema)==null?void 0:y.title)} ID`:A.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function Or(e){const t=zt(e.field,e.appends),o=ue(v({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(i=>wo(e.field,i))||(e.disabled=!0))}function ue(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=pe}=e,p=t!=null?t:qt(o,{compile:l,getCollectionFields:c}),u=Or.bind({compile:l,getCollectionFields:c,fieldNames:d});return Lt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(h=>{var A;const g=l(((A=h.uiSchema)==null?void 0:A.title)||h.name),y=zt(h,i),w=!jt(h)||y&&!y.length&&!i.includes(h.name)||!1;return{[d.label]:g,key:h.name,[d.value]:h.name,isLeaf:w,loadChildren:w?null:u,field:h,depth:a,appends:i,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.Input,v({scope:i},t))}function ot(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.TextArea,v({scope:i},t))}function ko(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.RawTextArea,v({scope:i},t))}function So(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.JSON,v({scope:i},t))}function Pr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=Co(e),l=le(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...a,...l,...i]},t))}function De({value:e,onChange:t,renderSchemaComponent:o}){const n=le();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Oe(e){const a=e,{options:t=[],direction:o}=a,n=K(a,["options","direction"]),i=s.useCompile();return r.jsx(x.Radio.Group,I(v({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.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]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:Ie,FieldsSelect:tt,ValueBlock:Se,AssociatedConfig:wr}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Oe||Object.values(Oe).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:o}:null}}class Cr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",vr)})}}const Co=[{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 kr(e){return Co.slice().reverse().find(t=>!(e%t.value))}function Sr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=kr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(x.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(x.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:Co.map(a=>({value:a.value,label:o(a.label)}))})]})}class Ar extends H{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",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}" })}}`,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}},this.components={Duration:Sr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class Ir extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Ar)})}}function Fr(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 Tr({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=le({types:[Fr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class Nr extends H{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",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}" })}}`,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]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:Tr,WorkflowVariableInput:ke,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Oe||Object.values(Oe).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const Dr=S.observer(e=>{const{onChange:t}=e,o=S.useField(),n=S.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();S.useFormEffects(()=>{S.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),S.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=ue({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,A(w({},e),{scope:u}))},{displayName:"InternalExpression"});function Or(e){const{t}=X.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=b.useMemo(()=>ue({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,A(w({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:m})})}const Pr=S.connect(Dr,S.mapReadPretty(Or)),{defaultProps:Mr}=s.interfacesProperties;class Er extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=w({},Mr)}}class $r extends s.Plugin{load(){return D(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Er]),this.app.addComponents({DynamicExpression:Pr});const t=this.app.pm.get("workflow"),o=new Nr;t.instructions.register(o.type,o)})}}function Br(n){var i=n,{collection:e,dataPath:t}=i,o=_(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,g]=s.parseCollectionName(e);p=c(g,f)}else p=e;function u(g){return D(this,arguments,function*({item:f}){const y=f.template?yield l(f):null,h={type:"void",name:S.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:y||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};yt(h,v=>{v["x-uid"]&&delete v["x-uid"]}),a(h)})}return r.jsx(s.SchemaInitializerItem,A(w({},o),{onClick:u,items:d}))}function De(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(Br,w(w({},t),e))})}function Vr(e){const{execution:t,nodes:o}=q(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=b.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return b.useMemo(()=>ge.get(i,e),[i,e])}function Vt({collection:e,dataPath:t,children:o}){const n=S.useField(),i=b.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Vr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=b.useMemo(()=>S.createForm({values:d,readPretty:!0}),[d]),g={appends:l},y={loading:!1,data:{data:d}},v=s.useAPIClient().resource(u),I=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:y,resource:v,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:{params:g,form:f,field:n,service:y,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Wr(){return!0}const tt=S.observer(e=>{const p=e,{filter:t=Wr}=p,o=_(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=S.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(x.Select,A(w({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function jr(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 pe={label:"label",value:"value",children:"children"},ko={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=he(),n=s.usePlugin(Z).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},bt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=he(),n=Ee(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(Z),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},Wt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=pe,current:o}=e,{instructions:n}=s.usePlugin(Z),i=he(),a=o!=null?o:i,l=jr(a),c=[];return l.forEach(d=>{var f,g;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(g=d.title)!=null?g:`#${d.id}`,[t.children]:u})}),c}},So={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=pe}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},Oe={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 Ao(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=Oe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?jt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function jt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function zt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Lt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Ao(l,d)):!0;if(jt(l)){if(o===null)return n?c||Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=zt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function ot(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function le(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[ot(Wt,o),ot(bt,o),ot(wt,o),ot(So,o),s.useGlobalVariable("$env")].filter(Boolean)}function Io(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[ot(ko,o)]}function qt(e,{compile:t,getCollectionFields:o}){var d,p,u,f,g,y,h;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(v=>{v.isForeignKey?l.push(v):c.push(v)});for(let v=c.length-1;v>=0;v--){const I=c[v];if(I.type==="belongsTo"){const T=l.find(C=>C.name===I.foreignKey);T?c.splice(v,0,A(w(w({},I),T),{uiSchema:A(w({},I.uiSchema),{title:(d=I.uiSchema)!=null&&d.title?`${t((p=I.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(v,0,A(w({},I),{name:I.foreignKey,type:"bigInt",isForeignKey:!0,interface:I.interface,uiSchema:A(w({},I.uiSchema),{title:(u=I.uiSchema)!=null&&u.title?`${t((f=I.uiSchema)==null?void 0:f.title)} ID`:I.name})}))}else if(I.type==="context"&&I.collectionName==="users"){const T=(g=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===I.name))!=null?g:{};c.splice(v,0,A(w({},I),{type:I.dataType,interface:T.interface,uiSchema:A(w({},T.uiSchema),{title:(y=T.uiSchema)!=null&&y.title?`${t((h=T.uiSchema)==null?void 0:h.title)} ID`:I.name})}))}}return c.filter(v=>v.interface&&!v.hidden)}function zr(e){const t=zt(e.field,e.appends),o=ue(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(i=>Ao(e.field,i))||(e.disabled=!0))}function ue(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=pe}=e,p=t!=null?t:qt(o,{compile:l,getCollectionFields:c}),u=zr.bind({compile:l,getCollectionFields:c,fieldNames:d});return Lt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(g=>{var I;const y=l(((I=g.uiSchema)==null?void 0:I.title)||g.name),h=zt(g,i),v=!jt(g)||h&&!h.length&&!i.includes(g.name)||!1;return{[d.label]:y,key:g.name,[d.value]:g.name,isLeaf:v,loadChildren:v?null:u,field:g,depth:a,appends:i,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.Input,w({scope:i},t))}function nt(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.TextArea,w({scope:i},t))}function Fo(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.RawTextArea,w({scope:i},t))}function To(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.JSON,w({scope:i},t))}function Lr(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const{options:i=[]}=t,a=Io(e),l=le(e);return r.jsx(s.Variable.CodeMirror,w({scope:[...a,...l,...i]},t))}function Ie({value:e,onChange:t,renderSchemaComponent:o}){const n=le();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Fe(e){const a=e,{options:t=[],direction:o}=a,n=_(a,["options","direction"]),i=s.useCompile();return r.jsx(x.Radio.Group,A(w({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.Radio,{value:l.value,children:[r.jsx("span",{className:s.css`
|
|
418
418
|
& + .anticon {
|
|
419
419
|
margin-left: 0.25em;
|
|
420
420
|
}
|
|
421
|
-
`,children:i(l.label)}),l.tooltip&&r.jsx(x.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function
|
|
421
|
+
`,children:i(l.label)}),l.tooltip&&r.jsx(x.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function No(e){const a=e,{options:t=[],direction:o}=a,n=_(a,["options","direction"]),i=s.useCompile();return r.jsx(x.Checkbox.Group,A(w({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.Checkbox,{value:l.value,children:[r.jsx("span",{className:s.css`
|
|
422
422
|
& + .anticon {
|
|
423
423
|
margin-left: 0.25em;
|
|
424
424
|
}
|
|
425
|
-
`,children:i(l.label)}),l.tooltip&&r.jsx(x.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Ut(){const e=S.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 Se=()=>null;function
|
|
425
|
+
`,children:i(l.label)}),l.tooltip&&r.jsx(x.Tooltip,{title:i(l.tooltip),children:r.jsx(j.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Ut(){const e=S.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 Se=()=>null;function qr(){const a=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=_(a,["node","resultTitle"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{var l;i({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 Ur({dataSource:e}){var i;const t=S.useFieldSchema(),{execution:o}=q();if(!o)return t.title;const n=W.parse(e)({$jobsMapByNodeKey:((i=o.jobs)!=null?i:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
|
|
426
426
|
margin: 0;
|
|
427
|
-
`,children:JSON.stringify(n,null,2)})}Se.Initializer=
|
|
427
|
+
`,children:JSON.stringify(n,null,2)})}Se.Initializer=qr,Se.Result=Ur,Se.Designer=Ut;function Do(n){var i=n,{component:e="div",children:t}=i,o=_(i,["component","children"]);const[a,l]=b.useState(!1),c=S.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Oo(e){var a;const o=s.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:i}=(a=ft[e.value])!=null?a:{};return r.jsx(x.Tag,{color:i,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function _r(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Oo,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function Po(t){var e=_(t,[]);const o=e.multiple?"multiple":null;return r.jsx(x.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Oo,children:mt.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(x.Select.Option,A(w({},n),{children:r.jsx(_r,w({},n))}),n.value))}))}function _t(e){const{t}=X.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useCollectionRecordData(),a=b.useCallback(()=>{x.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:i.id}).then(()=>{x.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[i]);return r.jsxs("div",{className:s.css`
|
|
428
428
|
display: flex;
|
|
429
|
-
`,children:[e.children,i.status?null:r.jsx(x.Tooltip,{title:F("Cancel the execution"),children:r.jsx(x.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})})]})}const
|
|
429
|
+
`,children:[e.children,i.status?null:r.jsx(x.Tooltip,{title:F("Cancel the execution"),children:r.jsx(x.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})})]})}const Mo=t=>{var e=_(t,[]);const[o,n]=b.useState(30),i=b.useRef(null),a=l=>{var c;n(i.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return b.useEffect(()=>{n(i.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(x.Input,A(w({},e),{onChange:a,style:{width:`${o}px`}})),r.jsx("span",{ref:i,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},Kr=e=>e.value&&typeof e.value=="object"?r.jsx(Hr,w({},e)):r.jsx(Gr,w({},e)),Gr=({value:e,onChange:t})=>{const o=le({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})})},Hr=()=>{const e=S.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:Ie}}}}})})};function Jr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Kt(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function Eo(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const Yr=()=>{const e=Kt(),t=we.ArrayItems.useArray()||{field:[]},{t:o}=ve(),[n,i]=b.useState(!1),a=b.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=b.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(x.Popover,{open:n,onOpenChange:i,content:r.jsx(Qr,{onSlecet:a,onQuery:l}),children:r.jsx(x.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Qr=({onSlecet:e,onQuery:t})=>{const{t:o}=ve();return r.jsxs(x.Space,{direction:"vertical",size:"small",children:[r.jsx(x.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(x.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Zr=e=>{const{t}=ve(),[o,n]=b.useState(!1),i=b.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Gt=()=>{const{t:e}=X.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(ne.Link,{to:xt(t),onClick:()=>o(!1),children:e("View")})},Ht=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest();return{onClick(){return D(this,null,function*(){yield t.retry({filterByTk:e.id}),o==null||o.refresh()})}}};function Xr(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:F("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:F("Values submitted"),value:"values",children:ue(A(w({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class Rr extends Qe{constructor(){super(...arguments),this.sync=!0,this.title=F("Interceptor"),this.description=F('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.'),this.fieldset={collection:{type:"string",title:N("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:N("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:N("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:N("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:N("Create record action"),value:"create"},{label:N("Update record action"),value:"update"},{label:N("Delete record action"),value:"destroy"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FieldsSelect:tt,RadioWithTooltip:Fe,CheckboxGroupWithTooltip:No},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=ue(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User acted")}}],compile:n,getCollectionFields:i})),l=[{label:F("Parameters"),value:"params",children:Xr(t,o)}];return[...a,{label:F("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:De,collection:t.collection,dataPath:"$context.params.values"}:null}}class es extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(Z).registerTrigger("request-interception",Rr)})}}class ts extends H{constructor(){super(...arguments),this.title=N("JS Parse"),this.type=go,this.group=_e,this.description=N("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:N("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:N("P
|
|
|
440
440
|
button {
|
|
441
441
|
padding: 0;
|
|
442
442
|
}
|
|
443
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:
|
|
443
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:we.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class os extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(Z).registerInstruction(go,ts)})}}class ns extends H{constructor(){super(...arguments),this.title=N("JSON Parse"),this.type=fo,this.group=_e,this.description=N("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:N("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:N("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:N("Properties mapping"),description:N("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:N("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:N("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("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:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:
|
|
450
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:we.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}isAvailable(){return!1}}class rs extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(Z).registerInstruction(fo,ns)})}}function ss(e,t){let o=e,n=null;for(let i=0;i<t.length;i++){const a=t[i],l=o.find(c=>c.value===a);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class is extends H{constructor(){super(...arguments),this.title=`{{t("Loop", { ns: "${m}" })}}`,this.type="loop",this.group="control",this.icon="RetweetOutlined",this.color="#0ed6ec",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}" })}}`,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 {
|
|
@@ -457,25 +457,25 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
457
457
|
.ant-input.null-value {
|
|
458
458
|
width: 100%;
|
|
459
459
|
}
|
|
460
|
-
`},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableInput:ke}}Component({data:t}){var a;const{nodes:o}=q(),{styles:n}=
|
|
460
|
+
`},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableInput:ke}}Component({data:t}){var a;const{nodes:o}=q(),{styles:n}=ye(),i=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(st,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
|
|
461
461
|
padding-left: 20em;
|
|
462
|
-
`),children:[r.jsx($e,{from:t,entry:i,branchIndex:(a=i==null?void 0:i.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(j.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),i=F("Loop target"),a=F("Loop index"),l=F("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=pe}=o;let p={key:"item",[d.value]:"item",[d.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const u=c.slice(2,-2).split(".").map(
|
|
462
|
+
`),children:[r.jsx($e,{from:t,entry:i,branchIndex:(a=i==null?void 0:i.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(j.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),i=F("Loop target"),a=F("Loop index"),l=F("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=pe}=o;let p={key:"item",[d.value]:"item",[d.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const u=c.slice(2,-2).split(".").map(y=>y.trim()),f=[Wt,bt,wt].map(y=>{const h=y.useOptions(A(w({},o),{current:t})).filter(Boolean);return{[d.label]:n(y.label),[d.value]:y.value,key:y.value,[d.children]:h,disabled:h&&!h.length}}),g=ss(f,u);p=Object.assign({},g,p)}return[p,{key:"index",[d.value]:"index",[d.label]:a},{key:"length",[d.value]:"length",[d.label]:l}]}}class as extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",is)})}}function ls(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function cs({multiple:e=!1,value:t=[],onChange:o}){const n=le({types:[ls]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:i=>{o([i])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:i=>{o(i!=null?[i]:[])}})})}function ds({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(we.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:F("Negotiation"),children:r.jsxs(x.Radio.Group,{value:e,onChange:t,children:[r.jsx(x.Radio,{value:1,children:r.jsxs(x.Tooltip,{title:F("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:F("All pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:-1,children:r.jsxs(x.Tooltip,{title:F("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:F("Any pass")}),r.jsx(j.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(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:F("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:F("Separately")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:!1,children:r.jsxs(x.Tooltip,{title:F("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:F("Collaboratively")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Oo(e){var E,P,B;const t=s.useRecord(),o=S.useFieldSchema(),n=S.useField(),i=b.useRef(null),a=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(a),{appends:c,updateAssociationValues:d}=l(),[p]=Object.keys((E=o.toJSON().properties)!=null?E:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[p],{findComponent:f}=s.useDesignable(),h=f((B=n.component)==null?void 0:B[0])||b.Fragment,g=b.useMemo(()=>S.createForm({initialValues:u}),[u]),y=b.useMemo(()=>v({appends:c},e.params),[c,e.params]),w=b.useMemo(()=>({loading:!1,data:{data:u}}),[u]),A=s.useAPIClient(),T=s.useDataSourceHeaders(a),C=A.resource(e.collection,void 0,T),D=s.useBlockRequestContext(),$=b.useMemo(()=>({params:y,form:g,field:n,service:w,updateAssociationValues:d,formBlockRef:i}),[n,g,y,w,d]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:a,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:w,resource:C,__parent:D},children:r.jsx(s.FormBlockContext.Provider,{value:$,children:r.jsxs(h,I(v({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:g}),r.jsx("div",{ref:i,children:r.jsx(S.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function os(e){return s.createFormBlockSchema(e)}function ns(o){var n=o,{schema:e}=n,t=K(n,["schema"]);const{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),{insert:a}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(p){return O(this,arguments,function*({item:d}){var y;const u=d.template?yield i(d):null,f=os(I(v({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ye.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:u}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[h]=Object.keys(f.properties),g=((y=Object.entries(f.properties[h].properties).find(([w,A])=>A["x-component"]==="ActionBar"))==null?void 0:y[0])||"actions";f.properties[h].properties[g]["x-decorator"]="ActionBarProvider",f.properties[h].properties[g]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},gt(f,w=>{w["x-uid"]&&delete w["x-uid"]}),a(f)})}return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:c,items:l}))}function Po(){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(ns,v({},e))})}function Pe(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(i=>{n.push(...Pe(e.properties[i],t))}),n):n}function rs(){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 ss={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=b.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:fe.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Po}))})),[e]),[o,n]=b.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{CreateFormDesigner:rs},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Pe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Mo(e){var p,u,f,h;const[t,o]=b.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),i=S.useField(),a=S.useFieldSchema(),[l]=Object.keys((f=a.toJSON().properties)!=null?f:{}),c=(h=n==null?void 0:n.result)==null?void 0:h[l],d=b.useMemo(()=>S.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:I(v({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:i,setCollectionFields:o},children:e.children})})}):null}function is(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:W.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[W.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:ye.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Eo={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:i="others"}=n;t[i]=t[i]||{},fe.set(t,[i,o],n)}),Object.keys(Eo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Eo[o],children:Object.keys(t[o]||{}).map(n=>{const i=t[o][n];return v({value:n,title:i.title,name:n},t[o][n])}).sort((n,i)=>n.order-i.order)}))}function ls(){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:ps,fieldInterface:n.name}))}))}const $o=b.createContext({}),cs=e=>{const[t,o]=b.useState(null),[n,i]=b.useState(),a=ls(),l=s.useCollection_deprecated(),{setCollectionFields:c}=b.useContext(s.FormBlockContext),d=b.useMemo(()=>S.createForm(),[t]);return r.jsxs($o.Provider,{value:{onAddField(p){const u=fe.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,C=T,{unique:f,type:h,layout:g,autoIncrement:y}=C,w=K(C,["unique","type","layout","autoIncrement"]);u.properties=w;const A=fe.cloneDeep(u);delete A.properties.name["x-disabled"],o(A)},setCallback:i},children:[r.jsx(s.SchemaInitializerItems,I(v({},e),{items:a})),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:d},"x-component":"Action.Drawer",properties:I(v({},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=S.useForm();return{run(){return O(this,null,function*(){i(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:f}=S.useForm(),h=[F("Field name existed in form")];return{run(){return O(this,null,function*(){var C,D,$,E;const{default:y}=t,w=W.uid();if(y.name=(C=p.name)!=null?C:w,y.uiSchema.title=($=(D=p.uiSchema)==null?void 0:D.title)!=null?$:w,y.interface=t.name,(E=l.fields)==null?void 0:E.find(P=>P.name===y.name)){u("name").take().setFeedback({type:"error",messages:h});return}const T=W.merge(y,p);c([...l.fields,T]),n({name:y.name,type:y.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${y.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),i(null),o(null)})}}}}}}}})},components:{ArrayTable:be.ArrayTable}}):null})]})},ds=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:cs});function ps(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:i}=b.useContext($o),{getInterface:a}=s.useCollectionManager_deprecated(),l=a(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,v({onClick:()=>{i(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const Bo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:is}},initializers:{},components:{CustomFormBlockProvider:Mo},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=Pe(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var f,h;return(h=(f=u["x-component-props"])==null?void 0:f.field)!=null?h:u["x-interface-options"]});const c=((d=Object.entries(a.properties).find(([u,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[i]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Pe(a.properties[c],u=>u["x-component"]==="Action").map(u=>{var f,h;return{status:u["x-decorator-props"].value,values:(h=(f=u["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:h.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Mo}}};function us(){const{name:e,title:t}=s.useCollection_deprecated(),o=S.useFieldSchema(),{t:n}=X.useTranslation(),{dn:i}=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:a})=>{o["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ms={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=b.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:fe.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Po}))})),[e]),[o,n]=b.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:De,UpdateFormDesigner:us},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]=I(v({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Pe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Me=new W.Registry;Me.register("customForm",Bo),Me.register("createForm",ss),Me.register("updateForm",ms);function fs(){const{workflow:e}=q(),t=Ze();return t.useInitializers?t.useInitializers(e.config):null}Bo.title,`${m}`;const hs=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=he(),o=Ee(t),n=[fs()].filter(Boolean),i=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:i}]:[]].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 A,T,C;const e=b.useContext(s.SchemaComponentContext),{t}=X.useTranslation(),o=S.useFieldSchema(),n=le(),[i,a]=b.useState(!1),[l,c]=b.useState((C=(T=(A=o==null?void 0:o["x-action-settings"])==null?void 0:A.assignedValues)==null?void 0:T.schema)!=null?C:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,p]=b.useState(null),{components:u}=s.useSchemaOptionsContext();b.useEffect(()=>{p(new S.Schema({properties:{grid:l}}))},[l]);const f=b.useMemo(()=>{var $,E;const D=(E=($=o==null?void 0:o["x-action-settings"])==null?void 0:$.assignedValues)==null?void 0:E.values;return S.createForm({initialValues:W.lodash.cloneDeep(D),values:W.lodash.cloneDeep(D)})},[o]),h=s.useFormActiveFields(),g=t("Assign field values");function y(){a(!1)}function w(){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=f.values,a(!1),setTimeout(()=>{var D;(D=e.refresh)==null||D.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:g,onClick:()=>a(!0),children:g}),r.jsx(x.Modal,{width:"50%",title:g,open:i,onCancel:y,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:y,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:w,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:h==null?void 0:h.getActiveFieldsName,children:r.jsx(S.FormProvider,{form:f,children:r.jsxs(be.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:F("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),i&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},e),{refresh(){c(W.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:u})})]})})})})})})]})}function ys(e){return r.jsxs(s.GeneralSchemaDesigner,I(v({},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 xs(){const a=s.useSchemaInitializerItem(),{action:t,actionProps:o}=a,n=K(a,["action","actionProps"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,I(v({},n),{onClick:()=>{i({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":I(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Vo(){const e=s.useSchemaInitializerItem(),i=e,{action:t,actionProps:o}=i,n=K(i,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,I(v({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":I(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const bs=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:xs,action:ye.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Vo,action:ye.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Vo,action:ye.PENDING}]});function vs(){return{run(){}}}function ws({value:e,onChange:t}){const o=s.usePlugin(Z),n=b.useContext(s.SchemaComponentContext),i=he(),a=Ee(i),l=S.useForm(),{workflow:c}=q(),d={};a.forEach(f=>{const h=o.instructions.get(f.type);Object.assign(d,h.components)});const p=b.useMemo(()=>new S.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(x.Form.Item,{children:r.jsxs(x.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(x.Radio,{value:!0,children:r.jsxs(x.Tooltip,{title:F("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:F("Separately")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:!1,children:r.jsxs(x.Tooltip,{title:F("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:F("Collaboratively")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function $o(e){var E,P,$;const t=s.useRecord(),o=S.useFieldSchema(),n=S.useField(),i=b.useRef(null),a=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(a),{appends:c,updateAssociationValues:d}=l(),[p]=Object.keys((E=o.toJSON().properties)!=null?E:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[p],{findComponent:f}=s.useDesignable(),g=f(($=n.component)==null?void 0:$[0])||b.Fragment,y=b.useMemo(()=>S.createForm({initialValues:u}),[u]),h=b.useMemo(()=>w({appends:c},e.params),[c,e.params]),v=b.useMemo(()=>({loading:!1,data:{data:u}}),[u]),I=s.useAPIClient(),T=s.useDataSourceHeaders(a),C=I.resource(e.collection,void 0,T),O=s.useBlockRequestContext(),B=b.useMemo(()=>({params:h,form:y,field:n,service:v,updateAssociationValues:d,formBlockRef:i}),[n,y,h,v,d]);return!t.status||u?r.jsx(s.CollectionManagerProvider,{dataSource:a,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:v,resource:C,__parent:O},children:r.jsx(s.FormBlockContext.Provider,{value:B,children:r.jsxs(g,A(w({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:y}),r.jsx("div",{ref:i,children:r.jsx(S.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function ps(e){return s.createFormBlockSchema(e)}function us(o){var n=o,{schema:e}=n,t=_(n,["schema"]);const{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),{insert:a}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(p){return D(this,arguments,function*({item:d}){var h;const u=d.template?yield i(d):null,f=ps(A(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 f["x-acl-action-props"],delete f["x-acl-action"];const[g]=Object.keys(f.properties),y=((h=Object.entries(f.properties[g].properties).find(([v,I])=>I["x-component"]==="ActionBar"))==null?void 0:h[0])||"actions";f.properties[g].properties[y]["x-decorator"]="ActionBarProvider",f.properties[g].properties[y]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},yt(f,v=>{v["x-uid"]&&delete v["x-uid"]}),a(f)})}return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:c,items:l}))}function Bo(){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(us,w({},e))})}function Pe(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(i=>{n.push(...Pe(e.properties[i],t))}),n):n}function ms(){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 fs={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=b.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:ge.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Bo}))})),[e]),[o,n]=b.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{CreateFormDesigner:ms},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Pe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Vo(e){var p,u,f,g;const[t,o]=b.useState((u=(p=e.collection)==null?void 0:p.fields)!=null?u:[]),n=s.useRecord(),i=S.useField(),a=S.useFieldSchema(),[l]=Object.keys((f=a.toJSON().properties)!=null?f:{}),c=(g=n==null?void 0:n.result)==null?void 0:g[l],d=b.useMemo(()=>S.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:A(w({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:i,setCollectionFields:o},children:e.children})})}):null}function gs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:W.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[W.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 Wo={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 hs(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:i="others"}=n;t[i]=t[i]||{},ge.set(t,[i,o],n)}),Object.keys(Wo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Wo[o],children:Object.keys(t[o]||{}).map(n=>{const i=t[o][n];return w({value:n,title:i.title,name:n},t[o][n])}).sort((n,i)=>n.order-i.order)}))}function ys(){const{interfaces:e}=s.useCollectionManager_deprecated();return hs(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:ws,fieldInterface:n.name}))}))}const jo=b.createContext({}),xs=e=>{const[t,o]=b.useState(null),[n,i]=b.useState(),a=ys(),l=s.useCollection_deprecated(),{setCollectionFields:c}=b.useContext(s.FormBlockContext),d=b.useMemo(()=>S.createForm(),[t]);return r.jsxs(jo.Provider,{value:{onAddField(p){const u=ge.pick(p,["name","group","title","default","validateSchema"]),{properties:T}=p,C=T,{unique:f,type:g,layout:y,autoIncrement:h}=C,v=_(C,["unique","type","layout","autoIncrement"]);u.properties=v;const I=ge.cloneDeep(u);delete I.properties.name["x-disabled"],o(I)},setCallback:i},children:[r.jsx(s.SchemaInitializerItems,A(w({},e),{items:a})),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:d},"x-component":"Action.Drawer",properties:A(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=S.useForm();return{run(){return D(this,null,function*(){i(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:f}=S.useForm(),g=[F("Field name existed in form")];return{run(){return D(this,null,function*(){var C,O,B,E;const{default:h}=t,v=W.uid();if(h.name=(C=p.name)!=null?C:v,h.uiSchema.title=(B=(O=p.uiSchema)==null?void 0:O.title)!=null?B:v,h.interface=t.name,(E=l.fields)==null?void 0:E.find(P=>P.name===h.name)){u("name").take().setFeedback({type:"error",messages:g});return}const T=W.merge(h,p);c([...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"}),f(),i(null),o(null)})}}}}}}}})},components:{ArrayTable:we.ArrayTable}}):null})]})},bs=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:xs});function ws(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:i}=b.useContext(jo),{getInterface:a}=s.useCollectionManager_deprecated(),l=a(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,w({onClick:()=>{i(()=>t),n(l),o(!1)}},e),e.fieldInterface)}const zo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:gs}},initializers:{},components:{CustomFormBlockProvider:Vo},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=Pe(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(u=>{var f,g;return(g=(f=u["x-component-props"])==null?void 0:f.field)!=null?g:u["x-interface-options"]});const c=((d=Object.entries(a.properties).find(([u,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[i]={type:"custom",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Pe(a.properties[c],u=>u["x-component"]==="Action").map(u=>{var f,g;return{status:u["x-decorator-props"].value,values:(g=(f=u["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:g.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Vo}}};function vs(){const{name:e,title:t}=s.useCollection_deprecated(),o=S.useFieldSchema(),{t:n}=X.useTranslation(),{dn:i}=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:a})=>{o["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Cs={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=b.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(d=>({name:ge.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Bo}))})),[e]),[o,n]=b.useState([]),i=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(a){n(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:Ie,UpdateFormDesigner:vs},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([p,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]=A(w({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||i,actions:Pe(a.properties[l],p=>p["x-component"]==="Action").map(p=>{var u,f;return{status:p["x-decorator-props"].value,values:(f=(u=p["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:p.name}})})}),t}},block:{scope:{},components:{}}},Me=new W.Registry;Me.register("customForm",zo),Me.register("createForm",fs),Me.register("updateForm",Cs);function ks(){const{workflow:e}=q(),t=Ze();return t.useInitializers?t.useInitializers(e.config):null}zo.title,`${m}`;const Ss=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=he(),o=Ee(t),n=[ks()].filter(Boolean),i=o.map(l=>{var d;const c=e.instructions.get(l.type);return(d=c==null?void 0:c.useInitializers)==null?void 0:d.call(c,l)}).filter(Boolean);return[...n,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:i}]:[]].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 As(){var I,T,C;const e=b.useContext(s.SchemaComponentContext),{t}=X.useTranslation(),o=S.useFieldSchema(),n=le(),[i,a]=b.useState(!1),[l,c]=b.useState((C=(T=(I=o==null?void 0:o["x-action-settings"])==null?void 0:I.assignedValues)==null?void 0:T.schema)!=null?C:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,p]=b.useState(null),{components:u}=s.useSchemaOptionsContext();b.useEffect(()=>{p(new S.Schema({properties:{grid:l}}))},[l]);const f=b.useMemo(()=>{var B,E;const O=(E=(B=o==null?void 0:o["x-action-settings"])==null?void 0:B.assignedValues)==null?void 0:E.values;return S.createForm({initialValues:W.lodash.cloneDeep(O),values:W.lodash.cloneDeep(O)})},[o]),g=s.useFormActiveFields(),y=t("Assign field values");function h(){a(!1)}function v(){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=f.values,a(!1),setTimeout(()=>{var O;(O=e.refresh)==null||O.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:y,onClick:()=>a(!0),children:y}),r.jsx(x.Modal,{width:"50%",title:y,open:i,onCancel:h,footer:r.jsxs(x.Space,{children:[r.jsx(x.Button,{onClick:h,children:t("Cancel")}),r.jsx(x.Button,{type:"primary",onClick:v,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:g==null?void 0:g.getActiveFieldsName,children:r.jsx(S.FormProvider,{form:f,children:r.jsxs(we.FormLayout,{layout:"vertical",children:[r.jsx(x.Alert,{message:F("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),i&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{refresh(){c(W.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:u})})]})})})})})})]})}function Is(e){return r.jsxs(s.GeneralSchemaDesigner,A(w({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(As,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Fs(){const a=s.useSchemaInitializerItem(),{action:t,actionProps:o}=a,n=_(a,["action","actionProps"]),{insert:i}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:()=>{i({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Lo(){const e=s.useSchemaInitializerItem(),i=e,{action:t,actionProps:o}=i,n=_(i,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,A(w({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":A(w({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const Ts=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Fs,action:xe.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Lo,action:xe.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Lo,action:xe.PENDING}]});function Ns(){return{run(){}}}function Ds({value:e,onChange:t}){const o=s.usePlugin(Z),n=b.useContext(s.SchemaComponentContext),i=he(),a=Ee(i),l=S.useForm(),{workflow:c}=q(),d={};a.forEach(f=>{const g=o.instructions.get(f.type);Object.assign(d,g.components)});const p=b.useMemo(()=>new S.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":"popup:addTab","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=b.useCallback(function(){const{tabs:h}=W.lodash.get(p.toJSON(),"properties.drawer.properties"),g=Array.from(Me.getValues()).reduce((y,w)=>Object.assign(y,w.config.parseFormOptions(h)),{});l.setValuesIn("forms",g),t(h.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},n),{designable:!c.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:I(v(v({},d),Array.from(Me.getValues()).reduce((f,h)=>Object.assign(f,h.config.components),{})),{FormBlockProvider:Oo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Ut,ManualActionDesigner:ys}),scope:{useSubmit:vs,useDetailsBlockProps:s.useFormBlockContext}})})}function Cs(e){const{workflow:t}=q(),[o,n]=b.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:F(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class ks extends Q{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",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}" })}}`,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:{}}},this.components={SchemaConfigButton:Cs,SchemaConfig:ws,ModeConfig:ts,AssigneesSelect:es}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=pe}){var u;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((u=n.forms)!=null?u:{});if(!d.length)return null;const p=d.map(f=>{var w;const h=n.forms[f],g=ue({fields:(w=h.collection)==null?void 0:w.fields,collection:h.collection,types:i,compile:l,getCollectionFields:c}),y=l(h.title)||f;return g.length?{key:f,value:f,label:y,title:y,children:g}:null}).filter(Boolean);return p.length?{[a.value]:t,[a.label]:o,[a.children]:p}:null}useInitializers(t){var a;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((a=t.config.forms)!=null?a:{});if(!n.length||t.config.mode)return null;const i=n.map(l=>{var p,u;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(p=c.title)!=null?p:l,type:"item",title:(u=c.title)!=null?u:l,Component:Te,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return i.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:i}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}const Ss={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"}}]},As={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}}]},Is={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:mt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Fs=S.observer(()=>{var t,o,n;const e=S.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"}),Ts=S.observer(()=>{var t,o,n;const e=S.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"}),Ns=S.observer(()=>{var t,o,n;const e=S.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 Ds(e){const t=s.useRecord(),o=F("Unprocessed");return t.execution.status&&!t.status?r.jsx(x.Tag,{children:o}):e.children}const Jt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:Fs,WorkflowColumn:Ts,UserColumn:Ns,UserJobStatusColumn:Ds},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 Os(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=q(),{status:n,result:i,userId:a}=o,l=S.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?i[c]||(d=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(d=null),d}const Wo=b.createContext(null);Wo.displayName="ManualActionStatusContext";function Ps({value:e,children:t}){const{userJob:o,execution:n}=q(),i=S.useField(),a=S.useFieldSchema();return b.useEffect(()=>{(n.status||o.status)&&(i.disabled=!0,i.visible=o.status===e&&o.result._===a.name)},[n,o,e,i,a.name]),r.jsx(Wo.Provider,{value:e,children:t})}function Ms(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=S.useForm(),i=S.useFieldSchema(),{service:a}=s.useTableBlockContext(),{userJob:l,execution:c}=q(),{name:d}=i,{name:p}=i.parent.parent;return{run(){return O(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:d}}}),t(!1),a.refresh())})}}}function Es(e){var u;const t=s.usePlugin(Z),o=s.useAPIClient(),{id:n}=s.useRecord(),[i,a]=b.useState(null),[l,c]=b.useState(null);b.useEffect(()=>{var f,h;n&&((h=(f=o.resource("users_jobs")).get)==null||h.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:g})=>{var D;const $=(D=g==null?void 0:g.data)!=null?D:{},{node:y,workflow:E={}}=$,P=E,{nodes:w=[]}=P,A=K(P,["nodes"]),B=$,{execution:T}=B,C=K(B,["node","workflow","execution"]);ft(w),c(y),a({userJob:C,workflow:A,nodes:w,execution:T})}))},[o,n]);const p=Ee(i==null?void 0:i.nodes.find(f=>f.id===l.id)).reduce((f,{type:h})=>{var g;return Object.assign(f,(g=t.instructions.get(h))==null?void 0:g.components)},{});return l&&i?r.jsx(qe.Provider,{value:i,children:r.jsx(s.SchemaComponent,{components:v(v({FormBlockProvider:Oo,DetailsBlockProvider:Vt,ActionBarProvider:Os,ManualActionStatusProvider:Ps},Array.from(Me.getValues()).reduce((f,h)=>Object.assign(f,h.block.components),{})),p),scope:v({useSubmit:Ms,useFormBlockProps:$s,useDetailsBlockProps:Bs},Array.from(Me.getValues()).reduce((f,h)=>Object.assign(f,h.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(x.Spin,{})}function $s(){var l;const{userJob:e,execution:t}=q(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:i}=s.useFormBlockContext(),a=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return b.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Bs(){const{form:e}=s.useFormBlockContext();return{form:e}}function Vs(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=Re[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:s.css`
|
|
472
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","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=b.useCallback(function(){const{tabs:g}=W.lodash.get(p.toJSON(),"properties.drawer.properties"),y=Array.from(Me.getValues()).reduce((h,v)=>Object.assign(h,v.config.parseFormOptions(g)),{});l.setValuesIn("forms",y),t(g.properties)},[l,t,p]);return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},n),{designable:!c.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:p,components:A(w(w({},d),Array.from(Me.getValues()).reduce((f,g)=>Object.assign(f,g.config.components),{})),{FormBlockProvider:$o,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Ut,ManualActionDesigner:Is}),scope:{useSubmit:Ns,useDetailsBlockProps:s.useFormBlockContext}})})}function Os(e){const{workflow:t}=q(),[o,n]=b.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:F(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class Ps extends H{constructor(){super(...arguments),this.title=`{{t("Manual", { ns: "${m}" })}}`,this.type="manual",this.group="manual",this.icon="CoffeeOutlined",this.color="#a3243b",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}" })}}`,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:{}}},this.components={SchemaConfigButton:Os,SchemaConfig:Ds,ModeConfig:ds,AssigneesSelect:cs}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=pe}){var u;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((u=n.forms)!=null?u:{});if(!d.length)return null;const p=d.map(f=>{var v;const g=n.forms[f],y=ue({fields:(v=g.collection)==null?void 0:v.fields,collection:g.collection,types:i,compile:l,getCollectionFields:c}),h=l(g.title)||f;return y.length?{key:f,value:f,label:h,title:h,children:y}:null}).filter(Boolean);return p.length?{[a.value]:t,[a.label]:o,[a.children]:p}:null}useInitializers(t){var a;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((a=t.config.forms)!=null?a:{});if(!n.length||t.config.mode)return null;const i=n.map(l=>{var p,u;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(p=c.title)!=null?p:l,type:"item",title:(u=c.title)!=null?u:l,Component:De,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return i.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:i}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}const Ms={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"}}]},Es={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}}]},$s={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:gt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Bs=S.observer(()=>{var t,o,n;const e=S.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"}),Vs=S.observer(()=>{var t,o,n;const e=S.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"}),Ws=S.observer(()=>{var t,o,n;const e=S.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 js(e){const t=s.useRecord(),o=F("Unprocessed");return t.execution.status&&!t.status?r.jsx(x.Tag,{children:o}):e.children}const Jt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:Bs,WorkflowColumn:Vs,UserColumn:Ws,UserJobStatusColumn:js},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 zs(e){var p;const{data:t}=s.useCurrentUserContext(),{userJob:o}=q(),{status:n,result:i,userId:a}=o,l=S.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?i[c]||(d=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(d=null),d}const qo=b.createContext(null);qo.displayName="ManualActionStatusContext";function Ls({value:e,children:t}){const{userJob:o,execution:n}=q(),i=S.useField(),a=S.useFieldSchema();return b.useEffect(()=>{(n.status||o.status)&&(i.disabled=!0,i.visible=o.status===e&&o.result._===a.name)},[n,o,e,i,a.name]),r.jsx(qo.Provider,{value:e,children:t})}function qs(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=S.useForm(),i=S.useFieldSchema(),{service:a}=s.useTableBlockContext(),{userJob:l,execution:c}=q(),{name:d}=i,{name:p}=i.parent.parent;return{run(){return D(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[p]:o,_:d}}}),t(!1),a.refresh())})}}}function Us(e){var u;const t=s.usePlugin(Z),o=s.useAPIClient(),{id:n}=s.useRecord(),[i,a]=b.useState(null),[l,c]=b.useState(null);b.useEffect(()=>{var f,g;n&&((g=(f=o.resource("users_jobs")).get)==null||g.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:y})=>{var O;const B=(O=y==null?void 0:y.data)!=null?O:{},{node:h,workflow:E={}}=B,P=E,{nodes:v=[]}=P,I=_(P,["nodes"]),$=B,{execution:T}=$,C=_($,["node","workflow","execution"]);ht(v),c(h),a({userJob:C,workflow:I,nodes:v,execution:T})}))},[o,n]);const p=Ee(i==null?void 0:i.nodes.find(f=>f.id===l.id)).reduce((f,{type:g})=>{var y;return Object.assign(f,(y=t.instructions.get(g))==null?void 0:y.components)},{});return l&&i?r.jsx(qe.Provider,{value:i,children:r.jsx(s.SchemaComponent,{components:w(w({FormBlockProvider:$o,DetailsBlockProvider:Vt,ActionBarProvider:zs,ManualActionStatusProvider:Ls},Array.from(Me.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),p),scope:w({useSubmit:qs,useFormBlockProps:_s,useDetailsBlockProps:Ks},Array.from(Me.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(u=l.config)==null?void 0:u.schema}})}):r.jsx(x.Spin,{})}function _s(){var l;const{userJob:e,execution:t}=q(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:i}=s.useFormBlockContext(),a=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return b.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Ks(){const{form:e}=s.useFormBlockContext();return{form:e}}function Gs(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=Re[t];return t?r.jsxs(x.Space,{children:[r.jsx("time",{className:s.css`
|
|
473
473
|
margin-right: 0.5em;
|
|
474
|
-
`,children:W.dayjs(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(x.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function
|
|
474
|
+
`,children:W.dayjs(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(x.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function Hs(){var a;const e=b.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:i}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:Gs,FlowContextProvider:Us},schema:{type:"void",name:`drawer-${t}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(a=o.title)!=null?a:`#${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:A(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:[Ms,Es,$s],children:r.jsx(s.TableBlockProvider,A(w({name:"workflow-todo"},o),{children:t}))})}Jt.Drawer=Hs,Jt.Decorator=Js;const Ys=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,A(w({icon:r.jsx(j.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 Qs extends s.Plugin{load(){return D(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Ps),this.app.schemaInitializerManager.add(Ss),this.app.schemaInitializerManager.add(Ts),this.app.schemaInitializerManager.add(bs),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(j.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:Jt,WorkflowTodoBlockInitializer:Ys})}}const Uo="notice",Yt="workflowNotice",Te="workflow";function Ke(){return{t:(t,o={})=>s.i18n.t(t,w({ns:Te},o))}}const ie=e=>s.tval(e,{ns:Te});function Zs(){const e=s.useAPIClient(),t=S.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=ne.useNavigate(),l=S.useFieldSchema(),c=S.useField(),d=s.useCompile(),{modal:p}=x.App.useApp(),u=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return D(this,null,function*(){var T,C,O;const{onSuccess:y,skipValidator:h,triggerWorkflows:v}=(T=l==null?void 0:l["x-action-settings"])!=null?T:{};h||(yield t.submit());const I=yield u();c.data=o.data||{},c.data.loading=!0;try{const B=yield e.resource("workflows").trigger({values:I,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(c.data.loading=!1,c.data.data=B,(O=(C=n==null?void 0:n.service)==null?void 0:C.refresh)==null||O.call(C),i==null||i(!1),!(y!=null&&y.successMessage))return;y!=null&&y.manualClose?p.success({title:d(y==null?void 0:y.successMessage),onOk:()=>D(this,null,function*(){yield t.reset(),y!=null&&y.redirecting&&(y!=null&&y.redirectTo)&&(W.isURL(y.redirectTo)?window.location.href=y.redirectTo:a(y.redirectTo))})}):x.message.success(d(y==null?void 0:y.successMessage))}catch(B){c.data.loading=!1}})}}}function Xs(){var g;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=S.useField(),i=S.useFieldSchema(),{field:a,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=x.App.useApp(),p=ne.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(g=i==null?void 0:i["x-action-settings"])!=null?g:{};return{onClick(){return D(this,null,function*(){var h,v;n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(v=(h=l==null?void 0:l.service)==null?void 0:h.refresh)==null||v.call(h),c==null||c(!1),!(u!=null&&u.successMessage))return;if(u!=null&&u.manualClose){let I;d.success({title:e(u==null?void 0:u.successMessage),onOk(){return D(this,null,function*(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(W.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))})}})}else x.message.success(e(u==null?void 0:u.successMessage))}catch(I){console.error(I)}finally{n.data.loading=!1}})}}}const Rs=()=>{const e=Kt(),t=we.ArrayItems.useArray()||{field:[]},{t:o}=Ke(),[n,i]=b.useState(!1),a=b.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=b.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(x.Popover,{open:!e&&n,onOpenChange:i,content:r.jsx(ei,{onSlecet:a,onQuery:l}),children:r.jsx(x.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},ei=({onSlecet:e,onQuery:t})=>{const{t:o}=Ke();return r.jsxs(x.Space,{direction:"vertical",size:"small",children:[r.jsx(x.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(x.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ti=e=>{const{t}=Ke(),[o,n]=b.useState(!1),i=b.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(x.Button,{type:"primary",onClick:i,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},oi=e=>e.value&&typeof e.value=="object"?r.jsx(ri,w({},e)):r.jsx(ni,w({},e)),ni=({value:e,onChange:t})=>{const o=le({types:[si]});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})})},ri=()=>{const e=S.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:Ie}}}}})})};function si(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const ii=()=>{var d;const{workflow:e}=q(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=u=>D(this,[u],function*({item:p}){const f=p.template?yield a(p):null,g=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});ge.unset(g,["x-acl-action","x-acl-action-props"]);const[y]=Object.keys(g.properties);ge.set(g.properties[y],"x-component-props.useProps","usePropsNoticeDetail"),i(g)});return r.jsx(s.SchemaInitializerItem,A(w({},n),{onClick:c,items:l}))},ai=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ie("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:ii}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(Z),{workflow:t}=q(),o=Ze(),n=he(),i=Ee(n),a=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=i.map(d=>{var u;const p=e.instructions.get(d.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,d)}).filter(Boolean);return[...a,...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 li extends s.Plugin{load(){return D(this,null,function*(){this.app.schemaInitializerManager.add(ai)})}}function ci(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const di=e=>{const{schemaData:t,loading:o,handleChange:n}=pi(e);return o?r.jsx(x.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function pi(e){const{value:t,onChange:o}=e,n=s.useAPIClient();S.useForm();const{data:i,loading:a}=s.useRequest(()=>D(this,null,function*(){if(t){const p=yield ui(n,t);if(p["x-uid"]===t)return p}const c=t!=null?t:W.uid(),d=ci(c);return yield mi(n,d),o(c),d}));return{schemaData:i,loading:a,handleChange:c=>{}}}function ui(e,t){return D(this,null,function*(){var i;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(i=o.data)!=null?i:{}})}function mi(e,t){return D(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const fi={ActionStyle:s.css`
|
|
475
475
|
.ant-drawer-body {
|
|
476
476
|
background: var(--tb-box-bg);
|
|
477
477
|
}
|
|
478
|
-
`},
|
|
478
|
+
`},gi=()=>{const e=b.useContext(s.SchemaComponentContext),[,t]=b.useState(W.uid()),{workflow:o}=q(),n=b.useMemo(()=>A(w({},e),{refresh:()=>t(W.uid()),designable:!o.executed}),[e,o.executed]);return r.jsx(s.SchemaComponentContext.Provider,{value:n,children:r.jsx(s.SchemaComponent,{components:{NoticeDetail:di},schema:hi})})},hi={name:"drawer",type:"void",title:ie("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:fi.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const _o={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:N("P
|
|
|
492
492
|
> .ant-space-item:nth-child(2) {
|
|
493
493
|
flex-grow: 1;
|
|
494
494
|
}
|
|
495
|
-
`};class
|
|
495
|
+
`};class yi extends H{constructor(){super(...arguments),this.title=ie("Notice"),this.type=Uo,this.group=_e,this.icon="MessageOutlined",this.color="#82e29c",this.description=ie("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:we.ArrayItems,SelectNotifiedPerson:oi,AdditionNotifiedPerson:Rs,ConfigButtonNotice:ti,ShowNoticeDetail:gi},this.fieldset={notifiedPerson:{type:"array",title:ie("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:_o.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:_o.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:ie("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ie("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class xi extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(li)})}load(){return D(this,null,function*(){this.app.pm.get(Z).registerInstruction(Uo,yi),this.app.addComponents({ArrayItems:we.ArrayItems})})}}const bi={title:ie("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"}}]},wi=S.observer(()=>{const{value:e}=S.useField(),t=s.useRecord();return r.jsx(vi,{value:e,record:t})},{displayName:"ColumnStatus"}),vi=e=>{const{value:t,record:o}=e,n=ge.omit(e,["value","record"]),i=s.useCompile(),{t:a}=Ke(),{option:l=Ci[t]}=n,{workflow:c,execution:d,job:p}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||p!=null&&p.status)&&[].includes(t)?r.jsx(x.Tag,{children:a("Unprocessed")}):r.jsx(x.Tag,{color:l==null?void 0:l.color,children:i(l==null?void 0:l.label)})},Ko=[{value:de.QUEUEING,label:`{{t("Assigned", { ns: "${Te}" })}}`,color:"blue"},{value:de.STARTED,label:`{{t("Pending", { ns: "${Te}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${Te}" })}}`,color:"green"},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${Te}" })}}`,color:"red"}],Ci=Ko.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ki={title:ie("Notice Center"),name:Yt,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:ie("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: "${Te}" })}}`,"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:Ko}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${Te}" })}}`}},{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:ie("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},Si={title:ie("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}]}}]},Ai=o=>{var n=o,{children:e}=n,t=_(n,["children"]);const{collection:i,params:a={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:i,resource:i,action:l,params:A(w({pageSize:20,sort:["-createdAt"]},a),{filter:c!=null&&c.id?w({dataKey:`${c.id}`},a.filter):w({},a.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[Si,bi,ki],children:r.jsx(s.TableBlockProvider,A(w({name:i},d),{children:e}))})},Go=b.createContext({}),Ii=Go.Provider;function Fi(){return b.useContext(Go)}const Ho=b.createContext({}),Ti=Ho.Provider;function Ni(){return b.useContext(Ho)}function Di(){const{snapshot:e}=Ni(),{form:t}=s.useFormBlockContext();return b.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function Jo({children:e,workflow:t,execution:o,nodes:n}){const i=s.usePlugin(Z),a=i.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var p;return Object.assign(c,(p=i.instructions.get(d))==null?void 0:p.components)},{});return r.jsx(qe.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:w(w({},a),l),children:e})})}const Yo=o=>{var n=o,{children:e}=n,t=_(n,["children"]);const i=s.useSchemaComponentContext(),{t:a}=Ke(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=Oi(l);if(c)return r.jsx(x.Spin,{});if(!(d!=null&&d.data))return r.jsx(x.Result,{status:"error",title:a("Submission may be withdrawn, please try refresh the list.")});const p=d.data,{node:u,workflow:f,execution:g}=p,y=u==null?void 0:u.config.showNoticeDetail,{designable:h}=t;return r.jsx(Jo,{workflow:f,nodes:f.nodes,execution:g,children:r.jsx(Ti,{value:p,children:r.jsx(Ii,{value:{id:l,schemaId:y},children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:h}),children:e})})})})};function Oi(e){const{loading:t,data:o}=s.useRequest({resource:Yt,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 Pi=()=>r.jsx(Yo,{children:r.jsx(Mi,{})}),Mi=e=>{const{id:t,schemaId:o}=Fi();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:Yo,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:Vt},scope:{usePropsNoticeDetail:Di,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ie("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}}}}}}})},Ei=({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"}}}}}},$i=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:Pi},schema:Ei({record:e})})},Bi=S.observer(()=>{const e=S.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),Vi=S.observer(()=>{const e=S.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"}),Wi=S.observer(()=>{const{t:e}=Ke(),{value:t}=S.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"}),ji={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
|
+
`},zi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:Bi,ColumnWorkflow:Wi,ColumnUser:Vi,ColumnStatus:wi,ColumnAction:$i},schema:Li}),Li={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:ji.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:ie("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:ie("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:ie("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: "${Ie}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Mi extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockProvider:gi,NoticeCenter:Oi})})}}function Go(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Yt,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 Ei=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=b.useCallback(()=>{const n=Go();e(n)},[e,Go]);return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:o}))};class $i extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Mi)})}load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Ei}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ie("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Bi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(ci),yield this.app.pm.add($i)})}}class Vi extends Qe{constructor(){super(...arguments),this.title=N("General event"),this.description=N("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."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("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:N("Associations to use"),description:N("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 o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=ue(I(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...ue({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Wi=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,I(v({},e),{schema:ji,item:e}))},ji={type:"void",title:N("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"}},zi=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=S.useFieldSchema();return S.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}}],Li=new s.SchemaSettings({name:"actionSettings:APIRegular",items:zi}),qi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=S.useFieldSchema(),a=b.useContext(S.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=X.useTranslation();oe.useNavigate(),s.useCompile();const p=S.useField(),{modal:u,notification:f}=x.App.useApp(),h=s.useVariables(),{name:g,getField:y}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:A}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(x.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const D=C.current+1,$=Math.floor(D/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(x.Progress,{percent:Math.floor(D/C.total*100)}),duration:$})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(x.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return O(this,null,function*(){var Y,se,V,M,L,R,H;const C=(M=(V=(se=(Y=l.field)==null?void 0:Y.data)==null?void 0:se.selectedRowKeys)!=null?V:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:D}=(R=(L=n.params)==null?void 0:L[0])!=null?R:{},{bindWorkflow:$=!1,triggerWorkflows:E=!1,assignedValues:P={},updateMode:B}=(H=i==null?void 0:i["x-action-settings"])!=null?H:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!E&&!$)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(G=>O(this,null,function*(){const re=P[G],Le=y(G);if(s.isVariable(re)){const xe=yield h==null?void 0:h.parseVariable(re,w);xe&&s.transformVariableValue(xe,{targetCollectionField:Le})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return O(this,null,function*(){if($){const G={filterByTk:$,updateData:encodeURIComponent(JSON.stringify(z))};A(G)}else E&&(_?yield t.trigger({filterByTk:C,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}):yield t.trigger({filter:D,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}));p.data.loading=!1})},onCancel(){return O(this,null,function*(){p.data.loading=!1})}})})}}};class Ui extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({APIRegularInitializer:Wi}),this.app.addScopes({usePropsAPIRegular:qi}),this.app.schemaSettingsManager.add(Li),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("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 Ki(){const e=S.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=oe.useNavigate(),c=S.useFieldSchema(),d=S.useField(),p=s.useCompile(),{modal:u}=x.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return O(this,null,function*(){var T,C;const{onSuccess:g,skipValidator:y,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};y||(yield e.submit());const A=yield f();d.data=t.data||{},d.data.loading=!0;try{const D=yield n.trigger({values:A,filterByTk:a,triggerWorkflows:w!=null&&w.length?w.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.data=D,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:p(g==null?void 0:g.successMessage),onOk:()=>O(this,null,function*(){return yield e.reset(),(g==null?void 0:g.redirecting)&&(g==null?void 0:g.redirectTo)&&(W.isURL(g.redirectTo)?window.location.href=g.redirectTo:l(g.redirectTo))})}):x.message.success(p(g==null?void 0:g.successMessage))}catch(D){console.error(D)}finally{d.data.loading=!1}})}}}function _i(){const e=s.useCompile(),t=s.useFilterByTk(),o=S.useField(),n=S.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=x.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(g,y){return O(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:f!=null&&f.length?f.map(w=>[w.workflowKey,w.context].filter(Boolean).join("!")).join(","):void 0}),y==null||y(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(W.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):x.message.success(e(u==null?void 0:u.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const Qt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("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:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},vt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Zt=I(v({},vt),{schema:I(v({},vt.schema),{"x-component":"Action.Link"})});class Gi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Ui)})}load(){return O(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Vi),this.app.addScopes({useFormWorkflowCustomActionProps:Ki,useRecordWorkflowCustomTriggerActionProps:_i}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Zt)})}}class Hi extends Q{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,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"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Oe}}Component({data:t}){const{styles:o}=ge(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((y,w)=>w.upstreamId===n&&w.branchIndex!=null?y.concat(w):y,[]).sort((y,w)=>y.branchIndex-w.branchIndex),[d,p]=b.useState(Math.max(2,c.length)),{getAriaLabel:u}=dt(t),f=F("Add branch"),h=Array(Math.max(0,d-c.length)).fill(null),g=c[c.length-1];return r.jsx(nt,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(y=>r.jsx($e,{from:t,entry:y,branchIndex:y.branchIndex},y.id)),h.map((y,w)=>r.jsx($e,{from:t,branchIndex:(g?g.branchIndex:0)+w+1,controller:c.length+w>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:ie("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:ie("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:ie("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: "${Te}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class qi extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockProvider:Ai,NoticeCenter:zi})})}}function Qo(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Yt,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 Ui=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=b.useCallback(()=>{const n=Qo();e(n)},[e,Qo]);return r.jsx(s.SchemaInitializerItem,A(w({},t),{onClick:o}))};class _i extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(qi)})}load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Ui}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ie("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Ki extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(xi),yield this.app.pm.add(_i)})}}class Gi extends Qe{constructor(){super(...arguments),this.title=N("General event"),this.description=N("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."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("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:N("Associations to use"),description:N("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 o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=ue(A(w({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...ue({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:De,collection:t.collection,dataPath:"$context.data"}:null}}const Hi=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,A(w({},e),{schema:Ji,item:e}))},Ji={type:"void",title:N("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"}},Yi=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=S.useFieldSchema();return S.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}}],Qi=new s.SchemaSettings({name:"actionSettings:APIRegular",items:Yi}),Zi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=S.useFieldSchema(),a=b.useContext(S.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=X.useTranslation();ne.useNavigate(),s.useCompile();const p=S.useField(),{modal:u,notification:f}=x.App.useApp(),g=s.useVariables(),{name:y,getField:h}=s.useCollection_deprecated(),v=s.useLocalVariables(),{run:I}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(x.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const O=C.current+1,B=Math.floor(O/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(x.Progress,{percent:Math.floor(O/C.total*100)}),duration:B})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(x.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return D(this,null,function*(){var Y,se,V,M,L,ee,G;const C=(M=(V=(se=(Y=l.field)==null?void 0:Y.data)==null?void 0:se.selectedRowKeys)!=null?V:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:O}=(ee=(L=n.params)==null?void 0:L[0])!=null?ee:{},{bindWorkflow:B=!1,triggerWorkflows:E=!1,assignedValues:P={},updateMode:$}=(G=i==null?void 0:i["x-action-settings"])!=null?G:{},K=$==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!E&&!B)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(R=>D(this,null,function*(){const re=P[R],Le=h(R);if(s.isVariable(re)){const be=yield g==null?void 0:g.parseVariable(re,v);be&&s.transformVariableValue(be,{targetCollectionField:Le})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return D(this,null,function*(){if(B){const R={filterByTk:B,updateData:encodeURIComponent(JSON.stringify(z))};I(R)}else E&&(K?yield t.trigger({filterByTk:C,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}):yield t.trigger({filter:O,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}));p.data.loading=!1})},onCancel(){return D(this,null,function*(){p.data.loading=!1})}})})}}};class Xi extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({APIRegularInitializer:Hi}),this.app.addScopes({usePropsAPIRegular:Zi}),this.app.schemaSettingsManager.add(Qi),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("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 Ri(){const e=S.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=ne.useNavigate(),c=S.useFieldSchema(),d=S.useField(),p=s.useCompile(),{modal:u}=x.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return D(this,null,function*(){var T,C;const{onSuccess:y,skipValidator:h,triggerWorkflows:v}=(c==null?void 0:c["x-action-settings"])||{};h||(yield e.submit());const I=yield f();d.data=t.data||{},d.data.loading=!0;try{const O=yield n.trigger({values:I,filterByTk:a,triggerWorkflows:s.getAfterWorkflows(v),beforeWorkflows:s.getBeforeWorkflows(v)});if(d.data.data=O,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(y!=null&&y.successMessage))return;y!=null&&y.manualClose?u.success({title:p(y==null?void 0:y.successMessage),onOk:()=>D(this,null,function*(){return yield e.reset(),(y==null?void 0:y.redirecting)&&(y==null?void 0:y.redirectTo)&&(W.isURL(y.redirectTo)?window.location.href=y.redirectTo:l(y.redirectTo))})}):x.message.success(p(y==null?void 0:y.successMessage))}catch(O){console.error(O)}finally{d.data.loading=!1}})}}}function ea(){const e=s.useCompile(),t=s.useFilterByTk(),o=S.useField(),n=S.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=x.App.useApp(),p=ne.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(y,h){return D(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),h==null||h(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(W.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):x.message.success(e(u==null?void 0:u.successMessage))}catch(v){console.error(v)}finally{o.data.loading=!1}})}}}const Qt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("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:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},vt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Zt=A(w({},vt),{schema:A(w({},vt.schema),{"x-component":"Action.Link"})});class ta extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Xi)})}load(){return D(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Gi),this.app.addScopes({useFormWorkflowCustomActionProps:Ri,useRecordWorkflowCustomTriggerActionProps:ea}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Zt)})}}class oa extends H{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,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"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Fe}}Component({data:t}){const{styles:o}=ye(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((h,v)=>v.upstreamId===n&&v.branchIndex!=null?h.concat(v):h,[]).sort((h,v)=>h.branchIndex-v.branchIndex),[d,p]=b.useState(Math.max(2,c.length)),{getAriaLabel:u}=ut(t),f=F("Add branch"),g=Array(Math.max(0,d-c.length)).fill(null),y=c[c.length-1];return r.jsx(st,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(h=>r.jsx($e,{from:t,entry:h,branchIndex:h.branchIndex},h.id)),g.map((h,v)=>r.jsx($e,{from:t,branchIndex:(y?y.branchIndex:0)+v+1,controller:c.length+v>1?r.jsx("div",{className:s.css`
|
|
508
508
|
padding-top: 2em;
|
|
509
509
|
|
|
510
510
|
> button {
|
|
@@ -512,7 +512,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
512
512
|
transform: rotate(45deg);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(j.PlusOutlined,{}),onClick:()=>p(d-1),disabled:a.executed})}):null},`temp_${c.length+
|
|
515
|
+
`,children:r.jsx(x.Button,{shape:"circle",icon:r.jsx(j.PlusOutlined,{}),onClick:()=>p(d-1),disabled:a.executed})}):null},`temp_${c.length+v}`))]}),r.jsx(x.Tooltip,{title:f,className:s.css`
|
|
516
516
|
visibility: ${a.executed?"hidden":"visible"};
|
|
517
517
|
`,children:r.jsx(x.Button,{"aria-label":u("add-branch"),icon:r.jsx(j.PlusOutlined,{}),className:s.css`
|
|
518
518
|
position: relative;
|
|
@@ -524,7 +524,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
524
524
|
transform-origin: center;
|
|
525
525
|
transform: rotate(-45deg);
|
|
526
526
|
}
|
|
527
|
-
`,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class
|
|
527
|
+
`,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class na extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(Z).registerInstruction("parallel",oa)})}}class ra extends H{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",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}" })}}`,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}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { 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"}},this.components={ArrayItems:we.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:nt,WorkflowVariableJSON:To}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class sa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",ra)})}}class ia extends H{constructor(){super(...arguments),this.title=N("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=N("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:N("Message content"),description:N("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Fe,WorkflowVariableTextArea:nt,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class aa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",ia)})}}class la extends H{constructor(){super(...arguments),this.title=N("Data Mapping"),this.type=ho,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=N("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:N("Data source map"),description:N("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("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:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:
|
|
556
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:we.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}}class ca extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get(Z).registerInstruction(ho,la)})}}class da extends H{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,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(t){return t.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
|
-
`}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:
|
|
559
|
+
`}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:Fo}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class pa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",da)})}}const ua=()=>{const{workflow:e}=q();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class ma extends H{constructor(){super(...arguments),this.title=N("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={workflowKey:{type:"string",title:N("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":ua,required:!0},bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("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:N("Associations to use"),description:N("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 o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}}class fa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",ma)})}}const ga=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 ha({value:e,onChange:t}){const o=e==null,n=he(),i=Ee(n,d=>d.type==="variable"&&!d.config.target),{styles:a}=ga(),l=b.useCallback(({target:d})=>{if(d.value)return t(null);i.length&&t(i[0].key)},[t,i]),c=b.useCallback((d,p)=>p.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${p.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(x.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(x.Radio,{value:!0,children:F("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(x.Radio,{value:!1,disabled:!i.length,children:F("Assign value to an existing variable")}),!o&&r.jsx(x.Select,{options:i.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:a.nodeIdClass,children:p.data.id})]})})]})]})})})}class ya extends H{constructor(){super(...arguments),this.title=N("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=N("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:N("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:N("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:ke,VariableTargetSelect:ha}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=pe}){return n.target?null:{[a.value]:t,[a.label]:o}}}class xa extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",ya)})}}const Zo=e=>{const t=Ye.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 ba extends H{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",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}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ye.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"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("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`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:Zo},this.components={WorkflowVariableTextArea:nt,RadioWithTooltip:Fe,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Oe||Object.values(Oe).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const wa=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:i,children:a}=e,[l,c]=b.useState(!1),d=b.useMemo(()=>{const u=ge.cloneDeep(n.config);return S.createForm({initialValues:u,disabled:i.executed})},[n,i]),p=b.useCallback(u=>{o(u),u||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:a})})};function va(){return{form:S.useForm()}}var rt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ca(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xo={exports:{}};(function(e,t){(function(o,n){n()})(rt,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,f){var g=new XMLHttpRequest;g.open("GET",p),g.responseType="blob",g.onload=function(){d(g.response,u,f)},g.onerror=function(){console.error("could not download file")},g.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){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 rt=="object"&&rt.global===rt?rt:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var g=l.URL||l.webkitURL,y=document.createElement("a");u=u||p.name||"download",y.download=u,y.rel="noopener",typeof p=="string"?(y.href=p,y.origin===location.origin?a(y):i(y.href)?n(p,u,f):a(y,y.target="_blank")):(y.href=g.createObjectURL(p),setTimeout(function(){g.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var g=document.createElement("a");g.href=p,g.target="_blank",setTimeout(function(){a(g)})}}:function(p,u,f,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var y=p.type==="application/octet-stream",h=/constructor/i.test(l.HTMLElement)||l.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||y&&h||c)&&typeof FileReader!="undefined"){var I=new FileReader;I.onloadend=function(){var O=I.result;O=v?O:O.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=O:location=O,g=null},I.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);g?g.location=C:location.href=C,g=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})})(Xo);var Ro=Xo.exports;const ka=Ca(Ro);function Sa(){const e=S.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),i=he(),{workflow:a}=q();return{run(){return D(this,null,function*(){var c,d;if(a.executed){x.message.error(F("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:i.id,values:{config:e.values}}),o.setFormValueChanged(!1),x.message.success("success"),n()})}}}const Aa=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===_e;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:["(",F("Deprecated"),") "]}),t.title]}),r.jsxs(x.Tooltip,{title:F("Variable key of node"),children:[r.jsx(x.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(x.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function
|
|
587
|
+
`,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",F("Deprecated"),") "]}),t.title]}),r.jsxs(x.Tooltip,{title:F("Variable key of node"),children:[r.jsx(x.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(x.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function Ia(e,t){return r.jsx(Aa,{data:e,instruction:t})}const Fa=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e;return{type:"void",properties:A(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:Ia(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area",properties:A(w({},t.description?{description:{type:"void","x-component":mo,"x-component-props":{label:F("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:i.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:i.executed?null:{type:"void","x-component":"ActionArea.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action","x-component-props":{useAction(){const{t:a}=s.useTranslation();return{run(){return D(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,p)=>{if(!(d==="upstream"||d==="downstream"))return p},2)],{type:"application/json"});ka(c,o.title+"-"+o.key+".json"),x.message.success(a("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Sa}}}}})}})}},Ta=e=>{const{instruction:t,data:o,detailText:n,workflow:i}=e,a=Fa({instruction:t,data:o,detailText:n,workflow:i});return r.jsx(s.SchemaComponent,{schema:a,components:t.components,scope:A(w({},t.scope),{useFormProviderProps:va})})},Na=e=>{const{instruction:t,data:o,detailText:n,workflow:i,editingConfig:a,setEditingConfig:l}=e;return r.jsx(wa,{editingConfig:a,setEditingConfig:l,data:o,workflow:i,children:r.jsx(Ta,{instruction:t,data:o,detailText:n,workflow:i})})},Da=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
|
+
`})),Oa=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=q())!=null?c:{},i=he();if(!t)return null;const a=e.resource("flow_nodes");function l(){return D(this,null,function*(){var d;yield(d=a.moveUp)==null?void 0:d.call(a,{filterByTk:i.id}),n()})}return r.jsx(x.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(j.HolderOutlined,{}),onClick:l})},Pa=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
|
+
`})),Ma=()=>{var a;const{execution:e,setViewJob:t}=q(),{jobs:o}=(a=he())!=null?a:{},{styles:n}=Pa();if(!e)return null;if(!o.length)return r.jsx(Xe,{className:n.nodeJobButtonClass,disabled:!0});const i=l=>{const{key:c}=l,d=o.find(p=>p.id===+c);t(d)};return o.length>1?r.jsx(x.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Xe,{statusMap:Re,status:l.status}),r.jsx("time",{children:W.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:i},children:r.jsx(Xe,{statusMap:Re,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Xe,{statusMap:Re,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},Ea=()=>{var p;const{t:e}=X.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:i}=(p=q())!=null?p:{},a=he(),{modal:l}=x.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return D(this,null,function*(){function u(){return D(this,null,function*(){var h;yield(h=c.destroy)==null?void 0:h.call(c,{filterByTk:a.id}),i()})}const f=n.filter(h=>h===a?!1:W.parse(h.config).parameters.filter(({key:T})=>T.startsWith(`$jobsMapByNodeKey.${a.key}.`)||T===`$jobsMapByNodeKey.${a.key}`).length);if(f.length){l.error({title:F("Can not delete"),content:F("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(h=>`#${h.id}`).join(", ")})});return}const y=!n.find(h=>h.upstream===a&&h.branchIndex!=null)?e("Are you sure you want to delete it?"):F("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:y,onOk:u})})}return r.jsx(x.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(j.DeleteOutlined,{}),onClick:d})},$a=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
|
+
`})),Ba=e=>{const{color:t,icon:o,workflow:n,editingTitle:i,configuring:a,setEditingTitle:l,onChangeTitle:c}=e,d=he(),{styles:p}=$a(),[u,f]=b.useState(!1),g=n.executed||!u,y=(d==null?void 0:d.group)===_e,h=()=>{a&&f(!0)},v=I=>{c(I.target.value),f(!1)};return r.jsxs("div",{className:s.cx(p.nodePoint,{deprecated:y,configuring:a}),children:[r.jsx(Va,{color:t,icon:o}),r.jsx(Mo,{className:`workflow-node-edit ${g?"node-executed":""}`,readOnly:g,value:i,onChange:I=>l(I.target.value),onBlur:v,onClick:h}),r.jsx(Wa,{isExecuted:n.executed})]})},Va=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"})})},Wa=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(Ma,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(Ea,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(Oa,{})})]})})},st=e=>{var B,E;const{data:t,children:o}=e,n=s.useCompile(),i=s.useAPIClient(),{workflow:a,refresh:l}=(B=q())!=null?B:{},{styles:c}=Da(),p=s.usePlugin(Z).instructions.get(t.type),u=a.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(p.title),{color:g,icon:y}=p,[h,v]=b.useState((E=t.title)!=null?E:f),[I,T]=b.useState(!1),C=b.useCallback(function(P){return D(this,null,function*(){var K,z;const $=P||f;v($),$!==t.title&&(yield(z=(K=i.resource("flow_nodes")).update)==null?void 0:z.call(K,{filterByTk:t.id,values:{title:$}}),l())})},[t]),O=b.useCallback(function(P){var K,z;if(P.target===P.currentTarget){T(!0);return}(z=(K=P.target)==null?void 0:K.classList)!=null&&z.contains("workflow-node-edit")&&T(!0);const $=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let J=P.target;J&&J!==P.currentTarget&&J!==document.documentElement;J=J.parentNode)if(Array.from(J.classList).some(Y=>$.has(Y))){T(!0),P.stopPropagation();return}},[]);return r.jsxs("div",{className:s.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{className:s.cx(c.nodeCardClass),role:"button","aria-label":`${f}-${h}`,onClick:O,children:[r.jsx(Ba,{color:g,icon:y,workflow:a,editingTitle:h,configuring:I,setEditingTitle:v,onChangeTitle:C}),r.jsx(Na,{instruction:p,data:t,detailText:u,workflow:a,editingConfig:I,setEditingConfig:T})]}),o]})},Q=new W.Registry;Q.register("equal",{name:"=",type:"boolean",group:"boolean"}),Q.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Q.register("gt",{name:">",type:"boolean",group:"boolean"}),Q.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Q.register("lt",{name:"<",type:"boolean",group:"boolean"}),Q.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Q.register("add",{name:"+",type:"number",group:"number"}),Q.register("minus",{name:"-",type:"number",group:"number"}),Q.register("multiple",{name:"*",type:"number",group:"number"}),Q.register("divide",{name:"/",type:"number",group:"number"}),Q.register("mod",{name:"%",type:"number",group:"number"}),Q.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Q.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Q.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Q.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Q.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Q.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Q.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),Q.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Q.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Q.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),Q.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const ja=[{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}" })}}`},{value:"existence",title:`{{t("Existence check", { ns: "${m}" })}}`}];function en(e){return Array.from(Q.getEntities()).filter(([t,o])=>o.group===e)}function za({calculator:e,operands:t=[],onChange:o}){const[n,i]=b.useState(e),a=s.useCompile(),l=le(),c=p=>{const u=Q.get(p);return(u==null?void 0:u.group)==="existence"},d=p=>{i(p),o({operands:t,calculator:p})};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:
|
|
783
|
+
`,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:p=>o({calculator:n,operands:[p,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(x.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:F("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:ja.filter(p=>!!en(p.value).length).map(p=>r.jsx(x.Select.OptGroup,{label:a(p.title),children:en(p.value).map(([u,{name:f}])=>r.jsx(x.Select.Option,{value:u,children:a(f)},u))},p.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:p=>o({calculator:n,operands:[t[0],p]}),scope:l,useTypedConstant:!0})]})}function La({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:i=[]}=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(
|
|
787
|
+
`,children:[e.group?r.jsx(tn,{value:e.group,onChange:a=>t(A(w({},e),{group:a}))}):r.jsx(za,{operands:i,calculator:n,onChange:t}),r.jsx(x.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(j.CloseCircleOutlined,{})})]})}function tn({value:e,onChange:t}){const{t:o}=X.useTranslation(),{type:n="and",calculations:i=[]}=e;function a(){t(A(w({},e),{calculations:[...i,{not:!1,calculator:"equal"}]}))}function l(){t(A(w({},e),{calculations:[...i,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){i.splice(p,1),t(A(w({},e),{calculations:[...i]}))}function d(p,u){i.splice(p,1,u),t(A(w({},e),{calculations:[...i]}))}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(X.Trans,{children:["Meet ",r.jsxs(x.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(
|
|
806
|
+
`,children:r.jsxs(X.Trans,{children:["Meet ",r.jsxs(x.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(A(w({},e),{type:p})),children:[r.jsx(x.Select.Option,{value:"and",children:"All"}),r.jsx(x.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:i.map((p,u)=>r.jsx(La,{value:p,onChange:d.bind(this,u),onRemove:()=>c(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(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function
|
|
813
|
+
`,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function qa({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(tn,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class Ua extends H{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",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}" })}}`,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(Ye.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(w({value:o},n)),[])},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"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},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}}],this.scope={renderEngineReference:Zo,useWorkflowVariableOptions:le},this.components={CalculationConfig:qa,WorkflowVariableTextArea:nt,RadioWithTooltip:Fe}}Component({data:t}){const{t:o}=X.useTranslation(),{nodes:n}=q(),{styles:i}=ye(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),d=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(st,{data:t,children:l?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx($e,{from:t,entry:c,branchIndex:1}),r.jsx($e,{from:t,entry:d,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:o("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:o("No")})]})]})})}}function _a(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=S.useField(),n=o.segments[o.segments.length-1],{values:i}=S.useForm(),[a,l]=s.parseCollectionName(i==null?void 0:i.collection),c=t(l,a),{type:d}=c.find(f=>f.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(f){const g=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?g:g.split(/[,\s]+/))}return r.jsx(x.Input,A(w({},e),{value:p,onChange:u}))}const Xt=S.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:i}=s.useToken(),{t:a}=X.useTranslation(),l=s.useCompile(),c=S.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),p=le(),{values:u}=c,[f,g]=s.parseCollectionName(u==null?void 0:u.collection),y=d(g,f).filter(C=>C.uiSchema),h=n?y.filter(n.bind(u)):y,v=b.useMemo(()=>h.filter(C=>!e||!(C.name in e)),[h,e]),I=t||c.disabled,T=b.useMemo(()=>({onClick:({key:C})=>{o(A(w({},e),{[C]:null}))},style:{maxHeight:300,overflowY:"auto"},items:v.map(C=>{var O,B;return{key:C.name,label:l((B=(O=C.uiSchema)==null?void 0:O.title)!=null?B:C.name)}})}),[o,v,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:
|
|
823
|
+
`,children:h.length?r.jsxs(s.CollectionProvider_deprecated,{name:g,dataSource:f,children:[h.filter(C=>e&&C.name in e).map(C=>{var B,E;const O=["belongsTo","hasOne","hasMany","belongsToMany"].includes(C.type)?_a:s.CollectionField;return r.jsxs(x.Form.Item,{label:l((E=(B=C.uiSchema)==null?void 0:B.title)!=null?E:C.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[C.name],changeOnSelect:!0,onChange:P=>{o(
|
|
827
|
+
`,children:[r.jsx(s.Variable.Input,{scope:p,value:e[C.name],changeOnSelect:!0,onChange:P=>{o(A(w({},e),{[C.name]:P}))},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[C.name]:{"x-component":O,"x-validator"(){return""}}}}})}),I?null:r.jsx(x.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(j.CloseCircleOutlined,{}),onClick:()=>{var K;const z=e,{[K=C.name]:P}=z,$=_(z,[qn(K)]);o($)}})]},C.name)}),v.length?r.jsx(x.Dropdown,{menu:T,children:r.jsx(x.Button,{icon:r.jsx(j.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:i.colorText},children:F("Please select collection first")})})},{displayName:"CollectionFieldSet"}),me={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Rt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:s.css`
|
|
828
828
|
flex-direction: column;
|
|
829
|
-
`},"x-component":"CollectionFieldset"},
|
|
829
|
+
`},"x-component":"CollectionFieldset"},it={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=S.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"}},Ea={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"}}},$a={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("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}}}}}}}}},rt={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}=S.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Ba extends Q{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Zo,appends:rt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Qo}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Va extends Q{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",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}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:I(v({},wt),{"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De}}}class Wa extends Q{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,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:ye.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class ja extends Q{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["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:wt,sort:Ea,pagination:$a,appends:rt},"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}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=S.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:be.ArrayItems,FilterDynamicComponent:De,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function za(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,y)=>(y.name in f.value&&(u.value||![].includes(y.type))&&(g[y.name]=f.value[y.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Oe,I(v({},t),{onChange:p}))}class La extends Q{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["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:I(v({},wt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}}),values:I(v({},Zo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De,CollectionFieldset:Qo,IndividualHooksRadioWithTooltip:za}}}const qa=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=S.useFieldSchema();return S.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}}]}),Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Ua=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ve.DELETED}];class Ka extends Qe{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ve["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:Ua,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(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.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(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},condition:I(v({},wt),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:I(v({},rt),{"x-reactions":[...rt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Do},this.components={FieldsSelect:et}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return ue(I(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function _a(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Xo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=X.useTranslation(),[i,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
|
|
832
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Ka={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"}}},Ga={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("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}}}}}}}}},at={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}=S.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Ha extends H{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},me),{"x-reactions":[...me["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Rt,appends:at}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Xt}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:De,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Ja extends H{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",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}" })}}`,this.fieldset={collection:A(w({},me),{"x-reactions":[...me["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(w({},it),{"x-validator"(t){return et(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ie}}}class Ya extends H{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,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},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class Qa extends H{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},me),{"x-reactions":[...me["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:it,sort:Ka,pagination:Ga,appends:at},"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}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=S.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:we.ArrayItems,FilterDynamicComponent:Ie,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(A(w({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:De,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function Za(o){var n=o,{onChange:e}=n,t=_(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const g=c.reduce((y,h)=>(h.name in f.value&&(u.value||![].includes(h.type))&&(y[h.name]=f.value[h.name]),y),{});a.setValuesIn("params.values",g),e(u.value)}return r.jsx(Fe,A(w({},t),{onChange:p}))}class Xa extends H{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},me),{"x-reactions":[...me["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:A(w({},it),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return et(t)?"":F("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ie,CollectionFieldset:Xt,IndividualHooksRadioWithTooltip:Za}}}function Ra(o){var n=o,{onChange:e}=n,t=_(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const g=c.reduce((y,h)=>(h.name in f.value&&(u.value||![].includes(h.type))&&(y[h.name]=f.value[h.name]),y),{});a.setValuesIn("params.values",g),e(u.value)}return r.jsx(Fe,A(w({},t),{onChange:p}))}class el extends H{constructor(){super(...arguments),this.title=`{{t("Update or create record", { ns: "${m}" })}}`,this.type="updateorcreate",this.group="collection",this.icon="FileSyncOutlined",this.color="#f6f66a",this.description=`{{t("Update or create record, if no matching record is found, a new record will be created, with the ability to assign values to fields using variables from upstream nodes.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},me),{"x-reactions":[...me["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:A(w({},it),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return et(t)?"":F("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ie,CollectionFieldset:Xt,IndividualHooksRadioWithTooltip:Ra}}}const tl=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=S.useFieldSchema();return S.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}}]}),Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ol=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ve.DELETED}];class nl extends Qe{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:A(w({},me),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...me["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:ol,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(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.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(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},condition:A(w({},it),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},at),{"x-reactions":[...at["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Eo},this.components={FieldsSelect:tt}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return ue(A(w({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:De,collection:t.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function rl(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function on({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=X.useTranslation(),[i,a]=b.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(
|
|
835
|
+
`,children:[r.jsx(tt,{value:o.field,onChange:l=>t(A(w({},o),{field:l})),filter:rl,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(x.Select,{value:i,onChange:l=>{a(l),t(A(w({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:F("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,i?r.jsxs(r.Fragment,{children:[r.jsx(x.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(A(w({},o),{offset:(l!=null?l:0)*i}))}),r.jsx(x.Select,{value:o.unit||864e5,onChange:l=>t(A(w({},o),{unit:l})),options:[{value:864e5,label:F("Days")},{value:36e5,label:F("Hours")},{value:6e4,label:F("Minutes")},{value:1e3,label:F("Seconds")}],className:"auto-width"})]}):null]})}function sl({value:e,onChange:t}){const{t:o}=ve(),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(x.Select,{value:n,onChange:i=>{t(i?i==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(Xo,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:W.dayjs(e),onChange:i=>{t(i?i.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ce.apply(this,arguments)};function Ro(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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function Ct(e,t,o){if(o||arguments.length===2)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var Ha=[{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 * * * *"}],je=[{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 en(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function kt(e){return e.sort(function(t,o){return t-o}),e}function tn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function we(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 on(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function St(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function nn(e,t,o,n,i,a,l,c,d,p,u,f,h,g){o&&o(void 0),t(!1);var y=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;y=!0}if(!y){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var w=Ha.find(function(C){return C.name===e});w&&(e=w.value)}try{var A=function(C){if(typeof C!="string")throw new Error("Invalid cron string");var D=C.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function($,E){return function(P,B){if(P==="*"||P==="*/1")return[];var _=kt(tn(ln(function(J,Y,se){if(se){J=J.toUpperCase();for(var V=0;V<se.length;V++)J=J.replace(se[V],"".concat(V+Y))}return J}(P,B.min,B.alt).split(",").map(function(J){var Y,se=J.split("/");if(se.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat(B.type,'"'));var V=se[0],M=se[1];Y=V==="*"?en(B.min,B.max):function(H,ee,G){var re=H.split("-");if(re.length===1){var Le=St(re[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(ee,'" for ').concat(G.type));return[Le]}if(re.length===2){var xe=St(re[0]),He=St(re[1]);if(isNaN(xe)||isNaN(He))throw new Error('Invalid value "'.concat(ee,'" for ').concat(G.type));if(He<xe)throw new Error('Max range is less than min range in "'.concat(H,'" for ').concat(G.type));return en(xe,He)}throw new Error('Invalid value "'.concat(H,'" for ').concat(G.type))}(V,P,B);var L=function(H,ee){if(H!==void 0){var G=St(H);if(isNaN(G)||G<1)throw new Error('Invalid interval step value "'.concat(H,'" for ').concat(ee.type));return G}}(M,B),R=function(H,ee){if(ee){var G=H[0];H=H.filter(function(re){return re%ee==G%ee||re===G})}return H}(Y,L);return R}).flat(),B))),z=cn(_,B);if(z!==void 0)throw new Error('Value "'.concat(z,'" out of range for ').concat(B.type));return _.length===B.total?[]:_}($,je[E])});throw new Error("Invalid cron string format")}(e),T=function(C){return C[3].length>0?"year":C[2].length>0?"month":C[4].length>0?"week":C[1].length>0?"day":C[0].length>0?"hour":"minute"}(A);g(T),d(A[0]),p(A[1]),u(A[2]),f(A[3]),h(A[4])}catch(C){y=!0}}y&&(i.current=e,t(!0),on(o,l))}function rn(e,t,o,n,i,a,l){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(u,f){var h=je[f];return sn(an(u,h),h,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&i?i:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function sn(e,t,o,n,i){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var p=1;p<c.length;p++){var u=c[p-1];if(c[p]-u!==d)return!1}return!0}(e,l)?function(c,d,p){var u=dn(c),f=pn(c),h=c.length===(f-u)/p+1;return!!(u===d.min&&f+p>d.max&&h)}(e,t,l)?"*/".concat(l):"".concat(Ge(dn(e),t,o,n,i),"-").concat(Ge(pn(e),t,o,n,i),"/").concat(l):function(c){var d=[],p=null;return c.forEach(function(u,f,h){u!==h[f+1]-1?p!==null?(d.push([p,u]),p=null):d.push(u):p===null&&(p=u)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ge(c[0],t,o,n,i),"-").concat(Ge(c[1],t,o,n,i)):Ge(c,t,o,n,i)}).join(",")}return a}function Ge(e,t,o,n,i){var a=e.toString(),l=t.type,c=t.alt,d=t.min,p=n&&(n===!0||n.includes(l)),u=i==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(p||u)&&(a=a.padStart(2,"0")),l==="hours"&&i==="12-hour-clock"){var f=e>=12?"PM":"AM",h=e%12||12;h<10&&p&&(h=h.toString().padStart(2,"0")),a="".concat(h).concat(f)}return a}function an(e,t){var o=kt(tn(ln(e,t)));if(o.length===0)return o;var n=cn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function ln(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function cn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function dn(e){return e[0]}function pn(e){return e[e.length-1]}function st(e){var t=e.value,o=e.grid,n=o===void 0||o,i=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,u=e.readOnly,f=e.leadingZero,h=e.clockFormat,g=e.period,y=e.unit,w=e.periodicityOnDoubleClick,A=e.mode,T=Ro(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),C=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(V){return V.toString()})},[t]),D=b.useMemo(function(){return i?i.map(function(V,M){return{value:(y.min===0?M:M+1).toString(),label:V}}):Ct([],Array(y.total),!0).map(function(V,M){var L=y.min===0?M:M+1;return{value:L.toString(),label:Ge(L,y,d,f,h)}})},[i,f,d,h]),$=JSON.stringify(l),E=b.useCallback(function(V){var M=V.value;if(!t||t[0]!==Number(M))return r.jsx(r.Fragment,{});var L=sn(an(t,y),y,d,f,h),R=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:R[1]?"".concat(l.everyText||U.everyText," ").concat(R[1]):L})},[t,$,d,f,h]),P=b.useCallback(function(V){var M=Array.isArray(V)?kt(V):[V],L=M;t&&(L=A==="single"?[]:Ct([],t,!0),M.forEach(function(R){var H=Number(R);L=t.some(function(ee){return ee===H})?L.filter(function(ee){return ee!==H}):kt(Ct(Ct([],L,!0),[H],!1))})),L.length===y.total?a([]):a(L)},[a,t]),B=b.useCallback(function(V){if(V!==0&&V!==1){for(var M=y.total+y.min,L=[],R=y.min;R<M;R++)R%V==0&&L.push(R);var H=t&&L&&t.length===L.length&&t.every(function(G,re){return G===L[re]}),ee=L.length===D.length;a(ee||H?[]:L)}else a([])},[t,D,a]),_=b.useRef([]),z=b.useCallback(function(V){if(!u){var M=_.current;M.push({time:new Date().getTime(),value:Number(V)});var L=window.setTimeout(function(){w&&M.length>1&&M[M.length-1].time-M[M.length-2].time<300?M[M.length-1].value===M[M.length-2].value?B(Number(V)):P([M[M.length-2].value,M[M.length-1].value]):P(Number(V)),_.current=[]},300);return function(){window.clearTimeout(L)}}},[_,P,B,u,w]),J=b.useCallback(function(){u||a([])},[a,u]),Y=b.useMemo(function(){var V;return we(((V={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,V))},[c]),se=b.useMemo(function(){var V;return we(((V={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(y.type)]=!0,V["react-js-cron-custom-select-dropdown"]=!0,V["react-js-cron-custom-select-dropdown-".concat(y.type)]=!0,V["react-js-cron-custom-select-dropdown-minutes-large"]=y.type==="minutes"&&g!=="hour"&&g!=="day",V["react-js-cron-custom-select-dropdown-minutes-medium"]=y.type==="minutes"&&(g==="day"||g==="hour"),V["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=y.type==="hours"&&h==="12-hour-clock",V["react-js-cron-custom-select-dropdown-grid"]=!!n,V["".concat(c,"-select-dropdown")]=!!c,V["".concat(c,"-select-dropdown-").concat(y.type)]=!!c,V))},[c,n,h,g]);return r.jsx(x.Select,ce({mode:A!=="single"||w?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:C,onClear:J,tagRender:E,className:Y,popupClassName:se,options:D,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:z,onDeselect:z,disabled:p,dropdownAlign:y.type!=="minutes"&&y.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(y.type)},T))}function Ja(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=b.useMemo(function(){var g;return we(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-hours")]=!!i,g))},[i]);return r.jsxs("div",ce({className:h},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(st,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:je[1],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f})]}))}function Ya(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=b.useMemo(function(){var g;return we(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-minutes")]=!!i,g))},[i]);return r.jsxs("div",ce({className:h},{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(st,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:je[0],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function Qa(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=!a||a.length===0,g=b.useMemo(function(){var A;return we(((A={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!h})["".concat(i,"-field")]=!!i,A["".concat(i,"-month-days")]=!!i,A))},[i,h]),y=JSON.stringify(n),w=b.useMemo(function(){return h?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[h,y]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",ce({className:g},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(st,{placeholder:w,value:t,setValue:o,unit:je[2],locale:n,className:i,disabled:l,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function Za(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,u=e.mode,f=n.months||U.months,h=b.useMemo(function(){var g;return we(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,g["".concat(i,"-months")]=!!i,g))},[i]);return r.jsxs("div",ce({className:h},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(st,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:f,grid:!1,value:t,unit:ce(ce({},je[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:u})]}))}function Xa(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),d.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),d.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),d.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),d.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),d.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=b.useCallback(function(y){l||o(y)},[o,l]),f=b.useMemo(function(){var y;return we(((y={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(i,"-field")]=!!i,y["".concat(i,"-period")]=!!i,y))},[i]),h=b.useMemo(function(){var y;return we(((y={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(i,"-select")]=!!i,y))},[i,n.prefixPeriod]),g=b.useMemo(function(){var y;return we(((y={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(i,"-select-dropdown")]=!!i,y["".concat(i,"-select-dropdown-period")]=!!i,y))},[i]);return r.jsxs("div",ce({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:u,options:p,className:h,popupClassName:g,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Ra(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.weekDays||U.weekDays,g=p==="week"||!l||l.length===0,y=b.useMemo(function(){var D;return we(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(i,"-field")]=!!i,D["".concat(i,"-week-days")]=!!i,D))},[i,g]),w=JSON.stringify(n),A=b.useMemo(function(){return g?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[g,w]),T=p==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),C=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",ce({className:y},{children:[n.prefixWeekDays!==""&&(p==="week"||!C)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&C&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(st,{placeholder:A,optionsList:h,grid:!1,value:t,unit:ce(ce({},je[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function el(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,i=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?U:c,p=e.value,u=p===void 0?"":p,f=e.setValue,h=e.displayError,g=h===void 0||h,y=e.onError,w=e.className,A=e.defaultPeriod,T=A===void 0?"day":A,C=e.allowEmpty,D=C===void 0?"for-default-value":C,$=e.humanizeLabels,E=$===void 0||$,P=e.humanizeValue,B=P!==void 0&&P,_=e.disabled,z=_!==void 0&&_,J=e.readOnly,Y=J!==void 0&&J,se=e.leadingZero,V=se!==void 0&&se,M=e.shortcuts,L=M===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:M,R=e.clockFormat,H=e.periodicityOnDoubleClick,ee=H===void 0||H,G=e.mode,re=G===void 0?"multiple":G,Le=e.allowedDropdowns,xe=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,He=e.allowedPeriods,vl=He===void 0?["year","month","week","day","hour","minute","reboot"]:He,Je=b.useRef(u),to=b.useRef(T),Cn=b.useState(),Fe=Cn[0],At=Cn[1],kn=b.useState(),at=kn[0],It=kn[1],Sn=b.useState(),Ft=Sn[0],Tt=Sn[1],An=b.useState(),lt=An[0],Nt=An[1],In=b.useState(),Dt=In[0],Ot=In[1],Fn=b.useState(),Pt=Fn[0],Mt=Fn[1],Tn=b.useState(!1),oo=Tn[0],ct=Tn[1],Nn=b.useState(!1),Et=Nn[0],Dn=Nn[1],wl=function(te){var Ae=b.useRef(te);return b.useEffect(function(){Ae.current=te},[te]),Ae.current}(Et),On=JSON.stringify(d);b.useEffect(function(){nn(u,ct,y,D,Je,!0,d,L,Mt,Ot,It,Tt,Nt,At)},[]),b.useEffect(function(){u!==Je.current&&nn(u,ct,y,D,Je,!1,d,L,Mt,Ot,It,Tt,Nt,At)},[u,Je,On,D,L]),b.useEffect(function(){if(!(Fe||Pt||Ft||at||lt||Dt)||Et||wl)Et&&Dn(!1);else{var te=Fe||to.current,Ae=rn(te,Ft,at,lt,Dt,Pt,B);f(Ae,{selectedPeriod:te}),Je.current=Ae,y&&y(void 0),ct(!1)}},[Fe,at,Ft,lt,Dt,Pt,B,Et]);var Pn=b.useCallback(function(){It(void 0),Tt(void 0),Nt(void 0),Ot(void 0),Mt(void 0);var te="",Ae=Fe!=="reboot"&&Fe?Fe:to.current;Ae!==Fe&&At(Ae),l==="fill-with-every"&&(te=rn(Ae,void 0,void 0,void 0,void 0,void 0)),f(te,{selectedPeriod:Ae}),Je.current=te,Dn(!0),D==="never"&&l==="empty"?(ct(!0),on(y,d)):(y&&y(void 0),ct(!1))},[Fe,f,y,l]),Cl=b.useMemo(function(){var te;return we(((te={"react-js-cron":!0,"react-js-cron-error":oo&&g,"react-js-cron-disabled":z,"react-js-cron-read-only":Y})["".concat(w)]=!!w,te["".concat(w,"-error")]=oo&&g&&!!w,te["".concat(w,"-disabled")]=z&&!!w,te["".concat(w,"-read-only")]=Y&&!!w,te))},[w,oo,g,z,Y]),no=i.className,Mn=Ro(i,["className"]),En=b.useMemo(function(){var te;return we(((te={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,te["".concat(no)]=!!no,te))},[w,no]),kl=JSON.stringify(Mn),$n=b.useMemo(function(){return o&&!Y?r.jsx(x.Button,ce({className:En,danger:!0,type:"primary",disabled:z},Mn,{onClick:Pn},{children:d.clearButtonText||U.clearButtonText})):null},[o,Y,On,En,z,kl,Pn]),ae=Fe||to.current;return r.jsxs("div",ce({className:Cl},{children:[xe.includes("period")&&r.jsx(Xa,{value:ae,setValue:At,locale:d,className:w,disabled:z,readOnly:Y,shortcuts:L,allowedPeriods:vl}),ae==="reboot"?$n:r.jsxs(r.Fragment,{children:[ae==="year"&&xe.includes("months")&&r.jsx(Za,{value:Ft,setValue:Tt,locale:d,className:w,humanizeLabels:E,disabled:z,readOnly:Y,period:ae,periodicityOnDoubleClick:ee,mode:re}),(ae==="year"||ae==="month")&&xe.includes("month-days")&&r.jsx(Qa,{value:at,setValue:It,locale:d,className:w,weekDays:lt,disabled:z,readOnly:Y,leadingZero:V,period:ae,periodicityOnDoubleClick:ee,mode:re}),(ae==="year"||ae==="month"||ae==="week")&&xe.includes("week-days")&&r.jsx(Ra,{value:lt,setValue:Nt,locale:d,className:w,humanizeLabels:E,monthDays:at,disabled:z,readOnly:Y,period:ae,periodicityOnDoubleClick:ee,mode:re}),r.jsxs("div",{children:[ae!=="minute"&&ae!=="hour"&&xe.includes("hours")&&r.jsx(Ja,{value:Dt,setValue:Ot,locale:d,className:w,disabled:z,readOnly:Y,leadingZero:V,clockFormat:R,period:ae,periodicityOnDoubleClick:ee,mode:re}),ae!=="minute"&&xe.includes("minutes")&&r.jsx(Ya,{value:Pt,setValue:Mt,locale:d,period:ae,className:w,disabled:z,readOnly:Y,leadingZero:V,clockFormat:R,periodicityOnDoubleClick:ee,mode:re}),$n]})]})]}))}const tl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},un=[{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 mn(e){return un.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function ol(e){let t;switch(typeof e){case"number":return t=mn(e),t?t.value:"none";case"string":return"cron"}return"none"}function nl({value:e,onChange:t}){const{t:o}=Ce(),n=mn(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:i=>t(i*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function rl({value:e=null,onChange:t}){const{t:o}=Ce(),n=ol(e);function i(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=tl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
|
|
838
|
+
`,children:[r.jsxs(x.Select,{value:n,onChange:i=>{t(i?i==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(x.Select.Option,{value:null,children:o("No end")}),r.jsx(x.Select.Option,{value:"field",children:o("By field")}),r.jsx(x.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(on,{value:e,onChange:t}):null,n==="date"?r.jsx(x.DatePicker,{showTime:!0,value:W.dayjs(e),onChange:i=>{t(i?i.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ce.apply(this,arguments)};function nn(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 i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function Ct(e,t,o){if(o||arguments.length===2)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var il=[{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 * * * *"}],je=[{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 rn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function kt(e){return e.sort(function(t,o){return t-o}),e}function sn(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 an(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function St(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function ln(e,t,o,n,i,a,l,c,d,p,u,f,g,y){o&&o(void 0),t(!1);var h=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;h=!0}if(!h){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void y("reboot");var v=il.find(function(C){return C.name===e});v&&(e=v.value)}try{var I=function(C){if(typeof C!="string")throw new Error("Invalid cron string");var O=C.replace(/\s+/g," ").trim().split(" ");if(O.length===5)return O.map(function(B,E){return function(P,$){if(P==="*"||P==="*/1")return[];var K=kt(sn(un(function(J,Y,se){if(se){J=J.toUpperCase();for(var V=0;V<se.length;V++)J=J.replace(se[V],"".concat(V+Y))}return J}(P,$.min,$.alt).split(",").map(function(J){var Y,se=J.split("/");if(se.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat($.type,'"'));var V=se[0],M=se[1];Y=V==="*"?rn($.min,$.max):function(G,te,R){var re=G.split("-");if(re.length===1){var Le=St(re[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(te,'" for ').concat(R.type));return[Le]}if(re.length===2){var be=St(re[0]),He=St(re[1]);if(isNaN(be)||isNaN(He))throw new Error('Invalid value "'.concat(te,'" for ').concat(R.type));if(He<be)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return rn(be,He)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}(V,P,$);var L=function(G,te){if(G!==void 0){var R=St(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(te.type));return R}}(M,$),ee=function(G,te){if(te){var R=G[0];G=G.filter(function(re){return re%te==R%te||re===R})}return G}(Y,L);return ee}).flat(),$))),z=mn(K,$);if(z!==void 0)throw new Error('Value "'.concat(z,'" out of range for ').concat($.type));return K.length===$.total?[]:K}(B,je[E])});throw new Error("Invalid cron string format")}(e),T=function(C){return C[3].length>0?"year":C[2].length>0?"month":C[4].length>0?"week":C[1].length>0?"day":C[0].length>0?"hour":"minute"}(I);y(T),d(I[0]),p(I[1]),u(I[2]),f(I[3]),g(I[4])}catch(C){h=!0}}h&&(i.current=e,t(!0),an(o,l))}function cn(e,t,o,n,i,a,l){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(u,f){var g=je[f];return dn(pn(u,g),g,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&i?i:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function dn(e,t,o,n,i){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var p=1;p<c.length;p++){var u=c[p-1];if(c[p]-u!==d)return!1}return!0}(e,l)?function(c,d,p){var u=fn(c),f=gn(c),g=c.length===(f-u)/p+1;return!!(u===d.min&&f+p>d.max&&g)}(e,t,l)?"*/".concat(l):"".concat(Ge(fn(e),t,o,n,i),"-").concat(Ge(gn(e),t,o,n,i),"/").concat(l):function(c){var d=[],p=null;return c.forEach(function(u,f,g){u!==g[f+1]-1?p!==null?(d.push([p,u]),p=null):d.push(u):p===null&&(p=u)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ge(c[0],t,o,n,i),"-").concat(Ge(c[1],t,o,n,i)):Ge(c,t,o,n,i)}).join(",")}return a}function Ge(e,t,o,n,i){var a=e.toString(),l=t.type,c=t.alt,d=t.min,p=n&&(n===!0||n.includes(l)),u=i==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(p||u)&&(a=a.padStart(2,"0")),l==="hours"&&i==="12-hour-clock"){var f=e>=12?"PM":"AM",g=e%12||12;g<10&&p&&(g=g.toString().padStart(2,"0")),a="".concat(g).concat(f)}return a}function pn(e,t){var o=kt(sn(un(e,t)));if(o.length===0)return o;var n=mn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function un(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function mn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function fn(e){return e[0]}function gn(e){return e[e.length-1]}function lt(e){var t=e.value,o=e.grid,n=o===void 0||o,i=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,u=e.readOnly,f=e.leadingZero,g=e.clockFormat,y=e.period,h=e.unit,v=e.periodicityOnDoubleClick,I=e.mode,T=nn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),C=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(V){return V.toString()})},[t]),O=b.useMemo(function(){return i?i.map(function(V,M){return{value:(h.min===0?M:M+1).toString(),label:V}}):Ct([],Array(h.total),!0).map(function(V,M){var L=h.min===0?M:M+1;return{value:L.toString(),label:Ge(L,h,d,f,g)}})},[i,f,d,g]),B=JSON.stringify(l),E=b.useCallback(function(V){var M=V.value;if(!t||t[0]!==Number(M))return r.jsx(r.Fragment,{});var L=dn(pn(t,h),h,d,f,g),ee=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ee[1]?"".concat(l.everyText||U.everyText," ").concat(ee[1]):L})},[t,B,d,f,g]),P=b.useCallback(function(V){var M=Array.isArray(V)?kt(V):[V],L=M;t&&(L=I==="single"?[]:Ct([],t,!0),M.forEach(function(ee){var G=Number(ee);L=t.some(function(te){return te===G})?L.filter(function(te){return te!==G}):kt(Ct(Ct([],L,!0),[G],!1))})),L.length===h.total?a([]):a(L)},[a,t]),$=b.useCallback(function(V){if(V!==0&&V!==1){for(var M=h.total+h.min,L=[],ee=h.min;ee<M;ee++)ee%V==0&&L.push(ee);var G=t&&L&&t.length===L.length&&t.every(function(R,re){return R===L[re]}),te=L.length===O.length;a(te||G?[]:L)}else a([])},[t,O,a]),K=b.useRef([]),z=b.useCallback(function(V){if(!u){var M=K.current;M.push({time:new Date().getTime(),value:Number(V)});var L=window.setTimeout(function(){v&&M.length>1&&M[M.length-1].time-M[M.length-2].time<300?M[M.length-1].value===M[M.length-2].value?$(Number(V)):P([M[M.length-2].value,M[M.length-1].value]):P(Number(V)),K.current=[]},300);return function(){window.clearTimeout(L)}}},[K,P,$,u,v]),J=b.useCallback(function(){u||a([])},[a,u]),Y=b.useMemo(function(){var V;return Ce(((V={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,V))},[c]),se=b.useMemo(function(){var V;return Ce(((V={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(h.type)]=!0,V["react-js-cron-custom-select-dropdown"]=!0,V["react-js-cron-custom-select-dropdown-".concat(h.type)]=!0,V["react-js-cron-custom-select-dropdown-minutes-large"]=h.type==="minutes"&&y!=="hour"&&y!=="day",V["react-js-cron-custom-select-dropdown-minutes-medium"]=h.type==="minutes"&&(y==="day"||y==="hour"),V["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=h.type==="hours"&&g==="12-hour-clock",V["react-js-cron-custom-select-dropdown-grid"]=!!n,V["".concat(c,"-select-dropdown")]=!!c,V["".concat(c,"-select-dropdown-").concat(h.type)]=!!c,V))},[c,n,g,y]);return r.jsx(x.Select,ce({mode:I!=="single"||v?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:C,onClear:J,tagRender:E,className:Y,popupClassName:se,options:O,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:z,onDeselect:z,disabled:p,dropdownAlign:h.type!=="minutes"&&h.type!=="hours"||y==="day"||y==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(h.type)},T))}function al(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=b.useMemo(function(){var y;return Ce(((y={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,y["".concat(i,"-hours")]=!!i,y))},[i]);return r.jsxs("div",ce({className:g},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(lt,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:je[1],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f})]}))}function ll(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=b.useMemo(function(){var y;return Ce(((y={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,y["".concat(i,"-minutes")]=!!i,y))},[i]);return r.jsxs("div",ce({className:g},{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(lt,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:je[0],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:u,mode:f}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||U.suffixMinutesForHourPeriod})]}))}function cl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=!a||a.length===0,y=b.useMemo(function(){var I;return Ce(((I={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!g})["".concat(i,"-field")]=!!i,I["".concat(i,"-month-days")]=!!i,I))},[i,g]),h=JSON.stringify(n),v=b.useMemo(function(){return g?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[g,h]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",ce({className:y},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(lt,{placeholder:v,value:t,setValue:o,unit:je[2],locale:n,className:i,disabled:l,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function dl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,u=e.mode,f=n.months||U.months,g=b.useMemo(function(){var y;return Ce(((y={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,y["".concat(i,"-months")]=!!i,y))},[i]);return r.jsxs("div",ce({className:g},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||U.prefixMonths}),r.jsx(lt,{placeholder:n.emptyMonths||U.emptyMonths,optionsList:f,grid:!1,value:t,unit:ce(ce({},je[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:u})]}))}function pl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:n.yearOption||U.yearOption}),d.includes("month")&&p.push({value:"month",label:n.monthOption||U.monthOption}),d.includes("week")&&p.push({value:"week",label:n.weekOption||U.weekOption}),d.includes("day")&&p.push({value:"day",label:n.dayOption||U.dayOption}),d.includes("hour")&&p.push({value:"hour",label:n.hourOption||U.hourOption}),d.includes("minute")&&p.push({value:"minute",label:n.minuteOption||U.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=b.useCallback(function(h){l||o(h)},[o,l]),f=b.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(i,"-field")]=!!i,h["".concat(i,"-period")]=!!i,h))},[i]),g=b.useMemo(function(){var h;return Ce(((h={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(i,"-select")]=!!i,h))},[i,n.prefixPeriod]),y=b.useMemo(function(){var h;return Ce(((h={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(i,"-select-dropdown")]=!!i,h["".concat(i,"-select-dropdown-period")]=!!i,h))},[i]);return r.jsxs("div",ce({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(x.Select,{defaultValue:t,value:t,onChange:u,options:p,className:g,popupClassName:y,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function ul(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=n.weekDays||U.weekDays,y=p==="week"||!l||l.length===0,h=b.useMemo(function(){var O;return Ce(((O={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!y})["".concat(i,"-field")]=!!i,O["".concat(i,"-week-days")]=!!i,O))},[i,y]),v=JSON.stringify(n),I=b.useMemo(function(){return y?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[y,v]),T=p==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),C=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?r.jsxs("div",ce({className:h},{children:[n.prefixWeekDays!==""&&(p==="week"||!C)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&C&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(lt,{placeholder:I,optionsList:g,grid:!1,value:t,unit:ce(ce({},je[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:u,mode:f})]})):null}function ml(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,i=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?U:c,p=e.value,u=p===void 0?"":p,f=e.setValue,g=e.displayError,y=g===void 0||g,h=e.onError,v=e.className,I=e.defaultPeriod,T=I===void 0?"day":I,C=e.allowEmpty,O=C===void 0?"for-default-value":C,B=e.humanizeLabels,E=B===void 0||B,P=e.humanizeValue,$=P!==void 0&&P,K=e.disabled,z=K!==void 0&&K,J=e.readOnly,Y=J!==void 0&&J,se=e.leadingZero,V=se!==void 0&&se,M=e.shortcuts,L=M===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:M,ee=e.clockFormat,G=e.periodicityOnDoubleClick,te=G===void 0||G,R=e.mode,re=R===void 0?"multiple":R,Le=e.allowedDropdowns,be=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,He=e.allowedPeriods,Pl=He===void 0?["year","month","week","day","hour","minute","reboot"]:He,Je=b.useRef(u),no=b.useRef(T),An=b.useState(),Ne=An[0],At=An[1],In=b.useState(),ct=In[0],It=In[1],Fn=b.useState(),Ft=Fn[0],Tt=Fn[1],Tn=b.useState(),dt=Tn[0],Nt=Tn[1],Nn=b.useState(),Dt=Nn[0],Ot=Nn[1],Dn=b.useState(),Pt=Dn[0],Mt=Dn[1],On=b.useState(!1),ro=On[0],pt=On[1],Pn=b.useState(!1),Et=Pn[0],Mn=Pn[1],Ml=function(oe){var Ae=b.useRef(oe);return b.useEffect(function(){Ae.current=oe},[oe]),Ae.current}(Et),En=JSON.stringify(d);b.useEffect(function(){ln(u,pt,h,O,Je,!0,d,L,Mt,Ot,It,Tt,Nt,At)},[]),b.useEffect(function(){u!==Je.current&&ln(u,pt,h,O,Je,!1,d,L,Mt,Ot,It,Tt,Nt,At)},[u,Je,En,O,L]),b.useEffect(function(){if(!(Ne||Pt||Ft||ct||dt||Dt)||Et||Ml)Et&&Mn(!1);else{var oe=Ne||no.current,Ae=cn(oe,Ft,ct,dt,Dt,Pt,$);f(Ae,{selectedPeriod:oe}),Je.current=Ae,h&&h(void 0),pt(!1)}},[Ne,ct,Ft,dt,Dt,Pt,$,Et]);var $n=b.useCallback(function(){It(void 0),Tt(void 0),Nt(void 0),Ot(void 0),Mt(void 0);var oe="",Ae=Ne!=="reboot"&&Ne?Ne:no.current;Ae!==Ne&&At(Ae),l==="fill-with-every"&&(oe=cn(Ae,void 0,void 0,void 0,void 0,void 0)),f(oe,{selectedPeriod:Ae}),Je.current=oe,Mn(!0),O==="never"&&l==="empty"?(pt(!0),an(h,d)):(h&&h(void 0),pt(!1))},[Ne,f,h,l]),El=b.useMemo(function(){var oe;return Ce(((oe={"react-js-cron":!0,"react-js-cron-error":ro&&y,"react-js-cron-disabled":z,"react-js-cron-read-only":Y})["".concat(v)]=!!v,oe["".concat(v,"-error")]=ro&&y&&!!v,oe["".concat(v,"-disabled")]=z&&!!v,oe["".concat(v,"-read-only")]=Y&&!!v,oe))},[v,ro,y,z,Y]),so=i.className,Bn=nn(i,["className"]),Vn=b.useMemo(function(){var oe;return Ce(((oe={"react-js-cron-clear-button":!0})["".concat(v,"-clear-button")]=!!v,oe["".concat(so)]=!!so,oe))},[v,so]),$l=JSON.stringify(Bn),Wn=b.useMemo(function(){return o&&!Y?r.jsx(x.Button,ce({className:Vn,danger:!0,type:"primary",disabled:z},Bn,{onClick:$n},{children:d.clearButtonText||U.clearButtonText})):null},[o,Y,En,Vn,z,$l,$n]),ae=Ne||no.current;return r.jsxs("div",ce({className:El},{children:[be.includes("period")&&r.jsx(pl,{value:ae,setValue:At,locale:d,className:v,disabled:z,readOnly:Y,shortcuts:L,allowedPeriods:Pl}),ae==="reboot"?Wn:r.jsxs(r.Fragment,{children:[ae==="year"&&be.includes("months")&&r.jsx(dl,{value:Ft,setValue:Tt,locale:d,className:v,humanizeLabels:E,disabled:z,readOnly:Y,period:ae,periodicityOnDoubleClick:te,mode:re}),(ae==="year"||ae==="month")&&be.includes("month-days")&&r.jsx(cl,{value:ct,setValue:It,locale:d,className:v,weekDays:dt,disabled:z,readOnly:Y,leadingZero:V,period:ae,periodicityOnDoubleClick:te,mode:re}),(ae==="year"||ae==="month"||ae==="week")&&be.includes("week-days")&&r.jsx(ul,{value:dt,setValue:Nt,locale:d,className:v,humanizeLabels:E,monthDays:ct,disabled:z,readOnly:Y,period:ae,periodicityOnDoubleClick:te,mode:re}),r.jsxs("div",{children:[ae!=="minute"&&ae!=="hour"&&be.includes("hours")&&r.jsx(al,{value:Dt,setValue:Ot,locale:d,className:v,disabled:z,readOnly:Y,leadingZero:V,clockFormat:ee,period:ae,periodicityOnDoubleClick:te,mode:re}),ae!=="minute"&&be.includes("minutes")&&r.jsx(ll,{value:Pt,setValue:Mt,locale:d,period:ae,className:v,disabled:z,readOnly:Y,leadingZero:V,clockFormat:ee,periodicityOnDoubleClick:te,mode:re}),Wn]})]})]}))}const fl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},hn=[{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 yn(e){return hn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function gl(e){let t;switch(typeof e){case"number":return t=yn(e),t?t.value:"none";case"string":return"cron"}return"none"}function hl({value:e,onChange:t}){const{t:o}=ve(),n=yn(e);return r.jsx(x.InputNumber,{value:e/n.value,onChange:i=>t(i*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function yl({value:e=null,onChange:t}){const{t:o}=ve(),n=gl(e);function i(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=fl[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(x.Select,{value:n,onChange:i,className:"auto-width",children:
|
|
867
|
+
`,children:[r.jsx(x.Select,{value:n,onChange:i,className:"auto-width",children:hn.map(l=>r.jsx(x.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(hl,{value:e,onChange:t}):null,n==="cron"?r.jsx(ml,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const xl={[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:A(w({},me),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...me["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:A(w({},at),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${We.DATE_FIELD} && $deps[1]}}`}}}]})}},bl=[{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}" })}}`}],wl=()=>{const{values:e={},clearFormGraph:t}=S.useForm(),[o,n]=b.useState(e.mode);return S.useFormEffects(()=>{S.onFieldValueChange("mode",i=>{n(i.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:bl},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:sl[o]}}},components:{OnField:Xo,RepeatField:rl,EndsByField:Ga}})]})};class ll extends Qe{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:al}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===We.DATE_FIELD){const[c]=ue(I(v({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Xt={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:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=nr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"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:Be(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:pt}}]},fn=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:Xt,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}=Ce(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return O(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),x.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"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},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}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","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}}}}}}}}}},Rt=fn();function cl(n){var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const{workflow:a}=q(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function dl(){var se;const e=oe.useNavigate(),{t}=X.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=b.useState(!1),[u,f]=b.useState(!1),[h,g]=b.useState(null),{styles:y}=ge(),{modal:w}=x.App.useApp();if(b.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const V=(se=n==null?void 0:n.data)!=null?se:{},{nodes:A=[],revisions:T=[]}=V,C=K(V,["nodes","revisions"]);ft(A);const D=A.find(M=>!M.upstream);function $({key:M}){M!==C.id&&e(Be(M))}function E(M){return O(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return O(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(yt(M.executionId))})}function B(){return O(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key}});x.message.success(t("Operation succeeded")),e(Be(M.id))})}function _(){return O(this,null,function*(){const M=C.current?F("Delete a main version will cause all other revisions to be deleted too."):"";w.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return O(this,null,function*(){var R;yield l.destroy({filterByTk:C.id}),x.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Be((R=T.find(H=>H.current))==null?void 0:R.id))})}})})}const z=()=>O(this,null,function*(){h?(yield l.moveWorkflow({id:C.id,targetKey:h}),x.message.success(F("Move success")),f(!1),C.key=h,i()):x.message.error(F("Select target workflow"))});function J(L){return O(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return B();case"delete":return _();case"move":g(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(qe.Provider,{value:{workflow:C,nodes:A,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(go,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:$,defaultSelectedKeys:[`${C.id}`],className:s.cx(y.dropdownClass,y.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.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:W.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:C.enabled,onChange:E,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(x.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:Rt,components:{ExecutionResourceProvider:cl,ExecutionLink:Gt,ExecutionStatusColumn:Kt},scope:{ExecutionRetryAction:Ht}})})]})]}),r.jsx(ho,{entry:D}),r.jsxs(x.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:h,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>g(M)})]})]})}const hn=()=>{const e=oe.useParams(),{styles:t}=ge();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:dl}})})},pl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},ul=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(x.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},ml=n=>{var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const a=s.useCollectionRecordData(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))};var it=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},gn={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,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,u,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){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,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var h=l.URL||l.webkitURL,g=document.createElement("a");u=u||p.name||"download",g.download=u,g.rel="noopener",typeof p=="string"?(g.href=p,g.origin===location.origin?a(g):i(g.href)?n(p,u,f):a(g,g.target="_blank")):(g.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(g.href)},4e4),setTimeout(function(){a(g)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){a(h)})}}:function(p,u,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var g=p.type==="application/octet-stream",y=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||g&&y||c)&&typeof FileReader!="undefined"){var A=new FileReader;A.onloadend=function(){var D=A.result;D=w?D:D.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=D:location=D,h=null},A.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);h?h.location=C:location.href=C,h=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})})(gn);var fl=gn.exports;const eo=S.observable({value:""}),yn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],ze={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:yn,"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:N("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}}]},me={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}}}}},xn={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":`${ze.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:ze},"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:me.title,tags:me.tags,type:me.type,sync:me.sync,description:me.description,options:me.options}}}}}}}},bn={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":`${ze.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:ze},"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:me.title,tags:me.tags,type:me.type,enabled:me.enabled,sync:me.sync,description:me.description,options:me.options}}}}}}}},hl={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}=X.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return O(this,null,function*(){yield o.revision({filterByTk:i,values:a}),x.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(){X.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:i}=S.useForm();return{run(){return O(this,null,function*(){yield t.test({filterByTk:n,values:i.params}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},yl=({children:e})=>r.jsx(x.Tabs,{type:"card",onChange:t=>{eo.value=t},items:[{value:"",label:F("All")}].concat(yn).map(({label:t,value:o},n)=>({label:t,key:o,children:r.jsx(s.CardItem,{children:e})}))}),vn={type:"void",properties:{provider:{type:"void","x-decorator":S.observer(e=>{const t={collection:ze,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return eo.value&&(t.params.filter.tags={$anyOf:[eo.value]}),r.jsx(s.TableBlockProvider,v(v({},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"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","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}=X.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=S.useForm();return{run(){return O(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:I(v({},l),{workflow:d})}),x.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:xn}},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:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,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":{sorter:!0,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 b.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Rt}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,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":{sorter:!0,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:bn,revision:hl,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}=X.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return O(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});fl.saveAs(a,i.data.title+"-"+i.data.key+".json"),x.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},xl=()=>{const{t:e}=X.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:Be(t),onClick:()=>o(!1),children:e("Configure")})};function bl(e){const t=S.useField(),o=s.usePlugin(Z);return S.useFormEffects(()=>{S.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Oe,v({},e))}function wn(e){const{schema:t=vn,components:o,scopes:n}=e,i=b.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[ze,Xt],children:r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:xl,ExecutionResourceProvider:ml,ExecutionLink:Gt,OpenDrawer:Io,ExecutionStatusSelect:To,SyncOptionSelect:bl,ExecutionStatusColumn:Kt,ColumnShowTitle:ul,ColumnShowCollection:pl},o),scope:v({getTriggersOptions:a,ExecutionRetryAction:Ht},n)})})})}class Z extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=K(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof Q)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return O(this,null,function*(){yield this.pm.add(oa),yield this.pm.add(Qi),yield this.pm.add(Ji),yield this.pm.add(Ls),yield this.pm.add(Xr),yield this.pm.add(Ir),yield this.pm.add(yr),yield this.pm.add(mr),yield this.pm.add(ea),yield this.pm.add(_r),yield this.pm.add(ca),yield this.pm.add(Xi),yield this.pm.add(Gi),yield this.pm.add(sa),yield this.pm.add(Bi),yield this.pm.add(Yr),yield this.pm.add(Hr)})}load(){return O(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:wn,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:yo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(qa),this.registerTrigger("collection",Ka),this.registerTrigger("schedule",ll),this.registerInstruction("calculation",da),this.registerInstruction("condition",Pa),this.registerInstruction("end",Wa),this.registerInstruction("query",ja),this.registerInstruction("create",Ba),this.registerInstruction("update",La),this.registerInstruction("destroy",Va)})}addComponents(){this.app.addComponents({WorkflowLink:zn,WorkflowPage:hn,ExecutionPage:yo})}}k.AddButton=Bt,k.AdditionNotifiedPerson=zr,k.AutoResizeInput=No,k.BaseTypeSets=Ne,k.Branch=$e,k.BuiltinGroupType=Ue,k.CheckboxGroupWithTooltip=Ao,k.CollectionBlockInitializer=Te,k.ConfigButtonMessage=qr,k.DetailsBlockProvider=Vt,k.EXECUTION_STATUS=de,k.ExecutionContextProvider=Ko,k.ExecutionLink=Gt,k.ExecutionRetryAction=Ht,k.ExecutionStatusColumn=Kt,k.ExecutionStatusOptions=pt,k.ExecutionStatusOptionsMap=ut,k.ExecutionStatusSelect=To,k.FieldsSelect=et,k.FilterDynamicComponent=De,k.FlowContext=qe,k.Instruction=Q,k.JOB_STATUS=ye,k.JobStatusOptions=mt,k.JobStatusOptionsMap=Re,k.Node=ao,k.NodeDefaultView=nt,k.OpenDrawer=Io,k.ProviderContextNode=io,k.RadioWithTooltip=Oe,k.SelectNotifiedPerson=Br,k.SimpleDesigner=Ut,k.Trigger=Qe,k.ValueBlock=Se,k.WorkflowPane=wn,k.WorkflowVariableCodeMirror=Pr,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=So,k.WorkflowVariableRawTextArea=ko,k.WorkflowVariableTextArea=ot,k.collectionWorkflows=ze,k.createWorkflow=xn,k.currentFormOptions=bo,k.default=Z,k.defaultFieldNames=pe,k.executionCollection=Xt,k.executionSchema=Rt,k.getCollectionFieldOptions=ue,k.getExecutionSchema=fn,k.getWorkflowDetailPath=Be,k.getWorkflowExecutionsPath=yt,k.isValidFilter=ht,k.linkNodes=ft,k.nodesOptions=xt,k.scopeOptions=Wt,k.systemOptions=vo,k.traverseSchema=gt,k.triggerOptions=bt,k.updateWorkflow=bn,k.useAvailableUpstreams=Ee,k.useContextNode=he,k.useFlowContext=q,k.useGetAriaLabelOfAddButton=dt,k.useRecordTriggerWorkflowsActionProps=Us,k.useStyles=ge,k.useTrigger=Ze,k.useTriggerWorkflowsActionProps=qs,k.useWorkflowAnyExecuted=Do,k.useWorkflowExecuted=_t,k.useWorkflowVariableFormOptions=Co,k.useWorkflowVariableOptions=le,k.workflowFieldset=me,k.workflowSchema=vn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
876
|
+
`},properties:xl[o]}}},components:{OnField:on,RepeatField:yl,EndsByField:sl}})]})};class vl extends Qe{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:wl}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===We.DATE_FIELD){const[c]=ue(A(w({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:De,collection:t.collection,dataPath:"$context.data"}:null}}const eo={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:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=ur(e,t);return r.jsx(s.Input,{type:"text",value:o})},"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(ne.Link,{to:Be(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:mt}}]},xn=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:eo,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}=ve(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return D(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),x.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"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},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}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","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}}}}}}}}}},to=xn();function Cl(n){var i=n,{params:e,filter:t={}}=i,o=_(i,["params","filter"]);const{workflow:a}=q(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))}function kl(){var se;const e=ne.useNavigate(),{t}=X.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=b.useState(!1),[u,f]=b.useState(!1),[g,y]=b.useState(null),{styles:h}=ye(),{modal:v}=x.App.useApp();if(b.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const V=(se=n==null?void 0:n.data)!=null?se:{},{nodes:I=[],revisions:T=[]}=V,C=_(V,["nodes","revisions"]);ht(I);const O=I.find(M=>!M.upstream);function B({key:M}){M!==C.id&&e(Be(M))}function E(M){return D(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return D(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(xt(M.executionId))})}function $(){return D(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key}});x.message.success(t("Operation succeeded")),e(Be(M.id))})}function K(){return D(this,null,function*(){const M=C.current?F("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return D(this,null,function*(){var ee;yield l.destroy({filterByTk:C.id}),x.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Be((ee=T.find(G=>G.current))==null?void 0:ee.id))})}})})}const z=()=>D(this,null,function*(){g?(yield l.moveWorkflow({id:C.id,targetKey:g}),x.message.success(F("Move success")),f(!1),C.key=g,i()):x.message.error(F("Select target workflow"))});function J(L){return D(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return $();case"delete":return K();case"move":y(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(qe.Provider,{value:{workflow:C,nodes:I,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(wo,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(ne.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:B,defaultSelectedKeys:[`${C.id}`],className:s.cx(h.dropdownClass,h.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.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:W.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:C.enabled,onChange:E,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(x.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:to,components:{ExecutionResourceProvider:Cl,ExecutionLink:Gt,ExecutionStatusColumn:_t},scope:{ExecutionRetryAction:Ht}})})]})]}),r.jsx(bo,{entry:O}),r.jsxs(x.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:g,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>y(M)})]})]})}const bn=()=>{const e=ne.useParams(),{styles:t}=ye();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:kl}})})},Sl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},Al=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(x.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},Il=n=>{var i=n,{params:e,filter:t={}}=i,o=_(i,["params","filter"]);const a=s.useCollectionRecordData(),l=A(w({},o),{params:A(w({},e),{filter:A(w({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,w({},l))},oo=S.observable({value:""}),wn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],ze={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:wn,"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:N("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":`${ze.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:ze},"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":`${ze.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:ze},"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}=X.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return D(this,null,function*(){yield o.revision({filterByTk:i,values:a}),x.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},Tl={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(){X.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:i}=S.useForm();return{run(){return D(this,null,function*(){yield t.test({filterByTk:n,values:i.params}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},Nl=({children:e})=>r.jsx(x.Tabs,{type:"card",onChange:t=>{oo.value=t},items:[{value:"",label:F("All")}].concat(wn).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":S.observer(e=>{const t={collection:ze,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return oo.value&&(t.params.filter.tags={$anyOf:[oo.value]}),r.jsx(s.TableBlockProvider,w(w({},e),t))}),"x-component":Nl,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"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","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}=X.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=S.useForm();return{run(){return D(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:A(w({},l),{workflow:d})}),x.message.success(e("Operation succeeded")),o(),a(!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:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,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":{sorter:!0,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 b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:to}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,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":{sorter:!0,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:Tl,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}=X.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return D(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});Ro.saveAs(a,i.data.title+"-"+i.data.key+".json"),x.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},Dl=()=>{const{t:e}=X.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(ne.Link,{"aria-label":n(),to:Be(t),onClick:()=>o(!1),children:e("Configure")})};function Ol(e){const t=S.useField(),o=s.usePlugin(Z);return S.useFormEffects(()=>{S.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Fe,w({},e))}function Sn(e){const{schema:t=kn,components:o,scopes:n}=e,i=b.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[ze,eo],children:r.jsx(s.SchemaComponentContext.Provider,{value:A(w({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:w({WorkflowLink:Dl,ExecutionResourceProvider:Il,ExecutionLink:Gt,OpenDrawer:Do,ExecutionStatusSelect:Po,SyncOptionSelect:Ol,ExecutionStatusColumn:_t,ColumnShowTitle:Al,ColumnShowCollection:Sl},o),scope:w({getTriggersOptions:a,ExecutionRetryAction:Ht},n)})})})}class Z extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=_(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof H)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return D(this,null,function*(){yield this.pm.add(pa),yield this.pm.add(sa),yield this.pm.add(na),yield this.pm.add(Qs),yield this.pm.add(as),yield this.pm.add($r),yield this.pm.add(Ir),yield this.pm.add(Cr),yield this.pm.add(ca),yield this.pm.add(es),yield this.pm.add(xa),yield this.pm.add(aa),yield this.pm.add(ta),yield this.pm.add(fa),yield this.pm.add(Ki),yield this.pm.add(rs),yield this.pm.add(os)})}load(){return D(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:bn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:vo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(tl),this.registerTrigger("collection",nl),this.registerTrigger("schedule",vl),this.registerInstruction("calculation",ba),this.registerInstruction("condition",Ua),this.registerInstruction("end",Ya),this.registerInstruction("updateorcreate",el),this.registerInstruction("query",Qa),this.registerInstruction("create",Ha),this.registerInstruction("update",Xa),this.registerInstruction("destroy",Ja)})}addComponents(){this.app.addComponents({WorkflowLink:Un,WorkflowPage:bn,ExecutionPage:vo})}}k.AddButton=Bt,k.AdditionNotifiedPerson=Yr,k.AutoResizeInput=Mo,k.BaseTypeSets=Oe,k.Branch=$e,k.BuiltinGroupType=Ue,k.CheckboxGroupWithTooltip=No,k.CollectionBlockInitializer=De,k.ConfigButtonMessage=Zr,k.DetailsBlockProvider=Vt,k.EXECUTION_STATUS=de,k.ExecutionContextProvider=Jo,k.ExecutionLink=Gt,k.ExecutionRetryAction=Ht,k.ExecutionStatusColumn=_t,k.ExecutionStatusOptions=mt,k.ExecutionStatusOptionsMap=ft,k.ExecutionStatusSelect=Po,k.FieldsSelect=tt,k.FilterDynamicComponent=Ie,k.FlowContext=qe,k.Instruction=H,k.JOB_STATUS=xe,k.JobStatusOptions=gt,k.JobStatusOptionsMap=Re,k.Node=uo,k.NodeDefaultView=st,k.OpenDrawer=Do,k.ProviderContextNode=po,k.RadioWithTooltip=Fe,k.SelectNotifiedPerson=Kr,k.SimpleDesigner=Ut,k.Trigger=Qe,k.ValueBlock=Se,k.WorkflowPane=Sn,k.WorkflowVariableCodeMirror=Lr,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=To,k.WorkflowVariableRawTextArea=Fo,k.WorkflowVariableTextArea=nt,k.collectionWorkflows=ze,k.createWorkflow=vn,k.currentFormOptions=ko,k.default=Z,k.defaultFieldNames=pe,k.executionCollection=eo,k.executionSchema=to,k.getCollectionFieldOptions=ue,k.getExecutionSchema=xn,k.getWorkflowDetailPath=Be,k.getWorkflowExecutionsPath=xt,k.isValidFilter=et,k.linkNodes=ht,k.nodesOptions=bt,k.scopeOptions=Wt,k.systemOptions=So,k.traverseSchema=yt,k.triggerOptions=wt,k.updateWorkflow=Cn,k.useAvailableUpstreams=Ee,k.useContextNode=he,k.useFlowContext=q,k.useGetAriaLabelOfAddButton=ut,k.useRecordTriggerWorkflowsActionProps=Xs,k.useStyles=ye,k.useTrigger=Ze,k.useTriggerWorkflowsActionProps=Zs,k.useWorkflowAnyExecuted=Eo,k.useWorkflowExecuted=Kt,k.useWorkflowVariableFormOptions=Io,k.useWorkflowVariableOptions=le,k.workflowFieldset=fe,k.workflowSchema=kn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|