@odigos/ui-kit 0.0.274 → 0.0.276
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 +16 -0
- package/docs/api-context.md +6 -2
- package/lib/chunks/{helpers-9QRquBS1.js → helpers-DifX1XM0.js} +1 -1
- package/lib/chunks/{index-BesD_mee.js → index-BxDn2YI2.js} +1 -1
- package/lib/chunks/source-instrument-form-context-M5A5jkXP.js +5 -0
- package/lib/chunks/{ui-components-i5FUYiX9.js → ui-components-B2sd5xH7.js} +230 -230
- package/lib/components.js +1 -1
- package/lib/constants/strings/index.d.ts +0 -1
- package/lib/constants.js +1 -1
- package/lib/containers.js +89 -77
- package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +16 -1
- package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +17 -2
- package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +1 -1
- package/lib/contexts/odigos-api/use-api-query.d.ts +3 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/snippets.js +1 -1
- package/lib/store/useFilterStore.d.ts +4 -0
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/source-instrument-form-context-fYKmw6ZG.js +0 -5
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* concurrent consumers and shares the cached list, so the
|
|
7
7
|
* `<AddSourceDrawer>` and `<DiagnoseTab>` (and any other consumer)
|
|
8
8
|
* see the same data once any of them has triggered the fetch.
|
|
9
|
+
*
|
|
10
|
+
* `useNamespaces({ skip })` lets a consumer opt out of triggering that
|
|
11
|
+
* fetch. The query is a full cluster-wide workload inventory, so a
|
|
12
|
+
* consumer that has a cheaper source for the same data should gate it
|
|
13
|
+
* rather than pay for both round-trips (PLAT-1345).
|
|
9
14
|
*/
|
|
10
15
|
import { type Namespace } from '../../../types';
|
|
11
16
|
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
@@ -21,13 +26,23 @@ export interface UseNamespacesResult {
|
|
|
21
26
|
error?: string;
|
|
22
27
|
}>;
|
|
23
28
|
}
|
|
29
|
+
export interface UseNamespacesOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Skip the query entirely: no request is sent, `items` stays the stable
|
|
32
|
+
* empty array and `loading` stays `false`. `GET_NAMESPACES_WITH_WORKLOADS`
|
|
33
|
+
* is a cluster-wide workload inventory, so a container that can source the
|
|
34
|
+
* same data more cheaply should gate it — the `<AddSourceDrawer>` only
|
|
35
|
+
* needs it when no cluster snapshot is available (PLAT-1345).
|
|
36
|
+
*/
|
|
37
|
+
skip?: boolean;
|
|
38
|
+
}
|
|
24
39
|
export interface NamespaceApi {
|
|
25
40
|
/**
|
|
26
41
|
* Subscribe to the namespaces (with workloads) list. Owns a
|
|
27
42
|
* `useApiQuery('GET_NAMESPACES_WITH_WORKLOADS')` — call at the top level of a
|
|
28
43
|
* container. Returns the reactive `{ items, loading, refetch }`.
|
|
29
44
|
*/
|
|
30
|
-
useNamespaces: () => UseNamespacesResult;
|
|
45
|
+
useNamespaces: (options?: UseNamespacesOptions) => UseNamespacesResult;
|
|
31
46
|
fetchAll: () => Promise<{
|
|
32
47
|
data?: NamespacesEnvelope;
|
|
33
48
|
error?: string;
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* blocks the op for the active context (e.g. central-ui can't snapshot a
|
|
15
15
|
* < v1.20 proxy, or a VM proxy) the query is skipped and `data` stays
|
|
16
16
|
* `undefined` — consumers treat that as the signal to fall back to the
|
|
17
|
-
* per-proxy `namespacesApi` path.
|
|
18
|
-
*
|
|
17
|
+
* per-proxy `namespacesApi` path. `pending` tells them WHEN that signal is
|
|
18
|
+
* trustworthy, so a consumer can gate its fallback request instead of firing
|
|
19
|
+
* it speculatively alongside the snapshot. Imperative `getAllClusterSnapshots`
|
|
20
|
+
* / `getClusterSnapshot` remain for fire-and-forget reads.
|
|
19
21
|
*/
|
|
20
22
|
import type { AllClusterSnapshots, ClusterSnapshot } from '../../../types';
|
|
21
23
|
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
@@ -23,6 +25,19 @@ export interface UseSnapshotsResult {
|
|
|
23
25
|
/** All-cluster snapshot for the active context (undefined while loading, skipped, or blocked by the op's guard). */
|
|
24
26
|
data?: AllClusterSnapshots;
|
|
25
27
|
loading: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* True while the snapshot outcome is still unknown — a request is in flight
|
|
30
|
+
* and nothing has landed yet. Once this is `false`, `data === undefined`
|
|
31
|
+
* definitively means "no snapshot for this context" (the op is missing, its
|
|
32
|
+
* `canRun` guard blocked it, or the backend returned none), which is the
|
|
33
|
+
* signal to fall back to the per-proxy namespaces path.
|
|
34
|
+
*
|
|
35
|
+
* Distinct from `loading`, which is also `true` while `cache-and-network`
|
|
36
|
+
* revalidates a snapshot that's already rendered. Consumers gating a
|
|
37
|
+
* fallback request need `pending`: gating on `!data` alone fires the
|
|
38
|
+
* fallback on the first render, before the snapshot had a chance to arrive.
|
|
39
|
+
*/
|
|
40
|
+
pending: boolean;
|
|
26
41
|
/** True when the host adapter doesn't expose `GET_ALL_CLUSTER_SNAPSHOTS` at all. */
|
|
27
42
|
unsupported: boolean;
|
|
28
43
|
refetch: () => Promise<{
|
|
@@ -39,7 +39,7 @@ export interface PersistSourceInput {
|
|
|
39
39
|
}[];
|
|
40
40
|
}
|
|
41
41
|
export interface UseSourcesResult {
|
|
42
|
-
/**
|
|
42
|
+
/** Overview workloads: instrumented plus explicitly disabled Sources. */
|
|
43
43
|
items: Workload[];
|
|
44
44
|
/** True while the initial `GET_WORKLOADS` request is in flight. */
|
|
45
45
|
loading: boolean;
|
|
@@ -67,7 +67,9 @@ export interface UseApiQueryResult<TData> {
|
|
|
67
67
|
/**
|
|
68
68
|
* Re-execute the query with the same variables, returning the
|
|
69
69
|
* transformed data. Wraps Apollo's `refetch` so callers don't see
|
|
70
|
-
* the raw envelope.
|
|
70
|
+
* the raw envelope. No-ops to `{ data: undefined }` while the query is
|
|
71
|
+
* skipped — by `options.skip`, a missing slot, or the op's `canRun` guard —
|
|
72
|
+
* so a "refresh on open" effect can't smuggle a request past those gates.
|
|
71
73
|
*/
|
|
72
74
|
refetch: () => Promise<{
|
|
73
75
|
data: TData | undefined;
|
package/lib/contexts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as a,r as x,a as y}from"./chunks/source-instrument-form-context-
|
|
1
|
+
import{u as a,r as x,a as y}from"./chunks/source-instrument-form-context-M5A5jkXP.js";export{A as ActionFormContextProvider,C as CloudConnectorFormContextProvider,D as DataStreamFormContextProvider,b as DestinationFormContextProvider,O as OdigosApiConnectionsScope,c as OdigosApiProvider,R as RuleFormContextProvider,S as SamplingRuleFormType,d as SamplingRulesFormProvider,e as SourceEditFormContextProvider,f as SourceInstrumentFormContextProvider,p as prepareNamespacePayloads,g as prepareSourcePayloads,h as useActionFormContext,i as useApiLazyQuery,j as useApiMutation,k as useApiQuery,l as useCloudConnectorFormContext,m as useDataStreamFormContext,n as useDestinationFormContext,o as useOdigosApi,q as useRuleFormContext,s as useSamplingRulesFormContext,t as useSourceEditFormContext,v as useSourceInstrumentFormContext}from"./chunks/source-instrument-form-context-M5A5jkXP.js";export{O as OdigosProvider,c as checkVersionSupport,r as resolveMinSupportedVersion,u as useOdigos}from"./chunks/helpers-DifX1XM0.js";import{jsx as F}from"react/jsx-runtime";import{useMemo as P,useContext as E,createContext as T}from"react";import{P as I,t as _}from"./chunks/ui-components-B2sd5xH7.js";import{useApolloClient as M}from"@apollo/client/react";import"@apollo/client/link/error";import"@apollo/client/link/context";import"@apollo/client/utilities";import"@apollo/client/errors";import"@apollo/client";import"styled-components";import"./icons.js";import"zustand";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";const V=()=>{const o=M(),{operations:r,context:e}=a();return{multiFetch:async(t,s,n)=>{const i=r[t];return i?y(o,i,s,n,e):{results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:s.length,error:`Operation ${String(t)} not configured`}},bulkPersistSources:async(t,s)=>{const n=[];for(const i of t){const t={...e,proxyID:i},{error:a}=await x(o,r.PERSIST_SOURCES,s,t);a&&n.push(`${i}: ${a}`)}return n.length?{error:n.join(", ")}:void 0},applyConfigurations:async(t,s)=>{if(!r.UPDATE_REMOTE_CONFIG)return{error:"UPDATE_REMOTE_CONFIG not configured"};const{error:n}=await x(o,r.UPDATE_REMOTE_CONFIG,{formData:s,connectionIds:t},e);return n?{error:n}:void 0}}},w=(o,r)=>o.platformType===I.K8s?r.K8s:[I.Vm,I.Connector,I.AwsEcs].includes(o.platformType)?r.Vm:void 0,N=o=>r=>{const e=o[r.platformType];if(!e)return;const t=Object.keys(e);if(0===t.length)return;const s=_(r.schemaVersion??r.version),n=[...t].sort((o,r)=>_(r)-_(o)).find(o=>s>=_(o));return n?e[n]:void 0},U=(o,r)=>{const e={};for(const t of Object.keys(o))e[t]=r(o[t]);return e},z=T({formType:void 0}),G=({children:o,formType:r})=>{const e=P(()=>({formType:r}),[r]);return F(z.Provider,{value:e,children:o})},$=()=>E(z);export{G as StorybookProvider,w as pickByPlatform,V as useApiForConnections,$ as useStorybook,N as versionedDocument,U as vmDialectMap};
|
package/lib/functions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{bk as adaptInstrumentationRuleFromWire,bi as adaptInstrumentationRuleInputForWire,ci as buildBadgeForDesiredStatus,c9 as buildCatalogFieldsDataCard,fs as capitalizeFirstLetter,ft as cleanObjectEmptyStringsValues,a3 as compareCondition,fu as decimalsOnly,aY as deepClone,eA as entityIdKey,eF as filterActions,eE as filterDestinations,cd as filterDestinationsByStream,eD as filterSources,eq as filterSourcesByStream,fv as flattenObjectKeys,cw as formatBytes,fw as formatDuration,b4 as generateId,ex as getActionConditions,cb as getActionIcon,ey as getConditionsBooleans,cM as getContainersIcons,fx as getContainersInstrumentedCount,fy as getDeepValue,c1 as getDestinationIcon,fz as getDetectedLanguageIcons,cm as getEffectiveLanguage,cE as getEffectiveRuntimeVersion,eB as getEntityIcon,bh as getEntityId,ew as getEntityIdKey,ez as getEntityLabel,fA as getHealthBadgeLabel,bf as getIdFromSseTarget,cf as getInstrumentationRuleIcon,fB as getMainContainerLanguage,fC as getMetricForEntity,fD as getMonitorIcon,fE as getNearestTypographySize,cL as getPlatformIcon,em as getPlatformLabel,O as getProgrammingLanguageIcon,fF as getRecursiveValues,cv as getSourceKindLabel,cs as getSourceLanguageIcons,b8 as getSseTargetFromId,cC as getStatusColor,eH as getStatusFromPodStatus,cD as getStatusIcon,cx as getStatusTypeFromOdigosHealth,fG as getValueForRange,cr as getVirtualServiceIcon,cq as getWorkloadId,ce as getYamlFieldsForDestination,fH as hasUnhealthyInstances,fI as instrumentationRuleSourceScopesFromWire,fJ as instrumentationRuleSourceScopesToWire,bp as isEmpty,bq as isLegalK8sLabel,d5 as isOverTime,fK as isStringABoolean,fL as isTimeElapsed,cB as isValidVersion,fM as mapConditions,ck as mapDesiredStatusToConditionStatus,c7 as mapDesiredStatusesToConditions,cc as mapDestinationFieldsForDisplay,bu as mapExportedSignals,bs as mapSupportedSignals,fN as numbersOnly,fO as parseBooleanFromString,fP as parseJsonStringToPrettyString,bK as prepareDestinationFormData,fQ as removeEmptyValuesFromObject,v as safeJsonParse,fR as safeJsonStringify,fS as setDeepValue,fT as sleep,ag as splitCamelString,fU as stringifyNonStringValues,t as trimVersion}from"./chunks/ui-components-
|
|
1
|
+
export{bk as adaptInstrumentationRuleFromWire,bi as adaptInstrumentationRuleInputForWire,ci as buildBadgeForDesiredStatus,c9 as buildCatalogFieldsDataCard,fs as capitalizeFirstLetter,ft as cleanObjectEmptyStringsValues,a3 as compareCondition,fu as decimalsOnly,aY as deepClone,eA as entityIdKey,eF as filterActions,eE as filterDestinations,cd as filterDestinationsByStream,eD as filterSources,eq as filterSourcesByStream,fv as flattenObjectKeys,cw as formatBytes,fw as formatDuration,b4 as generateId,ex as getActionConditions,cb as getActionIcon,ey as getConditionsBooleans,cM as getContainersIcons,fx as getContainersInstrumentedCount,fy as getDeepValue,c1 as getDestinationIcon,fz as getDetectedLanguageIcons,cm as getEffectiveLanguage,cE as getEffectiveRuntimeVersion,eB as getEntityIcon,bh as getEntityId,ew as getEntityIdKey,ez as getEntityLabel,fA as getHealthBadgeLabel,bf as getIdFromSseTarget,cf as getInstrumentationRuleIcon,fB as getMainContainerLanguage,fC as getMetricForEntity,fD as getMonitorIcon,fE as getNearestTypographySize,cL as getPlatformIcon,em as getPlatformLabel,O as getProgrammingLanguageIcon,fF as getRecursiveValues,cv as getSourceKindLabel,cs as getSourceLanguageIcons,b8 as getSseTargetFromId,cC as getStatusColor,eH as getStatusFromPodStatus,cD as getStatusIcon,cx as getStatusTypeFromOdigosHealth,fG as getValueForRange,cr as getVirtualServiceIcon,cq as getWorkloadId,ce as getYamlFieldsForDestination,fH as hasUnhealthyInstances,fI as instrumentationRuleSourceScopesFromWire,fJ as instrumentationRuleSourceScopesToWire,bp as isEmpty,bq as isLegalK8sLabel,d5 as isOverTime,fK as isStringABoolean,fL as isTimeElapsed,cB as isValidVersion,fM as mapConditions,ck as mapDesiredStatusToConditionStatus,c7 as mapDesiredStatusesToConditions,cc as mapDestinationFieldsForDisplay,bu as mapExportedSignals,bs as mapSupportedSignals,fN as numbersOnly,fO as parseBooleanFromString,fP as parseJsonStringToPrettyString,bK as prepareDestinationFormData,fQ as removeEmptyValuesFromObject,v as safeJsonParse,fR as safeJsonStringify,fS as setDeepValue,fT as sleep,ag as splitCamelString,fU as stringifyNonStringValues,t as trimVersion}from"./chunks/ui-components-B2sd5xH7.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/hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{g9 as IGNORE_OUTSIDE_CLICK_ATTR,ga as useActionFormData,gb as useBodyScroll,eC as useContainerSize,b3 as useCopy,gc as useDataStreamFormData,gd as useDestinationFormData,bl as useGenericForm,ge as useInstrumentationRuleFormData,d4 as useKeyDown,cy as useOnClickOutside,gf as useOverflow,gg as usePopup,ch as useScrollIntoViewWhen,f0 as useScrollTo,et as useSessionStorage,gh as useSourceFormData,cg as useTimeAgo}from"./chunks/ui-components-
|
|
1
|
+
export{g9 as IGNORE_OUTSIDE_CLICK_ATTR,ga as useActionFormData,gb as useBodyScroll,eC as useContainerSize,b3 as useCopy,gc as useDataStreamFormData,gd as useDestinationFormData,bl as useGenericForm,ge as useInstrumentationRuleFormData,d4 as useKeyDown,cy as useOnClickOutside,gf as useOverflow,gg as usePopup,ch as useScrollIntoViewWhen,f0 as useScrollTo,et as useSessionStorage,gh as useSourceFormData,cg as useTimeAgo}from"./chunks/ui-components-B2sd5xH7.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/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-B2sd5xH7.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-BxDn2YI2.js";export{C as ColoredSpan,a as ColoredSpanVariant}from"./chunks/helpers-DifX1XM0.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";
|
|
@@ -9,6 +9,8 @@ export interface FiltersState {
|
|
|
9
9
|
monitors?: DropDataOption[];
|
|
10
10
|
languages?: DropDataOption[];
|
|
11
11
|
podsAgentInjectionStatus?: DropDataOption[];
|
|
12
|
+
/** Filter by Source enabled/disabled (`markedForInstrumentation`). */
|
|
13
|
+
enabledStatuses?: DropDataOption[];
|
|
12
14
|
onlyErrors?: boolean;
|
|
13
15
|
}
|
|
14
16
|
interface StoreState {
|
|
@@ -30,6 +32,8 @@ interface StoreState {
|
|
|
30
32
|
setLanguages: (metrics: FiltersState['languages']) => void;
|
|
31
33
|
podsAgentInjectionStatus: FiltersState['podsAgentInjectionStatus'];
|
|
32
34
|
setPodsAgentInjectionStatus: (podsAgentInjectionStatus: FiltersState['podsAgentInjectionStatus']) => void;
|
|
35
|
+
enabledStatuses: FiltersState['enabledStatuses'];
|
|
36
|
+
setEnabledStatuses: (enabledStatuses: FiltersState['enabledStatuses']) => void;
|
|
33
37
|
onlyErrors: FiltersState['onlyErrors'];
|
|
34
38
|
setOnlyErrors: (onlyErrors: FiltersState['onlyErrors']) => void;
|
|
35
39
|
setAll: (params: Partial<FiltersState>) => void;
|
package/lib/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-B2sd5xH7.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{gi as Provider,gj as animations,gk as opacity,gl as palettes}from"./chunks/ui-components-
|
|
1
|
+
export{gi as Provider,gj as animations,gk as opacity,gl as palettes}from"./chunks/ui-components-B2sd5xH7.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/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-B2sd5xH7.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{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-
|
|
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-B2sd5xH7.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,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,bb as y,bc as h,bd as S,be as T,bf as g,bg as _,bh as I,bi as A,bj as v,bk as R,bl as C,aY as N,bm as O,bn as D,n as w,bo as b,bp as P,bq as L,br as k,bs as F,bt as G,v as U,bu as M,bv as x,ad as H,a9 as K,ab as V,aa as W,ac as Y,a8 as $,bw as j,b as q}from"./ui-components-i5FUYiX9.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-9QRquBS1.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}=y(),{setProgress:l,resetProgress:d}=h(),{setConfiguredSources:u,setConfiguredFutureApps:m}=S(),E=(e,t)=>{const{progress:r}=h.getState();e>0&&l(T.Instrumenting,{total:(r[T.Instrumenting]?.total||0)+e,current:r[T.Instrumenting]?.current||0}),t>0&&l(T.Uninstrumenting,{total:(r[T.Uninstrumenting]?.total||0)+t,current:r[T.Uninstrumenting]?.current||0})},_=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:_}},fetchAll:_,fetchByTargets:async(n,o)=>{const s=!!o?.slim,i=n.map(e=>g(e,f.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===i.length)return;if(i.length>50)return void await _();const c=s&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error: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 _()},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:g}=We(o,c);let _=!1;h||(_=!0,s("Persisting sources...")),g||_||s("Persisting namespaces...");const{error:I}=await be(r,e.PERSIST_SOURCES,y,t);if(I&&(d(T.Instrumenting),d(T.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}=y(),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=>I(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(()=>_(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(R),[e.data]),loading:e.loading,refetch:i}},useRuleTypes:()=>{const e=Me("GET_INSTRUMENTATION_RULE_TYPES",void 0,{fetchPolicy:"cache-first"});return{options:t(()=>v(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:A(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:A(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}=y(),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),C=((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),N=((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),O=((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),D=((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),w=((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),b=((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),P=((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),L=((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),k=((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),F=((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),G=((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:C,k8sManifestApi:N,configApi:O,describeApi:D,tokensApi:w,metricsApi:b,serviceMapApi:P,profilingApi:L,collectorsApi:k,samplingApi:F,snapshotsApi:G,capabilities:t(()=>((e,t)=>{const r=t.platformType===E.K8s,a=r,n=r,o=!(t.platformType===E.Vm);return{canBulkPersistSources:o&&!!e.PERSIST_SOURCES,canInstrumentNamespaces:n&&!!e.PERSIST_NAMESPACES,canFetchSnapshots:a&&!!e.GET_ALL_CLUSTER_SNAPSHOTS,canRecoverFromRollback:a&&!!e.RECOVER_FROM_ROLLBACK,canRestartWorkloads:a&&!!e.RESTART_WORKLOADS,canFetchPeerSources:!!e.GET_PEER_SOURCES,canFetchSourceLibraries:!!e.GET_SOURCE_LIBRARIES,canFetchK8sManifest:a&&!!e.GET_K8S_MANIFEST,canCreateDestination:!!e.CREATE_DESTINATION,canTestConnection:o&&!!e.TEST_DESTINATION_CONNECTION,canFetchDestinationCategories:!!e.GET_DESTINATION_CATEGORIES,canFetchPotentialDestinations:o&&!!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:o&&!!e.UPDATE_REMOTE_CONFIG&&!!e.GET_EFFECTIVE_CONFIG,canFetchEffectiveConfig:!!e.GET_EFFECTIVE_CONFIG,canFetchConfigYamls:!!e.GET_CONFIG_YAMLS,canFetchProfiling:a&&!!e.GET_PROFILING_SLOTS,canFetchCollectorInfo:a&&!!e.GET_GATEWAY_INFO,canManageSamplingRules:!!e.GET_SAMPLING_RULES}})(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=N(e??{}),a=r[D.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===w.SourceScopes).map(e=>e.name));return void 0!==r[D.Scopes]&&n.add(D.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():P(a));var a}),ct=({children:r,sourceOptions:a=[],namespaceOptions:s=[]})=>{const[i,c]=o(null),d=C(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,O.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:N(rt)};const e=((e,t)=>{const r=N(e),a=r.fields||{},n=a[D.UrlTemplatizationRulesGroups];n?.length&&(a[D.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const o=a[D.AttributeNamesToDelete];o?.length&&(a[D.AttributeNamesToDelete]=o.filter(e=>!!e?.trim()));const s=a[D.Renames];if(s){const e=Array.isArray(s)?s.map(e=>[e?.key??"",e?.value??""]):Object.entries(s);a[D.Renames]=Object.fromEntries(e.filter(([e,t])=>!!e?.trim()&&!!t?.trim()))}const i=new Set((t?.fields||[]).filter(e=>e.componentType===w.SourceScopes).map(e=>e.name));void 0!==a[D.Scopes]&&i.add(D.Scopes),i.forEach(e=>{const t=a[e];void 0!==t&&(a[e]=B(t)?null:t)});const c=a[D.ExtractAttribute];return c?.extractions?.length&&(a[D.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 P(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 b.K8sAttributes:{const e=!(n[D.CollectContainerAttributes]||n[D.CollectReplicaSetAttributes]||n[D.CollectWorkloadId]||n[D.CollectClusterId]),t=!n[D.LabelsAttributes]?.length,r=!n[D.AnnotationsAttributes]?.length;e&&t&&r&&(a[D.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const o=n[D.LabelsAttributes];o?.some(e=>!it(e,["labelKey","attributeKey","fromSources"]))&&(a[D.LabelsAttributes]=ot);const s=n[D.AnnotationsAttributes];s?.some(e=>!it(e,["annotationKey","attributeKey","fromSources"]))&&(a[D.AnnotationsAttributes]=ot);break}case b.AddClusterInfo:{const e=n[D.ClusterAttributes];e?.length?e.some(e=>!it(e,["attributeName","attributeStringValue"]))&&(a[D.ClusterAttributes]=ot):a[D.ClusterAttributes]=st;break}case b.DeleteAttributes:{const e=o[D.AttributeNamesToDelete]||[],t=n[D.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(a[D.AttributeNamesToDelete]=ot):a[D.AttributeNamesToDelete]=e.length?ot:st;break}case b.RenameAttributes:{const e=Object.entries(o[D.Renames]||{}),t=Object.entries(n[D.Renames]||{}),r=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?r&&(a[D.Renames]=ot):a[D.Renames]=e.length?ot:st;break}case b.PiiMasking:{const e=n[D.PiiCategories];e?.length||(a[D.PiiCategories]="Select at least one attribute to mask");break}case b.URLTemplatization:{const e=n[D.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(a[D.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case b.ExtractAttribute:{const e=n[D.ExtractAttribute]?.extractions||[],t=o[D.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[D.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[D.ExtractAttribute]="Each new span attribute name must be unique")}else a[D.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=C(dt),s=n(()=>{const e=N(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}=y(),[c,d]=o(void 0),[u,m]=o(a),[p,f]=o(void 0),[E,h]=o(null),S=i(null),T=C(ft),g=n(e=>{T.resetFormData({name:e}),T.handleErrorChange(void 0,void 0,{}),d(void 0),m(e),f(e),h(null),S.current=null},[]),_=n(()=>{const e=N(T.formData),t=(e=>{const t={};return e.name?L(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 h({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,h(null),e&&t&&await e(t)},[E]),v=n(()=>{S.current=null,h(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:N(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===w.Dropdown,c=U(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}=y(),{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:k.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:k.UNSAVED}:null:null))},[c]),h=n(e=>{m(t=>t.filter((t,r)=>r!==e)),d(null)},[]),S=C({...St,currentStreamName:a});s(()=>{if(!c)return;if(p)return void S.resetFormData({...p.formData});if(c.listType===k.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=F(c.option.supportedSignals);S.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:a,disabled:!1,exportedSignals:{logs:e.includes(G.Logs),metrics:e.includes(G.Metrics),traces:e.includes(G.Traces),profiles:e.includes(G.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=U(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:k.EXISTS,option:n,dynamicFields:o})},[]),_=n(()=>{const e=N(S.formData),t={};return c?.dynamicFields.forEach(({name:r,required:a})=>{if(a){const a=e.fields.find(e=>e.key===r)?.value;P(a)&&(t[r]=l.FIELD_IS_REQUIRED)}}),M(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:h},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=C(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,x.find(e=>e.type===r)??null))},[]),m=n(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:N(vt)};const e=(e=>{const t=N(e),r={...t,sourceScopes:B(t.sourceScopes)?null:t.sourceScopes,workloads:null};return r.headersCollection?.[H.HeaderKeys]?.length&&(r.headersCollection[H.HeaderKeys]=r.headersCollection[H.HeaderKeys].map(e=>e.trim()).filter(e=>e)),r.customInstrumentations?.[K.Golang]?.length&&(r.customInstrumentations[K.Golang]=r.customInstrumentations[K.Golang].map(e=>new V(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?.[K.Java]?.length&&(r.customInstrumentations[K.Java]=r.customInstrumentations[K.Java].map(e=>new W(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),r.customInstrumentations?.[K.Php]?.length&&(r.customInstrumentations[K.Php]=r.customInstrumentations[K.Php].map(e=>new Y(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 $.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(r.codeAttributes="Code attributes are required");break;case $.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(r.payloadCollection="Payload collection are required");break;case $.HeadersCollection:t.headersCollection?.[H.HeaderKeys]?.length||(r.headersCollection="Header keys are required");break;case $.CustomInstrumentation:{const e=t.customInstrumentations?.[K.Golang]||[],a=t.customInstrumentations?.[K.Java]||[],n=t.customInstrumentations?.[K.Php]||[];if(!e.length&&!a.length&&!n.length){r.customInstrumentations="Custom instrumentation are required";break}const o=e.findIndex(e=>!new V(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 W(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 Y(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}=C(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}=C(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=C(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=N(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([j.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===q.Onprem,{capabilities:u}=tt(),m=u.canInstrumentNamespaces,{selectedStreamName:p}=y(),[E,h]=o(!1),[S,T]=o(null),[g,_]=o([]),I=i(new Set),A=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&&I.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&&I.current.add(zt(t.clusterId,e.name,r.kind,r.name))}))})})},[]);s(()=>{S&&_(e=>{const t=((e,t)=>N(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(S,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,I.current);if(c?.[t.clusterId]){const e=c[t.clusterId],r=N(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})})},[S,a,c]);const{formDiff:v,isFormDirty:R}=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})(g,S?.clusters||[],p,m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[g,S,p,m]),C=n(e=>!d&&Yt.has(e),[d]),O=n(({clusterId:e,workloadId:t,selected:r,auto:a})=>{_(n=>{const o=N(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=>!C(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=>{C(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&&C(t.kind)||(t.selected=e)})}return A(n,o),o})},[C,m,A]),D=n(({clusterId:e,namespaceName:t,boolean:r,searchText:a="",searchBy:n="",filters:o})=>{_(s=>{const i=N(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&&C(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=>!C(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&&C(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})}else m&&(i[n].namespaces[s].selected=r),a.forEach((e,t)=>{r&&C(e.kind)||(i[n].namespaces[s].workloads[t].selected=r)})})}),A(s,i),i})},[C,m,A]);return e(Bt.Provider,{value:{snapshots:S,setSnapshots:T,isFetching:E,setIsFetching:h,formData:g,handleSourceChange:O,handleSelectAll:D,formDiff:v,isFormDirty:R},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};
|