@nocobase/plugin-workflow 2.1.0-alpha.19 → 2.1.0-alpha.20
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/964.6251d37b35710747.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client/nodes/index.d.ts +3 -0
- package/dist/common/collections/jobs.js +7 -0
- package/dist/externalVersion.js +12 -12
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/joi/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/package.json +2 -2
- package/dist/client/964.2eb66ab3cc22e6a4.js +0 -10
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["964"],{2596:function(e,t,n){n.d(t,{i:function(){return x}});var r=n(2059),o=n(9155),l=n.n(o);let a=(0,o.createContext)(null),i={didCatch:!1,error:null};class c extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=i}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,o=Array(r),l=0;l<r;l++)o[l]=arguments[l];null==(t=(n=this.props).onReset)||t.call(n,{args:o,reason:"imperative-api"}),this.setState(i)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)){var o,l;null==(o=(l=this.props).onReset)||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(i)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:l,error:i}=this.state,c=e;if(l){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if((0,o.isValidElement)(r))c=r;else if("function"==typeof t)c=t(e);else if(n)c=(0,o.createElement)(n,e);else throw i}return(0,o.createElement)(a.Provider,{value:{didCatch:l,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}var s=n(7375),u=n(3342),d=n(5324),m=n(8083),f=n(404),p=n(3872),y=n(6660),v=n(8201),b=n(4562);function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(){var e=w(["\n margin-top: 0 !important;\n "]);return h=function(){return e},e}function g(){var e=w(["\n margin-bottom: 1em;\n "]);return g=function(){return e},e}function k(){var e=w(["\n margin-top: 0 !important;\n "]);return k=function(){return e},e}function x(e){var t,n,o=e.entry,a=(0,y.A)().styles,i=(0,b.sD)(),w=(0,f.x)(),x=(0,u.useCompile)(),C=(0,u.usePlugin)(d.default),O=function(e){if(Array.isArray(e))return e}(t=l().useState(100))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return E(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),S=O[0],j=O[1],A=null==w?void 0:w.clipboard,P=A?C.instructions.get(A.type):null,N=A?P?x(P.title):A.type:"";return l().createElement("div",{className:"workflow-canvas-wrapper"},l().createElement(c,{FallbackComponent:u.ErrorFallback,onError:console.error},l().createElement("div",{className:"workflow-canvas",style:{zoom:S/100}},l().createElement("div",{className:(0,u.cx)(a.branchBlockClass,(0,u.css)(h()))},l().createElement("div",{className:a.branchClass},i?l().createElement(r.Alert,{type:"warning",message:(0,p.vV)("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:(0,u.css)(g())}):null,l().createElement(v.Vo,null),l().createElement("div",{className:(0,u.cx)(a.branchBlockClass,(0,u.css)(k()))},l().createElement(m.lg,{entry:o})),l().createElement("div",{className:a.terminalClass},(0,p.vV)("End")))))),A?l().createElement("div",{className:a.clipboardPreviewClass},l().createElement("div",{className:"workflow-clipboard-header"},l().createElement("span",null,(0,p.vV)("Copied node")),l().createElement(r.Button,{type:"text",size:"small",icon:l().createElement(s.CloseOutlined,null),onClick:function(){var e;return null==w||null==(e=w.clearClipboard)?void 0:e.call(w)}})),l().createElement("div",{className:"workflow-clipboard-card"},l().createElement("div",{className:"workflow-clipboard-type"},N),l().createElement("div",{className:"workflow-clipboard-title"},null!=(n=A.title)?n:A.type))):null,l().createElement("div",{className:"workflow-canvas-zoomer"},l().createElement(r.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:S,onChange:j})))}},3639:function(e,t,n){n.r(t),n.d(t,{ExecutionPage:function(){return I}});var r=n(3342),o=n(9155),l=n.n(o),a=n(4442),i=n(2059),c=n(7768),s=n(7375),u=n(5953),d=n(5324),m=n(2596),f=n(1958),p=n(7428),y=n(7846),v=n(3872),b=n(7065),E=n(6660),w=n(6072),h=n(6773);function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||O(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||O(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}function S(e){return(0,r.useRequest)({resource:"jobs",action:"get",params:{filterByTk:e}},{cacheKey:"job-".concat(e)})}function j(e){var t,n,o=S((0,y.$K)().viewJob.id),a=o.data;if(o.loading)return l().createElement(i.Spin,null);var c=(0,h.get)(a,"data.result");return l().createElement(r.Input.JSON,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){k(e,t,n[t])})}return e}({},e),n=n={value:c,disabled:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function A(){var e=S((0,y.$K)().viewJob.id),t=e.data;if(e.loading)return null;var n=(0,h.get)(t,"data.log");return l().createElement(b.KV,{value:n})}function P(){var e=(0,r.usePlugin)(d.default).instructions,t=(0,r.useCompile)(),n=(0,y.$K)(),o=n.viewJob,a=n.setViewJob,c=(0,E.A)().styles,s=(null!=o?o:{}).node,u=void 0===s?{}:s,m=e.get(u.type);return l().createElement(r.ActionContextProvider,{value:{visible:!!o,setVisible:a}},l().createElement(r.SchemaComponent,{components:{JobResult:j,JobLog:A},schema:{type:"void",properties:k({},"".concat(null==o?void 0:o.id,"-").concat(null==o?void 0:o.updatedAt,"-modal"),{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:l().createElement("div",{className:c.nodeTitleClass},l().createElement(i.Tag,null,t(null==m?void 0:m.title)),l().createElement("strong",null,u.title),l().createElement("span",{className:"workflow-node-id"},"#",u.id)),properties:{status:{type:"number",title:'{{t("Status", { ns: "'.concat(v.CU,'" })}}'),"x-decorator":"FormItem","x-component":"Select",enum:p.ox,"x-read-pretty":!0},updatedAt:{type:"string",title:'{{t("Executed at", { ns: "'.concat(v.CU,'" })}}'),"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:'{{t("Node result", { ns: "'.concat(v.CU,'" })}}'),"x-decorator":"FormItem","x-component":"JobResult","x-component-props":{className:c.nodeJobResultClass,autoSize:{minRows:4,maxRows:32}}},log:{type:"string","x-component":"JobLog"}}})}}))}function N(e){var t=(0,y.$K)().execution,n=(0,r.useAPIClient)(),u=(0,a.useNavigate)(),d=(0,E.A)().styles,m=(0,r.useResourceActionContext)().refresh,v=x((0,o.useState)([]),2),b=v[0],h=v[1],g=x((0,o.useState)([]),2),k=g[0],O=g[1],S=x((0,o.useState)(null),2),j=S[0],A=S[1],P=x((0,o.useState)(null),2),N=P[0],D=P[1],I=x((0,o.useState)(null),2),R=I[0],V=I[1],B=(0,o.useCallback)(function(e){t&&e&&(j!==t.id&&n.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-id",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){var n=e.data;A(t.id),h(n.data)}).catch(function(){}),(N!==t.id||R&&Date.now()-Number(R)>6e4&&k.length<10)&&n.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"id",pageSize:10,fields:["id","status","createdAt"]}).then(function(e){var n=e.data;D(t.id),V(Date.now()),O(n.data.reverse())}).catch(function(){}))},[t,j,N,R,k.length,n]),T=(0,o.useCallback)(function(e){var n=e.key;n!=t.id&&u((0,w.mz)(n))},[t.id,u]);return t?l().createElement(i.Space,null,l().createElement(i.Dropdown,{onOpenChange:B,menu:{onClick:T,defaultSelectedKeys:["".concat(t.id)],className:(0,r.cx)(d.dropdownClass,d.executionsDropdownRowClass),items:C(k).concat([t],C(b)).map(function(e){return{key:e.id,label:l().createElement(l().Fragment,null,l().createElement("span",{className:"id"},"#".concat(e.id)),l().createElement("time",null,(0,c.str2moment)(e.createdAt).format("YYYY-MM-DD HH:mm:ss"))),icon:l().createElement("span",null,l().createElement(f.p,{statusMap:p.$Y,status:e.status}))}})}},l().createElement(i.Space,null,l().createElement("strong",null,"#".concat(t.id)),l().createElement(s.DownOutlined,null))),l().createElement(i.Button,{type:"link",size:"small",icon:l().createElement(s.ReloadOutlined,null),onClick:m})):null}function D(){var e,t=(0,u.useTranslation)().t,n=(0,r.useCompile)(),d=(0,r.useResourceActionContext)(),f=d.data,b=d.loading,E=d.refresh,h=(0,r.useDocumentTitle)().setTitle,g=x((0,o.useState)(null),2),k=g[0],C=g[1],O=(0,r.useApp)(),S=(0,r.useAPIClient)();(0,o.useEffect)(function(){var e,t=(null!=(e=null==f?void 0:f.data)?e:{}).workflow;null==h||h("".concat((null==t?void 0:t.title)?"".concat(t.title," - "):"").concat((0,v.vV)("Execution history")))},[null==f?void 0:f.data,h]);var j=(0,o.useCallback)(function(){i.Modal.confirm({title:(0,v.vV)("Cancel the execution"),icon:l().createElement(s.ExclamationCircleFilled,null),content:(0,v.vV)("Are you sure you want to cancel the execution?"),onOk:function(){S.resource("executions").cancel({filterByTk:null==f?void 0:f.data.id}).then(function(){i.message.success(t("Operation succeeded")),E()}).catch(function(e){console.error(e.data.error)})}})},[null==f?void 0:f.data]),A=(0,o.useCallback)(function(){history.back()},[]);if(!(null==f?void 0:f.data))return b?l().createElement(i.Spin,null):l().createElement(i.Result,{status:"404",title:"Not found"});var D=null!=(e=null==f?void 0:f.data)?e:{},I=D.jobs,R=D.workflow,V=function(e,t){if(null==e)return{};var n,r,o,l={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}if(l=function(e,t){if(null==e)return{};var n,r,o={},l=Object.getOwnPropertyNames(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}(D,["jobs","workflow"]),B=(R||{}).nodes,T=void 0===B?[]:B;(0,w.KD)(T),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Map;e.forEach(function(e){e.jobs=[],n.set(e.id,e)}),t.forEach(function(e){var t=n.get(e.nodeId);t&&(t.jobs.push(e),e.node={id:t.id,key:t.key,title:t.title,type:t.type})}),e.forEach(function(e){e.jobs=e.jobs.sort(function(e,t){return e.id-t.id})})}(T,void 0===I?[]:I);var K=T.find(function(e){return!e.upstream}),z=p.$Y[V.status];return R?l().createElement(y.cB.Provider,{value:{workflow:R.type?R:null,nodes:T,execution:V,viewJob:k,setViewJob:C}},l().createElement("div",{className:"workflow-toolbar"},l().createElement("header",null,l().createElement(i.Breadcrumb,{items:[{title:l().createElement(a.Link,{to:O.pluginSettingsManager.getRoutePath("workflow")},(0,v.vV)("Workflow"))},{title:l().createElement(i.Tooltip,{title:"Key: ".concat(R.key)},l().createElement(a.Link,{to:(0,w.Yz)(R.id)},R.title))},{title:l().createElement(N,null)}]})),l().createElement("aside",null,l().createElement(i.Tag,{color:z.color},n(z.label)),V.status?null:l().createElement(i.Tooltip,{title:(0,v.vV)("Cancel the execution")},l().createElement(i.Button,{type:"link",danger:!0,onClick:j,shape:"circle",size:"small",icon:l().createElement(s.StopOutlined,null)})),l().createElement("time",null,(0,c.str2moment)(V.updatedAt).format("YYYY-MM-DD HH:mm:ss")))),l().createElement(m.i,{entry:K}),l().createElement(P,null)):l().createElement(i.Result,{status:"404",title:(0,v.vV)("Not found"),subTitle:(0,v.vV)("Workflow of execution is not existed"),extra:l().createElement(i.Button,{onClick:A},(0,v.vV)("Go back"))})}var I=function(){var e,t,n,o=(0,a.useParams)(),i=(0,E.A)().styles;return l().createElement("div",{className:(0,r.cx)(i.workflowPageClass)},l().createElement(r.SchemaComponent,{schema:{type:"void",properties:(e={},t="execution_".concat(o.id),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:o,appends:["jobs","workflow","workflow.nodes","workflow.versionStats","workflow.stats"],except:["jobs.result","workflow.options"]}}},"x-component":"ExecutionCanvas"},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},components:{ExecutionCanvas:D}}))}}}]);
|