@nocobase/plugin-workflow 1.5.0-beta.1 → 1.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +2 -2
- package/dist/externalVersion.js +10 -10
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +2 -1
- package/dist/server/Processor.d.ts +4 -0
- package/dist/server/Processor.js +12 -4
- package/package.json +3 -3
package/dist/client/index.js
CHANGED
|
@@ -509,12 +509,12 @@
|
|
|
509
509
|
margin-top: 0 !important;
|
|
510
510
|
`),children:n.jsx(tt,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(g.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function Wn(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Ln(){const{instructions:e}=l.usePlugin(le),t=l.useCompile(),{viewJob:o,setViewJob:r}=H(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},i=e.get(a.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:r},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(g.Tag,{children:t(i==null?void 0:i.title)}),n.jsx("strong",{children:a.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:kt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function zn(e){const{execution:t}=H(),o=l.useAPIClient(),r=se.useNavigate(),{styles:s}=ne(),[a,i]=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:m})=>{i(m.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:m})=>{p(m.data.reverse())}).catch(()=>{})},[t]);const d=y.useCallback(({key:m})=>{m!=t.id&&r(qe(m))},[t]);return t?n.jsx(g.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${m.id}`}),n.jsx("time",{children:Q.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Me,{statusMap:_e,status:m.status})})}))},children:n.jsxs(g.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(V.DownOutlined,{})]})}):null}function Jn(){var S;const{t:e}=X.useTranslation(),t=l.useCompile(),{data:o,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:a}=l.useDocumentTitle(),[i,c]=y.useState(null),p=l.useApp(),d=l.useAPIClient();y.useEffect(()=>{var D;const{workflow:I}=(D=o==null?void 0:o.data)!=null?D:{};a==null||a(`${I!=null&&I.title?`${I.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const m=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{g.message.success(e("Operation succeeded")),s()}).catch(I=>{console.error(I.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return r?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found"});const E=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:L={}}=E,$=L,{nodes:v=[],revisions:b=[]}=$,f=Z($,["nodes","revisions"]),k=Z(E,["jobs","workflow"]);vt(v),Wn(v,h);const F=v.find(I=>!I.upstream),M=_e[k.status];return n.jsxs(Ie.Provider,{value:{workflow:f.type?f:null,nodes:v,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:p.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx(se.Link,{to:Ce(f.id),children:f.title})})},{title:n.jsx(zn,{})}]})}),n.jsxs("aside",{children:[n.jsx(g.Tag,{color:M.color,children:t(M.label)}),k.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:m,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})}),n.jsx("time",{children:Q.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(so,{entry:F}),n.jsx(Ln,{})]})}const lo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.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:Jn}})})},ao=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return n.jsx(se.Link,{to:qe(t),onClick:()=>o(!1),children:e("View")})},Un={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return n.jsx(se.Link,{to:Ce(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Ye}}]},io={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Un,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=X.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return J(this,null,function*(){var i;yield r.destroy({filter:(i=o.params)==null?void 0:i.filter}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,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: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${u}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:`{{ $deps[0] !== ${ie.STARTED} }}`}}}]}}}}}}}}}}};function co(e){var a;const o=l.useCompile()(e.label),r=y.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(a=_e[e.value])!=null?a:{};return n.jsx(g.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Hn(e){const t=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(co,C({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Gn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return n.jsx(g.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:co,children:Ye.filter(r=>!!r.value&&r.value!==ie.ABORTED).map(r=>n.jsx(g.Select.Option,A(C({},r),{children:n.jsx(Hn,C({},r))}),r.value))}))}function uo(e){const{t}=X.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),a=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{g.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
511
511
|
display: flex;
|
|
512
|
-
`,children:[e.children,s.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function po(){const e=l.useResourceActionContext();return{onClick(){return J(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function qn(r){var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=H(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function Yn(){var I;const e=se.useNavigate(),{t}=X.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[p,d]=y.useState(!1),{styles:m}=ne(),{modal:h}=g.App.useApp();if(y.useEffect(()=>{var B;const{title:N}=(B=r==null?void 0:r.data)!=null?B:{};c==null||c(`${O("Workflow")}${N?`: ${N}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found",extra:n.jsx(g.Button,{onClick:()=>e(-1),children:O("Go back")})});const D=(I=r==null?void 0:r.data)!=null?I:{},{nodes:v=[],revisions:b=[]}=D,f=Z(D,["nodes","revisions"]);vt(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=f.id&&e(Ce(N))}function M(N){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:N}}),s()})}function S(){return J(this,null,function*(){const{data:{data:N}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});g.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function E(){return J(this,null,function*(){const N=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:N,onOk(){return J(this,null,function*(){var G;yield i.destroy({filterByTk:f.id}),g.message.success(t("Operation succeeded")),e(f.current?o.pluginSettingsManager.getRoutePath("workflow"):Ce((G=b.find(U=>U.current))==null?void 0:G.id))})}})})}function L(B){return J(this,arguments,function*({key:N}){switch(N){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const $=f.executed&&!b.find(N=>!N.executed&&new Date(N.createdAt)>new Date(f.createdAt));return n.jsxs(Ie.Provider,{value:{workflow:f,nodes:v,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(g.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(g.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:l.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((N,B)=>B.id-N.id).map((N,B)=>({role:"button","aria-label":`version-${B}`,key:`${N.id}`,icon:N.current?n.jsx(V.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${N.id}`}),n.jsx("time",{children:Q.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(g.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(g.Switch,{checked:f.enabled,onChange:M,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(g.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!$},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:L},children:n.jsx(g.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:p,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:qn,ExecutionLink:ao,ExecutionStatusColumn:uo},scope:{useRefreshActionProps:po}})})]})]}),n.jsx(so,{entry:k})]})}const mo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Yn}})})},_n=r=>{var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},Kn=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(t),onClick:()=>o(!1),children:e("Configure")})};function Zn(r){var s=r,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,i]=y.useState(!1),c=T.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[y.createElement(e,A(C({},o),{onClick(){i(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Qn({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(g.Space,{direction:"vertical",children:[n.jsx(g.Tag,{color:o,children:s(t)}),n.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const fo={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: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:Qn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"select",uiSchema:{title:`{{t("Mode", { ns: "${u}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Select",enum:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${u}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${u}" }) }}`},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,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: "${u}" }) }}`}]}},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: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Xn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:fo,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:fo},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${u}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${u}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=X.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return J(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),g.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:he.title,type:he.type,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:he.title,enabled:he.enabled,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:i}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Rn(e){const t=T.useField(),o=l.useRecord(),r=l.usePlugin(le);return T.useFormEffects(s=>{fe.onFieldChange("type",a=>{let i=o.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(ke,C({},e))}function er(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function tr(){const e=y.useContext(l.SchemaComponentContext),{useTriggersOptions:t}=l.usePlugin(le);return n.jsx(g.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:Xn,components:{WorkflowLink:Kn,ExecutionResourceProvider:_n,ExecutionLink:ao,OpenDrawer:Zn,ExecutionStatusSelect:Gn,SyncOptionSelect:Rn,ExecutionStatusColumn:uo,Tooltip:g.Tooltip},scope:{useTriggersOptions:t,useWorkflowSyncAction:er,useRefreshActionProps:po}})})})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ho={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: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
512
|
+
`,children:[e.children,s.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function po(){const e=l.useResourceActionContext();return{onClick(){return J(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function qn(r){var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=H(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function Yn(){var I;const e=se.useNavigate(),{t}=X.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[p,d]=y.useState(!1),{styles:m}=ne(),{modal:h}=g.App.useApp();if(y.useEffect(()=>{var B;const{title:N}=(B=r==null?void 0:r.data)!=null?B:{};c==null||c(`${O("Workflow")}${N?`: ${N}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found",extra:n.jsx(g.Button,{onClick:()=>e(-1),children:O("Go back")})});const D=(I=r==null?void 0:r.data)!=null?I:{},{nodes:v=[],revisions:b=[]}=D,f=Z(D,["nodes","revisions"]);vt(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=f.id&&e(Ce(N))}function M(N){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:N}}),s()})}function S(){return J(this,null,function*(){const{data:{data:N}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});g.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function E(){return J(this,null,function*(){const N=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:N,onOk(){return J(this,null,function*(){var G;yield i.destroy({filterByTk:f.id}),g.message.success(t("Operation succeeded")),e(f.current?o.pluginSettingsManager.getRoutePath("workflow"):Ce((G=b.find(U=>U.current))==null?void 0:G.id))})}})})}function L(B){return J(this,arguments,function*({key:N}){switch(N){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const $=f.executed&&!b.find(N=>!N.executed&&new Date(N.createdAt)>new Date(f.createdAt));return n.jsxs(Ie.Provider,{value:{workflow:f,nodes:v,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(g.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(g.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:l.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((N,B)=>B.id-N.id).map((N,B)=>({role:"button","aria-label":`version-${B}`,key:`${N.id}`,icon:N.current?n.jsx(V.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${N.id}`}),n.jsx("time",{children:Q.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(g.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(g.Switch,{checked:f.enabled,onChange:M,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(g.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!$},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:L},children:n.jsx(g.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:p,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:qn,ExecutionLink:ao,ExecutionStatusColumn:uo},scope:{useRefreshActionProps:po}})})]})]}),n.jsx(so,{entry:k})]})}const mo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Yn}})})},_n=r=>{var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},Kn=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(t),onClick:()=>o(!1),children:e("Configure")})};function Zn(r){var s=r,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,i]=y.useState(!1),c=T.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[y.createElement(e,A(C({},o),{onClick(){i(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Qn({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(g.Space,{direction:"vertical",children:[n.jsx(g.Tag,{color:o,children:s(t)}),n.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const fo={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: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:Qn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"radioGroup",uiSchema:{title:`{{t("Mode", { ns: "${u}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${u}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${u}" }) }}`},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,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: "${u}" }) }}`}]}},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: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Xn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:fo,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:fo},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${u}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${u}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=X.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return J(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),g.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:he.title,type:he.type,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:he.title,enabled:he.enabled,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:i}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Rn(e){const t=T.useField(),o=l.useRecord(),r=l.usePlugin(le);return T.useFormEffects(s=>{fe.onFieldChange("type",a=>{let i=o.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(ke,C({},e))}function er(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function tr(){const e=y.useContext(l.SchemaComponentContext),{useTriggersOptions:t}=l.usePlugin(le);return n.jsx(g.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:Xn,components:{WorkflowLink:Kn,ExecutionResourceProvider:_n,ExecutionLink:ao,OpenDrawer:Zn,ExecutionStatusSelect:Gn,SyncOptionSelect:Rn,ExecutionStatusColumn:uo,Tooltip:g.Tooltip},scope:{useTriggersOptions:t,useWorkflowSyncAction:er,useRefreshActionProps:po}})})})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ho={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: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
513
513
|
flex-direction: column;
|
|
514
514
|
`},"x-component":"CollectionFieldset"},ot={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=T.useForm(),[t,o]=l.parseCollectionName(e==null?void 0:e.collection);return{options:l.useCollectionFilterOptions(o,t),className:l.css`
|
|
515
515
|
position: relative;
|
|
516
516
|
width: 100%;
|
|
517
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},or={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"}}},nr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1},default:20}}}}}}},We={type:"array",title:`{{t("Preload associations", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=T.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};function rr(){const e=l.useAPIClient(),t=T.useForm(),{field:o,__parent:r}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),a=se.useNavigate(),i=T.useFieldSchema(),c=T.useField(),p=l.useCompile(),{modal:d}=g.App.useApp(),m=l.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var M,S,E;const{onSuccess:b,skipValidator:f,triggerWorkflows:k}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};f||(yield t.submit());const F=yield m();c.data=o.data||{},c.data.loading=!0;try{const L=yield e.resource("workflows").trigger({values:F,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=L,(E=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||E.call(S),s==null||s(!1),!(b!=null&&b.successMessage))return;b!=null&&b.manualClose?d.success({title:p(b==null?void 0:b.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),b!=null&&b.redirecting&&(b!=null&&b.redirectTo)&&(Q.isURL(b.redirectTo)?window.location.href=b.redirectTo:a(b.redirectTo))})}):g.message.success(p(b==null?void 0:b.successMessage))}catch(L){c.data.loading=!1}})}}}function sr(){var b;const e=l.useCompile(),t=l.useAPIClient(),o=l.useRecord(),r=T.useField(),s=T.useFieldSchema(),{field:a,__parent:i}=l.useBlockRequestContext(),{setVisible:c,setSubmitted:p}=l.useActionContext(),{modal:d}=g.App.useApp(),m=se.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(b=s==null?void 0:s["x-action-settings"])!=null?b:{};return{onClick(k,F){return J(this,null,function*(){r.data=a.data||{},r.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(M=>[M.workflowKey,M.context].filter(Boolean).join("!")).join(","):void 0}),F&&F(),c==null||c(!1),p==null||p(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let M;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return J(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(Q.isURL(h.redirectTo)?window.location.href=h.redirectTo:m(h.redirectTo))})}})}else g.message.success(e(h==null?void 0:h.successMessage))}catch(M){console.error(M)}finally{r.data.loading=!1}})}}}function lr(){const{workflow:e}=H();return!!(e!=null&&e.executed)}function yo(){const{workflow:e}=H();return!!(e!=null&&e.allExecuted)}const Se={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ar=[{label:`{{t("After record added", { ns: "${u}" })}}`,value:Se.CREATED},{label:`{{t("After record updated", { ns: "${u}" })}}`,value:Se.UPDATED},{label:`{{t("After record added or updated", { ns: "${u}" })}}`,value:Se.SAVED},{label:`{{t("After record deleted", { ns: "${u}" })}}`,value:Se.DELETED}];function ir(e,t){var p;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=je(o),i=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:O("Trigger data")}}];return Te(A(C({appends:["data",...((p=e.appends)==null?void 0:p.map(d=>`data.${d}`))||[]]},t),{fields:i,compile:s,getCollectionFields:a}))}class cr extends Mt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${u}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${u}" })}}`,className:"auto-width"},enum:ar,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Se.UPDATED})}}`}}}]},condition:A(C({},ot),{title:`{{t("Only triggers when match conditions", { ns: "${u}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && !($deps[1] & ${Se.DELETED})}}`}}}]}),appends:A(C({},We),{"x-reactions":[...We["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Se.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useWorkflowAnyExecuted:yo});w(this,"components",{FieldsSelect:Ct});w(this,"useVariables",ir)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Pe,collection:o.collection,dataPath:"$context.data"}:null}}const Ae={STATIC:0,DATE_FIELD:1};function dr(e){return!e.hidden&&(e.uiSchema?e.type
|
|
517
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},or={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"}}},nr={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1},default:20}}}}}}},We={type:"array",title:`{{t("Preload associations", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=T.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};function rr(){const e=l.useAPIClient(),t=T.useForm(),{field:o,__parent:r}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),a=se.useNavigate(),i=T.useFieldSchema(),c=T.useField(),p=l.useCompile(),{modal:d}=g.App.useApp(),m=l.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var M,S,E;const{onSuccess:b,skipValidator:f,triggerWorkflows:k}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};f||(yield t.submit());const F=yield m();c.data=o.data||{},c.data.loading=!0;try{const L=yield e.resource("workflows").trigger({values:F,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=L,(E=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||E.call(S),s==null||s(!1),!(b!=null&&b.successMessage))return;b!=null&&b.manualClose?d.success({title:p(b==null?void 0:b.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),b!=null&&b.redirecting&&(b!=null&&b.redirectTo)&&(Q.isURL(b.redirectTo)?window.location.href=b.redirectTo:a(b.redirectTo))})}):g.message.success(p(b==null?void 0:b.successMessage))}catch(L){c.data.loading=!1}})}}}function sr(){var b;const e=l.useCompile(),t=l.useAPIClient(),o=l.useRecord(),r=T.useField(),s=T.useFieldSchema(),{field:a,__parent:i}=l.useBlockRequestContext(),{setVisible:c,setSubmitted:p}=l.useActionContext(),{modal:d}=g.App.useApp(),m=se.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(b=s==null?void 0:s["x-action-settings"])!=null?b:{};return{onClick(k,F){return J(this,null,function*(){r.data=a.data||{},r.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(M=>[M.workflowKey,M.context].filter(Boolean).join("!")).join(","):void 0}),F&&F(),c==null||c(!1),p==null||p(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let M;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return J(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(Q.isURL(h.redirectTo)?window.location.href=h.redirectTo:m(h.redirectTo))})}})}else g.message.success(e(h==null?void 0:h.successMessage))}catch(M){console.error(M)}finally{r.data.loading=!1}})}}}function lr(){const{workflow:e}=H();return!!(e!=null&&e.executed)}function yo(){const{workflow:e}=H();return!!(e!=null&&e.allExecuted)}const Se={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ar=[{label:`{{t("After record added", { ns: "${u}" })}}`,value:Se.CREATED},{label:`{{t("After record updated", { ns: "${u}" })}}`,value:Se.UPDATED},{label:`{{t("After record added or updated", { ns: "${u}" })}}`,value:Se.SAVED},{label:`{{t("After record deleted", { ns: "${u}" })}}`,value:Se.DELETED}];function ir(e,t){var p;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=je(o),i=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:O("Trigger data")}}];return Te(A(C({appends:["data",...((p=e.appends)==null?void 0:p.map(d=>`data.${d}`))||[]]},t),{fields:i,compile:s,getCollectionFields:a}))}class cr extends Mt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${u}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${u}" })}}`,className:"auto-width"},enum:ar,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${u}" })}}`,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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Se.UPDATED})}}`}}}]},condition:A(C({},ot),{title:`{{t("Only triggers when match conditions", { ns: "${u}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && !($deps[1] & ${Se.DELETED})}}`}}}]}),appends:A(C({},We),{"x-reactions":[...We["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Se.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useWorkflowAnyExecuted:yo});w(this,"components",{FieldsSelect:Ct});w(this,"useVariables",ir)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Pe,collection:o.collection,dataPath:"$context.data"}:null}}const Ae={STATIC:0,DATE_FIELD:1};function dr(e){return!e.hidden&&(e.uiSchema?["date","datetimeTz","datetimeNoTz"].includes(e.type):!1)}function go({value:e,onChange:t}){const o=e!=null?e:{},{t:r}=X.useTranslation(),[s,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return n.jsxs("fieldset",{className:l.css`
|
|
518
518
|
display: flex;
|
|
519
519
|
gap: 0.5em;
|
|
520
520
|
`,children:[n.jsx(Ct,{value:o.field,onChange:i=>t(A(C({},o),{field:i})),filter:dr,placeholder:r("Select field"),className:"auto-width"}),o.field?n.jsx(g.Select,{value:s,onChange:i=>{a(i),t(A(C({},o),{offset:Math.abs(o.offset)*i}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:r("Before")},{value:1,label:r("After")}],className:"auto-width"}):null,s?n.jsxs(n.Fragment,{children:[n.jsx(g.InputNumber,{value:Math.abs(o.offset),onChange:i=>t(A(C({},o),{offset:(i!=null?i:0)*s}))}),n.jsx(g.Select,{value:o.unit||864e5,onChange:i=>t(A(C({},o),{unit:i})),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 ur({value:e,onChange:t}){const{t:o}=xt(),r=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return n.jsxs("fieldset",{className:l.css`
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,24 +11,24 @@ module.exports = {
|
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@formily/core": "2.3.0",
|
|
13
13
|
"@formily/react": "2.3.0",
|
|
14
|
-
"@nocobase/client": "1.5.0-beta.
|
|
15
|
-
"@nocobase/utils": "1.5.0-beta.
|
|
14
|
+
"@nocobase/client": "1.5.0-beta.3",
|
|
15
|
+
"@nocobase/utils": "1.5.0-beta.3",
|
|
16
16
|
"antd": "5.12.8",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
18
18
|
"react-router-dom": "6.21.0",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
20
|
"@formily/shared": "2.3.2",
|
|
21
21
|
"lodash": "4.17.21",
|
|
22
|
-
"@nocobase/database": "1.5.0-beta.
|
|
23
|
-
"@nocobase/server": "1.5.0-beta.
|
|
24
|
-
"@nocobase/logger": "1.5.0-beta.
|
|
25
|
-
"@nocobase/evaluators": "1.5.0-beta.
|
|
22
|
+
"@nocobase/database": "1.5.0-beta.3",
|
|
23
|
+
"@nocobase/server": "1.5.0-beta.3",
|
|
24
|
+
"@nocobase/logger": "1.5.0-beta.3",
|
|
25
|
+
"@nocobase/evaluators": "1.5.0-beta.3",
|
|
26
26
|
"@formily/antd-v5": "1.1.9",
|
|
27
27
|
"@formily/reactive": "2.3.0",
|
|
28
|
-
"@nocobase/actions": "1.5.0-beta.
|
|
28
|
+
"@nocobase/actions": "1.5.0-beta.3",
|
|
29
29
|
"dayjs": "1.11.10",
|
|
30
|
-
"@nocobase/data-source-manager": "1.5.0-beta.
|
|
30
|
+
"@nocobase/data-source-manager": "1.5.0-beta.3",
|
|
31
31
|
"sequelize": "6.35.2",
|
|
32
|
-
"@nocobase/plugin-workflow-test": "1.5.0-beta.
|
|
33
|
-
"@nocobase/test": "1.5.0-beta.
|
|
32
|
+
"@nocobase/plugin-workflow-test": "1.5.0-beta.3",
|
|
33
|
+
"@nocobase/test": "1.5.0-beta.3"
|
|
34
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-12-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-12-10T07:18:30.391Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-12-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-12-10T07:18:30.032Z"}
|
package/dist/server/Plugin.js
CHANGED
|
@@ -500,7 +500,8 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
500
500
|
async process(execution, job, options = {}) {
|
|
501
501
|
var _a, _b;
|
|
502
502
|
if (execution.status === import_constants.EXECUTION_STATUS.QUEUEING) {
|
|
503
|
-
await
|
|
503
|
+
const transaction = await this.useDataSourceTransaction("main", options.transaction);
|
|
504
|
+
await execution.update({ status: import_constants.EXECUTION_STATUS.STARTED }, { transaction });
|
|
504
505
|
}
|
|
505
506
|
const logger = this.getLogger(execution.workflowId);
|
|
506
507
|
const processor = this.createProcessor(execution, options);
|
package/dist/server/Processor.js
CHANGED
|
@@ -66,6 +66,10 @@ class Processor {
|
|
|
66
66
|
* @experimental
|
|
67
67
|
*/
|
|
68
68
|
transaction;
|
|
69
|
+
/**
|
|
70
|
+
* @experimental
|
|
71
|
+
*/
|
|
72
|
+
mainTransaction;
|
|
69
73
|
/**
|
|
70
74
|
* @experimental
|
|
71
75
|
*/
|
|
@@ -111,12 +115,13 @@ class Processor {
|
|
|
111
115
|
async prepare() {
|
|
112
116
|
const {
|
|
113
117
|
execution,
|
|
114
|
-
transaction,
|
|
115
118
|
options: { plugin }
|
|
116
119
|
} = this;
|
|
117
120
|
if (!execution.workflow) {
|
|
118
121
|
execution.workflow = plugin.enabledCache.get(execution.workflowId);
|
|
119
122
|
}
|
|
123
|
+
this.mainTransaction = plugin.useDataSourceTransaction("main", this.transaction);
|
|
124
|
+
const transaction = this.mainTransaction;
|
|
120
125
|
const nodes = await execution.workflow.getNodes({ transaction });
|
|
121
126
|
this.makeNodes(nodes);
|
|
122
127
|
const jobs = await execution.getJobs({
|
|
@@ -154,7 +159,7 @@ class Processor {
|
|
|
154
159
|
this.logger.debug(`config of node`, { data: node.config });
|
|
155
160
|
job = await instruction(node, prevJob, this);
|
|
156
161
|
if (!job) {
|
|
157
|
-
return
|
|
162
|
+
return this.exit();
|
|
158
163
|
}
|
|
159
164
|
} catch (err) {
|
|
160
165
|
this.logger.error(
|
|
@@ -227,7 +232,10 @@ class Processor {
|
|
|
227
232
|
async exit(s) {
|
|
228
233
|
if (typeof s === "number") {
|
|
229
234
|
const status = this.constructor.StatusMap[s] ?? Math.sign(s);
|
|
230
|
-
await this.execution.update({ status }, { transaction: this.
|
|
235
|
+
await this.execution.update({ status }, { transaction: this.mainTransaction });
|
|
236
|
+
}
|
|
237
|
+
if (this.mainTransaction && this.mainTransaction !== this.transaction) {
|
|
238
|
+
await this.mainTransaction.commit();
|
|
231
239
|
}
|
|
232
240
|
this.logger.info(`execution (${this.execution.id}) exiting with status ${this.execution.status}`);
|
|
233
241
|
return null;
|
|
@@ -238,7 +246,7 @@ class Processor {
|
|
|
238
246
|
*/
|
|
239
247
|
async saveJob(payload) {
|
|
240
248
|
const { database } = this.execution.constructor;
|
|
241
|
-
const { transaction } = this;
|
|
249
|
+
const { mainTransaction: transaction } = this;
|
|
242
250
|
const { model } = database.getCollection("jobs");
|
|
243
251
|
let job;
|
|
244
252
|
if (payload instanceof model) {
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
6
6
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
7
|
-
"version": "1.5.0-beta.
|
|
7
|
+
"version": "1.5.0-beta.3",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/plugin-workflow-test": "1.5.0-beta.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "1.5.0-beta.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ant-design/icons": "5.x",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@nocobase/test": "1.x",
|
|
45
45
|
"@nocobase/utils": "1.x"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be",
|
|
48
48
|
"keywords": [
|
|
49
49
|
"Workflow"
|
|
50
50
|
]
|