n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 14 kB
JavaScript
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.16.1"}}catch(e){}}(),System.register(["./chunk-legacy-Dz3fjYb5.js","./vue.runtime.esm-bundler-legacy-BW6xDdqj.js","./core-legacy-VD8c7QJ-.js","./get-legacy-CLCnFf3e.js","./users.store-legacy-azRUgFdP.js","./constants-legacy-2_ytuuS3.js","./useRootStore-legacy-CC08el-l.js","./settings.store-legacy-I6rZOvfF.js","./executions.store-legacy-Cfatr-ks.js","./useCanvasOperations-legacy-B8cM-OAy.js","./retry-legacy-Sl_oDViL.js","./pushConnection.store-legacy-idli-hOS.js"],(function(e,t){var n,o,a,r,s,i,d,u,c,l,f,g,w,p,N,h,y,m,v,k,b,E,T,D,x,I,R,A,S,M,C,_,j,W,P,O,q,U,B,V,F,G,L,$,Y,H,J,X,Q,z;function K(e){if(null===e)return{type:"null"};const t=typeof e;return function(e){return["string","number","boolean"].includes(e)}(t)?{type:t}:Array.isArray(e)?{type:"array",items:(n=e).length>0?K(n[0]):{}}:e&&"object"===t?function(e){const t={};return Object.entries(e).forEach((([e,n])=>{t[e]=K(n)})),{type:"object",properties:t}}(e):{type:"string"};var n}function Z(e,t,n,o,a){if(e instanceof c)return e.commands.some((n=>Z(n,t,e.commands,o,a)));if(e instanceof N)return e.connectionData[1]?.node===t;if(e instanceof m){const[o,a]=e.connectionData;return a.node===t&&n.some((e=>e instanceof y&&e.node.name===o.node))}const r=Object.values(o(t)).flat().flat().filter((e=>null!==e)).map((e=>e.node));return e instanceof h?r.includes(e.node.name):e instanceof T&&r.includes(e.nodeName)&&(e.newState||Object.keys(a(e.nodeName)).some((e=>e!==j.Main)))}function ee(e,t,n){const o=t.indexOf(e);if(o>=0)return t.slice(o);const a=[...t,e];for(const[r,s]of Object.entries(n(e)))if(r===j.Main)for(const e of s)for(const{node:t}of e??[]){const e=ee(t,a,n);if(e)return e}}function te(){const e=l(),t=I(),n=a((()=>t.workflowId?E(x(t.workflowId)):void 0));function o(e){return n.value?.incomingConnectionsByNodeName(e)??{}}function r(e){return n.value?.outgoingConnectionsByNodeName(e)??{}}function s(e){return Object.entries(o(e)).filter((([e])=>e!==j.Main)).flatMap((([,e])=>e.flat().filter((e=>null!==e))))}function i(e,n){if((t.getParametersLastUpdate(e)??0)>n)return d.PARAMETERS_UPDATED;for(const t of s(e))if(void 0!==i(t.node,n))return d.UPSTREAM_DIRTY}function u(t,n){for(let a=e.undoStack.length-1;a>=0;a--){const s=e.undoStack[a];if(s.getTimestamp()<n)break;if(Z(s,t,[],o,r))return d.INCOMING_CONNECTIONS_UPDATED}for(const e of s(t))if(void 0!==u(e.node,n))return d.UPSTREAM_DIRTY}const c=a((()=>{const e={};function t(n,o,a){if(a.has(n))return;const s=new Set(a);s.add(n);for(const[i,d]of Object.entries(r(n)))if(i===j.Main)for(const n of d)for(const{node:a}of n??[])(!e[a]||e[a]>o)&&(e[a]=o),t(a,o+1,s)}for(const a of n.value?.allNodes??[])Object.keys(o(a.name)).length>0||(e[a.name]=0,t(a.name,1,new Set));return e}));return{dirtinessByName:a((()=>{const e={},n=t.getWorkflowRunData??{};function a(t,n){e[t]=e[t]??n;const a=ee(t,[],o);if(!a)return;const r=[...a].sort(((e,t)=>(c.value[e]??Number.MAX_SAFE_INTEGER)-(c.value[t]??Number.MAX_SAFE_INTEGER)))?.[0];r&&c.value[r]&&(e[r]=e[r]??d.UPSTREAM_DIRTY)}for(const[r,s]of Object.entries(n)){const e=s[0]?.startTime??0;if(!e)continue;const n=i(r,e);if(n){a(r,n);continue}const c=u(r,e);c?a(r,c):(Object.values(o(r)).flat().flat().filter((e=>null!==e)).some((n=>(t.getPinnedDataLastUpdate(n.node)??0)>e))||(t.getPinnedDataLastRemovedAt(r)??0)>e)&&a(r,d.PINNED_DATA_UPDATED)}return e}))}}return e({r:te,t:function(e){const t=p(),n=r(),o=g(),s=v(),i=f(),d=B(),c=D(),l=Q(),N=U(),h=Y(),y=I(),m=e.workflowState??u(),T=a((()=>y.workflowId?E(x(y.workflowId)):void 0)),W=b(),P=A({router:e.router,workflowState:m}),O=V(),{dirtinessByName:q}=te(),{startChat:H}=L(),J=F(),X=a((()=>y.workflowObject));function K(e){return[...e].sort(((e,t)=>{const n=T.value?.getNodeByName(e)?.position??[0,0],o=T.value?.getNodeByName(t)?.position??[0,0],a=n[1],r=o[1];return a===r?0:a>r?1:-1}))}async function Z(e){if(!h.isConnected)throw new Error(n.baseText("workflowRun.noActiveConnectionToTheServer"));let t;m.setActiveExecutionId(null);try{t=await y.runWorkflow(e)}catch(r){throw m.setActiveExecutionId(void 0),r}const o=y.previousExecutionId!==t.executionId,a=null===y.activeExecutionId;return t.executionId&&o&&a&&m.setActiveExecutionId(t.executionId),!0===t.waitingForWebhook&&(y.executionWaitingForWebhook=!0),t}async function ee(e){if(!y.activeExecutionId){o.clearAllStickyNotifications();try{let r=[];void 0!==e.destinationNode&&(r=X.value.getParentNodes(e.destinationNode.nodeName,j.Main,-1));const s=y.getWorkflowRunData;!c.stateIsDirty&&y.isWorkflowSaved[y.workflowId]||await P.saveCurrentWorkflow();const d=await t.getWorkflowDataToSave();if("default"===N.binaryDataMode&&"combined"===d.settings?.binaryMode)return void o.showMessage({title:n.baseText("workflowRun.showError.unsupportedExecutionLogic.title"),message:n.baseText("workflowRun.showError.unsupportedExecutionLogic.description"),type:"error"});const{startNodeNames:u}=ne(r,s,d.pinData,X.value),f=e.destinationNode?T.value?.getNodeByName(e.destinationNode.nodeName)?.type??"":"";let g,p;if(0===u.length&&0===r.length&&"destinationNode"in e&&void 0!==e.destinationNode?(g=e.destinationNode.nodeName,u.push(e.destinationNode.nodeName)):e.triggerNode&&e.nodeData&&!e.rerunTriggerNode?u.push(...X.value.getChildNodes(e.triggerNode,j.Main,1)):e.destinationNode&&(g=e.destinationNode.nodeName),e.triggerNode&&(p={name:e.triggerNode,data:e.nodeData}),e.destinationNode&&(y.checkIfNodeHasChatParent(e.destinationNode.nodeName)||y.checkIfToolNodeHasChatParent(e.destinationNode.nodeName)||"@n8n/n8n-nodes-langchain.chatTrigger"===f)&&"RunData.ManualChatMessage"!==e.source&&"RunData.ManualChatTrigger"!==e.source){const t=X.value.getStartNode(e.destinationNode.nodeName);if(t&&"@n8n/n8n-nodes-langchain.chatTrigger"===t.type){const n=W.getNodeInputData(t,0,0,"input")?.length>0,o=!!d.pinData?.[t.name];if(!n&&!o)return y.chatPartialExecutionDestinationNode=e.destinationNode.nodeName,void H()}H()}const h=d.nodes.filter((e=>!e.disabled&&e.type.toLowerCase().includes("trigger"))),v=h.find((e=>e.type===C)),b=v?.parameters?.options;e.triggerNode===v?.name&&"responseNodes"===b?.responseMode&&(d.nodes.filter((e=>!e.disabled&&("@n8n/n8n-nodes-langchain.chat"===e.type||"@n8n/n8n-nodes-langchain.chatTool"===e.type||"@n8n/n8n-nodes-langchain.chatHitlTool"===e.type||"n8n-nodes-base.respondToWebhook"===e.type)))?.length||o.showMessage({title:n.baseText("workflowRun.showWarning.noChatResponseNodes.title"),message:n.baseText("workflowRun.showWarning.noChatResponseNodes.description"),type:"warning"})),!e.destinationNode&&"RunData.ManualChatMessage"!==e.source&&v&&h.filter((e=>"@n8n/n8n-nodes-langchain.chatTrigger"!==e.type)).length&&(v.disabled=!0);const E=void 0!==e.destinationNode,D=K(u).map((e=>{let n=(0,z.default)(s,[e,0,"source",0],null);if(null===n){const o=X.value.getParentNodes(e,j.Main,1);n=(0,z.default)(t.executeData(X.value.connectionsBySourceNode,o,e,j.Main,0),["source",j.Main,0],null)}return{name:e,sourceData:n}})).filter((t=>!e.destinationNode||!y.checkIfNodeHasChatParent(e.destinationNode.nodeName)||t.name!==e.destinationNode.nodeName)),x={workflowId:d.id,runData:E?s??void 0:void 0,startNodes:D,triggerToStartFrom:p,chatSessionId:e.sessionId};if("destinationNode"in e){x.destinationNode=e.destinationNode;const t=T.value?.getNodeByName(e.destinationNode?.nodeName??"")?.id;if(X.value.id&&t){const e=l.getAgentRequest(X.value.id,t);e&&(x.agentRequest={query:e.query??{},tool:{name:e.toolName??""}})}}if(x.runData){const e=Object.entries(q.value).flatMap((([e,t])=>t?[e]:[]));x.dirtyNodeNames=e.length>0?e:void 0}const I={id:S,finished:!1,mode:"manual",status:"running",createdAt:new Date,startedAt:new Date,stoppedAt:void 0,workflowId:X.value.id,executedNode:g,triggerNode:p?.name,data:M({resultData:{runData:x.runData??{},pinData:d.pinData}}),workflowData:{id:y.workflowId,name:d.name,active:d.active,createdAt:0,updatedAt:0,...d}};m.setWorkflowExecutionData(I),W.updateNodesExecutionIssues(),w().setDocumentTitle(X.value.name,"EXECUTING");const R=await Z(x);!J?.ws&&"responseNodes"===b?.responseMode&&"RunData.ManualChatMessage"!==e.source&&"RunData.ManualChatTrigger"!==e.source&&R.executionId&&G.emit("setupWebsocket",R.executionId);const A=d.pinData??{},_=e=>{const t=e.parameters.path||e.parameters.options?.path||e.webhookId;return`${N.formTestUrl}/${t}`};try{await k({nodes:d.nodes,runData:y.getWorkflowExecution?.data?.resultData?.runData,destinationNode:e.destinationNode?.nodeName,triggerNode:e.triggerNode,pinData:A,directParentNodes:r,source:e.source,getTestUrl:_})}catch(a){}return await i.run("workflowRun.runWorkflow",{nodeName:e.destinationNode?.nodeName,source:e.source}),R}catch(a){return console.error(a),m.setWorkflowExecutionData(null),w().setDocumentTitle(X.value.name,"ERROR"),void o.showError(a,n.baseText("workflowRun.showError.title"))}}}function ne(e,t,n,o){const a=new Set;let r;if(null!==t&&0!==Object.keys(t).length){r={};for(const s of e){const e=o.getParentNodes(s,j.Main);if(!o.nodes[s].disabled){e.push(s);for(const o of e){if(!t[o]?.length&&!n?.[o]?.length||void 0!==t[o]?.[0]?.error){a.add(o);break}t[o]&&!t[o]?.[0]?.error&&(r[o]=t[o]?.slice(0,1))}}}R(r)&&(r=void 0)}return{runData:r,startNodeNames:[...a]}}return{consolidateRunDataAndStartNodes:ne,runEntireWorkflow:async function(e,n){t.getWorkflowDataToSave().then((n=>{const o={workflow_id:X.value.id,node_graph_string:JSON.stringify(_(n,t.getNodeTypes(),{isCloudDeployment:d.isCloudDeployment}).nodeGraph),button_type:e};s.track("User clicked execute workflow button",o),i.run("nodeView.onRunWorkflow",o)}));let o=n??y.selectedTriggerNodeName;if(!o){const e=Object.values(X.value.nodes).filter((e=>!e.disabled&&e.type.toLowerCase().includes("trigger")));1===e.length&&(o=e[0].name)}ee({triggerNode:o})},runWorkflow:ee,runWorkflowApi:Z,stopCurrentExecution:async function(){const e=y.activeExecutionId;let t;if(e)try{t=await O.stopCurrentExecution(e)}catch(a){const t=await y.getExecution(e);if(void 0===t)o.showMessage({title:n.baseText("nodeView.showMessage.stopExecutionCatch.unsaved.title"),message:n.baseText("nodeView.showMessage.stopExecutionCatch.unsaved.message"),type:"success"});else if(t?.finished){const e={data:t.data,workflowData:y.workflow,finished:t.finished,mode:t.mode,startedAt:t.startedAt,stoppedAt:t.stoppedAt};m.setWorkflowExecutionData(e),o.showMessage({title:n.baseText("nodeView.showMessage.stopExecutionCatch.title"),message:n.baseText("nodeView.showMessage.stopExecutionCatch.message"),type:"success"})}else o.showError(a,n.baseText("nodeView.showError.stopExecution.title"))}finally{await $((async()=>{const n=await y.getExecution(e);return!["running","waiting"].includes(n?.status)&&(m.markExecutionAsStopped(t),!0)}),250,20)||m.markExecutionAsStopped(t)}},stopWaitingForWebhook:async function(){try{await y.removeTestWebhook(y.workflowId)}catch(e){return void o.showError(e,n.baseText("nodeView.showError.stopWaitingForWebhook.title"))}},sortNodesByYPosition:K}}}),{setters:[function(e){n=e.o},function(e){o=e.Nt,a=e.S},function(e){r=e.at,s=e.v},function(e){i=e.t},function(e){d=e.Br,u=e.Et,c=e.Gr,l=e.Hr,f=e.In,g=e.Pn,w=e.Rt,p=e.Tt,N=e.Ur,h=e.Wr,y=e.Xr,m=e.Yr,v=e.fr,k=e.h,b=e.lr,E=e.oa,T=e.qr,D=e.r,x=e.ra,I=e.s,R=e.ya,A=e.zt},function(e){S=e.A,e.Gn,M=e.Ki,e.Mt,e.Nt,C=e.Pt,_=e.Qi,e.co,j=e.eo,e.jt,W=e.vi,P=e.yi},function(e){O=e.T,q=e.d,U=e.t},function(e){B=e.t},function(e){V=e.t},function(e){F=e.S,G=e.l,L=e.t},function(e){$=e.t},function(e){Y=e.t}],execute:function(){try{t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(r=(new t.Error).stack)&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="93e0441a-822a-40e0-94f5-4d10f4b33239",t._sentryDebugIdIdentifier="sentry-dbid-93e0441a-822a-40e0-94f5-4d10f4b33239")}catch(t){}var t,r;H=e=>e.toString().split(".").concat(["0","0"]).slice(0,3).join("."),J=e=>!!e&&"object"==typeof e&&"type"in e&&"properties"in e&&!R(e.properties),X=async(e,t)=>{const{nodeType:n,version:o,resource:a,operation:r}=t,s=H(o),i=await q({method:"GET",baseURL:e,endpoint:`${["schemas",n.replace("@n8n/",""),s,a,r].filter(Boolean).join("/")}.json`,withCredentials:!1});if(!J(i))throw new Error("Invalid JSON schema");return i},e("i",O("schemaPreview",(()=>{const e=o(new Map),t=U(),n=v(),r=I(),s=a((()=>r.workflowId?E(x(r.workflowId)):void 0));function i({nodeType:e,version:t,operation:n,resource:o}){return`${e}_${t}_${o?.toString()??"all"}_${n?.toString()??"all"}`}return{getSchemaPreview:async function(n){const o=i(n),a=e.get(o);if(a)return a;try{const a=P(await X(t.baseUrl,n));return e.set(o,a),a}catch(r){const t=W(r);return e.set(o,t),t}},trackSchemaPreviewExecution:async function(t){if(0===e.size||"success"!==t.data.executionStatus)return;const o=s.value?.getNodeByName(t.nodeName)??null;if(!o)return;const{id:a,type:d,typeVersion:u,parameters:{resource:c,operation:l}}=o,f=e.get(i({nodeType:d,version:u,resource:c,operation:l}));var g;f?.ok&&n.track("User executed node with schema preview",{node_id:a,node_type:d,node_version:u,node_resource:c,node_operation:l,schema_preview:JSON.stringify(f.result),output_schema:JSON.stringify((g=t.data.data?.main?.[0]?.[0]?.json,K(g))),workflow_id:r.workflowId})}}}))),e("n",Q=O("agentRequest",(()=>{const e=s("N8N_AGENT_REQUESTS",{});return{agentRequests:e,getAgentRequests:(t,n)=>e.value[t]?.[n]?.query||{},getQueryValue:(t,n,o,a)=>{const r=e.value[t]?.[n]?.query?.[o];return"string"!=typeof r&&a?r?.[a]:r},setAgentRequestForNode:(t,n,o)=>{((t,n)=>{e.value[t]||(e.value[t]={}),e.value[t][n]||(e.value[t][n]={query:{}})})(t,n),e.value[t][n]={...o,query:{...o.query}}},clearAgentRequests:(t,n)=>{e.value[t]&&(e.value[t][n]={query:{}})},clearAllAgentRequests:t=>{t?e.value[t]={}:e.value={}},getAgentRequest:(t,n)=>{if(e.value[t])return e.value[t]?.[n]}}}))),z=n(i(),1)}}}));
//# sourceMappingURL=useRunWorkflow-legacy-DKBAJ9Cs.js.map