@odigos/ui-kit 0.0.251 → 0.0.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +0,0 @@
1
- import{useMemo as e,useContext as t,createContext as r,useCallback as a,useState as n,useEffect as o}from"react";import{HttpLink as i,from as s,split as c,ApolloClient as d,InMemoryCache as u,ApolloProvider as l,useApolloClient as E,useLazyQuery as T,useQuery as f,gql as _}from"@apollo/client";import{jsx as R}from"react/jsx-runtime";import{onError as p}from"@apollo/client/link/error";import{setContext as S}from"@apollo/client/link/context";import{getMainDefinition as y}from"@apollo/client/utilities";import{o as m,y as A,D as O,S as I,X as N,Y as C,E as g,P as h,c as L,z as P,Z as G,_ as U,$ as v,a0 as D,a1 as w,a2 as b}from"./ui-components-BKrLf2tx.js";const F=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},k=r(null),M=()=>{const e=t(k);if(!e)throw new Error("[ui-kit] useOdigosApi() / useXxxApi() called outside of <OdigosApiProvider>. Make sure the host app mounts the provider at its layout level.");return e},Y=({apolloConfig:t,operations:r,context:a,children:n})=>{const o=e(()=>(e=>{const t=new i({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=p(({graphQLErrors:t,networkError:r})=>{t&&t.length>0&&t.some(e=>F(e.message))&&e.onAuthError?.(),r&&(401===r.statusCode||F(r.message))&&e.onAuthError?.()}),a=S(async(t,r)=>{const a={...r.headers};if(e.authHeader){const t=await e.authHeader();Object.assign(a,t)}return e.csrfHeader&&Object.assign(a,e.csrfHeader()),{headers:a}}),n=[];e.additionalLinks?.length&&n.push(...e.additionalLinks),n.push(a,r,t);let o=s(n);e.wsLink&&(o=c(({query:e})=>{const t=y(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const l=e.defaultFetchPolicies;return new d({link:o,cache:new u({addTypename:e.addTypename??!0,typePolicies:e.cacheTypePolicies}),defaultOptions:{watchQuery:{fetchPolicy:l?.watchQuery??"cache-and-network"},query:{fetchPolicy:l?.query??"cache-first"},mutate:{fetchPolicy:l?.mutate??"network-only"}}})})(t),[t.httpUrl,t.wsLink,t.addTypename,t.credentials]),E=e(()=>({operations:r,context:a,apolloConfig:t}),[r,a,t]);return R(l,{client:o,children:R(k.Provider,{value:E,children:n})})},H=k,W=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),x=(e,t)=>{if(e)return"function"==typeof e?e(t):e},K=e=>{if(!e)return"Unknown error";if(e instanceof Error)return e.cause instanceof Error?e.cause.message:e.message;if("object"==typeof e){const t=e;return t.cause?.message||t.message||String(e)}return String(e)},V=(e,t)=>e.client??t,B=async(e,t,r,a,n)=>{if(!t)return{error:"Query operation not configured"};const o=x(t.document,a);if(!o)return{error:"Query operation not supported in this context"};if(t.canRun&&!t.canRun(a))return{data:void 0};const i=t.transformVariables?t.transformVariables(r,a):r,s=V(t,e);try{const e=await s.query({query:o,variables:i,fetchPolicy:"network-only"});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:e.error?K(e.error):void 0}}catch(e){return{error:K(e)}}},j=async(e,t,r,a)=>{if(!t)return{error:"Mutation operation not configured"};const n=x(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};if(t.canRun&&!t.canRun(a))return{data:void 0};const o=t.transformVariables?t.transformVariables(r,a):r,i=V(t,e);try{const e=await i.mutate({mutation:n,variables:o});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:void 0}}catch(e){return{error:K(e)}}},q=async(e,t,r,a,n)=>{if(!t)return W("Multi fetch operation not configured");if(!r.length)return W("No proxy ids supplied for multi fetch");const o=V(t,e);if(t.transformVariablesMulti&&(t.documentMulti||t.document)){const e=t.transformVariablesMulti(r,a,n),i=[];for(const r of e)try{const e=await o.query({query:r.document,variables:r.variables,fetchPolicy:"network-only"});t.transformMultiResult?t.transformMultiResult(e.data,n).forEach(e=>i.push(e)):r.proxyIDs.forEach(t=>{i.push({proxyID:t,success:!e.error,data:e.data,error:e.error?.message})})}catch(e){const t=K(e);r.proxyIDs.forEach(e=>i.push({proxyID:e,success:!1,error:t}))}const s=i.filter(e=>e.success).length,c=i.length-s,d=Array.from(new Set(i.filter(e=>!!e.error).map(e=>e.error)));return{results:i,allSucceeded:0===c,anySucceeded:s>0,successCount:s,failureCount:c,error:d.length?d.join(", "):void 0}}const i=await Promise.all(r.map(async r=>{const o={...n,proxyID:r},i=await B(e,t,a,o);return{proxyID:r,success:!i.error,data:i.data,error:i.error}})),s=i.filter(e=>e.success).length,c=i.length-s,d=Array.from(new Set(i.filter(e=>!!e.error).map(e=>e.error)));return{results:i,allSucceeded:0===c,anySucceeded:s>0,successCount:s,failureCount:c,error:d.length?d.join(", "):void 0}},Q=(e,t)=>{if(e)return"string"==typeof e?e:N(e,t)},$=e=>{const{addNotification:t}=m(),r=(r,a,n,o,i)=>t({type:r,title:a,message:n,crdType:e,target:Q(o,e),hideFromHistory:i});return{notify:r,notifyError:(e,t,a)=>r(I.Error,e,t,a),notifySuccess:(e,t,a)=>r(I.Success,e,t,a),notifyPending:(e,t)=>r(I.Default,"Pending",e,t,!0),notifyReadonly:()=>{t({type:I.Warning,title:O.READONLY,message:A.READONLY_WARNING,hideFromHistory:!0})}}},z=e=>{e({type:I.Warning,title:O.READONLY,message:A.READONLY_WARNING,hideFromHistory:!0})},X=_`
2
- query OdigosApiNoop {
3
- __typename
4
- }
5
- `,J=(e,t)=>{if(e)return"function"==typeof e?e(t):e},Z=(e,t)=>e[t],ee=(e,t,r)=>{if(void 0===t)return;return e?.transformResult?e.transformResult(t,r):t},te=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},re=(t,r,n)=>{const{operations:o,context:i}=M(),s=Z(o,t),c=e(()=>J(s?.document,i),[s,i]),d=e(()=>te(s,r,i),[s,r,i]),u=!s||!c,l=!!s?.canRun&&!s.canRun(i),E=n?.skip||u||l,T=f(c??X,{variables:d,skip:E,pollInterval:n?.pollInterval,fetchPolicy:n?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:n?.notifyOnNetworkStatusChange,client:s?.client,onCompleted:n?.onCompleted?e=>{const t=ee(s,e,i);void 0!==t&&n.onCompleted(t)}:void 0,onError:n?.onError}),_=e(()=>{if(!E)return ee(s,T.data,i)},[s,i,T.data,E]),R=a(async()=>{if(u)return{data:void 0};const e=await T.refetch();return{data:ee(s,e.data,i)}},[s,i,T,u]);return{data:_,loading:!E&&T.loading,error:T.error,refetch:R,unsupported:u}},ae=(t,r)=>{const{operations:n,context:o}=M(),i=Z(n,t),s=e(()=>J(i?.document,o),[i,o]),c=!i||!s,[d,u]=T(s??X,{fetchPolicy:r?.fetchPolicy??"network-only",notifyOnNetworkStatusChange:r?.notifyOnNetworkStatusChange,client:i?.client});return{execute:a(async e=>{if(c)return{error:void 0};if(i?.canRun&&!i.canRun(o))return{data:void 0};const t=te(i,e,o),r=await d({variables:t});return r.error?{error:r.error}:{data:ee(i,r.data,o)}},[i,o,d,c]),data:e(()=>ee(i,u.data,o),[i,o,u.data]),loading:u.loading,error:u.error,called:u.called,unsupported:c}},ne=(t,r)=>{const{operations:o,context:i}=M(),s=E(),c=Z(o,t),d=e(()=>J(c?.document,i),[c,i]),u=!c||!d,[l,T]=n({loading:!1,called:!1}),f=a(()=>T({loading:!1,called:!1}),[]);return[a(async e=>{if(u||!d)return{error:void 0};if(c?.canRun&&!c.canRun(i))return{data:void 0};const t=te(c,e,i),a=c?.client??s;T(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:d,variables:t}),n=ee(c,e.data,i);if(T({data:n,loading:!1,error:void 0,called:!0}),r?.refetchQueries){const e=a.refetchQueries({include:r.refetchQueries});r?.awaitRefetchQueries&&await e}return void 0!==n&&r?.onCompleted?.(n),{data:n}}catch(e){const t=e;return T({data:void 0,loading:!1,error:t,called:!0}),r?.onError?.(t),{error:t}}},[c,i,s,d,u,r]),{data:l.data,loading:l.loading,error:l.error,called:l.called,unsupported:u,reset:f}]},oe=(e,t,r,a)=>{let n=!0;const o={sources:[]};for(const[i,s]of Object.entries(e)){if(!s.length)continue;n=!1;const e=s.map(({id:e,selected:t,currentStreamName:a})=>({namespace:e.namespace,name:e.name,kind:e.kind,selected:void 0!==t&&t,currentStreamName:a||r}));let c=0,d=0;for(const r of e){const e=t.find(e=>e.id.namespace===i&&e.id.name===r.name&&e.id.kind===r.kind),a=e?.dataStreamNames||[];r.selected&&!e?c++:!r.selected&&e&&a.length<=1&&d++}a(c,d),o.sources.push(...e)}return{payload:o,isEmpty:n}},ie=(e,t)=>{let r=!0;const a={namespaces:[]};for(const[n,{selected:o,currentStreamName:i}]of Object.entries(e))"boolean"==typeof o&&(r=!1,a.namespaces.push({namespace:n,selected:o,currentStreamName:i||t}));return{payload:a,isEmpty:r}},se={filter:{markedForInstrumentation:!0}},ce=[],de=[],ue=async e=>{const t=(e=>{try{return new URL("/diagnose/download",e).toString()}catch{return null}})(e.httpUrl);if(t)try{const[r,a]=await Promise.all([Promise.resolve(e.authHeader?.()??{}),Promise.resolve(e.csrfHeader?.()??{})]),n=await fetch(t,{credentials:e.credentials??"same-origin",headers:{...r,...a}});if(!n.ok)throw new Error(`Failed to download diagnose archive: ${n.status} ${n.statusText}`);((e,t)=>{if("undefined"==typeof document)return;const r=URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)})(await n.blob(),`odigos-diagnose-${Date.now()}.tar.gz`)}catch(e){}},le=[],Ee=[],Te=[],fe=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),_e=t=>{const{operations:r,context:n}=M(),i=E(),s=t?.subscribe,c=!!s&&s.includes("sources"),d=!!s&&s.includes("destinations"),u=!!s&&s.includes("actions"),l=!!s&&s.includes("rules"),T=!!s&&s.includes("namespaces"),f=!!s&&s.includes("dataStreams"),_=!!s&&s.includes("destinationCategories"),R=!!s&&s.includes("potentialDestinations"),p=((e,t,r)=>{const n=E(),{notifyError:o,notifySuccess:i,notifyPending:s,notifyReadonly:c}=$(g.Source),{selectedStreamName:d}=P(),{setProgress:u,resetProgress:l}=G(),{setConfiguredSources:T,setConfiguredFutureApps:f}=U(),_=re("GET_WORKLOADS",se,{fetchPolicy:"cache-first",skip:!r?.subscribe}),R=_.data?.workloads??ce,p=(e,t)=>{const{progress:r}=G.getState();e>0&&u(v.Instrumenting,{total:(r[v.Instrumenting]?.total||0)+e,current:r[v.Instrumenting]?.current||0}),t>0&&u(v.Uninstrumenting,{total:(r[v.Uninstrumenting]?.total||0)+t,current:r[v.Uninstrumenting]?.current||0})},S=a(async()=>{const{error:r}=await B(n,e.GET_WORKLOADS,se,t);r&&o(C.Read,r)},[n,e.GET_WORKLOADS,t,o]);return{items:R,loading:_.loading,fetchAll:S,fetchByTargets:async(r,a)=>{const i=!!a?.slim,s=r.map(e=>D(e,g.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===s.length)return;if(s.length>50)return void await S();const c=i&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:d}=await B(n,c,{ids:s.map(({namespace:e,kind:t,name:r})=>({namespace:e,kind:t,name:r}))},t);d?o(C.Read,d):await S()},fetchById:async r=>{const{data:a,error:i}=await B(n,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:r.namespace,kind:r.kind,name:r.name}]},t);if(!i)return await S(),a?.workloadsByIds?.find(e=>e.id.namespace===r.namespace&&e.id.kind===r.kind&&e.id.name===r.name);o(C.Read,i)},fetchLibraries:async r=>B(n,e.GET_SOURCE_LIBRARIES,r,t),fetchPeerSources:async r=>B(n,e.GET_PEER_SOURCES,{serviceName:r},t),persist:async(r,a)=>{if(t.isReadonly)return c();const{payload:i,isEmpty:u}=oe(r,R,d,p),{payload:E,isEmpty:_}=ie(a,d);let S=!1;u||(S=!0,s("Persisting sources...")),_||S||s("Persisting namespaces...");const{error:y}=await j(n,e.PERSIST_SOURCES,i,t);if(y&&(l(v.Instrumenting),l(v.Uninstrumenting),o(C.Update,y)),e.PERSIST_NAMESPACES){const{error:r}=await j(n,e.PERSIST_NAMESPACES,E,t);r&&o(C.Update,r)}T({}),f({})},persistV2:async r=>{if(t.isReadonly)return c(),{error:"readonly"};const a=[];for(const[,o]of Object.entries(r)){const r={sources:[]},i={namespaces:[]};for(const e of o)e.name&&e.kind?r.sources.push(e):i.namespaces.push(e);if(i.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:r}=await j(n,e.PERSIST_NAMESPACES,i,t);r&&a.push(r)}if(r.sources.length>0){const{error:o}=await j(n,e.PERSIST_SOURCES,r,t);o&&a.push(o)}}return a.length?{error:a.join(", ")}:void 0},update:async(r,a)=>{if(t.isReadonly)return c();s("Updating source...");const u={sourceId:r,patchSourceRequest:{...a,currentStreamName:d}},{data:l,error:E}=await j(n,e.UPDATE_SOURCE,u,t);E?o(C.Update,E,r):l?.updateK8sActualSource&&i(C.Update,`Successfully updated "${r.name}" source`,r)},restartWorkloads:async r=>{if(t.isReadonly)return c();s("Restarting sources...");const{data:a,error:d}=await j(n,e.RESTART_WORKLOADS,{sourceIds:r},t);d?o(C.Update,d):a?.restartWorkloads&&i(C.Update,`Successfully restarted ${r.length} sources`)},restartPod:async(r,a)=>{if(t.isReadonly)return c();s("Restarting pod...");const{data:d,error:u}=await j(n,e.RESTART_POD,{namespace:r,name:a},t);u?o(C.Update,u):d?.restartPod&&i(C.Update,`Successfully restarted pod ${r}/${a}`)},recoverFromRollback:async r=>{if(t.isReadonly)return c();s("Recovering from rollback...");const{data:a,error:d}=await j(n,e.RECOVER_FROM_ROLLBACK,{sourceId:r},t);d?o(C.Update,d,r):a?.recoverFromRollbackForWorkload&&i(C.Update,"Successfully triggered recovery from rollback")}}})(r,n,{subscribe:c}),S=((e,t,r)=>{const a=E(),{notifyError:n,notifySuccess:o,notifyReadonly:i}=$(g.Destination),{selectedStreamName:s}=P(),c=re("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe}),d=re("GET_DESTINATION_CATEGORIES",void 0,{skip:!r?.subscribeCategories}),u=re("GET_POTENTIAL_DESTINATIONS",void 0,{skip:!r?.subscribePotential}),l=c.data?.computePlatform?.destinations??c.data?.destinations??Te,T=async()=>{const{error:r}=await B(a,e.GET_DESTINATIONS,void 0,t);r&&n(C.Read,r)};return{items:l,loading:c.loading,fetchAll:T,categoriesResult:d.data,categoriesLoading:d.loading,potentialResult:u.data,potentialLoading:u.loading,testConnection:async r=>{const{data:n}=await j(a,e.TEST_DESTINATION_CONNECTION,{destination:fe(r,s)},t);return n},create:async r=>{if(t.isReadonly)return i();const{error:o}=await j(a,e.CREATE_DESTINATION,{destination:fe(r,s)},t);o?n(C.Create,o):await T()},update:async(r,c)=>{if(t.isReadonly)return i();const{data:d,error:u}=await j(a,e.UPDATE_DESTINATION,{id:r,destination:fe(c,s)},t);u?n(C.Update,u,r):d?.updateDestination&&(o(C.Update,`Successfully updated "${c.type}" destination`,r),await T())},remove:async r=>{if(t.isReadonly)return i();const{error:o}=await j(a,e.DELETE_DESTINATION,{id:r,currentStreamName:s},t);o?n(C.Delete,o,r):await T()}}})(r,n,{subscribe:d,subscribeCategories:_,subscribePotential:R}),y=((e,t,r)=>{const a=E(),{notifyError:n,notifyReadonly:o}=$(g.Action),i=re("GET_ACTIONS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe}),s=i.data?.computePlatform?.actions??i.data?.actions??de,c=async()=>{const{error:r}=await B(a,e.GET_ACTIONS,void 0,t);r&&n(C.Read,r)};return{items:s,loading:i.loading,fetchAll:c,create:async r=>{if(t.isReadonly)return o();if(!e.CREATE_ACTION)return;const{error:i}=await j(a,e.CREATE_ACTION,{action:r},t);i?n(C.Create,i):await c()},update:async(r,i)=>{if(t.isReadonly)return o();if(!e.UPDATE_ACTION)return;const{error:s}=await j(a,e.UPDATE_ACTION,{id:r,action:i},t);s?n(C.Update,s,r):await c()},remove:async(r,i)=>{if(t.isReadonly)return o();if(!e.DELETE_ACTION)return;const{error:s}=await j(a,e.DELETE_ACTION,{id:r,actionType:i},t);s?n(C.Delete,s,r):await c()}}})(r,n,{subscribe:u}),A=((t,r,a)=>{const n=E(),{notifyError:o,notifyReadonly:i}=$(g.InstrumentationRule),s=re("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first",skip:!a?.subscribe}),c=e(()=>(s.data?.computePlatform?.instrumentationRules??s.data?.instrumentationRules??[]).map(w),[s.data]),d=async()=>{const{error:e}=await B(n,t.GET_INSTRUMENTATION_RULES,void 0,r);e&&o(C.Read,e)};return{items:c,loading:s.loading,fetchAll:d,create:async e=>{if(r.isReadonly)return i();if(!t.CREATE_INSTRUMENTATION_RULE)return;const{error:a}=await j(n,t.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:b(e)},r);a?o(C.Create,a):await d()},update:async(e,a)=>{if(r.isReadonly)return i();if(!t.UPDATE_INSTRUMENTATION_RULE)return;const{error:s}=await j(n,t.UPDATE_INSTRUMENTATION_RULE,{ruleId:e,instrumentationRule:b(a)},r);s?o(C.Update,s,e):await d()},remove:async e=>{if(r.isReadonly)return i();if(!t.DELETE_INSTRUMENTATION_RULE)return;const{error:a}=await j(n,t.DELETE_INSTRUMENTATION_RULE,{ruleId:e},r);a?o(C.Delete,a,e):await d()}}})(r,n,{subscribe:l}),O=((e,t,r)=>{const a=E(),{addNotification:n}=m(),{setDataStreams:i}=P(),s=!!r?.subscribe,c=(e,t)=>n({type:I.Error,title:e,message:t}),d=re("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first",skip:!s}),u=d.data?.computePlatform?.dataStreams??d.data?.dataStreams??Ee;o(()=>{s&&i(u)},[s,JSON.stringify(u.map(e=>e.name))]);const l=async()=>{const{data:r,error:n}=await B(a,e.GET_DATA_STREAMS,void 0,t);if(n)c(C.Read,n);else if(r){const e=r.computePlatform?.dataStreams??r.dataStreams??[];i(e)}},T=e.CREATE_DATA_STREAM?async r=>{if(t.isReadonly)return z(n);const{error:o}=await j(a,e.CREATE_DATA_STREAM,{stream:r},t);o?c(C.Create,o):await l()}:void 0;return{items:u,loading:d.loading,fetchAll:l,create:T,update:async(r,o)=>{if(t.isReadonly)return z(n);const{error:i}=await j(a,e.UPDATE_DATA_STREAM,{id:r,dataStream:o},t);i?c(C.Update,i):await l()},remove:async r=>{if(t.isReadonly)return z(n);const{error:o}=await j(a,e.DELETE_DATA_STREAM,{id:r},t);o?c(C.Delete,o):await l()}}})(r,n,{subscribe:f}),N=((e,t,r)=>{const a=E(),{notifyError:n,notifyReadonly:o}=$(g.Namespace),i=re("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe});return{items:i.data?.namespaces??le,loading:i.loading,fetchAll:async()=>{const r=await B(a,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return r.error&&n(C.Read,r.error),r},persist:async r=>{if(t.isReadonly)return o();const{error:i}=await j(a,e.PERSIST_NAMESPACES,r,t);return i&&n(C.Update,i),i?{error:i}:void 0}}})(r,n,{subscribe:T}),F=((e,t)=>{const r=E(),{notifyError:a}=$(g.Source);return{fetch:async n=>{const o=await B(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(C.Read,o.error),o}}})(r,n),k=((e,t)=>{const r=E(),{notifyError:a,notifyReadonly:n}=$(g.Source);return{getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?B(r,e.GET_EFFECTIVE_CONFIG,{id:a},t):{error:"GET_EFFECTIVE_CONFIG not configured"},applyConfigurations:e.UPDATE_REMOTE_CONFIG?async(o,i)=>{if(t.isReadonly)return n();const{error:s}=await j(r,e.UPDATE_REMOTE_CONFIG,{formData:o,connectionIds:i},t);return s&&a(C.Update,s),s?{error:s}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>B(r,e.GET_CONFIG_YAMLS,void 0,t):void 0,updateLocalUiConfig:e.UPDATE_LOCAL_UI_CONFIG?async o=>{if(t.isReadonly)return n();const{error:i}=await j(r,e.UPDATE_LOCAL_UI_CONFIG,{config:o},t);return i&&a(C.Update,i),i?{error:i}:void 0}:void 0,resetLocalUiConfigToDefaults:e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS?async()=>{if(t.isReadonly)return n();const{error:o}=await j(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return o&&a(C.Update,o),o?{error:o}:void 0}:void 0}})(r,n),Y=((e,t)=>{const r=E(),{apolloConfig:a}=M();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>B(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>B(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const i=await B(r,e.GET_DIAGNOSE,{input:n,dryRun:o?.dryRun??!1},t),s=i?.data?.stats?.fileCount??0;return!i.error&&s>0&&!o?.dryRun&&await ue(a),i}:void 0}})(r,n),H=((e,t)=>{const r=E(),{notifyError:a,notifyReadonly:n}=$(g.Source);return{fetchTokens:e.GET_TOKENS?async()=>B(r,e.GET_TOKENS,void 0,t):void 0,updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:i}=await j(r,e.UPDATE_TOKEN,{token:o},t);return i&&a(C.Update,i),i?{error:i}:void 0}:void 0}})(r,n),W=((e,t)=>{const r=E();return{fetch:async()=>B(r,e.GET_METRICS,void 0,t)}})(r,n),x=((e,t)=>{const r=E();return{fetch:e.GET_SERVICE_MAP?async()=>B(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(r,n),K=((e,t)=>{const r=E();return{fetchSlots:e.GET_PROFILING_SLOTS?async()=>B(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>B(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>j(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0}})(r,n),V=((e,t)=>{const r=E();return{getGatewayInfo:e.GET_GATEWAY_INFO?async()=>B(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>B(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>B(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>B(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>B(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(r,n),q=((e,t)=>{const r=E(),{notifyError:a,notifyReadonly:n}=$(g.SamplingRule),o=async()=>{e.GET_SAMPLING_RULES&&await B(r,e.GET_SAMPLING_RULES,void 0,t)},i=(e,i)=>e?async s=>{if(t.isReadonly)return n();const{error:c}=await j(r,e,s,t);return c?a(i,c):await o(),c?{error:c}:void 0}:void 0,s=(e,i)=>e?async(s,c)=>{if(t.isReadonly)return n();const{error:d}=await j(r,e,{samplingId:c.samplingId,ruleId:s,rule:c.rule},t);return d?a(i,d):await o(),d?{error:d}:void 0}:void 0,c=e=>e?async(i,s)=>{if(t.isReadonly)return n();const{error:c}=await j(r,e,{samplingId:s,ruleId:i},t);return c?a(C.Delete,c):await o(),c?{error:c}:void 0}:void 0;return{fetchAll:e.GET_SAMPLING_RULES?async()=>B(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:i(e.CREATE_NOISY_OPERATION_RULE,C.Create),updateNoisy:s(e.UPDATE_NOISY_OPERATION_RULE,C.Update),deleteNoisy:c(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:i(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Create),updateHighlyRelevant:s(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Update),deleteHighlyRelevant:c(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:i(e.CREATE_COST_REDUCTION_RULE,C.Create),updateCostReduction:s(e.UPDATE_COST_REDUCTION_RULE,C.Update),deleteCostReduction:c(e.DELETE_COST_REDUCTION_RULE),updateK8sHealthProbesConfig:e.UPDATE_LOCAL_UI_SAMPLING_CONFIG?async i=>{if(t.isReadonly)return n();const{error:s}=await j(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:i},t);return s?a(C.Update,s):await o(),s?{error:s}:void 0}:void 0}})(r,n),Q=((e,t)=>{const r=E();return{getAllClusterSnapshots:e.GET_ALL_CLUSTER_SNAPSHOTS?async()=>B(r,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,t):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async a=>B(r,e.GET_CLUSTER_SNAPSHOT,{clusterId:a},t):void 0}})(r,n);return{sourcesApi:p,destinationsApi:S,actionsApi:y,instrumentationRulesApi:A,dataStreamsApi:O,namespacesApi:N,k8sManifestApi:F,configApi:k,describeApi:Y,tokensApi:H,metricsApi:W,serviceMapApi:x,profilingApi:K,collectorsApi:V,samplingApi:q,snapshotsApi:Q,capabilities:e(()=>((e,t)=>{const r=t.platformType===h.Vm,a=t.tier===L.Onprem,n=!r;return{canBulkPersistSources:n&&!!e.PERSIST_SOURCES,canFetchSnapshots:n&&!!e.GET_ALL_CLUSTER_SNAPSHOTS,canRecoverFromRollback:n&&!!e.RECOVER_FROM_ROLLBACK,canRestartWorkloads:n&&!!e.RESTART_WORKLOADS,canFetchPeerSources:!!e.GET_PEER_SOURCES,canFetchSourceLibraries:!!e.GET_SOURCE_LIBRARIES,canFetchK8sManifest:n&&!!e.GET_K8S_MANIFEST,canCreateDestination:n&&!!e.CREATE_DESTINATION,canTestConnection:n&&!!e.TEST_DESTINATION_CONNECTION,canFetchDestinationCategories:!!e.GET_DESTINATION_CATEGORIES,canFetchPotentialDestinations:n&&!!e.GET_POTENTIAL_DESTINATIONS,canCreateAction:n&&!!e.CREATE_ACTION,canCreateInstrumentationRule:n&&!!e.CREATE_INSTRUMENTATION_RULE,canApplyEffectiveConfig:n&&!!e.UPDATE_REMOTE_CONFIG&&!!e.GET_EFFECTIVE_CONFIG,canFetchEffectiveConfig:!!e.GET_EFFECTIVE_CONFIG,canFetchConfigYamls:!!e.GET_CONFIG_YAMLS,canFetchProfiling:n&&!!e.GET_PROFILING_SLOTS,canFetchCollectorInfo:n&&!!e.GET_GATEWAY_INFO,canManageSamplingRules:!!e.GET_SAMPLING_RULES,isEnterprise:a,isVm:r}})(r,n),[r,n]),resetCache:a(async()=>{await i.cache.reset()},[i])}};export{Y as O,H as _,oe as a,ne as b,re as c,_e as d,M as e,q as f,ie as p,j as r,ae as u};