n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 4.86 kB
JavaScript
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`n8n@2.16.1`}}catch{}})();try{(function(){var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b3f1721c-a124-4b16-a849-9e369fb843e9`,e._sentryDebugIdIdentifier=`sentry-dbid-b3f1721c-a124-4b16-a849-9e369fb843e9`)})()}catch{}import{Rt as e,S as t,Wt as n}from"./vue.runtime.esm-bundler-C3C09Zii.js";import{at as r}from"./core-Bz5WjPxS.js";import{In as i,Pn as a,Ta as o,aa as s,ca as c,ct as l,fr as u,la as d,oa as f,r as p,ra as m,s as h,w as g,wa as _}from"./users.store-xP93bV7X.js";import{Bn as v,Ra as y,eo as b,ha as x,hc as S,pc as C,ra as w,za as T}from"./constants-DuQbSl-q.js";import{t as E}from"./useRootStore-XEREVjMN.js";function D(e={}){let r=g(),i=t(()=>{if(e.nodeType)return n(e.nodeType);let t=n(e.node);return t?r.getNodeType(t.type,t.typeVersion):null});return{nodeType:i,isSubNodeType:t(()=>x(i.value)),isMultipleOutputsNodeType:t(()=>{let e=i.value?.outputs;return typeof e==`string`?!1:(e??[]).length>1})}}function O(x,O={}){let k=E(),A=h(),j=p(),M=s()??(A.workflowId?e(f(m(A.workflowId))):null),N=a(),P=r(),F=u(),I=i(),{getInputDataWithPinned:L}=l(),R=t(()=>A.workflowObject),{isSubNodeType:z,isMultipleOutputsNodeType:B}=D({node:x}),V=t(()=>{let e=n(x);if(!(!e||!M?.value))return d(M.value.pinData)[e.name]}),H=t(()=>!!n(x)&&V.value!==void 0),U=t(()=>{let e=n(x);return!!e&&!z.value&&!B.value&&!v.includes(e.type)});function W(e=!1,t){let r=n(x);if(r===null||v.includes(r.type))return!1;let i=g().getNodeType(r.type,r.typeVersion),a=L(r);if(!i||e&&a.length===0)return!1;let o=w(R.value,r,i).map(e=>typeof e==`string`?{type:e}:e),s=o.filter(e=>e.type===b.Main&&e.category!==`error`),c=!0;if(t!==void 0){let e=o[t];if(o[t]===void 0)return!1;c=e.type===b.Main&&e.category!==`error`}return s.length===1&&c}function G(e){try{return JSON.parse(e),!0}catch(t){let n=P.baseText(`runData.editOutputInvalid`),r=new RegExp(/JSON\.parse:|of the JSON data/,`g`),i=t.message.replace(r,``).trim(),a=/at position (\d+)/,o=t.message.match(a);if(t.message=i.charAt(0).toUpperCase()+i.slice(1),t.message=t.message.replace(`Unexpected token ' in JSON`,P.baseText(`runData.editOutputInvalid.singleQuote`)),o){let n=parseInt(o[1],10),r=(e.slice(0,n).match(/\n/g)||[]).length;t.message=t.message.replace(a,P.baseText(`runData.editOutputInvalid.atPosition`,{interpolate:{position:`${n}`}})),t.message=`${P.baseText(`runData.editOutputInvalid.onLine`,{interpolate:{line:`${r+1}`}})} ${t.message}`}return N.showError(t,n),!1}}function K(){return window.maxPinnedDataSize??12582912}function q(e){let t=n(x);if(!t)return!1;typeof e==`object`&&(e=JSON.stringify(e));let{pinData:r,...i}=R.value,a=M?.value?.pinData??{},s=T(i,{replaceCircularRefs:!0}),l=c({...a,[t.name]:e});if(l>K())return N.showError(Error(P.baseText(`ndv.pinData.error.tooLarge.description`,{interpolate:{size:o(l),limit:o(K())}})),P.baseText(`ndv.pinData.error.tooLarge.title`)),!1;let u=_(s)+l,d=S-C;return u>d?(N.showError(Error(P.baseText(`ndv.pinData.error.tooLargeWorkflow.description`,{interpolate:{size:o(u),limit:o(d)}})),P.baseText(`ndv.pinData.error.tooLargeWorkflow.title`)),!1):!0}function J({source:e}){let t=n(x),r=n(O.displayMode),i=n(O.runIndex),a={pinning_source:e,node_type:t?.type,push_ref:k.pushRef,data_size:_(V.value),view:r,run_index:i,workflow_id:A.workflowId,node_id:t?.id};I.run(`runData.onDataPinningSuccess`,a),F.track(`Ndv data pinning success`,a)}function Y({errorType:e,source:t}){let r=n(x),i=n(O.displayMode),a=n(O.runIndex);F.track(`Ndv data pinning failure`,{pinning_source:t,node_type:r?.type,push_ref:k.pushRef,data_size:_(V.value),view:i,run_index:a,error_type:e})}function X(e,t){let r=n(x);if(r){if(typeof e==`string`){if(!G(e))throw Y({errorType:`invalid-json`,source:t}),Error(`Invalid JSON`);e=y(e)}if(!q(e))throw Y({errorType:`data-too-large`,source:t}),Error(`Data too large`);if(M?.value){let t=r.name;(M.value.pinData[t]??[]).length>0&&A.nodeMetadata[t]&&(A.nodeMetadata[t].pinnedDataLastUpdatedAt=Date.now()),M.value.pinNodeData(t,e),j.markStateDirty()}J({source:t})}}function Z({source:e}){let t=n(x),r=n(O.runIndex);F.track(`User unpinned ndv data`,{node_type:t?.type,push_ref:k.pushRef,run_index:r,source:e,data_size:_(V.value)})}function Q(e){let t=n(x);t&&(Z({source:e}),M?.value&&(M.value.unpinNodeData(t.name),A.nodeMetadata[t.name]&&(A.nodeMetadata[t.name].pinnedDataLastRemovedAt=Date.now()),j.markStateDirty()))}return{data:V,hasData:H,isValidNodeType:U,canPinNode:W,setData:X,onSetDataSuccess:J,onSetDataError:Y,unsetData:Q,onUnsetData:Z,isValidJSON:G,isValidSize:q}}export{D as n,O as t};
//# sourceMappingURL=usePinnedData-DYpKK5t1.js.map