n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 4.87 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.13.4`}}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]=`c8dcf058-0c89-4f3b-a262-4db8e9e7edcb`,e._sentryDebugIdIdentifier=`sentry-dbid-c8dcf058-0c89-4f3b-a262-4db8e9e7edcb`)})()}catch{}import{Rt as e,S as t,Wt as n}from"./vue.runtime.esm-bundler-D9KLAxvJ.js";import{bt as r}from"./_MapCache-CUJwh2qp.js";import{Ca as i,Dr as a,Tr as o,aa as s,ca as c,en as l,ia as u,lt as d,na as f,r as p,s as m,sa as h,w as g,wa as _}from"./users.store-BHWXXawf.js";import{$a as v,Aa as y,Ac as b,Oc as x,Zn as S,eo as C,ho as w,kc as T,va as E}from"./constants-CIP7tKq1.js";import{r as D}from"./_baseOrderBy-CaKruttV.js";function O(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(()=>y(i.value)),isMultipleOutputsNodeType:t(()=>{let e=i.value?.outputs;return typeof e==`string`?!1:(e??[]).length>1})}}function k(y,T={}){let k=D(),A=m(),j=p(),M=u()??(A.workflowId?e(s(f(A.workflowId))):null),N=o(),P=r(),F=l(),I=a(),{getInputDataWithPinned:L}=d(),R=t(()=>A.workflowObject),{isSubNodeType:z,isMultipleOutputsNodeType:B}=O({node:y}),V=t(()=>{let e=n(y);if(!(!e||!M?.value))return c(M.value.pinData)[e.name]}),H=t(()=>!!n(y)&&V.value!==void 0),U=t(()=>{let e=n(y);return!!e&&!z.value&&!B.value&&!S.includes(e.type)});function W(e=!1,t){let r=n(y);if(r===null||S.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=E(R.value,r,i).map(e=>typeof e==`string`?{type:e}:e),s=o.filter(e=>e.type===w.Main&&e.category!==`error`),c=!0;if(t!==void 0){let e=o[t];if(o[t]===void 0)return!1;c=e.type===w.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(y);if(!t)return!1;typeof e==`object`&&(e=JSON.stringify(e));let{pinData:r,...a}=R.value,o=M?.value?.pinData??{},s=C(a,{replaceCircularRefs:!0}),c=h({...o,[t.name]:e});if(c>K())return N.showError(Error(P.baseText(`ndv.pinData.error.tooLarge.description`,{interpolate:{size:_(c),limit:_(K())}})),P.baseText(`ndv.pinData.error.tooLarge.title`)),!1;let l=i(s)+c,u=b-x;return l>u?(N.showError(Error(P.baseText(`ndv.pinData.error.tooLargeWorkflow.description`,{interpolate:{size:_(l),limit:_(u)}})),P.baseText(`ndv.pinData.error.tooLargeWorkflow.title`)),!1):!0}function J({source:e}){let t=n(y),r=n(T.displayMode),a=n(T.runIndex),o={pinning_source:e,node_type:t?.type,push_ref:k.pushRef,data_size:i(V.value),view:r,run_index:a,workflow_id:A.workflowId,node_id:t?.id};I.run(`runData.onDataPinningSuccess`,o),F.track(`Ndv data pinning success`,o)}function Y({errorType:e,source:t}){let r=n(y),a=n(T.displayMode),o=n(T.runIndex);F.track(`Ndv data pinning failure`,{pinning_source:t,node_type:r?.type,push_ref:k.pushRef,data_size:i(V.value),view:a,run_index:o,error_type:e})}function X(e,t){let r=n(y);if(r){if(typeof e==`string`){if(!G(e))throw Y({errorType:`invalid-json`,source:t}),Error(`Invalid JSON`);e=v(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(y),r=n(T.runIndex);F.track(`User unpinned ndv data`,{node_type:t?.type,push_ref:k.pushRef,run_index:r,source:e,data_size:i(V.value)})}function Q(e){let t=n(y);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{O as n,k as t};
//# sourceMappingURL=usePinnedData-bxdhY-Ce.js.map