PageSourceSearch

https://sublake.com/_next/static/chunks/5021-6f51dae0b9d1a263.js

js sublake.com collected 2026-10-06 12:09:47 UTC 5,678 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cc45a2e2-8e65-496b-a450-6b2662bc0b27",e._sentryDebugIdIdentifier="sentry-dbid-cc45a2e2-8e65-496b-a450-6b2662bc0b27")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5021],{55021:(e,t,a)=>{a.d(t,{$8:()=>h,K2:()=>d,PN:()=>f,T8:()=>g});var r=a(12115),n=a(18720),o=a(68576),c=a(3828),s=a(7308);let i="/api/v1/crud";function l(){let e=o.useWorkspaceStore.getState(),t={"Content-Type":"application/json"};return e.authToken&&(t.Authorization="Bearer ".concat(e.authToken)),e.workspaceId&&(t["X-Workspace-ID"]=e.workspaceId),t}async function u(e){var t,a,r;let c,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=l(),f=new AbortController,h=setTimeout(()=>f.abort(),3e4);try{c=await fetch("".concat(i).concat(e),{...u,signal:null!=(t=u.signal)?t:f.signal,headers:{...d,...u.headers}})}catch(a){let t=a instanceof Error&&"AbortError"===a.name;throw(0,s.Xu)("the API",(0,s.nG)(e),t?"timeout":"network"),t?Error("Request timed out — please try again."):a}finally{clearTimeout(h)}(0,s.iy)("the API");let g=!1;if(403===c.status)try{let e=c.clone(),t=await e.json(),r="string"==typeof(null==t?void 0:t.detail)?t.detail:(null==t||null==(a=t.detail)?void 0:a.message)||(null==t?void 0:t.message)||"";g="Not authenticated"===r}catch(e){}if(401===c.status||g)try{let t=o.useWorkspaceStore.getState();await t.initWorkspace();let a=l(),r=await fetch("".concat(i).concat(e),{...u,headers:{...a,...u.headers}});if(r.ok)return r.json();let n=await r.json().catch(()=>({detail:r.statusText})),c=Error(n.detail||n.message||"HTTP ".concat(r.status));throw(401===r.status||403===r.status)&&(c.__authExpired=!0),c}catch(e){if(!(null==e?void 0:e.__authExpired))throw e;throw n.toast.error("Session expired",{description:"Redirecting to login...",duration:3e3}),setTimeout(()=>{window.location.href="/login?redirect="+encodeURIComponent(window.location.pathname)},2e3),e}if(!c.ok){let t=await c.json().catch(()=>({detail:c.statusText})),a=c.status;if(a>=500||405===a||410===a||413===a||415===a||429===a)try{(0,s.reportIssue)(a>=500?"error":"warning","API ".concat(a," on ").concat((0,s.nG)(e)),{scope:"api",where:e,status:a,requestId:null==t?void 0:t.request_id,code:"object"==typeof(null==t?void 0:t.detail)?null==(r=t.detail)?void 0:r.code:void 0})}catch(e){}throw Error(t.detail||t.message||"HTTP ".concat(c.status))}return c.json()}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{columns:a="*",orderBy:n="created_at",ascending:s=!1,limit:i=200,offset:l=0,filters:d={},search:f,enabled:h=!0,realtime:g=!1,noWorkspaceFilter:y=!1}=t,p=(0,o.useWorkspaceStore)(e=>e.workspaceId),w=(0,o.useWorkspaceStore)(e=>e.authToken),[b,m]=(0,r.useState)([]),[k,S]=(0,r.useState)(0),[E,_]=(0,r.useState)(!0),[v,T]=(0,r.useState)(null),[I,C]=(0,r.useState)(!1),[P,j]=(0,r.useState)(!1),q=(0,r.useCallback)((e,t)=>{let r=new URLSearchParams;for(let[o,c]of(r.set("columns",a),r.set("order_by",n),r.set("ascending",String(s)),r.set("limit",String(t)),r.set("offset",String(e)),Object.entries(d)))null!=c&&""!==c&&"all"!==c&&r.set(o,String(c));return(null==f?void 0:f.query)&&f.query.length>0&&(r.set("search_column",f.column),r.set("search_query",f.query)),r.toString()},[a,n,s,JSON.stringify(d),null==f?void 0:f.query,null==f?void 0:f.column]),x=(0,r.useRef)(0);(0,r.useEffect)(()=>{x.current=b.length},[b.length]);let A=(0,r.useRef)(0),N=(0,r.useCallback)(async()=>{if(!h)return void _(!1);if(!y&&!p){_(!1),m([]);return}let t=++A.current;_(!0),T(null);try{let a=Math.max(i,x.current),r=await u("/".concat(e,"?").concat(q(l,a)));if(t!==A.current)return;let n=r.data||[];m(n),S(r.count||0),C(n.length<a)}catch(e){if(t!==A.current)return;T(e instanceof Error?e.message:"Failed to fetch"),m([])}finally{t===A.current&&_(!1)}},[e,p,w,i,l,q,h,y]);(0,r.useEffect)(()=>{N()},[N]);let D=(0,r.useCallback)(async()=>
1{if(!E&&!P&&h&&(y||p)){j(!0);try{let t=await u("/".concat(e,"?").concat(q(l+b.length,i))),a=t.data||[];a.length<i&&C(!0),m(e=>{let t=new Set(e.map(e=>e.id));return[...e,...a.filter(e=>!t.has(e.id))]}),S(t.count||0)}catch(e){T(e instanceof Error?e.message:"Failed to load more")}finally{j(!1)}}},[e,p,i,l,b.length,q,h,y,E,P]),R=b.length<k&&!I;(0,c.M7)({table:e,event:"*"},{enabled:g&&h&&(!!y||!!p),workspaceId:null!=p?p:void 0,onChange:()=>N()});let W=(0,r.useCallback)(async t=>{if(!p&&!y)return null;try{let a=(await u("/".concat(e),{method:"POST",body:JSON.stringify({data:t})})).data;return m(e=>[a,...e]),S(e=>e+1),a}catch(e){return T(e instanceof Error?e.message:"Failed to create"),null}},[e,p,y]),F=(0,r.useCallback)(async(t,a)=>{m(e=>e.map(e=>e.id===t?{...e,...a}:e));try{let r=(await u("/".concat(e,"/").concat(t),{method:"PATCH",body:JSON.stringify({data:a})})).data;return m(e=>e.map(e=>e.id===t?r:e)),r}catch(e){return T(e instanceof Error?e.message:"Failed to update"),N(),null}},[e,p,N]),O=(0,r.useCallback)(async t=>{m(e=>e.filter(e=>e.id!==t)),S(e=>Math.max(0,e-1));try{return await u("/".concat(e,"/").concat(t),{method:"DELETE"}),!0}catch(e){return T(e instanceof Error?e.message:"Failed to delete"),N(),!1}},[e,p,N]);return{data:b,count:k,isLoading:E,error:v,isEmpty:!E&&0===b.length,refetch:N,create:W,update:F,remove:O,loadMore:D,hasMore:R,isLoadingMore:P}}function f(e){return d("contacts",{orderBy:"created_at",...e})}function h(e){return d("integrations",{orderBy:"created_at",...e})}function g(e){return d("funnel_campaigns",{orderBy:"created_at",...e})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.