@odigos/ui-kit 0.0.272 → 0.0.274
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 +21 -0
- package/lib/chunks/helpers-9QRquBS1.js +9 -0
- package/lib/chunks/{index-D2_SqNhv.js → index-BesD_mee.js} +3 -3
- package/lib/chunks/source-instrument-form-context-fYKmw6ZG.js +5 -0
- package/lib/chunks/{ui-components-Cz2E0SIN.js → ui-components-i5FUYiX9.js} +215 -215
- package/lib/components/note/index.d.ts +2 -1
- package/lib/components.js +1 -1
- package/lib/constants/actions/categories.d.ts +6 -0
- package/lib/constants/actions/index.d.ts +1 -0
- package/lib/constants.js +1 -1
- package/lib/containers/_drawers/add-action-drawer/lists-column/index.d.ts +10 -0
- package/lib/containers/_drawers/edit-action-drawer/statuses-card.d.ts +6 -0
- package/lib/containers/central-connections/helpers.d.ts +2 -1
- package/lib/containers/central-connections/index.d.ts +1 -1
- package/lib/containers.js +272 -273
- package/lib/contexts/odigos-api/capabilities.d.ts +0 -4
- package/lib/contexts/odigos-api/types.d.ts +1 -1
- package/lib/contexts/odigos-context.d.ts +3 -1
- package/lib/contexts.js +1 -1
- package/lib/functions/get-action-conditions/index.d.ts +2 -0
- package/lib/functions/get-action-icon/index.d.ts +2 -2
- package/lib/functions/index.d.ts +2 -0
- package/lib/functions/map-desired-statuses-to-conditions/index.d.ts +2 -0
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/icons/actions/enrichment-icon/index.d.ts +2 -0
- package/lib/icons/actions/index.d.ts +3 -0
- package/lib/icons/actions/normalization-icon/index.d.ts +2 -0
- package/lib/icons/actions/privacy-icon/index.d.ts +2 -0
- package/lib/icons/compute-platform/ecs-logo/index.d.ts +2 -0
- package/lib/icons/compute-platform/index.d.ts +1 -1
- package/lib/icons.js +1 -1
- package/lib/snippets/wide-drawer/index.d.ts +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 +12 -2
- package/lib/types/common/index.d.ts +17 -1
- package/lib/types/workload/index.d.ts +2 -16
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/helpers-BjINTDe1.js +0 -9
- package/lib/chunks/source-instrument-form-context-DqNzAFUO.js +0 -5
- package/lib/containers/_drawers/edit-source-drawer/helpers.d.ts +0 -16
- package/lib/icons/compute-platform/cloud-connector-policy-icon/index.d.ts +0 -2
|
@@ -29,7 +29,7 @@ export interface WideDrawerProps {
|
|
|
29
29
|
value: string[];
|
|
30
30
|
setValue: Dispatch<SetStateAction<string[]>>;
|
|
31
31
|
};
|
|
32
|
-
search?: Pick<SearchProps, 'value' | 'onChange' | 'placeholder' | 'segment'>;
|
|
32
|
+
search?: Pick<SearchProps, 'value' | 'onChange' | 'placeholder' | 'segment' | 'width'>;
|
|
33
33
|
filters?: ReactNode;
|
|
34
34
|
errorMessage?: string;
|
|
35
35
|
isFormDirty?: boolean;
|
package/lib/snippets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as ActionType,a as Actions,R as RichTitle}from"./chunks/ui-components-
|
|
1
|
+
export{A as ActionType,a as Actions,R as RichTitle}from"./chunks/ui-components-i5FUYiX9.js";export{C as CancelModal,a as ConnectorCreatedModal,D as DURATION_OPTIONS,b as DeleteModal,c as DurationErrorsSection,d as DynamicActionFields,e as DynamicField,f as DynamicFields,I as InstrumentationPreviewSection,N as NOISY_PERCENTAGE_OPTIONS,O as OdigosLogoTextByTier,g as OperationSection,P as PERCENTAGE_OPTIONS,h as PercentageSection,i as PresetWithCustomInput,R as RuleInfoSection,j as RuleTypeSection,S as SamplingPreviewSection,k as SignalsCheckboxList,l as SourceScopeSection,U as UpgradeModal,W as WIDE_DRAWER_WIDTH,m as WideDrawer,Y as YamlSectionCard}from"./chunks/index-BesD_mee.js";export{C as ColoredSpan,a as ColoredSpanVariant}from"./chunks/helpers-9QRquBS1.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"react-dom";import"prism-react-renderer";import"zustand/middleware";import"react-error-boundary";import"virtua";
|
package/lib/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{d9 as DrawerType,be as ProgressKeys,eu as getDrawerTypeForAdd,cu as getDrawerTypeForEdit,g8 as useDarkMode,bb as useDataStreamStore,cp as useDrawerStore,ep as useFilterStore,b6 as useNotificationStore,bc as useProgressStore,ev as useSelectedStore,bd as useSetupStore}from"./chunks/ui-components-i5FUYiX9.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"react-dom";import"prism-react-renderer";import"zustand/middleware";import"react-error-boundary";import"virtua";
|
package/lib/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{gi as Provider,gj as animations,gk as opacity,gl as palettes}from"./chunks/ui-components-i5FUYiX9.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"react-dom";import"prism-react-renderer";import"zustand/middleware";import"react-error-boundary";import"virtua";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SignalType } from '../signals';
|
|
2
2
|
import { type DropDataOption } from '../../components';
|
|
3
3
|
import type { SourcesScopes } from '../sampling';
|
|
4
|
-
import { type Condition, FieldTypes, InputTypes, type PlatformType, type SVG, type YamlFieldProperties } from '../common';
|
|
4
|
+
import { type Condition, type DesiredConditionStatus, FieldTypes, InputTypes, type PlatformType, type SVG, type YamlFieldProperties } from '../common';
|
|
5
5
|
export declare enum ActionType {
|
|
6
6
|
K8sAttributes = "K8sAttributesResolver",
|
|
7
7
|
AddClusterInfo = "AddClusterInfo",
|
|
@@ -13,6 +13,11 @@ export declare enum ActionType {
|
|
|
13
13
|
DbQueryTemplatization = "DbQueryTemplatization",
|
|
14
14
|
InferDbAttributes = "InferDbAttributes"
|
|
15
15
|
}
|
|
16
|
+
export declare enum ActionCategoryTypes {
|
|
17
|
+
Enrichment = "enrichment",
|
|
18
|
+
Normalization = "normalization",
|
|
19
|
+
Privacy = "privacy"
|
|
20
|
+
}
|
|
16
21
|
export declare enum ActionKeyTypes {
|
|
17
22
|
CollectContainerAttributes = "collectContainerAttributes",
|
|
18
23
|
CollectReplicaSetAttributes = "collectReplicaSetAttributes",
|
|
@@ -49,6 +54,8 @@ export interface ActionDynamicField {
|
|
|
49
54
|
export interface ActionTypeOption {
|
|
50
55
|
type: ActionType;
|
|
51
56
|
displayName: string;
|
|
57
|
+
category?: ActionCategoryTypes | null;
|
|
58
|
+
subtitle?: string | null;
|
|
52
59
|
description: string;
|
|
53
60
|
allowedSignals: SignalType[];
|
|
54
61
|
docsUrl: string;
|
|
@@ -60,7 +67,9 @@ export interface GetActionTypesResult {
|
|
|
60
67
|
export interface ActionOption {
|
|
61
68
|
type?: ActionType;
|
|
62
69
|
icon?: SVG;
|
|
70
|
+
category?: ActionCategoryTypes;
|
|
63
71
|
label: string;
|
|
72
|
+
subtitle?: string;
|
|
64
73
|
description?: string;
|
|
65
74
|
allowedSignals?: SignalType[];
|
|
66
75
|
docsUrl?: string;
|
|
@@ -78,8 +87,9 @@ export interface Action {
|
|
|
78
87
|
signals?: SignalType[] | null;
|
|
79
88
|
fields: ActionFields;
|
|
80
89
|
conditions?: Condition[] | null;
|
|
90
|
+
statuses?: DesiredConditionStatus[] | null;
|
|
81
91
|
}
|
|
82
|
-
export type ActionFormData = Omit<Action, 'id' | 'conditions'>;
|
|
92
|
+
export type ActionFormData = Omit<Action, 'id' | 'conditions' | 'statuses'>;
|
|
83
93
|
export interface ActionFields {
|
|
84
94
|
[ActionKeyTypes.CollectContainerAttributes]?: boolean | null;
|
|
85
95
|
[ActionKeyTypes.CollectReplicaSetAttributes]?: boolean | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FC, MouseEventHandler } from 'react';
|
|
2
|
+
import type { DesiredStateProgress } from '../enum';
|
|
2
3
|
export type AnyObj = Record<string, any>;
|
|
3
4
|
export interface SVGProps {
|
|
4
5
|
/**
|
|
@@ -41,7 +42,8 @@ export declare enum Tier {
|
|
|
41
42
|
export declare enum PlatformType {
|
|
42
43
|
K8s = "k8s",
|
|
43
44
|
Vm = "vm",
|
|
44
|
-
Connector = "connector"
|
|
45
|
+
Connector = "connector",
|
|
46
|
+
AwsEcs = "aws.ecs"
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* The minimum Odigos version required to use a given feature.
|
|
@@ -194,6 +196,20 @@ export interface Condition {
|
|
|
194
196
|
reason?: string | null;
|
|
195
197
|
message?: string | null;
|
|
196
198
|
}
|
|
199
|
+
export interface DesiredConditionStatus {
|
|
200
|
+
name?: string;
|
|
201
|
+
status?: DesiredStateProgress;
|
|
202
|
+
reasonEnum?: string | null;
|
|
203
|
+
message: string;
|
|
204
|
+
actionItems?: DesiredConditionActionItem[] | null;
|
|
205
|
+
}
|
|
206
|
+
export declare enum DesiredConditionActionItemType {
|
|
207
|
+
RolloutWorkload = "RolloutWorkload"
|
|
208
|
+
}
|
|
209
|
+
export interface DesiredConditionActionItem {
|
|
210
|
+
type: DesiredConditionActionItemType | string;
|
|
211
|
+
buttonText: string;
|
|
212
|
+
}
|
|
197
213
|
export declare enum ConditionType {
|
|
198
214
|
MarkedForInstrumentation = "MarkedForInstrumentation",
|
|
199
215
|
RuntimeDetection = "RuntimeDetection",
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import type { ProgrammingLanguages } from '../common';
|
|
1
|
+
import type { DesiredConditionStatus, ProgrammingLanguages } from '../common';
|
|
2
2
|
import type { HeadSamplingOperationMatcher, TailSamplingOperationMatcher } from '../sampling';
|
|
3
|
-
import { K8sResourceKind, OtelDistroName
|
|
3
|
+
import { K8sResourceKind, OtelDistroName } from '../enum';
|
|
4
4
|
export interface WorkloadId {
|
|
5
5
|
namespace: string;
|
|
6
6
|
name: string;
|
|
7
7
|
kind: K8sResourceKind | '';
|
|
8
8
|
region?: string | null;
|
|
9
9
|
}
|
|
10
|
-
export interface DesiredConditionStatus {
|
|
11
|
-
name?: string;
|
|
12
|
-
status?: DesiredStateProgress;
|
|
13
|
-
reasonEnum?: string | null;
|
|
14
|
-
message: string;
|
|
15
|
-
actionItems?: DesiredConditionActionItem[] | null;
|
|
16
|
-
}
|
|
17
|
-
export declare enum DesiredConditionActionItemType {
|
|
18
|
-
RolloutWorkload = "RolloutWorkload"
|
|
19
|
-
}
|
|
20
|
-
export interface DesiredConditionActionItem {
|
|
21
|
-
type: DesiredConditionActionItemType | string;
|
|
22
|
-
buttonText: string;
|
|
23
|
-
}
|
|
24
10
|
export interface NamespaceWorkload {
|
|
25
11
|
id: WorkloadId;
|
|
26
12
|
markedForInstrumentation: {
|
package/lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{bn as ActionKeyTypes,bo as ActionType,
|
|
1
|
+
export{bZ as ActionCategoryTypes,bn as ActionKeyTypes,bo as ActionType,f1 as AgentInjectedReason,f2 as BooleanOperation,c5 as CloudConnectorFeatureKey,af as CodeAttributesKeyTypes,f3 as ConditionType,b9 as Crud,a9 as CustomInstrumentationsKeyTypes,f4 as DesiredConditionActionItemType,cj as DesiredStateProgress,f5 as DestinationTypes,ba as EntityTypes,bE as ExtractionDataFormat,n as FieldTypes,ab as GolangCustomProbe,ad as HeadersCollectionKeyTypes,y as InputTypes,f6 as InstallationMethod,f7 as InstallationStatus,a8 as InstrumentationRuleType,f8 as IntrumentationStatus,aa as JavaCustomProbe,f9 as JsonOperation,bC as K8sAttributesFrom,bw as K8sResourceKind,fa as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,fb as ListDirection,fc as NumberOperation,fd as OtelDistroName,fe as OtherEntityTypes,ae as PayloadCollectionKeyTypes,ac as PhpCustomProbe,P as PlatformType,ff as PodContainerLifecycleStatus,fg as PodContainerStatus,fh as PodPhase,fi as Profile,M as ProgrammingLanguages,fj as SIGNAL_KEY_TO_TYPE,fk as SIGNAL_TYPE_TO_KEY,fl as SignalKey,bt as SignalType,fm as SortDirection,S as StatusType,fn as StringOperation,b as Tier,fo as WorkloadRolloutReason,eI as WorkloadRolloutStatus}from"./chunks/ui-components-i5FUYiX9.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"react-dom";import"prism-react-renderer";import"zustand/middleware";import"react-error-boundary";import"virtua";
|
package/lib/visuals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{fp as VISUAL_ODIGOS_LOGO_HEIGHT,fq as VISUAL_ODIGOS_LOGO_WIDTH,V as VisualGreenRings,fr as VisualOdigosLogo,dj as VisualPurpleRings}from"./chunks/ui-components-i5FUYiX9.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"react-dom";import"prism-react-renderer";import"zustand/middleware";import"react-error-boundary";import"virtua";
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{Fragment as n,useMemo as o,useContext as a,createContext as s}from"react";import{T as i,t as u,b as l,P as c}from"./ui-components-Cz2E0SIN.js";import p from"styled-components";var d;(e=>{e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"})(d||(d={}));const f=[d.Action,d.Endpoint,d.Scope,d.Duration],h=p.span`
|
|
2
|
-
font-family: ${({theme:e,$isMono:t})=>t?e.font_family.secondary:e.font_family.primary};
|
|
3
|
-
font-size: ${({theme:e})=>e.v2.text.size.xxs}px;
|
|
4
|
-
line-height: 20px;
|
|
5
|
-
color: ${({theme:e,$variant:t})=>{const r=e.v2.colors;switch(t){case"action":return r.green[400];case"endpoint":return r.purple[300];case"scope":return r.yellow[400];case"duration":return r.orange[600];default:return r.white[500]}}};
|
|
6
|
-
`,m=p.span`
|
|
7
|
-
text-decoration: underline dotted;
|
|
8
|
-
text-underline-offset: 3px;
|
|
9
|
-
`,v=({parts:o})=>{const a=o.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text.length>0);return e(t,{children:a.map((o,a)=>{const s=e(h,{$variant:o.variant,$isMono:f.includes(o.variant),children:o.text});return r(n,{children:[0!==a&&e(t,{children:" "}),o.tooltipItems?.length?e(i,{text:o.tooltipItems,inline:!0,maxWidth:"300px",children:e(m,{children:s})}):s]},`${o.variant}-${a}`)})})};function g(){return{sources:[],namespaces:[],languages:[]}}function y(e){return!e||!e.sources?.length&&!e.namespaces?.length&&!e.languages?.length}function x(e){return e?{sources:e.sources?[...e.sources]:[],namespaces:e.namespaces?[...e.namespaces]:[],languages:e.languages?[...e.languages]:[]}:{sources:[],namespaces:[],languages:[]}}function k(e){return null==e||0===e}function S(e){return{name:"",notes:"",disabled:!1,ruleType:"Relevance",sourceScopes:{sources:[],namespaces:[],languages:[]},operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:"",durationPreset:"500",customDurationMs:"",keepErrors:!1,percentageMode:"costReduction"===e?"sample":"all",percentagePreset:"0",customPercentage:""}}function T(e){return y(e.sourceScopes)?null:e.sourceScopes}function A(e){return T(e)}function R(e){if("all"===e.percentageMode)return null;if("custom"===e.percentagePreset){const t=parseFloat(e.customPercentage);return isNaN(t)?null:t}return parseFloat(e.percentagePreset)}function P(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function b(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function D(e){return"all"===e.operationType?null:"httpServer"===e.operationType?b(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?b(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function M(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),percentageAtMost:R(e),operation:D(e)}}function C(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),error:e.keepErrors,durationAtLeastMs:"Duration"===e.ruleType?P(e):null,percentageAtLeast:R(e),operation:I(e)}}function $(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:T(e),percentageAtMost:R(e)??0,operation:I(e)}}function E(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:A(e),operation:D(e),percentageAtMost:R(e),notes:e.notes||null}}function L(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:A(e),error:"Error"===e.ruleType,durationAtLeastMs:"Duration"===e.ruleType?P(e):null,operation:I(e),percentageAtLeast:R(e),notes:e.notes||null}}function N(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:A(e),operation:I(e),percentageAtMost:R(e)??0,notes:e.notes||null}}const w=["5000","1000","500","100","50"],O=["50","25","10","1","0.5","0.1","0"];function H(e){if(null==e)return{percentageMode:"all",percentagePreset:"0",customPercentage:""};const t=O.find(t=>Number(t)===e);return t?{percentageMode:"sample",percentagePreset:t,customPercentage:""}:{percentageMode:"sample",percentagePreset:"custom",customPercentage:String(e)}}function K(e){if(!e)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};const t=e;return t.httpServer?{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""}:t.kafkaConsumer?{operationType:"kafkaConsumer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaConsumer.kafkaTopic||""}:t.kafkaProducer?{operationType:"kafkaProducer",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:t.kafkaProducer.kafkaTopic||""}:{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}function j(e){const t=S(),r=x(e.rule.sourceScopes),n=(e=>"highlyRelevant"!==e.category?"Relevance":e.rule.error?"Error":null!=e.rule.durationAtLeastMs?"Duration":"Relevance")(e);let o,a,s={durationPreset:"500",customDurationMs:""},i=!1;switch(e.category){case"noisy":o=(e=>{const t=e.rule.operation;return t?t.httpServer?{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""}:t.httpClient?{operationType:"httpClient",routeType:t.httpClient.templatedPathPrefix?"routePrefix":"route",route:t.httpClient.templatedPath||t.httpClient.templatedPathPrefix||"",serverAddress:t.httpClient.serverAddress||"",method:t.httpClient.method||"",kafkaTopic:""}:{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}:{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}})(e),a=k(u=e.rule.percentageAtMost)?{percentageMode:"all",percentagePreset:"0",customPercentage:""}:H(u);break;case"highlyRelevant":o=K(e.rule.operation),a=H(e.rule.percentageAtLeast),s=(e=>{if(null==e)return{durationPreset:"500",customDurationMs:""};const t=w.find(t=>Number(t)===e);return t?{durationPreset:t,customDurationMs:""}:{durationPreset:"custom",customDurationMs:String(e)}})(e.rule.durationAtLeastMs),i=e.rule.error;break;case"costReduction":o=K(e.rule.operation),a=H(e.rule.percentageAtMost)}var u;return{...t,name:e.rule.name||"",notes:e.rule.notes||"",disabled:e.rule.disabled,ruleType:n,sourceScopes:r,...o,...s,keepErrors:i,...a}}const z=s({platformType:c.K8s,tier:l.Community,version:"v0.0.0"}),F=({children:t,platformType:r,tier:n,version:a})=>{const s=o(()=>({platformType:r,tier:n,version:a}),[r,n,a]);return e(z.Provider,{value:s,children:t})},J=(e,t)=>null==e?0:"number"==typeof e?e:t?e[t]??0:0,V=(e,t,r)=>{const n=J(t,r);return!n||u(e)>=u(n)},B=e=>{const t=a(z),r=J(e,t.platformType),n=V(t.version,r),o=t.platformType===c.Vm,s=t.platformType===c.Connector,i=t.platformType===c.K8s;return{...t,isVersionSupported:n,minSupportedVersion:r,isVm:o,isConnector:s,isK8s:i,isEnterprise:t.tier===l.Onprem}};var W;(e=>{e.Noisy="noisy",e.HighlyRelevant="highly-relevant",e.CostReduction="cost-reduction"})(W||(W={}));const _=[{value:W.Noisy,label:"1. Noisy Operations",tooltip:"Rules that reduce noise from high-volume, low-value operations"},{value:W.HighlyRelevant,label:"2. Highly Relevant Operations",tooltip:"Rules that prioritize important traces for retention"},{value:W.CostReduction,label:"3. Cost Reduction",tooltip:"Rules that optimize costs by sampling less critical data"}],q={[W.Noisy]:"This is the most efficient way to sample (with Head Sampling). Prefer to use it where possible.",[W.HighlyRelevant]:'Any trace from the "Noisy Operations" category is sampled prior to checking highly relevance.',[W.CostReduction]:"Cost reduction rules use Tail Sampling to drop traces that are unlikely to be useful for debugging or monitoring."},G={[W.Noisy]:"Noisy Operations rules list",[W.HighlyRelevant]:"Highly Relevant Operations rules list",[W.CostReduction]:"Cost Reduction rules list"},Q={[W.Noisy]:"noisy",[W.HighlyRelevant]:"highlyRelevant",[W.CostReduction]:"costReduction"},U={noisy:W.Noisy,highlyRelevant:W.HighlyRelevant,costReduction:W.CostReduction};function X(e){const t=e.kind?String(e.kind).toLowerCase():"deployment";return e.namespace&&e.name?`${t} '${e.name}' in namespace '${e.namespace}'`:e.name?`${t} '${e.name}'`:e.namespace?`any service in namespace '${e.namespace}'`:""}function Y(e){return`any service in namespace '${e}'`}function Z(e){return`${e} services`}function ee(e,t="global"){const r=(e=>{if(!e)return[];const t=[];for(const r of e.sources??[]){const e=X(r);e&&t.push(e)}for(const r of e.namespaces??[])r&&t.push(Y(r));for(const r of e.languages??[])r&&t.push(Z(r));return t})(e);if(!r.length)return"source"===t?[]:[{text:" in ",variant:d.Default},{text:"any service in the cluster",variant:d.Scope}];const n=[{text:" in ",variant:d.Default}],o=r.slice(0,2),a=r.slice(2);return o.forEach((e,t)=>{t>0&&n.push({text:", ",variant:d.Default}),n.push({text:e,variant:d.Scope})}),a.length>0&&n.push({text:` + ${a.length} more`,variant:d.Default,tooltipItems:a}),n}function te(e,t){const r=(n=e).startsWith("/")?n.slice(1):n;var n;return t?`${t} /${r}`:`/${r}`}function re(e){const t=e.method;return e.route?[{text:" for server endpoint ",variant:d.Default},{text:te(e.route,t),variant:d.Endpoint}]:e.routePrefix?[{text:" for endpoints under ",variant:d.Default},{text:te(e.routePrefix,t),variant:d.Endpoint}]:[]}function ne(e,t="global"){const r=[];if(k(e.percentageAtMost)?r.push({text:"Drop all traces",variant:d.Action}):(r.push({text:`Keep at most ${e.percentageAtMost}%`,variant:d.Action}),r.push({text:" of traces",variant:d.Default})),e.operation){const t=e.operation.httpServer,n=t?(e=>{const t=e.method;return e.route?[{text:" where the root span is ",variant:d.Default},{text:te(e.route,t),variant:d.Endpoint}]:e.routePrefix?[{text:" where the root span is under ",variant:d.Default},{text:te(e.routePrefix,t),variant:d.Endpoint}]:[]})(t):[];n.length>0&&r.push(...n);const o=e.operation.httpClient,a=o?.templatedPath||o?.templatedPathPrefix,s=o?.serverAddress;if((a||s)&&0===n.length){const e=o?.method;if(r.push({text:" to ",variant:d.Default}),a){const t=te(a,e);s&&(r.push({text:"server address ",variant:d.Default}),r.push({text:s,variant:d.Endpoint}),r.push({text:" ",variant:d.Default})),r.push({text:t,variant:d.Endpoint})}else s&&(r.push({text:"server address ",variant:d.Default}),r.push({text:s,variant:d.Endpoint}))}}else r.push({text:" on ",variant:d.Default}),r.push({text:"any operation",variant:d.Endpoint});return r.push(...ee(e.sourceScopes,t)),r}function oe(e,t="global"){const r=[];if(null!=e.percentageAtLeast?(r.push({text:`Keep ${e.percentageAtLeast}%`,variant:d.Action}),r.push({text:" of traces",variant:d.Default})):r.push({text:"Keep all traces",variant:d.Action}),e.operation){const t=e.operation.httpServer;t&&r.push(...re(t))}else r.push({text:" on ",variant:d.Default}),r.push({text:"any operation",variant:d.Endpoint});return r.push(...ee(e.sourceScopes,t)),!e.error&&null!=e.durationAtLeastMs&&e.durationAtLeastMs>0&&(r.push({text:" with duration > ",variant:d.Default}),r.push({text:`${e.durationAtLeastMs}ms`,variant:d.Duration})),r}function ae(e,t="global"){const r=[];if(r.push({text:`Keep at most ${e.percentageAtMost}%`,variant:d.Action}),r.push({text:" of traces",variant:d.Default}),e.operation){const t=e.operation.httpServer,n=t?re(t):[];n.length>0&&r.push(...n);const o=e.operation.kafkaConsumer?.kafkaTopic;o&&0===n.length&&(r.push({text:" from ",variant:d.Default}),r.push({text:`topic '${o}'`,variant:d.Endpoint}))}else r.push({text:" on ",variant:d.Default}),r.push({text:"any operation",variant:d.Endpoint});return r.push(...ee(e.sourceScopes,t)),r}function se(e){return e.error?"Error":null!=e.durationAtLeastMs?"Duration":"Relevance"}function ie(e,t,r){const n=Q[t],o=[];for(const a of e)switch(t){case W.Noisy:for(const e of a.noisyOperations)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:ne(e),category:n});break;case W.HighlyRelevant:for(const e of a.highlyRelevantOperations)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:oe(e),category:n,typeBadge:se(e)});break;case W.CostReduction:for(const e of a.costReductionRules)r?.has(e.ruleId)||o.push({ruleId:e.ruleId,samplingId:a.id,name:e.name??null,disabled:e.disabled,notes:e.notes??null,summary:ae(e),category:n})}return o}function ue(e,t){switch(e){case"noisy":return ne(t);case"highlyRelevant":return oe(t);case"costReduction":return ae(t)}}function le(e,t,r,n){for(const o of e)if(o.id===t)switch(n){case"noisy":{const e=o.noisyOperations.find(e=>e.ruleId===r);if(e)return{category:"noisy",samplingId:o.id,rule:e};break}case"highlyRelevant":{const e=o.highlyRelevantOperations.find(e=>e.ruleId===r);if(e)return{category:"highlyRelevant",samplingId:o.id,rule:e};break}case"costReduction":{const e=o.costReductionRules.find(e=>e.ruleId===r);if(e)return{category:"costReduction",samplingId:o.id,rule:e};break}}return null}function ce(e,t){const r=le(e,t.samplingId,t.rule.ruleId,t.category);return r?{...r,summary:ue(r.category,r.rule)}:null}function pe(e,t){const r=le(e,t.samplingId,t.ruleId,t.category);return r?{...r,summary:ue(r.category,r.rule)}:null}function de(e,t,r){for(const n of e){const o=le(e,n.id,t,r);if(o)return{...o,summary:ue(o.category,o.rule)}}return null}function fe(e){if(!e)return null;const t=(e.sources??[]).map(e=>`${e.namespace}/${e.kind}/${e.name}`).sort(),r=(e.namespaces??[]).slice().sort(),n=(e.languages??[]).slice().sort();return t.length||r.length||n.length?[t.join("|"),r.join("|"),n.join("|")].join("::"):null}function he(e){return null==e?null:e}function me(e,t){return JSON.stringify({sourceScopes:fe(e),operation:he(t)})}function ve(e,t,r,n){return JSON.stringify({sourceScopes:fe(e),error:t??!1,durationAtLeastMs:(o=r,null==o?null:o),operation:he(n)});var o}function ge(e,t){return JSON.stringify({sourceScopes:fe(e),operation:he(t)})}function ye(e,t,r,n){switch(t){case"noisy":{const t=me(r.sourceScopes,r.operation);for(const r of e)for(const e of r.noisyOperations)if((!n||e.ruleId!==n)&&me(e.sourceScopes,e.operation)===t)return e.ruleId;return null}case"highlyRelevant":{const t=ve(r.sourceScopes,r.error,r.durationAtLeastMs,r.operation);for(const r of e)for(const e of r.highlyRelevantOperations)if((!n||e.ruleId!==n)&&ve(e.sourceScopes,e.error,e.durationAtLeastMs,e.operation)===t)return e.ruleId;return null}case"costReduction":{const t=ge(r.sourceScopes,r.operation);for(const r of e)for(const e of r.costReductionRules)if((!n||e.ruleId!==n)&&ge(e.sourceScopes,e.operation)===t)return e.ruleId;return null}}}function xe(e){return e&&e.enabled?[{text:`Keep ${e.keepPercentage??0}%`,variant:d.Action},{text:" of ",variant:d.Default},{text:"traces for kubelet health probes in the entire cluster",variant:d.Scope}]:[{text:"Auto rule is ",variant:d.Default},{text:"disabled",variant:d.Action}]}function ke(e){return!0===e.error&&y(e.sourceScopes)&&!e.operation&&(null==e.percentageAtLeast||100===e.percentageAtLeast)}function Se(e){for(const t of e){const e=t.highlyRelevantOperations.find(ke);if(e)return{rule:e,samplingId:t.id}}return null}function Te(e){return!e||e.disabled?[{text:"Auto rule is ",variant:d.Default},{text:"disabled",variant:d.Action}]:[{text:"Keep all traces",variant:d.Action},{text:" of ",variant:d.Default},{text:"error traces across the entire cluster",variant:d.Scope}]}function Ae(e){return y(e.sourceScopes)&&!e.operation}function Re(e){for(const t of e){const e=t.costReductionRules.find(Ae);if(e)return{rule:e,samplingId:t.id}}return null}function Pe(e){return!e||e.disabled?[{text:" is ",variant:d.Default},{text:"disabled",variant:d.Action}]:[{text:`Keep at most ${e.percentageAtMost}%`,variant:d.Action},{text:" of ",variant:d.Default},{text:"traces across the entire cluster",variant:d.Scope}]}export{L as A,E as B,v as C,pe as D,ue as E,Q as F,ye as G,_ as H,q as I,G as J,F as O,U as R,W as S,d as a,ee as b,V as c,k as d,ae as e,oe as f,ne as g,$ as h,y as i,C as j,M as k,Te as l,g as m,x as n,Pe as o,xe as p,S as q,J as r,de as s,Se as t,B as u,j as v,Re as w,ce as x,ie as y,N as z};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useMemo as t,useContext as r,createContext as a,useCallback as n,useState as o,useEffect as s,useRef as i}from"react";import{b6 as c,b7 as l,m as d,S as u,b8 as m,b9 as p,ba as f,P as E,b as y,bb as h,bc as S,bd as T,be as g,bf as _,bg as I,bh as A,bi as v,bj as R,bk as C,bl as N,aY as O,bm as D,bn as w,n as b,bo as P,bp as L,bq as k,br as F,bs as G,bt as U,v as M,bu as x,bv as H,ad as K,a9 as V,ab as W,aa as Y,ac as $,a8 as j,bw as q}from"./ui-components-Cz2E0SIN.js";import{i as B,n as Q,m as z,l as J,o as X,p as Z,v as ee,q as te,u as re}from"./helpers-BjINTDe1.js";import{ApolloProvider as ae,useLazyQuery as ne,useApolloClient as oe,useQuery as se}from"@apollo/client/react";import{ErrorLink as ie}from"@apollo/client/link/error";import{SetContextLink as ce}from"@apollo/client/link/context";import{getMainDefinition as le}from"@apollo/client/utilities";import{CombinedGraphQLErrors as de,ServerError as ue}from"@apollo/client/errors";import{HttpLink as me,ApolloLink as pe,ApolloClient as fe,InMemoryCache as Ee,gql as ye}from"@apollo/client";const he=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},Se=a(null),Te=()=>{const e=r(Se);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},ge=({apolloConfig:r,operations:a,context:n,children:o})=>{const s=t(()=>(e=>{const t=new me({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=new ie(({error:t})=>{de.is(t)?t.errors.some(e=>he(e.message))&&e.onAuthError?.():(ue.is(t)&&401===t.statusCode||he(t.message))&&e.onAuthError?.()}),a=new ce(async t=>{const r={...t.headers};if(e.authHeader){const t=await e.authHeader();Object.assign(r,t)}return e.csrfHeader&&Object.assign(r,e.csrfHeader()),{headers:r}}),n=[];e.additionalLinks?.length&&n.push(...e.additionalLinks),n.push(a,r,t);let o=pe.from(n);e.wsLink&&(o=pe.split(({query:e})=>{const t=le(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const s=e.defaultFetchPolicies;return new fe({link:o,cache:new Ee({typePolicies:e.cacheTypePolicies}),defaultOptions:{watchQuery:{fetchPolicy:s?.watchQuery??"cache-and-network"},query:{fetchPolicy:s?.query??"cache-first"},mutate:{fetchPolicy:s?.mutate??"network-only"}}})})(r),[r.httpUrl,r.wsLink,r.credentials,r.clientKey]),i=t(()=>({operations:a,context:n,apolloConfig:r}),[a,n,r]);return e(ae,{client:s,children:e(Se.Provider,{value:i,children:o})})},_e=Se,Ie=({connectionIds:r,children:a})=>{const n=Te(),o=t(()=>({operations:n.operations,context:{...n.context,connectionIds:r},apolloConfig:n.apolloConfig}),[n.operations,n.context,n.apolloConfig,r.join(",")]);return e(_e.Provider,{value:o,children:a})},Ae=(e,t)=>{if(e)return"string"==typeof e?e:m(e,t)},ve=e=>{const{addNotification:t}=c(),r=(r,a,n,o,s)=>t({type:r,title:a,message:n,crdType:e,target:Ae(o,e),hideFromHistory:s});return{notify:r,notifyError:(e,t,a)=>r(u.Error,e,t,a),notifySuccess:(e,t,a)=>r(u.Success,e,t,a),notifyPending:(e,t)=>r(u.Default,"Pending",e,t,!0),notifyReadonly:()=>{t({type:u.Warning,title:d.READONLY,message:l.READONLY_WARNING,hideFromHistory:!0})}}},Re=e=>{e({type:u.Warning,title:d.READONLY,message:l.READONLY_WARNING,hideFromHistory:!0})},Ce=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),Ne=(e,t)=>{if(e)return"function"==typeof e?e(t):e},Oe=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)},De=(e,t)=>e.client??t,we=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(De(t,e),r,a)}catch(e){return{error:Oe(e)}}const o=Ne(t.document,a);if(!o)return{error:"Query operation not supported in this context"};const s=t.transformVariables?t.transformVariables(r,a):r,i=De(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?Oe(e.error):void 0}}catch(e){return{error:Oe(e)}}},be=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(De(t,e),r,a)}catch(e){return{error:Oe(e)}}const n=Ne(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};const o=t.transformVariables?t.transformVariables(r,a):r,s=De(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:Oe(e)}}},Pe=async(e,t,r,a,n)=>{if(!t)return Ce("Multi fetch operation not configured");if(!r.length)return Ce("No proxy ids supplied for multi fetch");const o=De(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=Oe(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,l=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:l.length?l.join(", "):void 0}}const s=await Promise.all(r.map(async r=>{const o={...n,proxyID:r},s=await we(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,l=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:l.length?l.join(", "):void 0}},Le=ye`
|
|
2
|
-
query OdigosApiNoop {
|
|
3
|
-
__typename
|
|
4
|
-
}
|
|
5
|
-
`,ke=(e,t)=>{if(e)return"function"==typeof e?e(t):e},Fe=(e,t)=>e[t],Ge=(e,t,r)=>{if(void 0!==t)return e?.transformResult?e.transformResult(t,r):t},Ue=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},Me=(e,r,a)=>{const{operations:o,context:i}=Te(),c=Fe(o,e),l=t(()=>ke(c?.document,i),[c,i]),d=t(()=>Ue(c,r,i),[c,r,i]),u=!c||!l,m=!!c?.canRun&&!c.canRun(i),p=a?.skip||u||m,f=se(l??Le,{variables:d,skip:p,pollInterval:a?.pollInterval,fetchPolicy:a?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:a?.notifyOnNetworkStatusChange,client:c?.client}),E=t(()=>{if(!p)return Ge(c,f.data,i)},[c,i,f.data,p]);s(()=>{p||void 0===E||a?.onCompleted?.(E)},[p,E,a?.onCompleted]),s(()=>{f.error&&a?.onError?.(f.error)},[f.error,a?.onError]);const y=n(async()=>{if(u)return{data:void 0};const e=await f.refetch();return{data:Ge(c,e.data,i)}},[c,i,f,u]);return{data:E,loading:!p&&f.loading,error:f.error,refetch:y,unsupported:u}},xe=(e,r)=>{const{operations:a,context:o}=Te(),s=Fe(a,e),i=t(()=>ke(s?.document,o),[s,o]),c=!s||!i,[l,d]=ne(i??Le,{fetchPolicy:r?.fetchPolicy??"network-only",notifyOnNetworkStatusChange:r?.notifyOnNetworkStatusChange,client:s?.client});return{execute:n(async e=>{if(c)return{error:void 0};if(s?.canRun&&!s.canRun(o))return{data:void 0};const t=Ue(s,e,o),r=await l({variables:t});return r.error?{error:r.error}:{data:Ge(s,r.data,o)}},[s,o,l,c]),data:t(()=>Ge(s,d.data,o),[s,o,d.data]),loading:d.loading,error:d.error,called:d.called,unsupported:c}},He=(e,r)=>{const{operations:a,context:s}=Te(),i=oe(),c=Fe(a,e),l=t(()=>ke(c?.document,s),[c,s]),d=!c||!l,[u,m]=o({loading:!1,called:!1}),p=n(()=>m({loading:!1,called:!1}),[]);return[n(async e=>{if(d||!l)return{error:void 0};if(c?.canRun&&!c.canRun(s))return{data:void 0};const t=Ue(c,e,s),a=c?.client??i;m(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:l,variables:t}),n=Ge(c,e.data,s);if(m({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 m({data:void 0,loading:!1,error:t,called:!0}),r?.onError?.(t),{error:t}}},[c,s,i,l,d,r]),{data:u.data,loading:u.loading,error:u.error,called:u.called,unsupported:d,reset:p}]},Ke=[],Ve=(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,l=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&&l++}a(c,l),o.sources.push(...e)}return{payload:o,isEmpty:n}},We=(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}},Ye={filter:{markedForInstrumentation:!0}},$e=[],je=[],qe=[],Be=[],Qe=[],ze=e=>{if(e)return{clusters:[e],totalNamespaces:e.namespaces?.length??0,totalWorkloads:(e.namespaces??[]).reduce((e,t)=>e+(t.workloads?.length??0),0),lastUpdated:e.timestamp}},Je=[],Xe=[],Ze=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),et=[],tt=()=>{const{operations:e,context:r}=Te(),a=oe(),o=((e,t)=>{const r=oe(),{notifyError:a,notifySuccess:o,notifyPending:s,notifyReadonly:i}=ve(f.Source),{selectedStreamName:c}=h(),{setProgress:l,resetProgress:d}=S(),{setConfiguredSources:u,setConfiguredFutureApps:m}=T(),E=(e,t)=>{const{progress:r}=S.getState();e>0&&l(g.Instrumenting,{total:(r[g.Instrumenting]?.total||0)+e,current:r[g.Instrumenting]?.current||0}),t>0&&l(g.Uninstrumenting,{total:(r[g.Uninstrumenting]?.total||0)+t,current:r[g.Uninstrumenting]?.current||0})},y=n(async()=>{const{error:n}=await we(r,e.GET_WORKLOADS,Ye,t);n&&a(p.Read,n)},[r,e.GET_WORKLOADS,t,a]);return{useSources:()=>{const e=Me("GET_WORKLOADS",Ye,{fetchPolicy:"cache-first"});return{items:e.data?.workloads??$e,loading:e.loading,refetch:y}},fetchAll:y,fetchByTargets:async(n,o)=>{const s=!!o?.slim,i=n.map(e=>_(e,f.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===i.length)return;if(i.length>50)return void await y();const c=s&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:l}=await we(r,c,{ids:i.map(({namespace:e,kind:t,name:r,region:a})=>({namespace:e,kind:t,name:r,region:a||void 0}))},t);l?a(p.Read,l):await y()},fetchById:async n=>{const{data:o,error:s}=await we(r,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:n.namespace,kind:n.kind,name:n.name,...n.region?{region:n.region}:{}}]},t);if(!s)return o?.workloadsByIds?.find(e=>e.id.namespace===n.namespace&&e.id.kind===n.kind&&e.id.name===n.name&&(e.id.region??"")===(n.region??""));a(p.Read,s)},fetchLibraries:async a=>we(r,e.GET_SOURCE_LIBRARIES,a,t),fetchPeerSources:async a=>we(r,e.GET_PEER_SOURCES,{serviceName:a},t),usePeerSources:(e,t)=>Me("GET_PEER_SOURCES",e,t),persist:async(n,o)=>{if(t.isReadonly)return i();const{data:l}=await we(r,e.GET_WORKLOADS,Ye,t,"cache-first"),f=l?.workloads??$e,{payload:y,isEmpty:h}=Ve(n,f,c,E),{payload:S,isEmpty:T}=We(o,c);let _=!1;h||(_=!0,s("Persisting sources...")),T||_||s("Persisting namespaces...");const{error:I}=await be(r,e.PERSIST_SOURCES,y,t);if(I&&(d(g.Instrumenting),d(g.Uninstrumenting),a(p.Update,I)),e.PERSIST_NAMESPACES){const{error:n}=await be(r,e.PERSIST_NAMESPACES,S,t);n&&a(p.Update,n)}u({}),m({})},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 be(r,e.PERSIST_NAMESPACES,s,t);a&&n.push(a)}if(a.sources.length>0){const{error:o}=await be(r,e.PERSIST_SOURCES,a,t);o&&n.push(o)}}return n.length?{error:n.join(", ")}:void 0},update:async(n,l)=>{if(t.isReadonly)return i();s("Updating source...");const d={sourceId:n,patchSourceRequest:{...l,currentStreamName:c}},{data:u,error:m}=await be(r,e.UPDATE_SOURCE,d,t);m?a(p.Update,m,n):u?.updateK8sActualSource&&o(p.Update,`Successfully updated "${n.name}" source`,n)},restartWorkloads:async n=>{if(t.isReadonly)return i();s("Restarting sources...");const{data:c,error:l}=await be(r,e.RESTART_WORKLOADS,{sourceIds:n},t);l?a(p.Update,l):c?.restartWorkloads&&o(p.Update,`Successfully restarted ${n.length} sources`)},restartPod:async(n,c)=>{if(t.isReadonly)return i();s("Restarting pod...");const{data:l,error:d}=await be(r,e.RESTART_POD,{namespace:n,name:c},t);d?a(p.Update,d):l?.restartPod&&o(p.Update,`Successfully restarted pod ${n}/${c}`)},recoverFromRollback:async n=>{if(t.isReadonly)return i();s("Recovering from rollback...");const{data:c,error:l}=await be(r,e.RECOVER_FROM_ROLLBACK,{sourceId:n},t);l?a(p.Update,l,n):c?.recoverFromRollbackForWorkload&&o(p.Update,"Successfully triggered recovery from rollback")}}})(e,r),i=((e,t)=>{const r=oe(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=ve(f.Destination),{selectedStreamName:s}=h(),i=async()=>{const{error:n}=await we(r,e.GET_DESTINATIONS,void 0,t);n&&a(p.Read,n)};return{useDestinations:()=>{const e=Me("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.destinations??e.data?.destinations??Xe,loading:e.loading,refetch:i}},useDestinationCategories:()=>{const e=Me("GET_DESTINATION_CATEGORIES",void 0);return{data:e.data,loading:e.loading}},usePotentialDestinations:()=>{const e=Me("GET_POTENTIAL_DESTINATIONS",void 0);return{data:e.data,loading:e.loading}},fetchAll:i,testConnection:async a=>{const{data:n}=await be(r,e.TEST_DESTINATION_CONNECTION,{destination:Ze(a,s)},t);return n},create:async c=>{if(t.isReadonly)return o();const{error:l}=await be(r,e.CREATE_DESTINATION,{destination:Ze(c,s)},t);l?a(p.Create,l):(n(p.Create,`Successfully created "${c.type}" destination`),await i())},update:async(c,l)=>{if(t.isReadonly)return o();const{data:d,error:u}=await be(r,e.UPDATE_DESTINATION,{id:c,destination:Ze(l,s)},t);u?a(p.Update,u,c):d?.updateDestination&&(n(p.Update,`Successfully updated "${l.type}" destination`,c),await i())},remove:async c=>{if(t.isReadonly)return o();const{data:l}=await we(r,e.GET_DESTINATIONS,void 0,t,"cache-first"),d=l?.computePlatform?.destinations??l?.destinations??Xe,u=d.find(e=>A(e)===c)?.destinationType?.type,{error:m}=await be(r,e.DELETE_DESTINATION,{id:c,currentStreamName:s},t);m?a(p.Delete,m,c):(n(p.Delete,`Successfully deleted "${u??c}" destination`,c),await i())}}})(e,r),l=((e,r)=>{const a=oe(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=ve(f.Action),i=async()=>{const{error:t}=await we(a,e.GET_ACTIONS,void 0,r);t&&n(p.Read,t)};return{useActions:()=>{const e=Me("GET_ACTIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.actions??e.data?.actions??je,loading:e.loading,refetch:i}},useActionTypes:()=>{const e=Me("GET_ACTION_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>I(e.data)||qe,[e.data]),loading:e.loading}},fetchAll:i,create:async t=>{if(r.isReadonly)return s();if(!e.CREATE_ACTION)return;const{error:c}=await be(a,e.CREATE_ACTION,{action:t},r);c?n(p.Create,c):(o(p.Create,`Successfully created "${t.type}" action`),await i())},update:async(t,c)=>{if(r.isReadonly)return s();if(!e.UPDATE_ACTION)return;const{error:l}=await be(a,e.UPDATE_ACTION,{id:t,action:c},r);l?n(p.Update,l,t):(o(p.Update,`Successfully updated "${c.type}" action`,t),await i())},remove:async(t,c)=>{if(r.isReadonly)return s();if(!e.DELETE_ACTION)return;const{error:l}=await be(a,e.DELETE_ACTION,{id:t,actionType:c},r);l?n(p.Delete,l,t):(o(p.Delete,`Successfully deleted "${c}" action`,t),await i())}}})(e,r),d=((e,r)=>{const a=oe(),{notifyError:n,notifySuccess:o,notifyReadonly:s}=ve(f.InstrumentationRule),i=async()=>{const{error:t}=await we(a,e.GET_INSTRUMENTATION_RULES,void 0,r);t&&n(p.Read,t)};return{useRules:()=>{const e=Me("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first"});return{items:t(()=>(e.data?.computePlatform?.instrumentationRules??e.data?.instrumentationRules??[]).map(C),[e.data]),loading:e.loading,refetch:i}},useRuleTypes:()=>{const e=Me("GET_INSTRUMENTATION_RULE_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>R(e.data)||et,[e.data]),loading:e.loading}},fetchAll:i,create:async(t,c)=>{if(r.isReadonly)return s();if(!e.CREATE_INSTRUMENTATION_RULE)return;const{error:l}=await be(a,e.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:v(t)},r);l?n(p.Create,l):(o(p.Create,`Successfully created${c?` "${c}"`:""} rule`),await i())},update:async(t,c,l)=>{if(r.isReadonly)return s();if(!e.UPDATE_INSTRUMENTATION_RULE)return;const{error:d}=await be(a,e.UPDATE_INSTRUMENTATION_RULE,{ruleId:t,instrumentationRule:v(c)},r);d?n(p.Update,d,t):(o(p.Update,`Successfully updated${l?` "${l}"`:""} rule`,t),await i())},remove:async(t,c)=>{if(r.isReadonly)return s();if(!e.DELETE_INSTRUMENTATION_RULE)return;const{error:l}=await be(a,e.DELETE_INSTRUMENTATION_RULE,{ruleId:t},r);l?n(p.Delete,l,t):(o(p.Delete,`Successfully deleted${c?` "${c}"`:""} rule`,t),await i())}}})(e,r),m=((e,t)=>{const r=oe(),{addNotification:a}=c(),{setDataStreams:n}=h(),o=(e,t)=>a({type:u.Error,title:e,message:t}),i=async()=>{const{data:a,error:s}=await we(r,e.GET_DATA_STREAMS,void 0,t);if(s)o(p.Read,s);else if(a){const e=a.computePlatform?.dataStreams??a.dataStreams??[];n(e)}},l=e.CREATE_DATA_STREAM?async n=>{if(t.isReadonly)return Re(a);const{error:s}=await be(r,e.CREATE_DATA_STREAM,{stream:n},t);s?o(p.Create,s):await i()}:void 0;return{useDataStreams:()=>{const e=Me("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first"}),t=e.data?.computePlatform?.dataStreams??e.data?.dataStreams??Je;return s(()=>{n(t)},[JSON.stringify(t.map(e=>e.name))]),{items:t,loading:e.loading,refetch:i}},fetchAll:i,create:l,update:async(n,s)=>{if(t.isReadonly)return Re(a);const{error:c}=await be(r,e.UPDATE_DATA_STREAM,{id:n,dataStream:s},t);c?o(p.Update,c):await i()},remove:async n=>{if(t.isReadonly)return Re(a);const{error:s}=await be(r,e.DELETE_DATA_STREAM,{id:n},t);s?o(p.Delete,s):await i()}}})(e,r),N=((e,t)=>{const r=oe(),{notifyError:a,notifyReadonly:n}=ve(f.Namespace),o=async()=>{const n=await we(r,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return n.error&&a(p.Read,n.error),n};return{useNamespaces:()=>{const e=Me("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-and-network"});return{items:e.data?.namespaces??Qe,loading:e.loading,refetch:o}},fetchAll:o,persist:async o=>{if(t.isReadonly)return n();const{error:s}=await be(r,e.PERSIST_NAMESPACES,o,t);return s&&a(p.Update,s),s?{error:s}:void 0}}})(e,r),O=((e,t)=>{const r=oe(),{notifyError:a}=ve(f.Source);return{fetch:async n=>{const o=await we(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(p.Read,o.error),o}}})(e,r),D=((e,t)=>{const r=oe(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=ve(f.Source);return{useEffectiveConfig:(e,t)=>Me("GET_EFFECTIVE_CONFIG",e,t),useConfigYamls:e=>Me("GET_CONFIG_YAMLS",void 0,e),getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?we(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 be(r,e.UPDATE_REMOTE_CONFIG,{formData:n,connectionIds:s},t);return i&&a(p.Update,i),i?{error:i}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>we(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 be(r,e.UPDATE_LOCAL_UI_CONFIG,{config:s},t);return i?a(p.Update,i):n(p.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 be(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return s?a(p.Update,s):n(p.Update,"Local UI configuration reset to factory defaults"),s?{error:s}:void 0}:void 0}})(e,r),w=((e,t)=>{const r=oe(),{apolloConfig:a}=Te();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>we(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>we(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const s=await we(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(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){}})(a),s}:void 0}})(e,r),b=((e,t)=>{const r=oe(),{notifyError:a,notifyReadonly:n}=ve(f.Source),o=async()=>{e.GET_TOKENS&&await we(r,e.GET_TOKENS,void 0,t)};return{useTokens:()=>{const e=Me("GET_TOKENS",void 0,{fetchPolicy:"cache-first"});return{items:e.data??Ke,loading:e.loading,refetch:o}},updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:s}=await be(r,e.UPDATE_TOKEN,{token:o},t);return s&&a(p.Update,s),s?{error:s}:void 0}:void 0}})(e,r),P=((e,t)=>{const r=oe();return{useMetrics:e=>Me("GET_METRICS",void 0,e),fetch:async()=>we(r,e.GET_METRICS,void 0,t)}})(e,r),L=((e,t)=>{const r=oe();return{useServiceMap:e=>Me("GET_SERVICE_MAP",void 0,e),fetch:e.GET_SERVICE_MAP?async()=>we(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(e,r),k=((e,t)=>{const r=oe();return{useSlots:e=>Me("GET_PROFILING_SLOTS",void 0,e),useSourceProfiling:(e,t)=>Me("GET_SOURCE_PROFILING",e,t),fetchSlots:e.GET_PROFILING_SLOTS?async()=>we(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>we(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>be(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0}})(e,r),F=((e,t)=>{const r=oe();return{useGatewayInfo:e=>Me("GET_GATEWAY_INFO",void 0,e),useGatewayPods:e=>Me("GET_GATEWAY_PODS",void 0,e),useNodeCollectorInfo:e=>Me("GET_NODE_COLLECTOR_INFO",void 0,e),useNodeCollectorPods:e=>Me("GET_NODE_COLLECTOR_PODS",void 0,e),usePodInfo:(e,t)=>Me("GET_COLLECTOR_POD_INFO",e,t),getGatewayInfo:e.GET_GATEWAY_INFO?async()=>we(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>we(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>we(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>we(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>we(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(e,r),G=((e,t)=>{const r=oe(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=ve(f.SamplingRule),s=async()=>{e.GET_SAMPLING_RULES&&await we(r,e.GET_SAMPLING_RULES,void 0,t)},i=(e,i)=>e?async c=>{if(t.isReadonly)return o();const{error:l}=await be(r,e,c,t);return l?a(i,l):(n(p.Create,"Successfully created sampling rule"),await s()),l?{error:l}:void 0}:void 0,c=(e,i)=>e?async(c,l)=>{if(t.isReadonly)return o();const{error:d}=await be(r,e,{samplingId:l.samplingId,ruleId:c,rule:l.rule},t);return d?a(i,d):(n(p.Update,"Successfully updated sampling rule"),await s()),d?{error:d}:void 0}:void 0,l=e=>e?async(i,c)=>{if(t.isReadonly)return o();const{error:l}=await be(r,e,{samplingId:c,ruleId:i},t);return l?a(p.Delete,l):(n(p.Delete,"Successfully deleted sampling rule"),await s()),l?{error:l}:void 0}:void 0;return{useSamplingRules:()=>{const e=Me("GET_SAMPLING_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.samplingRules??e.data?.samplingRules??Be,k8sHealthProbesConfig:e.data?.computePlatform?.k8sHealthProbesConfig??e.data?.k8sHealthProbesConfig??null,loading:e.loading,refetch:s}},fetchAll:e.GET_SAMPLING_RULES?async()=>we(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:i(e.CREATE_NOISY_OPERATION_RULE,p.Create),updateNoisy:c(e.UPDATE_NOISY_OPERATION_RULE,p.Update),deleteNoisy:l(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:i(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,p.Create),updateHighlyRelevant:c(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,p.Update),deleteHighlyRelevant:l(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:i(e.CREATE_COST_REDUCTION_RULE,p.Create),updateCostReduction:c(e.UPDATE_COST_REDUCTION_RULE,p.Update),deleteCostReduction:l(e.DELETE_COST_REDUCTION_RULE),updateK8sHealthProbesConfig:e.UPDATE_LOCAL_UI_SAMPLING_CONFIG?async n=>{if(t.isReadonly)return o();const{error:i}=await be(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:{k8sHealthProbesSampling:n}},t);return i?a(p.Update,i):await s(),i?{error:i}:void 0}:void 0}})(e,r),U=((e,r)=>{const a=oe();return{useSnapshots:()=>{const e=r.proxyID,a=!!e,o=Me("GET_ALL_CLUSTER_SNAPSHOTS",void 0,{fetchPolicy:"cache-and-network",skip:a}),s=Me("GET_CLUSTER_SNAPSHOT",e?{clusterId:e}:void 0,{fetchPolicy:"cache-and-network",skip:!a}),i=t(()=>a?ze(s.data):o.data,[a,s.data,o.data]),c=n(async()=>{if(!a)return o.refetch();const{data:e}=await s.refetch();return{data:ze(e)}},[a,o.refetch,s.refetch]);return{data:i,loading:a?s.loading:o.loading,unsupported:a?s.unsupported:o.unsupported,refetch:c}},getAllClusterSnapshots:e.GET_ALL_CLUSTER_SNAPSHOTS?async()=>we(a,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,r):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async t=>we(a,e.GET_CLUSTER_SNAPSHOT,{clusterId:t},r):void 0}})(e,r);return{sourcesApi:o,destinationsApi:i,actionsApi:l,instrumentationRulesApi:d,dataStreamsApi:m,namespacesApi:N,k8sManifestApi:O,configApi:D,describeApi:w,tokensApi:b,metricsApi:P,serviceMapApi:L,profilingApi:k,collectorsApi:F,samplingApi:G,snapshotsApi:U,capabilities:t(()=>((e,t)=>{const r=t.platformType===E.Vm,a=t.platformType===E.Connector,n=t.platformType===E.K8s,o=t.tier===y.Onprem,s=!r,i=n,c=n;return{canBulkPersistSources:s&&!!e.PERSIST_SOURCES,canInstrumentNamespaces:c&&!!e.PERSIST_NAMESPACES,canFetchSnapshots:i&&!!e.GET_ALL_CLUSTER_SNAPSHOTS,canRecoverFromRollback:i&&!!e.RECOVER_FROM_ROLLBACK,canRestartWorkloads:i&&!!e.RESTART_WORKLOADS,canFetchPeerSources:!!e.GET_PEER_SOURCES,canFetchSourceLibraries:!!e.GET_SOURCE_LIBRARIES,canFetchK8sManifest:i&&!!e.GET_K8S_MANIFEST,canCreateDestination:!!e.CREATE_DESTINATION,canTestConnection:s&&!!e.TEST_DESTINATION_CONNECTION,canFetchDestinationCategories:!!e.GET_DESTINATION_CATEGORIES,canFetchPotentialDestinations:s&&!!e.GET_POTENTIAL_DESTINATIONS,canCreateAction:!!e.CREATE_ACTION,canFetchActionTypes:!!e.GET_ACTION_TYPES,canCreateInstrumentationRule:!!e.CREATE_INSTRUMENTATION_RULE,canFetchInstrumentationRuleTypes:!!e.GET_INSTRUMENTATION_RULE_TYPES,canApplyEffectiveConfig:s&&!!e.UPDATE_REMOTE_CONFIG&&!!e.GET_EFFECTIVE_CONFIG,canFetchEffectiveConfig:!!e.GET_EFFECTIVE_CONFIG,canFetchConfigYamls:!!e.GET_CONFIG_YAMLS,canFetchProfiling:i&&!!e.GET_PROFILING_SLOTS,canFetchCollectorInfo:i&&!!e.GET_GATEWAY_INFO,canManageSamplingRules:!!e.GET_SAMPLING_RULES,isEnterprise:o,isVm:r,isConnector:a,isK8s:n}})(e,r),[e,r]),resetCache:n(async()=>{await a.cache.reset()},[a])}},rt={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},at=a(null),nt=(e,t)=>{const r=O(e??{}),a=r[w.ExtractAttribute];a?.extractions?.length&&(a.extractions=a.extractions.map(e=>{const t=e;return{...t,method:t.method||(t.regex?.trim()?"regex":"preset")}}));const n=new Set((t?.fields||[]).filter(e=>e.componentType===b.SourceScopes).map(e=>e.name));return void 0!==r[w.Scopes]&&n.add(w.Scopes),n.forEach(e=>{const t=e;r[t]=Q(r[t])}),r},ot="All row fields are required",st="At least one row is required",it=(e,t)=>!!e&&t.every(t=>{const r=e[t];return Array.isArray(r)?r.length>0:!("string"==typeof(a=r)?!a.trim():L(a));var a}),ct=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),d=N(rt),u=n(e=>{d.resetFormData(),d.handleErrorChange(void 0,void 0,{}),e?.type&&d.handleFormChange("type",e.type),c(e)},[]),m=n((e,t)=>{const r=t??(a=e.type,D.find(e=>e.type===a)??null);var a;d.resetFormData((({type:e,name:t,notes:r,disabled:a,signals:n,fields:o},s)=>({type:e,name:t||"",notes:r||"",disabled:!!a,signals:n??[],fields:nt(o,s)}))(e,r)),d.handleErrorChange(void 0,void 0,{}),c(r)},[]),p=n(()=>{if(!i)return{errorMessage:"No action type selected",preparedFormData:O(rt)};const e=((e,t)=>{const r=O(e),a=r.fields||{},n=a[w.UrlTemplatizationRulesGroups];n?.length&&(a[w.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const o=a[w.AttributeNamesToDelete];o?.length&&(a[w.AttributeNamesToDelete]=o.filter(e=>!!e?.trim()));const s=a[w.Renames];if(s){const e=Array.isArray(s)?s.map(e=>[e?.key??"",e?.value??""]):Object.entries(s);a[w.Renames]=Object.fromEntries(e.filter(([e,t])=>!!e?.trim()&&!!t?.trim()))}const i=new Set((t?.fields||[]).filter(e=>e.componentType===b.SourceScopes).map(e=>e.name));void 0!==a[w.Scopes]&&i.add(w.Scopes),i.forEach(e=>{const t=a[e];void 0!==t&&(a[e]=B(t)?null:t)});const c=a[w.ExtractAttribute];return c?.extractions?.length&&(a[w.ExtractAttribute]={extractions:c.extractions.map(e=>{const t=e,r=t.method||(t.regex?.trim()?"regex":"preset"),a=t.targetAttributeName?.trim()||"";if("regex"===r)return{targetAttributeName:a,lookupKey:"",regex:t.regex?.trim()||""};const n={targetAttributeName:a,lookupKey:t.lookupKey?.trim()||"",regex:""};return t.dataFormat&&(n.dataFormat=t.dataFormat),n}).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),r.fields=a,r})(d.formData,i),t={};return L(e.signals)&&(t.signals=l.FIELD_IS_REQUIRED),i.type&&Object.assign(t,((e,t,r)=>{const a={},n=t.fields||{},o=r.fields||{};switch(e){case P.K8sAttributes:{const e=!(n[w.CollectContainerAttributes]||n[w.CollectReplicaSetAttributes]||n[w.CollectWorkloadId]||n[w.CollectClusterId]),t=!n[w.LabelsAttributes]?.length,r=!n[w.AnnotationsAttributes]?.length;e&&t&&r&&(a[w.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const o=n[w.LabelsAttributes];o?.some(e=>!it(e,["labelKey","attributeKey","fromSources"]))&&(a[w.LabelsAttributes]=ot);const s=n[w.AnnotationsAttributes];s?.some(e=>!it(e,["annotationKey","attributeKey","fromSources"]))&&(a[w.AnnotationsAttributes]=ot);break}case P.AddClusterInfo:{const e=n[w.ClusterAttributes];e?.length?e.some(e=>!it(e,["attributeName","attributeStringValue"]))&&(a[w.ClusterAttributes]=ot):a[w.ClusterAttributes]=st;break}case P.DeleteAttributes:{const e=o[w.AttributeNamesToDelete]||[],t=n[w.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(a[w.AttributeNamesToDelete]=ot):a[w.AttributeNamesToDelete]=e.length?ot:st;break}case P.RenameAttributes:{const e=Object.entries(o[w.Renames]||{}),t=Object.entries(n[w.Renames]||{}),r=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?r&&(a[w.Renames]=ot):a[w.Renames]=e.length?ot:st;break}case P.PiiMasking:{const e=n[w.PiiCategories];e?.length||(a[w.PiiCategories]="Select at least one attribute to mask");break}case P.URLTemplatization:{const e=n[w.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(a[w.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case P.ExtractAttribute:{const e=n[w.ExtractAttribute]?.extractions||[],t=o[w.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),r=!!e.lookupKey?.trim();return r!==!!e.dataFormat||t===r}))a[w.ExtractAttribute]="Each row needs a target attribute name and either a regex or both lookup key and data format";else{const t=new Set;e.some(e=>{const r=e.targetAttributeName?.trim()||"";return!!t.has(r)||(t.add(r),!1)})&&(a[w.ExtractAttribute]="Each new span attribute name must be unique")}else a[w.ExtractAttribute]=t.length?ot:st;break}}return a})(i.type,e,d.formData)),d.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[d,i]),f=t(()=>({selectedOption:i,onSelectOption:u,loadAction:m,genericForm:d,validateFormData:p,sourceOptions:a,namespaceOptions:s}),[i,u,m,d,p,a,s]);return e(at.Provider,{value:f,children:r})},lt=()=>{const e=r(at);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},dt={provider:"",permission:"",customCapabilities:{},authMethod:"",setupMethod:"",awsAccountId:"",credentials:{},accessToken:"",secretId:"",name:""},ut=a(null),mt=({children:r,providers:a=[]})=>{const o=N(dt),s=n(()=>{const e=O(o.formData);return e.provider?e.permission?{errorMessage:void 0,preparedFormData:e}:{errorMessage:"Please select a permission level",preparedFormData:e}:{errorMessage:"Please select a provider",preparedFormData:e}},[o]),i=t(()=>({providers:a,genericForm:o,validateFormData:s}),[a,o,s]);return e(ut.Provider,{value:i,children:r})},pt=()=>{const e=r(ut);if(!e)throw new Error("useCloudConnectorFormContext must be used within a CloudConnectorFormContextProvider");return e},ft={name:""},Et=a(null),yt=({children:r,defaultExcludeName:a=""})=>{const{dataStreams:s}=h(),[c,d]=o(void 0),[u,m]=o(a),[p,f]=o(void 0),[E,y]=o(null),S=i(null),T=N(ft),g=n(e=>{T.resetFormData({name:e}),T.handleErrorChange(void 0,void 0,{}),d(void 0),m(e),f(e),y(null),S.current=null},[]),_=n(()=>{const e=O(T.formData),t=(e=>{const t={};return e.name?k(e.name)||(t.name=l.ILLEGAL_K8S_LABEL):t.name=l.FIELD_IS_REQUIRED,t})(e);T.handleErrorChange(void 0,void 0,t);const r=Object.keys(t).length>0?l.REQUIRED_FIELDS:void 0;return d(r),{errorMessage:r,preparedFormData:e}},[T]),I=n(async e=>{const{errorMessage:t,preparedFormData:r}=_();if(t)return;const a=s.find(e=>e.name===r.name&&e.name!==u);if(a)return S.current=e,void y({preparedFormData:r,existingName:a.name,editingName:p});await e(r)},[_,s,u,p]),A=n(async()=>{const e=S.current,t=E?.preparedFormData;S.current=null,y(null),e&&t&&await e(t)},[E]),v=n(()=>{S.current=null,y(null)},[]),R=t(()=>({genericForm:T,loadDataStream:g,editingName:p,validateFormData:_,requestSubmit:I,pendingMerge:E,confirmMerge:A,cancelMerge:v,errorMessage:c,excludeName:u,setExcludeName:m}),[T,g,p,_,I,E,A,v,c,u]);return e(Et.Provider,{value:R,children:r})},ht=()=>{const e=r(Et);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},St={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},Tt={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:O(St)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},gt=a(Tt),_t=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:r,componentProperties:a,displayName:n,initialValue:o,renderCondition:s}=e,i=r===b.Dropdown,c=M(a,{});return{componentType:r,renderCondition:s,name:t,title:n,value:o,placeholder:c.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(c.values)?c.values.map(e=>({id:e,label:e})):void 0,...c}}),It=({children:r})=>{const{selectedStreamName:a}=h(),{items:i}=tt().destinationsApi.useDestinations(),[c,d]=o(null),[u,m]=o(Tt.unsavedDestinations),p=t(()=>"number"==typeof c?.unsavedIdx?u[c.unsavedIdx]:void 0,[c,u]),f=n((e,t)=>{c&&(m(t=>[...t,{...e,option:c.option}]),d(t?e=>e?{...e,listType:F.UNSAVED,unsavedIdx:u.length}:null:null))},[c,u.length]),E=n((e,t,r)=>{c&&(m(r=>r.map((r,a)=>a===e?{...r,...t,option:c.option}:r)),d(r?e=>e?{...e,listType:F.UNSAVED}:null:null))},[c]),y=n(e=>{m(t=>t.filter((t,r)=>r!==e)),d(null)},[]),S=N({...St,currentStreamName:a});s(()=>{if(!c)return;if(p)return void S.resetFormData({...p.formData});if(c.listType===F.EXISTS&&c.option.id){const e=i.find(e=>e.id===c.option.id);if(e)return void S.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:a,disabled:!!e.disabled,exportedSignals:{logs:!!e.exportedSignals?.logs,metrics:!!e.exportedSignals?.metrics,traces:!!e.exportedSignals?.traces,profiles:!!e.exportedSignals?.profiles},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})}const e=G(c.option.supportedSignals);S.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:a,disabled:!1,exportedSignals:{logs:e.includes(U.Logs),metrics:e.includes(U.Metrics),traces:e.includes(U.Traces),profiles:e.includes(U.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,p]);const T=n(e=>{S.resetFormData(),S.handleErrorChange(void 0,void 0,{}),d(e?{...e,dynamicFields:e.option?.fields?_t(e.option.fields):[]}:null)},[]),g=n((e,t)=>{let r;for(const a of t){const t=a.items.find(t=>t.type===e.destinationType.type);if(t){r=t;break}}const a=M(e.fields,{}),n={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:r?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:r?r.fields.map(e=>({...e,initialValue:a[e.name]??e.initialValue})):[]},o=_t(n.fields);d({listType:F.EXISTS,option:n,dynamicFields:o})},[]),_=n(()=>{const e=O(S.formData),t={};return c?.dynamicFields.forEach(({name:r,required:a})=>{if(a){const a=e.fields.find(e=>e.key===r)?.value;L(a)&&(t[r]=l.FIELD_IS_REQUIRED)}}),x(e.exportedSignals).length||(t.exportedSignals=l.FIELD_IS_REQUIRED),S.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[S,c]);return e(gt.Provider,{value:{activeForm:c,onChangeActiveForm:T,loadDestination:g,genericForm:S,validateFormData:_,unsavedDestinations:u,thisUnsavedDestination:p,setUnsavedDestinations:m,addUnsavedDestination:f,updateUnsavedDestination:E,deleteUnsavedDestination:y},children:r})},At=()=>r(gt),vt={disabled:!1,ruleName:"",notes:"",sourceScopes:z(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null,networkMetrics:null},Rt=a(null),Ct=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),l=N(vt),d=n(e=>{l.resetFormData(),l.handleErrorChange(void 0,void 0,{}),c(e)},[]),u=n((e,t)=>{var r;l.resetFormData((({ruleName:e,notes:t,disabled:r,sourceScopes:a,instrumentationLibraries:n,payloadCollection:o,codeAttributes:s,headersCollection:i,customInstrumentations:c,networkMetrics:l})=>({ruleName:e||"",notes:t||"",disabled:!!r,sourceScopes:Q(a),workloads:null,instrumentationLibraries:n??null,payloadCollection:o??null,codeAttributes:s??null,headersCollection:i??null,customInstrumentations:c??null,networkMetrics:l??null}))(e)),l.handleErrorChange(void 0,void 0,{}),c(t??(r=e.type,H.find(e=>e.type===r)??null))},[]),m=n(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:O(vt)};const e=(e=>{const t=O(e),r={...t,sourceScopes:B(t.sourceScopes)?null:t.sourceScopes,workloads:null};return r.headersCollection?.[K.HeaderKeys]?.length&&(r.headersCollection[K.HeaderKeys]=r.headersCollection[K.HeaderKeys].map(e=>e.trim()).filter(e=>e)),r.customInstrumentations?.[V.Golang]?.length&&(r.customInstrumentations[V.Golang]=r.customInstrumentations[V.Golang].map(e=>new W(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>{return t=e,!!(t.packageName?.trim()||t.functionName?.trim()||t.receiverName?.trim()||t.receiverMethodName?.trim());var t})),r.customInstrumentations?.[V.Java]?.length&&(r.customInstrumentations[V.Java]=r.customInstrumentations[V.Java].map(e=>new Y(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),r.customInstrumentations?.[V.Php]?.length&&(r.customInstrumentations[V.Php]=r.customInstrumentations[V.Php].map(e=>new $(e.className,e.functionName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.functionName?.trim());var t})),r})(l.formData),t=((e,t)=>{const r={};switch(e){case j.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(r.codeAttributes="Code attributes are required");break;case j.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(r.payloadCollection="Payload collection are required");break;case j.HeadersCollection:t.headersCollection?.[K.HeaderKeys]?.length||(r.headersCollection="Header keys are required");break;case j.CustomInstrumentation:{const e=t.customInstrumentations?.[V.Golang]||[],a=t.customInstrumentations?.[V.Java]||[],n=t.customInstrumentations?.[V.Php]||[];if(!e.length&&!a.length&&!n.length){r.customInstrumentations="Custom instrumentation are required";break}const o=e.findIndex(e=>!new W(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==o){r.customInstrumentations=`Golang probe #${o+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=a.findIndex(e=>!new Y(e.className,e.methodName).Verify());if(-1!==s){r.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}const i=n.findIndex(e=>!new $(e.className,e.functionName).Verify());if(-1!==i){r.customInstrumentations=`PHP probe #${i+1} is invalid: function name is required`;break}break}}return r})(i.type,e);return l.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[l,i]),p=t(()=>({selectedOption:i,onSelectOption:d,loadRule:u,genericForm:l,validateFormData:m,sourceOptions:a,namespaceOptions:s}),[i,d,u,l,m,a,s]);return e(Rt.Provider,{value:p,children:r})},Nt=()=>{const e=r(Rt);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var Ot;(e=>{e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"})(Ot||(Ot={}));const Dt=a(null),wt=["50","25","10","1"];function bt(e){const t=String(e);return wt.includes(t)?t:"custom"}const Pt=({category:r,sourceOptions:a=[],namespaceOptions:i=[],children:c})=>{const{formData:l,handleFormChange:d,resetFormData:u}=N(te(r)),[m,p]=o(null);s(()=>{u(te(r)),p(null)},[r]);const f=n(e=>{p(null),d(void 0,void 0,{...l,...e})},[l,d]),E=n(()=>{u(te(r)),p(null)},[r,u]),y=t(()=>({formType:Ot.Create,category:r,formData:l,handleChange:f,resetForm:E,duplicateWarning:m,setDuplicateWarning:p,sourceOptions:a,namespaceOptions:i}),[r,l,f,E,m,a,i]);return e(Dt.Provider,{value:y,children:c})},Lt=({data:r,defaultEditMode:a,sourceOptions:c=[],namespaceOptions:l=[],children:d})=>{const[u,m]=o(!1),{formData:p,handleFormChange:f,resetFormData:E}=N(void 0),y=i(null),[h,S]=o(null);s(()=>{r!==y.current&&(y.current=r,r&&a?(E(ee(r)),S(null),m(!0)):(m(!1),S(null)))},[r,a]);const T=n(e=>{S(null),f(void 0,void 0,{...p,...e})},[p,f]),g=n(()=>{r&&(E(ee(r)),S(null),m(!0))},[r,E]),_=n(()=>{m(!1),S(null)},[]),I=t(()=>({formType:Ot.View,data:r,isEditing:u,formData:p,handleChange:T,handleEdit:g,handleCancelEdit:_,duplicateWarning:h,setDuplicateWarning:S,sourceOptions:c,namespaceOptions:l}),[r,u,p,T,g,_,h,c,l]);return e(Dt.Provider,{value:I,children:d})};function kt(e){const[r,a]=o(()=>0===e?"all":"sample"),[n,i]=o(()=>bt(e)),[c,l]=o(()=>"custom"===bt(e)?String(e):"");s(()=>{a(0===e?"all":"sample");const t=bt(e);i(t),l("custom"===t?String(e):"")},[e]);const d=t(()=>"all"===r?0:"custom"===n?Number(c)||0:Number(n),[r,n,c]);return{percentageMode:r,setPercentageMode:a,percentagePreset:n,setPercentagePreset:i,customPercentage:c,setCustomPercentage:l,resolvedPercentage:d}}const Ft=({enabled:r,keepPercentage:a,children:n})=>{const[i,c]=o(r),l=kt(a);s(()=>{c(r)},[r]);const d=t(()=>Z({enabled:i,keepPercentage:l.resolvedPercentage}),[i,l.resolvedPercentage]),u=t(()=>({formType:Ot.EditAutoNoisy,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Dt.Provider,{value:u,children:n})},Gt=({enabled:r,dropPercentage:a,children:n})=>{const[i,c]=o(r),l=kt(a);s(()=>{c(r)},[r]);const d=t(()=>X(i?{disabled:!1,percentageAtMost:l.resolvedPercentage}:null),[i,l.resolvedPercentage]),u=t(()=>({formType:Ot.EditAutoCostReduction,localEnabled:i,setLocalEnabled:c,...l,summary:d}),[i,l,d]);return e(Dt.Provider,{value:u,children:n})},Ut=({enabled:r,children:a})=>{const[n,i]=o(r);s(()=>{i(r)},[r]);const c=t(()=>J(n?{disabled:!1}:null),[n]),l=t(()=>({formType:Ot.EditAutoHighlyRelevant,localEnabled:n,setLocalEnabled:i,summary:c}),[n,c]);return e(Dt.Provider,{value:l,children:a})},Mt=t=>{switch(t.formType){case Ot.Create:return e(Pt,{...t});case Ot.View:return e(Lt,{...t});case Ot.EditAutoNoisy:return e(Ft,{...t});case Ot.EditAutoCostReduction:return e(Gt,{...t});case Ot.EditAutoHighlyRelevant:return e(Ut,{...t})}};function xt(e){const t=r(Dt);if(!t)throw new Error("useSamplingRulesFormContext must be used within a SamplingRulesFormProvider");if(e&&t.formType!==e)throw new Error(`Expected formType "${e}" but found "${t.formType}"`);return t}const Ht={otelServiceName:"",currentStreamName:""},Kt=a(null),Vt=({children:r})=>{const[a,s]=o(void 0),i=N(Ht),c=n(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),s(void 0)},[]),l=n(()=>{const e=O(i.formData);return i.handleErrorChange(void 0,void 0,{}),s(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),d=t(()=>({loadSource:c,genericForm:i,validateFormData:l,errorMessage:a}),[c,i,l,a]);return e(Kt.Provider,{value:d,children:r})},Wt=()=>{const e=r(Kt);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Yt=new Set([q.StaticPod]),$t=e=>{const t=e.workloads.filter(({selected:e})=>e).length,r=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===r,isSomeSourced:t>0&&t<r,isFutureApps:e.selected||!1}},jt=(e,t,r)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(r.showOnlySelected){const{isAllSourced:t,isSomeSourced:r,isFutureApps:a}=$t(e);return t||r||a}return!0},qt=(e,t,r)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!r.showOnlySelected||e.selected),Bt=a({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),Qt=(e,t)=>`${e}\0${t}`,zt=(e,t,r,a)=>`${e}\0${t}\0${r}/${a}`,Jt=(e,t)=>e.name===t.name&&e.kind===t.kind&&(e.region??"")===(t.region??""),Xt=(e,t,r)=>{const a=[];return t.workloads.forEach(n=>{const o=e?.workloads.find(e=>Jt(e,n));n.selected!==o?.selected&&a.push({namespace:t.name,name:n.name,kind:n.kind,region:n.region||void 0,selected:n.selected||!1,currentStreamName:r})}),a},Zt=({children:r,selectedConnectionIds:a,initialInputs:c})=>{const{tier:l}=re(),d=l===y.Onprem,{capabilities:u}=tt(),m=u.canInstrumentNamespaces,{selectedStreamName:p}=h(),[E,S]=o(!1),[T,g]=o(null),[_,I]=o([]),A=i(new Set),v=n((e,t)=>{t.forEach(t=>{const r=e.find(e=>e.clusterId===t.clusterId);r&&t.namespaces.forEach(e=>{const a=r.namespaces.find(t=>t.name===e.name);a&&(a.selected!==e.selected&&A.current.add(Qt(t.clusterId,e.name)),e.workloads.forEach(r=>{const n=a.workloads.find(e=>e.name===r.name&&e.kind===r.kind);n&&n.selected!==r.selected&&A.current.add(zt(t.clusterId,e.name,r.kind,r.name))}))})})},[]);s(()=>{T&&I(e=>{const t=((e,t)=>O(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(T,a);return t.map(t=>{const r=e?.find(e=>e.clusterId===t.clusterId),a=((e,t,r)=>{if(!t)return e;const a=new Map(t.namespaces.map(e=>[e.name,e]));return{...e,namespaces:e.namespaces.map(t=>{const n=a.get(t.name);if(!n)return t;const o=new Map(n.workloads.map(e=>[`${e.kind}/${e.name}`,e])),s=r.has(Qt(e.clusterId,t.name));return{...t,selected:s?n.selected:t.selected,workloads:t.workloads.map(a=>{const n=o.get(`${a.kind}/${a.name}`),s=r.has(zt(e.clusterId,t.name,a.kind,a.name));return n&&s?{...a,selected:n.selected}:a})}})}})(t,r,A.current);if(c?.[t.clusterId]){const e=c[t.clusterId],r=O(a);return e.forEach(e=>{const t=r.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const r=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);r&&(r.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Yt.has(e.kind)&&!d||(e.selected=!0)})}),r}return a})})},[T,a,c]);const{formDiff:R,isFormDirty:C}=t(()=>{const e=((e,t,r,a)=>{const n={};return e.forEach(e=>{e.namespaces.forEach(o=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===o.name);if(!a){const t=Xt(s,o,r);return void(t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t)))}const i=o.selected||!1;if(i!==s?.selected)n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push({namespace:o.name,selected:i,currentStreamName:r}),i?n[e.clusterId]=n[e.clusterId].filter(e=>e.namespace!==o.name||e.namespace===o.name&&(!e.name||!e.kind)):o.workloads.forEach(t=>{t.selected&&n[e.clusterId].push({namespace:o.name,name:t.name,kind:t.kind,region:t.region||void 0,selected:!0,currentStreamName:r})});else{const t=Xt(s,o,r);t.length>0&&(n[e.clusterId]||(n[e.clusterId]=[]),n[e.clusterId].push(...t))}})}),n})(_,T?.clusters||[],p,m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[_,T,p,m]),N=n(e=>!d&&Yt.has(e),[d]),D=n(({clusterId:e,workloadId:t,selected:r,auto:a})=>{I(n=>{const o=O(n),s=o.findIndex(t=>t.clusterId===e);if(-1===s)return o;const i=o[s].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return o;if(t.kind&&t.name){const e=o[s].namespaces[i].workloads.findIndex(e=>Jt(e,{name:t.name,kind:t.kind,region:t.region}));if(-1===e)return o;const a="boolean"==typeof r?r:!o[s].namespaces[i].workloads[e].selected;o[s].namespaces[i].workloads[e].selected=a,m&&(a?o[s].namespaces[i].workloads.filter(e=>!N(e.kind)).every(e=>e.selected)&&(o[s].namespaces[i].selected=!0):o[s].namespaces[i].selected=!1)}else if(m){const e="boolean"==typeof a?a:!o[s].namespaces[i].selected;o[s].namespaces[i].selected=e,e?o[s].namespaces[i].workloads.forEach(e=>{N(e.kind)||(e.selected=!0)}):"boolean"!=typeof r||r||o[s].namespaces[i].workloads.forEach(e=>{e.selected=!1})}else{const e="boolean"==typeof r?r:"boolean"!=typeof a||a;o[s].namespaces[i].workloads.forEach(t=>{e&&N(t.kind)||(t.selected=e)})}return v(n,o),o})},[N,m,v]),w=n(({clusterId:e,namespaceName:t,boolean:r,searchText:a="",searchBy:n="",filters:o})=>{I(s=>{const i=O(s),c=n===f.Namespace?a:"",l=n===f.Source?a:"",d=!!c||!!l||!!o?.showOnlySelected;return i.forEach((a,n)=>{e&&a.clusterId!==e||a.namespaces.forEach(({name:e,workloads:a},s)=>{if(!t||e===t)if(d)if(t){if(a.forEach((e,t)=>{r&&N(e.kind)||qt(e,l,o||{showOnlySelected:!1})&&(i[n].namespaces[s].workloads[t].selected=r)}),m){const e=i[n].namespaces[s].workloads.filter(e=>!N(e.kind)).every(e=>e.selected);i[n].namespaces[s].selected=e}}else{if(!jt(i[n].namespaces[s],c,o||{showOnlySelected:!1}))return;m&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&N(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})}else m&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&N(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})})}),v(s,i),i})},[N,m,v]);return e(Bt.Provider,{value:{snapshots:T,setSnapshots:g,isFetching:E,setIsFetching:S,formData:_,handleSourceChange:D,handleSelectAll:w,formDiff:R,isFormDirty:C},children:r})},er=()=>r(Bt);export{ct as A,mt as C,yt as D,Yt as E,Ie as O,Ct as R,Ot as S,Pe as a,It as b,ge as c,Mt as d,Vt as e,Zt as f,Ve as g,lt as h,xe as i,He as j,Me as k,pt as l,ht as m,At as n,tt as o,We as p,Nt as q,be as r,xt as s,Wt as t,Te as u,er as v,qt as w,jt as x,$t as y};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type DataCardProps } from '../../../components';
|
|
2
|
-
import { type Workload } from '../../../types';
|
|
3
|
-
/**
|
|
4
|
-
* Build the items shown in the view-mode `Source Details` `DataCard`.
|
|
5
|
-
* Namespace is K8s-only; region is connector-only; kubectl is omitted for
|
|
6
|
-
* non-K8s platforms.
|
|
7
|
-
*/
|
|
8
|
-
export declare const buildDataCard: (source: Workload, opts: {
|
|
9
|
-
isK8s?: boolean;
|
|
10
|
-
isConnector?: boolean;
|
|
11
|
-
} | boolean) => DataCardProps["items"];
|
|
12
|
-
/**
|
|
13
|
-
* Build the kubectl command that targets this source. Returns `null` for
|
|
14
|
-
* non-K8s sources (they don't have a workload to address with kubectl).
|
|
15
|
-
*/
|
|
16
|
-
export declare const buildKubectlCommand: (source: Workload, isVmOrNonK8s: boolean) => string | null;
|