@odigos/ui-kit 0.0.260 → 0.0.262
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.
- package/CHANGELOG.md +23 -0
- package/lib/chunks/{connections-scope-BLrBW0hm.js → connections-scope-7HTW_FyZ.js} +1 -1
- package/lib/chunks/{index-D-8Yak_c.js → index-raAGXSYj.js} +12 -12
- package/lib/chunks/odigos-context-nQT2LWDb.js +18 -0
- package/lib/chunks/source-instrument-form-context-BDrkrejS.js +1 -0
- package/lib/chunks/ui-components-p39Q_a1_.js +1703 -0
- package/lib/chunks/use-odigos-api-CPlk79JW.js +5 -0
- package/lib/components/_v2/input-table/card-table.d.ts +10 -0
- package/lib/components/_v2/input-table/dynamic-field/index.d.ts +1 -0
- package/lib/components/_v2/input-table/index.d.ts +2 -0
- package/lib/components/_v2/input-table/types.d.ts +13 -1
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/actions/index.d.ts +5 -1
- package/lib/constants/instrumentation-rules/index.d.ts +2 -1
- package/lib/constants/sampling/index.d.ts +4 -0
- package/lib/constants.js +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/index.d.ts +1 -1
- package/lib/containers/_v2/_forms/add-action-form/custom-fields/index.d.ts +3 -1
- package/lib/containers/_v2/_forms/add-action-form/dynamic-fields/index.d.ts +21 -0
- package/lib/containers/_v2/_forms/add-rule-form/custom-fields/index.d.ts +2 -1
- package/lib/containers/v2.js +155 -143
- package/lib/containers.js +1 -1
- package/lib/contexts/action-form-context.d.ts +1 -1
- package/lib/contexts/odigos-api/capabilities.d.ts +2 -0
- package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +12 -1
- package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +13 -1
- package/lib/contexts/odigos-api/types.d.ts +3 -1
- package/lib/contexts/odigos-api.js +1 -1
- package/lib/contexts/rule-form-context.d.ts +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks/useActionFormData.d.ts +1 -1
- package/lib/hooks/useInstrumentationRuleFormData.d.ts +1 -1
- package/lib/hooks.js +1 -1
- package/lib/icons.js +1 -1
- package/lib/snippets/v2.js +1 -1
- package/lib/snippets.js +1 -1
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types/actions/index.d.ts +40 -4
- package/lib/types/common/index.d.ts +3 -1
- package/lib/types/instrumentation-rules/index.d.ts +22 -3
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/helpers-45znEVHP.js +0 -19
- package/lib/chunks/source-instrument-form-context-D7wjfWpw.js +0 -1
- package/lib/chunks/ui-components-CrXELmQx.js +0 -1692
- package/lib/chunks/use-odigos-api-CgkEC7if.js +0 -5
|
@@ -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 s,from as i,split as c,ApolloClient as d,InMemoryCache as u,ApolloProvider as l,useLazyQuery as E,useApolloClient as f,useQuery as T,gql as _}from"@apollo/client";import{jsx as S}from"react/jsx-runtime";import{onError as p}from"@apollo/client/link/error";import{setContext as y}from"@apollo/client/link/context";import{getMainDefinition as R}from"@apollo/client/utilities";import{W as m,F as O,p as A,o as I,Z as N,_ as C,E as h,P as g,T as L,h as P,$ as G,a0 as U,a1 as v,a2 as D,a3 as w,a4 as F,a5 as k}from"./ui-components-CrXELmQx.js";const M=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},b=r(null),H=()=>{const e=t(b);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},W=({apolloConfig:t,operations:r,context:a,children:n})=>{const o=e(()=>(e=>{const t=new s({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=p(({graphQLErrors:t,networkError:r})=>{t&&t.length>0&&t.some(e=>M(e.message))&&e.onAuthError?.(),r&&(401===r.statusCode||M(r.message))&&e.onAuthError?.()}),a=y(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=i(n);e.wsLink&&(o=c(({query:e})=>{const t=R(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 S(l,{client:o,children:S(b.Provider,{value:E,children:n})})},Y=b,x=(e,t)=>{if(e)return"string"==typeof e?e:N(e,t)},K=e=>{const{addNotification:t}=m(),r=(r,a,n,o,s)=>t({type:r,title:a,message:n,crdType:e,target:x(o,e),hideFromHistory:s});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:A.READONLY,message:O.READONLY_WARNING,hideFromHistory:!0})}}},V=e=>{e({type:I.Warning,title:A.READONLY,message:O.READONLY_WARNING,hideFromHistory:!0})},$=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),B=(e,t)=>{if(e)return"function"==typeof e?e(t):e},j=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)},q=(e,t)=>e.client??t,Q=async(e,t,r,a,n)=>{if(!t)return{error:"Query operation not configured"};if(t.canRun&&!t.canRun(a))return{data:void 0};if(t.run)try{return await t.run(q(t,e),r,a)}catch(e){return{error:j(e)}}const o=B(t.document,a);if(!o)return{error:"Query operation not supported in this context"};const s=t.transformVariables?t.transformVariables(r,a):r,i=q(t,e);try{const e=await i.query({query:o,variables:s,fetchPolicy:n??"network-only"});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:e.error?j(e.error):void 0}}catch(e){return{error:j(e)}}},z=async(e,t,r,a)=>{if(!t)return{error:"Mutation operation not configured"};if(t.canRun&&!t.canRun(a))return{data:void 0};if(t.run)try{return await t.run(q(t,e),r,a)}catch(e){return{error:j(e)}}const n=B(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};const o=t.transformVariables?t.transformVariables(r,a):r,s=q(t,e);try{const e=await s.mutate({mutation:n,variables:o});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:void 0}}catch(e){return{error:j(e)}}},J=async(e,t,r,a,n)=>{if(!t)return $("Multi fetch operation not configured");if(!r.length)return $("No proxy ids supplied for multi fetch");const o=q(t,e);if(t.transformVariablesMulti&&(t.documentMulti||t.document)){const e=t.transformVariablesMulti(r,a,n),s=[];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=>s.push(e)):r.proxyIDs.forEach(t=>{s.push({proxyID:t,success:!e.error,data:e.data,error:e.error?.message})})}catch(e){const t=j(e);r.proxyIDs.forEach(e=>s.push({proxyID:e,success:!1,error:t}))}const i=s.filter(e=>e.success).length,c=s.length-i,d=Array.from(new Set(s.filter(e=>!!e.error).map(e=>e.error)));return{results:s,allSucceeded:0===c,anySucceeded:i>0,successCount:i,failureCount:c,error:d.length?d.join(", "):void 0}}const s=await Promise.all(r.map(async r=>{const o={...n,proxyID:r},s=await Q(e,t,a,o);return{proxyID:r,success:!s.error,data:s.data,error:s.error}})),i=s.filter(e=>e.success).length,c=s.length-i,d=Array.from(new Set(s.filter(e=>!!e.error).map(e=>e.error)));return{results:s,allSucceeded:0===c,anySucceeded:i>0,successCount:i,failureCount:c,error:d.length?d.join(", "):void 0}},X=_`
|
|
2
|
-
query OdigosApiNoop {
|
|
3
|
-
__typename
|
|
4
|
-
}
|
|
5
|
-
`,Z=(e,t)=>{if(e)return"function"==typeof e?e(t):e},ee=(e,t)=>e[t],te=(e,t,r)=>{if(void 0===t)return;return e?.transformResult?e.transformResult(t,r):t},re=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},ae=(t,r,n)=>{const{operations:o,context:s}=H(),i=ee(o,t),c=e(()=>Z(i?.document,s),[i,s]),d=e(()=>re(i,r,s),[i,r,s]),u=!i||!c,l=!!i?.canRun&&!i.canRun(s),E=n?.skip||u||l,f=T(c??X,{variables:d,skip:E,pollInterval:n?.pollInterval,fetchPolicy:n?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:n?.notifyOnNetworkStatusChange,client:i?.client,onCompleted:n?.onCompleted?e=>{const t=te(i,e,s);void 0!==t&&n.onCompleted(t)}:void 0,onError:n?.onError}),_=e(()=>{if(!E)return te(i,f.data,s)},[i,s,f.data,E]),S=a(async()=>{if(u)return{data:void 0};const e=await f.refetch();return{data:te(i,e.data,s)}},[i,s,f,u]);return{data:_,loading:!E&&f.loading,error:f.error,refetch:S,unsupported:u}},ne=(t,r)=>{const{operations:n,context:o}=H(),s=ee(n,t),i=e(()=>Z(s?.document,o),[s,o]),c=!s||!i,[d,u]=E(i??X,{fetchPolicy:r?.fetchPolicy??"network-only",notifyOnNetworkStatusChange:r?.notifyOnNetworkStatusChange,client:s?.client});return{execute:a(async e=>{if(c)return{error:void 0};if(s?.canRun&&!s.canRun(o))return{data:void 0};const t=re(s,e,o),r=await d({variables:t});return r.error?{error:r.error}:{data:te(s,r.data,o)}},[s,o,d,c]),data:e(()=>te(s,u.data,o),[s,o,u.data]),loading:u.loading,error:u.error,called:u.called,unsupported:c}},oe=(t,r)=>{const{operations:o,context:s}=H(),i=f(),c=ee(o,t),d=e(()=>Z(c?.document,s),[c,s]),u=!c||!d,[l,E]=n({loading:!1,called:!1}),T=a(()=>E({loading:!1,called:!1}),[]);return[a(async e=>{if(u||!d)return{error:void 0};if(c?.canRun&&!c.canRun(s))return{data:void 0};const t=re(c,e,s),a=c?.client??i;E(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:d,variables:t}),n=te(c,e.data,s);if(E({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 E({data:void 0,loading:!1,error:t,called:!0}),r?.onError?.(t),{error:t}}},[c,s,i,d,u,r]),{data:l.data,loading:l.loading,error:l.error,called:l.called,unsupported:u,reset:T}]},se=[],ie=(e,t,r,a)=>{let n=!0;const o={sources:[]};for(const[s,i]of Object.entries(e)){if(!i.length)continue;n=!1;const e=i.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===s&&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}},ce=(e,t)=>{let r=!0;const a={namespaces:[]};for(const[n,{selected:o,currentStreamName:s}]of Object.entries(e))"boolean"==typeof o&&(r=!1,a.namespaces.push({namespace:n,selected:o,currentStreamName:s||t}));return{payload:a,isEmpty:r}},de={filter:{markedForInstrumentation:!0}},ue=[],le=[],Ee=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){}},fe=[],Te=[],_e=e=>{if(!e)return;return{clusters:[e],totalNamespaces:e.namespaces?.length??0,totalWorkloads:(e.namespaces??[]).reduce((e,t)=>e+(t.workloads?.length??0),0),lastUpdated:e.timestamp}},Se=[],pe=[],ye=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),Re=()=>{const{operations:t,context:r}=H(),n=f(),s=((e,t)=>{const r=f(),{notifyError:n,notifySuccess:o,notifyPending:s,notifyReadonly:i}=K(h.Source),{selectedStreamName:c}=P(),{setProgress:d,resetProgress:u}=G(),{setConfiguredSources:l,setConfiguredFutureApps:E}=U(),T=(e,t)=>{const{progress:r}=G.getState();e>0&&d(v.Instrumenting,{total:(r[v.Instrumenting]?.total||0)+e,current:r[v.Instrumenting]?.current||0}),t>0&&d(v.Uninstrumenting,{total:(r[v.Uninstrumenting]?.total||0)+t,current:r[v.Uninstrumenting]?.current||0})},_=a(async()=>{const{error:a}=await Q(r,e.GET_WORKLOADS,de,t);a&&n(C.Read,a)},[r,e.GET_WORKLOADS,t,n]);return{useSources:()=>{const e=ae("GET_WORKLOADS",de,{fetchPolicy:"cache-first"});return{items:e.data?.workloads??ue,loading:e.loading,refetch:_}},fetchAll:_,fetchByTargets:async(a,o)=>{const s=!!o?.slim,i=a.map(e=>D(e,h.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===i.length)return;if(i.length>50)return void await _();const c=s&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:d}=await Q(r,c,{ids:i.map(({namespace:e,kind:t,name:r})=>({namespace:e,kind:t,name:r}))},t);d?n(C.Read,d):await _()},fetchById:async a=>{const{data:o,error:s}=await Q(r,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:a.namespace,kind:a.kind,name:a.name}]},t);if(!s)return o?.workloadsByIds?.find(e=>e.id.namespace===a.namespace&&e.id.kind===a.kind&&e.id.name===a.name);n(C.Read,s)},fetchLibraries:async a=>Q(r,e.GET_SOURCE_LIBRARIES,a,t),fetchPeerSources:async a=>Q(r,e.GET_PEER_SOURCES,{serviceName:a},t),usePeerSources:(e,t)=>ae("GET_PEER_SOURCES",e,t),persist:async(a,o)=>{if(t.isReadonly)return i();const{data:d}=await Q(r,e.GET_WORKLOADS,de,t,"cache-first"),f=d?.workloads??ue,{payload:_,isEmpty:S}=ie(a,f,c,T),{payload:p,isEmpty:y}=ce(o,c);let R=!1;S||(R=!0,s("Persisting sources...")),y||R||s("Persisting namespaces...");const{error:m}=await z(r,e.PERSIST_SOURCES,_,t);if(m&&(u(v.Instrumenting),u(v.Uninstrumenting),n(C.Update,m)),e.PERSIST_NAMESPACES){const{error:a}=await z(r,e.PERSIST_NAMESPACES,p,t);a&&n(C.Update,a)}l({}),E({})},persistV2:async a=>{if(t.isReadonly)return i(),{error:"readonly"};const n=[];for(const[,o]of Object.entries(a)){const a={sources:[]},s={namespaces:[]};for(const e of o)e.name&&e.kind?a.sources.push(e):s.namespaces.push(e);if(s.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:a}=await z(r,e.PERSIST_NAMESPACES,s,t);a&&n.push(a)}if(a.sources.length>0){const{error:o}=await z(r,e.PERSIST_SOURCES,a,t);o&&n.push(o)}}return n.length?{error:n.join(", ")}:void 0},update:async(a,d)=>{if(t.isReadonly)return i();s("Updating source...");const u={sourceId:a,patchSourceRequest:{...d,currentStreamName:c}},{data:l,error:E}=await z(r,e.UPDATE_SOURCE,u,t);E?n(C.Update,E,a):l?.updateK8sActualSource&&o(C.Update,`Successfully updated "${a.name}" source`,a)},restartWorkloads:async a=>{if(t.isReadonly)return i();s("Restarting sources...");const{data:c,error:d}=await z(r,e.RESTART_WORKLOADS,{sourceIds:a},t);d?n(C.Update,d):c?.restartWorkloads&&o(C.Update,`Successfully restarted ${a.length} sources`)},restartPod:async(a,c)=>{if(t.isReadonly)return i();s("Restarting pod...");const{data:d,error:u}=await z(r,e.RESTART_POD,{namespace:a,name:c},t);u?n(C.Update,u):d?.restartPod&&o(C.Update,`Successfully restarted pod ${a}/${c}`)},recoverFromRollback:async a=>{if(t.isReadonly)return i();s("Recovering from rollback...");const{data:c,error:d}=await z(r,e.RECOVER_FROM_ROLLBACK,{sourceId:a},t);d?n(C.Update,d,a):c?.recoverFromRollbackForWorkload&&o(C.Update,"Successfully triggered recovery from rollback")}}})(t,r),i=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Destination),{selectedStreamName:s}=P(),i=async()=>{const{error:n}=await Q(r,e.GET_DESTINATIONS,void 0,t);n&&a(C.Read,n)};return{useDestinations:()=>{const e=ae("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.destinations??e.data?.destinations??pe,loading:e.loading,refetch:i}},useDestinationCategories:()=>{const e=ae("GET_DESTINATION_CATEGORIES",void 0);return{data:e.data,loading:e.loading}},usePotentialDestinations:()=>{const e=ae("GET_POTENTIAL_DESTINATIONS",void 0);return{data:e.data,loading:e.loading}},fetchAll:i,testConnection:async a=>{const{data:n}=await z(r,e.TEST_DESTINATION_CONNECTION,{destination:ye(a,s)},t);return n},create:async c=>{if(t.isReadonly)return o();const{error:d}=await z(r,e.CREATE_DESTINATION,{destination:ye(c,s)},t);d?a(C.Create,d):(n(C.Create,`Successfully created "${c.type}" destination`),await i())},update:async(c,d)=>{if(t.isReadonly)return o();const{data:u,error:l}=await z(r,e.UPDATE_DESTINATION,{id:c,destination:ye(d,s)},t);l?a(C.Update,l,c):u?.updateDestination&&(n(C.Update,`Successfully updated "${d.type}" destination`,c),await i())},remove:async c=>{if(t.isReadonly)return o();const{data:d}=await Q(r,e.GET_DESTINATIONS,void 0,t,"cache-first"),u=d?.computePlatform?.destinations??d?.destinations??pe,l=u.find(e=>w(e)===c)?.destinationType?.type,{error:E}=await z(r,e.DELETE_DESTINATION,{id:c,currentStreamName:s},t);E?a(C.Delete,E,c):(n(C.Delete,`Successfully deleted "${l??c}" destination`,c),await i())}}})(t,r),c=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Action),s=async()=>{const{error:n}=await Q(r,e.GET_ACTIONS,void 0,t);n&&a(C.Read,n)};return{useActions:()=>{const e=ae("GET_ACTIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.actions??e.data?.actions??le,loading:e.loading,refetch:s}},fetchAll:s,create:async i=>{if(t.isReadonly)return o();if(!e.CREATE_ACTION)return;const{error:c}=await z(r,e.CREATE_ACTION,{action:i},t);c?a(C.Create,c):(n(C.Create,`Successfully created "${i.type}" action`),await s())},update:async(i,c)=>{if(t.isReadonly)return o();if(!e.UPDATE_ACTION)return;const{error:d}=await z(r,e.UPDATE_ACTION,{id:i,action:c},t);d?a(C.Update,d,i):(n(C.Update,`Successfully updated "${c.type}" action`,i),await s())},remove:async(i,c)=>{if(t.isReadonly)return o();if(!e.DELETE_ACTION)return;const{error:d}=await z(r,e.DELETE_ACTION,{id:i,actionType:c},t);d?a(C.Delete,d,i):(n(C.Delete,`Successfully deleted "${c}" action`,i),await s())}}})(t,r),d=((t,r)=>{const a=f(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=K(h.InstrumentationRule),i=async()=>{const{error:e}=await Q(a,t.GET_INSTRUMENTATION_RULES,void 0,r);e&&n(C.Read,e)};return{useRules:()=>{const t=ae("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e(()=>(t.data?.computePlatform?.instrumentationRules??t.data?.instrumentationRules??[]).map(k),[t.data]),loading:t.loading,refetch:i}},fetchAll:i,create:async(e,c)=>{if(r.isReadonly)return s();if(!t.CREATE_INSTRUMENTATION_RULE)return;const{error:d}=await z(a,t.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:F(e)},r);d?n(C.Create,d):(o(C.Create,`Successfully created${c?` "${c}"`:""} rule`),await i())},update:async(e,c,d)=>{if(r.isReadonly)return s();if(!t.UPDATE_INSTRUMENTATION_RULE)return;const{error:u}=await z(a,t.UPDATE_INSTRUMENTATION_RULE,{ruleId:e,instrumentationRule:F(c)},r);u?n(C.Update,u,e):(o(C.Update,`Successfully updated${d?` "${d}"`:""} rule`,e),await i())},remove:async(e,c)=>{if(r.isReadonly)return s();if(!t.DELETE_INSTRUMENTATION_RULE)return;const{error:d}=await z(a,t.DELETE_INSTRUMENTATION_RULE,{ruleId:e},r);d?n(C.Delete,d,e):(o(C.Delete,`Successfully deleted${c?` "${c}"`:""} rule`,e),await i())}}})(t,r),u=((e,t)=>{const r=f(),{addNotification:a}=m(),{setDataStreams:n}=P(),s=(e,t)=>a({type:I.Error,title:e,message:t}),i=async()=>{const{data:a,error:o}=await Q(r,e.GET_DATA_STREAMS,void 0,t);if(o)s(C.Read,o);else if(a){const e=a.computePlatform?.dataStreams??a.dataStreams??[];n(e)}},c=e.CREATE_DATA_STREAM?async n=>{if(t.isReadonly)return V(a);const{error:o}=await z(r,e.CREATE_DATA_STREAM,{stream:n},t);o?s(C.Create,o):await i()}:void 0;return{useDataStreams:()=>{const e=ae("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first"}),t=e.data?.computePlatform?.dataStreams??e.data?.dataStreams??Se;return o(()=>{n(t)},[JSON.stringify(t.map(e=>e.name))]),{items:t,loading:e.loading,refetch:i}},fetchAll:i,create:c,update:async(n,o)=>{if(t.isReadonly)return V(a);const{error:c}=await z(r,e.UPDATE_DATA_STREAM,{id:n,dataStream:o},t);c?s(C.Update,c):await i()},remove:async n=>{if(t.isReadonly)return V(a);const{error:o}=await z(r,e.DELETE_DATA_STREAM,{id:n},t);o?s(C.Delete,o):await i()}}})(t,r),l=((e,t)=>{const r=f(),{notifyError:a,notifyReadonly:n}=K(h.Namespace),o=async()=>{const n=await Q(r,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return n.error&&a(C.Read,n.error),n};return{useNamespaces:()=>{const e=ae("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.namespaces??Te,loading:e.loading,refetch:o}},fetchAll:o,persist:async o=>{if(t.isReadonly)return n();const{error:s}=await z(r,e.PERSIST_NAMESPACES,o,t);return s&&a(C.Update,s),s?{error:s}:void 0}}})(t,r),E=((e,t)=>{const r=f(),{notifyError:a}=K(h.Source);return{fetch:async n=>{const o=await Q(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(C.Read,o.error),o}}})(t,r),T=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Source);return{useEffectiveConfig:(e,t)=>ae("GET_EFFECTIVE_CONFIG",e,t),useConfigYamls:e=>ae("GET_CONFIG_YAMLS",void 0,e),getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?Q(r,e.GET_EFFECTIVE_CONFIG,{id:a},t):{error:"GET_EFFECTIVE_CONFIG not configured"},applyConfigurations:e.UPDATE_REMOTE_CONFIG?async(n,s)=>{if(t.isReadonly)return o();const{error:i}=await z(r,e.UPDATE_REMOTE_CONFIG,{formData:n,connectionIds:s},t);return i&&a(C.Update,i),i?{error:i}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>Q(r,e.GET_CONFIG_YAMLS,void 0,t):void 0,updateLocalUiConfig:e.UPDATE_LOCAL_UI_CONFIG?async s=>{if(t.isReadonly)return o();const{error:i}=await z(r,e.UPDATE_LOCAL_UI_CONFIG,{config:s},t);return i?a(C.Update,i):n(C.Update,"Local UI configuration updated successfully"),i?{error:i}:void 0}:void 0,resetLocalUiConfigToDefaults:e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS?async()=>{if(t.isReadonly)return o();const{error:s}=await z(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return s?a(C.Update,s):n(C.Update,"Local UI configuration reset to factory defaults"),s?{error:s}:void 0}:void 0}})(t,r),_=((e,t)=>{const r=f(),{apolloConfig:a}=H();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>Q(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>Q(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const s=await Q(r,e.GET_DIAGNOSE,{input:n,dryRun:o?.dryRun??!1},t),i=s?.data?.stats?.fileCount??0;return!s.error&&i>0&&!o?.dryRun&&await Ee(a),s}:void 0}})(t,r),S=((e,t)=>{const r=f(),{notifyError:a,notifyReadonly:n}=K(h.Source),o=async()=>{e.GET_TOKENS&&await Q(r,e.GET_TOKENS,void 0,t)};return{useTokens:()=>{const e=ae("GET_TOKENS",void 0,{fetchPolicy:"cache-first"});return{items:e.data??se,loading:e.loading,refetch:o}},updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:s}=await z(r,e.UPDATE_TOKEN,{token:o},t);return s&&a(C.Update,s),s?{error:s}:void 0}:void 0}})(t,r),p=((e,t)=>{const r=f();return{useMetrics:e=>ae("GET_METRICS",void 0,e),fetch:async()=>Q(r,e.GET_METRICS,void 0,t)}})(t,r),y=((e,t)=>{const r=f();return{useServiceMap:e=>ae("GET_SERVICE_MAP",void 0,e),fetch:e.GET_SERVICE_MAP?async()=>Q(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(t,r),R=((e,t)=>{const r=f();return{useSlots:e=>ae("GET_PROFILING_SLOTS",void 0,e),useSourceProfiling:(e,t)=>ae("GET_SOURCE_PROFILING",e,t),fetchSlots:e.GET_PROFILING_SLOTS?async()=>Q(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>Q(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>z(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0}})(t,r),O=((e,t)=>{const r=f();return{useGatewayInfo:e=>ae("GET_GATEWAY_INFO",void 0,e),useGatewayPods:e=>ae("GET_GATEWAY_PODS",void 0,e),useNodeCollectorInfo:e=>ae("GET_NODE_COLLECTOR_INFO",void 0,e),useNodeCollectorPods:e=>ae("GET_NODE_COLLECTOR_PODS",void 0,e),usePodInfo:(e,t)=>ae("GET_COLLECTOR_POD_INFO",e,t),getGatewayInfo:e.GET_GATEWAY_INFO?async()=>Q(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>Q(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>Q(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>Q(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>Q(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(t,r),A=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.SamplingRule),s=async()=>{e.GET_SAMPLING_RULES&&await Q(r,e.GET_SAMPLING_RULES,void 0,t)},i=(e,i)=>e?async c=>{if(t.isReadonly)return o();const{error:d}=await z(r,e,c,t);return d?a(i,d):(n(C.Create,"Successfully created sampling rule"),await s()),d?{error:d}:void 0}:void 0,c=(e,i)=>e?async(c,d)=>{if(t.isReadonly)return o();const{error:u}=await z(r,e,{samplingId:d.samplingId,ruleId:c,rule:d.rule},t);return u?a(i,u):(n(C.Update,"Successfully updated sampling rule"),await s()),u?{error:u}:void 0}:void 0,d=e=>e?async(i,c)=>{if(t.isReadonly)return o();const{error:d}=await z(r,e,{samplingId:c,ruleId:i},t);return d?a(C.Delete,d):(n(C.Delete,"Successfully deleted sampling rule"),await s()),d?{error:d}:void 0}:void 0;return{useSamplingRules:()=>{const e=ae("GET_SAMPLING_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.samplingRules??e.data?.samplingRules??fe,k8sHealthProbesConfig:e.data?.computePlatform?.k8sHealthProbesConfig??e.data?.k8sHealthProbesConfig??null,loading:e.loading,refetch:s}},fetchAll:e.GET_SAMPLING_RULES?async()=>Q(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:i(e.CREATE_NOISY_OPERATION_RULE,C.Create),updateNoisy:c(e.UPDATE_NOISY_OPERATION_RULE,C.Update),deleteNoisy:d(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:i(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Create),updateHighlyRelevant:c(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Update),deleteHighlyRelevant:d(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:i(e.CREATE_COST_REDUCTION_RULE,C.Create),updateCostReduction:c(e.UPDATE_COST_REDUCTION_RULE,C.Update),deleteCostReduction:d(e.DELETE_COST_REDUCTION_RULE),updateK8sHealthProbesConfig:e.UPDATE_LOCAL_UI_SAMPLING_CONFIG?async n=>{if(t.isReadonly)return o();const{error:i}=await z(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:{k8sHealthProbesSampling:n}},t);return i?a(C.Update,i):await s(),i?{error:i}:void 0}:void 0}})(t,r),N=((t,r)=>{const n=f();return{useSnapshots:()=>{const t=r.proxyID,n=!!t,o=ae("GET_ALL_CLUSTER_SNAPSHOTS",void 0,{fetchPolicy:"cache-first",skip:n}),s=ae("GET_CLUSTER_SNAPSHOT",t?{clusterId:t}:void 0,{fetchPolicy:"cache-first",skip:!n}),i=e(()=>n?_e(s.data):o.data,[n,s.data,o.data]),c=a(async()=>{if(!n)return o.refetch();const{data:e}=await s.refetch();return{data:_e(e)}},[n,o.refetch,s.refetch]);return{data:i,loading:n?s.loading:o.loading,unsupported:n?s.unsupported:o.unsupported,refetch:c}},getAllClusterSnapshots:t.GET_ALL_CLUSTER_SNAPSHOTS?async()=>Q(n,t.GET_ALL_CLUSTER_SNAPSHOTS,void 0,r):void 0,getClusterSnapshot:t.GET_CLUSTER_SNAPSHOT?async e=>Q(n,t.GET_CLUSTER_SNAPSHOT,{clusterId:e},r):void 0}})(t,r);return{sourcesApi:s,destinationsApi:i,actionsApi:c,instrumentationRulesApi:d,dataStreamsApi:u,namespacesApi:l,k8sManifestApi:E,configApi:T,describeApi:_,tokensApi:S,metricsApi:p,serviceMapApi:y,profilingApi:R,collectorsApi:O,samplingApi:A,snapshotsApi:N,capabilities:e(()=>((e,t)=>{const r=t.platformType===g.Vm,a=t.tier===L.Onprem,n=!r;return{canBulkPersistSources:n&&!!e.PERSIST_SOURCES,canInstrumentNamespaces:n&&!!e.PERSIST_NAMESPACES,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}})(t,r),[t,r]),resetCache:a(async()=>{await n.cache.reset()},[n])}};export{W as O,Y as _,ie as a,oe as b,ae as c,Re as d,H as e,J as f,ce as p,z as r,ne as u};
|