@tachybase/module-workflow 1.5.1 → 1.6.1
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/WorkflowCategoriesProvider.d.ts +4 -0
- package/dist/client/components/ColletionTreeSelect.d.ts +16 -0
- package/dist/client/components/EnabledStatusFilter.d.ts +2 -0
- package/dist/client/components/WorkflowCategoryColumn.d.ts +8 -0
- package/dist/client/components/index.d.ts +3 -0
- package/dist/client/features/script/Script.instruction.d.ts +136 -0
- package/dist/client/features/script/ScriptCodeEditor.d.ts +9 -0
- package/dist/client/features/script/SyncRemoteCodeButton.d.ts +6 -0
- package/dist/client/features/trigger-instruction/TriggerInstruction.d.ts +164 -5
- package/dist/client/hooks/index.d.ts +2 -0
- package/dist/client/hooks/useDumpAction.d.ts +7 -0
- package/dist/client/hooks/useRevisionAction.d.ts +7 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +85 -59
- package/dist/client/nodes/select.d.ts +235 -0
- package/dist/client/schemas/workflows.d.ts +5 -0
- package/dist/client/utils.d.ts +2 -2
- package/dist/externalVersion.js +9 -9
- package/dist/locale/en-US.json +49 -1
- package/dist/locale/es-ES.json +19 -1
- package/dist/locale/fr-FR.json +18 -0
- package/dist/locale/ja-JP.json +19 -1
- package/dist/locale/ko_KR.json +19 -1
- package/dist/locale/pt-BR.json +19 -1
- package/dist/locale/ru-RU.json +20 -2
- package/dist/locale/tr-TR.json +20 -2
- package/dist/locale/zh-CN.json +52 -1
- package/dist/node_modules/@babel/core/lib/index.js +77 -77
- package/dist/node_modules/@babel/core/node_modules/.bin/parser +4 -4
- package/dist/node_modules/@babel/core/package.json +1 -1
- package/dist/node_modules/@babel/preset-env/lib/index.js +88 -88
- package/dist/node_modules/@babel/preset-env/package.json +1 -1
- package/dist/node_modules/@babel/preset-react/lib/index.js +80 -80
- package/dist/node_modules/@babel/preset-react/package.json +1 -1
- package/dist/node_modules/@babel/preset-typescript/lib/index.js +77 -77
- package/dist/node_modules/@babel/preset-typescript/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 +57 -1
- package/dist/server/actions/executions.d.ts +3 -3
- package/dist/server/actions/executions.js +42 -30
- package/dist/server/actions/index.js +3 -2
- package/dist/server/actions/nodes.d.ts +13 -6
- package/dist/server/actions/nodes.js +160 -34
- package/dist/server/actions/workflows.d.ts +17 -8
- package/dist/server/actions/workflows.helpers.d.ts +55 -0
- package/dist/server/actions/workflows.helpers.js +167 -0
- package/dist/server/actions/workflows.js +118 -69
- package/dist/server/features/interception/RequestInterceptionTrigger.d.ts +1 -1
- package/dist/server/features/interception/RequestInterceptionTrigger.js +12 -12
- package/dist/server/features/manual/actions.d.ts +1 -1
- package/dist/server/features/manual/actions.js +12 -12
- package/dist/server/features/notice/actions.js +19 -19
- package/dist/server/features/notice/plugin.js +0 -3
- package/dist/server/features/omni-trigger/CustomActionTrigger.d.ts +2 -2
- package/dist/server/features/omni-trigger/CustomActionTrigger.js +27 -27
- package/dist/server/features/script/script.instruction.js +146 -4
- package/dist/server/features/trigger-instruction/TriggerInstruction.d.ts +4 -0
- package/dist/server/features/trigger-instruction/TriggerInstruction.js +71 -5
- package/dist/server/instructions/SelectInstruction.d.ts +13 -0
- package/dist/server/instructions/SelectInstruction.js +126 -0
- package/dist/server/services/remote-code-fetcher.d.ts +48 -0
- package/dist/server/services/remote-code-fetcher.js +370 -0
- package/dist/server/utils/get-remote-code-fetcher.d.ts +7 -0
- package/dist/server/utils/get-remote-code-fetcher.js +39 -0
- package/dist/server/utils.d.ts +16 -0
- package/dist/server/utils.js +33 -2
- package/package.json +12 -12
- package/dist/client/provider/EventSourceProvider.d.ts +0 -7
- package/dist/server/features/trigger-instruction/index.d.ts +0 -0
- package/dist/server/features/trigger-instruction/index.js +0 -0
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(k,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("antd"),require("react-router-dom"),require("react-i18next"),require("@tachybase/schema"),require("lodash"),require("dayjs"),require("@dnd-kit/core")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","react","@ant-design/icons","antd","react-router-dom","react-i18next","@tachybase/schema","lodash","dayjs","@dnd-kit/core"],s):(k=typeof globalThis!="undefined"?globalThis:k||self,s(k["@tachybase/module-workflow"]={},k["@tachybase/client"],k["@tego/client"],k.jsxRuntime,k.react,k["@ant-design/icons"],k.antd,k["react-router-dom"],k["react-i18next"],k["@tachybase/schema"],k.lodash,k.dayjs,k["@dnd-kit/core"]))})(this,function(k,s,W,r,x,H,b,se,ee,A,ae,mt,Be){"use strict";var Sc=Object.defineProperty,Ac=Object.defineProperties;var Ic=Object.getOwnPropertyDescriptors;var Wt=Object.getOwnPropertySymbols;var ir=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable;var ar=(k,s,W)=>s in k?Sc(k,s,{enumerable:!0,configurable:!0,writable:!0,value:W}):k[s]=W,v=(k,s)=>{for(var W in s||(s={}))ir.call(s,W)&&ar(k,W,s[W]);if(Wt)for(var W of Wt(s))lr.call(s,W)&&ar(k,W,s[W]);return k},F=(k,s)=>Ac(k,Ic(s));var cr=k=>typeof k=="symbol"?k:k+"",Q=(k,s)=>{var W={};for(var r in k)ir.call(k,r)&&s.indexOf(r)<0&&(W[r]=k[r]);if(k!=null&&Wt)for(var r of Wt(k))s.indexOf(r)<0&&lr.call(k,r)&&(W[r]=k[r]);return W};var P=(k,s,W)=>new Promise((r,x)=>{var H=ee=>{try{se(W.next(ee))}catch(A){x(A)}},b=ee=>{try{se(W.throw(ee))}catch(A){x(A)}},se=ee=>ee.done?r(ee.value):Promise.resolve(ee.value).then(H,b);se((W=W.apply(k,s)).next())});function dr({collection:e}){return e}function ur(e){return!0}function jt(e){return e.target&&e.interface}function pr(e){const t=fo.call(this,e.field.target,e);return t.length&&t.some(o=>jt(o.field))||(e.isLeaf=!0),t}function fo(e,t,o={needLeaf:!0}){const{needLeaf:n}=o,[a,i]=s.parseCollectionName(e),l=this.getCollectionFields(i,a),c=n?l:l.filter(jt),d=pr.bind(this);return c.filter(this.filter).map(u=>{var h,g,w;const p=t?`${t.value?`${t.value}.`:""}${u.name}`:u.name,f=(g=this.compile((h=u.uiSchema)==null?void 0:h.title))!=null?g:u.name,y=!this.getCollectionFields(u.target).filter(jt).filter(this.filter).length;return{pId:(w=t==null?void 0:t.key)!=null?w:null,id:p,key:p,value:p,title:f,isLeaf:y,loadChildren:y?null:d,field:u,fullTitle:t?[...t.fullTitle,f]:[f]}})}const mr=e=>{const G=e,{title:t,value:o,onChange:n,collection:a,useCollection:i=dr,filter:l=ur,rootOption:c,loadData:d,needLeaf:u=!1}=G,p=Q(G,["title","value","onChange","collection","useCollection","filter","rootOption","loadData","needLeaf"]),f=s.useCompile(),{t:y}=s.useTranslation(),[h,g]=x.useState({}),w=i({collection:a}),[C,D]=s.parseCollectionName(w),{getCollectionFields:S}=s.useCollectionManager_deprecated(C),I=Object.values(h),M=x.useMemo(()=>e.multiple?(o||[]).map(j=>h[j]).filter(Boolean):o,[o,e.multiple,h]),E=x.useCallback(j=>P(null,null,function*(){if(d!=null)return d(j);if(!j.isLeaf&&j.loadChildren){const X=j.loadChildren(j);g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))}}),[d]);x.useEffect(()=>{const j=c?F(v({},c),{id:c.value,key:c.value,title:c.label,fullTitle:c.label,isLeaf:!1}):null,B=(d===null?[]:fo.call({compile:f,getCollectionFields:S,filter:l},w,j,{needLeaf:u})).reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},{});j&&(B[j.value]=j),g(B)},[w,c,l,d]),x.useEffect(()=>{const j=e.multiple?o:typeof o=="string"?[o]:o||[];if(!(j!=null&&j.length)||j.every(B=>!!h[B]))return;const X=[];j.forEach(B=>{const L=B.split(".");let $=h[L[0]];for(let U=1;U<L.length&&$;U++){const J=L.slice(0,U+1).join(".");if(h[J]){$=h[J];break}if(!$.isLeaf&&$.loadChildren){const _=$.loadChildren($);_!=null&&_.length&&(X.push(..._),$=_.find(R=>R.value===L.slice(0,U+1).join(".")))}}}),g(B=>X.reduce((L,$)=>{var U;return Object.assign(L,{[$.value]:F(v({},$),{label:$.fullTitle.length?(U=$.fullTitle)==null?void 0:U.join(" / "):$.title})})},v({},B)))},[o,I.length,e.multiple]);const N=x.useCallback(j=>{if(!e.multiple){n(j);return}const X=j.map($=>$.value).filter(Boolean),B=new Set(X),L=M.find($=>!B.has($.value));if(L){const $=`${L.value}.`;Object.keys(h).forEach(U=>{U.startsWith($)&&B.delete(U)})}else X.forEach($=>{const U=$.split(".");if(U.length)for(let J=1;J<=U.length;J++)B.add(U.slice(0,J).join("."))});n(Array.from(B))},[e.multiple,M,n,h]),V=x.useCallback(j=>{var J;const{value:X,onClose:B,disabled:L,closable:$}=j;if(!X)return null;const{fullTitle:U}=(J=h[X])!=null?J:{};return r.jsx(b.Tag,{closable:$&&!L,onClose:B,children:U==null?void 0:U.join(" / ")})},[h]),K=Array.isArray(M)?M.filter(j=>j.value in h):M,q=e.multiple?o:o!=null?[o]:[];return r.jsx(b.TreeSelect,v({"data-testid":`select-field${t?`-${t}`:""}`,value:K,placeholder:y("Select field"),showCheckedStrategy:b.TreeSelect.SHOW_ALL,treeDefaultExpandedKeys:q,allowClear:{clearIcon:r.jsx(H.CloseCircleFilled,{role:"button","aria-label":"icon-close"})},treeCheckStrictly:e.multiple,treeCheckable:e.multiple,tagRender:V,treeNodeLabelProp:"label",onChange:N,treeDataSimpleMode:!0,treeData:I,loadData:E},p))},m="workflow";function O(e,t={}){return s.i18n.t(e,F(v({},t),{ns:[m,"core"]}))}function ve(){return ee.useTranslation([m,"core"])}const T=(e,t={})=>s.tval(e,v({ns:[m,"core"]},t)),fr=()=>{const{t:e}=ve(),t=se.useNavigate(),{token:o}=s.useToken();return r.jsx(b.Tooltip,{title:e("Workflow"),children:r.jsx(b.Button,{icon:r.jsx(s.Icon,{type:"workflow",style:{color:o.colorTextHeaderMenu}}),title:e("Workflow"),onClick:()=>{t("/_admin/business-components/workflow")}})})},ft=(e,t)=>({getAriaLabel:x.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])}),go=x.createContext({}),gr=go.Provider;function hr(){return x.useContext(go)}const Ve=x.createContext({}),yr=Ve.Provider;function Y(){return x.useContext(Ve)}var _e=(e=>(e.CONTROL="control",e.COLLECTION="collection",e.EXTENDED="extended",e.MANUAL="manual",e.ADVANCED="advanced",e))(_e||{});class oe{}function xr(e){var g;const{upstream:t,branchIndex:o=null}=e,n=s.usePlugin(re),a=s.useCompile(),i=s.useAPIClient(),{workflow:l,refresh:c}=(g=Y())!=null?g:{},d=Array.from(n.instructions.getValues()),u=x.useMemo(()=>wr(d,{engine:n,workflow:l,upstream:t,branchIndex:o,compile:a}),[o,n,d,t,l]),[p,f]=x.useState(!1),y=x.useCallback(C=>P(null,[C],function*({keyPath:w}){var E,N,V;const D=w.pop(),S={},[I]=w,M=n.instructions.get(D);if(I){const{value:K}=(N=(E=M.options)==null?void 0:E.find(q=>q.key===I))!=null?N:{};Object.assign(S,typeof K=="function"?K():K)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:D,upstreamId:(V=t==null?void 0:t.id)!=null?V:null,branchIndex:o,title:a(M.title),config:S}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,l]),h=x.useMemo(()=>({onClick:w=>{const{keyPath:C}=w||{};(C==null?void 0:C[0])==="load"?f(!0):y(w)},items:u}),[u,y]);return{workflow:l,menu:h,isShowUploadModal:p,setIsShowUploadModal:f}}const ho=[{key:_e.CONTROL,label:O("Control")},{key:_e.COLLECTION,label:O("Collection operations")},{key:_e.MANUAL,label:O("Manual")},{key:_e.EXTENDED,label:O("Extended types")}],br={key:"hot",label:O("Hot tools")},vr={key:"load",label:O("Load")};function wr(e,{engine:t,workflow:o,upstream:n,branchIndex:a,compile:i}){const l=[],c=[];for(const d of ho){const u=e.filter(y=>{var h,g;return y.group===d.key&&((g=(h=y.isAvailable)==null?void 0:h.call(y,{engine:t,workflow:o,upstream:n,branchIndex:a}))!=null?g:!0)});let p=[];for(const y of u){const{type:h,title:g,icon:w,color:C,options:D,isHot:S}=y,I=yo(w,C),M={role:"button","aria-label":h,key:h,label:i(g),type:D?"subMenu":null,icon:I,children:D?D.map(E=>({role:"button","aria-label":E.key,key:E.key,label:i(E.label)})):null};p.push(M),S&&c.push(M)}const f=F(v({},d),{type:"group",children:p});l.push(f)}return l.unshift(F(v({},vr),{type:"group",children:[{key:"load","aria-label":"load",role:"button",label:O("Upload node"),icon:yo("ToTopOutlined","#ff92ca")}]})),l.unshift(F(v({},br),{type:"group",children:c})),l.filter(d=>d.children.length)}function yo(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 Cr=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``}));function
|
|
35
|
+
`,iconContainerClass:e``}));function kr(){const e=s.useActionContext(),t=A.useForm();return{onClick(){return P(this,null,function*(){var n;(n=e==null?void 0:e.setVisible)==null||n.call(e,!1),t.reset()})}}}function Sr(){var d;const{t:e}=ve(),t=s.useAPIClient(),o=s.useActionContext(),{workflow:n,refresh:a}=(d=Y())!=null?d:{},i=A.useForm(),{upstream:l,branchIndex:c}=hr();return{onClick(){return P(this,null,function*(){var p;try{const y=yield(yield fetch(i.values.file.url)).json();n&&(yield t.resource("workflows.nodes",n.id).create({values:{type:y.type,upstreamId:(p=l==null?void 0:l.id)!=null?p:null,branchIndex:c,title:y.title,config:y.config}}),o.setVisible(!1),b.message.success(e("Operation succeeded")),a(),i.reset())}catch(f){o.setVisible(!1),console.error("JSON解析失败:",f),a()}})}}}const Ar={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"}}}}},Ir=()=>r.jsx(s.SchemaComponent,{schema:Ar,scope:{useCancelActionProps:kr,useCreateActionProps:Sr}}),Lt=e=>{const{t}=ve(),{styles:o}=Cr(),{upstream:n,branchIndex:a=null}=e,{workflow:i,menu:l,isShowUploadModal:c,setIsShowUploadModal:d}=xr(e);return i?r.jsxs("div",{className:o.addButtonClass,children:[r.jsx(b.Dropdown,{trigger:["click"],disabled:i.executed,overlayClassName:o.dropDownClass,menu:l,children:r.jsx(b.Button,{className:"add-btn",icon:r.jsx(H.PlusOutlined,{}),type:"primary","aria-label":e["aria-label"]||"add-button"})}),r.jsx(b.Modal,{footer:null,closable:!1,title:t("Upload node"),open:c,children:r.jsx(s.ActionContextProvider,{value:{visible:c,setVisible:d},children:r.jsx(gr,{value:{upstream:n,branchIndex:a},children:r.jsx(Ir,{})})})})]}):null};function We(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 xo=x.createContext({}),bo=xo.Provider;function he(){return x.useContext(xo)}const Fr=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
|
+
`})),vo=({data:e})=>{const{styles:t}=Fr(),{getAriaLabel:o}=ft(e),n=s.usePlugin(re),{Component:a=it,end:i,group:l}=n.instructions.get(e.type);return r.jsx(bo,{value:F(v({},e),{group:l}),children:r.jsxs("div",{className:s.cx(t.nodeBlockClass),children:[r.jsx(a,{data:e}),!i||typeof i=="function"&&!i(e)?r.jsx(Lt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(H.CloseOutlined,{})})]})})},we=s.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
43
43
|
flex-grow: 1;
|
|
44
44
|
overflow: hidden;
|
|
45
45
|
display: flex;
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
.workflow-node-config-button {
|
|
331
331
|
display: none;
|
|
332
332
|
}
|
|
333
|
-
`}));function
|
|
333
|
+
`}));function je({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:a,end:i}){const{styles:l}=we(),{getAriaLabel:c}=ft(e,o),d=[];for(let u=t;u;u=u.downstream)d.push(u);return r.jsxs("div",{className:s.cx("workflow-branch",l.branchClass,a),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Lt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(u=>r.jsx(vo,{data:u},u.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(H.CloseOutlined,{})}):null]})}const Tr=s.createStyles(({css:e,token:t})=>({container:e`
|
|
334
334
|
margin-bottom: 1.5em;
|
|
335
335
|
padding: 1em;
|
|
336
336
|
background-color: ${t.colorFillAlter};
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
p {
|
|
356
356
|
color: ${t.colorTextDescription};
|
|
357
357
|
}
|
|
358
|
-
`}));function
|
|
358
|
+
`}));function wo(e){const{label:t,title:o,description:n,workflowKey:a,createdAt:i,createdBy:l}=e,{styles:c}=Tr(),{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(b.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]}),a||i||l?r.jsxs("div",{className:s.cx(c.container,e.className),children:[a?r.jsx("p",{children:`${d("Key")}: ${a}`}):null,i?r.jsx("p",{children:`${d("Created at")}: ${W.convertUTCToLocal(i)}`}):null,l?r.jsx("p",{children:`${d("Created by")}: ${l}`}):null]}):null]})}const Co="json-parse",ko="js-parse",So="data-mapping",Ge="deprecated",Nr=e=>{var d;const{className:t}=e,{t:o}=ve(),{styles:n}=Dr(),a=s.useCompile(),{instructions:i}=s.usePlugin(re),{nodes:l}=(d=Y())!=null?d:{},c=x.useMemo(()=>l==null?void 0:l.reduce((u,p)=>{const f=i.get(p.type),{group:y,title:h}=f,g=ho.find(D=>D.key===y),w={key:y,title:h,groupLabel:g!=null&&g.label?g==null?void 0:g.label:o("Unkown group"),count:1,isDeprecated:y===Ge},C=u.findIndex(D=>D.key===y);return C>0?u[C].count++:u.push(w),u},[]),[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:u,title:p,groupLabel:f,count:y,isDeprecated:h},g)=>r.jsx("p",{className:h?n.deprecated:"",children:`${g+1}: ${f}:${a(p)}-${y} ${h?o("Deprecated, please do not use it"):""}`},u))]})},Dr=s.createStyles(({css:e,token:t})=>({container:e`
|
|
359
359
|
margin-bottom: 1.5em;
|
|
360
360
|
padding: 1em;
|
|
361
361
|
background-color: ${t.colorFillAlter};
|
|
@@ -382,23 +382,23 @@
|
|
|
382
382
|
}
|
|
383
383
|
`,deprecated:e`
|
|
384
384
|
background-color: yellow;
|
|
385
|
-
`}));function
|
|
385
|
+
`}));function Or(){var i;const e=A.useForm(),t=s.useAPIClient(),{workflow:o}=(i=Y())!=null?i:{},n=s.useActionContext(),{refresh:a}=s.useResourceActionContext();return{run(){return P(this,null,function*(){if(o.executed){b.message.error(O("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),b.message.success("success"),a()})}}}class Re{}const Pr=()=>{const e=s.useCompile(),{workflow:t,execution:o}=Y(),{styles:n}=we(),a=et();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`
|
|
386
386
|
position: absolute;
|
|
387
387
|
top: 50%;
|
|
388
388
|
right: -50px;
|
|
389
389
|
transform: translateY(-50%);
|
|
390
|
-
`),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:
|
|
390
|
+
`),type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:F(v({},o),{context:JSON.stringify(o.context||{},null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(a.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"string",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:i}=s.useTranslation();return{run(){return P(this,null,function*(){try{const c=JSON.stringify(o.context,null,2);yield navigator.clipboard.writeText(c),b.message.success(i("Copied"))}catch(c){b.message.error(i("Copy failed"))}})}}}}}}}}}}}}):null};function Er(){return{form:A.useForm()}}const Mr=()=>{var E;const e=s.useAPIClient(),{workflow:t,refresh:o}=Y(),[n,a]=x.useState(""),[i,l]=x.useState(!1),[c,d]=x.useState(!1),{styles:u}=we(),p=s.useCompile(),f=et(),y=p(f.title),{fieldset:h,scope:g,components:w}=f,C=t.executed?'{{t("View")}}':'{{t("Configure")}}',D=O("Trigger");x.useEffect(()=>{var N,V;t&&a((V=(N=t.triggerTitle)!=null?N:t.title)!=null?V:y)},[t]);const S=x.useMemo(()=>{const N=ae.cloneDeep(t.config);return A.createForm({initialValues:N,disabled:t.executed})},[t]),I=x.useCallback(N=>{l(N),N||S.reset()},[S]);x.useCallback(function(N){return P(this,null,function*(){const V=N||y;a(V),V!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:V}}),o())})},[t]);const M=x.useCallback(function(N){var K;if(N.target===N.currentTarget){l(!0);return}const V=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let q=N.target;q&&q!==N.currentTarget;q=q.parentNode)if(Array.from((K=q.classList)!=null?K:[]).some(G=>V.has(G))){l(!0),N.stopPropagation();return}},[]);return r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{role:"button","aria-label":`${D}-${n}`,className:s.cx(u.terminalClass),onClick:M,children:[O("Start"),r.jsx(s.ActionContextProvider,{value:{visible:i,setVisible:I,formValueChanged:c,setFormValueChanged:d},children:r.jsx(s.FormProvider,{form:S,children:r.jsx(s.SchemaComponent,{scope:F(v({},g),{useFormProviderProps:Er}),components:w,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":C,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:D,"x-component":"Action.Area","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:F(v({},f.description?{description:{type:"void","x-component":wo,"x-component-props":{label:O("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`
|
|
391
391
|
.ant-select.auto-width {
|
|
392
392
|
width: auto;
|
|
393
393
|
min-width: 6em;
|
|
394
394
|
}
|
|
395
|
-
`},properties:h},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:
|
|
395
|
+
`},properties:h},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:Or}}}},showNodes:{type:"void","x-component":Nr}})}}}})})})]}),r.jsx(Pr,{})]})};function et(){const e=s.usePlugin(re),{workflow:t}=Y();return e.triggers.get(t.type)}const Ao="workflow-zoom";function $r({entry:e}){const{styles:t}=we(),{workflow:o}=Y(),[n,a]=x.useState(100),i=ae.debounce(l=>{localStorage.setItem(Ao,l)});return x.useEffect(()=>{const l=localStorage.getItem(Ao);l&&Number(l)>0&&a(Number(l))},[]),r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
|
|
396
396
|
margin-top: 0 !important;
|
|
397
|
-
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:
|
|
397
|
+
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:O("Executed workflow cannot be modified"),showIcon:!0,className:s.css`
|
|
398
398
|
margin-bottom: 1em;
|
|
399
|
-
`}):null,r.jsx(
|
|
399
|
+
`}):null,r.jsx(Mr,{}),r.jsx("div",{className:s.cx(t.branchBlockClass,s.css`
|
|
400
400
|
margin-top: 0 !important;
|
|
401
|
-
`),children:r.jsx(
|
|
401
|
+
`),children:r.jsx(je,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:O("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:l=>{a(l),i(l)}})})]})}const Io="workflow-splitter",Fo=({entry:e})=>{const t=Y(),[o,n]=x.useState(600),a=ae.debounce(i=>{localStorage.setItem(Io,i)});return x.useEffect(()=>{const i=localStorage.getItem(Io);i&&Number(i)>0&&n(Number(i))},[t.workflow.key]),r.jsx(s.ActionAreaProvider,{children:r.jsxs(b.Splitter,{onResize:i=>{n(i[1]),a(String(i[1]))},children:[r.jsx(b.Splitter.Panel,{collapsible:!0,children:r.jsx($r,{entry:e})}),r.jsx(b.Splitter.Panel,{size:o,min:"240",collapsible:!0,className:"workflow-operator-area",children:r.jsx(s.ActionAreaStub,{})})]})})};function Br(e){if(e>=86313600)return"999 D";const n=Math.floor(e/(24*60*60)),a=Math.floor(e%(24*60*60)/3600),i=Math.floor(e%3600/60),l=e%60;let c="";return n>0&&(c+=`${n} D `),(a>0||n>0)&&(c+=`${a} h `),(i>0||a>0||n>0)&&(c+=`${i} m `),e>=60?c+=`${Math.floor(l)} s`:c+=`${l.toFixed(3)} s`,c.trim()}function Vr(e){if(!e)return;const i=e/1e3,l=999*86400;if(i>=l)return"999 D";if(e<6e5){const y=Math.floor(i/60),h=Math.floor(i%60),g=e%1e3;let w=`${g} ms`;return y>0?w=`${y} m ${h} s ${g} ms`:h>0&&(w=`${h} s ${g} ms`),w}const c=Math.floor(i/86400),d=Math.floor(i%86400/3600),u=Math.floor(i%3600/60),p=i%60;let f="";return c>0&&(f+=`${c} D `),(d>0||c>0)&&(f+=`${d} h `),(u>0||d>0||c>0)&&(f+=`${u} m `),i>=60?f+=`${Math.floor(p)} s`:f+=`${p} s`,f.trim()}function Wr(e,t){const o=()=>{const i=Date.now(),l=new Date(t.createdAt).getTime();return i-l},[n,a]=x.useState(e||o());return x.useEffect(()=>{let i;return t.status===0?i=setInterval(()=>{a(o())},1e3):a(e),()=>{i&&clearInterval(i)}},[e,t.status]),Vr(n)}const To=e=>{const t=se.useNavigate();return r.jsx(b.Button,v({type:"text",icon:r.jsx(s.Icon,{type:"ArrowLeftOutlined"}),onClick:()=>{t(-1)}},e))},jr=s.createStyles(({css:e})=>({statusButtonClass:e`
|
|
402
402
|
border: none;
|
|
403
403
|
.ant-tag {
|
|
404
404
|
display: inline-grid;
|
|
@@ -412,43 +412,43 @@
|
|
|
412
412
|
}
|
|
413
413
|
`,noStatusButtonClass:e`
|
|
414
414
|
border-width: 2px;
|
|
415
|
-
`}));function Xe(e){var n;const{styles:t}=Sr();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(b.Tag,{color:a,children:i})}return r.jsx(b.Button,I(v({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:pe.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:pe.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:pe.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:pe.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:pe.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:pe.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(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 ve=(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))(ve||{});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 We(e){return`/_admin/business-components/workflow/${e}/workflow`}function tt(e){return`/_admin/business-components/workflow/${e}/executions`}function Ar(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(X),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=wr(o.cost/1e3);const{styles:i}=be(),{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(b.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}=Q.useTranslation();return{run(){return D(this,null,function*(){try{const d=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(d),b.message.success(c("Copied"))}catch(d){b.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function Fr(e){const{execution:t}=q(),o=s.useAPIClient(),n=re.useNavigate(),{styles:i}=be(),[a,l]=y.useState([]),[c,p]=y.useState([]);y.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]),y.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})=>{p(u.data.reverse())}).catch(()=>{})},[t]);const d=y.useCallback(({key:u})=>{u!==t.id&&n(tt(u))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:d,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:M.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(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function Tr(){var w;const{t:e}=Q.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=y.useState(null),p=s.useApp(),d=s.useAPIClient();y.useEffect(()=>{var B;const{workflow:P}=(B=o==null?void 0:o.data)!=null?B:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${T("Execution history")}`)},[o==null?void 0:o.data]);const u=y.useCallback(()=>{b.Modal.confirm({title:T("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:T("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.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(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const O=(w=o==null?void 0:o.data)!=null?w:{},{jobs:f=[],workflow:V={}}=O,$=V,{nodes:g=[],revisions:h=[]}=$,x=K($,["nodes","revisions"]),C=K(O,["jobs","workflow"]);ht(g),Ar(g,f);const k=g.find(P=>!P.upstream),F=ft[C.status];return r.jsxs($e.Provider,{value:{workflow:x.type?x:null,nodes:g,execution:C,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(Co,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:p.systemSettingsManager.getRoutePath(`business-components.${m}`),children:T("Workflow")})},{title:r.jsx(re.Link,{to:We(x.id),children:x.title})},{title:r.jsx(Fr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:F.color,children:t(F.label)}),C.status?null:r.jsx(b.Tooltip,{title:T("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:M.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(wo,{entry:k}),r.jsx(Ir,{})]})}const ko=()=>{const e=re.useParams(),{styles:t}=be();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:Tr}})})};function Nr(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:[Nr],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 Or(n){var i=n,{value:e,onChange:t}=i,o=K(i,["value","onChange"]);const{setValuesIn:a}=A.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=Dr(),[p,d]=y.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let g=[];const h=u.match(/^{{(.*)}}$/);h&&(g=[...h[1].trim().split(".").slice(0,-1),f]);const x=k=>D(null,null,function*(){var w;const F=k[k.length-1];!((w=F.children)!=null&&w.length)&&!F.isLeaf&&F.loadChildren&&(yield F.loadChildren(F),d(O=>[...O]))});y.useEffect(()=>{D(null,null,function*(){var w;if(!g||p.length<=1)return;let F=null;for(let O=0;O<g.length;O++){const V=g[O];try{O===0?F=p.find($=>$.value===V):(F.loadChildren&&!((w=F.children)!=null&&w.length)&&(yield F.loadChildren(F)),F=F.children.find($=>$.value===V))}catch($){console.error($)}}d([...p])})},[e,p.length]);const C=y.useCallback((k,F)=>{if(!(k!=null&&k.length)){a("collection",null),t({});return}const{field:w}=F.pop();if(!w||!["hasMany","belongsToMany"].includes(w.type))return;const{collectionName:O,target:V,name:$,dataSourceKey:P}=w,_=l(O,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${V}`),t({name:$,associatedKey:`{{${k.slice(0,-1).join(".")}.${_.name}}}`,associatedCollection:s.joinCollectionName(P,O)})},[t]);return r.jsx(b.Cascader,I(v({},o),{value:g,options:p,changeOnSelect:!0,onChange:C,loadData:x}))}class Pr 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}=A.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
|
|
415
|
+
`}));function tt(e){var n;const{styles:t}=jr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:a,color:i}=e.statusMap[e.status];o=r.jsx(b.Tag,{color:i,children:a})}return r.jsx(b.Button,F(v({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ye={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},gt=[{value:ye.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(H.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:ye.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(H.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:ye.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(H.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:ye.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:ye.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:ye.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(H.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:ye.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:ye.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(H.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ht=gt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var Ce=(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))(Ce||{});const yt=[{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"})}],ot=yt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function xt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function nt(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return nt(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[a]=Object.keys(o[n]);return!(!a||typeof o[n][a]=="undefined")}):!1}function bt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{bt(e.properties[o],t)})}function Le(e,t){return`/_admin/business-components/${t||"workflow"}/${e}/workflow`}function He(e,t){return`/_admin/business-components/${t||"workflow"}/${e}/executions`}function Lr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const a=o.get(n.nodeId);a.jobs.push(n),n.node={id:a.id,key:a.key,title:a.title,type:a.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((a,i)=>a.id-i.id)})}function zr(){const{instructions:e}=s.usePlugin(re),t=s.useCompile(),{viewJob:o,setViewJob:n}=Y();if(!o)return;o.cost=Br(o.cost/1e3);const{styles:a}=we(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:F(v({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:a.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:yt,"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}=ee.useTranslation();return{run(){return P(this,null,function*(){try{const u=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(u),b.message.success(c("Copied"))}catch(u){b.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function qr(e){var y;const{execution:t}=Y(),o=s.useAPIClient(),n=se.useNavigate(),{styles:a}=we(),[i,l]=x.useState([]),[c,d]=x.useState([]),p=(y=window.location.pathname.split("business-components/")[1])==null?void 0:y.split("/")[0];x.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:h})=>{l(h.data)}).catch(()=>{})},[t]),x.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:h})=>{d(h.data.reverse())}).catch(()=>{})},[t]);const f=x.useCallback(({key:h})=>{h!==t.id&&n(He(h,p))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:f,defaultSelectedKeys:[`${t.id}`],className:s.cx(a.dropdownClass,a.executionsDropdownRowClass),items:[...c,t,...i].map(h=>({key:h.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${h.id}`}),r.jsx("time",{children:W.str2moment(h.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(tt,{statusMap:ht,status:h.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(H.DownOutlined,{})]})}):null}function Ur(){var E,N;const{t:e}=ee.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:a}=s.useResourceActionContext(),{setTitle:i}=s.useDocumentTitle(),[l,c]=x.useState(null),d=s.useApp(),u=s.useAPIClient(),f=(E=window.location.pathname.split("business-components/")[1])==null?void 0:E.split("/")[0],y=d.systemSettingsManager.get(`business-components.${f}`)||{};x.useEffect(()=>{var j;const{workflow:G}=(j=o==null?void 0:o.data)!=null?j:{};i==null||i(`${G!=null&&G.title?`${G.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const h=x.useCallback(()=>{b.Modal.confirm({title:O("Cancel the execution"),icon:r.jsx(H.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{u.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),a()}).catch(G=>{console.error(G.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const V=(N=o==null?void 0:o.data)!=null?N:{},{jobs:g=[],workflow:K={}}=V,q=K,{nodes:w=[],revisions:C=[]}=q,D=Q(q,["nodes","revisions"]),S=Q(V,["jobs","workflow"]);xt(w),Lr(w,g);const I=w.find(G=>!G.upstream),M=ht[S.status];return r.jsxs(Ve.Provider,{value:{workflow:D.type?D:null,nodes:w,execution:S,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(To,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(se.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${f||"workflow"}`),children:t(y.label)})},{title:r.jsx(se.Link,{to:Le(D.id,f),children:D.title})},{title:r.jsx(qr,{})}]})]}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:M.color,children:t(M.label)}),S.status?null:r.jsx(b.Tooltip,{title:O("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:h,shape:"circle",size:"small",icon:r.jsx(H.StopOutlined,{})})}),r.jsx("time",{children:W.str2moment(S.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Fo,{entry:I}),r.jsx(zr,{})]})}const zt=()=>{const e=se.useParams(),{styles:t}=we();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:Ur}})})};function Kr(e){return["hasMany","belongsToMany"].includes(e.type)}function _r(){const e=s.useCompile();return[vt,wt].map(t=>{var n;const o=(n=t.useOptions({types:[Kr],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 Gr(n){var a=n,{value:e,onChange:t}=a,o=Q(a,["value","onChange"]);const{setValuesIn:i}=A.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=_r(),[d,u]=x.useState(c),{associatedKey:p="",name:f}=e!=null?e:{};let y=[];const h=p.match(/^{{(.*)}}$/);h&&(y=[...h[1].trim().split(".").slice(0,-1),f]);const g=C=>P(null,null,function*(){var S;const D=C[C.length-1];!((S=D.children)!=null&&S.length)&&!D.isLeaf&&D.loadChildren&&(yield D.loadChildren(D),u(I=>[...I]))});x.useEffect(()=>{P(null,null,function*(){var S;if(!y||d.length<=1)return;let D=null;for(let I=0;I<y.length;I++){const M=y[I];try{I===0?D=d.find(E=>E.value===M):(D.loadChildren&&!((S=D.children)!=null&&S.length)&&(yield D.loadChildren(D)),D=D.children.find(E=>E.value===M))}catch(E){console.error(E)}}u([...d])})},[e,d.length]);const w=x.useCallback((C,D)=>{if(!(C!=null&&C.length)){i("collection",null),t({});return}const{field:S}=D.pop();if(!S||!["hasMany","belongsToMany"].includes(S.type))return;const{collectionName:I,target:M,name:E,dataSourceKey:N}=S,K=l(I,N).fields.find(q=>q.primaryKey);i("collection",`${N}:${M}`),t({name:E,associatedKey:`{{${C.slice(0,-1).join(".")}.${K.name}}}`,associatedCollection:s.joinCollectionName(N,I)})},[t]);return r.jsx(b.Cascader,F(v({},o),{value:y,options:d,changeOnSelect:!0,onChange:w,loadData:g}))}class Hr extends oe{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}=A.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
|
|
416
416
|
position: relative;
|
|
417
417
|
width: 100%;
|
|
418
|
-
`}},"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:ot,ValueBlock:Se,AssociatedConfig:Or}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){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=T("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 Er extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Pr)})}}const So=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function Mr(e){return So.slice().reverse().find(t=>!(e%t.value))}function $r({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Mr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:So.map(a=>({value:a.value,label:o(a.label)}))})]})}class Br 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:ve.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:ve.FAILED}],required:!0,default:ve.RESOLVED}},this.components={Duration:$r}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class Vr extends s.Plugin{load(){return D(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Br)})}}function Wr(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 jr({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=ce({types:[Wr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class zr 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:jr,WorkflowVariableInput:ke,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=ue}){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:T("Calculation result")}}}const Lr=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(n.getValuesIn(a)),p=s.useCompile(),{getCollectionFields:d}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),A.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=me({collection:l,compile:p,getCollectionFields:d});return r.jsx(s.Variable.TextArea,I(v({},e),{scope:u}))},{displayName:"InternalExpression"});function qr(e){const{t}=Q.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=y.useMemo(()=>me({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(b.Tag,{children:t("Unconfigured",{ns:m})})}const Ur=A.connect(Lr,A.mapReadPretty(qr)),{defaultProps:Kr}=s.interfacesProperties;class _r extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.icon="FunctionOutlined",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({},Kr)}}class Gr extends s.Plugin{load(){return D(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([_r]),this.app.addComponents({DynamicExpression:Ur});const t=this.app.pm.get("workflow"),o=new zr;t.instructions.register(o.type,o)})}}function Hr(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(),p=s.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[f,g]=s.parseCollectionName(e);d=c(g,f)}else d=e;function u(g){return D(this,arguments,function*({item:f}){const h=f.template?yield l(f):null,x={type:"void",name:A.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};yt(x,C=>{C["x-uid"]&&delete C["x-uid"]}),a(x)})}return r.jsx(s.SchemaInitializerItem,I(v({},o),{onClick:u,items:p}))}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(Hr,v(v({},t),e))})}function Jr(e){const{execution:t,nodes:o}=q(),n=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=y.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,p)=>Object.assign(c,{[n[p.nodeId]]:p.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return y.useMemo(()=>te.get(i,e),[i,e])}function jt({collection:e,dataPath:t,children:o}){const n=A.useField(),i=y.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),p=Jr(t);let d,u;if(typeof e=="string"){const F=s.parseCollectionName(e);d=F[0],u=F[1]}else u=e;const f=y.useMemo(()=>A.createForm({values:p,readPretty:!0}),[p]),g={appends:l},h={loading:!1,data:{data:p}},C=s.useAPIClient().resource(u),k=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:d,collection:u,children:r.jsx(s.RecordProvider,{record:p,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:h,resource:C,__parent:k},children:r.jsx(s.FormBlockContext.Provider,{value:{params:g,form:f,field:n,service:h,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Yr(){return!0}const ot=A.observer(e=>{const d=e,{filter:t=Yr}=d,o=K(d,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=A.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),p=i(c,l);return r.jsx(b.Select,I(v({popupMatchSelectWidth:!1},o),{options:p.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Qr(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}const ue={label:"label",value:"value",children:"children"},Ao={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=xe(),n=s.usePlugin(X).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 t=s.useCompile(),{instructions:o}=s.usePlugin(X),n=xe(),i=Be(n),a=[];return i.forEach(l=>{var u;const c=o.get(l.type),p=`<${t(c.title)}>${l.title}`,d=(u=c.useVariables)==null?void 0:u.call(c,I(v({},l),{title:p}),e);d&&a.push(d)}),a}},bt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(X),{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}},zt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ue,current:o}=e,{instructions:n}=s.usePlugin(X),i=xe(),a=o!=null?o:i,l=Qr(a),c=[];return l.forEach(p=>{var f,g;const d=n.get(p.type),u=(f=d.useScopeVariables)==null?void 0:f.call(d,p,e);u&&c.push({key:p.key,[t.value]:p.key,[t.label]:(g=p.title)!=null?g:`#${p.id}`,[t.children]:u})}),c}},Io={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ue}){return!e||e.includes("date")?[{key:"now",[t.label]:T("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 Fo(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"?Lt(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 Lt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function qt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Ut({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(p=>Fo(l,p)):!0;if(Lt(l)){if(o===null)return n?c||Ut({fields:Kt(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const p=qt(l,o),d=o.includes(l.name);return c?d:((p==null?void 0:p.length)||d)&&Ut({fields:Kt(l.target,{compile:i,getCollectionFields:a}),types:t,appends:p,compile:i,getCollectionFields:a}).length}else return c})}function nt(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 ce(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[nt(zt,o),nt(xt,o),nt(bt,o),nt(Io,o),s.useGlobalVariable("$env")].filter(Boolean)}function To(e={}){var i;const t=Object.assign({},ue,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[nt(Ao,o)]}function Kt(e,{compile:t,getCollectionFields:o}){var p,d,u,f,g,h,x;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(C=>{C.isForeignKey?l.push(C):c.push(C)});for(let C=c.length-1;C>=0;C--){const k=c[C];if(k.type==="belongsTo"){const F=l.find(w=>w.name===k.foreignKey);F?c.splice(C,0,I(v(v({},k),F),{uiSchema:I(v({},k.uiSchema),{title:(p=k.uiSchema)!=null&&p.title?`${t((d=k.uiSchema)==null?void 0:d.title)} ID`:F.name})})):c.splice(C,0,I(v({},k),{name:k.foreignKey,type:"bigInt",isForeignKey:!0,interface:k.interface,uiSchema:I(v({},k.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?`${t((f=k.uiSchema)==null?void 0:f.title)} ID`:k.name})}))}else if(k.type==="context"&&k.collectionName==="users"){const F=(g=c.find(w=>w.type==="belongsTo"&&w.target==="users"&&w.foreignKey===k.name))!=null?g:{};c.splice(C,0,I(v({},k),{type:k.dataType,interface:F.interface,uiSchema:I(v({},F.uiSchema),{title:(h=F.uiSchema)!=null&&h.title?`${t((x=F.uiSchema)==null?void 0:x.title)} ID`:k.name})}))}}return c.filter(C=>C.interface&&!C.hidden)}function Zr(e){const t=qt(e.field,e.appends),o=me(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=>Fo(e.field,i))||(e.disabled=!0))}function me(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:p=ue}=e,d=t!=null?t:Kt(o,{compile:l,getCollectionFields:c}),u=Zr.bind({compile:l,getCollectionFields:c,fieldNames:p});return Ut({fields:d,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(g=>{var k;const h=l(((k=g.uiSchema)==null?void 0:k.title)||g.name),x=qt(g,i),C=!Lt(g)||x&&!x.length&&!i.includes(g.name)||!1;return{[p.label]:h,key:g.name,[p.value]:g.name,isLeaf:C,loadChildren:C?null:u,field:g,depth:a,appends:i,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.Input,v({scope:i},t))}function rt(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.TextArea,v({scope:i},t))}function No(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.RawTextArea,v({scope:i},t))}function Do(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=ce(e);return r.jsx(s.Variable.JSON,v({scope:i},t))}function Xr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=To(e),l=ce(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...a,...l,...i]},t))}function Ie({value:e,onChange:t,renderSchemaComponent:o}){const n=ce();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Fe(e){const p=e,{options:t=[],getOptions:o=()=>[],direction:n}=p,i=K(p,["options","getOptions","direction"]),a=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,I(v({},i),{children:r.jsx(b.Space,{direction:n,children:c.map(d=>r.jsxs(b.Radio,{value:d.value,children:[r.jsx("span",{className:s.css`
|
|
418
|
+
`}},"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:Ae,FieldsSelect:rt,ValueBlock:Ie,AssociatedConfig:Gr}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var n;const o=O("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:o}:null}}class Jr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",Hr)})}}const No=[{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 Yr(e){return No.slice().reverse().find(t=>!(e%t.value))}function Qr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=Yr(e),a=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(b.InputNumber,{min:1,value:a,onChange:i=>t(Math.round(i*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:i=>t(Math.round(a*i)),className:"auto-width",options:No.map(i=>({value:i.value,label:o(i.label)}))})]})}class Zr extends oe{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:Ce.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.RESOLVED}},this.components={Duration:Qr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}class Xr extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",Zr)})}}function Rr(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 es({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),a=me({types:[Rr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:a})}class ts extends oe{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:es,WorkflowVariableInput:ke,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const os=A.observer(e=>{const{onChange:t}=e,o=A.useField(),n=A.useForm(),i=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=x.useState(n.getValuesIn(i)),d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated();A.useFormEffects(()=>{A.onFormInitialValuesChange(f=>{c(f.getValuesIn(i))}),A.onFieldInputValueChange(i,f=>{c(f.value),t(null)})});const p=fe({collection:l,compile:d,getCollectionFields:u});return r.jsx(s.Variable.TextArea,F(v({},e),{scope:p}))},{displayName:"InternalExpression"});function ns(e){const{t}=ee.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=x.useMemo(()=>fe({collection:o.sourceCollection,compile:n,getCollectionFields:a}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,F(v({},e),{scope:i})):r.jsx(b.Tag,{children:t("Unconfigured",{ns:m})})}const rs=A.connect(os,A.mapReadPretty(ns)),{defaultProps:ss}=s.interfacesProperties;class as extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.icon="FunctionOutlined",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({},ss)}}class is extends s.Plugin{load(){return P(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([as]),this.app.addComponents({DynamicExpression:rs});const t=this.app.pm.get("workflow"),o=new ts;t.instructions.register(o.type,o)})}}function ls(n){var a=n,{collection:e,dataPath:t}=a,o=Q(a,["collection","dataPath"]);const{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[f,y]=s.parseCollectionName(e);u=c(y,f)}else u=e;function p(y){return P(this,arguments,function*({item:f}){const h=f.template?yield l(f):null,g={type:"void",name:A.uid(),title:u.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};bt(g,w=>{w["x-uid"]&&delete w["x-uid"]}),i(g)})}return r.jsx(s.SchemaInitializerItem,F(v({},o),{onClick:p,items:d}))}function Te(e){var i;const t=s.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let n,a;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],a=l[1]}else a=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:a,children:r.jsx(ls,v(v({},t),e))})}function cs(e){const{execution:t,nodes:o}=Y(),n=x.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),a=x.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 x.useMemo(()=>ae.get(a,e),[a,e])}function qt({collection:e,dataPath:t,children:o}){const n=A.useField(),a=x.useRef(null),{getAssociationAppends:i}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=i(),d=cs(t);let u,p;if(typeof e=="string"){const D=s.parseCollectionName(e);u=D[0],p=D[1]}else p=e;const f=x.useMemo(()=>A.createForm({values:d,readPretty:!0}),[d]),y={appends:l},h={loading:!1,data:{data:d}},w=s.useAPIClient().resource(p),C=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:u,collection:p,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:h,resource:w,__parent:C},children:r.jsx(s.FormBlockContext.Provider,{value:{params:y,form:f,field:n,service:h,updateAssociationValues:c,formBlockRef:a},children:o})})})})}function ds(){return!0}const rt=A.observer(e=>{const u=e,{filter:t=ds}=u,o=Q(u,["filter"]),n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),{values:i}=A.useForm(),[l,c]=s.parseCollectionName(i==null?void 0:i.collection),d=a(c,l);return r.jsx(b.Select,F(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(p=>{var f;return{label:n((f=p.uiSchema)==null?void 0:f.title),value:p.name}})}))},{displayName:"FieldsSelect"});function us(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 xe={label:"label",value:"value",children:"children"},Do={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var i;const t=he(),n=s.usePlugin(re).instructions.get(t.type);return((i=n.useCurrentFormVariables)==null?void 0:i.call(n,t,e))||[]}},vt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const t=s.useCompile(),{instructions:o}=s.usePlugin(re),n=he(),a=We(n),i=[];return a.forEach(l=>{var p;const c=o.get(l.type),d=`<${t(c.title)}>${l.title}`,u=(p=c.useVariables)==null?void 0:p.call(c,F(v({},l),{title:d}),e);u&&i.push(u)}),i}},wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var a,i;const{triggers:t}=s.usePlugin(re),{workflow:o}=Y(),n=t.get(o.type);return(i=(a=n==null?void 0:n.useVariables)==null?void 0:a.call(n,o.config,e))!=null?i:null}},Ut={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=xe,current:o}=e,{instructions:n}=s.usePlugin(re),a=he(),i=o!=null?o:a,l=us(i),c=[];return l.forEach(d=>{var f,y;const u=n.get(d.type),p=(f=u.useScopeVariables)==null?void 0:f.call(u,d,e);p&&c.push({key:d.key,[t.value]:d.key,[t.label]:(y=d.title)!=null?y:`#${d.id}`,[t.children]:p})}),c}},Oo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=xe}){return!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"}]:[]}},Pe={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 Po(e,t){var o,n,a,i,l,c;return typeof t=="string"?(o=Pe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Kt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((a=t.options)==null?void 0:a.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Kt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function _t(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Gt({fields:e,types:t,appends:o,depth:n=1,compile:a,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>Po(l,d)):!0;if(Kt(l)){if(o===null)return n?c||Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:a,getCollectionFields:i}):!1;const d=_t(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&Gt({fields:Ht(l.target,{compile:a,getCollectionFields:i}),types:t,appends:d,compile:a,getCollectionFields:i}).length}else return c})}function st(e,t){var i,l;const o=s.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:a}=t;return{[a.label]:o(e.label),[a.value]:e.value,key:e[a.value],[a.children]:n,disabled:!n||!n.length}}function me(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Ut,o),st(vt,o),st(wt,o),st(Oo,o),s.useGlobalVariable("$env")].filter(Boolean)}function Eo(e={}){var a;const t=Object.assign({},xe,(a=e.fieldNames)!=null?a:{}),o=Object.assign(e,{fieldNames:t});return[st(Do,o)]}function Ht(e,{compile:t,getCollectionFields:o}){var d,u,p,f,y,h,g;const[n,a]=s.parseCollectionName(e),i=o(a,n),l=[],c=[];i.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const C=c[w];if(C.type==="belongsTo"){const D=l.find(S=>S.name===C.foreignKey);D?c.splice(w,0,F(v(v({},C),D),{uiSchema:F(v({},C.uiSchema),{title:(d=C.uiSchema)!=null&&d.title?`${t((u=C.uiSchema)==null?void 0:u.title)} ID`:D.name})})):c.splice(w,0,F(v({},C),{name:C.foreignKey,type:"bigInt",isForeignKey:!0,interface:C.interface,uiSchema:F(v({},C.uiSchema),{title:(p=C.uiSchema)!=null&&p.title?`${t((f=C.uiSchema)==null?void 0:f.title)} ID`:C.name})}))}else if(C.type==="context"&&C.collectionName==="users"){const D=(y=c.find(S=>S.type==="belongsTo"&&S.target==="users"&&S.foreignKey===C.name))!=null?y:{};c.splice(w,0,F(v({},C),{type:C.dataType,interface:D.interface,uiSchema:F(v({},D.uiSchema),{title:(h=D.uiSchema)!=null&&h.title?`${t((g=D.uiSchema)==null?void 0:g.title)} ID`:C.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function ps(e){const t=_t(e.field,e.appends),o=fe(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(a=>Po(e.field,a))||(e.disabled=!0))}function fe(e){const{fields:t,collection:o,types:n,appends:a=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:d=xe}=e,u=t!=null?t:Ht(o,{compile:l,getCollectionFields:c}),p=ps.bind({compile:l,getCollectionFields:c,fieldNames:d});return Gt({fields:u,types:n,depth:i,appends:a,compile:l,getCollectionFields:c}).map(y=>{var C;const h=l(((C=y.uiSchema)==null?void 0:C.title)||y.name),g=_t(y,a),w=!Kt(y)||g&&!g.length&&!a.includes(y.name)||!1;return{[d.label]:h,key:y.name,[d.value]:y.name,isLeaf:w,loadChildren:w?null:p,field:y,depth:i,appends:a,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.Input,v({scope:a},t))}function at(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.TextArea,v({scope:a},t))}function Mo(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.RawTextArea,v({scope:a},t))}function $o(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const a=me(e);return r.jsx(s.Variable.JSON,v({scope:a},t))}function ms(o){var n=o,{variableOptions:e}=n,t=Q(n,["variableOptions"]);const{options:a=[]}=t,i=Eo(e),l=me(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...i,...l,...a]},t))}function Ae({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ne(e){const d=e,{options:t=[],getOptions:o=()=>[],direction:n}=d,a=Q(d,["options","getOptions","direction"]),i=s.useCompile(),l=o(),c=t.length>0?t:l;return r.jsx(b.Radio.Group,F(v({},a),{children:r.jsx(b.Space,{direction:n,children:c.map(u=>r.jsxs(b.Radio,{value:u.value,children:[r.jsx("span",{className:s.css`
|
|
419
419
|
& + .anticon {
|
|
420
420
|
margin-left: 0.25em;
|
|
421
421
|
}
|
|
422
|
-
`,children:
|
|
422
|
+
`,children:i(u.label)}),u.tooltip&&r.jsx(b.Tooltip,{title:i(u.tooltip),children:r.jsx(H.QuestionCircleOutlined,{style:{color:"#666"}})})]},u.value))})}))}function Bo(e){const i=e,{options:t=[],direction:o}=i,n=Q(i,["options","direction"]),a=s.useCompile();return r.jsx(b.Checkbox.Group,F(v({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Checkbox,{value:l.value,children:[r.jsx("span",{className:s.css`
|
|
423
423
|
& + .anticon {
|
|
424
424
|
margin-left: 0.25em;
|
|
425
425
|
}
|
|
426
|
-
`,children:
|
|
426
|
+
`,children:a(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:a(l.tooltip),children:r.jsx(H.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function Jt(){const e=A.useFieldSchema(),t=s.useCompile();return r.jsxs(s.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ie=()=>null;function fs(){const i=s.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=Q(i,["node","resultTitle"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{var l;a({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function gs({dataSource:e}){var a;const t=A.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=W.parse(e)({$jobsMapByNodeKey:((a=o.jobs)!=null?a:[]).reduce((i,l)=>Object.assign(i,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:s.css`
|
|
427
427
|
margin: 0;
|
|
428
|
-
`,children:JSON.stringify(n,null,2)})}
|
|
428
|
+
`,children:JSON.stringify(n,null,2)})}Ie.Initializer=fs,Ie.Result=gs,Ie.Designer=Jt;function Vo(n){var a=n,{component:e="div",children:t}=a,o=Q(a,["component","children"]);const[i,l]=x.useState(!1),c=A.useFieldSchema();return r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[x.createElement(e,F(v({},o),{onClick(){l(!0)}}),t),r.jsx(s.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Wo(e){var i;const o=s.useCompile()(e.label),n=x.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:a}=(i=ht[e.value])!=null?i:{};return r.jsx(b.Tag,{color:a,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function hs(e){const t=s.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Wo,v({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function jo(t){var e=Q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Wo,children:gt.filter(n=>!!n.value&&n.value!==ye.ABORTED).map(n=>r.jsx(b.Select.Option,F(v({},n),{children:r.jsx(hs,v({},n))}),n.value))}))}function Yt(e){const{t}=ee.useTranslation(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useCollectionRecordData(),i=x.useCallback(()=>{b.Modal.confirm({title:O("Cancel the execution"),icon:r.jsx(H.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:a.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[a]);return r.jsxs("div",{className:s.css`
|
|
429
429
|
display: flex;
|
|
430
|
-
`,children:[e.children,
|
|
430
|
+
`,children:[e.children,a.status?null:r.jsx(b.Tooltip,{title:O("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(H.StopOutlined,{})})})]})}const Lo=t=>{var e=Q(t,[]);const[o,n]=x.useState(30),a=x.useRef(null),i=l=>{var c;n(a.current.offsetWidth+50),(c=e.onChange)==null||c.call(e,l)};return x.useEffect(()=>{n(a.current.offsetWidth+50)},[]),r.jsxs("div",{style:{display:"inline-block",position:"relative",height:"100%"},children:[r.jsx(b.Input,F(v({},e),{onChange:i,style:{width:`${o}px`}})),r.jsx("span",{ref:a,style:{position:"absolute",visibility:"hidden",whiteSpace:"pre",font:"inherit"},children:e.value||e.placeholder})]})},ys=e=>e.value&&typeof e.value=="object"?r.jsx(bs,v({},e)):r.jsx(xs,v({},e)),xs=({value:e,onChange:t})=>{const o=me({types:[vs]});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})})},bs=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function vs(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function Qt(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function zo(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const ws=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=ve(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:n,onOpenChange:a,content:r.jsx(Cs,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Cs=({onSlecet:e,onQuery:t})=>{const{t:o}=ve();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ks=e=>{const{t}=ve(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Zt=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext();return r.jsx(se.Link,{to:He(t),onClick:()=>o(!1),children:e("View")})},Xt=()=>{const e=s.useCollectionRecordData(),t=s.useDataBlockResource(),o=s.useDataBlockRequest(),n=se.useNavigate();return{onClick(){return P(this,null,function*(){var i;try{const{data:{data:l}}=yield t.retry({filterByTk:e.id});if(l&&l.id){const d=(i=window.location.pathname.split("business-components/")[1])==null?void 0:i.split("/")[0];n(He(l.id,d))}else o==null||o.refresh()}catch(l){o==null||o.refresh()}})}}},qo=()=>{const t=s.useCollectionRecordData().latestExecutedTime,o=t?mt(t).format("YYYY-MM-DD HH:mm:ss"):"-";return r.jsx("div",{style:{textAlign:"left"},children:o})},Uo=A.observer(e=>{const{value:t}=e,o=s.useCompile();return!t||!Array.isArray(t)||t.length===0?r.jsx("span",{children:"-"}):r.jsx(r.Fragment,{children:t.map(n=>{const a=(n==null?void 0:n.name)||(n==null?void 0:n.id),i=n==null?void 0:n.color;return r.jsx(b.Tag,{color:i,children:o(a)},(n==null?void 0:n.id)||a)})})}),Ko=e=>{var t,o,n;if(e["category.id"])return Array.isArray(e["category.id"])?e["category.id"][0]:e["category.id"];if((t=e.category)!=null&&t.id)return Array.isArray(e.category.id)?e.category.id[0]:e.category.id;if((o=e.$and)!=null&&o.length)for(const a of e.$and){if(a["category.id"])return Array.isArray(a["category.id"])?a["category.id"][0]:a["category.id"];if((n=a.category)!=null&&n.id)return Array.isArray(a.category.id)?a.category.id[0]:a.category.id}},_o=A.observer(()=>{const{t:e}=ee.useTranslation(),t=s.useDataBlockRequest(),o=s.useDataBlockProps(),[n,a]=x.useState("all"),i=x.useRef(void 0),l=x.useRef(!1);x.useEffect(()=>{var D,S,I,M,E,N,V;if(l.current){l.current=!1;return}const u=(((D=t==null?void 0:t.params)==null?void 0:D[0])||{}).filter||{},p=((S=o==null?void 0:o.params)==null?void 0:S.filter)||{},f=Ko(u)||Ko(p);if(i.current!==f&&(i.current!==void 0||f!==void 0)){i.current=f,a("all");const K=((M=(I=t==null?void 0:t.params)==null?void 0:I[1])==null?void 0:M.filters)||{};if(K.statusFilter){delete K.statusFilter;const q=s.mergeFilter([...Object.values(K),p]);t.run(F(v({},(E=t.params)==null?void 0:E[0]),{page:1,filter:q}),{filters:K})}return}i.current=f;const g=(((V=(N=t==null?void 0:t.params)==null?void 0:N[1])==null?void 0:V.filters)||{}).statusFilter,w=u.enabled;let C="all";(g==null?void 0:g.enabled)===!0||w===!0?C="enabled":((g==null?void 0:g.enabled)===!1||w===!1)&&(C="disabled"),C!==n&&a(C)},[t==null?void 0:t.params,o]);const c=x.useCallback(d=>{var h,g,w,C;const u=d.target.value;if(u===n)return;l.current=!0,a(u);const p=v({},(g=(h=t==null?void 0:t.params)==null?void 0:h[1])==null?void 0:g.filters),f=((w=o==null?void 0:o.params)==null?void 0:w.filter)||{};u==="all"?delete p.statusFilter:p.statusFilter={enabled:u==="enabled"};const y=s.mergeFilter([...Object.values(p),f]);t.run(F(v({},(C=t.params)==null?void 0:C[0]),{page:1,filter:y}),{filters:p})},[t,o,n]);return r.jsx(b.Radio.Group,{value:n,onChange:c,optionType:"button",buttonStyle:"solid",options:[{label:e("All statuses"),value:"all"},{label:e("On"),value:"enabled"},{label:e("Off"),value:"disabled"}]})});function Ss(e,t){const o=s.useCompile(),{getCollectionFields:n}=s.useCollectionManager_deprecated();return[{label:O("ID"),value:"filterByTk"},...e.action!=="destroy"?[{label:O("Values submitted"),value:"values",children:fe(F(v({},t),{appends:null,depth:3,collection:e.collection,compile:o,getCollectionFields:n}))}]:[]]}class As extends Re{constructor(){super(...arguments),this.sync=!0,this.title=O("Interceptor"),this.description=O('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:T("Collection"),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:T("Trigger mode"),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Local mode, triggered before executing the actions bound to this workflow"),value:!1},{label:T("Global mode, triggered before executing the following actions"),value:!0}]},default:!1},actions:{type:"number",title:T("Select actions"),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:T("Create record action"),value:"create"},{label:T("Update record action"),value:"update"},{label:T("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:rt,RadioWithTooltip:Ne,CheckboxGroupWithTooltip:Bo},this.isActionTriggerable=(t,o)=>{const{global:n}=t;return!n&&!o.direct}}useVariables(t,o){const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User acted")}}],compile:n,getCollectionFields:a})),l=[{label:O("Parameters"),value:"params",children:Ss(t,o)}];return[...i,{label:O("Role of user acted"),value:"roleName"},...l]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.params.values"}:null}}class Is extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerTrigger("request-interception",As)})}}class Fs extends oe{constructor(){super(...arguments),this.title=T("JS Parse"),this.type=ko,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY js code;"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},JSCode:{type:"string",title:T("JSCode expression"),"x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.data
|
|
431
431
|
ctx.body
|
|
432
432
|
__ctx
|
|
433
433
|
lib.JSON
|
|
434
434
|
lib.qrcode
|
|
435
435
|
canvas
|
|
436
436
|
lib.dayjs
|
|
437
|
-
lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:
|
|
437
|
+
lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:T("Properties mapping"),description:T("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:T("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:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
438
438
|
> *:not(:last-child) {
|
|
439
439
|
margin-right: 0.5em;
|
|
440
440
|
}
|
|
441
441
|
button {
|
|
442
442
|
padding: 0;
|
|
443
443
|
}
|
|
444
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:
|
|
444
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ts extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(ko,Fs)})}}class Ns extends oe{constructor(){super(...arguments),this.title=T("JSON Parse"),this.type=Co,this.group=Ge,this.description=T("Get specific data from JSON result of any node BY jsonata; https://jsonata.org/"),this.fieldset={source:{type:"string",title:T("Data source"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0},required:!0},expression:{type:"string",title:T("Query expression"),"x-decorator":"FormItem","x-component":"CodeMirror"},model:{type:"array",title:T("Properties mapping"),description:T("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:T("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:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
445
445
|
> *:not(:last-child) {
|
|
446
446
|
margin-right: 0.5em;
|
|
447
447
|
}
|
|
448
448
|
button {
|
|
449
449
|
padding: 0;
|
|
450
450
|
}
|
|
451
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:
|
|
451
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}isAvailable(){return!1}}class Ds extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(Co,Ns)})}}function Os(e,t){let o=e,n=null;for(let a=0;a<t.length;a++){const i=t[a],l=o.find(c=>c.value===i);if(!l)return null;n=l,!l.isLeaf&&l.loadChildren&&l.loadChildren(l),l.children&&(o=l.children)}return n}class Ps extends oe{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`
|
|
452
452
|
width: 100%;
|
|
453
453
|
|
|
454
454
|
.variable {
|
|
@@ -458,25 +458,25 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
458
458
|
.ant-input.null-value {
|
|
459
459
|
width: 100%;
|
|
460
460
|
}
|
|
461
|
-
`},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
|
|
461
|
+
`},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 i;const{nodes:o}=Y(),{styles:n}=we(),a=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(it,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
|
|
462
462
|
padding-left: 20em;
|
|
463
|
-
`),children:[r.jsx(
|
|
463
|
+
`),children:[r.jsx(je,{from:t,entry:a,branchIndex:(i=a==null?void 0:a.branchIndex)!=null?i: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(H.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),a=O("Loop target"),i=O("Loop index"),l=O("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=xe}=o;let u={key:"item",[d.value]:"item",[d.label]:a};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const p=c.slice(2,-2).split(".").map(h=>h.trim()),f=[Ut,vt,wt].map(h=>{const g=h.useOptions(F(v({},o),{current:t})).filter(Boolean);return{[d.label]:n(h.label),[d.value]:h.value,key:h.value,[d.children]:g,disabled:g&&!g.length}}),y=Os(f,p);u=Object.assign({},y,u)}return[u,{key:"index",[d.value]:"index",[d.label]:i},{key:"length",[d.value]:"length",[d.label]:l}]}}class Es extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",Ps)})}}function Ms(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function $s({multiple:e=!1,value:t=[],onChange:o}){const n=me({types:[Ms]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:a=>{o([a])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:a=>{o(a!=null?[a]:[])}})})}function Bs({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(W.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:O("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:t,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:O("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:O("All pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:O("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:O("Any pass")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
|
|
464
464
|
.ant-radio-group {
|
|
465
465
|
.anticon {
|
|
466
466
|
margin-left: 0.5em;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:T("Separately")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:T("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:T("Collaboratively")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Vo(e){var $,P,B;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),i=y.useRef(null),a=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(a),{appends:c,updateAssociationValues:p}=l(),[d]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(P=t==null?void 0:t.result)==null?void 0:P[d],{findComponent:f}=s.useDesignable(),g=f((B=n.component)==null?void 0:B[0])||y.Fragment,h=y.useMemo(()=>A.createForm({initialValues:u}),[u]),x=y.useMemo(()=>v({appends:c},e.params),[c,e.params]),C=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=s.useAPIClient(),F=s.useDataSourceHeaders(a),w=k.resource(e.collection,void 0,F),O=s.useBlockRequestContext(),V=y.useMemo(()=>({params:x,form:h,field:n,service:C,updateAssociationValues:p,formBlockRef:i}),[n,h,x,C,p]);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:C,resource:w,__parent:O},children:r.jsx(s.FormBlockContext.Provider,{value:V,children:r.jsxs(g,I(v({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:i,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function Cs(e){return s.createFormBlockSchema(e)}function ks(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(d){return D(this,arguments,function*({item:p}){var x;const u=p.template?yield i(p):null,f=Cs(I(v({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ve.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),h=((x=Object.entries(f.properties[g].properties).find(([C,k])=>k["x-component"]==="ActionBar"))==null?void 0:x[0])||"actions";f.properties[g].properties[h]["x-decorator"]="ActionBarProvider",f.properties[g].properties[h]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},yt(f,C=>{C["x-uid"]&&delete C["x-uid"]}),a(f)})}return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:c,items:l}))}function Wo(){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(ks,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 Ss(){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 As={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(p=>({name:te.camelCase(`createRecordForm-child-${p.name}`),type:"item",title:p.title||p.tableName,schema:{collection:p.name,dataSource:a,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Wo}))})),[e]),[o,n]=y.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:Ss},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([d,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]={type:"create",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Pe(a.properties[l],d=>d["x-component"]==="Action").map(d=>{var u,f;return{status:d["x-decorator-props"].value,values:(f=(u=d["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:d.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function jo(e){var d,u,f,g;const[t,o]=y.useState((u=(d=e.collection)==null?void 0:d.fields)!=null?u:[]),n=s.useRecord(),i=A.useField(),a=A.useFieldSchema(),[l]=Object.keys((f=a.toJSON().properties)!=null?f:{}),c=(g=n==null?void 0:n.result)==null?void 0:g[l],p=y.useMemo(()=>A.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:p,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:M.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[M.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:ve.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const zo={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 Fs(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:i="others"}=n;t[i]=t[i]||{},te.set(t,[i,o],n)}),Object.keys(zo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:zo[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 Ts(){const{interfaces:e}=s.useCollectionManager_deprecated();return Fs(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:Os,fieldInterface:n.name}))}))}const Lo=y.createContext({}),Ns=e=>{const[t,o]=y.useState(null),[n,i]=y.useState(),a=Ts(),l=s.useCollection_deprecated(),{setCollectionFields:c}=y.useContext(s.FormBlockContext),p=y.useMemo(()=>A.createForm(),[t]);return r.jsxs(Lo.Provider,{value:{onAddField(d){const u=te.pick(d,["name","group","title","default","validateSchema"]),{properties:F}=d,w=F,{unique:f,type:g,layout:h,autoIncrement:x}=w,C=K(w,["unique","type","layout","autoIncrement"]);u.properties=C;const k=te.cloneDeep(u);delete k.properties.name["x-disabled"],o(k)},setCallback:i},children:[r.jsx(s.SchemaInitializerItems,I(v({},e),{items:a})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(d){d||o(null)}},children:t?r.jsx(s.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:p},"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 d=A.useForm();return{run(){return D(this,null,function*(){i(null),o(null),d.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:d,query:u,reset:f}=A.useForm(),g=[T("Field name existed in form")];return{run(){return D(this,null,function*(){var w,O,V,$;const{default:x}=t,C=M.uid();if(x.name=(w=d.name)!=null?w:C,x.uiSchema.title=(V=(O=d.uiSchema)==null?void 0:O.title)!=null?V:C,x.interface=t.name,($=l.fields)==null?void 0:$.find(P=>P.name===x.name)){u("name").take().setFeedback({type:"error",messages:g});return}const F=M.merge(x,d);c([...l.fields,F]),n({name:x.name,type:x.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:F},"x-collection-field":`${l.name}.${x.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),i(null),o(null)})}}}}}}}})},components:{ArrayTable:M.ArrayTable}}):null})]})},Ds=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:Ns});function Os(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:i}=y.useContext(Lo),{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 qo={title:`{{t("Custom form", { ns: "${m}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${m}" })}}`,Component:Is}},initializers:{},components:{CustomFormBlockProvider:jo},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var p,d;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=((p=Object.entries(a.properties).find(([u,f])=>f["x-component"]==="ActionBar"))==null?void 0:p[0])||"actions";t[i]={type:"custom",title:((d=n["x-component-props"])==null?void 0:d.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:jo}}};function Ps(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=Q.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 Es={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=y.useMemo(()=>e.map(({key:a,displayName:l,collections:c})=>({key:a,name:a,label:l,type:"subMenu",children:c.map(p=>({name:te.camelCase(`updateRecordForm-child-${p.name}`),type:"item",title:p.title||p.tableName,schema:{collection:p.name,dataSource:a,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Wo}))})),[e]),[o,n]=y.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:Ps},parseFormOptions(e){const t={};return Pe(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,p;const[i]=Object.keys(n.properties),a=n.properties[i],l=((c=Object.entries(a.properties).find(([d,u])=>u["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[i]=I(v({},n["x-decorator-props"]),{type:"update",title:((p=n["x-component-props"])==null?void 0:p.title)||i,actions:Pe(a.properties[l],d=>d["x-component"]==="Action").map(d=>{var u,f;return{status:d["x-decorator-props"].value,values:(f=(u=d["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:f.values,key:d.name}})})}),t}},block:{scope:{},components:{}}},Ee=new M.Registry;Ee.register("customForm",qo),Ee.register("createForm",As),Ee.register("updateForm",Es);function Ms(){const{workflow:e}=q(),t=Ze();return t.useInitializers?t.useInitializers(e.config):null}qo.title;const $s=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(X),t=xe(),o=Be(t),n=[Ms()].filter(Boolean),i=o.map(l=>{var p;const c=e.instructions.get(l.type);return(p=c==null?void 0:c.useInitializers)==null?void 0:p.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(Ee.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 Bs(){var k,F,w;const e=y.useContext(s.SchemaComponentContext),{t}=Q.useTranslation(),o=A.useFieldSchema(),n=ce(),[i,a]=y.useState(!1),[l,c]=y.useState((w=(F=(k=o==null?void 0:o["x-action-settings"])==null?void 0:k.assignedValues)==null?void 0:F.schema)!=null?w:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[p,d]=y.useState(null),{components:u}=s.useSchemaOptionsContext();y.useEffect(()=>{d(new A.Schema({properties:{grid:l}}))},[l]);const f=y.useMemo(()=>{var V,$;const O=($=(V=o==null?void 0:o["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:$.values;return A.createForm({initialValues:te.cloneDeep(O),values:te.cloneDeep(O)})},[o]),g=s.useFormActiveFields(),h=t("Assign field values");function x(){a(!1)}function C(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=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:h,onClick:()=>a(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:i,onCancel:x,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:x,children:t("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:C,children:t("Submit")})]}),children:r.jsx(s.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(s.VariableScopeProvider,{scope:n,children:r.jsx(s.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:g==null?void 0:g.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:f,children:r.jsxs(M.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:T("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),i&&p&&r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},e),{refresh(){c(te.get(p.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:p,components:u})})]})})})})})})]})}function Vs(e){return r.jsxs(s.GeneralSchemaDesigner,I(v({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Bs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Ws(){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 Uo(){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 js=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Ws,action:ve.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Uo,action:ve.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Uo,action:ve.PENDING}]});function zs(){return{run(){}}}function Ls({value:e,onChange:t}){const o=s.usePlugin(X),n=y.useContext(s.SchemaComponentContext),i=xe(),a=Be(i),l=A.useForm(),{workflow:c}=q(),p={};a.forEach(f=>{const g=o.instructions.get(f.type);Object.assign(p,g.components)});const d=y.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
|
|
469
|
+
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),t(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:O("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:O("Separately")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:O("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:O("Collaboratively")}),r.jsx(H.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?o:null]})}function Go(e){var E,N,V;const t=s.useRecord(),o=A.useFieldSchema(),n=A.useField(),a=x.useRef(null),i=e.dataSource||s.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=s.useAssociationNames(i),{appends:c,updateAssociationValues:d}=l(),[u]=Object.keys((E=o.toJSON().properties)!=null?E:{}),p=(N=t==null?void 0:t.result)==null?void 0:N[u],{findComponent:f}=s.useDesignable(),y=f((V=n.component)==null?void 0:V[0])||x.Fragment,h=x.useMemo(()=>A.createForm({initialValues:p}),[p]),g=x.useMemo(()=>v({appends:c},e.params),[c,e.params]),w=x.useMemo(()=>({loading:!1,data:{data:p}}),[p]),C=s.useAPIClient(),D=s.useDataSourceHeaders(i),S=C.resource(e.collection,void 0,D),I=s.useBlockRequestContext(),M=x.useMemo(()=>({params:g,form:h,field:n,service:w,updateAssociationValues:d,formBlockRef:a}),[n,h,g,w,d]);return!t.status||p?r.jsx(s.CollectionManagerProvider,{dataSource:i,children:r.jsx(s.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(s.RecordProvider,{record:p,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:S,__parent:I},children:r.jsx(s.FormBlockContext.Provider,{value:M,children:r.jsxs(y,F(v({},n.componentProps),{children:[r.jsx(s.FormV2.Templates,{style:{marginBottom:18},form:h}),r.jsx("div",{ref:a,children:r.jsx(A.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})})}):null}function Vs(e){return s.createFormBlockSchema(e)}function Ws(o){var n=o,{schema:e}=n,t=Q(n,["schema"]);const{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),{insert:i}=s.useSchemaInitializer(),l=s.useRecordCollectionDataSourceItems("FormItem");function c(u){return P(this,arguments,function*({item:d}){var g;const p=d.template?yield a(d):null,f=Vs(F(v({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${m}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},e),{template:p}));delete f["x-acl-action-props"],delete f["x-acl-action"];const[y]=Object.keys(f.properties),h=((g=Object.entries(f.properties[y].properties).find(([w,C])=>C["x-component"]==="ActionBar"))==null?void 0:g[0])||"actions";f.properties[y].properties[h]["x-decorator"]="ActionBarProvider",f.properties[y].properties[h]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},bt(f,w=>{w["x-uid"]&&delete w["x-uid"]}),i(f)})}return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:c,items:l}))}function Ho(){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(Ws,v({},e))})}function Ee(e,t,o=!1){const n=[];return e?t(e)&&(!o||!e.properties)?(n.push(e),n):(e.properties&&Object.keys(e.properties).forEach(a=>{n.push(...Ee(e.properties[a],t))}),n):n}function js(){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 Ls={title:`{{t("Create record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Create record", { ns: "${m}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{CreateFormDesigner:js},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="create").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]={type:"create",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function Jo(e){var u,p,f,y;const[t,o]=x.useState((p=(u=e.collection)==null?void 0:u.fields)!=null?p:[]),n=s.useRecord(),a=A.useField(),i=A.useFieldSchema(),[l]=Object.keys((f=i.toJSON().properties)!=null?f:{}),c=(y=n==null?void 0:n.result)==null?void 0:y[l],d=x.useMemo(()=>A.createForm({initialValues:c}),[c]);return!n.status||c?r.jsx(s.CollectionProvider_deprecated,{collection:F(v({},e.collection),{fields:t}),children:r.jsx(s.RecordProvider,{record:c,parent:null,children:r.jsx(s.FormBlockContext.Provider,{value:{form:d,field:a,setCollectionFields:o},children:e.children})})}):null}function zs(){const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem();return r.jsx(s.SchemaInitializerItem,F(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:Ce.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Yo={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 qs(e){const t={};return Object.keys(e).forEach(o=>{const n=e[o],{group:a="others"}=n;t[a]=t[a]||{},ae.set(t,[a,o],n)}),Object.keys(Yo).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Yo[o],children:Object.keys(t[o]||{}).map(n=>{const a=t[o][n];return v({value:n,title:a.title,name:n},t[o][n])}).sort((n,a)=>n.order-a.order)}))}function Us(){const{interfaces:e}=s.useCollectionManager_deprecated();return qs(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:Gs,fieldInterface:n.name}))}))}const Qo=x.createContext({}),Ks=e=>{const[t,o]=x.useState(null),[n,a]=x.useState(),i=Us(),l=s.useCollection_deprecated(),{setCollectionFields:c}=x.useContext(s.FormBlockContext),d=x.useMemo(()=>A.createForm(),[t]);return r.jsxs(Qo.Provider,{value:{onAddField(u){const p=ae.pick(u,["name","group","title","default","validateSchema"]),{properties:D}=u,S=D,{unique:f,type:y,layout:h,autoIncrement:g}=S,w=Q(S,["unique","type","layout","autoIncrement"]);p.properties=w;const C=ae.cloneDeep(p);delete C.properties.name["x-disabled"],o(C)},setCallback:a},children:[r.jsx(s.SchemaInitializerItems,F(v({},e),{items:i})),r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible(u){u||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:F(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 u=A.useForm();return{run(){return P(this,null,function*(){a(null),o(null),u.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:u,query:p,reset:f}=A.useForm(),y=[O("Field name existed in form")];return{run(){return P(this,null,function*(){var S,I,M,E;const{default:g}=t,w=W.uid();if(g.name=(S=u.name)!=null?S:w,g.uiSchema.title=(M=(I=u.uiSchema)==null?void 0:I.title)!=null?M:w,g.interface=t.name,(E=l.fields)==null?void 0:E.find(N=>N.name===g.name)){p("name").take().setFeedback({type:"error",messages:y});return}const D=W.merge(g,u);c([...l.fields,D]),n({name:g.name,type:g.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:D},"x-collection-field":`${l.name}.${g.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),f(),a(null),o(null)})}}}}}}}})},components:{ArrayTable:W.ArrayTable}}):null})]})},_s=new s.SchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:s.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:Ks});function Gs(){const e=s.useSchemaInitializerItem(),{insert:t,setVisible:o}=s.useSchemaInitializer(),{onAddField:n,setCallback:a}=x.useContext(Qo),{getInterface:i}=s.useCollectionManager_deprecated(),l=i(e.fieldInterface);return r.jsx(s.SchemaInitializerItem,v({onClick:()=>{a(()=>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:zs}},initializers:{},components:{CustomFormBlockProvider:Jo},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="CustomFormBlockProvider").forEach(n=>{var d,u;const[a]=Object.keys(n.properties),i=n.properties[a],l=Ee(i.properties.grid,p=>p["x-component"]==="CollectionField",!0);n["x-decorator-props"].collection.fields=l.map(p=>{var f,y;return(y=(f=p["x-component-props"])==null?void 0:f.field)!=null?y:p["x-interface-options"]});const c=((d=Object.entries(i.properties).find(([p,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";t[a]={type:"custom",title:((u=n["x-component-props"])==null?void 0:u.title)||a,actions:Ee(i.properties[c],p=>p["x-component"]==="Action").map(p=>{var f,y;return{status:p["x-decorator-props"].value,values:(y=(f=p["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:y.values,key:p.name}}),collection:n["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:Jo}}};function Hs(){const{name:e,title:t}=s.useCollection_deprecated(),o=A.useFieldSchema(),{t:n}=ee.useTranslation(),{dn:a}=s.useDesignable();return r.jsxs(s.GeneralSchemaDesigner,{title:t||e,children:[r.jsx(s.SchemaSettingsBlockTitleItem,{}),r.jsx(s.SchemaSettingsActionModalItem,{title:n("Filter settings",{ns:m}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:s.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:i})=>{o["x-decorator-props"].filter=i,a.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),a.refresh()}}),r.jsx(s.SchemaSettingsLinkageRules,{collectionName:e}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Js={title:`{{t("Update record form", { ns: "${m}" })}}`,config:{useInitializer({allCollections:e}){const t=x.useMemo(()=>e.map(({key:i,displayName:l,collections:c})=>({key:i,name:i,label:l,type:"subMenu",children:c.map(d=>({name:ae.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:i,title:`{{t("Update record", { ns: "${m}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Ho}))})),[e]),[o,n]=x.useState([]),a=s.useMenuSearch({data:t,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${m}" })}}`,componentProps:{onOpenChange(i){n(i)}},children:a}},initializers:{},components:{FilterDynamicComponent:Ae,UpdateFormDesigner:Hs},parseFormOptions(e){const t={};return Ee(e,n=>n["x-decorator"]==="FormBlockProvider"&&n["x-decorator-props"].formType==="update").forEach(n=>{var c,d;const[a]=Object.keys(n.properties),i=n.properties[a],l=((c=Object.entries(i.properties).find(([u,p])=>p["x-component"]==="ActionBar"))==null?void 0:c[0])||"actions";t[a]=F(v({},n["x-decorator-props"]),{type:"update",title:((d=n["x-component-props"])==null?void 0:d.title)||a,actions:Ee(i.properties[l],u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}})})}),t}},block:{scope:{},components:{}}},Me=new W.Registry;Me.register("customForm",Zo),Me.register("createForm",Ls),Me.register("updateForm",Js);function Ys(){const{workflow:e}=Y(),t=et();return t.useInitializers?t.useInitializers(e.config):null}Zo.title;const Qs=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(re),t=he(),o=We(t),n=[Ys()].filter(Boolean),a=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,...a.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${m}" })}}`,children:a}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const t=s.useDataSourceManager().getAllCollections();return Array.from(Me.getValues()).map(o=>{const{useInitializer:n}=o.config;return n({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Demonstration text")}}',Component:"MarkdownBlockInitializer"}]}]});function Zs(){var C,D,S;const e=x.useContext(s.SchemaComponentContext),{t}=ee.useTranslation(),o=A.useFieldSchema(),n=me(),[a,i]=x.useState(!1),[l,c]=x.useState((S=(D=(C=o==null?void 0:o["x-action-settings"])==null?void 0:C.assignedValues)==null?void 0:D.schema)!=null?S:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,u]=x.useState(null),{components:p}=s.useSchemaOptionsContext();x.useEffect(()=>{u(new A.Schema({properties:{grid:l}}))},[l]);const f=x.useMemo(()=>{var M,E;const I=(E=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:E.values;return A.createForm({initialValues:ae.cloneDeep(I),values:ae.cloneDeep(I)})},[o]),y=s.useFormActiveFields(),h=t("Assign field values");function g(){i(!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,i(!1),setTimeout(()=>{var I;(I=e.refresh)==null||I.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaSettingsItem,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:a,onCancel:g,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:g,children:t("Cancel")}),r.jsx(b.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:y==null?void 0:y.getActiveFieldsName,children:r.jsx(A.FormProvider,{form:f,children:r.jsxs(W.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:O("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),a&&d&&r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{refresh(){c(ae.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(s.SchemaComponent,{schema:d,components:p})})]})})})})})})]})}function Xs(e){return r.jsxs(s.GeneralSchemaDesigner,F(v({},e),{disableInitializer:!0,children:[r.jsx(s.Action.Designer.ButtonEditor,{}),r.jsx(Zs,{}),r.jsx(s.SchemaSettingsDivider,{}),r.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Rs(){const i=s.useSchemaInitializerItem(),{action:t,actionProps:o}=i,n=Q(i,["action","actionProps"]),{insert:a}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:()=>{a({type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Xo(){const e=s.useSchemaInitializerItem(),a=e,{action:t,actionProps:o}=a,n=Q(a,["action","actionProps"]);return r.jsx(s.InitializerWithSwitch,F(v({},n),{item:e,schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":F(v({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${t}`},type:"x-action"}))}const ea=new s.SchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${m}" })}}`,Component:Rs,action:Ce.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${m}" })}}`,Component:Xo,action:Ce.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${m}" })}}`,Component:Xo,action:Ce.PENDING}]});function ta(){return{run(){}}}function oa({value:e,onChange:t}){const o=s.usePlugin(re),n=x.useContext(s.SchemaComponentContext),a=he(),i=We(a),l=A.useForm(),{workflow:c}=Y(),d={};i.forEach(f=>{const y=o.instructions.get(f.type);Object.assign(d,y.components)});const u=x.useMemo(()=>new A.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${m}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:s.css`
|
|
470
470
|
.ant-drawer-body {
|
|
471
471
|
background: var(--tb-box-bg);
|
|
472
472
|
}
|
|
473
|
-
`},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=y.useCallback(function(){const{tabs:g}=te.get(d.toJSON(),"properties.drawer.properties"),h=Array.from(Ee.getValues()).reduce((x,C)=>Object.assign(x,C.config.parseFormOptions(g)),{});l.setValuesIn("forms",h),t(g.properties)},[l,t,d]);return r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},n),{designable:!c.executed,refresh:u}),children:r.jsx(s.SchemaComponent,{schema:d,components:I(v(v({},p),Array.from(Ee.getValues()).reduce((f,g)=>Object.assign(f,g.config.components),{})),{FormBlockProvider:Vo,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:_t,ManualActionDesigner:Vs}),scope:{useSubmit:zs,useDetailsBlockProps:s.useFormBlockContext}})})}function qs(e){const{workflow:t}=q(),[o,n]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:T(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class Us 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:qs,SchemaConfig:Ls,ModeConfig:ws,AssigneesSelect:vs}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=ue}){var u;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),p=Object.keys((u=n.forms)!=null?u:{});if(!p.length)return null;const d=p.map(f=>{var C;const g=n.forms[f],h=me({fields:(C=g.collection)==null?void 0:C.fields,collection:g.collection,types:i,compile:l,getCollectionFields:c}),x=l(g.title)||f;return h.length?{key:f,value:f,label:x,title:x,children:h}:null}).filter(Boolean);return d.length?{[a.value]:t,[a.label]:o,[a.children]:d}: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 d,u;const c=t.config.forms[l],{fields:p=[]}=o(c.collection);return p.length?{name:(d=c.title)!=null?d: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 Ks={title:`{{t("Task", { ns: "${m}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},_s={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}}]},Gs={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}}}]},Hs=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Js=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Ys=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function Qs(e){const t=s.useRecord(),o=T("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Qt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:Hs,WorkflowColumn:Js,UserColumn:Ys,UserJobStatusColumn:Qs},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 d;const{data:t}=s.useCurrentUserContext(),{userJob:o}=q(),{status:n,result:i,userId:a}=o,l=A.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:p}=e;return n?i[c]||(p=null):((d=t==null?void 0:t.data)==null?void 0:d.id)!==a&&(p=null),p}const Ko=y.createContext(null);Ko.displayName="ManualActionStatusContext";function Xs({value:e,children:t}){const{userJob:o,execution:n}=q(),i=A.useField(),a=A.useFieldSchema();return y.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(Ko.Provider,{value:e,children:t})}function Rs(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),i=A.useFieldSchema(),{service:a}=s.useTableBlockContext(),{userJob:l,execution:c}=q(),{name:p}=i,{name:d}=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:{[d]:o,_:p}}}),t(!1),a.refresh())})}}}function ei(e){var u;const t=s.usePlugin(X),o=s.useAPIClient(),{id:n}=s.useRecord(),[i,a]=y.useState(null),[l,c]=y.useState(null);y.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:h})=>{var O;const V=(O=h==null?void 0:h.data)!=null?O:{},{node:x,workflow:$={}}=V,P=$,{nodes:C=[]}=P,k=K(P,["nodes"]),B=V,{execution:F}=B,w=K(B,["node","workflow","execution"]);ht(C),c(x),a({userJob:w,workflow:k,nodes:C,execution:F})}))},[o,n]);const d=Be(i==null?void 0:i.nodes.find(f=>f.id===l.id)).reduce((f,{type:g})=>{var h;return Object.assign(f,(h=t.instructions.get(g))==null?void 0:h.components)},{});return l&&i?r.jsx($e.Provider,{value:i,children:r.jsx(s.SchemaComponent,{components:v(v({FormBlockProvider:Vo,DetailsBlockProvider:jt,ActionBarProvider:Zs,ManualActionStatusProvider:Xs},Array.from(Ee.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),d),scope:v({useSubmit:Rs,useFormBlockProps:ti,useDetailsBlockProps:oi},Array.from(Ee.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(b.Spin,{})}function ti(){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 y.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function oi(){const{form:e}=s.useFormBlockContext();return{form:e}}function ni(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=Re[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
|
|
473
|
+
`},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:{}}}}}}}}}}),[]),p=x.useCallback(function(){const{tabs:y}=ae.get(u.toJSON(),"properties.drawer.properties"),h=Array.from(Me.getValues()).reduce((g,w)=>Object.assign(g,w.config.parseFormOptions(y)),{});l.setValuesIn("forms",h),t(y.properties)},[l,t,u]);return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},n),{designable:!c.executed,refresh:p}),children:r.jsx(s.SchemaComponent,{schema:u,components:F(v(v({},d),Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.config.components),{})),{FormBlockProvider:Go,DetailsBlockProvider:s.DetailsBlockProvider,ManualActionStatusProvider(f){return f.children},ActionBarProvider(f){return f.children},SimpleDesigner:Jt,ManualActionDesigner:Xs}),scope:{useSubmit:ta,useDetailsBlockProps:s.useFormBlockContext}})})}function na(e){const{workflow:t}=Y(),[o,n]=x.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>n(!0),disabled:!1,children:O(t.executed?"View user interface":"Configure user interface")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})}class ra extends oe{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:na,SchemaConfig:oa,ModeConfig:Bs,AssigneesSelect:$s}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){var p;const l=s.useCompile(),{getCollectionFields:c}=s.useCollectionManager_deprecated(),d=Object.keys((p=n.forms)!=null?p:{});if(!d.length)return null;const u=d.map(f=>{var w;const y=n.forms[f],h=fe({fields:(w=y.collection)==null?void 0:w.fields,collection:y.collection,types:a,compile:l,getCollectionFields:c}),g=l(y.title)||f;return h.length?{key:f,value:f,label:g,title:g,children:h}:null}).filter(Boolean);return u.length?{[i.value]:t,[i.label]:o,[i.children]:u}:null}useInitializers(t){var i;const{getCollection:o}=s.useCollectionManager_deprecated(),n=Object.keys((i=t.config.forms)!=null?i:{});if(!n.length||t.config.mode)return null;const a=n.map(l=>{var u,p;const c=t.config.forms[l],{fields:d=[]}=o(c.collection);return d.length?{name:(u=c.title)!=null?u:l,type:"item",title:(p=c.title)!=null?p:l,Component:Te,collection:c.collection,dataPath:`$jobsMapByNodeKey.${t.key}.${l}`}:null}).filter(Boolean);return a.length?{name:`#${t.id}`,key:"forms",type:"subMenu",title:t.title,children:a}:null}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:a}){return!t.isWorkflowSync(o)}}const sa={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"}}]},aa={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}}]},ia={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:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},la=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),ca=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?n:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),da=A.observer(()=>{var t,o,n;const e=A.useField();return(n=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?n:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"});function ua(e){const t=s.useRecord(),o=O("Unprocessed");return t.execution.status&&!t.status?r.jsx(b.Tag,{children:o}):e.children}const Rt=()=>r.jsx(s.SchemaComponent,{components:{NodeColumn:la,WorkflowColumn:ca,UserColumn:da,UserJobStatusColumn:ua},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 pa(e){var u;const{data:t}=s.useCurrentUserContext(),{userJob:o}=Y(),{status:n,result:a,userId:i}=o,l=A.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:d}=e;return n?a[c]||(d=null):((u=t==null?void 0:t.data)==null?void 0:u.id)!==i&&(d=null),d}const Ro=x.createContext(null);Ro.displayName="ManualActionStatusContext";function ma({value:e,children:t}){const{userJob:o,execution:n}=Y(),a=A.useField(),i=A.useFieldSchema();return x.useEffect(()=>{(n.status||o.status)&&(a.disabled=!0,a.visible=o.status===e&&o.result._===i.name)},[n,o,e,a,i.name]),r.jsx(Ro.Provider,{value:e,children:t})}function fa(){const e=s.useAPIClient(),{setVisible:t}=s.useActionContext(),{values:o,submit:n}=A.useForm(),a=A.useFieldSchema(),{service:i}=s.useTableBlockContext(),{userJob:l,execution:c}=Y(),{name:d}=a,{name:u}=a.parent.parent;return{run(){return P(this,null,function*(){c.status||l.status||(yield n(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:d}}}),t(!1),i.refresh())})}}}function ga(e){var p;const t=s.usePlugin(re),o=s.useAPIClient(),{id:n}=s.useRecord(),[a,i]=x.useState(null),[l,c]=x.useState(null);x.useEffect(()=>{var f,y;n&&((y=(f=o.resource("users_jobs")).get)==null||y.call(f,{filterByTk:n,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:h})=>{var I;const M=(I=h==null?void 0:h.data)!=null?I:{},{node:g,workflow:E={}}=M,N=E,{nodes:w=[]}=N,C=Q(N,["nodes"]),V=M,{execution:D}=V,S=Q(V,["node","workflow","execution"]);xt(w),c(g),i({userJob:S,workflow:C,nodes:w,execution:D})}))},[o,n]);const u=We(a==null?void 0:a.nodes.find(f=>f.id===l.id)).reduce((f,{type:y})=>{var h;return Object.assign(f,(h=t.instructions.get(y))==null?void 0:h.components)},{});return l&&a?r.jsx(Ve.Provider,{value:a,children:r.jsx(s.SchemaComponent,{components:v(v({FormBlockProvider:Go,DetailsBlockProvider:qt,ActionBarProvider:pa,ManualActionStatusProvider:ma},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.components),{})),u),scope:v({useSubmit:fa,useFormBlockProps:ha,useDetailsBlockProps:ya},Array.from(Me.getValues()).reduce((f,y)=>Object.assign(f,y.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=l.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function ha(){var l;const{userJob:e,execution:t}=Y(),o=s.useRecord(),{data:n}=s.useCurrentUserContext(),{form:a}=s.useFormBlockContext(),i=t.status||e.status?o?"readPretty":"disabled":((l=n==null?void 0:n.data)==null?void 0:l.id)!==e.userId?"disabled":"editable";return x.useEffect(()=>{a==null||a.setPattern(i)},[i,a]),{form:a}}function ya(){const{form:e}=s.useFormBlockContext();return{form:e}}function xa(){const e=s.useCompile(),{status:t,updatedAt:o}=s.useRecord(),n=ot[t];return t?r.jsxs(b.Space,{children:[r.jsx("time",{className:s.css`
|
|
474
474
|
margin-right: 0.5em;
|
|
475
|
-
`,children:Vt(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function ri(){var a;const e=y.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:i}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:ni,FlowContextProvider:ei},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 si({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:I(v({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[Ks,_s,Gs],children:r.jsx(s.TableBlockProvider,I(v({name:"workflow-todo"},o),{children:t}))})}Qt.Drawer=ri,Qt.Decorator=si;const ii=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,I(v({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 ai extends s.Plugin{load(){return D(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Us),this.app.schemaInitializerManager.add($s),this.app.schemaInitializerManager.add(js),this.app.schemaInitializerManager.add(Ds),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:Qt,WorkflowTodoBlockInitializer:ii})}}const _o="notice",Zt="workflowNotice",Te="workflow";function Ge(){return{t:(t,o={})=>s.i18n.t(t,v({ns:Te},o))}}const ie=e=>s.tval(e,{ns:Te});function li(){const e=s.useAPIClient(),t=A.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=re.useNavigate(),l=A.useFieldSchema(),c=A.useField(),p=s.useCompile(),{modal:d}=b.App.useApp(),u=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return D(this,null,function*(){var F,w,O;const{onSuccess:h,skipValidator:x,triggerWorkflows:C}=(F=l==null?void 0:l["x-action-settings"])!=null?F:{};x||(yield t.submit());const k=yield u();c.data=o.data||{},c.data.loading=!0;try{const V=yield e.resource("workflows").trigger({values:k,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(C),beforeWorkflows:s.getBeforeWorkflows(C)});if(c.data.loading=!1,c.data.data=V,(O=(w=n==null?void 0:n.service)==null?void 0:w.refresh)==null||O.call(w),i==null||i(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?d.success({title:p(h==null?void 0:h.successMessage),onOk:()=>D(null,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(M.isURL(h.redirectTo)?window.location.href=h.redirectTo:a(h.redirectTo))})}):b.message.success(p(h==null?void 0:h.successMessage))}catch(V){c.data.loading=!1}})}}}function ci(){var g;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=A.useField(),i=A.useFieldSchema(),{field:a,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:p}=b.App.useApp(),d=re.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(g=i==null?void 0:i["x-action-settings"])!=null?g:{};return{onClick(){return D(this,null,function*(){var x,C;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)}),(C=(x=l==null?void 0:l.service)==null?void 0:x.refresh)==null||C.call(x),c==null||c(!1),!(u!=null&&u.successMessage))return;if(u!=null&&u.manualClose){let k;p.success({title:e(u==null?void 0:u.successMessage),onOk(){return D(this,null,function*(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(M.isURL(u.redirectTo)?window.location.href=u.redirectTo:d(u.redirectTo))})}})}else b.message.success(e(u==null?void 0:u.successMessage))}catch(k){console.error(k)}finally{n.data.loading=!1}})}}}const di=()=>{const e=Ht(),t=M.ArrayItems.useArray()||{field:[]},{t:o}=Ge(),[n,i]=y.useState(!1),a=y.useCallback(()=>{t.field.push(""),i(!1)},[t.field]),l=y.useCallback(()=>{t.field.push({filter:{}}),i(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:i,content:r.jsx(pi,{onSlecet:a,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},pi=({onSlecet:e,onQuery:t})=>{const{t:o}=Ge();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},ui=e=>{const{t}=Ge(),[o,n]=y.useState(!1),i=y.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.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})]})},mi=e=>e.value&&typeof e.value=="object"?r.jsx(gi,v({},e)):r.jsx(fi,v({},e)),fi=({value:e,onChange:t})=>{const o=ce({types:[hi]});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})})},gi=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ie}}}}})})};function hi(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const yi=()=>{var p;const{workflow:e}=q(),[t,o]=s.parseCollectionName((p=e.config)==null?void 0:p.collection),n=s.useSchemaInitializerItem(),{insert:i}=s.useSchemaInitializer(),{getTemplateSchemaByMode:a}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=u=>D(null,[u],function*({item:d}){const f=d.template?yield a(d):null,g=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});te.unset(g,["x-acl-action","x-acl-action-props"]);const[h]=Object.keys(g.properties);te.set(g.properties[h],"x-component-props.useProps","usePropsNoticeDetail"),i(g)});return r.jsx(s.SchemaInitializerItem,I(v({},n),{onClick:c,items:l}))},xi=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:yi}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(X),{workflow:t}=q(),o=Ze(),n=xe(),i=Be(n),a=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=i.map(p=>{var u;const d=e.instructions.get(p.type);return(u=d==null?void 0:d.useInitializers)==null?void 0:u.call(d,p)}).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 bi extends s.Plugin{load(){return D(this,null,function*(){this.app.schemaInitializerManager.add(xi)})}}function vi(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const wi=e=>{const{schemaData:t,loading:o,handleChange:n}=Ci(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function Ci(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:i,setValuesIn:a}=A.useForm(),{data:l,loading:c}=s.useRequest(()=>D(null,null,function*(){if(t){const f=yield ki(n,t);if(f["x-uid"]===t)return f}const d=t!=null?t:M.uid(),u=vi(d);return yield Si(n,u),o(d),u}));return{schemaData:l,loading:c,handleChange:d=>{}}}function ki(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 Si(e,t){return D(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const Ai={ActionStyle:s.css`
|
|
475
|
+
`,children:mt(o).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:n.icon,color:n.color,children:e(n.label)})]}):null}function ba(){var i;const e=x.useContext(s.SchemaComponentContext),{id:t,node:o,workflow:n,status:a}=s.useRecord();return r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},e),{reset(){},designable:!1}),children:r.jsx(s.SchemaComponent,{components:{FooterStatus:xa,FlowContextProvider:ga},schema:{type:"void",name:`drawer-${t}-${a}`,"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},title:`${n.title} - ${(i=o.title)!=null?i:`#${o.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function va({params:e={},children:t}){const o={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(v({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:[sa,aa,ia],children:r.jsx(s.TableBlockProvider,F(v({name:"workflow-todo"},o),{children:t}))})}Rt.Drawer=ba,Rt.Decorator=va;const wa=()=>{const e=s.useSchemaInitializerItem(),{insert:t}=s.useSchemaInitializer();return r.jsx(s.SchemaInitializerItem,F(v({icon:r.jsx(H.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 Ca extends s.Plugin{load(){return P(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",ra),this.app.schemaInitializerManager.add(Qs),this.app.schemaInitializerManager.add(ea),this.app.schemaInitializerManager.add(_s),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow",{name:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,type:"subMenu",icon:r.jsx(H.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:Rt,WorkflowTodoBlockInitializer:wa})}}const en="notice",eo="workflowNotice",De="workflow";function Je(){return{t:(t,o={})=>s.i18n.t(t,v({ns:De},o))}}const ce=e=>s.tval(e,{ns:De});var Ct=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ka(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kt={exports:{}},Sa=kt.exports,tn;function Aa(){return tn||(tn=1,function(e,t){(function(o,n){n()})(Sa,function(){function o(u,p){return typeof p=="undefined"?p={autoBom:!1}:typeof p!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),p={autoBom:!p}),p.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function n(u,p,f){var y=new XMLHttpRequest;y.open("GET",u),y.responseType="blob",y.onload=function(){d(y.response,p,f)},y.onerror=function(){console.error("could not download file")},y.send()}function a(u){var p=new XMLHttpRequest;p.open("HEAD",u,!1);try{p.send()}catch(f){}return 200<=p.status&&299>=p.status}function i(u){try{u.dispatchEvent(new MouseEvent("click"))}catch(f){var p=document.createEvent("MouseEvents");p.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(p)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Ct=="object"&&Ct.global===Ct?Ct: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(u,p,f){var y=l.URL||l.webkitURL,h=document.createElement("a");p=p||u.name||"download",h.download=p,h.rel="noopener",typeof u=="string"?(h.href=u,h.origin===location.origin?i(h):a(h.href)?n(u,p,f):i(h,h.target="_blank")):(h.href=y.createObjectURL(u),setTimeout(function(){y.revokeObjectURL(h.href)},4e4),setTimeout(function(){i(h)},0))}:"msSaveOrOpenBlob"in navigator?function(u,p,f){if(p=p||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(o(u,f),p);else if(a(u))n(u,p,f);else{var y=document.createElement("a");y.href=u,y.target="_blank",setTimeout(function(){i(y)})}}:function(u,p,f,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof u=="string")return n(u,p,f);var h=u.type==="application/octet-stream",g=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||h&&g||c)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var I=C.result;I=w?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=I:location=I,y=null},C.readAsDataURL(u)}else{var D=l.URL||l.webkitURL,S=D.createObjectURL(u);y?y.location=S:location.href=S,y=null,setTimeout(function(){D.revokeObjectURL(S)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})}(kt)),kt.exports}var on=Aa();const Ia=ka(on);function nn(){const{t:e}=ee.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return P(this,null,function*(){const{data:a}=yield t.dump({filterByTk:o}),i=new Blob([JSON.stringify(a.data,null,2)],{type:"application/json"});on.saveAs(i,a.data.title+"-"+a.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}function rn(){const{t:e}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n,visible:a}=s.useActionContext(),i=s.useFilterByTk(),{values:l,setInitialValues:c}=A.useForm(),d=s.useCollectionRecordData();return x.useEffect(()=>{a&&(d!=null&&d.category)&&c({category:d.category})},[a,d,c]),{run(){return P(this,null,function*(){const p=v({},l);p.category&&Array.isArray(p.category)&&(p.category=p.category.map(f=>typeof f=="object"&&(f==null?void 0:f.id)!=null?f.id:f)),yield o.revision({filterByTk:i,values:p}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}function Fa(){const e=s.useAPIClient(),t=A.useForm(),{field:o,__parent:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=se.useNavigate(),l=A.useFieldSchema(),c=A.useField(),d=s.useCompile(),{modal:u}=b.App.useApp(),p=s.useCollectValuesToSubmit(),f=c.componentProps.filterKeys||[];return{onClick(){return P(this,null,function*(){var D,S,I;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(D=l==null?void 0:l["x-action-settings"])!=null?D:{};g||(yield t.submit());const C=yield p();c.data=o.data||{},c.data.loading=!0;try{const M=yield e.resource("workflows").trigger({values:C,filterKeys:f,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(c.data.loading=!1,c.data.data=M,(I=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||I.call(S),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?u.success({title:d(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(M){c.data.loading=!1}})}}}function Ta(){var y;const e=s.useCompile(),t=s.useAPIClient(),o=s.useRecord(),n=A.useField(),a=A.useFieldSchema(),{field:i,__parent:l}=s.useBlockRequestContext(),{setVisible:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(y=a==null?void 0:a["x-action-settings"])!=null?y:{};return{onClick(){return P(this,null,function*(){var g,w;n.data=i.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),(w=(g=l==null?void 0:l.service)==null?void 0:g.refresh)==null||w.call(g),c==null||c(!1),!(p!=null&&p.successMessage))return;if(p!=null&&p.manualClose){let C;d.success({title:e(p==null?void 0:p.successMessage),onOk(){return P(this,null,function*(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))})}})}else b.message.success(e(p==null?void 0:p.successMessage))}catch(C){console.error(C)}finally{n.data.loading=!1}})}}}const Na=()=>{const e=Qt(),t=W.ArrayItems.useArray()||{field:[]},{t:o}=Je(),[n,a]=x.useState(!1),i=x.useCallback(()=>{t.field.push(""),a(!1)},[t.field]),l=x.useCallback(()=>{t.field.push({filter:{}}),a(!1)},[t.field]);return r.jsx(b.Popover,{open:!e&&n,onOpenChange:a,content:r.jsx(Da,{onSlecet:i,onQuery:l}),children:r.jsx(b.Button,{className:"ant-formily-array-base-addition",type:"dashed",block:!0,disabled:e,children:o("Add Notified Person")})})},Da=({onSlecet:e,onQuery:t})=>{const{t:o}=Je();return r.jsxs(b.Space,{direction:"vertical",size:"small",children:[r.jsx(b.Button,{type:"text",onClick:e,children:o("Select Notified Person")}),r.jsx(b.Button,{type:"text",onClick:t,children:o("Query Notified Person")})]})},Oa=e=>{const{t}=Je(),[o,n]=x.useState(!1),a=x.useCallback(()=>{n(!0)},[n]);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:a,disabled:!1,children:t("Go to configure")}),r.jsx(s.ActionContextProvider,{value:{visible:o,setVisible:n,formValueChanged:!1},children:e.children})]})},Pa=e=>e.value&&typeof e.value=="object"?r.jsx(Ma,v({},e)):r.jsx(Ea,v({},e)),Ea=({value:e,onChange:t})=>{const o=me({types:[$a]});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})})},Ma=()=>{const e=A.useField(),t=s.useCollectionFilterOptions("users"),{token:o}=s.useToken();return r.jsx("div",{style:{border:`1px dashed ${o.colorBorder}`,padding:o.paddingSM},children:r.jsx(s.SchemaComponent,{basePath:e.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:t,dynamicComponent:Ae}}}}})})};function $a(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}const Ba=()=>{var d;const{workflow:e}=Y(),[t,o]=s.parseCollectionName((d=e.config)==null?void 0:d.collection),n=s.useSchemaInitializerItem(),{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:i}=s.useSchemaTemplateManager(),l=s.useRecordCollectionDataSourceItems("FormItem"),c=p=>P(null,[p],function*({item:u}){const f=u.template?yield i(u):null,y=s.createReadPrettyFormBlockSchema({actionInitializers:null,resource:o,collection:o,dataSource:t,template:f,settings:"blockSettings:details"});ae.unset(y,["x-acl-action","x-acl-action-props"]);const[h]=Object.keys(y.properties);ae.set(y.properties[h],"x-component-props.useProps","usePropsNoticeDetail"),a(y)});return r.jsx(s.SchemaInitializerItem,F(v({},n),{onClick:c,items:l}))},Va=new s.SchemaInitializer({name:"NoticeDetailInitializer",wrap:s.gridRowColWrap,title:"{{t('Add block')}}",items:[{name:"notice",type:"itemGroup",title:ce("Notice blocks"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Ba}]},{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){var c;const e=s.usePlugin(re),{workflow:t}=Y(),o=et(),n=he(),a=We(n),i=[(c=o.useInitializers)==null?void 0:c.call(o,t.config)].filter(Boolean),l=a.map(d=>{var p;const u=e.instructions.get(d.type);return(p=u==null?void 0:u.useInitializers)==null?void 0:p.call(u,d)}).filter(Boolean);return[...i,...l.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:l}]:[]].filter(Boolean)}},{name:"others",type:"itemGroup",title:'{{t("Other blocks")}}',children:[{name:"markdown",type:"item",title:'{{t("Demonstration text")}}',component:"MarkdownBlockInitializer"}]}]});class Wa extends s.Plugin{load(){return P(this,null,function*(){this.app.schemaInitializerManager.add(Va)})}}function ja(e){return{type:"void",name:e,"x-uid":e,"x-component":"Grid","x-initializer":"NoticeDetailInitializer"}}const La=e=>{const{schemaData:t,loading:o,handleChange:n}=za(e);return o?r.jsx(b.Spin,{}):r.jsx(s.SchemaComponent,{memoized:!0,scope:{},components:{},schema:t,onChange:n})};function za(e){const{value:t,onChange:o}=e,n=s.useAPIClient(),{values:a,setValuesIn:i}=A.useForm(),{data:l,loading:c}=s.useRequest(()=>P(null,null,function*(){if(t){const f=yield qa(n,t);if(f["x-uid"]===t)return f}const u=t!=null?t:W.uid(),p=ja(u);return yield Ua(n,p),o(u),p}));return{schemaData:l,loading:c,handleChange:u=>{}}}function qa(e,t){return P(this,null,function*(){var a;const{data:o}=yield e.request({url:`uiSchemas:getJsonSchema/${t}`});return(a=o.data)!=null?a:{}})}function Ua(e,t){return P(this,null,function*(){yield e.resource("uiSchemas").insert({values:t})})}const Ka={ActionStyle:s.css`
|
|
476
476
|
.ant-drawer-body {
|
|
477
477
|
background: var(--tb-box-bg);
|
|
478
478
|
}
|
|
479
|
-
`},
|
|
479
|
+
`},_a=()=>{const e=x.useContext(s.SchemaComponentContext),[,t]=x.useState(W.uid()),{workflow:o}=Y(),n=x.useMemo(()=>F(v({},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:La},schema:Ga})})},Ga={name:"drawer",type:"void",title:ce("The interface of show notice detail"),"x-component":"Action.Drawer","x-component-props":{className:Ka.ActionStyle},properties:{showNoticeDetail:{type:"string","x-component":"NoticeDetail"}}};s.createStyles({});const sn={ArrayItemsStyle:s.css`
|
|
480
480
|
&[disabled] {
|
|
481
481
|
> .ant-formily-array-base-addition {
|
|
482
482
|
display: none;
|
|
@@ -493,19 +493,19 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
493
493
|
> .ant-space-item:nth-child(2) {
|
|
494
494
|
flex-grow: 1;
|
|
495
495
|
}
|
|
496
|
-
`};class
|
|
496
|
+
`};class Ha extends oe{constructor(){super(...arguments),this.title=ce("Notice"),this.type=en,this.group=Ge,this.icon="MessageOutlined",this.color="#82e29c",this.description=ce("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:W.ArrayItems,SelectNotifiedPerson:Pa,AdditionNotifiedPerson:Na,ConfigButtonNotice:Oa,ShowNoticeDetail:_a},this.fieldset={notifiedPerson:{type:"array",title:ce("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:sn.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:sn.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:ce("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},showNoticeDetail:{type:"void",title:ce("Show Notice Detail"),required:!0,"x-decorator":"FormItem","x-component":"ConfigButtonNotice",properties:{showNoticeDetail:{type:"void","x-component":"ShowNoticeDetail"}}}}}isAvailable(t){return!0}}class Ja extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Wa)})}load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(en,Ha),this.app.addComponents({ArrayItems:W.ArrayItems})})}}const Ya={title:ce("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"}}]},Qa=A.observer(()=>{const{value:e}=A.useField(),t=s.useRecord();return r.jsx(Za,{value:e,record:t})},{displayName:"ColumnStatus"}),Za=e=>{const{value:t,record:o}=e,n=ae.omit(e,["value","record"]),a=s.useCompile(),{t:i}=Je(),{option:l=Xa[t]}=n,{workflow:c,execution:d,job:u}=o!=null?o:{};return(!(c!=null&&c.enabled)||d!=null&&d.stauts||u!=null&&u.status)&&[].includes(t)?r.jsx(b.Tag,{children:i("Unprocessed")}):r.jsx(b.Tag,{color:l==null?void 0:l.color,children:a(l==null?void 0:l.label)})},an=[{value:ye.QUEUEING,label:`{{t("Assigned", { ns: "${De}" })}}`,color:"blue"},{value:ye.STARTED,label:`{{t("Pending", { ns: "${De}" })}}`,color:"gold"},{value:2,label:`{{t("Approved", { ns: "${De}" })}}`,color:"green"},{value:ye.REJECTED,label:`{{t("Rejected", { ns: "${De}" })}}`,color:"red"}],Xa=an.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),Ra={title:ce("Notice Center"),name:eo,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:ce("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: "${De}" })}}`,"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:an}},{type:"text",name:"comment",interface:"markdown",uiSchema:{type:"string","x-component":"Markdown",title:`{{t("Comment", { ns: "${De}" })}}`}},{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:ce("Summary"),"x-component":"ApprovalsSummary","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}]},ei={title:ce("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}]}}]},ti=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const{collection:a,params:i={filter:{}},action:l="list"}=t,c=s.useRecord(),d={collection:a,resource:a,action:l,params:F(v({pageSize:20,sort:["-createdAt"]},i),{filter:c!=null&&c.id?v({dataKey:`${c.id}`},i.filter):v({},i.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(s.ExtendCollectionsProvider,{collections:[ei,Ya,Ra],children:r.jsx(s.TableBlockProvider,F(v({name:a},d),{children:e}))})},ln=x.createContext({}),oi=ln.Provider;function ni(){return x.useContext(ln)}const cn=x.createContext({}),ri=cn.Provider;function si(){return x.useContext(cn)}function ai(){const{snapshot:e}=si(),{form:t}=s.useFormBlockContext();return x.useEffect(()=>{t.setValues(e)},[t,e]),{form:t}}function dn({children:e,workflow:t,execution:o,nodes:n}){const a=s.usePlugin(re),i=a.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>{var u;return Object.assign(c,(u=a.instructions.get(d))==null?void 0:u.components)},{});return r.jsx(Ve.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(s.SchemaComponentOptions,{components:v(v({},i),l),children:e})})}const un=o=>{var n=o,{children:e}=n,t=Q(n,["children"]);const a=s.useSchemaComponentContext(),{t:i}=Je(),{id:l}=s.useCollectionRecordData(),{loading:c,data:d}=ii(l);if(c)return r.jsx(b.Spin,{});if(!(d!=null&&d.data))return r.jsx(b.Result,{status:"error",title:i("Submission may be withdrawn, please try refresh the list.")});const u=d.data,{node:p,workflow:f,execution:y}=u,h=p==null?void 0:p.config.showNoticeDetail,{designable:g}=t;return r.jsx(dn,{workflow:f,nodes:f.nodes,execution:y,children:r.jsx(ri,{value:u,children:r.jsx(oi,{value:{id:l,schemaId:h},children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:g}),children:e})})})})};function ii(e){const{loading:t,data:o}=s.useRequest({resource:eo,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 li=()=>r.jsx(un,{children:r.jsx(ci,{})}),ci=e=>{const{id:t,schemaId:o}=ni();return r.jsx(s.SchemaComponent,{components:{NoticeDetailProvider:un,RemoteSchemaComponent:s.RemoteSchemaComponent,SchemaComponentProvider:s.SchemaComponentProvider,DetailsBlockProvider:qt},scope:{usePropsNoticeDetail:ai,useDetailsBlockProps:s.useFormBlockContext},schema:{name:`content-${t}`,type:"void","x-component":"Tabs",properties:{detail:{type:"void",title:ce("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}}}}}}})},di=({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"}}}}}},ui=()=>{const e=s.useCollectionRecordData();return r.jsx(s.SchemaComponent,{components:{NoticeDetailContent:li},schema:di({record:e})})},pi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.title?t.title:t!=null&&t.id?`#${t.id}`:""},{displayName:"ColumnNode"}),mi=A.observer(()=>{const e=A.useField(),t=e==null?void 0:e.value;return t!=null&&t.nickname?t.nickname:(t==null?void 0:t.id)!==void 0?t.id:""},{displayName:"ColumnUser"}),fi=A.observer(()=>{const{t:e}=Je(),{value:t}=A.useField(),o=(t==null?void 0:t.title)||`#${t==null?void 0:t.id}`;return t!=null&&t.enabled?o:r.jsx("span",{className:s.css`
|
|
497
497
|
text-decoration: line-through;
|
|
498
|
-
`,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),
|
|
498
|
+
`,title:e("Disabled"),children:o})},{displayName:"ColumnWorkflow"}),gi={ActionbarStyle:s.css`
|
|
499
499
|
margin-bottom: 16px;
|
|
500
500
|
`,TableV2Style:s.css`
|
|
501
501
|
.ant-table-cell {
|
|
502
502
|
text-align: center;
|
|
503
503
|
}
|
|
504
|
-
`},
|
|
504
|
+
`},hi=()=>r.jsx(s.SchemaComponent,{components:{ColumnNode:pi,ColumnWorkflow:fi,ColumnUser:mi,ColumnStatus:Qa,ColumnAction:ui},schema:yi}),yi={type:"void",name:"notice-center",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{className:gi.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`
|
|
505
505
|
.ant-table-cell {
|
|
506
506
|
text-align: center;
|
|
507
507
|
}
|
|
508
|
-
`},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 Ri extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockProvider:Bi,NoticeCenter:Zi})})}}function Xo(){const e=M.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Zt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const ea=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=y.useCallback(()=>{const n=Xo();e(n)},[e,Xo]);return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:o}))};class ta extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Ri)})}load(){return D(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:ea}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ie("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class oa extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(Ni),yield this.app.pm.add(ta)})}}class na 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=A.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=me(I(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:T("User acted")}}],compile:n,getCollectionFields:i}));return[...me({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:T("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:T("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 ra=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,I(v({},e),{schema:sa,item:e}))},sa={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"}},ia=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],aa=new s.SchemaSettings({name:"actionSettings:APIRegular",items:ia}),la=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=A.useFieldSchema(),a=y.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:p}=Q.useTranslation();re.useNavigate(),s.useCompile();const d=A.useField(),{modal:u,notification:f}=b.App.useApp(),g=s.useVariables(),{name:h,getField:x}=s.useCollection_deprecated(),C=s.useLocalVariables(),{run:k}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",w=>{var O,V;if(w.msg==="start")f.info({key:"workflow:regular",message:p("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(w.msg==="progress"){const $=w.current+1,P=Math.floor($/w.total*100)===100?3:0,B=`[${((O=w.loopData)==null?void 0:O.loopIndex)||""}/${((V=w.loopData)==null?void 0:V.loopLength)||""}]`;f.info({key:"workflow:regular",message:`${p("Processing")}${w.loopData?B:""}...`,description:r.jsx(b.Progress,{percent:Math.floor($/w.total*100)}),duration:P})}else w.msg==="done"&&(f.success({key:"workflow:regular",message:p("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return D(this,null,function*(){var Y,ae,W,L,E,R,G;const w=(L=(W=(ae=(Y=l.field)==null?void 0:Y.data)==null?void 0:ae.selectedRowKeys)!=null?W:a==null?void 0:a.selectedRecordKeys)!=null?L:[],{filter:O}=(R=(E=n.params)==null?void 0:E[0])!=null?R:{},{bindWorkflow:V=!1,triggerWorkflows:$=!1,assignedValues:P={},updateMode:B}=(G=i==null?void 0:i["x-action-settings"])!=null?G:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:w};if(d.data=e.data||{},d.data.loading=!0,!$&&!V)return u.info({title:T("Not bind workflow!")});const J=Object.keys(P).map(oe=>D(null,null,function*(){const se=P[oe],Ue=x(oe);if(s.isVariable(se)){const we=yield g==null?void 0:g.parseVariable(se,C);we&&s.transformVariableValue(we,{targetCollectionField:Ue})}}));yield Promise.all(J),u.confirm({title:T("Confirm",{ns:"core"}),content:T("Trigger workflow?"),onOk(){return D(this,null,function*(){if(V){const oe={filterByTk:V,updateData:encodeURIComponent(JSON.stringify(z))};k(oe)}else $&&(_?yield t.trigger({filterByTk:w,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}):yield t.trigger({filter:O,triggerWorkflows:s.getAfterWorkflows($),beforeWorkflows:s.getBeforeWorkflows($)}));d.data.loading=!1})},onCancel(){return D(this,null,function*(){d.data.loading=!1})}})})}}};class ca extends s.Plugin{load(){return D(this,null,function*(){this.app.addComponents({APIRegularInitializer:ra}),this.app.addScopes({usePropsAPIRegular:la}),this.app.schemaSettingsManager.add(aa),["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 da(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=re.useNavigate(),c=A.useFieldSchema(),p=A.useField(),d=s.useCompile(),{modal:u}=b.App.useApp(),f=s.useCollectValuesToSubmit();return p.componentProps.filterKeys,{onClick(){return D(this,null,function*(){var F,w;const{onSuccess:h,skipValidator:x,triggerWorkflows:C}=(c==null?void 0:c["x-action-settings"])||{};x||(yield e.submit());const k=yield f();p.data=t.data||{},p.data.loading=!0;try{const O=yield n.trigger({values:k,filterByTk:a,triggerWorkflows:s.getAfterWorkflows(C),beforeWorkflows:s.getBeforeWorkflows(C)});if(p.data.data=O,(w=(F=o==null?void 0:o.service)==null?void 0:F.refresh)==null||w.call(F),i==null||i(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?u.success({title:d(h==null?void 0:h.successMessage),onOk:()=>D(null,null,function*(){return yield e.reset(),(h==null?void 0:h.redirecting)&&(h==null?void 0:h.redirectTo)&&(M.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(O){console.error(O)}finally{p.data.loading=!1}})}}}function pa(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:p}=b.App.useApp(),d=re.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(h,x){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)}),x==null||x(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?p.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(M.isURL(u.redirectTo)?window.location.href=u.redirectTo:d(u.redirectTo))}}):b.message.success(e(u==null?void 0:u.successMessage))}catch(C){console.error(C)}finally{o.data.loading=!1}})}}}const Xt={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"}},Rt=I(v({},vt),{schema:I(v({},vt.schema),{"x-component":"Action.Link"})});class ua extends s.Plugin{afterAdd(){return D(this,null,function*(){yield this.app.pm.add(ca)})}load(){return D(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",na),this.app.addScopes({useFormWorkflowCustomActionProps:da,useRecordWorkflowCustomTriggerActionProps:pa}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Xt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Xt),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",Rt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Rt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Rt)})}}class ma 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}=be(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((x,C)=>C.upstreamId===n&&C.branchIndex!=null?x.concat(C):x,[]).sort((x,C)=>x.branchIndex-C.branchIndex),[p,d]=y.useState(Math.max(2,c.length)),{getAriaLabel:u}=ut(t),f=T("Add branch"),g=Array(Math.max(0,p-c.length)).fill(null),h=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(x=>r.jsx(Ve,{from:t,entry:x,branchIndex:x.branchIndex},x.id)),g.map((x,C)=>r.jsx(Ve,{from:t,branchIndex:(h?h.branchIndex:0)+C+1,controller:c.length+C>1?r.jsx("div",{className:s.css`
|
|
508
|
+
`},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:ce("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:ce("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:ce("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: "${De}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class xi extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockProvider:ti,NoticeCenter:hi})})}}function pn(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:eo,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 bi=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=x.useCallback(()=>{const n=pn();e(n)},[e,pn]);return r.jsx(s.SchemaInitializerItem,F(v({},t),{onClick:o}))};class vi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(xi)})}load(){return P(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:bi}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ce("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class wi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Ja),yield this.app.pm.add(vi)})}}class Ci extends Re{constructor(){super(...arguments),this.title=T("General event"),this.description=T("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:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("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:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.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:a}=s.useCollectionManager_deprecated(),i=fe(F(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:O("User acted")}}],compile:n,getCollectionFields:a}));return[...fe({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:O("Trigger data")}}],compile:n,getCollectionFields:a}),...i,{label:O("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:T("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const ki=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,F(v({},e),{schema:Si,item:e}))},Si={type:"void",title:T("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"}},Ai=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Ii=new s.SchemaSettings({name:"actionSettings:APIRegular",items:Ai}),Fi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),a=A.useFieldSchema(),i=x.useContext(A.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=ee.useTranslation();se.useNavigate(),s.useCompile();const u=A.useField(),{modal:p,notification:f}=b.App.useApp(),y=s.useVariables(),{name:h,getField:g}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:C}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",S=>{var I,M;if(S.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(b.Progress,{percent:0}),duration:0});else if(S.msg==="progress"){const E=S.current+1,N=Math.floor(E/S.total*100)===100?3:0,V=`[${((I=S.loopData)==null?void 0:I.loopIndex)||""}/${((M=S.loopData)==null?void 0:M.loopLength)||""}]`;f.info({key:"workflow:regular",message:`${d("Processing")}${S.loopData?V:""}...`,description:r.jsx(b.Progress,{percent:Math.floor(E/S.total*100)}),duration:N})}else S.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(b.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return P(this,null,function*(){var j,X,B,L,$,U,J;const S=(L=(B=(X=(j=l.field)==null?void 0:j.data)==null?void 0:X.selectedRowKeys)!=null?B:i==null?void 0:i.selectedRecordKeys)!=null?L:[],{filter:I}=(U=($=n.params)==null?void 0:$[0])!=null?U:{},{bindWorkflow:M=!1,triggerWorkflows:E=!1,assignedValues:N={},updateMode:V}=(J=a==null?void 0:a["x-action-settings"])!=null?J:{},K=V==="selected",q={primaryKey:c||"id",targetKeys:S};if(u.data=e.data||{},u.data.loading=!0,!E&&!M)return p.info({title:O("Not bind workflow!")});const G=Object.keys(N).map(R=>P(null,null,function*(){const z=N[R],de=g(R);if(s.isVariable(z)){const te=yield y==null?void 0:y.parseVariable(z,w);te&&s.transformVariableValue(te,{targetCollectionField:de})}}));yield Promise.all(G),p.confirm({title:O("Confirm",{ns:"core"}),content:O("Trigger workflow?"),onOk(){return P(this,null,function*(){if(M){const R={filterByTk:M,updateData:encodeURIComponent(JSON.stringify(q))};C(R)}else E&&(K?yield t.trigger({filterByTk:S,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}):yield t.trigger({filter:I,triggerWorkflows:s.getAfterWorkflows(E),beforeWorkflows:s.getBeforeWorkflows(E)}));u.data.loading=!1})},onCancel(){return P(this,null,function*(){u.data.loading=!1})}})})}}};class Ti extends s.Plugin{load(){return P(this,null,function*(){this.app.addComponents({APIRegularInitializer:ki}),this.app.addScopes({usePropsAPIRegular:Fi}),this.app.schemaSettingsManager.add(Ii),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:T("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 Ni(){const e=A.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:a}=s.useActionContext(),i=s.useFilterByTk(),l=se.useNavigate(),c=A.useFieldSchema(),d=A.useField(),u=s.useCompile(),{modal:p}=b.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return P(this,null,function*(){var D,S;const{onSuccess:h,skipValidator:g,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};g||(yield e.submit());const C=yield f();d.data=t.data||{},d.data.loading=!0;try{const I=yield n.trigger({values:C,filterByTk:i,triggerWorkflows:s.getAfterWorkflows(w),beforeWorkflows:s.getBeforeWorkflows(w)});if(d.data.data=I,(S=(D=o==null?void 0:o.service)==null?void 0:D.refresh)==null||S.call(D),a==null||a(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:u(h==null?void 0:h.successMessage),onOk:()=>P(null,null,function*(){return yield e.reset(),(h==null?void 0:h.redirecting)&&(h==null?void 0:h.redirectTo)&&(W.isURL(h.redirectTo)?window.location.href=h.redirectTo:l(h.redirectTo))})}):b.message.success(u(h==null?void 0:h.successMessage))}catch(I){console.error(I)}finally{d.data.loading=!1}})}}}function Di(){const e=s.useCompile(),t=s.useFilterByTk(),o=A.useField(),n=A.useFieldSchema(),{field:a,resource:i}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=b.App.useApp(),u=se.useNavigate(),{onSuccess:p,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(h,g){return P(this,null,function*(){o.data=a.data||{},o.data.loading=!0;try{if(yield i.trigger({filterByTk:t,triggerWorkflows:s.getAfterWorkflows(f),beforeWorkflows:s.getBeforeWorkflows(f)}),g==null||g(),l==null||l(!1),c==null||c(!0),!(p!=null&&p.successMessage))return;p!=null&&p.manualClose?d.success({title:e(p==null?void 0:p.successMessage),onOk(){p!=null&&p.redirecting&&(p!=null&&p.redirectTo)&&(W.isURL(p.redirectTo)?window.location.href=p.redirectTo:u(p.redirectTo))}}):b.message.success(e(p==null?void 0:p.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const to={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("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:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},St={name:"triggerWorkflow",title:T("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:T("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:T("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},oo=F(v({},St),{schema:F(v({},St.schema),{"x-component":"Action.Link"})});class Oi extends s.Plugin{afterAdd(){return P(this,null,function*(){yield this.app.pm.add(Ti)})}load(){return P(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Ci),this.app.addScopes({useFormWorkflowCustomActionProps:Ni,useRecordWorkflowCustomTriggerActionProps:Di}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",to),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",St),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",oo),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",oo)})}}class Pi extends oe{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:Ne}}Component({data:t}){const{styles:o}=we(),{id:n,config:{mode:a}}=t,{workflow:i,nodes:l}=Y(),c=l.reduce((g,w)=>w.upstreamId===n&&w.branchIndex!=null?g.concat(w):g,[]).sort((g,w)=>g.branchIndex-w.branchIndex),[d,u]=x.useState(Math.max(2,c.length)),{getAriaLabel:p}=ft(t),f=O("Add branch"),y=Array(Math.max(0,d-c.length)).fill(null),h=c[c.length-1];return r.jsx(it,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(g=>r.jsx(je,{from:t,entry:g,branchIndex:g.branchIndex},g.id)),y.map((g,w)=>r.jsx(je,{from:t,branchIndex:(h?h.branchIndex:0)+w+1,controller:c.length+w>1?r.jsx("div",{className:s.css`
|
|
509
509
|
padding-top: 2em;
|
|
510
510
|
|
|
511
511
|
> button {
|
|
@@ -513,9 +513,9 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
513
513
|
transform: rotate(45deg);
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
`,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(
|
|
517
|
-
visibility: ${
|
|
518
|
-
`,children:r.jsx(b.Button,{"aria-label":
|
|
516
|
+
`,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(H.PlusOutlined,{}),onClick:()=>u(d-1),disabled:i.executed})}):null},`temp_${c.length+w}`))]}),r.jsx(b.Tooltip,{title:f,className:s.css`
|
|
517
|
+
visibility: ${i.executed?"hidden":"visible"};
|
|
518
|
+
`,children:r.jsx(b.Button,{"aria-label":p("add-branch"),icon:r.jsx(H.PlusOutlined,{}),className:s.css`
|
|
519
519
|
position: relative;
|
|
520
520
|
top: 1em;
|
|
521
521
|
transform-origin: center;
|
|
@@ -525,18 +525,30 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
|
|
|
525
525
|
transform-origin: center;
|
|
526
526
|
transform: rotate(-45deg);
|
|
527
527
|
}
|
|
528
|
-
`,onClick:()=>d
|
|
528
|
+
`,onClick:()=>u(d+1),disabled:i.executed})})]})})}}class Ei extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction("parallel",Pi)})}}class Mi extends oe{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:W.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:at,WorkflowVariableJSON:$o}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class $i extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Mi)})}}class Bi extends oe{constructor(){super(...arguments),this.title=T("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=T("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:T("Message content"),description:T("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:Ne,WorkflowVariableTextArea:at,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class Vi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Bi)})}}const{TextArea:Wi}=b.Input,ji=A.connect(n=>{var a=n,{value:e,onChange:t}=a,o=Q(a,["value","onChange"]);var S;const i=A.useForm(),l=x.useRef(null),[c,d]=x.useState(null),[u,p]=x.useState(!1),[f,y]=x.useState(null),h=(S=i.values)==null?void 0:S.codeSource,g=h==="remote";x.useEffect(()=>{const I=setTimeout(()=>{!l.current&&!u&&(console.warn("[ScriptCodeEditor] Monaco Editor failed to load within timeout, using fallback TextArea"),p(!0))},5e3);return y(I),()=>{I&&clearTimeout(I)}},[u]);const w=x.useCallback(I=>{f&&(clearTimeout(f),y(null)),l.current=I,d(null),p(!1)},[f]),C=x.useMemo(()=>({lineNumbers:"on",minimap:{enabled:!1},readOnly:g,quickSuggestions:g?!1:{other:!0,comments:!0,strings:!0},suggestOnTriggerCharacters:!g,acceptSuggestionOnCommitCharacter:!g,acceptSuggestionOnEnter:g?"off":"on",tabCompletion:g?"off":"on",wordBasedSuggestions:g?"off":"allDocuments",snippetSuggestions:g?"none":"top",autoIndent:g?"none":"full",formatOnPaste:!g,formatOnType:!g,codeLens:!g,folding:!0,bracketPairColorization:{enabled:!g},suggest:{showKeywords:!g,showSnippets:!g,showClasses:!g,showFunctions:!g,showVariables:!g,showModules:!g,showProperties:!g,showReferences:!g,showValues:!g,showEnums:!g,showEnumMembers:!g,showEvents:!g,showOperators:!g,showUnits:!g,showColors:!g,showFiles:!g,showTypeParameters:!g,showIssues:!g,showUsers:!g,showFolders:!g}}),[g]);x.useEffect(()=>{var M;const I=l.current;if(I)if(typeof I.updateOptions=="function")I.updateOptions(C);else{const E=((M=I.getEditor)==null?void 0:M.call(I))||I;E&&typeof E.updateOptions=="function"&&E.updateOptions(C)}},[h,g,C]);const D=(I="")=>{g||t(I)};if(x.useCallback(I=>{console.error("[ScriptCodeEditor] Monaco Editor error:",I),d(I),p(!0)},[]),u||c){const I=o.height||"50vh",M=typeof I=="string"?I:`${I}px`;return r.jsxs("div",{className:s.css`
|
|
529
|
+
display: flex;
|
|
530
|
+
flex-direction: column;
|
|
531
|
+
height: ${M};
|
|
532
|
+
`,children:[c&&r.jsx(b.Alert,{message:T("Code editor failed to load"),description:T("Monaco Editor failed to load, downgraded to basic text editor. Some features may be limited."),type:"warning",showIcon:!0,closable:!0,onClose:()=>d(null),className:s.css`
|
|
533
|
+
margin-bottom: 8px;
|
|
534
|
+
`}),r.jsx(Wi,v({value:e||"",onChange:E=>D(E.target.value),readOnly:g,placeholder:T("Please enter code..."),style:{height:`calc(${M} - ${c?"60px":"0px"})`,fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',fontSize:"14px",lineHeight:"1.5",resize:"none"}},o))]})}return x.useEffect(()=>{const I=E=>{var N,V,K,q,G;((N=E.message)!=null&&N.includes("monaco")||(V=E.message)!=null&&V.includes("Monaco")||(K=E.filename)!=null&&K.includes("monaco")||(q=E.filename)!=null&&q.includes("vs/")||(G=E.filename)!=null&&G.includes("loader.js"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor error, will use fallback:",E.message),p(!0))},M=E=>{const N=E.reason,V=(N==null?void 0:N.message)||String(N);(V.includes("monaco")||V.includes("Monaco")||V.includes("loader"))&&(console.warn("[ScriptCodeEditor] Detected Monaco Editor promise rejection, will use fallback:",V),p(!0))};return window.addEventListener("error",I),window.addEventListener("unhandledrejection",M),()=>{window.removeEventListener("error",I),window.removeEventListener("unhandledrejection",M)}},[]),r.jsx(W.CodeEditor,v({defaultLanguage:"typescript",value:e,onChange:D,options:C,height:o.height||"50vh",onMount:w,loading:r.jsx("div",{className:s.css`
|
|
535
|
+
display: flex;
|
|
536
|
+
align-items: center;
|
|
537
|
+
justify-content: center;
|
|
538
|
+
height: ${typeof o.height=="string"?o.height:o.height||"50vh"};
|
|
539
|
+
color: #999;
|
|
540
|
+
`,children:T("Loading editor...")})},o))}),{Text:no}=b.Typography,Ye={primary:"#52c41a",hover:"#73d13d"},Li=()=>{var g,w,C,D,S;const e=A.useForm(),t=s.useAPIClient(),o=he(),[n,a]=x.useState(!1),[i,l]=x.useState(!1),c=x.useRef(null),d=(g=e.values)==null?void 0:g.codeSource,u=(w=e.values)==null?void 0:w.codeType;(C=e.values)==null||C.codeUrl;const p=((D=e.values)==null?void 0:D.code)||"",f=(S=e.values)!=null&&S.lastSyncTime?new Date(e.values.lastSyncTime):null,y=x.useCallback((I=!1)=>P(null,null,function*(){var X,B,L,$,U,J;const M=e.values||{},{codeSource:E,codeType:N,codeUrl:V,codeBranch:K="main",codeAuthType:q="token",codeAuthToken:G,codeAuthUsername:j}=M;if(!(E!=="remote"||!N||!V)){I||a(!0);try{const _=yield t.request({resource:"flow_nodes",action:"syncRemoteCode",params:{values:{codeUrl:V,codeType:N,codeBranch:N==="git"?K:void 0,codeAuthType:q,codeAuthToken:G,codeAuthUsername:j,nodeId:o==null?void 0:o.id}}}),R=((X=_==null?void 0:_.data)==null?void 0:X.code)||((L=(B=_==null?void 0:_.data)==null?void 0:B.data)==null?void 0:L.code);R?(e.setValues(F(v({},e.values),{code:R,lastSyncTime:new Date().toISOString()})),c.current=R,l(!0),I||b.message.success(O("Code synced successfully"))):I||b.message.error(O("No code returned from remote source"))}catch(_){if(!I){const R=((J=(U=($=_==null?void 0:_.response)==null?void 0:$.data)==null?void 0:U.error)==null?void 0:J.message)||(_==null?void 0:_.message)||O("Failed to sync remote code");b.message.error(R)}}finally{I||a(!1)}}}),[e,t,o==null?void 0:o.id]),h=()=>P(null,null,function*(){const I=e.values||{},M=I.codeSource,E=I.codeType,N=I.codeUrl;if(M!=="remote"){b.message.warning(O("Please select remote code source first"));return}if(!E){b.message.warning(O("Please select code type first"));return}if(!N||!N.trim()){b.message.warning(O("Code URL is required for Git"));return}yield y(!1)});return x.useEffect(()=>{c.current!==null?l(p===c.current):l(!1)},[p]),d!=="remote"||!u?null:r.jsxs("div",{style:{marginBottom:8},children:[r.jsx(b.Button,{type:"primary",icon:r.jsx(s.Icon,{type:"SyncOutlined"}),loading:n,onClick:h,style:{backgroundColor:Ye.primary,borderColor:Ye.primary,marginBottom:4},onMouseEnter:I=>{I.currentTarget.style.backgroundColor=Ye.hover,I.currentTarget.style.borderColor=Ye.hover},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=Ye.primary,I.currentTarget.style.borderColor=Ye.primary},children:O("Sync remote code")}),r.jsx("div",{children:r.jsxs(no,{type:"secondary",style:{fontSize:12},children:[O("Last sync time"),":"," ",f?r.jsx(no,{type:"success",children:mt(f).format("YYYY-MM-DD HH:mm:ss")}):r.jsx(no,{type:"secondary",children:"-"})]})})]})};class zi extends oe{constructor(){super(...arguments),this.title=T("Data Mapping"),this.type=So,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=T("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
529
541
|
> *:not(:last-child) {
|
|
530
542
|
margin-right: 0.5em;
|
|
531
543
|
}
|
|
532
544
|
button {
|
|
533
545
|
padding: 0;
|
|
534
546
|
}
|
|
535
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:
|
|
547
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}},type:{type:"string",title:T("type"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Cloud Component"),value:"ts"},{label:T("JSONata"),value:"jsonata"}],default:"ts"},codeSource:{type:"string",title:T("Code source"),"x-decorator":"FormItem","x-component":"Radio.Group",default:"local",enum:[{label:T("Local code"),value:"local"},{label:T("Remote code"),value:"remote"}]},codeType:{type:"string",title:T("Code type"),"x-decorator":"FormItem","x-component":"Radio.Group",default:"git",enum:[{label:T("Git"),value:"git"},{label:T("CDN"),value:"cdn"}],"x-reactions":[{dependencies:["codeSource"],fulfill:{state:{visible:'{{$deps[0] === "remote"}}'}}}]},codeUrl:{type:"string",title:T("Code URL"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:T("Code URL placeholder")},"x-reactions":[{dependencies:["codeSource","codeType"],fulfill:{state:{visible:'{{$deps[0] === "remote"}}',required:'{{$deps[0] === "remote" && $deps[1] === "git"}}'},schema:{"x-validator":'{{$deps[0] === "remote" && $deps[1] === "git" ? [{ required: true, message: tval("Code URL is required for Git") }] : []}}'}}}]},codeBranch:{type:"string",title:T("Code branch"),"x-decorator":"FormItem","x-component":"Input",default:"main","x-component-props":{placeholder:T("Code branch placeholder")},"x-reactions":[{dependencies:["codeSource","codeType"],fulfill:{state:{visible:'{{$deps[0] === "remote" && $deps[1] === "git"}}'}}}]},syncRemoteCodeButton:{type:"void","x-component":"SyncRemoteCodeButton","x-reactions":[{dependencies:["codeSource","codeType"],fulfill:{state:{visible:'{{$deps[0] === "remote" && $deps[1]}}'}}}]},codeAuthType:{type:"string",title:T("Authentication type"),"x-decorator":"FormItem","x-component":"Radio.Group",default:"token",enum:[{label:T("No authentication"),value:"none"},{label:T("Bearer Token"),value:"token"},{label:T("Basic Auth"),value:"basic"}],"x-reactions":[{dependencies:["codeSource"],fulfill:{state:{visible:'{{$deps[0] === "remote"}}'}}}]},codeAuthToken:{type:"string",title:T("Auth token"),"x-decorator":"FormItem","x-component":"Input.Password","x-component-props":{placeholder:T("Auth token placeholder")},"x-reactions":[{dependencies:["codeSource","codeAuthType"],fulfill:{state:{visible:'{{$deps[0] === "remote" && ($deps[1] === "token" || $deps[1] === "basic")}}'}}}]},codeAuthUsername:{type:"string",title:T("Auth username"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:T("Auth username placeholder")},"x-reactions":[{dependencies:["codeSource","codeAuthType"],fulfill:{state:{visible:'{{$deps[0] === "remote" && $deps[1] === "basic"}}'}}}]},code:{type:"string",title:T("expression"),"x-decorator":"FormItem","x-component":"ScriptCodeEditor","x-component-props":{defaultLanguage:"typescript",height:"50vh",defaultValue:`
|
|
536
548
|
import { Context, MagicAttributeModel, Transactionable } from '@tego/server';
|
|
537
549
|
|
|
538
550
|
export default async function (
|
|
539
|
-
_data
|
|
551
|
+
_data: any | Array<any>,
|
|
540
552
|
{
|
|
541
553
|
httpContext: ctx,
|
|
542
554
|
dbModel: model,
|
|
@@ -546,30 +558,44 @@ export default async function (
|
|
|
546
558
|
) {
|
|
547
559
|
return {};
|
|
548
560
|
}
|
|
549
|
-
`.trim()}},model:{type:"array",title:
|
|
561
|
+
`.trim()}},model:{type:"array",title:T("Properties mapping"),description:T("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:T("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:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
550
562
|
> *:not(:last-child) {
|
|
551
563
|
margin-right: 0.5em;
|
|
552
564
|
}
|
|
553
565
|
button {
|
|
554
566
|
padding: 0;
|
|
555
567
|
}
|
|
556
|
-
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:
|
|
568
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke,SyncRemoteCodeButton:Li,ScriptCodeEditor:ji}}useVariables(t,o){const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o,d=i.model||[];return{[c.label]:a,[c.value]:n,[c.children]:d.map(p=>({[c.label]:p.label,[c.value]:p.alias||p.path}))}}}class qi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get(re).registerInstruction(So,zi)})}}class Ui extends oe{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
569
|
font-size: 80%;
|
|
558
570
|
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:
|
|
571
|
+
`}},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:Mo}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return{[a.value]:t,[a.label]:o}}}class Ki extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",Ui)})}}const _i=()=>{const{workflow:e}=Y();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class Gi extends oe{constructor(){super(...arguments),this.title=T("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={sourceArray:{type:"array",title:T("Data source map"),description:T("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
572
|
+
> *:not(:last-child) {
|
|
573
|
+
margin-right: 0.5em;
|
|
574
|
+
}
|
|
575
|
+
button {
|
|
576
|
+
padding: 0;
|
|
577
|
+
}
|
|
578
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}},workflowKey:{type:"string",title:T("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":_i,required:!0},bindCollection:{type:"boolean",title:T("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:T("Yes"),value:!0},{label:T("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:T("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:T("Associations to use"),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."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=A.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},model:{type:"array",title:T("Properties mapping"),description:T("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:T("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:T("Alias")},properties:{alias:{type:"string",name:"alias","x-decorator":"FormItem","x-component":"Input"}}},label:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:T("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`
|
|
579
|
+
> *:not(:last-child) {
|
|
580
|
+
margin-right: 0.5em;
|
|
581
|
+
}
|
|
582
|
+
button {
|
|
583
|
+
padding: 0;
|
|
584
|
+
}
|
|
585
|
+
`},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:T("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:W.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){var f;const{key:n,title:a,config:i}=t,{types:l,fieldNames:c}=o;if(i.model&&Array.isArray(i.model)&&i.model.length>0)return{[c.label]:a,[c.value]:n,[c.children]:i.model.map(y=>({[c.label]:y.label,[c.value]:y.alias||y.path}))};const d=s.useCompile(),{getCollectionFields:u}=s.useCollectionManager_deprecated(),[p]=fe(F(v({appends:[n,...((f=i.appends)==null?void 0:f.map(y=>`${n}.${y}`))||[]]},o),{fields:[{collectionName:i.collection,name:n,type:"hasOne",target:i.collection,uiSchema:{title:a}}],compile:d,getCollectionFields:u}));return p}}class Hi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",Gi)})}}const Ji=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
|
|
560
586
|
color: ${t.colorTextDescription};
|
|
561
587
|
|
|
562
588
|
&:before {
|
|
563
589
|
content: '#';
|
|
564
590
|
}
|
|
565
|
-
`}));function
|
|
591
|
+
`}));function Yi({value:e,onChange:t}){const o=e==null,n=he(),a=We(n,d=>d.type==="variable"&&!d.config.target),{styles:i}=Ji(),l=x.useCallback(({target:d})=>{if(d.value)return t(null);a.length&&t(a[0].key)},[t,a]),c=x.useCallback((d,u)=>u.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${u.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(b.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(b.Radio,{value:!0,children:O("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(b.Radio,{value:!1,disabled:!a.length,children:O("Assign value to an existing variable")}),!o&&r.jsx(b.Select,{options:a.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:u})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:i.nodeIdClass,children:u.data.id})]})})]})]})})})}class Qi extends oe{constructor(){super(...arguments),this.title=T("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=T("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:T("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:T("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:Yi}}useVariables({key:t,title:o,config:n},{types:a,fieldNames:i=xe}){return n.target?null:{[i.value]:t,[i.label]:o}}}class Zi extends s.Plugin{load(){return P(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",Qi)})}}const mn=e=>{const t=W.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
|
|
566
592
|
&:after {
|
|
567
593
|
content: ':';
|
|
568
594
|
}
|
|
569
595
|
& + a {
|
|
570
596
|
margin-left: 0.25em;
|
|
571
597
|
}
|
|
572
|
-
`,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class
|
|
598
|
+
`,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Xi extends oe{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":{getOptions:W.getOptions},required:!0,default:"formula.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:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("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:mn},this.components={WorkflowVariableTextArea:at,RadioWithTooltip:Ne,ValueBlock:Ie}}useVariables({key:t,title:o},{types:n,fieldNames:a=xe}){return n&&!n.some(i=>i in Pe||Object.values(Pe).some(l=>l.has(i)))?null:{[a.value]:t,[a.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:Ie.Initializer,node:t,resultTitle:O("Calculation result")}}}const Ri=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:a,children:i}=e,[l,c]=x.useState(!1),d=x.useMemo(()=>{const p=ae.cloneDeep(n.config);return A.createForm({initialValues:p,disabled:a.executed})},[n,a]),u=x.useCallback(p=>{o(p),p||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:u,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:i})})};function el(){return{form:A.useForm()}}function tl(){const e=A.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),a=he(),{workflow:i}=Y();return{run(){return P(this,null,function*(){var c,d;if(i.executed){b.message.error(O("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:a.id,values:{config:e.values}}),o.setFormValueChanged(!1),b.message.success("success"),n()})}}}const ol=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ge;return r.jsxs("div",{className:s.css`
|
|
573
599
|
display: flex;
|
|
574
600
|
justify-content: space-between;
|
|
575
601
|
|
|
@@ -584,7 +610,7 @@ export default async function (
|
|
|
584
610
|
code {
|
|
585
611
|
font-weight: normal;
|
|
586
612
|
}
|
|
587
|
-
`,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",
|
|
613
|
+
`,children:[r.jsxs("strong",{children:[n&&r.jsxs("span",{className:"deprecated-tag",children:["(",O("Deprecated"),") "]}),t.title]}),r.jsxs(b.Tooltip,{title:O("Variable key of node"),children:[r.jsx(b.Tag,{children:r.jsx("code",{children:`id: ${t.id}`})}),r.jsx(b.Tag,{children:r.jsx("code",{children:`key: ${t.key}`})})]})]})};function nl(e,t){return r.jsx(ol,{data:e,instruction:t})}const rl=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e;return{type:"void",properties:F(v({},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:nl(o,t),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Area","x-component-props":{stickyFooter:!0},properties:F(v({actions:a.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:i}=s.useTranslation();return{run(){return P(this,null,function*(){const c=new Blob([JSON.stringify(o,(d,u)=>{if(!(d==="upstream"||d==="downstream"))return u},2)],{type:"application/json"});Ia(c,o.title+"-"+o.key+".json"),b.message.success(i("Operation succeeded"))})}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:tl}}}}},t.description?{description:{type:"void","x-component":wo,"x-component-props":{label:O("Node type"),title:t.title,description:t.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
|
|
588
614
|
.ant-input,
|
|
589
615
|
.ant-select,
|
|
590
616
|
.ant-cascader-picker,
|
|
@@ -596,7 +622,7 @@ export default async function (
|
|
|
596
622
|
min-width: 6em;
|
|
597
623
|
}
|
|
598
624
|
}
|
|
599
|
-
`},properties:t.fieldset}})}})}},
|
|
625
|
+
`},properties:t.fieldset}})}})}},sl=e=>{const{instruction:t,data:o,detailText:n,workflow:a}=e,i=x.useMemo(()=>rl({instruction:t,data:o,detailText:n,workflow:a}),[t,o,n,a]);return r.jsx(s.SchemaComponent,{schema:i,components:t.components,scope:F(v({},t.scope),{useFormProviderProps:el})})},al=e=>{const{instruction:t,data:o,detailText:n,workflow:a,editingConfig:i,setEditingConfig:l}=e;return r.jsx(Ri,{editingConfig:i,setEditingConfig:l,data:o,workflow:a,children:r.jsx(sl,{instruction:t,data:o,detailText:n,workflow:a})})},il=s.createStyles(({css:e,token:t})=>({nodeClass:e`
|
|
600
626
|
flex-shrink: 0;
|
|
601
627
|
display: flex;
|
|
602
628
|
flex-direction: column;
|
|
@@ -629,7 +655,7 @@ export default async function (
|
|
|
629
655
|
padding: 0;
|
|
630
656
|
display: none;
|
|
631
657
|
}
|
|
632
|
-
`})),
|
|
658
|
+
`})),ll=()=>{var c;const e=s.useAPIClient(),{workflow:t,nodes:o,refresh:n}=(c=Y())!=null?c:{},a=he();if(!t)return null;const i=e.resource("flow_nodes");function l(){return P(this,null,function*(){var d;yield(d=i.moveUp)==null?void 0:d.call(i,{filterByTk:a.id}),n()})}return r.jsx(b.Button,{className:"workflow-node-drag-button",type:"text",shape:"circle",icon:r.jsx(H.HolderOutlined,{}),onClick:l})},cl=s.createStyles(({css:e,token:t})=>({dropdownClass:e`
|
|
633
659
|
background-color: red;
|
|
634
660
|
max-height: 50vh;
|
|
635
661
|
overflow-y: auto;
|
|
@@ -651,7 +677,7 @@ export default async function (
|
|
|
651
677
|
display: inline-flex;
|
|
652
678
|
justify-content: center;
|
|
653
679
|
align-items: center;
|
|
654
|
-
`})),
|
|
680
|
+
`})),dl=()=>{var i;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(i=he())!=null?i:{},{styles:n}=cl();if(!e)return null;if(!o.length)return r.jsx(tt,{className:n.nodeJobButtonClass,disabled:!0});const a=l=>{const{key:c}=l,d=o.find(u=>u.id===+c);t(d)};return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(tt,{statusMap:ot,status:l.status}),r.jsx("time",{children:W.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),className:n.dropdownClass,onClick:a},children:r.jsx(tt,{statusMap:ot,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(tt,{statusMap:ot,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})},ul=()=>{var u;const{t:e}=ee.useTranslation(),t=s.useAPIClient(),{workflow:o,nodes:n,refresh:a}=(u=Y())!=null?u:{},i=he(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return P(this,null,function*(){function p(){return P(this,null,function*(){var g;yield(g=c.destroy)==null?void 0:g.call(c,{filterByTk:i.id}),a()})}const f=n.filter(g=>g===i?!1:W.parse(g.config).parameters.filter(({key:D})=>D.startsWith(`$jobsMapByNodeKey.${i.key}.`)||D===`$jobsMapByNodeKey.${i.key}`).length);if(f.length){l.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:f.map(g=>`#${g.id}`).join(", ")})});return}const h=!n.find(g=>g.upstream===i&&g.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:h,onOk:p})})}return r.jsx(b.Button,{className:"workflow-node-remove-button",type:"text",shape:"circle",icon:r.jsx(H.DeleteOutlined,{}),onClick:d})},pl=s.createStyles(({css:e,token:t})=>({nodePoint:e`
|
|
655
681
|
position: relative;
|
|
656
682
|
display: flex;
|
|
657
683
|
flex-direction: row;
|
|
@@ -775,16 +801,16 @@ export default async function (
|
|
|
775
801
|
}
|
|
776
802
|
}
|
|
777
803
|
}
|
|
778
|
-
`})),
|
|
804
|
+
`})),ml=e=>{const{color:t,icon:o,workflow:n,editingTitle:a,configuring:i,setEditingTitle:l,onChangeTitle:c}=e,d=he(),{styles:u}=pl(),[p,f]=x.useState(!1),y=n.executed||!p,h=(d==null?void 0:d.group)===Ge,g=()=>{i&&f(!0)},w=C=>{c(C.target.value),f(!1)};return r.jsxs("div",{className:s.cx(u.nodePoint,{deprecated:h,configuring:i}),children:[r.jsx(fl,{color:t,icon:o}),r.jsx(Lo,{className:`workflow-node-edit ${y?"node-executed":""}`,readOnly:y,value:a,onChange:C=>l(C.target.value),onBlur:w,onClick:g}),r.jsx(gl,{isExecuted:n.executed})]})},fl=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"})})},gl=e=>{const{isExecuted:t}=e;return r.jsx("div",{className:"workflow-node-suffix",children:t?r.jsx("div",{className:"icon-button",children:r.jsx(dl,{})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"icon-button",children:r.jsx(ul,{})}),r.jsx("div",{className:"icon-button",children:r.jsx(ll,{})})]})})},it=e=>{var M,E;const{data:t,children:o}=e,n=s.useCompile(),a=s.useAPIClient(),{workflow:i,refresh:l}=(M=Y())!=null?M:{},{styles:c}=il(),u=s.usePlugin(re).instructions.get(t.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=n(u.title),{color:y,icon:h}=u,[g,w]=x.useState((E=t.title)!=null?E:f),[C,D]=x.useState(!1),S=x.useCallback(function(N){return P(this,null,function*(){var K,q;const V=N||f;w(V),V!==t.title&&(yield(q=(K=a.resource("flow_nodes")).update)==null?void 0:q.call(K,{filterByTk:t.id,values:{title:V}}),l())})},[t]),I=x.useCallback(function(N){var K,q;if(N.target===N.currentTarget){D(!0);return}(q=(K=N.target)==null?void 0:K.classList)!=null&&q.contains("workflow-node-edit")&&D(!0);const V=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let G=N.target;G&&G!==N.currentTarget&&G!==document.documentElement;G=G.parentNode)if(Array.from(G.classList).some(j=>V.has(j))){D(!0),N.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}-${g}`,onClick:I,children:[r.jsx(ml,{color:y,icon:h,workflow:i,editingTitle:g,configuring:C,setEditingTitle:w,onChangeTitle:S}),r.jsx(al,{instruction:u,data:t,detailText:p,workflow:i,editingConfig:C,setEditingConfig:D})]}),o]})},ne=new W.Registry;ne.register("equal",{name:"=",type:"boolean",group:"boolean"}),ne.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ne.register("gt",{name:">",type:"boolean",group:"boolean"}),ne.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ne.register("lt",{name:"<",type:"boolean",group:"boolean"}),ne.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ne.register("add",{name:"+",type:"number",group:"number"}),ne.register("minus",{name:"-",type:"number",group:"number"}),ne.register("multiple",{name:"*",type:"number",group:"number"}),ne.register("divide",{name:"/",type:"number",group:"number"}),ne.register("mod",{name:"%",type:"number",group:"number"}),ne.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ne.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ne.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ne.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ne.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ne.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ne.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"}),ne.register("isEmpty",{name:`{{t("is empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isNotEmpty",{name:`{{t("is not empty", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isTrue",{name:`{{t("is true", { ns: "${m}" })}}`,type:"boolean",group:"existence"}),ne.register("isFalse",{name:`{{t("is false", { ns: "${m}" })}}`,type:"boolean",group:"existence"});const hl=[{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 fn(e){return Array.from(ne.getEntities()).filter(([t,o])=>o.group===e)}function yl({calculator:e,operands:t=[],onChange:o}){const[n,a]=x.useState(e),i=s.useCompile(),l=me(),c=u=>{const p=ne.get(u);return(p==null?void 0:p.group)==="existence"},d=u=>{a(u),o({operands:t,calculator:u})};return r.jsxs("fieldset",{className:s.css`
|
|
779
805
|
display: flex;
|
|
780
806
|
gap: 0.5em;
|
|
781
807
|
align-items: center;
|
|
782
808
|
flex-wrap: wrap;
|
|
783
|
-
`,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:
|
|
809
|
+
`,children:[r.jsx(s.Variable.Input,{value:t[0],onChange:u=>o({calculator:n,operands:[u,t[1]]}),scope:l,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:n,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:hl.filter(u=>!!fn(u.value).length).map(u=>r.jsx(b.Select.OptGroup,{label:i(u.title),children:fn(u.value).map(([p,{name:f}])=>r.jsx(b.Select.Option,{value:p,children:i(f)},p))},u.value))}),!c(n)&&r.jsx(s.Variable.Input,{value:t[1],onChange:u=>o({calculator:n,operands:[t[0],u]}),scope:l,useTypedConstant:!0})]})}function xl({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:a=[]}=e;return r.jsxs("div",{className:s.css`
|
|
784
810
|
display: flex;
|
|
785
811
|
position: relative;
|
|
786
812
|
margin: 0.5em 0;
|
|
787
|
-
`,children:[e.group?r.jsx(
|
|
813
|
+
`,children:[e.group?r.jsx(gn,{value:e.group,onChange:i=>t(F(v({},e),{group:i}))}):r.jsx(yl,{operands:a,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(H.CloseCircleOutlined,{})})]})}function gn({value:e,onChange:t}){const{t:o}=ee.useTranslation(),{type:n="and",calculations:a=[]}=e;function i(){t(F(v({},e),{calculations:[...a,{not:!1,calculator:"equal"}]}))}function l(){t(F(v({},e),{calculations:[...a,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(u){a.splice(u,1),t(F(v({},e),{calculations:[...a]}))}function d(u,p){a.splice(u,1,p),t(F(v({},e),{calculations:[...a]}))}return r.jsxs("div",{className:s.cx("node-type-condition-group",s.css`
|
|
788
814
|
position: relative;
|
|
789
815
|
width: 100%;
|
|
790
816
|
.node-type-condition-group {
|
|
@@ -803,14 +829,14 @@ export default async function (
|
|
|
803
829
|
width: auto;
|
|
804
830
|
min-width: 6em;
|
|
805
831
|
}
|
|
806
|
-
`,children:r.jsxs(
|
|
832
|
+
`,children:r.jsxs(ee.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:u=>t(F(v({},e),{type:u})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:a.map((u,p)=>r.jsx(xl,{value:u,onChange:d.bind(this,p),onRemove:()=>c(p)},`${u.calculator}_${p}`))}),r.jsxs("div",{className:s.css`
|
|
807
833
|
button {
|
|
808
834
|
padding: 0;
|
|
809
835
|
&:not(:last-child) {
|
|
810
836
|
margin-right: 1em;
|
|
811
837
|
}
|
|
812
838
|
}
|
|
813
|
-
`,children:[r.jsx(b.Button,{type:"link",onClick:
|
|
839
|
+
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function bl({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(gn,{value:o.group,onChange:n=>t(F(v({},o),{group:n}))})}class vl extends oe{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(W.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(v({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:a}=n,{evaluate:i}=W.evaluators.get(a.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return i(l),""}catch(c){return O("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:mn,useWorkflowVariableOptions:me},this.components={CalculationConfig:bl,WorkflowVariableTextArea:at,RadioWithTooltip:Ne}}Component({data:t}){const{t:o}=ee.useTranslation(),{nodes:n}=Y(),{styles:a}=we(),{id:i,config:{rejectOnFalse:l}}=t,c=n.find(u=>u.upstreamId===i&&u.branchIndex===1),d=n.find(u=>u.upstreamId===i&&u.branchIndex===0);return r.jsx(it,{data:t,children:l?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(je,{from:t,entry:c,branchIndex:1}),r.jsx(je,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:a.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 wl(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=A.useField(),n=o.segments[o.segments.length-1],{values:a}=A.useForm(),[i,l]=s.parseCollectionName(a==null?void 0:a.collection),c=t(l,i),{type:d}=c.find(f=>f.name===n),u=Array.isArray(e.value)?e.value.join(","):e.value;function p(f){const y=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?y:y.split(/[,\s]+/))}return r.jsx(b.Input,F(v({},e),{value:u,onChange:p}))}const ro=A.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:a}=s.useToken(),{t:i}=ee.useTranslation(),l=s.useCompile(),c=A.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),u=me(),{values:p}=c,[f,y]=s.parseCollectionName(p==null?void 0:p.collection),h=d(y,f).filter(S=>S.uiSchema),g=n?h.filter(n.bind(p)):h,w=x.useMemo(()=>g.filter(S=>!e||!(S.name in e)),[g,e]),C=t||c.disabled,D=x.useMemo(()=>({onClick:({key:S})=>{o(F(v({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(S=>{var I,M;return{key:S.name,label:l((M=(I=S.uiSchema)==null?void 0:I.title)!=null?M:S.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:s.css`
|
|
814
840
|
margin-top: 0.5em;
|
|
815
841
|
|
|
816
842
|
> .ant-formily-item {
|
|
@@ -820,22 +846,22 @@ export default async function (
|
|
|
820
846
|
line-height: 32px;
|
|
821
847
|
}
|
|
822
848
|
}
|
|
823
|
-
`,children:
|
|
849
|
+
`,children:g.length?r.jsxs(s.CollectionProvider_deprecated,{name:y,dataSource:f,children:[g.filter(S=>e&&S.name in e).map(S=>{var M,E;const I=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?wl:s.CollectionField;return r.jsxs(b.Form.Item,{label:l((E=(M=S.uiSchema)==null?void 0:M.title)!=null?E:S.name),labelAlign:"left",className:s.css`
|
|
824
850
|
.ant-form-item-control-input-content {
|
|
825
851
|
display: flex;
|
|
826
852
|
}
|
|
827
|
-
`,children:[r.jsx(s.Variable.Input,{scope:
|
|
853
|
+
`,children:[r.jsx(s.Variable.Input,{scope:u,value:e[S.name],changeOnSelect:!0,onChange:N=>{o(F(v({},e),{[S.name]:N}))},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":I,"x-validator"(){return""}}}}})}),C?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(H.CloseCircleOutlined,{}),onClick:()=>{var K;const q=e,{[K=S.name]:N}=q,V=Q(q,[cr(K)]);o(V)}})]},S.name)}),w.length?r.jsx(b.Dropdown,{menu:D,children:r.jsx(b.Button,{icon:r.jsx(H.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:a.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"}),ue={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},so={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
854
|
flex-direction: column;
|
|
829
|
-
`},"x-component":"CollectionFieldset"},
|
|
855
|
+
`},"x-component":"CollectionFieldset"},Qe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=A.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
|
|
830
856
|
position: relative;
|
|
831
857
|
width: 100%;
|
|
832
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},rl={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"}}},sl={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}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class il 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:I(v({},fe),{"x-reactions":[...fe["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:to,appends:at}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:eo}}useVariables({key:t,title:o,config:n},i){var p,d;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(I(v({appends:[t,...((d=(p=n.params)==null?void 0:p.appends)==null?void 0:d.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 al 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:I(v({},fe),{"x-reactions":[...fe["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({},it),{"x-validator"(t){return et(t)?"":T("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ie}}}class ll 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:ve.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:ve.FAILED}],required:!0,default:ve.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 cl 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:I(v({},fe),{"x-reactions":[...fe["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:rl,pagination:sl,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}=A.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,p;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((p=l==null?void 0:l.uiSchema)==null?void 0:p.title):l.name}})}},this.components={ArrayItems:M.ArrayItems,FilterDynamicComponent:Ie,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},i){var p,d;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=me(I(v({appends:[t,...((d=(p=n.params)==null?void 0:p.appends)==null?void 0:d.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 dl(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=A.useForm(),{collection:l}=a.values,c=i(l),p=A.useField();function d({target:u}){const f=p.query(".values").take();if(!f)return;const g=c.reduce((h,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(h[x.name]=f.value[x.name]),h),{});a.setValuesIn("params.values",g),e(u.value)}return r.jsx(Fe,I(v({},t),{onChange:d}))}class pl 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:I(v({},fe),{"x-reactions":[...fe["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({},it),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return et(t)?"":T("Please add at least one condition")}}),values:I(v({},to),{"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:eo,IndividualHooksRadioWithTooltip:dl}}}function ul(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=A.useForm(),{collection:l}=a.values,c=i(l),p=A.useField();function d({target:u}){const f=p.query(".values").take();if(!f)return;const g=c.reduce((h,x)=>(x.name in f.value&&(u.value||![].includes(x.type))&&(h[x.name]=f.value[x.name]),h),{});a.setValuesIn("params.values",g),e(u.value)}return r.jsx(Fe,I(v({},t),{onChange:d}))}class ml 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:I(v({},fe),{"x-reactions":[...fe["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({},it),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return et(t)?"":T("Please add at least one condition")}}),values:I(v({},to),{"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:eo,IndividualHooksRadioWithTooltip:ul}}}const fl=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),je={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},gl=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:je.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:je.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:je.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:je.DELETED}];class hl 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({},fe),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...fe["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:gl,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] & ${je.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(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] & ${je.UPDATED})}}`}}}]},condition:I(v({},it),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:I(v({},at),{"x-reactions":[...at["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${je.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Bo},this.components={FieldsSelect:ot}}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:T("Trigger data")}}];return me(I(v({appends:["data",...((c=t.appends)==null?void 0:c.map(p=>`data.${p}`))||[]]},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 ze={STATIC:0,DATE_FIELD:1};function yl(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function rn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[i,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
|
|
858
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},hn={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"}}},yn={type:"void",properties:{paginate:{type:"boolean",title:T("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":T("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}}}}}}}}},lt={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=A.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Cl extends oe{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:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:so,appends:lt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:ro}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,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 kl extends oe{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:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(v({},Qe),{"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:Ae}}}class Sl extends oe{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:Ce.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:Ce.FAILED}],required:!0,default:Ce.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 Al extends oe{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:F(v({},ue),{"x-reactions":[...ue["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:Qe,sort:hn,pagination:yn,appends:lt},"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:a}=A.useForm();return o(a.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:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,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}`}}}class Il extends oe{constructor(){super(...arguments),this.title=`{{t("Select record", { ns: "${m}" })}}`,this.type="select",this.group="collection",this.icon="SelectOutlined",this.color="#a47cef",this.description=`{{t("Select records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:F(v({},ue),{"x-reactions":[...ue["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:Qe,sort:hn,pagination:yn,summary:{type:"array",title:`{{t("Select fields to display in the collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CollectionTreeSelect","x-component-props":{title:"Preload associations",needLeaf:!0,useCollection(){const{values:t}=A.useForm();return t==null?void 0:t.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},"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:a}=A.useForm();return o(a.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:W.ArrayItems,FilterDynamicComponent:Ae,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},a){var d,u;const i=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=fe(F(v({appends:[t,...((u=(d=n.params)==null?void 0:d.appends)==null?void 0:u.map(p=>`${t}.${p}`))||[]]},a),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:i,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 Fl(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Tl extends oe{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:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"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:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Fl}}}function Nl(o){var n=o,{onChange:e}=n,t=Q(n,["onChange"]);const{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=A.useForm(),{collection:l}=i.values,c=a(l),d=A.useField();function u({target:p}){const f=d.query(".values").take();if(!f)return;const y=c.reduce((h,g)=>(g.name in f.value&&(p.value||![].includes(g.type))&&(h[g.name]=f.value[g.name]),h),{});i.setValuesIn("params.values",y),e(p.value)}return r.jsx(Ne,F(v({},t),{onChange:u}))}class Dl extends oe{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:F(v({},ue),{"x-reactions":[...ue["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:F(v({},Qe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return nt(t)?"":O("Please add at least one condition")}}),values:F(v({},so),{"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:Ae,CollectionFieldset:ro,IndividualHooksRadioWithTooltip:Nl}}}const Ol=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=A.useFieldSchema();return A.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),ze={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Pl=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:ze.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:ze.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:ze.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:ze.DELETED}];class El extends Re{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:F(v({},ue),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ue["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:Pl,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] & ${ze.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] & ${ze.UPDATED})}}`}}}]},condition:F(v({},Qe),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(v({},lt),{"x-reactions":[...lt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${ze.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:zo},this.components={FieldsSelect:rt}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:O("Trigger data")}}];return fe(F(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:i,compile:n,getCollectionFields:a}))}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 qe={STATIC:0,DATE_FIELD:1};function Ml(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function xn({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=ee.useTranslation(),[a,i]=x.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
|
|
833
859
|
display: flex;
|
|
834
860
|
gap: 0.5em;
|
|
835
|
-
`,children:[r.jsx(
|
|
861
|
+
`,children:[r.jsx(rt,{value:o.field,onChange:l=>t(F(v({},o),{field:l})),filter:Ml,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:a,onChange:l=>{i(l),t(F(v({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,a?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(F(v({},o),{offset:(l!=null?l:0)*a}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(F(v({},o),{unit:l})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}],className:"auto-width"})]}):null]})}function $l({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
862
|
display: flex;
|
|
837
863
|
gap: 0.5em;
|
|
838
|
-
`,children:[r.jsxs(b.Select,{value:n,onChange:i=>{t(i?i==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(rn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:Vt(e),onChange:i=>{t(i?i.toDate():null)}}):null]})}var de=function(){return de=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de.apply(this,arguments)};function sn(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 kt(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 bl=[{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 * * * *"}],Le=[{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 an(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function St(e){return e.sort(function(t,o){return t-o}),e}function ln(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 cn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||U.errorInvalidCron})}function At(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function dn(e,t,o,n,i,a,l,c,p,d,u,f,g,h){o&&o(void 0),t(!1);var x=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;x=!0}if(!x){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=bl.find(function(w){return w.name===e});C&&(e=C.value)}try{var k=function(w){if(typeof w!="string")throw new Error("Invalid cron string");var O=w.replace(/\s+/g," ").trim().split(" ");if(O.length===5)return O.map(function(V,$){return function(P,B){if(P==="*"||P==="*/1")return[];var _=St(ln(fn(function(J,Y,ae){if(ae){J=J.toUpperCase();for(var W=0;W<ae.length;W++)J=J.replace(ae[W],"".concat(W+Y))}return J}(P,B.min,B.alt).split(",").map(function(J){var Y,ae=J.split("/");if(ae.length>2)throw new Error('Invalid value "'.concat(P,' for "').concat(B.type,'"'));var W=ae[0],L=ae[1];Y=W==="*"?an(B.min,B.max):function(G,ee,oe){var se=G.split("-");if(se.length===1){var Ue=At(se[0]);if(isNaN(Ue))throw new Error('Invalid value "'.concat(ee,'" for ').concat(oe.type));return[Ue]}if(se.length===2){var we=At(se[0]),Je=At(se[1]);if(isNaN(we)||isNaN(Je))throw new Error('Invalid value "'.concat(ee,'" for ').concat(oe.type));if(Je<we)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(oe.type));return an(we,Je)}throw new Error('Invalid value "'.concat(G,'" for ').concat(oe.type))}(W,P,B);var E=function(G,ee){if(G!==void 0){var oe=At(G);if(isNaN(oe)||oe<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(ee.type));return oe}}(L,B),R=function(G,ee){if(ee){var oe=G[0];G=G.filter(function(se){return se%ee==oe%ee||se===oe})}return G}(Y,E);return R}).flat(),B))),z=gn(_,B);if(z!==void 0)throw new Error('Value "'.concat(z,'" out of range for ').concat(B.type));return _.length===B.total?[]:_}(V,Le[$])});throw new Error("Invalid cron string format")}(e),F=function(w){return w[3].length>0?"year":w[2].length>0?"month":w[4].length>0?"week":w[1].length>0?"day":w[0].length>0?"hour":"minute"}(k);h(F),p(k[0]),d(k[1]),u(k[2]),f(k[3]),g(k[4])}catch(w){x=!0}}x&&(i.current=e,t(!0),cn(o,l))}function pn(e,t,o,n,i,a,l){if(e==="reboot")return"@reboot";var c=function(p,d){return p.map(function(u,f){var g=Le[f];return un(mn(u,g),g,d)})}([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 un(e,t,o,n,i){var a="";if(function(c,p){return c.length===p.max-p.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var p=c[1]-c[0];if(p>1)return p}}(e);a=l&&function(c,p){for(var d=1;d<c.length;d++){var u=c[d-1];if(c[d]-u!==p)return!1}return!0}(e,l)?function(c,p,d){var u=hn(c),f=yn(c),g=c.length===(f-u)/d+1;return!!(u===p.min&&f+d>p.max&&g)}(e,t,l)?"*/".concat(l):"".concat(He(hn(e),t,o,n,i),"-").concat(He(yn(e),t,o,n,i),"/").concat(l):function(c){var p=[],d=null;return c.forEach(function(u,f,g){u!==g[f+1]-1?d!==null?(p.push([d,u]),d=null):p.push(u):d===null&&(d=u)}),p}(e).map(function(c){return Array.isArray(c)?"".concat(He(c[0],t,o,n,i),"-").concat(He(c[1],t,o,n,i)):He(c,t,o,n,i)}).join(",")}return a}function He(e,t,o,n,i){var a=e.toString(),l=t.type,c=t.alt,p=t.min,d=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-p]:e<10&&(d||u)&&(a=a.padStart(2,"0")),l==="hours"&&i==="12-hour-clock"){var f=e>=12?"PM":"AM",g=e%12||12;g<10&&d&&(g=g.toString().padStart(2,"0")),a="".concat(g).concat(f)}return a}function mn(e,t){var o=St(ln(fn(e,t)));if(o.length===0)return o;var n=gn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function fn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function gn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function hn(e){return e[0]}function yn(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,p=e.humanizeLabels,d=e.disabled,u=e.readOnly,f=e.leadingZero,g=e.clockFormat,h=e.period,x=e.unit,C=e.periodicityOnDoubleClick,k=e.mode,F=sn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),w=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(W){return W.toString()})},[t]),O=y.useMemo(function(){return i?i.map(function(W,L){return{value:(x.min===0?L:L+1).toString(),label:W}}):kt([],Array(x.total),!0).map(function(W,L){var E=x.min===0?L:L+1;return{value:E.toString(),label:He(E,x,p,f,g)}})},[i,f,p,g]),V=JSON.stringify(l),$=y.useCallback(function(W){var L=W.value;if(!t||t[0]!==Number(L))return r.jsx(r.Fragment,{});var E=un(mn(t,x),x,p,f,g),R=E.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:R[1]?"".concat(l.everyText||U.everyText," ").concat(R[1]):E})},[t,V,p,f,g]),P=y.useCallback(function(W){var L=Array.isArray(W)?St(W):[W],E=L;t&&(E=k==="single"?[]:kt([],t,!0),L.forEach(function(R){var G=Number(R);E=t.some(function(ee){return ee===G})?E.filter(function(ee){return ee!==G}):St(kt(kt([],E,!0),[G],!1))})),E.length===x.total?a([]):a(E)},[a,t]),B=y.useCallback(function(W){if(W!==0&&W!==1){for(var L=x.total+x.min,E=[],R=x.min;R<L;R++)R%W==0&&E.push(R);var G=t&&E&&t.length===E.length&&t.every(function(oe,se){return oe===E[se]}),ee=E.length===O.length;a(ee||G?[]:E)}else a([])},[t,O,a]),_=y.useRef([]),z=y.useCallback(function(W){if(!u){var L=_.current;L.push({time:new Date().getTime(),value:Number(W)});var E=window.setTimeout(function(){C&&L.length>1&&L[L.length-1].time-L[L.length-2].time<300?L[L.length-1].value===L[L.length-2].value?B(Number(W)):P([L[L.length-2].value,L[L.length-1].value]):P(Number(W)),_.current=[]},300);return function(){window.clearTimeout(E)}}},[_,P,B,u,C]),J=y.useCallback(function(){u||a([])},[a,u]),Y=y.useMemo(function(){var W;return Ce(((W={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,W))},[c]),ae=y.useMemo(function(){var W;return Ce(((W={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown"]=!0,W["react-js-cron-custom-select-dropdown-".concat(x.type)]=!0,W["react-js-cron-custom-select-dropdown-minutes-large"]=x.type==="minutes"&&h!=="hour"&&h!=="day",W["react-js-cron-custom-select-dropdown-minutes-medium"]=x.type==="minutes"&&(h==="day"||h==="hour"),W["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=x.type==="hours"&&g==="12-hour-clock",W["react-js-cron-custom-select-dropdown-grid"]=!!n,W["".concat(c,"-select-dropdown")]=!!c,W["".concat(c,"-select-dropdown-").concat(x.type)]=!!c,W))},[c,n,g,h]);return r.jsx(b.Select,de({mode:k!=="single"||C?"multiple":void 0,allowClear:!u,virtual:!1,open:!u&&void 0,value:w,onClear:J,tagRender:$,className:Y,popupClassName:ae,options:O,showSearch:!1,showArrow:!u,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:z,onDeselect:z,disabled:d,dropdownAlign:x.type!=="minutes"&&x.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(x.type)},F))}function vl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,p=e.clockFormat,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=y.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,h["".concat(i,"-hours")]=!!i,h))},[i]);return r.jsxs("div",de({className:g},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||U.prefixHours}),r.jsx(lt,{placeholder:n.emptyHours||U.emptyHours,value:t,unit:Le[1],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:p,period:d,periodicityOnDoubleClick:u,mode:f})]}))}function wl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,p=e.clockFormat,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=y.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,h["".concat(i,"-minutes")]=!!i,h))},[i]);return r.jsxs("div",de({className:g},{children:[d==="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:d==="hour"?n.emptyMinutesForHourPeriod||U.emptyMinutesForHourPeriod:n.emptyMinutes||U.emptyMinutes,value:t,unit:Le[0],setValue:o,locale:n,className:i,disabled:a,readOnly:l,leadingZero:c,clockFormat:p,period:d,periodicityOnDoubleClick:u,mode:f}),d==="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,p=e.leadingZero,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=!a||a.length===0,h=y.useMemo(function(){var k;return Ce(((k={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!g})["".concat(i,"-field")]=!!i,k["".concat(i,"-month-days")]=!!i,k))},[i,g]),x=JSON.stringify(n),C=y.useMemo(function(){return g?n.emptyMonthDays||U.emptyMonthDays:n.emptyMonthDaysShort||U.emptyMonthDaysShort},[g,x]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",de({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||U.prefixMonthDays}),r.jsx(lt,{placeholder:C,value:t,setValue:o,unit:Le[2],locale:n,className:i,disabled:l,readOnly:c,leadingZero:p,period:d,periodicityOnDoubleClick:u,mode:f})]})):null}function kl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,p=e.period,d=e.periodicityOnDoubleClick,u=e.mode,f=n.months||U.months,g=y.useMemo(function(){var h;return Ce(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,h["".concat(i,"-months")]=!!i,h))},[i]);return r.jsxs("div",de({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:de(de({},Le[3]),{alt:n.altMonths||U.altMonths}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:l,readOnly:c,period:p,periodicityOnDoubleClick:d,mode:u})]}))}function Sl(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,p=e.allowedPeriods,d=[];p.includes("year")&&d.push({value:"year",label:n.yearOption||U.yearOption}),p.includes("month")&&d.push({value:"month",label:n.monthOption||U.monthOption}),p.includes("week")&&d.push({value:"week",label:n.weekOption||U.weekOption}),p.includes("day")&&d.push({value:"day",label:n.dayOption||U.dayOption}),p.includes("hour")&&d.push({value:"hour",label:n.hourOption||U.hourOption}),p.includes("minute")&&d.push({value:"minute",label:n.minuteOption||U.minuteOption}),p.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||U.rebootOption});var u=y.useCallback(function(x){l||o(x)},[o,l]),f=y.useMemo(function(){var x;return Ce(((x={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(i,"-field")]=!!i,x["".concat(i,"-period")]=!!i,x))},[i]),g=y.useMemo(function(){var x;return Ce(((x={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(i,"-select")]=!!i,x))},[i,n.prefixPeriod]),h=y.useMemo(function(){var x;return Ce(((x={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(i,"-select-dropdown")]=!!i,x["".concat(i,"-select-dropdown-period")]=!!i,x))},[i]);return r.jsxs("div",de({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||U.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:u,options:d,className:g,popupClassName:h,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Al(e){var t=e.value,o=e.setValue,n=e.locale,i=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,p=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,g=n.weekDays||U.weekDays,h=d==="week"||!l||l.length===0,x=y.useMemo(function(){var O;return Ce(((O={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(i,"-field")]=!!i,O["".concat(i,"-week-days")]=!!i,O))},[i,h]),C=JSON.stringify(n),k=y.useMemo(function(){return h?n.emptyWeekDays||U.emptyWeekDays:n.emptyWeekDaysShort||U.emptyWeekDaysShort},[h,C]),F=d==="week"||!p||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),w=!p||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return F?r.jsxs("div",de({className:x},{children:[n.prefixWeekDays!==""&&(d==="week"||!w)&&r.jsx("span",{children:n.prefixWeekDays||U.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&w&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||U.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(lt,{placeholder:k,optionsList:g,grid:!1,value:t,unit:de(de({},Le[4]),{alt:n.altWeekDays||U.altWeekDays}),setValue:o,locale:n,className:i,humanizeLabels:a,disabled:c,readOnly:p,period:d,periodicityOnDoubleClick:u,mode:f})]})):null}function Il(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,p=c===void 0?U:c,d=e.value,u=d===void 0?"":d,f=e.setValue,g=e.displayError,h=g===void 0||g,x=e.onError,C=e.className,k=e.defaultPeriod,F=k===void 0?"day":k,w=e.allowEmpty,O=w===void 0?"for-default-value":w,V=e.humanizeLabels,$=V===void 0||V,P=e.humanizeValue,B=P!==void 0&&P,_=e.disabled,z=_!==void 0&&_,J=e.readOnly,Y=J!==void 0&&J,ae=e.leadingZero,W=ae!==void 0&&ae,L=e.shortcuts,E=L===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:L,R=e.clockFormat,G=e.periodicityOnDoubleClick,ee=G===void 0||G,oe=e.mode,se=oe===void 0?"multiple":oe,Ue=e.allowedDropdowns,we=Ue===void 0?["period","months","month-days","week-days","hours","minutes"]:Ue,Je=e.allowedPeriods,ic=Je===void 0?["year","month","week","day","hour","minute","reboot"]:Je,Ye=y.useRef(u),so=y.useRef(F),$n=y.useState(),Ne=$n[0],It=$n[1],Bn=y.useState(),ct=Bn[0],Ft=Bn[1],Vn=y.useState(),Tt=Vn[0],Nt=Vn[1],Wn=y.useState(),dt=Wn[0],Dt=Wn[1],jn=y.useState(),Ot=jn[0],Pt=jn[1],zn=y.useState(),Et=zn[0],Mt=zn[1],Ln=y.useState(!1),io=Ln[0],pt=Ln[1],qn=y.useState(!1),$t=qn[0],Un=qn[1],ac=function(ne){var Ae=y.useRef(ne);return y.useEffect(function(){Ae.current=ne},[ne]),Ae.current}($t),Kn=JSON.stringify(p);y.useEffect(function(){dn(u,pt,x,O,Ye,!0,p,E,Mt,Pt,Ft,Nt,Dt,It)},[]),y.useEffect(function(){u!==Ye.current&&dn(u,pt,x,O,Ye,!1,p,E,Mt,Pt,Ft,Nt,Dt,It)},[u,Ye,Kn,O,E]),y.useEffect(function(){if(!(Ne||Et||Tt||ct||dt||Ot)||$t||ac)$t&&Un(!1);else{var ne=Ne||so.current,Ae=pn(ne,Tt,ct,dt,Ot,Et,B);f(Ae,{selectedPeriod:ne}),Ye.current=Ae,x&&x(void 0),pt(!1)}},[Ne,ct,Tt,dt,Ot,Et,B,$t]);var _n=y.useCallback(function(){Ft(void 0),Nt(void 0),Dt(void 0),Pt(void 0),Mt(void 0);var ne="",Ae=Ne!=="reboot"&&Ne?Ne:so.current;Ae!==Ne&&It(Ae),l==="fill-with-every"&&(ne=pn(Ae,void 0,void 0,void 0,void 0,void 0)),f(ne,{selectedPeriod:Ae}),Ye.current=ne,Un(!0),O==="never"&&l==="empty"?(pt(!0),cn(x,p)):(x&&x(void 0),pt(!1))},[Ne,f,x,l]),lc=y.useMemo(function(){var ne;return Ce(((ne={"react-js-cron":!0,"react-js-cron-error":io&&h,"react-js-cron-disabled":z,"react-js-cron-read-only":Y})["".concat(C)]=!!C,ne["".concat(C,"-error")]=io&&h&&!!C,ne["".concat(C,"-disabled")]=z&&!!C,ne["".concat(C,"-read-only")]=Y&&!!C,ne))},[C,io,h,z,Y]),ao=i.className,Gn=sn(i,["className"]),Hn=y.useMemo(function(){var ne;return Ce(((ne={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,ne["".concat(ao)]=!!ao,ne))},[C,ao]),cc=JSON.stringify(Gn),Jn=y.useMemo(function(){return o&&!Y?r.jsx(b.Button,de({className:Hn,danger:!0,type:"primary",disabled:z},Gn,{onClick:_n},{children:p.clearButtonText||U.clearButtonText})):null},[o,Y,Kn,Hn,z,cc,_n]),le=Ne||so.current;return r.jsxs("div",de({className:lc},{children:[we.includes("period")&&r.jsx(Sl,{value:le,setValue:It,locale:p,className:C,disabled:z,readOnly:Y,shortcuts:E,allowedPeriods:ic}),le==="reboot"?Jn:r.jsxs(r.Fragment,{children:[le==="year"&&we.includes("months")&&r.jsx(kl,{value:Tt,setValue:Nt,locale:p,className:C,humanizeLabels:$,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:se}),(le==="year"||le==="month")&&we.includes("month-days")&&r.jsx(Cl,{value:ct,setValue:Ft,locale:p,className:C,weekDays:dt,disabled:z,readOnly:Y,leadingZero:W,period:le,periodicityOnDoubleClick:ee,mode:se}),(le==="year"||le==="month"||le==="week")&&we.includes("week-days")&&r.jsx(Al,{value:dt,setValue:Dt,locale:p,className:C,humanizeLabels:$,monthDays:ct,disabled:z,readOnly:Y,period:le,periodicityOnDoubleClick:ee,mode:se}),r.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&we.includes("hours")&&r.jsx(vl,{value:Ot,setValue:Pt,locale:p,className:C,disabled:z,readOnly:Y,leadingZero:W,clockFormat:R,period:le,periodicityOnDoubleClick:ee,mode:se}),le!=="minute"&&we.includes("minutes")&&r.jsx(wl,{value:Et,setValue:Mt,locale:p,period:le,className:C,disabled:z,readOnly:Y,leadingZero:W,clockFormat:R,periodicityOnDoubleClick:ee,mode:se}),Jn]})]})]}))}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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},xn=[{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 bn(e){return xn.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Tl(e){let t;switch(typeof e){case"number":return t=bn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Nl({value:e,onChange:t}){const{t:o}=ye(),n=bn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:i=>t(i*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Dl({value:e=null,onChange:t}){const{t:o}=ye(),n=Tl(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`
|
|
864
|
+
`,children:[r.jsxs(b.Select,{value:n,onChange:a=>{t(a?a==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(xn,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:mt(e),onChange:a=>{t(a?a.toDate():null)}}):null]})}var ge=function(){return ge=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var a in t=arguments[o])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},ge.apply(this,arguments)};function bn(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(o[n[a]]=e[n[a]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var n,a=0,i=t.length;a<i;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}var Bl=[{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 * * * *"}],Ue=[{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"]}],Z={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 vn(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function It(e){return e.sort(function(t,o){return t-o}),e}function wn(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function Se(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function Cn(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||Z.errorInvalidCron})}function Ft(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function kn(e,t,o,n,a,i,l,c,d,u,p,f,y,h){o&&o(void 0),t(!1);var g=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;g=!0}if(!g){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var w=Bl.find(function(S){return S.name===e});w&&(e=w.value)}try{var C=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var I=S.replace(/\s+/g," ").trim().split(" ");if(I.length===5)return I.map(function(M,E){return function(N,V){if(N==="*"||N==="*/1")return[];var K=It(wn(Fn(function(G,j,X){if(X){G=G.toUpperCase();for(var B=0;B<X.length;B++)G=G.replace(X[B],"".concat(B+j))}return G}(N,V.min,V.alt).split(",").map(function(G){var j,X=G.split("/");if(X.length>2)throw new Error('Invalid value "'.concat(N,' for "').concat(V.type,'"'));var B=X[0],L=X[1];j=B==="*"?vn(V.min,V.max):function(J,_,R){var z=J.split("-");if(z.length===1){var de=Ft(z[0]);if(isNaN(de))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[de]}if(z.length===2){var te=Ft(z[0]),$e=Ft(z[1]);if(isNaN(te)||isNaN($e))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if($e<te)throw new Error('Max range is less than min range in "'.concat(J,'" for ').concat(R.type));return vn(te,$e)}throw new Error('Invalid value "'.concat(J,'" for ').concat(R.type))}(B,N,V);var $=function(J,_){if(J!==void 0){var R=Ft(J);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(J,'" for ').concat(_.type));return R}}(L,V),U=function(J,_){if(_){var R=J[0];J=J.filter(function(z){return z%_==R%_||z===R})}return J}(j,$);return U}).flat(),V))),q=Tn(K,V);if(q!==void 0)throw new Error('Value "'.concat(q,'" out of range for ').concat(V.type));return K.length===V.total?[]:K}(M,Ue[E])});throw new Error("Invalid cron string format")}(e),D=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(C);h(D),d(C[0]),u(C[1]),p(C[2]),f(C[3]),y(C[4])}catch(S){g=!0}}g&&(a.current=e,t(!0),Cn(o,l))}function Sn(e,t,o,n,a,i,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(p,f){var y=Ue[f];return An(In(p,y),y,u)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&a?a:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function An(e,t,o,n,a){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=l&&function(c,d){for(var u=1;u<c.length;u++){var p=c[u-1];if(c[u]-p!==d)return!1}return!0}(e,l)?function(c,d,u){var p=Nn(c),f=Dn(c),y=c.length===(f-p)/u+1;return!!(p===d.min&&f+u>d.max&&y)}(e,t,l)?"*/".concat(l):"".concat(Ze(Nn(e),t,o,n,a),"-").concat(Ze(Dn(e),t,o,n,a),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(p,f,y){p!==y[f+1]-1?u!==null?(d.push([u,p]),u=null):d.push(p):u===null&&(u=p)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ze(c[0],t,o,n,a),"-").concat(Ze(c[1],t,o,n,a)):Ze(c,t,o,n,a)}).join(",")}return i}function Ze(e,t,o,n,a){var i=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),p=a==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?i=c[e-d]:e<10&&(u||p)&&(i=i.padStart(2,"0")),l==="hours"&&a==="12-hour-clock"){var f=e>=12?"PM":"AM",y=e%12||12;y<10&&u&&(y=y.toString().padStart(2,"0")),i="".concat(y).concat(f)}return i}function In(e,t){var o=It(wn(Fn(e,t)));if(o.length===0)return o;var n=Tn(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function Fn(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function Tn(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function Nn(e){return e[0]}function Dn(e){return e[e.length-1]}function ct(e){var t=e.value,o=e.grid,n=o===void 0||o,a=e.optionsList,i=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,p=e.readOnly,f=e.leadingZero,y=e.clockFormat,h=e.period,g=e.unit,w=e.periodicityOnDoubleClick,C=e.mode,D=bn(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=x.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(B){return B.toString()})},[t]),I=x.useMemo(function(){return a?a.map(function(B,L){return{value:(g.min===0?L:L+1).toString(),label:B}}):At([],Array(g.total),!0).map(function(B,L){var $=g.min===0?L:L+1;return{value:$.toString(),label:Ze($,g,d,f,y)}})},[a,f,d,y]),M=JSON.stringify(l),E=x.useCallback(function(B){var L=B.value;if(!t||t[0]!==Number(L))return r.jsx(r.Fragment,{});var $=An(In(t,g),g,d,f,y),U=$.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:U[1]?"".concat(l.everyText||Z.everyText," ").concat(U[1]):$})},[t,M,d,f,y]),N=x.useCallback(function(B){var L=Array.isArray(B)?It(B):[B],$=L;t&&($=C==="single"?[]:At([],t,!0),L.forEach(function(U){var J=Number(U);$=t.some(function(_){return _===J})?$.filter(function(_){return _!==J}):It(At(At([],$,!0),[J],!1))})),$.length===g.total?i([]):i($)},[i,t]),V=x.useCallback(function(B){if(B!==0&&B!==1){for(var L=g.total+g.min,$=[],U=g.min;U<L;U++)U%B==0&&$.push(U);var J=t&&$&&t.length===$.length&&t.every(function(R,z){return R===$[z]}),_=$.length===I.length;i(_||J?[]:$)}else i([])},[t,I,i]),K=x.useRef([]),q=x.useCallback(function(B){if(!p){var L=K.current;L.push({time:new Date().getTime(),value:Number(B)});var $=window.setTimeout(function(){w&&L.length>1&&L[L.length-1].time-L[L.length-2].time<300?L[L.length-1].value===L[L.length-2].value?V(Number(B)):N([L[L.length-2].value,L[L.length-1].value]):N(Number(B)),K.current=[]},300);return function(){window.clearTimeout($)}}},[K,N,V,p,w]),G=x.useCallback(function(){p||i([])},[i,p]),j=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,B))},[c]),X=x.useMemo(function(){var B;return Se(((B={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown"]=!0,B["react-js-cron-custom-select-dropdown-".concat(g.type)]=!0,B["react-js-cron-custom-select-dropdown-minutes-large"]=g.type==="minutes"&&h!=="hour"&&h!=="day",B["react-js-cron-custom-select-dropdown-minutes-medium"]=g.type==="minutes"&&(h==="day"||h==="hour"),B["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=g.type==="hours"&&y==="12-hour-clock",B["react-js-cron-custom-select-dropdown-grid"]=!!n,B["".concat(c,"-select-dropdown")]=!!c,B["".concat(c,"-select-dropdown-").concat(g.type)]=!!c,B))},[c,n,y,h]);return r.jsx(b.Select,ge({mode:C!=="single"||w?"multiple":void 0,allowClear:!p,virtual:!1,open:!p&&void 0,value:S,onClear:G,tagRender:E,className:j,popupClassName:X,options:I,showSearch:!1,showArrow:!p,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:q,onDeselect:q,disabled:u,dropdownAlign:g.type!=="minutes"&&g.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(g.type)},D))}function Vl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-hours")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||Z.prefixHours}),r.jsx(ct,{placeholder:n.emptyHours||Z.emptyHours,value:t,unit:Ue[1],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function Wl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-minutes")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||Z.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||Z.prefixMinutes}),r.jsx(ct,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||Z.emptyMinutesForHourPeriod:n.emptyMinutes||Z.emptyMinutes,value:t,unit:Ue[0],setValue:o,locale:n,className:a,disabled:i,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:p,mode:f}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||Z.suffixMinutesForHourPeriod})]}))}function jl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=!i||i.length===0,h=x.useMemo(function(){var C;return Se(((C={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!y})["".concat(a,"-field")]=!!a,C["".concat(a,"-month-days")]=!!a,C))},[a,y]),g=JSON.stringify(n),w=x.useMemo(function(){return y?n.emptyMonthDays||Z.emptyMonthDays:n.emptyMonthDaysShort||Z.emptyMonthDaysShort},[y,g]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",ge({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||Z.prefixMonthDays}),r.jsx(ct,{placeholder:w,value:t,setValue:o,unit:Ue[2],locale:n,className:a,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function Ll(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,p=e.mode,f=n.months||Z.months,y=x.useMemo(function(){var h;return Se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(a,"-field")]=!!a,h["".concat(a,"-months")]=!!a,h))},[a]);return r.jsxs("div",ge({className:y},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||Z.prefixMonths}),r.jsx(ct,{placeholder:n.emptyMonths||Z.emptyMonths,optionsList:f,grid:!1,value:t,unit:ge(ge({},Ue[3]),{alt:n.altMonths||Z.altMonths}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:p})]}))}function zl(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||Z.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||Z.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||Z.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||Z.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||Z.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||Z.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||Z.rebootOption});var p=x.useCallback(function(g){l||o(g)},[o,l]),f=x.useMemo(function(){var g;return Se(((g={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(a,"-field")]=!!a,g["".concat(a,"-period")]=!!a,g))},[a]),y=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(a,"-select")]=!!a,g))},[a,n.prefixPeriod]),h=x.useMemo(function(){var g;return Se(((g={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(a,"-select-dropdown")]=!!a,g["".concat(a,"-select-dropdown-period")]=!!a,g))},[a]);return r.jsxs("div",ge({className:f},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||Z.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:p,options:u,className:y,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function ql(e){var t=e.value,o=e.setValue,n=e.locale,a=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,y=n.weekDays||Z.weekDays,h=u==="week"||!l||l.length===0,g=x.useMemo(function(){var I;return Se(((I={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(a,"-field")]=!!a,I["".concat(a,"-week-days")]=!!a,I))},[a,h]),w=JSON.stringify(n),C=x.useMemo(function(){return h?n.emptyWeekDays||Z.emptyWeekDays:n.emptyWeekDaysShort||Z.emptyWeekDaysShort},[h,w]),D=u==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return D?r.jsxs("div",ge({className:g},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||Z.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||Z.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(ct,{placeholder:C,optionsList:y,grid:!1,value:t,unit:ge(ge({},Ue[4]),{alt:n.altWeekDays||Z.altWeekDays}),setValue:o,locale:n,className:a,humanizeLabels:i,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:p,mode:f})]})):null}function Ul(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,a=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?Z:c,u=e.value,p=u===void 0?"":u,f=e.setValue,y=e.displayError,h=y===void 0||y,g=e.onError,w=e.className,C=e.defaultPeriod,D=C===void 0?"day":C,S=e.allowEmpty,I=S===void 0?"for-default-value":S,M=e.humanizeLabels,E=M===void 0||M,N=e.humanizeValue,V=N!==void 0&&N,K=e.disabled,q=K!==void 0&&K,G=e.readOnly,j=G!==void 0&&G,X=e.leadingZero,B=X!==void 0&&X,L=e.shortcuts,$=L===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:L,U=e.clockFormat,J=e.periodicityOnDoubleClick,_=J===void 0||J,R=e.mode,z=R===void 0?"multiple":R,de=e.allowedDropdowns,te=de===void 0?["period","months","month-days","week-days","hours","minutes"]:de,$e=e.allowedPeriods,vc=$e===void 0?["year","month","week","day","hour","minute","reboot"]:$e,Xe=x.useRef(p),uo=x.useRef(D),Gn=x.useState(),Oe=Gn[0],Tt=Gn[1],Hn=x.useState(),dt=Hn[0],Nt=Hn[1],Jn=x.useState(),Dt=Jn[0],Ot=Jn[1],Yn=x.useState(),ut=Yn[0],Pt=Yn[1],Qn=x.useState(),Et=Qn[0],Mt=Qn[1],Zn=x.useState(),$t=Zn[0],Bt=Zn[1],Xn=x.useState(!1),po=Xn[0],pt=Xn[1],Rn=x.useState(!1),Vt=Rn[0],er=Rn[1],wc=function(ie){var Fe=x.useRef(ie);return x.useEffect(function(){Fe.current=ie},[ie]),Fe.current}(Vt),tr=JSON.stringify(d);x.useEffect(function(){kn(p,pt,g,I,Xe,!0,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[]),x.useEffect(function(){p!==Xe.current&&kn(p,pt,g,I,Xe,!1,d,$,Bt,Mt,Nt,Ot,Pt,Tt)},[p,Xe,tr,I,$]),x.useEffect(function(){if(!(Oe||$t||Dt||dt||ut||Et)||Vt||wc)Vt&&er(!1);else{var ie=Oe||uo.current,Fe=Sn(ie,Dt,dt,ut,Et,$t,V);f(Fe,{selectedPeriod:ie}),Xe.current=Fe,g&&g(void 0),pt(!1)}},[Oe,dt,Dt,ut,Et,$t,V,Vt]);var or=x.useCallback(function(){Nt(void 0),Ot(void 0),Pt(void 0),Mt(void 0),Bt(void 0);var ie="",Fe=Oe!=="reboot"&&Oe?Oe:uo.current;Fe!==Oe&&Tt(Fe),l==="fill-with-every"&&(ie=Sn(Fe,void 0,void 0,void 0,void 0,void 0)),f(ie,{selectedPeriod:Fe}),Xe.current=ie,er(!0),I==="never"&&l==="empty"?(pt(!0),Cn(g,d)):(g&&g(void 0),pt(!1))},[Oe,f,g,l]),Cc=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron":!0,"react-js-cron-error":po&&h,"react-js-cron-disabled":q,"react-js-cron-read-only":j})["".concat(w)]=!!w,ie["".concat(w,"-error")]=po&&h&&!!w,ie["".concat(w,"-disabled")]=q&&!!w,ie["".concat(w,"-read-only")]=j&&!!w,ie))},[w,po,h,q,j]),mo=a.className,nr=bn(a,["className"]),rr=x.useMemo(function(){var ie;return Se(((ie={"react-js-cron-clear-button":!0})["".concat(w,"-clear-button")]=!!w,ie["".concat(mo)]=!!mo,ie))},[w,mo]),kc=JSON.stringify(nr),sr=x.useMemo(function(){return o&&!j?r.jsx(b.Button,ge({className:rr,danger:!0,type:"primary",disabled:q},nr,{onClick:or},{children:d.clearButtonText||Z.clearButtonText})):null},[o,j,tr,rr,q,kc,or]),pe=Oe||uo.current;return r.jsxs("div",ge({className:Cc},{children:[te.includes("period")&&r.jsx(zl,{value:pe,setValue:Tt,locale:d,className:w,disabled:q,readOnly:j,shortcuts:$,allowedPeriods:vc}),pe==="reboot"?sr:r.jsxs(r.Fragment,{children:[pe==="year"&&te.includes("months")&&r.jsx(Ll,{value:Dt,setValue:Ot,locale:d,className:w,humanizeLabels:E,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month")&&te.includes("month-days")&&r.jsx(jl,{value:dt,setValue:Nt,locale:d,className:w,weekDays:ut,disabled:q,readOnly:j,leadingZero:B,period:pe,periodicityOnDoubleClick:_,mode:z}),(pe==="year"||pe==="month"||pe==="week")&&te.includes("week-days")&&r.jsx(ql,{value:ut,setValue:Pt,locale:d,className:w,humanizeLabels:E,monthDays:dt,disabled:q,readOnly:j,period:pe,periodicityOnDoubleClick:_,mode:z}),r.jsxs("div",{children:[pe!=="minute"&&pe!=="hour"&&te.includes("hours")&&r.jsx(Vl,{value:Et,setValue:Mt,locale:d,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,period:pe,periodicityOnDoubleClick:_,mode:z}),pe!=="minute"&&te.includes("minutes")&&r.jsx(Wl,{value:$t,setValue:Bt,locale:d,period:pe,className:w,disabled:q,readOnly:j,leadingZero:B,clockFormat:U,periodicityOnDoubleClick:_,mode:z}),sr]})]})]}))}const Kl={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},On=[{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 Pn(e){return On.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function _l(e){let t;switch(typeof e){case"number":return t=Pn(e),t?t.value:"none";case"string":return"cron"}return"none"}function Gl({value:e,onChange:t}){const{t:o}=ve(),n=Pn(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:a=>t(a*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Hl({value:e=null,onChange:t}){const{t:o}=ve(),n=_l(e);function a(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=Kl[localStorage.getItem("TACHYBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:s.css`
|
|
839
865
|
display: flex;
|
|
840
866
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
841
867
|
align-items: flex-start;
|
|
@@ -864,7 +890,7 @@ export default async function (
|
|
|
864
890
|
}
|
|
865
891
|
}
|
|
866
892
|
}
|
|
867
|
-
`,children:[r.jsx(b.Select,{value:n,onChange:
|
|
893
|
+
`,children:[r.jsx(b.Select,{value:n,onChange:a,className:"auto-width",children:On.map(l=>r.jsx(b.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Gl,{value:e,onChange:t}):null,n==="cron"?r.jsx(Ul,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Jl={[qe.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}}},[qe.DATE_FIELD]:{collection:F(v({},ue),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...ue["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:F(v({},lt),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${qe.DATE_FIELD} && $deps[1]}}`}}}]})}},Yl=[{value:qe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:qe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Ql=()=>{const{values:e={},clearFormGraph:t}=A.useForm(),[o,n]=x.useState(e.mode);return A.useFormEffects(()=>{A.onFieldValueChange("mode",a=>{n(a.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(s.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Yl},required:!0,default:qe.STATIC}}),r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:s.css`
|
|
868
894
|
.ant-input-number {
|
|
869
895
|
width: auto;
|
|
870
896
|
min-width: 6em;
|
|
@@ -873,4 +899,4 @@ export default async function (
|
|
|
873
899
|
.ant-picker {
|
|
874
900
|
width: auto;
|
|
875
901
|
}
|
|
876
|
-
`},properties:Ol[o]}}},components:{OnField:rn,RepeatField:Dl,EndsByField:xl}})]})};class Ml 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:El}}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:T("Trigger time")}),t.mode===ze.DATE_FIELD){const[c]=me(I(v({appends:["data",...((l=t.appends)==null?void 0:l.map(p=>`data.${p}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:T("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 oo={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=kr(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(re.Link,{to:We(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}}]},vn=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:oo,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}=ye(),{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}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},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}}}}}}}}}},no=vn();function $l(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 Bl(){var W;const e=re.useNavigate(),{t}=Q.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[p,d]=y.useState(!1),[u,f]=y.useState(!1),[g,h]=y.useState(null),{styles:x}=be(),{modal:C}=b.App.useApp();if(y.useEffect(()=>{var R;const{title:E}=(R=n==null?void 0:n.data)!=null?R:{};c==null||c(`${T("Workflow")}${E?`: ${E}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const L=(W=n==null?void 0:n.data)!=null?W:{},{nodes:k=[],revisions:F=[]}=L,w=K(L,["nodes","revisions"]);ht(k);const O=k.find(E=>!E.upstream);function V({key:E}){E!==w.id&&e(We(E))}function $(E){return D(this,null,function*(){yield l.update({filterByTk:w.id,values:{enabled:E}}),i()})}function P(){return D(this,null,function*(){const{data:{data:E}}=yield l.retry({filterByTk:w.id,filter:{key:w.key}});e(tt(E.id))})}function B(){return D(this,null,function*(){const{data:{data:E}}=yield l.test({filterByTk:w.id,filter:{key:w.key},values:{data:{}}});e(tt(E.id))})}function _(){return D(this,null,function*(){const{data:{data:E}}=yield l.revision({filterByTk:w.id,filter:{key:w.key},values:{color:w.color}});b.message.success(t("Operation succeeded")),e(We(E.id))})}function z(){return D(this,null,function*(){const E=w.current?T("Delete a main version will cause all other revisions to be deleted too."):"";C.confirm({title:t("Are you sure you want to delete it?"),content:E,onOk(){return D(this,null,function*(){var G;yield l.destroy({filterByTk:w.id}),b.message.success(t("Operation succeeded")),e(w.current?o.systemSettingsManager.getRoutePath("workflow"):We((G=F.find(ee=>ee.current))==null?void 0:G.id))})}})})}const J=()=>D(null,null,function*(){g?(yield l.moveWorkflow({id:w.id,targetKey:g}),b.message.success(T("Move success")),f(!1),w.key=g,i()):b.message.error(T("Select target workflow"))});function Y(R){return D(this,arguments,function*({key:E}){switch(E){case"history":d(!0);return;case"test":return B();case"Retry":return P();case"revision":return _();case"delete":return z();case"move":h(null),f(!0);return}})}const ae=w.executed&&!F.find(E=>!E.executed&&new Date(E.createdAt)>new Date(w.createdAt));return r.jsxs($e.Provider,{value:{workflow:w,nodes:k,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(Co,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:T("Workflow")})},{title:r.jsx("strong",{children:w.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:V,defaultSelectedKeys:[`${w.id}`],className:s.cx(x.dropdownClass,x.workflowVersionDropdownClass),items:F.sort((E,R)=>R.id-E.id).map((E,R)=>({role:"button","aria-label":`version-${R}`,key:`${E.id}`,icon:E.current?r.jsx(j.RightOutlined,{}):null,className:s.cx({executed:E.executed,unexecuted:!E.executed,enabled:E.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${E.id}`}),r.jsx("time",{children:M.str2moment(E.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:T("Version")}),r.jsx("span",{children:w!=null&&w.id?`#${w.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:w.enabled,onChange:$,checkedChildren:T("On"),unCheckedChildren:T("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:T("Show execution history"),disabled:!w.allExecuted},{role:"button","aria-label":"test",key:"test",label:T("Execute empty test")},{role:"button","aria-label":"Retry",key:"Retry",label:T("Retry"),disabled:!w.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:T("Copy to new version"),disabled:!ae},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:T("Move"),disabled:w.current}],onClick:Y},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:p,setVisible:d},children:r.jsx(s.SchemaComponent,{schema:no,components:{ExecutionResourceProvider:$l,ExecutionLink:Jt,ExecutionStatusColumn:Gt},scope:{ExecutionRetryAction:Yt}})})]})]}),r.jsx(wo,{entry:O}),r.jsxs(b.Modal,{title:T("Move workflow"),visible:u,onOk:J,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:T("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:g,filterType:w.type,filterSync:w.sync,filterKey:{$ne:w.key},onChange:E=>h(E)})]})]})}const wn=()=>{const e=re.useParams(),{styles:t}=be();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:Bl}})})},Cn=y.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),ro=()=>y.useContext(Cn),Vl=A.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),Wl=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=ro(),n=s.useAPIClient();return{run(){return D(this,null,function*(){yield e.submit();const a=te.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:I(v({},a),{type:t==null?void 0:t.categoryType})}),t.setVisible(!1),yield e.reset(),o()})}}},jl=e=>r.jsx(kn,v({},e)),kn=e=>{const{scope:t,getContainer:o,children:n,categoryType:i}=e,[a,l]=y.useState(!1),{t:c}=ye(),p=zl(i),d={visible:a,setVisible:l,categoryType:i};return r.jsxs(s.ActionContextProvider,{value:d,children:[r.jsx("div",{onClick:()=>l(!0),title:c("Add category"),children:n||r.jsx(j.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:p,components:{CollectionCategory:Vl},scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:Wl},t)})]})},zl=e=>({type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",categoryType:e,useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}}),Ll=()=>{const e=s.useCollectionRecordData();let t="-";const{data:o,run:n}=s.useRequest({resource:"executions",action:"list",params:{filter:{key:{$eq:e.key}},sort:["-createdAt"],pageSize:1}},{manual:!0});return o!=null&&o.data.length&&(t=Vt(o.data[0].createdAt).format("YYYY-MM-DD HH:mm:ss")),y.useEffect(()=>{n()},[e]),r.jsx("div",{style:{textAlign:"left"},children:t})},ql=()=>{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})},Sn=y.createContext({eventSourceList:[]}),Ul=e=>{const{data:t}=s.useRequest({resource:"webhooks",action:"list",params:{pageSize:99999}});return r.jsx(Sn.Provider,{value:{eventSourceList:t==null?void 0:t.data},children:e.children})},Kl=()=>y.useContext(Sn),_l=()=>{var n;const e=s.useCollectionRecordData(),{eventSourceList:t}=Kl();let o="-";if(t!=null&&t.length){const i=(n=t==null?void 0:t.filter(a=>a.workflowKey===e.key))==null?void 0:n[0];o=(i==null?void 0:i.name)||""}return r.jsx("div",{style:{textAlign:"left"},children:o})},Gl=()=>{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(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},Hl=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=ro(),n=s.useAPIClient(),{id:i}=s.useRecord();return{run(){return D(this,null,function*(){yield e.submit();const l=te.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:i},values:v({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},Jl=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:te.cloneDeep(t)}),I(v({},e),{manual:!0})),n=s.useActionContext();return y.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},Yl=e=>r.jsx(An,v({},e)),An=e=>{const{scope:t,getContainer:o,item:n,children:i}=e,[a,l]=y.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:l},children:[r.jsx(r.Fragment,{children:i||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:Ql,scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:Hl,useValuesFromRecord:Jl},t)})]})})},Ql={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},Zl=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))},ge=A.observable({value:"",item:{}}),qe={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:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{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":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},In={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Type")}}',type:"string","x-component":"Input"}}]},he={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}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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}}}}},Fn=()=>{const{form:e}=s.useFormBlockProps();return ge.value&&(e.values.category=[ge.item]),{form:e}},Tn={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":`${qe.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:qe},"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:he.title,category:he.category,type:he.type,sync:he.sync,description:he.description,options:he.options}}}}}}}},Nn={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":`${qe.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:qe,params:{appends:["category"]}},"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:he.title,category:he.category,type:he.type,enabled:he.enabled,sync:he.sync,description:he.description,options:he.options}}}}}}}},Xl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=A.useForm();return{run(){return D(this,null,function*(){yield o.revision({filterByTk:i,values:a}),b.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},Rl={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":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=A.useForm();return{run(){return D(this,null,function*(){try{const c=JSON.parse(a.params);yield o.test({filterByTk:i,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function ec(e){const{isOver:t,setNodeRef:o}=Me.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function tc(e){const{attributes:t,listeners:o,setNodeRef:n}=Me.useDraggable({id:e.id,data:e.data});return r.jsx("div",I(v(v({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const oc=A.observer(({item:e})=>r.jsx(ec,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(tc,{id:e.id.toString(),data:e,children:r.jsx(Dn,{item:e})})})}),{displayName:"TabTitle"}),Dn=({item:e})=>{const{t}=Q.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},nc=A.observer(e=>{const[t,o]=y.useState(null),{refresh:n}=ro(),i=s.useAPIClient(),a=d=>D(null,null,function*(){const{active:u,over:f}=d;setTimeout(()=>{o(null)}),f&&f.id!==u.id&&(yield i.resource("workflowCategories").move({sourceId:u.id,targetId:f.id}),n())});function l(d){var u;o((u=d.active)==null?void 0:u.data.current)}const c=Me.useSensor(Me.MouseSensor,{activationConstraint:{distance:10}}),p=Me.useSensors(c);return r.jsxs(Me.DndContext,{sensors:p,onDragEnd:a,onDragStart:l,children:[e.children,r.jsx(Me.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(Dn,{item:t})}):null})]})},{displayName:"DndProvider"}),On=e=>{const{children:t,params:o,type:n}=e,i=s.useAPIClient(),[a,l]=y.useState([]),[c,p]=y.useState(!0),[d,u]=y.useState({tab:ge.value,item:ge.item}),f=s.useCompile(),{modal:g}=b.App.useApp(),h=y.useCallback(()=>D(null,null,function*(){p(!0);const{data:k}=yield i.request({url:"workflowCategories:list",params:o});l(k.data),ge.value&&!k.data.find(F=>F.id===ge.value)&&(ge.value="",ge.item={},u({tab:"",item:{}})),p(!1)}),[]);y.useEffect(()=>{h()},[h]);const x=k=>{g.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>D(null,null,function*(){yield i.resource("workflowCategories").destroy({filter:{id:k}}),u({tab:"",item:{}}),ge.value="",ge.item={},h()})})},C=te.memoize(k=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[A.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:k}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>x(k.id)}]}));return r.jsx(Cn.Provider,{value:{refresh:h,activeKey:d.tab,setActiveKey:k=>u({tab:k,item:a.find(F=>F.id===k)})},children:r.jsx(nc,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary",categoryType:n}}}}}),type:"editable-card",activeKey:d.tab,onChange:k=>{const F=a.find(w=>w.id===k);u({tab:k,item:F}),ge.value=k,ge.item=F,k===""&&h()},defaultActiveKey:d.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:T("All"),closable:!1}].concat(a).filter(k=>k&&k.name!=null&&k.id!=null).map(k=>({label:k.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(oc,{item:k})}):f(k.name),key:k.id,closable:k.closable,closeIcon:r.jsx(b.Dropdown,{menu:C(k),children:r.jsx(j.MenuOutlined,{role:"button","aria-label":f(k.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:t})}))})})})},Pn=A.observer(e=>{const{params:t}=e,o={collection:qe,action:"list",params:I(v({},t),{filter:v({},t.filter)}),rowKey:"id"};return ge.value&&(o.params.filter["category.id"]=[ge.value]),r.jsx(s.TableBlockProvider,v(v({},e),o))}),En={type:"void",properties:{eventSourceProvider:{type:"void","x-decorator":Ul,properties:{provider:{type:"void","x-decorator":Pn,"x-decorator-props":{params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]}},"x-component":On,"x-component-props":{params:{paginate:!1,sort:["sort"],filter:{type:{$ne:"approval"}}},type:"workflow"},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}=Q.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=A.useForm();return{run(){return D(this,null,function*(){const{data:p}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:I(v({},l),{workflow:p})}),b.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:Tn}},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"}}},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 y.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:no}}}},executedTime:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Finally executed on"),"x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{executedTime:{type:"string","x-component":"ColumnExecutedTime"}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},showEventSource:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Event source"),properties:{showEventSource:{type:"string","x-component":"ColumnShowEventSource"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"workflows.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},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:Nn,revision:Xl,test:Rl,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}=Q.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"});tn.saveAs(a,i.data.title+"-"+i.data.key+".json"),b.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}}}},rc=()=>{const{t:e}=Q.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(re.Link,{"aria-label":n(),to:We(t),onClick:()=>o(!1),children:e("Configure")})};function sc(e){const t=A.useField(),o=s.usePlugin(X);return A.useFormEffects(()=>{A.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,v({},e))}function Mn(e){const{schema:t=En,components:o,scopes:n}=e,i=y.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(X);return r.jsx(s.ExtendCollectionsProvider,{collections:[qe,oo,In],children:r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:rc,ExecutionResourceProvider:Zl,ExecutionLink:Jt,OpenDrawer:Po,ExecutionStatusSelect:Mo,SyncOptionSelect:sc,ExecutionStatusColumn:Gt,ColumnShowTitle:Gl,ColumnShowCollection:ql,AddWorkflowCategory:jl,AddWorkflowCategoryAction:kn,EditWorkflowCategory:Yl,EditWorkflowCategoryAction:An,ColumnShowEventSource:_l,ColumnExecutedTime:Ll},o),scope:v({getTriggersOptions:a,ExecutionRetryAction:Yt,useCreateFormBlockProps:Fn},n)})})})}class X extends s.Plugin{constructor(){super(...arguments),this.triggers=new M.Registry,this.instructions=new M.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 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(Ca),yield this.pm.add(ha),yield this.pm.add(fa),yield this.pm.add(ai),yield this.pm.add(xs),yield this.pm.add(Gr),yield this.pm.add(Vr),yield this.pm.add(Er),yield this.pm.add(va),yield this.pm.add(ps),yield this.pm.add(Na),yield this.pm.add(xa),yield this.pm.add(ua),yield this.pm.add(Aa),yield this.pm.add(oa),yield this.pm.add(gs),yield this.pm.add(ms)})}load(){return D(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Mn,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:wn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:ko,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(fl),this.registerTrigger("collection",hl),this.registerTrigger("schedule",Ml),this.registerInstruction("calculation",Da),this.registerInstruction("condition",ol),this.registerInstruction("end",ll),this.registerInstruction("updateorcreate",ml),this.registerInstruction("query",cl),this.registerInstruction("create",il),this.registerInstruction("update",pl),this.registerInstruction("destroy",al)})}addComponents(){this.app.addComponents({WorkflowLink:Rn,WorkflowPage:wn,ExecutionPage:ko})}}S.AddButton=Wt,S.AdditionNotifiedPerson=is,S.AutoResizeInput=$o,S.BaseTypeSets=Oe,S.Branch=Ve,S.BuiltinGroupType=Ke,S.CheckboxGroupWithTooltip=Oo,S.CollectionBlockInitializer=De,S.ConfigButtonMessage=ls,S.DetailsBlockProvider=jt,S.EXECUTION_STATUS=pe,S.ExecutionContextProvider=Qo,S.ExecutionLink=Jt,S.ExecutionRetryAction=Yt,S.ExecutionStatusColumn=Gt,S.ExecutionStatusOptions=mt,S.ExecutionStatusOptionsMap=ft,S.ExecutionStatusSelect=Mo,S.FieldsSelect=ot,S.FilterDynamicComponent=Ie,S.FlowContext=$e,S.Instruction=H,S.JOB_STATUS=ve,S.JobStatusOptions=gt,S.JobStatusOptionsMap=Re,S.Node=fo,S.NodeDefaultView=st,S.OpenDrawer=Po,S.ProviderContextNode=mo,S.ProviderContextWorkflow=or,S.RadioWithTooltip=Fe,S.SelectNotifiedPerson=os,S.SimpleDesigner=_t,S.TabTableBlockProvider=Pn,S.Trigger=Qe,S.ValueBlock=Se,S.WorkflowPane=Mn,S.WorkflowTabCardItem=On,S.WorkflowVariableCodeMirror=Xr,S.WorkflowVariableInput=ke,S.WorkflowVariableJSON=Do,S.WorkflowVariableRawTextArea=No,S.WorkflowVariableTextArea=rt,S.collectionWorkflowCategories=In,S.collectionWorkflows=qe,S.createWorkflow=Tn,S.currentFormOptions=Ao,S.default=X,S.defaultFieldNames=ue,S.executionCollection=oo,S.executionSchema=no,S.getCollectionFieldOptions=me,S.getExecutionSchema=vn,S.getWorkflowDetailPath=We,S.getWorkflowExecutionsPath=tt,S.isValidFilter=et,S.linkNodes=ht,S.nodesOptions=xt,S.scopeOptions=zt,S.systemOptions=Io,S.traverseSchema=yt,S.triggerOptions=bt,S.updateWorkflow=Nn,S.useAvailableUpstreams=Be,S.useContextNode=xe,S.useCreateFormBlockProps=Fn,S.useFlowContext=q,S.useGetAriaLabelOfAddButton=ut,S.useRecordTriggerWorkflowsActionProps=ci,S.useStyles=be,S.useTrigger=Ze,S.useTriggerWorkflowsActionProps=li,S.useWorkflowAnyExecuted=Bo,S.useWorkflowExecuted=Ht,S.useWorkflowVariableFormOptions=To,S.useWorkflowVariableOptions=ce,S.workflowFieldset=he,S.workflowSchema=En,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
902
|
+
`},properties:Jl[o]}}},components:{OnField:xn,RepeatField:Hl,EndsByField:$l}})]})};class Zl extends Re{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:Ql}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:a}=s.useCollectionManager_deprecated(),i=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),t.mode===qe.DATE_FIELD){const[c]=fe(F(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:O("Trigger data")}}],compile:n,getCollectionFields:a}));c&&i.push(c)}return i}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 ao={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=Wr(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(se.Link,{to:Le(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:gt}}]},En=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:ao,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:a}=s.useDataBlockRequest(),i=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return P(this,null,function*(){yield i.destroy({filter:a==null?void 0:a.filter}),b.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},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}}}}}}}}}},io=En();function Xl(n){var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const{workflow:i}=Y(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function Rl(){var J,_;const e=se.useNavigate(),{t}=ee.useTranslation(),o=s.useApp(),{data:n,refresh:a,loading:i}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,u]=x.useState(!1),[p,f]=x.useState(!1),[y,h]=x.useState(null),{styles:g}=we(),{modal:w}=b.App.useApp(),D=(J=window.location.pathname.split("business-components/")[1])==null?void 0:J.split("/")[0],S=o.systemSettingsManager.get(`business-components.${D}`)||{},I=s.useCompile();if(x.useEffect(()=>{var de;const{title:z}=(de=n==null?void 0:n.data)!=null?de:{};c==null||c(`${O("Workflow")}${z?`: ${z}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const R=(_=n==null?void 0:n.data)!=null?_:{},{nodes:M=[],revisions:E=[]}=R,N=Q(R,["nodes","revisions"]);xt(M);const V=M.find(z=>!z.upstream);function K({key:z}){z!==N.id&&e(Le(z,D))}function q(z){return P(this,null,function*(){yield l.update({filterByTk:N.id,values:{enabled:z}}),a()})}function G(){return P(this,null,function*(){const{data:{data:z}}=yield l.retry({filterByTk:N.id,filter:{key:N.key}});e(He(z.id,D))})}function j(){return P(this,null,function*(){var z,de;try{const{data:{data:te}}=yield l.test({filterByTk:N.id,filter:{key:N.key},values:{data:{}}});if(!te||!te.id){b.message.error(O("Failed to create execution"));return}e(He(te.id,D))}catch(te){console.error("Test execution failed:",te),b.message.error(((de=(z=te==null?void 0:te.response)==null?void 0:z.data)==null?void 0:de.message)||(te==null?void 0:te.message)||O("Test execution failed"))}})}function X(){return P(this,null,function*(){const{data:{data:z}}=yield l.revision({filterByTk:N.id,filter:{key:N.key},values:{color:N.color}});b.message.success(t("Operation succeeded")),e(Le(z.id,D))})}function B(){return P(this,null,function*(){const z=N.current?O("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:z,onOk(){return P(this,null,function*(){var te;yield l.destroy({filterByTk:N.id}),b.message.success(t("Operation succeeded")),e(N.current?o.systemSettingsManager.getRoutePath("workflow"):Le((te=E.find($e=>$e.current))==null?void 0:te.id,D))})}})})}const L=()=>P(null,null,function*(){y?(yield l.moveWorkflow({id:N.id,targetKey:y}),b.message.success(O("Move success")),f(!1),N.key=y,a()):b.message.error(O("Select target workflow"))});function $(de){return P(this,arguments,function*({key:z}){switch(z){case"history":u(!0);return;case"test":return j();case"Retry":return G();case"revision":return X();case"delete":return B();case"move":h(null),f(!0);return}})}const U=N.executed&&!E.find(z=>!z.executed&&new Date(z.createdAt)>new Date(N.createdAt));return r.jsxs(Ve.Provider,{value:{workflow:N,nodes:M,refresh:a},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(To,{}),r.jsx(b.Breadcrumb,{items:[{title:r.jsx(se.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${D}`),children:I(S.label)})},{title:r.jsx("strong",{children:N.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:K,defaultSelectedKeys:[`${N.id}`],className:s.cx(g.dropdownClass,g.workflowVersionDropdownClass),items:E.sort((z,de)=>de.id-z.id).map((z,de)=>({role:"button","aria-label":`version-${de}`,key:`${z.id}`,icon:z.current?r.jsx(H.RightOutlined,{}):null,className:s.cx({executed:z.executed,unexecuted:!z.executed,enabled:z.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${z.id}`}),r.jsx("time",{children:W.str2moment(z.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:O("Version")}),r.jsx("span",{children:N!=null&&N.id?`#${N.id}`:null}),r.jsx(H.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:N.enabled,onChange:q,checkedChildren:O("On"),unCheckedChildren:O("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:O("Show execution history"),disabled:!N.allExecuted},{role:"button","aria-label":"test",key:"test",label:O("Execute empty test")},{role:"button","aria-label":"Retry",key:"Retry",label:O("Retry"),disabled:!N.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:O("Move"),disabled:N.current}],onClick:$},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(H.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(s.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:Xl,ExecutionLink:Zt,ExecutionStatusColumn:Yt},scope:{ExecutionRetryAction:Xt}})})]})]}),r.jsx(Fo,{entry:V}),r.jsxs(b.Modal,{title:O("Move workflow"),visible:p,onOk:L,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:O("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:y,filterType:N.type,filterSync:N.sync,filterKey:{$ne:N.key},onChange:z=>h(z)})]})]})}const lo=()=>{const e=se.useParams(),{styles:t}=we();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:Rl}})})},Mn=x.createContext({data:[],refresh:()=>{},activeKey:"",setActiveKey:()=>{},categoriesLoaded:!1}),co=()=>x.useContext(Mn),ec=A.observer(e=>{const{value:t}=e,o=s.useCompile();return r.jsx(r.Fragment,{children:t==null?void 0:t.map(n=>r.jsx(b.Tag,{color:n.color,children:o(n==null?void 0:n.name)},n.name))})},{displayName:"WorkflowCategory"}),tc=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient();return{run(){return P(this,null,function*(){yield e.submit();const i=ae.cloneDeep(e.values);yield n.resource("workflowCategories").create({values:F(v({},i),{type:t==null?void 0:t.categoryType})}),t.setVisible(!1),yield e.reset(),o()})}}},oc=e=>r.jsx($n,v({},e)),$n=e=>{const{scope:t,getContainer:o,children:n,categoryType:a}=e,[i,l]=x.useState(!1),{t:c}=ve(),d=nc(a),u={visible:i,setVisible:l,categoryType:a};return r.jsxs(s.ActionContextProvider,{value:u,children:[r.jsx("div",{onClick:()=>l(!0),title:c("Add category"),children:n||r.jsx(H.PlusOutlined,{})}),r.jsx(s.SchemaComponent,{schema:d,components:{CollectionCategory:ec},scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useCreateworkflowCategry:tc},t)})]})},nc=e=>({type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",categoryType:e,useAction:"{{ useCreateworkflowCategry }}",style:{marginLeft:"8px"}}}}}}}}}),rc=()=>{var i;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(i=e.config)==null?void 0:i.collection,n=t.getCollection(o),a=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"center"},children:a})},sc=()=>{const t=s.useCollectionRecordData().eventSourceName||"-";return r.jsx("div",{style:{textAlign:"left"},children:t})},ac=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:a,title:i}=e,l=n.find(c=>c.value===a);return r.jsx(b.Tooltip,{title:t(l.label),placement:"right",color:"cyan",style:{},children:r.jsx("span",{style:{display:"inline-block",maxWidth:300,textAlign:"left",cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})})},ic=()=>{const e=A.useForm(),t=s.useActionContext(),{refresh:o}=co(),n=s.useAPIClient(),{id:a}=s.useRecord();return{run(){return P(this,null,function*(){yield e.submit();const l=ae.cloneDeep(e.values);yield n.resource("workflowCategories").update({filter:{id:a},values:v({},l)}),t.setVisible(!1),yield e.reset(),o()})}}},lc=e=>{const t=s.useRecord(),o=s.useRequest(()=>Promise.resolve({data:ae.cloneDeep(t)}),F(v({},e),{manual:!0})),n=s.useActionContext();return x.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},cc=e=>r.jsx(Bn,v({},e)),Bn=e=>{const{scope:t,getContainer:o,item:n,children:a}=e,[i,l]=x.useState(!1),c=s.useCompile();return r.jsx(s.RecordProvider,{record:n,children:r.jsxs(s.ActionContextProvider,{value:{visible:i,setVisible:l},children:[r.jsx(r.Fragment,{children:a||r.jsx("span",{onClick:()=>l(!0),children:c('{{ t("Edit category") }}')})}),r.jsx(s.SchemaComponent,{schema:dc,scope:v({getContainer:o,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:ic,useValuesFromRecord:lc},t)})]})})},dc={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},uc=n=>{var a=n,{params:e,filter:t={}}=a,o=Q(a,["params","filter"]);const i=s.useCollectionRecordData(),l=F(v({},o),{params:F(v({},e),{filter:F(v({},e==null?void 0:e.filter),{key:i.key})})});return r.jsx(s.TableBlockProvider,v({},l))},le=A.observable({value:"",item:{}}),Ke={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:"belongsToMany",name:"category",target:"workflowCategories",sourceKey:"key",foreignKey:"workflowKey",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"workflowCategory",collectionName:"workflows",interface:"m2m",uiSchema:{title:`{{t("Category", { ns: "${m}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{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:T("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":{multiple:!0,fieldNames:{value:"id",label:"nickname"}}}}]},Vn={name:"workflowCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Type")}}',type:"string","x-component":"Input"}}]},be={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",default:!0,"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}" }) }}`}]}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Wn=()=>{const{form:e}=s.useFormBlockProps();return le.value&&(e.values.category=[le.item]),{form:e}},jn={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":`${Ke.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:Ke},"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:be.title,category:be.category,type:be.type,sync:be.sync,description:be.description,options:be.options}}}}}}}},Ln={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":`${Ke.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:Ke,params:{appends:["category"]}},"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:be.title,category:be.category,type:be.type,enabled:be.enabled,sync:be.sync,description:be.description,options:be.options}}}}}}}},pc={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"},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRevisionAction }}"}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},mc={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":"CodeMirror","x-component-props":{height:"50vh",defaultLanguage:"json"}},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}=ee.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),a=s.useFilterByTk(),{values:i}=A.useForm();return{run(){return P(this,null,function*(){try{const c=JSON.parse(i.params);yield o.test({filterByTk:a,values:c}),t(),n(!1)}catch(c){console.error(c)}})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}};function fc(e){const{isOver:t,setNodeRef:o}=Be.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return r.jsx("div",{ref:o,style:n,children:e.children})}function gc(e){const{attributes:t,listeners:o,setNodeRef:n}=Be.useDraggable({id:e.id,data:e.data});return r.jsx("div",F(v(v({ref:n},o),t),{children:r.jsx("div",{children:e.children})}))}const hc=A.observer(({item:e})=>r.jsx(fc,{id:e.id.toString(),data:e,children:r.jsx("div",{children:r.jsx(gc,{id:e.id.toString(),data:e,children:r.jsx(zn,{item:e})})})}),{displayName:"TabTitle"}),zn=({item:e})=>{const{t}=ee.useTranslation(),o=s.useCompile();return r.jsxs(b.Space,{children:[r.jsx(b.Badge,{color:e.color}),t(o(e.name))]})},yc=A.observer(e=>{const[t,o]=x.useState(null),{refresh:n}=co(),a=s.useAPIClient(),i=u=>P(null,null,function*(){const{active:p,over:f}=u;setTimeout(()=>{o(null)}),f&&f.id!==p.id&&(yield a.resource("workflowCategories").move({sourceId:p.id,targetId:f.id}),n())});function l(u){var p;o((p=u.active)==null?void 0:p.data.current)}const c=Be.useSensor(Be.MouseSensor,{activationConstraint:{distance:10}}),d=Be.useSensors(c);return r.jsxs(Be.DndContext,{sensors:d,onDragEnd:i,onDragStart:l,children:[e.children,r.jsx(Be.DragOverlay,{children:t?r.jsx("span",{style:{whiteSpace:"nowrap"},children:r.jsx(zn,{item:t})}):null})]})},{displayName:"DndProvider"}),qn=e=>{const{children:t,params:o,type:n}=e,a=s.useAPIClient(),[i,l]=x.useState([]),[c,d]=x.useState(!1),[u,p]=x.useState({tab:le.value,item:le.item}),f=s.useCompile(),{modal:y}=b.App.useApp(),h=x.useCallback(()=>P(null,null,function*(){const{data:C}=yield a.request({url:"workflowCategories:list",params:o});l(C.data),le.value&&!C.data.find(D=>D.id===le.value)&&(le.value="",le.item={},p({tab:"",item:{}})),d(!0)}),[a,o]);x.useEffect(()=>{h()},[h]);const g=C=>{y.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>P(null,null,function*(){yield a.resource("workflowCategories").destroy({filter:{id:C}}),p({tab:"",item:{}}),le.value="",le.item={},h()})})},w=ae.memoize(C=>({items:[{key:"edit",label:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[A.uid()]:{"x-component":"EditWorkflowCategory","x-component-props":{item:C}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>g(C.id)}]}));return r.jsx(Mn.Provider,{value:{data:i,refresh:h,activeKey:u.tab,setActiveKey:C=>p({tab:C,item:i.find(D=>D.id===C)}),categoriesLoaded:c},children:r.jsx(yc,{children:r.jsx(b.Tabs,{addIcon:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWorkflowCategory","x-component-props":{type:"primary",categoryType:n}}}}}),type:"editable-card",activeKey:u.tab,onChange:C=>{const D=i.find(S=>S.id===C);p({tab:C,item:D}),le.value=C,le.item=D,C===""&&h()},defaultActiveKey:u.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:O("All"),closable:!1}].concat(i).filter(C=>C&&C.name!=null&&C.id!=null).map(C=>({label:C.id!==""?r.jsx("div",{"data-no-dnd":"true",children:r.jsx(hc,{item:C})}):f(C.name),key:C.id,closable:C.closable,closeIcon:r.jsx(b.Dropdown,{menu:w(C),children:r.jsx(H.MenuOutlined,{role:"button","aria-label":f(C.name),style:{padding:8,margin:"-8px"}})}),children:r.jsx(s.CardItem,{children:t})}))})})})},Un=A.observer(e=>{const{params:t={}}=e,{filter:o}=s.useParsedFilter({filterOption:t==null?void 0:t.filter}),n=x.useMemo(()=>{const c=o&&Object.keys(o).length>0?v({},o):{};return le.value?c["category.id"]=[le.value]:delete c["category.id"],{collection:Ke,action:"listExtended",params:F(v({},t),{filter:v({},c)}),rowKey:"id"}},[t,o,le.value]),a=(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0,i=o&&Object.keys(o).length>0;return a&&!i||!(i||(t==null?void 0:t.filter)&&Object.keys(t.filter).length>0)?null:r.jsx(s.TableBlockProvider,v(v({},e),n))}),Kn={type:"void",properties:{provider:{type:"void","x-decorator":Un,"x-decorator-props":{params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]}},"x-component":qn,"x-component-props":{params:{paginate:!1,sort:["sort"],filter:{type:{$ne:"approval"}}},type:"workflow"},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"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","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:{file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input","x-reactions":{dependencies:["file"],fulfill:{state:{value:'{{$deps[0]?.title || $deps[0]?.filename || ""}}'}}}},category:{"x-collection-field":"workflows.category","x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{multiple:!0,service:{params:{filter:{$and:[{type:{$ne:"approval"}}]}}}}},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}=ee.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),a=s.useFilterByTk(),{setVisible:i}=s.useActionContext(),l=A.useForm();return le.value&&le.item&&(l.setInitialValues({category:[le.item]}),l.setValues({category:[le.item]})),{run(){return P(this,null,function*(){const{values:d}=l,{data:u}=yield t.request({url:d.file.url,baseURL:"/"});yield n.load({filterByTk:a,values:F(v({},d),{workflow:u})}),b.message.success(e("Operation succeeded")),o(),i(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:jn}},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,width:100},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},title:`{{t("Category", { ns: "${m}" })}}`,properties:{category:{type:"array","x-component":"WorkflowCategoryColumn","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:`{{t("Status", { ns: "${m}" })}}`,properties:{enabled:{type:"void","x-component":"EnabledToggle","x-component-props":{resource:"workflows"}}}},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 x.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},executedTime:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Finally executed on"),"x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{executedTime:{type:"string","x-component":"ColumnExecutedTime"}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},showEventSource:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:T("Event source"),properties:{showEventSource:{type:"string","x-component":"ColumnShowEventSource"}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0}}},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":{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:Ln,revision:pc,test:mc,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:"{{ useDumpAction }}"}}}}}}}}}}}},xc=()=>{const{t:e}=ee.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(se.Link,{"aria-label":n(),to:Le(t),onClick:()=>o(!1),children:e("Configure")})};function bc(e){const t=A.useField(),o=s.usePlugin(re);return A.useFormEffects(()=>{A.onFieldChange("type",n=>{let a=!n.value;if(n.value){const i=o.triggers.get(n.value);i.sync!=null&&(a=!0,t.setValue(i.sync))}t.setPattern(a?"disabled":"editable")})}),r.jsx(Ne,v({},e))}function _n(e){const{schema:t=Kn,components:o,scopes:n}=e,a=x.useContext(s.SchemaComponentContext),{getTriggersOptions:i}=s.usePlugin(re);return r.jsx(s.ExtendCollectionsProvider,{collections:[Ke,ao,Vn],children:r.jsx(s.SchemaComponentContext.Provider,{value:F(v({},a),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:xc,ExecutionResourceProvider:uc,ExecutionLink:Zt,OpenDrawer:Vo,ExecutionStatusSelect:jo,SyncOptionSelect:bc,ExecutionStatusColumn:Yt,ColumnShowTitle:ac,ColumnShowCollection:rc,AddWorkflowCategory:oc,AddWorkflowCategoryAction:$n,EditWorkflowCategory:cc,EditWorkflowCategoryAction:Bn,ColumnShowEventSource:sc,ColumnExecutedTime:qo,WorkflowCategoryColumn:Uo,EnabledStatusFilter:_o},o),scope:v({getTriggersOptions:i,ExecutionRetryAction:Xt,useCreateFormBlockProps:Wn,useDumpAction:nn,useRevisionAction:rn},n)})})})}class re extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(a=>{var[t,i]=a,l=i,{title:o}=l,n=Q(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 oe)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return P(this,null,function*(){yield this.pm.add(Ki),yield this.pm.add($i),yield this.pm.add(Ei),yield this.pm.add(Ca),yield this.pm.add(Es),yield this.pm.add(is),yield this.pm.add(Xr),yield this.pm.add(Jr),yield this.pm.add(qi),yield this.pm.add(Is),yield this.pm.add(Zi),yield this.pm.add(Vi),yield this.pm.add(Oi),yield this.pm.add(Hi),yield this.pm.add(wi),yield this.pm.add(Ds),yield this.pm.add(Ts)})}load(){return P(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:_n,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:lo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:zt,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(Ol),this.registerTrigger("collection",El),this.registerTrigger("schedule",Zl),this.registerInstruction("calculation",Xi),this.registerInstruction("condition",vl),this.registerInstruction("end",Sl),this.registerInstruction("updateorcreate",Dl),this.registerInstruction("query",Al),this.registerInstruction("select",Il),this.registerInstruction("create",Cl),this.registerInstruction("update",Tl),this.registerInstruction("destroy",kl)})}addComponents(){this.app.addComponents({WorkflowLink:fr,WorkflowPage:lo,ExecutionPage:zt,CollectionTreeSelect:mr})}}k.AddButton=Lt,k.AdditionNotifiedPerson=ws,k.AutoResizeInput=Lo,k.BaseTypeSets=Pe,k.Branch=je,k.BuiltinGroupType=_e,k.CheckboxGroupWithTooltip=Bo,k.CollectionBlockInitializer=Te,k.ColumnExecutedTime=qo,k.ConfigButtonMessage=ks,k.DetailsBlockProvider=qt,k.EXECUTION_STATUS=ye,k.EnabledStatusFilter=_o,k.ExecutionContextProvider=dn,k.ExecutionLink=Zt,k.ExecutionPage=zt,k.ExecutionRetryAction=Xt,k.ExecutionStatusColumn=Yt,k.ExecutionStatusOptions=gt,k.ExecutionStatusOptionsMap=ht,k.ExecutionStatusSelect=jo,k.FieldsSelect=rt,k.FilterDynamicComponent=Ae,k.FlowContext=Ve,k.Instruction=oe,k.JOB_STATUS=Ce,k.JobStatusOptions=yt,k.JobStatusOptionsMap=ot,k.Node=vo,k.NodeDefaultView=it,k.OpenDrawer=Vo,k.ProviderContextNode=bo,k.ProviderContextWorkflow=yr,k.RadioWithTooltip=Ne,k.SelectNotifiedPerson=ys,k.SimpleDesigner=Jt,k.TabTableBlockProvider=Un,k.Trigger=Re,k.ValueBlock=Ie,k.WorkflowCategoryColumn=Uo,k.WorkflowPage=lo,k.WorkflowPane=_n,k.WorkflowTabCardItem=qn,k.WorkflowVariableCodeMirror=ms,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=$o,k.WorkflowVariableRawTextArea=Mo,k.WorkflowVariableTextArea=at,k.collectionWorkflowCategories=Vn,k.collectionWorkflows=Ke,k.createWorkflow=jn,k.currentFormOptions=Do,k.default=re,k.defaultFieldNames=xe,k.executionCollection=ao,k.executionSchema=io,k.getCollectionFieldOptions=fe,k.getExecutionSchema=En,k.getWorkflowDetailPath=Le,k.getWorkflowExecutionsPath=He,k.isValidFilter=nt,k.linkNodes=xt,k.nodesOptions=vt,k.scopeOptions=Ut,k.systemOptions=Oo,k.traverseSchema=bt,k.triggerOptions=wt,k.updateWorkflow=Ln,k.useAvailableUpstreams=We,k.useContextNode=he,k.useCreateFormBlockProps=Wn,k.useDumpAction=nn,k.useFlowContext=Y,k.useGetAriaLabelOfAddButton=ft,k.useRecordTriggerWorkflowsActionProps=Ta,k.useRevisionAction=rn,k.useStyles=we,k.useTrigger=et,k.useTriggerWorkflowsActionProps=Fa,k.useWorkflowAnyExecuted=zo,k.useWorkflowExecuted=Qt,k.useWorkflowVariableFormOptions=Eo,k.useWorkflowVariableOptions=me,k.workflowFieldset=be,k.workflowSchema=Kn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|