@odigos/ui-kit 0.0.249 → 0.0.251
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 +14 -0
- package/docs/api-context.md +687 -0
- package/lib/chunks/connections-scope-CneIqjeg.js +1 -0
- package/lib/chunks/flow-CQi_KYfs.js +49 -0
- package/lib/chunks/helpers-K1tnyqhm.js +19 -0
- package/lib/chunks/{index-CRKgHzab.js → index-Dv0RvKAp.js} +8 -8
- package/lib/chunks/source-instrument-form-context-C79I_5cH.js +1 -0
- package/lib/chunks/{ui-components-DODwSdKu.js → ui-components-BKrLf2tx.js} +214 -214
- package/lib/chunks/use-odigos-api-CDHW7ekQ.js +5 -0
- package/lib/chunks/vendor-BFqT13Me.js +1 -0
- package/lib/components/_v2/segment/index.d.ts +4 -2
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/strings/index.d.ts +7 -0
- package/lib/constants.js +1 -1
- package/lib/containers/_v2/_drawers/add-action-drawer/index.d.ts +0 -2
- package/lib/containers/_v2/_drawers/add-destination-drawer/form-column/index.d.ts +1 -5
- package/lib/containers/_v2/_drawers/add-destination-drawer/index.d.ts +0 -6
- package/lib/containers/_v2/_drawers/add-destination-drawer/lists-filters/index.d.ts +2 -1
- package/lib/containers/_v2/_drawers/add-rule-drawer/index.d.ts +0 -2
- package/lib/containers/_v2/_drawers/add-source-drawer/index.d.ts +1 -4
- package/lib/containers/_v2/_drawers/edit-action-drawer/index.d.ts +0 -3
- package/lib/containers/_v2/_drawers/edit-config-drawer/index.d.ts +1 -3
- package/lib/containers/_v2/_drawers/edit-destination-drawer/index.d.ts +0 -5
- package/lib/containers/_v2/_drawers/edit-rule-drawer/index.d.ts +0 -3
- package/lib/containers/_v2/_drawers/edit-source-drawer/debug/index.d.ts +1 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/index.d.ts +3 -14
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/containers-card/index.d.ts +1 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/overview/index.d.ts +0 -2
- package/lib/containers/_v2/_drawers/edit-source-drawer/peers/index.d.ts +1 -6
- package/lib/containers/_v2/_drawers/edit-source-drawer/profiling/index.d.ts +1 -15
- package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/index.d.ts +8 -0
- package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/rule-row.d.ts +8 -0
- package/lib/containers/_v2/_drawers/edit-source-drawer/tabs.d.ts +1 -0
- package/lib/containers/_v2/_drawers/system-drawer/describe/index.d.ts +1 -8
- package/lib/containers/_v2/_drawers/system-drawer/diagnose/index.d.ts +1 -4
- package/lib/containers/_v2/_drawers/system-drawer/index.d.ts +1 -4
- package/lib/containers/_v2/_drawers/system-drawer/tokens/index.d.ts +1 -2
- package/lib/containers/_v2/_forms/add-destination-form/index.d.ts +1 -2
- package/lib/containers/_v2/_modals/add-data-stream-modal/index.d.ts +0 -3
- package/lib/containers/_v2/_modals/edit-data-stream-modal/index.d.ts +0 -2
- package/lib/containers/_v2/_modals/sampling-onboarding-modal/types.d.ts +1 -4
- package/lib/containers/_v2/central-connections/index.d.ts +1 -12
- package/lib/containers/_v2/onboarding/index.d.ts +0 -8
- package/lib/containers/_v2/overview/columns/column/head.d.ts +1 -1
- package/lib/containers/_v2/overview/columns/column/index.d.ts +2 -1
- package/lib/containers/_v2/overview/columns/index.d.ts +1 -8
- package/lib/containers/_v2/overview/data-stream-select/index.d.ts +1 -10
- package/lib/containers/_v2/overview/drawers/index.d.ts +2 -29
- package/lib/containers/_v2/overview/index.d.ts +2 -8
- package/lib/containers/_v2/overview/multi-source-control/index.d.ts +1 -5
- package/lib/containers/_v2/pipeline-collectors/index.d.ts +0 -7
- package/lib/containers/_v2/pipeline-collectors/pods-info/index.d.ts +1 -2
- package/lib/containers/_v2/pipeline-collectors/pods-info/pod-drawer/index.d.ts +1 -2
- package/lib/containers/_v2/sampling-rules/helpers.d.ts +2 -0
- package/lib/containers/_v2/sampling-rules/types.d.ts +2 -16
- package/lib/containers/_v2/settings/index.d.ts +0 -9
- package/lib/containers/service-map/index.d.ts +4 -2
- package/lib/containers/v2.js +197 -166
- package/lib/containers.js +7 -7
- package/lib/contexts/index.d.ts +1 -0
- package/lib/contexts/odigos-api/capabilities.d.ts +38 -0
- package/lib/contexts/odigos-api/client.d.ts +22 -0
- package/lib/contexts/odigos-api/connections-scope.d.ts +18 -0
- package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +26 -0
- package/lib/contexts/odigos-api/hooks/use-collectors-api.d.ts +25 -0
- package/lib/contexts/odigos-api/hooks/use-config-api.d.ts +24 -0
- package/lib/contexts/odigos-api/hooks/use-data-streams-api.d.ts +26 -0
- package/lib/contexts/odigos-api/hooks/use-describe-api.d.ts +33 -0
- package/lib/contexts/odigos-api/hooks/use-destinations-api.d.ts +50 -0
- package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +35 -0
- package/lib/contexts/odigos-api/hooks/use-k8s-manifest-api.d.ts +14 -0
- package/lib/contexts/odigos-api/hooks/use-metrics-api.d.ts +13 -0
- package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +30 -0
- package/lib/contexts/odigos-api/hooks/use-profiling-api.d.ts +17 -0
- package/lib/contexts/odigos-api/hooks/use-sampling-api.d.ts +39 -0
- package/lib/contexts/odigos-api/hooks/use-service-map-api.d.ts +13 -0
- package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +13 -0
- package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +75 -0
- package/lib/contexts/odigos-api/hooks/use-tokens-api.d.ts +12 -0
- package/lib/contexts/odigos-api/index.d.ts +37 -0
- package/lib/contexts/odigos-api/internal/notify.d.ts +49 -0
- package/lib/contexts/odigos-api/internal/source-payloads.d.ts +53 -0
- package/lib/contexts/odigos-api/platform-helpers.d.ts +98 -0
- package/lib/contexts/odigos-api/provider.d.ts +28 -0
- package/lib/contexts/odigos-api/runner.d.ts +32 -0
- package/lib/contexts/odigos-api/types.d.ts +831 -0
- package/lib/contexts/odigos-api/use-api-for-connections.d.ts +43 -0
- package/lib/contexts/odigos-api/use-api-query.d.ts +130 -0
- package/lib/contexts/odigos-api/use-odigos-api.d.ts +103 -0
- package/lib/contexts/odigos-api.js +1 -0
- package/lib/contexts/odigos-context.d.ts +2 -2
- package/lib/contexts/storybook-context.d.ts +2 -2
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/icons/destinations/open-telemetry-logo/index.d.ts +2 -1
- package/lib/snippets/_v2/sampling-rule-form-sections/preset-with-custom-input.d.ts +1 -1
- package/lib/snippets/v2.js +1 -1
- package/lib/snippets.js +1 -49
- package/lib/store/index.d.ts +0 -1
- package/lib/store/useDrawerStore.d.ts +6 -1
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types/actions/index.d.ts +0 -5
- package/lib/types/common/index.d.ts +29 -4
- package/lib/types/destinations/index.d.ts +0 -10
- package/lib/types/index.d.ts +0 -1
- package/lib/types/instrumentation-rules/index.d.ts +0 -5
- package/lib/types/namespaces/index.d.ts +0 -5
- package/lib/types/pipeline-collectors/index.d.ts +0 -5
- package/lib/types/snapshot/index.d.ts +0 -2
- package/lib/types/sources/index.d.ts +0 -30
- package/lib/types/tokens/index.d.ts +0 -6
- package/lib/types/workload/index.d.ts +46 -22
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +31 -22
- package/lib/chunks/helpers-IEFhGXc7.js +0 -19
- package/lib/chunks/source-instrument-form-context-DjIHPYQJ.js +0 -1
- package/lib/chunks/vendor-Be0cOokr.js +0 -1
- package/lib/mock-data/actions/index.d.ts +0 -2
- package/lib/mock-data/config/index.d.ts +0 -3
- package/lib/mock-data/connections/index.d.ts +0 -2
- package/lib/mock-data/describe/index.d.ts +0 -3
- package/lib/mock-data/destinations/index.d.ts +0 -4
- package/lib/mock-data/index.d.ts +0 -15
- package/lib/mock-data/instrumentation-instances/index.d.ts +0 -2
- package/lib/mock-data/instrumentation-rules/index.d.ts +0 -2
- package/lib/mock-data/namespaces/index.d.ts +0 -2
- package/lib/mock-data/pipeline-collectors/index.d.ts +0 -6
- package/lib/mock-data/profiling/index.d.ts +0 -8
- package/lib/mock-data/service-map/index.d.ts +0 -4
- package/lib/mock-data/snapshot/index.d.ts +0 -5
- package/lib/mock-data/sources/index.d.ts +0 -4
- package/lib/mock-data/sources/yamls.d.ts +0 -22
- package/lib/mock-data/tokens/index.d.ts +0 -2
- package/lib/mock-data/traces/index.d.ts +0 -2
- package/lib/store/useEntityStore.d.ts +0 -24
- package/lib/types/k8s-manifest/index.d.ts +0 -2
package/lib/containers.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState as i,useRef as n,useCallback as a,useEffect as o}from"react";import{MarkerType as s,useNodesState as c,useEdgesState as l}from"@xyflow/react";import{b as d,D as p,E as u,i as g,j as m,k as h,S as y,l as f,T as v,m as x,n as S,a as b,o as N,p as k,q as w}from"./chunks/ui-components-BKrLf2tx.js";import{UserIcon as K,ImageErrorIcon as T,ChevronDownIcon as M,ChevronRightIcon as I}from"./icons.js";import C,{useTheme as E}from"styled-components";import $ from"elkjs/lib/elk.bundled.js";import{c as z,d as G}from"./chunks/use-odigos-api-CDHW7ekQ.js";import{F as V}from"./chunks/flow-CQi_KYfs.js";import"zustand";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";import"@apollo/client";import"@apollo/client/link/error";import"@apollo/client/link/context";import"@apollo/client/utilities";import"@xyflow/react/dist/style.css";const j=e=>`${u.Source}-${e}-${d.MapItem}`,A=(e,t,r)=>{const i=e.isVirtual,n=r?[K]:i?[g(e)]:t?m(t):[T],{priorotizedStatus:a}=i?{priorotizedStatus:void 0}:h(t?.conditions||[]);return{id:e.graphKey,title:e.serviceName,icons:n,isVirtual:i,status:a,aggService:e}},D=e=>!(!e||"user"!==e.serviceName||e.id.namespace||e.id.name||e.id.kind),R=({theme:e,nodes:t,aggregatedServiceMap:r})=>{const i=[],n=new Map(t.map(e=>[e.id,e]));for(const t of r){const r=j(t.graphKey),a=n.get(r);if(!a)continue;const o=a.data?.status===y.Error;for(const a of t.connections){const c=j(a.targetGraphKey);n.has(c)&&i.push({id:`${r}-to-${c}`,type:"smoothstep",source:r,target:c,data:{sourceGraphKey:t.graphKey,targetGraphKey:a.targetGraphKey},markerEnd:{type:s.ArrowClosed},style:{stroke:o?e?.colors.dark_red:e?.colors.border}})}}return i},_=new $,O=`${u.Source}-user-${d.MapItem}`,q={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"150","elk.spacing.nodeNode":"120","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.spacing.edgeEdgeBetweenLayers":"30","elk.layered.spacing.edgeNodeBetweenLayers":"40"},B=e=>{const t=e.lastIndexOf("|");return-1===t?{graphKey:e,detail:""}:{graphKey:e.substring(0,t),detail:e.substring(t+1)}},F=C.div`
|
|
2
2
|
padding: 8px 0;
|
|
3
|
-
`,
|
|
3
|
+
`,L=C.div`
|
|
4
4
|
display: flex;
|
|
5
5
|
gap: 12px;
|
|
6
6
|
align-items: center;
|
|
7
7
|
padding: 4px 0 4px 16px;
|
|
8
|
-
`,
|
|
8
|
+
`,P=C.button`
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
11
|
gap: 4px;
|
|
@@ -19,16 +19,16 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState
|
|
|
19
19
|
&:hover {
|
|
20
20
|
text-decoration: underline;
|
|
21
21
|
}
|
|
22
|
-
`,W=
|
|
22
|
+
`,W=C.div`
|
|
23
23
|
padding: 4px 0 8px;
|
|
24
|
-
`,
|
|
24
|
+
`,U=({conn:r,onToggle:i,isExpanded:n})=>{const a=r.details.length>0;return e(F,{children:t(S,{$justifyContent:"space-between",$alignItems:"center",children:[e(v,{size:14,weight:500,children:r.targetServiceName}),a&&t(P,{onClick:i,children:[e(n?M:I,{size:12}),n?"hide attributes":`${r.details.length} attribute${r.details.length>1?"s":""}`]})]})})},H=({conn:t})=>{const i=E();return e(r,{children:t.details.map(t=>e(L,{children:e(v,{size:12,color:i.text.secondary,style:{flex:1},children:t.value})},t.value))})},X=({connections:n,isVirtual:a,attributes:o})=>{const[s,c]=i(new Set),l=E();if(a){const i=Object.entries(o||{});return t(r,{children:[e(v,{size:12,color:l.text.info,children:"This service is not instrumented. It was detected from client-side spans of services that communicate with it."}),i.length>0&&t(r,{children:[e(W,{style:{paddingTop:16},children:e(v,{size:11,color:l.text.info,children:"Attributes"})}),i.map(([r,i])=>t(L,{children:[e(v,{size:12,color:l.text.secondary,children:r}),e(v,{size:12,children:i})]},r))]})]})}return n.length?t(r,{children:[e(W,{children:e(v,{size:11,color:l.text.info,children:"Connected services"})}),n.map(r=>t("div",{children:[e(U,{conn:r,isExpanded:s.has(r.targetGraphKey),onToggle:()=>{return e=r.targetGraphKey,void c(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});var e}}),s.has(r.targetGraphKey)&&e(H,{conn:r}),e(x,{})]},r.targetGraphKey))]}):e(v,{size:12,color:l.text.info,children:"No outgoing connections"})},J=({conn:i})=>{const n=E();return i?e(r,{children:i.details.length>0?t(r,{children:[e(W,{children:e(v,{size:11,color:n.text.info,children:"Attribute breakdown"})}),i.details.map(t=>e(L,{children:e(v,{size:12,style:{flex:1},children:t.value})},t.value))]}):e(v,{size:12,color:n.text.info,style:{padding:"8px 0"},children:"No attribute breakdown"})}):e(v,{size:12,color:n.text.info,children:"No data for this connection"})},Q=({drawerState:t,aggregatedData:r,onClose:i})=>{if(!t)return null;const n=new Map(r.map(e=>[e.graphKey,e]));let a="",o="",s=null;if("node"===t.type){const r=n.get(t.graphKey);a=r?.serviceName||t.graphKey,o=r?.isVirtual?"Virtual service (uninstrumented)":"Outgoing connections",s=e(X,{connections:r?.connections||[],isVirtual:r?.isVirtual,attributes:r?.attributes})}else{const r=n.get(t.sourceKey),i=r?.connections.find(e=>e.targetGraphKey===t.targetKey);a=`${r?.serviceName||t.sourceKey} → ${i?.targetServiceName||t.targetKey}`,o="Connection details",s=e(J,{conn:i})}return e(f,{isOpen:!0,width:"420px",position:"right",header:{title:a,subTitle:o,onClose:i},children:s})},Y=["sources"],Z=[],ee=C.div`
|
|
25
25
|
width: 100%;
|
|
26
26
|
flex: 1;
|
|
27
27
|
align-self: stretch;
|
|
28
28
|
min-height: 0;
|
|
29
29
|
height: 100%;
|
|
30
30
|
position: relative;
|
|
31
|
-
`,
|
|
31
|
+
`,te={id:{namespace:"",name:"",kind:""},serviceName:"user",markedForInstrumentation:{markedForInstrumentation:!0}},re=`${u.Source}-`,ie=`-${d.MapItem}`,ne=.15,ae=({serviceMap:r,pollIntervalMs:s=5e3})=>{const g=E(),{data:m,refetch:h}=z("GET_SERVICE_MAP",void 0,{skip:!!r,pollInterval:s,fetchPolicy:"cache-and-network"}),{sourcesApi:y}=G({subscribe:Y}),f=y.items,v=r??(m?.serviceMap??Z),x=r?void 0:()=>{h()},[S,N,k]=c([]),[w,K,T]=l([]),[M,I]=i(0),[C,$]=i(null),F=n([]);F.current=S;const L=n(g);L.current=g;const P=n([]),W=n([]),U=a(()=>I(e=>e+1),[]),{activeNodeId:H,setActiveNodeType:X,setActiveNodeId:J}=b();o(()=>{if(!H)return;const e=(t=H).startsWith(re)&&t.endsWith(ie)?t.slice(re.length,-ie.length):null;var t;e&&$({type:"node",graphKey:e})},[H]);const ae=a((e,t)=>{const{sourceGraphKey:r,targetGraphKey:i}=t.data||{};r&&i&&(X(null),J(null),$({type:"edge",sourceKey:r,targetKey:i}))},[X,J]),oe=a(()=>{$(null),X(null),J(null)},[X,J]),se=a((e,t)=>{const r=t.id;K(e=>e.map(e=>e.source===r||e.target===r?{...e,animated:!0,style:{...e.style,strokeWidth:2.5},labelStyle:{...e.labelStyle,opacity:1},labelBgStyle:{...e.labelBgStyle,opacity:1}}:{...e,style:{...e.style,opacity:ne},labelStyle:{...e.labelStyle,opacity:ne},labelBgStyle:{...e.labelBgStyle,opacity:ne}}))},[K]),ce=a(()=>{K(W.current)},[K]);return o(()=>{let e=!1;const t=(e=>{const t=new Map,r=new Set,i=(e,r,i=!1)=>{let n=t.get(e);return n||(n={serviceName:r,isVirtual:i,attributes:{},connectionMap:new Map},t.set(e,n)),n},n=(e,t)=>{if(t)for(const{key:r,value:i}of t)r in e||(e[r]=i)};for(const t of e){const{graphKey:e}=B(t.nodeId),a=i(e,t.serviceName);a.isVirtual=!1;for(const e of t.services){const{graphKey:t,detail:o}=B(e?.nodeId??"");e.isVirtual&&(r.add(t),n(i(t,e.serviceName,!0).attributes,e.nodeAttributes));let s=a.connectionMap.get(t);if(s||(s={targetGraphKey:t,targetServiceName:e.serviceName,totalRequests:0,lastDateTime:e.dateTime,details:[]},a.connectionMap.set(t,s)),s.totalRequests+=e.requests,e.dateTime>s.lastDateTime&&(s.lastDateTime=e.dateTime),o){const t=s.details.find(e=>e.value===o);t?(t.requests+=e.requests,e.dateTime>t.dateTime&&(t.dateTime=e.dateTime)):s.details.push({value:o,requests:e.requests,dateTime:e.dateTime})}}}const a=[...t.entries()];for(const[,{connectionMap:e}]of a)for(const[n,a]of e)t.has(n)||i(n,a.targetServiceName,r.has(n));const o=[];for(const[e,{serviceName:r,isVirtual:i,attributes:n,connectionMap:a}]of t){const t=[...a.values()];t.sort((e,t)=>e.targetGraphKey.localeCompare(t.targetGraphKey)),o.push({graphKey:e,serviceName:r,isVirtual:i,connections:t,attributes:n})}return o.sort((e,t)=>e.graphKey.localeCompare(t.graphKey)),o})(v);P.current=t;const r=(({sources:e,aggregatedServiceMap:t})=>{const r=[],i={x:0,y:0};if(t.length&&e.length)for(const n of t){const t=j(n.graphKey),a=e.find(e=>n.serviceName===e.serviceName||n.serviceName===e.id.name);r.push({id:t,type:d.MapItem,position:i,data:A(n,a,D(a)),measured:{width:80,height:80}})}else r.push({id:`${u.Source}-${d.NoData}`,type:d.NoData,position:i,data:{subTitle:p.ARE_SERVICES_INSTRUMENTED_AND_PRODUCING_TRAFFIC}});return r})({aggregatedServiceMap:t,sources:[te].concat(f)});if(1===r.length&&r[0].id===`${u.Source}-${d.NoData}`)return N(r),K([]),void(W.current=[]);const i=new Set(F.current.map(e=>e.id)),n=new Set(r.map(e=>e.id)),a=r.some(e=>!i.has(e.id)),o=F.current.some(e=>!n.has(e.id));if(!(a||o)){const e=new Map(F.current.map(e=>[e.id,e.position]));N(r.map(t=>({...t,position:e.get(t.id)??t.position})));const i=R({theme:L.current,nodes:r,aggregatedServiceMap:t});return W.current=i,void K(i)}return(async(e,t,r={})=>{const i={id:"root",layoutOptions:{...q,...r},children:e.map(e=>({id:e.id,width:80,height:80,...e.id===O?{layoutOptions:{"elk.layered.layering.layerConstraint":"FIRST","elk.alignment":"CENTER"}}:{}})),edges:t.map(e=>({id:e.id,sources:[e.source],targets:[e.target]}))},n=await _.layout(i),a=new Map;return n.children?.forEach(e=>{a.set(e.id,{x:e.x??0,y:e.y??0})}),{nodes:e.map(e=>({...e,position:a.get(e.id)??e.position})),edges:t}})(r,R({theme:L.current,nodes:r,aggregatedServiceMap:t})).then(({nodes:t})=>{if(e)return;N(t);const r=R({theme:L.current,nodes:t,aggregatedServiceMap:P.current});W.current=r,K(r),U()}),()=>{e=!0}},[v,f]),o(()=>{if(!F.current.length)return;const e=R({theme:g,nodes:F.current,aggregatedServiceMap:P.current});W.current=e,K(e)},[g]),t(ee,{children:[e(V,{nodes:S,edges:w,onNodesChange:k,onEdgesChange:T,onEdgeClick:ae,onNodeMouseEnter:se,onNodeMouseLeave:ce,onRefresh:x,fitViewTrigger:M,zoomOnScroll:!0}),e(Q,{drawerState:C,aggregatedData:P.current,onClose:oe})]})},oe=C.div`
|
|
32
32
|
position: fixed;
|
|
33
33
|
bottom: 12px;
|
|
34
34
|
left: 12px;
|
|
@@ -37,4 +37,4 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState
|
|
|
37
37
|
flex-direction: column-reverse;
|
|
38
38
|
gap: 6px;
|
|
39
39
|
max-width: 600px;
|
|
40
|
-
`,
|
|
40
|
+
`,se=()=>{const{notifications:t,markAsDismissed:r,markAsSeen:i}=N(),{onClickNotification:n}=k(),a=t.filter(({dismissed:e})=>!e);return e(oe,{children:a.map(({id:t,type:o,title:s,message:c,crdType:l,target:d},p)=>{const u=c||s;if(!u)return null;const g=a.length-p;return e(w,{status:o,message:u,action:l&&d?{label:"go to details",onClick:()=>n({id:t,crdType:l,target:d},{dismissToast:!0})}:void 0,onClose:({asSeen:e})=>(({id:e,asSeen:t})=>{r(e),t&&i(e)})({id:t,asSeen:e}),zIndex:g},`toast-${t}`)})})};export{ae as ServiceMap,se as ToastList};
|
package/lib/contexts/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './action-form-context';
|
|
2
2
|
export * from './data-stream-form-context';
|
|
3
3
|
export * from './destination-form-context';
|
|
4
|
+
export * from './odigos-api';
|
|
4
5
|
export * from './odigos-context';
|
|
5
6
|
export * from './rule-form-context';
|
|
6
7
|
export * from './sampling-rules-form-context';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability derivation: a single source of truth for "is this UI affordance
|
|
3
|
+
* available?" replacing the scattered `!isVm && fn ? ... : undefined` checks
|
|
4
|
+
* the ticket called out.
|
|
5
|
+
*
|
|
6
|
+
* Capabilities are computed from:
|
|
7
|
+
* 1. `ctx.platformType` — VM platforms gate out cluster-only features.
|
|
8
|
+
* 2. `ctx.tier` — community vs enterprise.
|
|
9
|
+
* 3. Operation presence — if the host adapter doesn't supply
|
|
10
|
+
* `CREATE_ACTION`, the capability is `false`.
|
|
11
|
+
*
|
|
12
|
+
* Containers should consume capabilities, not platform identity.
|
|
13
|
+
*/
|
|
14
|
+
import type { OdigosApiOperations, OperationContext } from './types';
|
|
15
|
+
export interface Capabilities {
|
|
16
|
+
canBulkPersistSources: boolean;
|
|
17
|
+
canFetchSnapshots: boolean;
|
|
18
|
+
canRecoverFromRollback: boolean;
|
|
19
|
+
canRestartWorkloads: boolean;
|
|
20
|
+
canFetchPeerSources: boolean;
|
|
21
|
+
canFetchSourceLibraries: boolean;
|
|
22
|
+
canFetchK8sManifest: boolean;
|
|
23
|
+
canCreateDestination: boolean;
|
|
24
|
+
canTestConnection: boolean;
|
|
25
|
+
canFetchDestinationCategories: boolean;
|
|
26
|
+
canFetchPotentialDestinations: boolean;
|
|
27
|
+
canCreateAction: boolean;
|
|
28
|
+
canCreateInstrumentationRule: boolean;
|
|
29
|
+
canApplyEffectiveConfig: boolean;
|
|
30
|
+
canFetchEffectiveConfig: boolean;
|
|
31
|
+
canFetchConfigYamls: boolean;
|
|
32
|
+
canFetchProfiling: boolean;
|
|
33
|
+
canFetchCollectorInfo: boolean;
|
|
34
|
+
canManageSamplingRules: boolean;
|
|
35
|
+
isEnterprise: boolean;
|
|
36
|
+
isVm: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const deriveCapabilities: (operations: OdigosApiOperations, ctx: OperationContext) => Capabilities;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apollo client factory used by the OdigosApiProvider.
|
|
3
|
+
*
|
|
4
|
+
* Encodes the union of the two host apps' Apollo setups (odigos webapp +
|
|
5
|
+
* central-ui), gating each concern on a flag in `ApolloConfig`. Hosts
|
|
6
|
+
* supply their own auth header / CSRF header / error redirect callbacks
|
|
7
|
+
* and (if needed) their own WS link, while the kit owns the link
|
|
8
|
+
* composition, cache, and default fetch policies.
|
|
9
|
+
*/
|
|
10
|
+
import type { ApolloConfig } from './types';
|
|
11
|
+
import { ApolloClient } from '@apollo/client';
|
|
12
|
+
/**
|
|
13
|
+
* Construct an ApolloClient for the supplied host config.
|
|
14
|
+
*
|
|
15
|
+
* The link chain is:
|
|
16
|
+
* 1. authLink: injects auth + CSRF headers from host callbacks.
|
|
17
|
+
* 2. errorLink: routes auth failures to `onAuthError`.
|
|
18
|
+
* 3. additionalLinks (host-supplied) prepended.
|
|
19
|
+
* 4. HttpLink terminates.
|
|
20
|
+
* 5. Optional WS link is split-routed for subscription operations.
|
|
21
|
+
*/
|
|
22
|
+
export declare const makeApolloClient: (config: ApolloConfig) => ApolloClient<unknown>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<OdigosApiConnectionsScope connectionIds={…}>` — overrides the
|
|
3
|
+
* current operation context's `connectionIds` for all `useOdigosApi()`
|
|
4
|
+
* calls inside. Used by central-ui's `<CentralConnections>` to wrap bulk
|
|
5
|
+
* drawers (`<AddSourceDrawer>`, `<AddDestinationDrawer>`,
|
|
6
|
+
* `<AddActionDrawer>`, `<AddRuleDrawer>`, `<EditConfigDrawer>`).
|
|
7
|
+
*
|
|
8
|
+
* The host adapter reads `ctx.connectionIds` inside its operation
|
|
9
|
+
* `transformVariables` to route mutations across the selected clusters
|
|
10
|
+
* (typically via REMOTE_MULTI_FETCH).
|
|
11
|
+
*/
|
|
12
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
13
|
+
interface ConnectionsScopeProps extends PropsWithChildren {
|
|
14
|
+
/** Connection ids to scope all operations to. */
|
|
15
|
+
connectionIds: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare const OdigosApiConnectionsScope: FC<ConnectionsScopeProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useActionsApi` — actions CRUD.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`actions`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_ACTIONS')` so every consumer stays in sync via
|
|
6
|
+
* Apollo's cache broadcast. Mutations call `runMutation` and then
|
|
7
|
+
* `await fetchAll()` to refresh the cached list.
|
|
8
|
+
*/
|
|
9
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
10
|
+
import { type Action, type ActionFormData } from '@/types';
|
|
11
|
+
export interface ActionsApi {
|
|
12
|
+
items: Action[];
|
|
13
|
+
loading: boolean;
|
|
14
|
+
fetchAll: () => Promise<void>;
|
|
15
|
+
create: (input: ActionFormData) => Promise<void>;
|
|
16
|
+
update: (id: string, input: ActionFormData) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Delete an action. Both `id` and `actionType` are required by the
|
|
19
|
+
* wire mutation; the type is what the server uses to look up which
|
|
20
|
+
* action CRD to delete.
|
|
21
|
+
*/
|
|
22
|
+
remove: (id: string, actionType: string) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const useActionsApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
25
|
+
subscribe?: boolean;
|
|
26
|
+
}) => ActionsApi;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
2
|
+
import type { ExtendedPodInfo, GatewayInfo, NodeCollectoInfo, PodInfo } from '@/types';
|
|
3
|
+
export interface CollectorsApi {
|
|
4
|
+
getGatewayInfo?: () => Promise<{
|
|
5
|
+
data?: GatewayInfo;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
getGatewayPods?: () => Promise<{
|
|
9
|
+
data?: PodInfo[];
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
12
|
+
getNodeCollectorInfo?: () => Promise<{
|
|
13
|
+
data?: NodeCollectoInfo;
|
|
14
|
+
error?: string;
|
|
15
|
+
}>;
|
|
16
|
+
getNodeCollectorPods?: () => Promise<{
|
|
17
|
+
data?: PodInfo[];
|
|
18
|
+
error?: string;
|
|
19
|
+
}>;
|
|
20
|
+
getExtendedPodInfo?: (namespace: string, name: string) => Promise<{
|
|
21
|
+
data?: ExtendedPodInfo;
|
|
22
|
+
error?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export declare const useCollectorsApi: (operations: OdigosApiOperations, ctx: OperationContext) => CollectorsApi;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
2
|
+
import { type ConfigYaml, type EffectiveConfig, type EffectiveConfigInput, type LocalUiConfigInput } from '@/types';
|
|
3
|
+
export interface ConfigApi {
|
|
4
|
+
getEffectiveConfig: (id?: string) => Promise<{
|
|
5
|
+
data?: EffectiveConfig;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
applyConfigurations?: (formData: Partial<EffectiveConfigInput>, connectionIds: string[]) => Promise<{
|
|
9
|
+
error?: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
getConfigYamls?: () => Promise<{
|
|
12
|
+
data?: {
|
|
13
|
+
configYamls: ConfigYaml[];
|
|
14
|
+
};
|
|
15
|
+
error?: string;
|
|
16
|
+
}>;
|
|
17
|
+
updateLocalUiConfig?: (input: LocalUiConfigInput) => Promise<{
|
|
18
|
+
error?: string;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
resetLocalUiConfigToDefaults?: () => Promise<{
|
|
21
|
+
error?: string;
|
|
22
|
+
} | undefined>;
|
|
23
|
+
}
|
|
24
|
+
export declare const useConfigApi: (operations: OdigosApiOperations, ctx: OperationContext) => ConfigApi;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useDataStreamsApi` — data-streams CRUD.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`items`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_DATA_STREAMS')` so the list auto-fetches once any
|
|
6
|
+
* consumer of `useOdigosApi()` mounts. The hook also bridges the
|
|
7
|
+
* fetched list into `useDataStreamStore.dataStreams` so legacy
|
|
8
|
+
* consumers that read `useDataStreamStore` directly stay in sync —
|
|
9
|
+
* we keep the Zustand store as the canonical "selected stream"
|
|
10
|
+
* carrier (UI state) but the underlying list comes from the same
|
|
11
|
+
* Apollo cache as every other entity.
|
|
12
|
+
*/
|
|
13
|
+
import { type DataStream } from '@/types';
|
|
14
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
15
|
+
export interface DataStreamsApi {
|
|
16
|
+
/** All data streams. Sourced from `useApiQuery('GET_DATA_STREAMS')`. */
|
|
17
|
+
items: DataStream[];
|
|
18
|
+
loading: boolean;
|
|
19
|
+
fetchAll: () => Promise<void>;
|
|
20
|
+
create?: (stream: DataStream) => Promise<void>;
|
|
21
|
+
update: (name: string, stream: DataStream) => Promise<void>;
|
|
22
|
+
remove: (name: string) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const useDataStreamsApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
25
|
+
subscribe?: boolean;
|
|
26
|
+
}) => DataStreamsApi;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { WorkloadId } from '@/types';
|
|
2
|
+
import type { DescribeOdigosData, DescribeSourceData, DiagnoseResult, OperationContext, OdigosApiOperations, DiagnoseVars } from '../types';
|
|
3
|
+
export interface DescribeApi {
|
|
4
|
+
fetchDescribeOdigos?: () => Promise<{
|
|
5
|
+
data?: DescribeOdigosData;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
fetchDescribeSource?: (id: WorkloadId) => Promise<{
|
|
9
|
+
data?: DescribeSourceData;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Diagnose download is a 2-step flow, both owned by the kit:
|
|
14
|
+
*
|
|
15
|
+
* 1. `GET_DIAGNOSE` — server-side bundle build that the SSE listener turns into per-stage progress notifications.
|
|
16
|
+
* Resolves with the diagnostic stats (file count, byte size).
|
|
17
|
+
* 2. REST GET to `<apollo-origin>/diagnose/download` — the kit re-uses the host's `apolloConfig` (origin from `httpUrl`, `credentials`, `authHeader`, `csrfHeader`) to fetch the prepared archive, then triggers a browser download via a hidden `<a download>` element.
|
|
18
|
+
* The host doesn't have to wire anything; if `GET_DIAGNOSE` is mapped, the file download just works.
|
|
19
|
+
*
|
|
20
|
+
* Step 2 is skipped on dry runs and when `stats.fileCount === 0` (nothing to bundle).
|
|
21
|
+
* Step 2 errors are logged but not surfaced — step 1 has already succeeded by then so a step-2 failure shouldn't roll back progress or fire a confusing toast.
|
|
22
|
+
*
|
|
23
|
+
* The wire mutation is `diagnose(input: DiagnoseInput!, dryRun: Boolean)`, so consumers pass the bare `DiagnoseInput` and the hook wraps it under `{ input }` before dispatching.
|
|
24
|
+
* `dryRun` defaults to false.
|
|
25
|
+
*/
|
|
26
|
+
downloadDiagnose?: (payload: DiagnoseVars['input'], options?: {
|
|
27
|
+
dryRun?: boolean;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
data?: DiagnoseResult;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
export declare const useDescribeApi: (operations: OdigosApiOperations, ctx: OperationContext) => DescribeApi;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useDestinationsApi` — destinations CRUD.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`destinations`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_DESTINATIONS')` so every consumer (overview
|
|
6
|
+
* column, drawers, form context) stays in sync via Apollo's cache
|
|
7
|
+
* broadcast. Mutations call `runMutation` and then `await fetchAll()`
|
|
8
|
+
* to refresh the cached list — the broadcast updates every subscriber
|
|
9
|
+
* in one go.
|
|
10
|
+
*/
|
|
11
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
12
|
+
import { type Destination, type DestinationFormData, type TestConnectionResponse, type GetDestinationCategoriesResult, type GetPotentialDestinationsResult } from '@/types';
|
|
13
|
+
export interface DestinationsApi {
|
|
14
|
+
items: Destination[];
|
|
15
|
+
loading: boolean;
|
|
16
|
+
fetchAll: () => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Destination category definitions (the YAML field schemas grouped by
|
|
19
|
+
* "self hosted" / "managed"). Reactive: flows through
|
|
20
|
+
* `useApiQuery('GET_DESTINATION_CATEGORIES')` and is gated on the
|
|
21
|
+
* `subscribeCategories` opt-in (see `useOdigosApi({ subscribe: ['destinationCategories'] })`).
|
|
22
|
+
* `undefined` until the consumer subscribes and the request resolves.
|
|
23
|
+
*/
|
|
24
|
+
categoriesResult: GetDestinationCategoriesResult | undefined;
|
|
25
|
+
/** True while the categories request is in flight (only when subscribed). */
|
|
26
|
+
categoriesLoading: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Auto-detected destinations from a cluster scan. Reactive: flows through
|
|
29
|
+
* `useApiQuery('GET_POTENTIAL_DESTINATIONS')` and is gated on the
|
|
30
|
+
* `subscribePotential` opt-in. `undefined` until subscribed + resolved.
|
|
31
|
+
*/
|
|
32
|
+
potentialResult: GetPotentialDestinationsResult | undefined;
|
|
33
|
+
/** True while the potential-destinations request is in flight (only when subscribed). */
|
|
34
|
+
potentialLoading: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Test the destination connection. The host adapter's
|
|
37
|
+
* `TEST_DESTINATION_CONNECTION` operation should set `transformResult` to
|
|
38
|
+
* unwrap `data?.testDestinationConnection` so the consumer gets a
|
|
39
|
+
* `TestConnectionResponse` directly.
|
|
40
|
+
*/
|
|
41
|
+
testConnection: (formData: DestinationFormData) => Promise<TestConnectionResponse | undefined>;
|
|
42
|
+
create: (destination: DestinationFormData) => Promise<void>;
|
|
43
|
+
update: (id: string, destination: DestinationFormData) => Promise<void>;
|
|
44
|
+
remove: (id: string) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export declare const useDestinationsApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
47
|
+
subscribe?: boolean;
|
|
48
|
+
subscribeCategories?: boolean;
|
|
49
|
+
subscribePotential?: boolean;
|
|
50
|
+
}) => DestinationsApi;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useInstrumentationRulesApi` — instrumentation rules CRUD.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`rules`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_INSTRUMENTATION_RULES')` so every consumer stays
|
|
6
|
+
* in sync via Apollo's cache broadcast. Mutations call `runMutation`
|
|
7
|
+
* and then `await fetchAll()` to refresh the cached list.
|
|
8
|
+
*
|
|
9
|
+
* Wire-shape note: the GraphQL `InstrumentationRule` schema uses
|
|
10
|
+
* `sourcesScopes` (a row-per-criterion array), while the kit's
|
|
11
|
+
* `InstrumentationRule` model uses `sourceScopes` (a tri-list spec
|
|
12
|
+
* shape, matching sampling rules' naming). This hook owns the
|
|
13
|
+
* conversion in BOTH directions so consumer code only ever sees the
|
|
14
|
+
* spec shape:
|
|
15
|
+
* - Reads run through `adaptInstrumentationRuleFromWire` (folds the
|
|
16
|
+
* row array back into `{ sources, namespaces, languages }`).
|
|
17
|
+
* - Mutation inputs run through `adaptInstrumentationRuleInputForWire`
|
|
18
|
+
* (unfolds the spec back into rows + renames the field).
|
|
19
|
+
*
|
|
20
|
+
* Both adapters return the same wire shape, so the conversion lives
|
|
21
|
+
* here rather than per-adapter.
|
|
22
|
+
*/
|
|
23
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
24
|
+
import { type InstrumentationRule, type InstrumentationRuleFormData } from '@/types';
|
|
25
|
+
export interface InstrumentationRulesApi {
|
|
26
|
+
items: InstrumentationRule[];
|
|
27
|
+
loading: boolean;
|
|
28
|
+
fetchAll: () => Promise<void>;
|
|
29
|
+
create: (input: InstrumentationRuleFormData) => Promise<void>;
|
|
30
|
+
update: (id: string, input: InstrumentationRuleFormData) => Promise<void>;
|
|
31
|
+
remove: (id: string) => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare const useInstrumentationRulesApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
34
|
+
subscribe?: boolean;
|
|
35
|
+
}) => InstrumentationRulesApi;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OperationContext, OdigosApiOperations, GetK8sManifestVars, GetK8sManifestData } from '../types';
|
|
2
|
+
export interface K8sManifestApi {
|
|
3
|
+
/**
|
|
4
|
+
* Fetch the YAML manifest for a k8s resource. Returns the bare YAML
|
|
5
|
+
* string — adapters whose wire shape is `{ k8sActualManifest } | { manifest }`
|
|
6
|
+
* MUST flatten via `Operation.transformResult` (or `wrapRemote`'s
|
|
7
|
+
* `extract` callback). Returns `undefined` data on error.
|
|
8
|
+
*/
|
|
9
|
+
fetch: (input: GetK8sManifestVars) => Promise<{
|
|
10
|
+
data?: GetK8sManifestData;
|
|
11
|
+
error?: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export declare const useK8sManifestApi: (operations: OdigosApiOperations, ctx: OperationContext) => K8sManifestApi;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Metrics } from '@/types';
|
|
2
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
3
|
+
interface MetricsEnvelope {
|
|
4
|
+
getOverviewMetrics?: Metrics;
|
|
5
|
+
}
|
|
6
|
+
export interface MetricsApi {
|
|
7
|
+
fetch: () => Promise<{
|
|
8
|
+
data?: MetricsEnvelope;
|
|
9
|
+
error?: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const useMetricsApi: (operations: OdigosApiOperations, ctx: OperationContext) => MetricsApi;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useNamespaceApi` — namespaces (with workloads) read + persist.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`namespaces`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_NAMESPACES_WITH_WORKLOADS')`. Apollo dedupes
|
|
6
|
+
* concurrent consumers and shares the cached list, so the
|
|
7
|
+
* `<AddSourceDrawer>` and `<DiagnoseTab>` (and any other consumer)
|
|
8
|
+
* see the same data once any of them has triggered the fetch.
|
|
9
|
+
*/
|
|
10
|
+
import { type Namespace } from '@/types';
|
|
11
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
12
|
+
import type { NamespaceInstrumentInput } from '../internal/source-payloads';
|
|
13
|
+
interface NamespacesEnvelope {
|
|
14
|
+
namespaces?: Namespace[];
|
|
15
|
+
}
|
|
16
|
+
export interface NamespaceApi {
|
|
17
|
+
items: Namespace[];
|
|
18
|
+
loading: boolean;
|
|
19
|
+
fetchAll: () => Promise<{
|
|
20
|
+
data?: NamespacesEnvelope;
|
|
21
|
+
error?: string;
|
|
22
|
+
}>;
|
|
23
|
+
persist: (payload: NamespaceInstrumentInput) => Promise<{
|
|
24
|
+
error?: string;
|
|
25
|
+
} | void>;
|
|
26
|
+
}
|
|
27
|
+
export declare const useNamespaceApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
28
|
+
subscribe?: boolean;
|
|
29
|
+
}) => NamespaceApi;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
2
|
+
import type { EnableProfilingResult, ProfilingSlots, SourceProfilingResult, WorkloadId } from '@/types';
|
|
3
|
+
export interface ProfilingApi {
|
|
4
|
+
fetchSlots?: () => Promise<{
|
|
5
|
+
data?: ProfilingSlots;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
fetchSourceProfiling?: (sourceId: WorkloadId) => Promise<{
|
|
9
|
+
data?: SourceProfilingResult;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
12
|
+
enableProfiling?: (sourceId: WorkloadId) => Promise<{
|
|
13
|
+
data?: EnableProfilingResult;
|
|
14
|
+
error?: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare const useProfilingApi: (operations: OdigosApiOperations, ctx: OperationContext) => ProfilingApi;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type CostReductionRuleInput, type HighlyRelevantOperationRuleInput, type NoisyOperationRuleInput } from '@/types';
|
|
2
|
+
import type { GetSamplingRulesData, OperationContext, OdigosApiOperations, SamplingK8sHealthConfigVars, SamplingRuleCreateVars } from '../types';
|
|
3
|
+
export interface SamplingApi {
|
|
4
|
+
fetchAll?: () => Promise<{
|
|
5
|
+
data?: GetSamplingRulesData;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
createNoisy?: (vars: SamplingRuleCreateVars<NoisyOperationRuleInput>) => Promise<{
|
|
9
|
+
error?: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
updateNoisy?: (ruleId: string, vars: SamplingRuleCreateVars<NoisyOperationRuleInput>) => Promise<{
|
|
12
|
+
error?: string;
|
|
13
|
+
} | undefined>;
|
|
14
|
+
deleteNoisy?: (ruleId: string, samplingId: string) => Promise<{
|
|
15
|
+
error?: string;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
createHighlyRelevant?: (vars: SamplingRuleCreateVars<HighlyRelevantOperationRuleInput>) => Promise<{
|
|
18
|
+
error?: string;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
updateHighlyRelevant?: (ruleId: string, vars: SamplingRuleCreateVars<HighlyRelevantOperationRuleInput>) => Promise<{
|
|
21
|
+
error?: string;
|
|
22
|
+
} | undefined>;
|
|
23
|
+
deleteHighlyRelevant?: (ruleId: string, samplingId: string) => Promise<{
|
|
24
|
+
error?: string;
|
|
25
|
+
} | undefined>;
|
|
26
|
+
createCostReduction?: (vars: SamplingRuleCreateVars<CostReductionRuleInput>) => Promise<{
|
|
27
|
+
error?: string;
|
|
28
|
+
} | undefined>;
|
|
29
|
+
updateCostReduction?: (ruleId: string, vars: SamplingRuleCreateVars<CostReductionRuleInput>) => Promise<{
|
|
30
|
+
error?: string;
|
|
31
|
+
} | undefined>;
|
|
32
|
+
deleteCostReduction?: (ruleId: string, samplingId: string) => Promise<{
|
|
33
|
+
error?: string;
|
|
34
|
+
} | undefined>;
|
|
35
|
+
updateK8sHealthProbesConfig?: (input: SamplingK8sHealthConfigVars) => Promise<{
|
|
36
|
+
error?: string;
|
|
37
|
+
} | undefined>;
|
|
38
|
+
}
|
|
39
|
+
export declare const useSamplingApi: (operations: OdigosApiOperations, ctx: OperationContext) => SamplingApi;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
2
|
+
import type { AggregatedServiceMap, ServiceMapSources } from '@/types';
|
|
3
|
+
interface ServiceMapEnvelope {
|
|
4
|
+
serviceMap?: AggregatedServiceMap | ServiceMapSources;
|
|
5
|
+
}
|
|
6
|
+
export interface ServiceMapApi {
|
|
7
|
+
fetch?: () => Promise<{
|
|
8
|
+
data?: ServiceMapEnvelope;
|
|
9
|
+
error?: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const useServiceMapApi: (operations: OdigosApiOperations, ctx: OperationContext) => ServiceMapApi;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AllClusterSnapshots, ClusterSnapshot } from '@/types';
|
|
2
|
+
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
3
|
+
export interface SnapshotsApi {
|
|
4
|
+
getAllClusterSnapshots?: () => Promise<{
|
|
5
|
+
data?: AllClusterSnapshots;
|
|
6
|
+
error?: string;
|
|
7
|
+
}>;
|
|
8
|
+
getClusterSnapshot?: (clusterId: string) => Promise<{
|
|
9
|
+
data?: ClusterSnapshot;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare const useSnapshotsApi: (operations: OdigosApiOperations, ctx: OperationContext) => SnapshotsApi;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useSourcesApi` — sources/workloads CRUD.
|
|
3
|
+
*
|
|
4
|
+
* Reads (`sources`, `loading`) flow through the kit's declarative
|
|
5
|
+
* `useApiQuery('GET_WORKLOADS')` so multiple consumers automatically
|
|
6
|
+
* share Apollo's normalized cache and stay in sync via cache
|
|
7
|
+
* broadcasts. Mutations (`persist` / `persistV2` / `update`) call
|
|
8
|
+
* `runMutation` and then return — they do NOT refetch the list. The
|
|
9
|
+
* cluster SSE stream is the source of truth for post-mutation state:
|
|
10
|
+
* host SSE handlers call `fetchByTargets` / `fetchAll`, whose cache
|
|
11
|
+
* write broadcasts to every subscriber (overview columns, drawers,
|
|
12
|
+
* service-map, etc.) in one go.
|
|
13
|
+
*
|
|
14
|
+
* Optimistic in-memory updates that this hook used to perform via
|
|
15
|
+
* the deleted `useEntityStore` (`addEntities` / `removeEntities` /
|
|
16
|
+
* `setEntitiesLoading`) are no longer needed: the explicit refetch
|
|
17
|
+
* after each mutation produces the same visible end-state with a
|
|
18
|
+
* sub-second latency, and the kit no longer needs to know how each
|
|
19
|
+
* host adapter shapes its `GET_WORKLOADS` response envelope to write
|
|
20
|
+
* back through Apollo's cache.
|
|
21
|
+
*
|
|
22
|
+
* SSE-driven invalidation flows through the same `fetchAll` /
|
|
23
|
+
* `fetchByTargets` entry points: host SSE handlers call them when
|
|
24
|
+
* cluster events arrive; the cache write broadcasts to every active
|
|
25
|
+
* `useApiQuery('GET_WORKLOADS')` subscriber.
|
|
26
|
+
*/
|
|
27
|
+
import { type PeerSources, type SourceFormData, type Workload, type WorkloadId } from '@/types';
|
|
28
|
+
import type { GetSourceLibrariesData, OperationContext, OdigosApiOperations } from '../types';
|
|
29
|
+
import { type NamespaceSelectionFormData, type SourceSelectionFormData } from '@/store';
|
|
30
|
+
export interface PersistSourceInput {
|
|
31
|
+
[clusterId: string]: {
|
|
32
|
+
namespace: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
kind?: string;
|
|
35
|
+
selected: boolean;
|
|
36
|
+
currentStreamName: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
export interface SourcesApi {
|
|
40
|
+
/** All workloads marked for instrumentation. Sourced from the active `useApiQuery('GET_WORKLOADS')` subscription. */
|
|
41
|
+
items: Workload[];
|
|
42
|
+
/** True while the initial `GET_WORKLOADS` request is in flight. */
|
|
43
|
+
loading: boolean;
|
|
44
|
+
/** Trigger a fresh `GET_WORKLOADS` round-trip and broadcast the result via Apollo's cache. */
|
|
45
|
+
fetchAll: () => Promise<void>;
|
|
46
|
+
/** Fetch specific workloads by SSE-target strings. The result is merged into Apollo's cache via the slot's normalization. */
|
|
47
|
+
fetchByTargets: (targets: string[], options?: {
|
|
48
|
+
slim?: boolean;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
/** Fetch a single workload by id, returning the freshest copy from Apollo's cache once the round-trip completes. */
|
|
51
|
+
fetchById: (id: WorkloadId) => Promise<Workload | undefined>;
|
|
52
|
+
fetchLibraries: (id: WorkloadId) => Promise<{
|
|
53
|
+
data?: GetSourceLibrariesData;
|
|
54
|
+
error?: string;
|
|
55
|
+
}>;
|
|
56
|
+
fetchPeerSources: (serviceName: string) => Promise<{
|
|
57
|
+
data?: {
|
|
58
|
+
peerSources?: PeerSources;
|
|
59
|
+
};
|
|
60
|
+
error?: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** Persist the legacy form-shape payload (used by `AddSourceDrawer` / `Onboarding`). */
|
|
63
|
+
persist: (selectAppsList: SourceSelectionFormData, futureSelectAppsList: NamespaceSelectionFormData) => Promise<void>;
|
|
64
|
+
/** Persist the V2 multi-cluster payload shape (used by `CentralConnections` / standalone overview's bulk persist). */
|
|
65
|
+
persistV2: (input: PersistSourceInput) => Promise<{
|
|
66
|
+
error?: string;
|
|
67
|
+
} | undefined>;
|
|
68
|
+
update: (sourceId: WorkloadId, payload: SourceFormData) => Promise<void>;
|
|
69
|
+
restartWorkloads: (sourceIds: WorkloadId[]) => Promise<void>;
|
|
70
|
+
restartPod: (namespace: string, name: string) => Promise<void>;
|
|
71
|
+
recoverFromRollback: (sourceId: WorkloadId) => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export declare const useSourcesApi: (operations: OdigosApiOperations, ctx: OperationContext, options?: {
|
|
74
|
+
subscribe?: boolean;
|
|
75
|
+
}) => SourcesApi;
|