UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

2 lines 13.6 kB
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.13.4"}}catch(e){}}(),System.register(["./chunk-legacy-TXBRODOR.js","./vue.runtime.esm-bundler-legacy-IafOlCW8.js","./_MapCache-legacy-DwgdC8YO.js","./src-legacy-Dwzr7bD0.js","./users.store-legacy-OKuN0qAC.js","./constants-legacy-DNCca_FT.js","./_baseOrderBy-legacy-PsQY_Pvh.js","./executions.store-legacy-z6ytCHo9.js","./useCanvasOperations-legacy-DHjpE9Af.js","./retry-legacy-CkrvG-jL.js","./pushConnection.store-legacy-CdZe0qqo.js"],(function(e,t){var n,o,a,i,s,r,d,c,u,l,f,g,w,N,p,y,m,h,v,b,E,k,D,T,x,A,S,R,I,C,M,_,j,W,O,P,B,q,U,F,L,V,G,$,H,Y;function J(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?J(n[0]):{}}:e&&"object"===t?function(e){const t={};return Object.entries(e).forEach((([e,n])=>{t[e]=J(n)})),{type:"object",properties:t}}(e):{type:"string"};var n}function X(e,t,n,o,a){if(e instanceof p)return e.commands.some((n=>X(n,t,e.commands,o,a)));if(e instanceof D)return e.connectionData[1]?.node===t;if(e instanceof x){const[o,a]=e.connectionData;return a.node===t&&n.some((e=>e instanceof g&&e.node.name===o.node))}const i=Object.values(o(t)).flat().flat().filter((e=>null!==e)).map((e=>e.node));return e instanceof A?i.includes(e.node.name):e instanceof f&&i.includes(e.nodeName)&&(e.newState||Object.keys(a(e.nodeName)).some((e=>e!==_.Main)))}function Q(e,t,n){const o=t.indexOf(e);if(o>=0)return t.slice(o);const a=[...t,e];for(const[i,s]of Object.entries(n(e)))if(i===_.Main)for(const e of s)for(const{node:t}of e??[]){const e=Q(t,a,n);if(e)return e}}function z(){const e=N(),t=E();function n(e){return Object.entries(t.incomingConnectionsByNodeName(e)).filter((([e])=>e!==_.Main)).flatMap((([,e])=>e.flat().filter((e=>null!==e))))}function o(e,a){if((t.getParametersLastUpdate(e)??0)>a)return h.PARAMETERS_UPDATED;for(const t of n(e))if(void 0!==o(t.node,a))return h.UPSTREAM_DIRTY}function i(o,a){for(let n=e.undoStack.length-1;n>=0;n--){const i=e.undoStack[n];if(i.getTimestamp()<a)break;if(X(i,o,[],t.incomingConnectionsByNodeName,t.outgoingConnectionsByNodeName))return h.INCOMING_CONNECTIONS_UPDATED}for(const e of n(o))if(void 0!==i(e.node,a))return h.UPSTREAM_DIRTY}const s=a((()=>{const e={};function n(o,a,i){if(i.has(o))return;const s=new Set(i);s.add(o);for(const[r,d]of Object.entries(t.outgoingConnectionsByNodeName(o)))if(r===_.Main)for(const t of d)for(const{node:o}of t??[])(!e[o]||e[o]>a)&&(e[o]=a),n(o,a+1,s)}for(const o of t.allNodes)Object.keys(t.incomingConnectionsByNodeName(o.name)).length>0||(e[o.name]=0,n(o.name,1,new Set));return e}));return{dirtinessByName:a((()=>{const e={},n=t.getWorkflowRunData??{};function a(n,o){e[n]=e[n]??o;const a=Q(n,[],t.incomingConnectionsByNodeName);if(!a)return;const i=[...a].sort(((e,t)=>(s.value[e]??Number.MAX_SAFE_INTEGER)-(s.value[t]??Number.MAX_SAFE_INTEGER)))?.[0];i&&s.value[i]&&(e[i]=e[i]??h.UPSTREAM_DIRTY)}for(const[s,r]of Object.entries(n)){const e=r[0]?.startTime??0;if(!e)continue;const n=o(s,e);if(n){a(s,n);continue}const d=i(s,e);d?a(s,d):(Object.values(t.incomingConnectionsByNodeName(s)).flat().flat().filter((e=>null!==e)).some((n=>(t.getPinnedDataLastUpdate(n.node)??0)>e))||(t.getPinnedDataLastRemovedAt(s)??0)>e)&&a(s,h.PINNED_DATA_UPDATED)}return e}))}}return e({r:z,t:function(e){const t=l(),n=s(),o=w(),i=y(),r=u(),f=c(),g=b(),N=H(),p=B(),h=L(),D=E(),x=e.workflowState??v(),A=d({workflowState:x}),R=S({router:e.router,workflowState:x}),C=q(),{dirtinessByName:O}=z(),{startChat:P}=U(),V=a((()=>D.workflowObject));function G(e){return[...e].sort(((e,t)=>{const n=D.getNodeByName(e)?.position??[0,0],o=D.getNodeByName(t)?.position??[0,0],a=n[1],i=o[1];return a===i?0:a>i?1:-1}))}async function $(e){if(!h.isConnected)throw new Error(n.baseText("workflowRun.noActiveConnectionToTheServer"));let t;x.setActiveExecutionId(null);try{t=await D.runWorkflow(e)}catch(i){throw x.setActiveExecutionId(void 0),i}const o=D.previousExecutionId!==t.executionId,a=null===D.activeExecutionId;return t.executionId&&o&&a&&x.setActiveExecutionId(t.executionId),!0===t.waitingForWebhook&&(D.executionWaitingForWebhook=!0),t}async function J(e){if(!D.activeExecutionId){o.clearAllStickyNotifications();try{let i=[];void 0!==e.destinationNode&&(i=V.value.getParentNodes(e.destinationNode.nodeName,_.Main,-1));const s=D.getWorkflowRunData;!g.stateIsDirty&&D.isWorkflowSaved[D.workflowId]||await R.saveCurrentWorkflow();const d=await t.getWorkflowDataToSave();if("default"===p.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:c}=X(i,s,d.pinData,V.value),u=e.destinationNode?D.getNodeByName(e.destinationNode.nodeName)?.type:"";let l,f;if(0===c.length&&0===i.length&&"destinationNode"in e&&void 0!==e.destinationNode?(l=e.destinationNode.nodeName,c.push(e.destinationNode.nodeName)):e.triggerNode&&e.nodeData&&!e.rerunTriggerNode?c.push(...V.value.getChildNodes(e.triggerNode,_.Main,1)):e.destinationNode&&(l=e.destinationNode.nodeName),e.triggerNode&&(f={name:e.triggerNode,data:e.nodeData}),e.destinationNode&&(D.checkIfNodeHasChatParent(e.destinationNode.nodeName)||"@n8n/n8n-nodes-langchain.chatTrigger"===u)&&"RunData.ManualChatMessage"!==e.source&&"RunData.ManualChatTrigger"!==e.source){const t=V.value.getStartNode(e.destinationNode.nodeName);if(t&&"@n8n/n8n-nodes-langchain.chatTrigger"===t.type){const n=A.getNodeInputData(t,0,0,"input")?.length>0,o=!!d.pinData?.[t.name];if(!n&&!o)return D.chatPartialExecutionDestinationNode=e.destinationNode.nodeName,void P()}}const w=d.nodes.filter((e=>!e.disabled&&e.type.toLowerCase().includes("trigger"))),y=w.find((e=>e.type===I)),h=y?.parameters?.options;e.triggerNode===y?.name&&"responseNodes"===h?.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&&y&&w.filter((e=>"@n8n/n8n-nodes-langchain.chatTrigger"!==e.type)).length&&(y.disabled=!0);const v=void 0!==e.destinationNode,b=G(c).map((e=>{let n=(0,Y.default)(s,[e,0,"source",0],null);if(null===n){const o=V.value.getParentNodes(e,_.Main,1);n=(0,Y.default)(t.executeData(V.value.connectionsBySourceNode,o,e,_.Main,0),["source",_.Main,0],null)}return{name:e,sourceData:n}})).filter((t=>!e.destinationNode||!D.checkIfNodeHasChatParent(e.destinationNode.nodeName)||t.name!==e.destinationNode.nodeName)),E={workflowId:d.id,runData:v?s??void 0:void 0,startNodes:b,triggerToStartFrom:f,chatSessionId:e.sessionId};if("destinationNode"in e){E.destinationNode=e.destinationNode;const t=D.getNodeByName(e.destinationNode?.nodeName??"")?.id;if(V.value.id&&t){const e=N.getAgentRequest(V.value.id,t);e&&(E.agentRequest={query:e.query??{},tool:{name:e.toolName??""}})}}if(E.runData){const e=Object.entries(O.value).flatMap((([e,t])=>t?[e]:[]));E.dirtyNodeNames=e.length>0?e:void 0}const k={id:M,finished:!1,mode:"manual",status:"running",createdAt:new Date,startedAt:new Date,stoppedAt:void 0,workflowId:V.value.id,executedNode:l,triggerNode:f?.name,data:W({resultData:{runData:E.runData??{},pinData:d.pinData}}),workflowData:{id:D.workflowId,name:d.name,active:d.active,createdAt:0,updatedAt:0,...d}};x.setWorkflowExecutionData(k),A.updateNodesExecutionIssues(),T().setDocumentTitle(V.value.name,"EXECUTING");const S=await $(E),C=d.pinData??{},j=e=>{const t=e.parameters.path||e.parameters.options?.path||e.webhookId;return`${p.formTestUrl}/${t}`};try{await m({nodes:d.nodes,runData:D.getWorkflowExecution?.data?.resultData?.runData,destinationNode:e.destinationNode?.nodeName,triggerNode:e.triggerNode,pinData:C,directParentNodes:i,source:e.source,getTestUrl:j})}catch(a){}return await r.run("workflowRun.runWorkflow",{nodeName:e.destinationNode?.nodeName,source:e.source}),S}catch(a){return console.error(a),x.setWorkflowExecutionData(null),T().setDocumentTitle(V.value.name,"ERROR"),void o.showError(a,n.baseText("workflowRun.showError.title"))}}}function X(e,t,n,o){const a=new Set;let i;if(null!==t&&0!==Object.keys(t).length){i={};for(const s of e){const e=o.getParentNodes(s,_.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&&(i[o]=t[o]?.slice(0,1))}}}k(i)&&(i=void 0)}return{runData:i,startNodeNames:[...a]}}return{consolidateRunDataAndStartNodes:X,runEntireWorkflow:async function(e,n){t.getWorkflowDataToSave().then((n=>{const o={workflow_id:V.value.id,node_graph_string:JSON.stringify(j(n,t.getNodeTypes(),{isCloudDeployment:f.isCloudDeployment}).nodeGraph),button_type:e};i.track("User clicked execute workflow button",o),r.run("nodeView.onRunWorkflow",o)}));let o=n??D.selectedTriggerNodeName;if(!o){const e=Object.values(V.value.nodes).filter((e=>!e.disabled&&e.type.toLowerCase().includes("trigger")));1===e.length&&(o=e[0].name)}J({triggerNode:o})},runWorkflow:J,runWorkflowApi:$,stopCurrentExecution:async function(){const e=D.activeExecutionId;let t;if(e)try{t=await C.stopCurrentExecution(e)}catch(a){const t=await D.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:D.workflow,finished:t.finished,mode:t.mode,startedAt:t.startedAt,stoppedAt:t.stoppedAt};x.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 F((async()=>{const n=await D.getExecution(e);return!["running","waiting"].includes(n?.status)&&(x.markExecutionAsStopped(t),!0)}),250,20)||x.markExecutionAsStopped(t)}},stopWaitingForWebhook:async function(){try{await D.removeTestWebhook(D.workflowId)}catch(e){return void o.showError(e,n.baseText("nodeView.showError.stopWaitingForWebhook.title"))}},sortNodesByYPosition:G}}}),{setters:[function(e){n=e.o},function(e){o=e.Nt,a=e.S},function(e){i=e.M,s=e.bt},function(e){r=e.v},function(e){d=e.$t,c=e.As,u=e.Dr,l=e.Et,f=e.Si,g=e.Ti,w=e.Tr,N=e._i,p=e.bi,y=e.en,m=e.h,h=e.hi,v=e.in,b=e.r,E=e.s,k=e.va,D=e.vi,T=e.vn,x=e.wi,A=e.yi,S=e.yn},function(e){e.Co,R=e.Fi,I=e.Gt,e.Ht,C=e.Ii,M=e.N,e.Ut,e.Wt,_=e.ho,e.nr,j=e.pa,W=e.sa},function(e){O=e.j,P=e.m,B=e.r},function(e){q=e.t},function(e){U=e.t},function(e){F=e.t},function(e){L=e.t}],execute:function(){try{t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(a=(new t.Error).stack)&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="4e74065f-d61e-4380-8fa9-dee363c32f62",t._sentryDebugIdIdentifier="sentry-dbid-4e74065f-d61e-4380-8fa9-dee363c32f62")}catch(t){}var t,a;V=e=>e.toString().split(".").concat(["0","0"]).slice(0,3).join("."),G=e=>!!e&&"object"==typeof e&&"type"in e&&"properties"in e&&!k(e.properties),$=async(e,t)=>{const{nodeType:n,version:o,resource:a,operation:i}=t,s=V(o),r=await P({method:"GET",baseURL:e,endpoint:`${["schemas",n.replace("@n8n/",""),s,a,i].filter(Boolean).join("/")}.json`,withCredentials:!1});if(!G(r))throw new Error("Invalid JSON schema");return r},e("i",O("schemaPreview",(()=>{const e=o(new Map),t=B(),n=y(),a=E();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=C(await $(t.baseUrl,n));return e.set(o,a),a}catch(s){const t=R(s);return e.set(o,t),t}},trackSchemaPreviewExecution:async function(t){if(0===e.size||"success"!==t.data.executionStatus)return;const o=a.getNodeByName(t.nodeName);if(!o)return;const{id:s,type:r,typeVersion:d,parameters:{resource:c,operation:u}}=o,l=e.get(i({nodeType:r,version:d,resource:c,operation:u}));var f;l?.ok&&n.track("User executed node with schema preview",{node_id:s,node_type:r,node_version:d,node_resource:c,node_operation:u,schema_preview:JSON.stringify(l.result),output_schema:JSON.stringify((f=t.data.data?.main?.[0]?.[0]?.json,J(f))),workflow_id:a.workflowId})}}}))),e("n",H=O("agentRequest",(()=>{const e=i("N8N_AGENT_REQUESTS",{});return{agentRequests:e,getAgentRequests:(t,n)=>e.value[t]?.[n]?.query||{},getQueryValue:(t,n,o,a)=>{const i=e.value[t]?.[n]?.query?.[o];return"string"!=typeof i&&a?i?.[a]:i},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]}}}))),Y=n(r(),1)}}})); //# sourceMappingURL=useRunWorkflow-legacy-D--lDsti.js.map