@odigos/ui-kit 0.0.259 → 0.0.261
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/{connections-scope-CogqbI1K.js → connections-scope-DhNWocBO.js} +1 -1
- package/lib/chunks/{index-Bio7SJqx.js → index-DILEVYlK.js} +12 -12
- package/lib/chunks/odigos-context-BYgtdAtj.js +19 -0
- package/lib/chunks/source-instrument-form-context-oDlfTrOD.js +1 -0
- package/lib/chunks/{ui-components-CrXELmQx.js → ui-components-BDSEcaSZ.js} +197 -197
- package/lib/chunks/use-odigos-api-DHCLONPK.js +5 -0
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/actions/index.d.ts +5 -1
- package/lib/constants/sampling/index.d.ts +4 -0
- package/lib/constants.js +1 -1
- package/lib/containers/_v2/_drawers/edit-source-drawer/sampling/index.d.ts +1 -1
- package/lib/containers/_v2/_forms/add-action-form/custom-fields/index.d.ts +3 -1
- package/lib/containers/_v2/_forms/add-action-form/dynamic-fields/index.d.ts +20 -0
- package/lib/containers/_v2/sampling-rules/helpers.d.ts +5 -4
- package/lib/containers/v2.js +155 -143
- package/lib/containers.js +1 -1
- package/lib/contexts/action-form-context.d.ts +1 -1
- package/lib/contexts/odigos-api/capabilities.d.ts +1 -0
- package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +12 -1
- package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +14 -6
- package/lib/contexts/odigos-api/types.d.ts +2 -1
- package/lib/contexts/odigos-api.js +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks/useActionFormData.d.ts +1 -1
- package/lib/hooks/useInstrumentationRuleFormData.d.ts +1 -1
- package/lib/hooks.js +1 -1
- package/lib/snippets/v2.js +1 -1
- package/lib/snippets.js +1 -1
- package/lib/store.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/types/actions/index.d.ts +40 -4
- package/lib/types/common/index.d.ts +2 -1
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/helpers-zByTbpzZ.js +0 -19
- package/lib/chunks/source-instrument-form-context-CowQuxT5.js +0 -1
- package/lib/chunks/use-odigos-api-UctF_jx_.js +0 -5
package/lib/containers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import o,{useTheme as r}from"styled-components";import{memo as n,useState as a,useCallback as s,useEffect as d,useMemo as l,createContext as c,useContext as p,useRef as u}from"react";import{U as h}from"./chunks/consts-D6GCMJ6c.js";import{MarkerType as g,useNodesState as m,useEdgesState as f,Handle as v,Position as y,getSmoothStepPath as b,BaseEdge as x,EdgeLabelRenderer as N,ReactFlowProvider as S,ReactFlow as I,Background as w,Controls as $,ControlButton as k,useReactFlow as M}from"@xyflow/react";import{N as C,o as T,p as A,q as E,r as z,v as X,w as K,
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import o,{useTheme as r}from"styled-components";import{memo as n,useState as a,useCallback as s,useEffect as d,useMemo as l,createContext as c,useContext as p,useRef as u}from"react";import{U as h}from"./chunks/consts-D6GCMJ6c.js";import{MarkerType as g,useNodesState as m,useEdgesState as f,Handle as v,Position as y,getSmoothStepPath as b,BaseEdge as x,EdgeLabelRenderer as N,ReactFlowProvider as S,ReactFlow as I,Background as w,Controls as $,ControlButton as k,useReactFlow as M}from"@xyflow/react";import{N as C,o as T,p as A,q as E,r as z,v as X,w as K,T as R,a as V,x as O,y as _,B as q,z as L,L as j,M as H,O as D,Q as G,R as P,U as B,V as F,W as U,X as Y,Y as W}from"./chunks/ui-components-BDSEcaSZ.js";import{UserIcon as Z,ImageErrorIcon as Q,ArrowLeftIcon as J,InboundIcon as ee,OutboundIcon as te,RefreshIcon as ie}from"./icons.js";import oe from"elkjs/lib/elk.bundled.js";import{d as re}from"./chunks/use-odigos-api-DHCLONPK.js";import"@xyflow/react/dist/style.css";import"zustand";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";import"@apollo/client";import"@apollo/client/link/error";import"@apollo/client/link/context";import"@apollo/client/utilities";const ne=o.div`
|
|
2
2
|
padding: 12px;
|
|
3
3
|
border-radius: 12px;
|
|
4
4
|
background-color: ${({theme:e})=>e.v2.colors.silver[750]};
|
|
@@ -4,7 +4,7 @@ import { type Action, type ActionFormData, type ActionOption } from '@/types';
|
|
|
4
4
|
interface ActionFormContextValue {
|
|
5
5
|
selectedOption: ActionOption | null;
|
|
6
6
|
onSelectOption: (option: ActionOption | null) => void;
|
|
7
|
-
loadAction: (action: Action) => void;
|
|
7
|
+
loadAction: (action: Action, option?: ActionOption | null) => void;
|
|
8
8
|
genericForm?: GenericFormResult<ActionFormData>;
|
|
9
9
|
validateFormData: () => {
|
|
10
10
|
errorMessage?: string;
|
|
@@ -26,6 +26,7 @@ export interface Capabilities {
|
|
|
26
26
|
canFetchDestinationCategories: boolean;
|
|
27
27
|
canFetchPotentialDestinations: boolean;
|
|
28
28
|
canCreateAction: boolean;
|
|
29
|
+
canFetchActionTypes: boolean;
|
|
29
30
|
canCreateInstrumentationRule: boolean;
|
|
30
31
|
canApplyEffectiveConfig: boolean;
|
|
31
32
|
canFetchEffectiveConfig: boolean;
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
* `runMutation` and then `await fetchAll()` to refresh the cached list.
|
|
9
9
|
*/
|
|
10
10
|
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
11
|
-
import { type Action, type ActionFormData } from '@/types';
|
|
11
|
+
import { type Action, type ActionFormData, type ActionOption } from '@/types';
|
|
12
12
|
export interface UseActionsResult {
|
|
13
13
|
items: Action[];
|
|
14
14
|
loading: boolean;
|
|
15
15
|
refetch: () => Promise<void>;
|
|
16
16
|
}
|
|
17
|
+
export interface UseActionTypesResult {
|
|
18
|
+
options: ActionOption[];
|
|
19
|
+
loading: boolean;
|
|
20
|
+
}
|
|
17
21
|
export interface ActionsApi {
|
|
18
22
|
/**
|
|
19
23
|
* Subscribe to the actions list. Owns a `useApiQuery('GET_ACTIONS')` — call
|
|
@@ -21,6 +25,13 @@ export interface ActionsApi {
|
|
|
21
25
|
* `{ items, loading, refetch }`.
|
|
22
26
|
*/
|
|
23
27
|
useActions: () => UseActionsResult;
|
|
28
|
+
/**
|
|
29
|
+
* Subscribe to the dynamic action-type catalog (GET_ACTION_TYPES). Owns a
|
|
30
|
+
* `useApiQuery` — call at the top level of a container. Returns the mapped
|
|
31
|
+
* `{ options, loading }`; `options` is empty when the operation is unsupported
|
|
32
|
+
* or resolves nothing, so callers can fall back to `ACTION_OPTIONS`.
|
|
33
|
+
*/
|
|
34
|
+
useActionTypes: () => UseActionTypesResult;
|
|
24
35
|
fetchAll: () => Promise<void>;
|
|
25
36
|
create: (input: ActionFormData) => Promise<void>;
|
|
26
37
|
update: (id: string, input: ActionFormData) => Promise<void>;
|
|
@@ -2,12 +2,20 @@
|
|
|
2
2
|
* `useSnapshotsApi` — central-ui's cross-cluster snapshot reads.
|
|
3
3
|
*
|
|
4
4
|
* Reactive `data` / `loading` flow through the `useSnapshots()` sub-hook, which
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* routes by the active context:
|
|
6
|
+
* - In-proxy (a specific proxy is selected, e.g. the overview's
|
|
7
|
+
* AddSourceDrawer) it owns a `useApiQuery('GET_CLUSTER_SNAPSHOT')` scoped to
|
|
8
|
+
* the selected proxy id and wraps that single cluster into the
|
|
9
|
+
* `AllClusterSnapshots` shape consumers expect.
|
|
10
|
+
* - Out-of-proxy (the connections overview / bulk AddSourceDrawer) it owns a
|
|
11
|
+
* `useApiQuery('GET_ALL_CLUSTER_SNAPSHOTS')` for the full cross-cluster
|
|
12
|
+
* aggregate.
|
|
13
|
+
* Either way the op's `canRun(ctx)` guard is honored INTERNALLY: when the host
|
|
14
|
+
* blocks the op for the active context (e.g. central-ui can't snapshot a
|
|
15
|
+
* < v1.20 proxy, or a VM proxy) the query is skipped and `data` stays
|
|
16
|
+
* `undefined` — consumers treat that as the signal to fall back to the
|
|
17
|
+
* per-proxy `namespacesApi` path. Imperative `getAllClusterSnapshots` /
|
|
18
|
+
* `getClusterSnapshot` remain for fire-and-forget reads.
|
|
11
19
|
*/
|
|
12
20
|
import type { AllClusterSnapshots, ClusterSnapshot } from '@/types';
|
|
13
21
|
import type { OperationContext, OdigosApiOperations } from '../types';
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import type { ReactNode } from 'react';
|
|
18
18
|
import type { DocumentNode } from 'graphql';
|
|
19
19
|
import type { InstrumentationRuleInputWire } from '@/functions/instrumentation-rule-source-scopes';
|
|
20
|
-
import type { Action, ActionFormData, AllClusterSnapshots, ClusterSnapshot, ConfigYaml, CostReductionRule, CostReductionRuleInput, DataStream, DescribeOdigos, DescribeSource, Destination, DestinationFormData, DiagnoseFormData, EffectiveConfig, EffectiveConfigInput, EnableProfilingResult, ExtendedPodInfo, FetchedConfig, GatewayInfo, GetDestinationCategoriesResult, GetPotentialDestinationsResult, HighlyRelevantOperationRule, HighlyRelevantOperationRuleInput, InstrumentationRule, K8sResourceKind, LocalUiConfigInput, Metrics, Namespace, NoisyOperationRule, NoisyOperationRuleInput, NodeCollectoInfo, PlatformType, PodInfo, ProfilingSlots, SamplingRules, SamplingRulesK8sHealthConfig, ServiceMapSources, SourceFormData, SourceProfilingResult, TestConnectionResponse, Tier, TokenPayload, Workload, WorkloadId, PeerSources } from '@/types';
|
|
20
|
+
import type { Action, ActionFormData, AllClusterSnapshots, ClusterSnapshot, ConfigYaml, CostReductionRule, CostReductionRuleInput, DataStream, DescribeOdigos, DescribeSource, Destination, DestinationFormData, DiagnoseFormData, EffectiveConfig, EffectiveConfigInput, EnableProfilingResult, ExtendedPodInfo, FetchedConfig, GatewayInfo, GetActionTypesResult, GetDestinationCategoriesResult, GetPotentialDestinationsResult, HighlyRelevantOperationRule, HighlyRelevantOperationRuleInput, InstrumentationRule, K8sResourceKind, LocalUiConfigInput, Metrics, Namespace, NoisyOperationRule, NoisyOperationRuleInput, NodeCollectoInfo, PlatformType, PodInfo, ProfilingSlots, SamplingRules, SamplingRulesK8sHealthConfig, ServiceMapSources, SourceFormData, SourceProfilingResult, TestConnectionResponse, Tier, TokenPayload, Workload, WorkloadId, PeerSources } from '@/types';
|
|
21
21
|
import type { ApolloClient, ApolloLink, FetchPolicy, MutationFetchPolicy, NormalizedCacheObject, TypePolicies, WatchQueryFetchPolicy } from '@apollo/client';
|
|
22
22
|
/**
|
|
23
23
|
* The execution context for a given operation, propagated through every
|
|
@@ -708,6 +708,7 @@ export interface OdigosApiOperations {
|
|
|
708
708
|
DELETE_DESTINATION: Operation<DeleteDestinationResult, DeleteDestinationVars>;
|
|
709
709
|
TEST_DESTINATION_CONNECTION: Operation<TestConnectionResponse, TestDestinationConnectionVars>;
|
|
710
710
|
GET_ACTIONS: Operation<GetActionsData, undefined>;
|
|
711
|
+
GET_ACTION_TYPES?: Operation<GetActionTypesResult, undefined>;
|
|
711
712
|
CREATE_ACTION: Operation<CreateActionResult, CreateActionVars>;
|
|
712
713
|
UPDATE_ACTION: Operation<UpdateActionResult, UpdateActionVars>;
|
|
713
714
|
DELETE_ACTION: Operation<DeleteActionResult, DeleteActionVars>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,r,f as t}from"../chunks/use-odigos-api-
|
|
1
|
+
import{e as o,r,f as t}from"../chunks/use-odigos-api-DHCLONPK.js";export{O as OdigosApiProvider,p as prepareNamespacePayloads,a as prepareSourcePayloads,u as useApiLazyQuery,b as useApiMutation,c as useApiQuery,d as useOdigosApi}from"../chunks/use-odigos-api-DHCLONPK.js";export{O as OdigosApiConnectionsScope}from"../chunks/connections-scope-DhNWocBO.js";import{useApolloClient as e}from"@apollo/client";import{c as s,t as i}from"../chunks/ui-components-BDSEcaSZ.js";import"react";import"react/jsx-runtime";import"@apollo/client/link/error";import"@apollo/client/link/context";import"@apollo/client/utilities";import"styled-components";import"../icons.js";import"zustand";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"../chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";const n=()=>{const s=e(),{operations:i,context:n}=o();return{multiFetch:async(o,r,e)=>{const a=i[o];return a?t(s,a,r,e,n):{results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:r.length,error:`Operation ${String(o)} not configured`}},bulkPersistSources:async(o,t)=>{const e=[];for(const a of o){const o={...n,proxyID:a},{error:c}=await r(s,i.PERSIST_SOURCES,t,o);c&&e.push(`${a}: ${c}`)}return e.length?{error:e.join(", ")}:void 0},applyConfigurations:async(o,t)=>{if(!i.UPDATE_REMOTE_CONFIG)return{error:"UPDATE_REMOTE_CONFIG not configured"};const{error:e}=await r(s,i.UPDATE_REMOTE_CONFIG,{formData:t,connectionIds:o},n);return e?{error:e}:void 0}}},m=(o,r)=>o.platformType===s.K8s?r.K8s:o.platformType===s.Vm?r.Vm:void 0,l=o=>r=>{const t=o[r.platformType];if(!t)return;const e=Object.keys(t);if(0===e.length)return;const s=i(r.schemaVersion??r.version),n=[...e].sort((o,r)=>i(r)-i(o)).find(o=>s>=i(o));return n?t[n]:void 0},f=(o,r)=>{const t={};for(const e of Object.keys(o))t[e]=r(o[e]);return t};export{m as pickByPlatform,n as useApiForConnections,l as versionedDocument,f as vmDialectMap};
|
package/lib/contexts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as ActionFormContextProvider,D as DataStreamFormContextProvider,a as DestinationFormContextProvider,R as RuleFormContextProvider,S as SamplingRuleFormType,b as SamplingRulesFormProvider,c as SourceEditFormContextProvider,d as SourceInstrumentFormContextProvider,u as useActionFormContext,e as useDataStreamFormContext,f as useDestinationFormContext,g as useRuleFormContext,h as useSamplingRulesFormContext,i as useSourceEditFormContext,j as useSourceInstrumentFormContext}from"./chunks/source-instrument-form-context-
|
|
1
|
+
export{A as ActionFormContextProvider,D as DataStreamFormContextProvider,a as DestinationFormContextProvider,R as RuleFormContextProvider,S as SamplingRuleFormType,b as SamplingRulesFormProvider,c as SourceEditFormContextProvider,d as SourceInstrumentFormContextProvider,u as useActionFormContext,e as useDataStreamFormContext,f as useDestinationFormContext,g as useRuleFormContext,h as useSamplingRulesFormContext,i as useSourceEditFormContext,j as useSourceInstrumentFormContext}from"./chunks/source-instrument-form-context-oDlfTrOD.js";export{O as OdigosProvider,c as checkVersionSupport,u as useOdigos}from"./chunks/odigos-context-BYgtdAtj.js";import{jsx as o}from"react/jsx-runtime";import{useMemo as r,useContext as t,createContext as s}from"react";export{O as OdigosApiConnectionsScope}from"./chunks/connections-scope-DhNWocBO.js";export{O as OdigosApiProvider,p as prepareNamespacePayloads,a as prepareSourcePayloads,u as useApiLazyQuery,b as useApiMutation,c as useApiQuery,d as useOdigosApi}from"./chunks/use-odigos-api-DHCLONPK.js";export{pickByPlatform,useApiForConnections,versionedDocument,vmDialectMap}from"./contexts/odigos-api.js";import"./chunks/ui-components-BDSEcaSZ.js";import"styled-components";import"./icons.js";import"zustand";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";import"@apollo/client";import"@apollo/client/link/error";import"@apollo/client/link/context";import"@apollo/client/utilities";const n=s({formType:void 0}),m=({children:e,formType:t})=>{const s=r(()=>({formType:t}),[t]);return o(n.Provider,{value:s,children:e})},l=()=>t(n);export{m as StorybookProvider,l as useStorybook};
|
package/lib/functions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{a6 as adaptInstrumentationRuleFromWire,a5 as adaptInstrumentationRuleInputForWire,b9 as buildBadgeForDesiredStatus,fb as capitalizeFirstLetter,fc as cleanObjectEmptyStringsValues,ao as compareCondition,fd as decimalsOnly,e as deepClone,dl as entityIdKey,dr as filterActions,dq as filterDestinations,b2 as filterDestinationsByStream,dp as filterSources,dd as filterSourcesByStream,fe as flattenObjectKeys,bk as formatBytes,ff as formatDuration,bY as generateId,b0 as getActionIcon,v as getConditionsBooleans,by as getContainersIcons,fg as getContainersInstrumentedCount,fh as getDeepValue,aU as getDestinationIcon,fi as getDetectedLanguageIcons,be as getEffectiveLanguage,br as getEffectiveRuntimeVersion,dm as getEntityIcon,a4 as getEntityId,dj as getEntityIdKey,dk as getEntityLabel,fj as getHealthBadgeLabel,a2 as getIdFromSseTarget,b6 as getInstrumentationRuleIcon,fk as getMainContainerLanguage,fl as getMetricForEntity,fm as getMonitorIcon,fn as getNearestTypographySize,fo as getPlatformIcon,fp as getPlatformLabel,ay as getProgrammingLanguageIcon,fq as getRecursiveValues,r as getSourceLanguageIcons,Z as getSseTargetFromId,fr as getStatusColor,dw as getStatusFromPodStatus,x as getStatusIcon,bm as getStatusTypeFromOdigosHealth,fs as getValueForRange,q as getVirtualServiceIcon,bj as getWorkloadId,b3 as getYamlFieldsForDestination,ft as hasUnhealthyInstances,fu as instrumentationRuleSourceScopesFromWire,fv as instrumentationRuleSourceScopesToWire,i as isEmpty,j as isLegalK8sLabel,bU as isOverTime,fw as isStringABoolean,fx as isTimeElapsed,bq as isValidVersion,fy as mapConditions,bc as mapDesiredStatusToConditionStatus,b1 as mapDestinationFieldsForDisplay,k as mapExportedSignals,m as mapSupportedSignals,fz as numbersOnly,fA as parseBooleanFromString,fB as parseJsonStringToPrettyString,at as prepareDestinationFormData,fC as removeEmptyValuesFromObject,s as safeJsonParse,fD as safeJsonStringify,fE as setDeepValue,fF as sleep,b4 as splitCamelString,fG as stringifyNonStringValues,t as trimVersion}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Action, type ActionFormData } from '@/types';
|
|
2
2
|
export declare const useActionFormData: () => {
|
|
3
3
|
formData: ActionFormData;
|
|
4
|
-
formErrors: Partial<Record<"type" | "disabled" | "name" | "notes" | "
|
|
4
|
+
formErrors: Partial<Record<"type" | "disabled" | "name" | "notes" | "fields" | "signals", string>>;
|
|
5
5
|
handleFormChange: (key?: string | undefined, val?: any, obj?: ActionFormData | undefined) => void;
|
|
6
6
|
resetFormData: (overrideForm?: ActionFormData | undefined) => void;
|
|
7
7
|
validateForm: (params?: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type InstrumentationRule, type InstrumentationRuleFormData } from '@/types';
|
|
2
2
|
export declare const useInstrumentationRuleFormData: () => {
|
|
3
3
|
formData: InstrumentationRuleFormData;
|
|
4
|
-
formErrors: Partial<Record<"disabled" | "conditions" | "
|
|
4
|
+
formErrors: Partial<Record<"disabled" | "conditions" | "sourceScopes" | "ruleName" | "notes" | "workloads" | "instrumentationLibraries" | "codeAttributes" | "headersCollection" | "payloadCollection" | "customInstrumentations", string>>;
|
|
5
5
|
handleFormChange: (key?: string | undefined, val?: any, obj?: InstrumentationRuleFormData | undefined) => void;
|
|
6
6
|
resetFormData: (overrideForm?: InstrumentationRuleFormData | undefined) => void;
|
|
7
7
|
validateForm: () => boolean;
|
package/lib/hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{fU as IGNORE_OUTSIDE_CLICK_ATTR,fV as useActionFormData,fW as useBodyScroll,ds as useClickNode,X as useClickNotification,dn as useContainerSize,bl as useCopy,fX as useDataStreamFormData,fY as useDestinationFormData,d as useGenericForm,fZ as useInstrumentationRuleFormData,bT as useKeyDown,bn as useOnClickOutside,f_ as useOverflow,u as usePopup,b8 as useScrollIntoViewWhen,dS as useScrollTo,dg as useSessionStorage,f$ as useSourceFormData,b7 as useTimeAgo}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/snippets/v2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{bh as ActionType,dv as Actions,du as RichTitle}from"../chunks/ui-components-BDSEcaSZ.js";export{C as CancelModal,j as DURATION_OPTIONS,g as DeleteModal,e as DurationErrorsSection,D as DynamicField,I as InstrumentationPreviewSection,N as NOISY_PERCENTAGE_OPTIONS,h as OdigosLogoTextByTier,O as OperationSection,b as PERCENTAGE_OPTIONS,f as PercentageSection,P as PresetWithCustomInput,R as RuleInfoSection,d as RuleTypeSection,c as SamplingPreviewSection,S as SignalsCheckboxList,a as SourceScopeSection,U as UpgradeModal,i as WIDE_DRAWER_WIDTH,W as WideDrawer,Y as YamlSectionCard}from"../chunks/index-DILEVYlK.js";export{C as ColoredSpan,G as ColoredSpanVariant}from"../chunks/odigos-context-BYgtdAtj.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"prism-react-renderer";import"../chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/snippets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{bh as ActionType,dv as Actions,du as RichTitle}from"./chunks/ui-components-BDSEcaSZ.js";export{C as CancelModal,j as DURATION_OPTIONS,g as DeleteModal,e as DurationErrorsSection,D as DynamicField,I as InstrumentationPreviewSection,N as NOISY_PERCENTAGE_OPTIONS,h as OdigosLogoTextByTier,O as OperationSection,b as PERCENTAGE_OPTIONS,f as PercentageSection,P as PresetWithCustomInput,R as RuleInfoSection,d as RuleTypeSection,c as SamplingPreviewSection,S as SignalsCheckboxList,a as SourceScopeSection,U as UpgradeModal,i as WIDE_DRAWER_WIDTH,W as WideDrawer,Y as YamlSectionCard}from"./chunks/index-DILEVYlK.js";export{C as ColoredSpan,G as ColoredSpanVariant}from"./chunks/odigos-context-BYgtdAtj.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a1 as ProgressKeys,
|
|
1
|
+
export{a1 as ProgressKeys,fT as useDarkMode,h as useDataStreamStore,bi as useDrawerStore,dc as useFilterStore,bZ as useModalStore,W as useNotificationStore,$ as useProgressStore,di as useSelectedStore,a0 as useSetupStore}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{g0 as Provider,g1 as animations,g2 as opacity,g3 as palettes}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SignalType } from '../signals';
|
|
2
|
-
import
|
|
2
|
+
import { type DropDataOption } from '@/components/_v2';
|
|
3
|
+
import { type Condition, FieldTypes, InputTypes, type PlatformType, type SVG } from '../common';
|
|
3
4
|
export declare enum ActionType {
|
|
4
5
|
K8sAttributes = "K8sAttributesResolver",
|
|
5
6
|
AddClusterInfo = "AddClusterInfo",
|
|
@@ -24,15 +25,50 @@ export declare enum ActionKeyTypes {
|
|
|
24
25
|
UrlTemplatizationRulesGroups = "urlTemplatizationRulesGroups",
|
|
25
26
|
ExtractAttribute = "extractAttribute"
|
|
26
27
|
}
|
|
28
|
+
export interface ActionYamlProperties {
|
|
29
|
+
name: string;
|
|
30
|
+
componentType: FieldTypes;
|
|
31
|
+
componentProperties?: string;
|
|
32
|
+
displayName?: string;
|
|
33
|
+
initialValue?: string;
|
|
34
|
+
renderCondition?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface ActionDynamicField {
|
|
37
|
+
name: string;
|
|
38
|
+
componentType: FieldTypes;
|
|
39
|
+
title?: string;
|
|
40
|
+
value?: string;
|
|
41
|
+
renderCondition?: string[];
|
|
42
|
+
type?: InputTypes;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
tooltip?: string;
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
options?: DropDataOption[];
|
|
47
|
+
}
|
|
48
|
+
export interface ActionTypeOption {
|
|
49
|
+
type: ActionType;
|
|
50
|
+
displayName: string;
|
|
51
|
+
description: string;
|
|
52
|
+
allowedSignals: SignalType[];
|
|
53
|
+
docsUrl: string;
|
|
54
|
+
fields: ActionYamlProperties[];
|
|
55
|
+
}
|
|
56
|
+
export interface GetActionTypesResult {
|
|
57
|
+
actionTypes: ActionTypeOption[] | null;
|
|
58
|
+
}
|
|
27
59
|
export interface ActionOption {
|
|
28
60
|
type?: ActionType;
|
|
29
61
|
icon?: SVG;
|
|
30
62
|
label: string;
|
|
31
63
|
description?: string;
|
|
32
64
|
allowedSignals?: SignalType[];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
minVersion?:
|
|
65
|
+
docsUrl?: string;
|
|
66
|
+
fields?: ActionYamlProperties[];
|
|
67
|
+
minVersion?: {
|
|
68
|
+
[PlatformType.K8s]?: number;
|
|
69
|
+
[PlatformType.Vm]?: number;
|
|
70
|
+
};
|
|
71
|
+
supportedPlatforms?: PlatformType[];
|
|
36
72
|
items?: ActionOption[];
|
|
37
73
|
}
|
|
38
74
|
export interface Action {
|
|
@@ -126,7 +126,8 @@ export declare enum FieldTypes {
|
|
|
126
126
|
Dropdown = "dropdown",
|
|
127
127
|
Checkbox = "checkbox",
|
|
128
128
|
Toggle = "toggle",// not used by dests, but is in form components
|
|
129
|
-
Time = "time"
|
|
129
|
+
Time = "time",
|
|
130
|
+
FieldGroup = "fieldGroup"
|
|
130
131
|
}
|
|
131
132
|
export declare enum InputTypes {
|
|
132
133
|
Text = "text",
|
package/lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as ActionKeyTypes,g as ActionType,
|
|
1
|
+
export{f as ActionKeyTypes,g as ActionType,eN as AgentInjectedReason,eO as BooleanOperation,au as CodeAttributesKeyTypes,eP as ConditionType,_ as Crud,C as CustomInstrumentationsKeyTypes,ba as DesiredStateProgress,eQ as DestinationTypes,E as EntityTypes,ai as ExtractionDataFormat,l as FieldTypes,G as GolangCustomProbe,H as HeadersCollectionKeyTypes,dU as InputTypes,eR as InstallationMethod,eS as InstallationStatus,n as InstrumentationRuleType,eT as IntrumentationStatus,J as JavaCustomProbe,eU as JsonOperation,ab as K8sAttributesFrom,K as K8sResourceKind,eV as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,eW as ListDirection,eX as NumberOperation,eY as OtelDistroName,eZ as OtherEntityTypes,aw as PayloadCollectionKeyTypes,c as PlatformType,e_ as PodContainerLifecycleStatus,e$ as PodContainerStatus,f0 as PodPhase,f1 as Profile,bt as ProgrammingLanguages,f2 as SIGNAL_KEY_TO_TYPE,f3 as SIGNAL_TYPE_TO_KEY,f4 as SignalKey,S as SignalType,f5 as SortDirection,o as StatusType,f6 as StringOperation,b as Tier,f7 as WorkloadRolloutReason,dx as WorkloadRolloutStatus}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/visuals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{f8 as VISUAL_ODIGOS_LOGO_HEIGHT,f9 as VISUAL_ODIGOS_LOGO_WIDTH,eL as VisualGreenRings,fa as VisualOdigosLogo,c8 as VisualPurpleRings}from"./chunks/ui-components-BDSEcaSZ.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"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{useMemo as n,useContext as o,createContext as a,Fragment as s}from"react";import{t as i,T as u,P as l,u as c,a as p,b as d,c as f}from"./ui-components-CrXELmQx.js";import h from"styled-components";const m=a({platformType:l.K8s,tier:u.Community,version:"v0.0.0"}),v=({children:t,platformType:r,tier:o,version:a})=>{const s=n(()=>({platformType:r,tier:o,version:a}),[r,o,a]);return e(m.Provider,{value:s,children:t})},g=(e,t)=>!t||i(e)>=i(t),y=e=>{const t=o(m),r=g(t.version,e),n=t.platformType===l.Vm;return{...t,isVersionSupported:r,isVm:n,isEnterprise:t.tier===u.Onprem}};function x(){return{sources:[],namespaces:[],languages:[]}}function k(e){return!e||!e.sources?.length&&!e.namespaces?.length&&!e.languages?.length}function S(e){return e?{sources:e.sources?[...e.sources]:[],namespaces:e.namespaces?[...e.namespaces]:[],languages:e.languages?[...e.languages]:[]}:{sources:[],namespaces:[],languages:[]}}function A(e){return null==e||0===e}function T(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 R(e){return k(e.sourceScopes)?null:e.sourceScopes}function P(e){return R(e)}function b(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 D(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function M(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?M(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function C(e){return"all"===e.operationType?null:"httpServer"===e.operationType?M(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function $(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),percentageAtMost:b(e),operation:I(e)}}function E(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),error:e.keepErrors,durationAtLeastMs:"Duration"===e.ruleType?D(e):null,percentageAtLeast:b(e),operation:C(e)}}function w(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),percentageAtMost:b(e)??0,operation:C(e)}}function L(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:I(e),percentageAtMost:b(e),notes:e.notes||null}}function O(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),error:"Error"===e.ruleType,durationAtLeastMs:"Duration"===e.ruleType?D(e):null,operation:C(e),percentageAtLeast:b(e),notes:e.notes||null}}function N(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:C(e),percentageAtMost:b(e)??0,notes:e.notes||null}}const H=["5000","1000","500","100","50"],K=["50","25","10","1","0.5","0.1","0"];function j(e){if(null==e)return{percentageMode:"all",percentagePreset:"0",customPercentage:""};const t=K.find(t=>Number(t)===e);return t?{percentageMode:"sample",percentagePreset:t,customPercentage:""}:{percentageMode:"sample",percentagePreset:"custom",customPercentage:String(e)}}function z(e){if(!e)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};const t=e;if(t.httpServer){return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""}}return 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 F(e){const t=T(),r=S(e.rule.sourceScopes);const n=function(e){return"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=function(e){const t=e.rule.operation;if(!t)return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""};if(t.httpServer)return{operationType:"httpServer",routeType:t.httpServer.routePrefix?"routePrefix":"route",route:t.httpServer.route||t.httpServer.routePrefix||"",serverAddress:"",method:t.httpServer.method||"",kafkaTopic:""};if(t.httpClient)return{operationType:"httpClient",routeType:t.httpClient.templatedPathPrefix?"routePrefix":"route",route:t.httpClient.templatedPath||t.httpClient.templatedPathPrefix||"",serverAddress:t.httpClient.serverAddress||"",method:t.httpClient.method||"",kafkaTopic:""};return{operationType:"all",routeType:"route",route:"",serverAddress:"",method:"",kafkaTopic:""}}(e),a=A(u=e.rule.percentageAtMost)?{percentageMode:"all",percentagePreset:"0",customPercentage:""}:j(u);break;case"highlyRelevant":o=z(e.rule.operation),a=j(e.rule.percentageAtLeast),s=function(e){if(null==e)return{durationPreset:"500",customDurationMs:""};const t=H.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=z(e.rule.operation),a=j(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}}var X;!function(e){e.Default="default",e.Action="action",e.Endpoint="endpoint",e.Scope="scope",e.Duration="duration"}(X||(X={}));const J=[X.Action,X.Endpoint,X.Scope,X.Duration],V=h.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
|
-
`,B=h.span`
|
|
7
|
-
display: inline;
|
|
8
|
-
cursor: help;
|
|
9
|
-
text-decoration: underline dotted;
|
|
10
|
-
text-underline-offset: 3px;
|
|
11
|
-
`,W=h.div`
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-direction: column;
|
|
14
|
-
gap: 4px;
|
|
15
|
-
background-color: ${({theme:e})=>e.v2.colors.black[500]};
|
|
16
|
-
border-radius: 4px;
|
|
17
|
-
padding: 8px;
|
|
18
|
-
max-width: 300px;
|
|
19
|
-
`,_=({items:t,children:n})=>{const{popupRef:o,popupOpen:a,setPopupOpen:s,popupPosition:i,handlePosition:u}=c({positionMode:"viewport",defaultClientHeight:48,defaultClientwidth:240}),l=e=>{u(e.clientX,e.clientY),s("mouseleave"!==e.type)};return r(B,{onMouseEnter:l,onMouseMove:l,onMouseLeave:l,children:[n,e(p,{ref:o,isOpen:a,top:i.top,left:i.left,asPortal:!0,style:{backgroundColor:"transparent",border:"none"},borderRadius:"0",padding:"0",maxWidth:"300px",children:e(W,{children:t.map((t,r)=>e(d,{size:f.XXXS,children:t},r))})})]})},q=({parts:n})=>{const o=n.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text.length>0);return e(t,{children:o.map((n,o)=>{const a=e(V,{$variant:n.variant,$isMono:J.includes(n.variant),children:n.text});return r(s,{children:[0!==o&&e(t,{children:" "}),n.tooltipItems?.length?e(_,{items:n.tooltipItems,children:a}):a]},`${n.variant}-${o}`)})})};var G;!function(e){e.Noisy="noisy",e.HighlyRelevant="highly-relevant",e.CostReduction="cost-reduction"}(G||(G={}));const Y=[{value:G.Noisy,label:"1. Noisy Operations",tooltip:"Rules that reduce noise from high-volume, low-value operations"},{value:G.HighlyRelevant,label:"2. Highly Relevant Operations",tooltip:"Rules that prioritize important traces for retention"},{value:G.CostReduction,label:"3. Cost Reduction",tooltip:"Rules that optimize costs by sampling less critical data"}],Q={[G.Noisy]:"This is the most efficient way to sample (with Head Sampling). Prefer to use it where possible.",[G.HighlyRelevant]:'Any trace from the "Noisy Operations" category is sampled prior to checking highly relevance.',[G.CostReduction]:"Cost reduction rules use Tail Sampling to drop traces that are unlikely to be useful for debugging or monitoring."},U={[G.Noisy]:"Noisy Operations rules list",[G.HighlyRelevant]:"Highly Relevant Operations rules list",[G.CostReduction]:"Cost Reduction rules list"},Z={[G.Noisy]:"noisy",[G.HighlyRelevant]:"highlyRelevant",[G.CostReduction]:"costReduction"},ee={noisy:G.Noisy,highlyRelevant:G.HighlyRelevant,costReduction:G.CostReduction};function te(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 re(e){return`any service in namespace '${e}'`}function ne(e){return`${e} services`}function oe(e){const t=function(e){if(!e)return[];const t=[];for(const r of e.sources??[]){const e=te(r);e&&t.push(e)}for(const r of e.namespaces??[])r&&t.push(re(r));for(const r of e.languages??[])r&&t.push(ne(r));return t}(e);if(!t.length)return[{text:" in ",variant:X.Default},{text:"any service in the cluster",variant:X.Scope}];const r=[{text:" in ",variant:X.Default}],n=t.slice(0,2),o=t.slice(2);return n.forEach((e,t)=>{t>0&&r.push({text:", ",variant:X.Default}),r.push({text:e,variant:X.Scope})}),o.length>0&&r.push({text:` + ${o.length} more`,variant:X.Default,tooltipItems:o}),r}function ae(e,t){const r=(n=e).startsWith("/")?n.slice(1):n;var n;return t?`${t} /${r}`:`/${r}`}function se(e){const t=e.method;return e.route?[{text:" for server endpoint ",variant:X.Default},{text:ae(e.route,t),variant:X.Endpoint}]:e.routePrefix?[{text:" for endpoints under ",variant:X.Default},{text:ae(e.routePrefix,t),variant:X.Endpoint}]:[]}function ie(e){const t=[];if(A(e.percentageAtMost)?t.push({text:"Drop all traces",variant:X.Action}):(t.push({text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default})),e.operation){const r=e.operation.httpServer,n=r?function(e){const t=e.method;return e.route?[{text:" where the root span is ",variant:X.Default},{text:ae(e.route,t),variant:X.Endpoint}]:e.routePrefix?[{text:" where the root span is under ",variant:X.Default},{text:ae(e.routePrefix,t),variant:X.Endpoint}]:[]}(r):[];n.length>0&&t.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(t.push({text:" to ",variant:X.Default}),a){const r=ae(a,e);s&&(t.push({text:"server address ",variant:X.Default}),t.push({text:s,variant:X.Endpoint}),t.push({text:" ",variant:X.Default})),t.push({text:r,variant:X.Endpoint})}else s&&(t.push({text:"server address ",variant:X.Default}),t.push({text:s,variant:X.Endpoint}))}}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...oe(e.sourceScopes)),t}function ue(e){const t=[];if(null!=e.percentageAtLeast?(t.push({text:`Keep ${e.percentageAtLeast}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default})):t.push({text:"Keep all traces",variant:X.Action}),e.operation){const r=e.operation.httpServer;r&&t.push(...se(r))}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...oe(e.sourceScopes)),!e.error&&null!=e.durationAtLeastMs&&e.durationAtLeastMs>0&&(t.push({text:" with duration > ",variant:X.Default}),t.push({text:`${e.durationAtLeastMs}ms`,variant:X.Duration})),t}function le(e){const t=[];if(t.push({text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action}),t.push({text:" of traces",variant:X.Default}),e.operation){const r=e.operation.httpServer,n=r?se(r):[];n.length>0&&t.push(...n);const o=e.operation.kafkaConsumer?.kafkaTopic;o&&0===n.length&&(t.push({text:" from ",variant:X.Default}),t.push({text:`topic '${o}'`,variant:X.Endpoint}))}else t.push({text:" on ",variant:X.Default}),t.push({text:"any operation",variant:X.Endpoint});return t.push(...oe(e.sourceScopes)),t}function ce(e){return e.error?"Error":null!=e.durationAtLeastMs?"Duration":"Relevance"}function pe(e,t,r){const n=Z[t],o=[];for(const a of e)switch(t){case G.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:ie(e),category:n});break;case G.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:ue(e),category:n,typeBadge:ce(e)});break;case G.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:le(e),category:n})}return o}function de(e,t){switch(e){case"noisy":return ie(t);case"highlyRelevant":return ue(t);case"costReduction":return le(t)}}function fe(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 he(e,t){const r=fe(e,t.samplingId,t.rule.ruleId,t.category);return r?{...r,summary:de(r.category,r.rule)}:null}function me(e,t){const r=fe(e,t.samplingId,t.ruleId,t.category);return r?{...r,summary:de(r.category,r.rule)}:null}function ve(e,t,r){for(const n of e){const o=fe(e,n.id,t,r);if(o)return{...o,summary:de(o.category,o.rule)}}return null}function ge(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 ye(e){return null==e?null:e}function xe(e,t){return JSON.stringify({sourceScopes:ge(e),operation:ye(t)})}function ke(e,t,r,n){return JSON.stringify({sourceScopes:ge(e),error:t??!1,durationAtLeastMs:(o=r,null==o?null:o),operation:ye(n)});var o}function Se(e,t){return JSON.stringify({sourceScopes:ge(e),operation:ye(t)})}function Ae(e,t,r,n){switch(t){case"noisy":{const t=xe(r.sourceScopes,r.operation);for(const r of e)for(const e of r.noisyOperations)if((!n||e.ruleId!==n)&&xe(e.sourceScopes,e.operation)===t)return e.ruleId;return null}case"highlyRelevant":{const t=ke(r.sourceScopes,r.error,r.durationAtLeastMs,r.operation);for(const r of e)for(const e of r.highlyRelevantOperations)if((!n||e.ruleId!==n)&&ke(e.sourceScopes,e.error,e.durationAtLeastMs,e.operation)===t)return e.ruleId;return null}case"costReduction":{const t=Se(r.sourceScopes,r.operation);for(const r of e)for(const e of r.costReductionRules)if((!n||e.ruleId!==n)&&Se(e.sourceScopes,e.operation)===t)return e.ruleId;return null}}}function Te(e){if(!e||!e.enabled)return[{text:"Auto rule is ",variant:X.Default},{text:"disabled",variant:X.Action}];return[{text:`Keep ${e.keepPercentage??0}%`,variant:X.Action},{text:" of ",variant:X.Default},{text:"traces for kubelet health probes in the entire cluster",variant:X.Scope}]}function Re(e){return!0===e.error&&k(e.sourceScopes)&&!e.operation&&(null==e.percentageAtLeast||100===e.percentageAtLeast)}function Pe(e){for(const t of e){const e=t.highlyRelevantOperations.find(Re);if(e)return{rule:e,samplingId:t.id}}return null}function be(e){return!e||e.disabled?[{text:"Auto rule is ",variant:X.Default},{text:"disabled",variant:X.Action}]:[{text:"Keep all traces",variant:X.Action},{text:" of ",variant:X.Default},{text:"error traces across the entire cluster",variant:X.Scope}]}function De(e){return k(e.sourceScopes)&&!e.operation}function Me(e){for(const t of e){const e=t.costReductionRules.find(De);if(e)return{rule:e,samplingId:t.id}}return null}function Ie(e){return!e||e.disabled?[{text:" is ",variant:X.Default},{text:"disabled",variant:X.Action}]:[{text:`Keep at most ${e.percentageAtMost}%`,variant:X.Action},{text:" of ",variant:X.Default},{text:"traces across the entire cluster",variant:X.Scope}]}export{Q as A,U as B,q as C,X as D,oe as E,A as F,w as G,E as H,$ as I,v as O,ee as R,G as S,Ie as a,be as b,g as c,Te as d,ie as e,ue as f,T as g,le as h,k as i,ve as j,Pe as k,Me as l,x as m,S as n,pe as o,N as p,O as q,he as r,L as s,me as t,y as u,F as v,de as w,Z as x,Ae as y,Y as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as n,useContext as r,createContext as s,useRef as o,useEffect as i}from"react";import{d as l,e as d,A as c,f as u,g as m,i as p,F as h,h as f,j as g,D as v,m as b,S as y,s as D,k as E,l as S,I as k,H as C,C as A,G as F,J as I,n as w,K as N,T as x,E as R}from"./ui-components-CrXELmQx.js";import{d as P}from"./use-odigos-api-UctF_jx_.js";import{n as T,m as O,i as L,b as M,a as U,d as j,v as K,g as G,u as V}from"./helpers-zByTbpzZ.js";const _={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},q=s(null),H="All row fields are required",z="At least one row is required",J=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!("string"==typeof(n=a)?!n.trim():p(n));var n}),Q=({children:r})=>{const[s,o]=t(null),i=l(_),f=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),g=a(e=>{var t;i.resetFormData((({type:e,name:t,notes:a,disabled:n,signals:r,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!n,signals:r??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o((t=e.type,c.find(e=>e.type===t)??null))},[]),v=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(_)};const e=(e=>{const t=d(e),a=t.fields||{},n=a[u.UrlTemplatizationRulesGroups];n?.length&&(a[u.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const r=a[u.AttributeNamesToDelete];r?.length&&(a[u.AttributeNamesToDelete]=r.filter(e=>!!e?.trim()));const s=a[u.Renames];s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim())));const o=a[u.ExtractAttribute];return o?.extractions?.length&&(a[u.ExtractAttribute]={extractions:o.extractions.map(e=>({targetAttributeName:e.targetAttributeName?.trim()||"",lookupKey:e.lookupKey?.trim()||"",dataFormat:e.dataFormat||"",regex:e.regex?.trim()||""})).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),t.fields=a,t})(i.formData),t={};p(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const n={},r=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(r[u.CollectContainerAttributes]||r[u.CollectReplicaSetAttributes]||r[u.CollectWorkloadId]||r[u.CollectClusterId]),t=!r[u.LabelsAttributes]?.length,a=!r[u.AnnotationsAttributes]?.length;e&&t&&a&&(n[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=r[u.LabelsAttributes];s?.some(e=>!J(e,["labelKey","attributeKey","fromSources"]))&&(n[u.LabelsAttributes]=H);const o=r[u.AnnotationsAttributes];o?.some(e=>!J(e,["annotationKey","attributeKey","fromSources"]))&&(n[u.AnnotationsAttributes]=H);break}case m.AddClusterInfo:{const e=r[u.ClusterAttributes];e?.length?e.some(e=>!J(e,["attributeName","attributeStringValue"]))&&(n[u.ClusterAttributes]=H):n[u.ClusterAttributes]=z;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=r[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(n[u.AttributeNamesToDelete]=H):n[u.AttributeNamesToDelete]=e.length?H:z;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(r[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(n[u.Renames]=H):n[u.Renames]=e.length?H:z;break}case m.PiiMasking:{const e=r[u.PiiCategories];e?.length||(n[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=r[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(n[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case m.ExtractAttribute:{const e=r[u.ExtractAttribute]?.extractions||[],t=s[u.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),a=!!e.lookupKey?.trim();return a!==!!e.dataFormat||t===a}))n[u.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 a=e.targetAttributeName?.trim()||"";return!!t.has(a)||(t.add(a),!1)})&&(n[u.ExtractAttribute]="Each new span attribute name must be unique")}else n[u.ExtractAttribute]=t.length?H:z;break}}return n})(s.type,e,i.formData)),i.handleErrorChange(void 0,void 0,t);return{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),b=n(()=>({selectedOption:s,onSelectOption:f,loadAction:g,genericForm:i,validateFormData:v}),[s,f,g,i,v]);return e(q.Provider,{value:b,children:r})},W=()=>{const e=r(q);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:r,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[v,b]=t(void 0),[y,D]=t(null),E=o(null),S=l($),k=a(e=>{S.resetFormData({name:e}),S.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),b(e),D(null),E.current=null},[]),C=a(()=>{const e=d(S.formData),t=(e=>{const t={};return e.name?g(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);S.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return u(a),{errorMessage:a,preparedFormData:e}},[S]),A=a(async e=>{const{errorMessage:t,preparedFormData:a}=C();if(t)return;const n=i.find(e=>e.name===a.name&&e.name!==m);if(n)return E.current=e,void D({preparedFormData:a,existingName:n.name,editingName:v});await e(a)},[C,i,m,v]),F=a(async()=>{const e=E.current,t=y?.preparedFormData;E.current=null,D(null),e&&t&&await e(t)},[y]),I=a(()=>{E.current=null,D(null)},[]),w=n(()=>({genericForm:S,loadDataStream:k,editingName:v,validateFormData:C,requestSubmit:A,pendingMerge:y,confirmMerge:F,cancelMerge:I,errorMessage:c,excludeName:m,setExcludeName:p}),[S,k,v,C,A,y,F,I,c,m]);return e(B.Provider,{value:w,children:r})},Y=()=>{const e=r(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},ee={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(Z)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},te=s(ee),ae=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:n,displayName:r,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=D(n,{});return{componentType:a,renderCondition:o,name:t,title:r,value:s,placeholder:l.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(l.values)?l.values.map(e=>({id:e,label:e})):void 0,...l}}),ne=({children:r})=>{const{selectedStreamName:s}=f(),{items:o}=P().destinationsApi.useDestinations(),[c,u]=t(null),[m,g]=t(ee.unsavedDestinations),S=n(()=>"number"==typeof c?.unsavedIdx?m[c.unsavedIdx]:void 0,[c,m]),k=a((e,t)=>{c&&(g(t=>[...t,{...e,option:c.option}]),u(t?e=>e?{...e,listType:v.UNSAVED,unsavedIdx:m.length}:null:null))},[c,m.length]),C=a((e,t,a)=>{c&&(g(a=>a.map((a,n)=>n===e?{...a,...t,option:c.option}:a)),u(a?e=>e?{...e,listType:v.UNSAVED}:null:null))},[c]),A=a(e=>{g(t=>t.filter((t,a)=>a!==e)),u(null)},[]),F=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(S)return void F.resetFormData({...S.formData});if(c.listType===v.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void F.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:s,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=b(c.option.supportedSignals);F.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(y.Logs),metrics:e.includes(y.Metrics),traces:e.includes(y.Traces),profiles:e.includes(y.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,S]);const I=a(e=>{F.resetFormData(),F.handleErrorChange(void 0,void 0,{}),u(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const n of t){const t=n.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const n=D(e.fields,{}),r={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:a?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:a?a.fields.map(e=>({...e,initialValue:n[e.name]??e.initialValue})):[]},s=ae(r.fields);u({listType:v.EXISTS,option:r,dynamicFields:s})},[]),N=a(()=>{const e=d(F.formData),t={};c?.dynamicFields.forEach(({name:a,required:n})=>{if(n){const n=e.fields.find(e=>e.key===a)?.value;p(n)&&(t[a]=h.FIELD_IS_REQUIRED)}});return E(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),F.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[F,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:I,loadDestination:w,genericForm:F,validateFormData:N,unsavedDestinations:m,thisUnsavedDestination:S,setUnsavedDestinations:g,addUnsavedDestination:k,updateUnsavedDestination:C,deleteUnsavedDestination:A},children:r})},re=()=>r(te),se={disabled:!1,ruleName:"",notes:"",sourceScopes:O(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:r,sourceOptions:s=[],namespaceOptions:o=[]})=>{const[i,c]=t(null),u=l(se),m=a(e=>{u.resetFormData(),u.handleErrorChange(void 0,void 0,{}),c(e)},[]),p=a(e=>{var t;u.resetFormData((({ruleName:e,notes:t,disabled:a,sourceScopes:n,instrumentationLibraries:r,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,sourceScopes:T(n),workloads:null,instrumentationLibraries:r??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),u.handleErrorChange(void 0,void 0,{}),c((t=e.type,k.find(e=>e.type===t)??null))},[]),h=a(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e),a={...t,sourceScopes:L(t.sourceScopes)?null:t.sourceScopes,workloads:null};return a.headersCollection?.[C.HeaderKeys]?.length&&(a.headersCollection[C.HeaderKeys]=a.headersCollection[C.HeaderKeys].map(e=>e.trim()).filter(e=>e)),a.customInstrumentations?.[A.Golang]?.length&&(a.customInstrumentations[A.Golang]=a.customInstrumentations[A.Golang].map(e=>new F(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})),a.customInstrumentations?.[A.Java]?.length&&(a.customInstrumentations[A.Java]=a.customInstrumentations[A.Java].map(e=>new I(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),a})(u.formData),t=((e,t)=>{const a={};switch(e){case w.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case w.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case w.HeadersCollection:t.headersCollection?.[C.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case w.CustomInstrumentation:{const e=t.customInstrumentations?.[A.Golang]||[],n=t.customInstrumentations?.[A.Java]||[];if(!e.length&&!n.length){a.customInstrumentations="Custom instrumentation are required";break}const r=e.findIndex(e=>!new F(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==r){a.customInstrumentations=`Golang probe #${r+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=n.findIndex(e=>!new I(e.className,e.methodName).Verify());if(-1!==s){a.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}break}}return a})(i.type,e);return u.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[u,i]),f=n(()=>({selectedOption:i,onSelectOption:m,loadRule:p,genericForm:u,validateFormData:h,sourceOptions:s,namespaceOptions:o}),[i,m,p,u,h,s,o]);return e(oe.Provider,{value:f,children:r})},le=()=>{const e=r(oe);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var de;!function(e){e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"}(de||(de={}));const ce=s(null),ue=["50","25","10","1"];function me(e){const t=String(e);return ue.includes(t)?t:"custom"}const pe=({category:r,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(G(r)),[p,h]=t(null);i(()=>{m(G(r)),h(null)},[r]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),g=a(()=>{m(G(r)),h(null)},[r,m]),v=n(()=>({formType:de.Create,category:r,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[r,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:r,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:u})=>{const[m,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{r!==v.current&&(v.current=r,r&&s?(g(K(r)),y(null),p(!0)):(p(!1),y(null)))},[r,s]);const D=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),E=a(()=>{r&&(g(K(r)),y(null),p(!0))},[r,g]),S=a(()=>{p(!1),y(null)},[]),k=n(()=>({formType:de.View,data:r,isEditing:m,formData:h,handleChange:D,handleEdit:E,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[r,m,h,D,E,S,b,d,c]);return e(ce.Provider,{value:k,children:u})};function fe(e){const[a,r]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>me(e)),[l,d]=t(()=>"custom"===me(e)?String(e):"");i(()=>{r(0===e?"all":"sample");const t=me(e);o(t),d("custom"===t?String(e):"")},[e]);const c=n(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:r,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=n(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},ve=({enabled:a,dropPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=n(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},be=({enabled:a,children:r})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=n(()=>M(s?{disabled:!1}:null),[s]),d=n(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:r})},ye=t=>{switch(t.formType){case de.Create:return e(pe,{...t});case de.View:return e(he,{...t});case de.EditAutoNoisy:return e(ge,{...t});case de.EditAutoCostReduction:return e(ve,{...t});case de.EditAutoHighlyRelevant:return e(be,{...t})}};function De(e){const t=r(ce);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 Ee={otelServiceName:"",currentStreamName:""},Se=s(null),ke=({children:r})=>{const[s,o]=t(void 0),i=l(Ee),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),u=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),m=n(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(Se.Provider,{value:m,children:r})},Ce=()=>{const e=r(Se);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ae=new Set([N.StaticPod]),Fe=e=>{const t=e.workloads.filter(({selected:e})=>e).length,a=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===a,isSomeSourced:t>0&&t<a,isFutureApps:e.selected||!1}},Ie=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:n}=Fe(e);return t||a||n}return!0},we=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),Ne=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),xe=(e,t,a)=>{const n=[];return t.workloads.forEach(r=>{const s=e?.workloads.find(e=>e.name===r.name&&e.kind===r.kind);r.selected!==s?.selected&&n.push({namespace:t.name,name:r.name,kind:r.kind,selected:r.selected||!1,currentStreamName:a})}),n},Re=({children:r,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=V(),c=l===x.Onprem,{capabilities:u}=P(),m=u.canInstrumentNamespaces,{selectedStreamName:p}=f(),[h,g]=t(!1),[v,b]=t(null),[y,D]=t([]);i(()=>{v&&D(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(v,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),n=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(n);return e.forEach(e=>{const t=a.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const a=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);a&&(a.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Ae.has(e.kind)&&!c||(e.selected=!0)})}),a}return n})})},[v,s,o]);const{formDiff:E,isFormDirty:S}=n(()=>{const e=((e,t,a,n)=>{const r={};return e.forEach(e=>{e.namespaces.forEach(s=>{const o=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===s.name);if(!n){const t=xe(o,s,a);return void(t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t)))}const i=s.selected||!1;if(i!==o?.selected)r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push({namespace:s.name,selected:i,currentStreamName:a}),i?r[e.clusterId]=r[e.clusterId].filter(e=>e.namespace!==s.name||e.namespace===s.name&&(!e.name||!e.kind)):s.workloads.forEach(t=>{t.selected&&r[e.clusterId].push({namespace:s.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=xe(o,s,a);t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t))}})}),r})(y,v?.clusters||[],p,m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[y,v,p,m]),k=a(e=>!c&&Ae.has(e),[c]),C=a(({clusterId:e,workloadId:t,selected:a,auto:n})=>{D(r=>{const s=d(r),o=s.findIndex(t=>t.clusterId===e);if(-1===o)return s;const i=s[o].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return s;if(t.kind&&t.name){const e=s[o].namespaces[i].workloads.findIndex(e=>e.name===t.name&&e.kind===t.kind);if(-1===e)return s;const n="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=n,m)if(n){s[o].namespaces[i].workloads.filter(e=>!k(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else if(m){const e="boolean"==typeof n?n:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{k(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}else{const e="boolean"==typeof a?a:"boolean"!=typeof n||n;s[o].namespaces[i].workloads.forEach(t=>{e&&k(t.kind)||(t.selected=e)})}return s})},[k,m]),A=a(({clusterId:e,namespaceName:t,boolean:a,searchText:n="",searchBy:r="",filters:s})=>{D(o=>{const i=d(o),l=r===R.Namespace?n:"",c=r===R.Source?n:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((n,r)=>{e&&n.clusterId!==e||n.namespaces.forEach(({name:e,workloads:n},o)=>{if(!t||e===t)if(u)if(t){if(n.forEach((e,t)=>{a&&k(e.kind)||we(e,c,s||{showOnlySelected:!1})&&(i[r].namespaces[o].workloads[t].selected=a)}),m){const e=i[r].namespaces[o].workloads.filter(e=>!k(e.kind)).every(e=>e.selected);i[r].namespaces[o].selected=e}}else{if(!Ie(i[r].namespaces[o],l,s||{showOnlySelected:!1}))return;m&&(i[r].namespaces[o].selected=a),n.forEach((e,t)=>{a&&k(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})}else m&&(i[r].namespaces[o].selected=a),n.forEach((e,t)=>{a&&k(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})})}),i})},[k,m]);return e(Ne.Provider,{value:{snapshots:v,setSnapshots:b,isFetching:h,setIsFetching:g,formData:y,handleSourceChange:C,handleSelectAll:A,formDiff:E,isFormDirty:S},children:r})},Pe=()=>r(Ne);export{Q as A,X as D,Ae as E,ie as R,de as S,ne as a,ye as b,ke as c,Re as d,Y as e,re as f,le as g,De as h,Ce as i,Pe as j,we as k,Ie as l,Fe as m,W as u};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{useMemo as e,useContext as t,createContext as r,useCallback as a,useState as n,useEffect as o}from"react";import{HttpLink as i,from as s,split as c,ApolloClient as d,InMemoryCache as u,ApolloProvider as l,useLazyQuery as E,useApolloClient as f,useQuery as T,gql as _}from"@apollo/client";import{jsx as S}from"react/jsx-runtime";import{onError as y}from"@apollo/client/link/error";import{setContext as R}from"@apollo/client/link/context";import{getMainDefinition as p}from"@apollo/client/utilities";import{W as m,F as O,p as A,o as I,Z as N,_ as C,E as h,P as g,T as L,h as P,$ as G,a0 as v,a1 as U,a2 as D,a3 as w,a4 as F,a5 as M}from"./ui-components-CrXELmQx.js";const k=e=>{if(!e)return!1;const t=e.toLowerCase();return t.includes("authentication required")||t.includes("authentication expired")||t.includes("http 401")},b=r(null),H=()=>{const e=t(b);if(!e)throw new Error("[ui-kit] useOdigosApi() / useXxxApi() called outside of <OdigosApiProvider>. Make sure the host app mounts the provider at its layout level.");return e},W=({apolloConfig:t,operations:r,context:a,children:n})=>{const o=e(()=>(e=>{const t=new i({uri:e.httpUrl,credentials:e.credentials??"same-origin"}),r=y(({graphQLErrors:t,networkError:r})=>{t&&t.length>0&&t.some(e=>k(e.message))&&e.onAuthError?.(),r&&(401===r.statusCode||k(r.message))&&e.onAuthError?.()}),a=R(async(t,r)=>{const a={...r.headers};if(e.authHeader){const t=await e.authHeader();Object.assign(a,t)}return e.csrfHeader&&Object.assign(a,e.csrfHeader()),{headers:a}}),n=[];e.additionalLinks?.length&&n.push(...e.additionalLinks),n.push(a,r,t);let o=s(n);e.wsLink&&(o=c(({query:e})=>{const t=p(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const l=e.defaultFetchPolicies;return new d({link:o,cache:new u({addTypename:e.addTypename??!0,typePolicies:e.cacheTypePolicies}),defaultOptions:{watchQuery:{fetchPolicy:l?.watchQuery??"cache-and-network"},query:{fetchPolicy:l?.query??"cache-first"},mutate:{fetchPolicy:l?.mutate??"network-only"}}})})(t),[t.httpUrl,t.wsLink,t.addTypename,t.credentials]),E=e(()=>({operations:r,context:a,apolloConfig:t}),[r,a,t]);return S(l,{client:o,children:S(b.Provider,{value:E,children:n})})},Y=b,x=(e,t)=>{if(e)return"string"==typeof e?e:N(e,t)},K=e=>{const{addNotification:t}=m(),r=(r,a,n,o,i)=>t({type:r,title:a,message:n,crdType:e,target:x(o,e),hideFromHistory:i});return{notify:r,notifyError:(e,t,a)=>r(I.Error,e,t,a),notifySuccess:(e,t,a)=>r(I.Success,e,t,a),notifyPending:(e,t)=>r(I.Default,"Pending",e,t,!0),notifyReadonly:()=>{t({type:I.Warning,title:A.READONLY,message:O.READONLY_WARNING,hideFromHistory:!0})}}},V=e=>{e({type:I.Warning,title:A.READONLY,message:O.READONLY_WARNING,hideFromHistory:!0})},$=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),B=(e,t)=>{if(e)return"function"==typeof e?e(t):e},j=e=>{if(!e)return"Unknown error";if(e instanceof Error)return e.cause instanceof Error?e.cause.message:e.message;if("object"==typeof e){const t=e;return t.cause?.message||t.message||String(e)}return String(e)},q=(e,t)=>e.client??t,Q=async(e,t,r,a,n)=>{if(!t)return{error:"Query operation not configured"};if(t.canRun&&!t.canRun(a))return{data:void 0};if(t.run)try{return await t.run(q(t,e),r,a)}catch(e){return{error:j(e)}}const o=B(t.document,a);if(!o)return{error:"Query operation not supported in this context"};const i=t.transformVariables?t.transformVariables(r,a):r,s=q(t,e);try{const e=await s.query({query:o,variables:i,fetchPolicy:n??"network-only"});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:e.error?j(e.error):void 0}}catch(e){return{error:j(e)}}},z=async(e,t,r,a)=>{if(!t)return{error:"Mutation operation not configured"};if(t.canRun&&!t.canRun(a))return{data:void 0};if(t.run)try{return await t.run(q(t,e),r,a)}catch(e){return{error:j(e)}}const n=B(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};const o=t.transformVariables?t.transformVariables(r,a):r,i=q(t,e);try{const e=await i.mutate({mutation:n,variables:o});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:void 0}}catch(e){return{error:j(e)}}},J=async(e,t,r,a,n)=>{if(!t)return $("Multi fetch operation not configured");if(!r.length)return $("No proxy ids supplied for multi fetch");const o=q(t,e);if(t.transformVariablesMulti&&(t.documentMulti||t.document)){const e=t.transformVariablesMulti(r,a,n),i=[];for(const r of e)try{const e=await o.query({query:r.document,variables:r.variables,fetchPolicy:"network-only"});t.transformMultiResult?t.transformMultiResult(e.data,n).forEach(e=>i.push(e)):r.proxyIDs.forEach(t=>{i.push({proxyID:t,success:!e.error,data:e.data,error:e.error?.message})})}catch(e){const t=j(e);r.proxyIDs.forEach(e=>i.push({proxyID:e,success:!1,error:t}))}const s=i.filter(e=>e.success).length,c=i.length-s,d=Array.from(new Set(i.filter(e=>!!e.error).map(e=>e.error)));return{results:i,allSucceeded:0===c,anySucceeded:s>0,successCount:s,failureCount:c,error:d.length?d.join(", "):void 0}}const i=await Promise.all(r.map(async r=>{const o={...n,proxyID:r},i=await Q(e,t,a,o);return{proxyID:r,success:!i.error,data:i.data,error:i.error}})),s=i.filter(e=>e.success).length,c=i.length-s,d=Array.from(new Set(i.filter(e=>!!e.error).map(e=>e.error)));return{results:i,allSucceeded:0===c,anySucceeded:s>0,successCount:s,failureCount:c,error:d.length?d.join(", "):void 0}},X=_`
|
|
2
|
-
query OdigosApiNoop {
|
|
3
|
-
__typename
|
|
4
|
-
}
|
|
5
|
-
`,Z=(e,t)=>{if(e)return"function"==typeof e?e(t):e},ee=(e,t)=>e[t],te=(e,t,r)=>{if(void 0===t)return;return e?.transformResult?e.transformResult(t,r):t},re=(e,t,r)=>{if(!e)return;const a=e.transformVariables;return a?a(t,r):t},ae=(t,r,n)=>{const{operations:o,context:i}=H(),s=ee(o,t),c=e(()=>Z(s?.document,i),[s,i]),d=e(()=>re(s,r,i),[s,r,i]),u=!s||!c,l=!!s?.canRun&&!s.canRun(i),E=n?.skip||u||l,f=T(c??X,{variables:d,skip:E,pollInterval:n?.pollInterval,fetchPolicy:n?.fetchPolicy??"cache-and-network",notifyOnNetworkStatusChange:n?.notifyOnNetworkStatusChange,client:s?.client,onCompleted:n?.onCompleted?e=>{const t=te(s,e,i);void 0!==t&&n.onCompleted(t)}:void 0,onError:n?.onError}),_=e(()=>{if(!E)return te(s,f.data,i)},[s,i,f.data,E]),S=a(async()=>{if(u)return{data:void 0};const e=await f.refetch();return{data:te(s,e.data,i)}},[s,i,f,u]);return{data:_,loading:!E&&f.loading,error:f.error,refetch:S,unsupported:u}},ne=(t,r)=>{const{operations:n,context:o}=H(),i=ee(n,t),s=e(()=>Z(i?.document,o),[i,o]),c=!i||!s,[d,u]=E(s??X,{fetchPolicy:r?.fetchPolicy??"network-only",notifyOnNetworkStatusChange:r?.notifyOnNetworkStatusChange,client:i?.client});return{execute:a(async e=>{if(c)return{error:void 0};if(i?.canRun&&!i.canRun(o))return{data:void 0};const t=re(i,e,o),r=await d({variables:t});return r.error?{error:r.error}:{data:te(i,r.data,o)}},[i,o,d,c]),data:e(()=>te(i,u.data,o),[i,o,u.data]),loading:u.loading,error:u.error,called:u.called,unsupported:c}},oe=(t,r)=>{const{operations:o,context:i}=H(),s=f(),c=ee(o,t),d=e(()=>Z(c?.document,i),[c,i]),u=!c||!d,[l,E]=n({loading:!1,called:!1}),T=a(()=>E({loading:!1,called:!1}),[]);return[a(async e=>{if(u||!d)return{error:void 0};if(c?.canRun&&!c.canRun(i))return{data:void 0};const t=re(c,e,i),a=c?.client??s;E(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:d,variables:t}),n=te(c,e.data,i);if(E({data:n,loading:!1,error:void 0,called:!0}),r?.refetchQueries){const e=a.refetchQueries({include:r.refetchQueries});r?.awaitRefetchQueries&&await e}return void 0!==n&&r?.onCompleted?.(n),{data:n}}catch(e){const t=e;return E({data:void 0,loading:!1,error:t,called:!0}),r?.onError?.(t),{error:t}}},[c,i,s,d,u,r]),{data:l.data,loading:l.loading,error:l.error,called:l.called,unsupported:u,reset:T}]},ie=[],se=(e,t,r,a)=>{let n=!0;const o={sources:[]};for(const[i,s]of Object.entries(e)){if(!s.length)continue;n=!1;const e=s.map(({id:e,selected:t,currentStreamName:a})=>({namespace:e.namespace,name:e.name,kind:e.kind,selected:void 0!==t&&t,currentStreamName:a||r}));let c=0,d=0;for(const r of e){const e=t.find(e=>e.id.namespace===i&&e.id.name===r.name&&e.id.kind===r.kind),a=e?.dataStreamNames||[];r.selected&&!e?c++:!r.selected&&e&&a.length<=1&&d++}a(c,d),o.sources.push(...e)}return{payload:o,isEmpty:n}},ce=(e,t)=>{let r=!0;const a={namespaces:[]};for(const[n,{selected:o,currentStreamName:i}]of Object.entries(e))"boolean"==typeof o&&(r=!1,a.namespaces.push({namespace:n,selected:o,currentStreamName:i||t}));return{payload:a,isEmpty:r}},de={filter:{markedForInstrumentation:!0}},ue=[],le=[],Ee=async e=>{const t=(e=>{try{return new URL("/diagnose/download",e).toString()}catch{return null}})(e.httpUrl);if(t)try{const[r,a]=await Promise.all([Promise.resolve(e.authHeader?.()??{}),Promise.resolve(e.csrfHeader?.()??{})]),n=await fetch(t,{credentials:e.credentials??"same-origin",headers:{...r,...a}});if(!n.ok)throw new Error(`Failed to download diagnose archive: ${n.status} ${n.statusText}`);((e,t)=>{if("undefined"==typeof document)return;const r=URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)})(await n.blob(),`odigos-diagnose-${Date.now()}.tar.gz`)}catch(e){}},fe=[],Te=[],_e=[],Se=[],ye=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),Re=()=>{const{operations:t,context:r}=H(),n=f(),i=((e,t)=>{const r=f(),{notifyError:n,notifySuccess:o,notifyPending:i,notifyReadonly:s}=K(h.Source),{selectedStreamName:c}=P(),{setProgress:d,resetProgress:u}=G(),{setConfiguredSources:l,setConfiguredFutureApps:E}=v(),T=(e,t)=>{const{progress:r}=G.getState();e>0&&d(U.Instrumenting,{total:(r[U.Instrumenting]?.total||0)+e,current:r[U.Instrumenting]?.current||0}),t>0&&d(U.Uninstrumenting,{total:(r[U.Uninstrumenting]?.total||0)+t,current:r[U.Uninstrumenting]?.current||0})},_=a(async()=>{const{error:a}=await Q(r,e.GET_WORKLOADS,de,t);a&&n(C.Read,a)},[r,e.GET_WORKLOADS,t,n]);return{useSources:()=>{const e=ae("GET_WORKLOADS",de,{fetchPolicy:"cache-first"});return{items:e.data?.workloads??ue,loading:e.loading,refetch:_}},fetchAll:_,fetchByTargets:async(a,o)=>{const i=!!o?.slim,s=a.map(e=>D(e,h.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===s.length)return;if(s.length>50)return void await _();const c=i&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:d}=await Q(r,c,{ids:s.map(({namespace:e,kind:t,name:r})=>({namespace:e,kind:t,name:r}))},t);d?n(C.Read,d):await _()},fetchById:async a=>{const{data:o,error:i}=await Q(r,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:a.namespace,kind:a.kind,name:a.name}]},t);if(!i)return o?.workloadsByIds?.find(e=>e.id.namespace===a.namespace&&e.id.kind===a.kind&&e.id.name===a.name);n(C.Read,i)},fetchLibraries:async a=>Q(r,e.GET_SOURCE_LIBRARIES,a,t),fetchPeerSources:async a=>Q(r,e.GET_PEER_SOURCES,{serviceName:a},t),usePeerSources:(e,t)=>ae("GET_PEER_SOURCES",e,t),persist:async(a,o)=>{if(t.isReadonly)return s();const{data:d}=await Q(r,e.GET_WORKLOADS,de,t,"cache-first"),f=d?.workloads??ue,{payload:_,isEmpty:S}=se(a,f,c,T),{payload:y,isEmpty:R}=ce(o,c);let p=!1;S||(p=!0,i("Persisting sources...")),R||p||i("Persisting namespaces...");const{error:m}=await z(r,e.PERSIST_SOURCES,_,t);if(m&&(u(U.Instrumenting),u(U.Uninstrumenting),n(C.Update,m)),e.PERSIST_NAMESPACES){const{error:a}=await z(r,e.PERSIST_NAMESPACES,y,t);a&&n(C.Update,a)}l({}),E({})},persistV2:async a=>{if(t.isReadonly)return s(),{error:"readonly"};const n=[];for(const[,o]of Object.entries(a)){const a={sources:[]},i={namespaces:[]};for(const e of o)e.name&&e.kind?a.sources.push(e):i.namespaces.push(e);if(i.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:a}=await z(r,e.PERSIST_NAMESPACES,i,t);a&&n.push(a)}if(a.sources.length>0){const{error:o}=await z(r,e.PERSIST_SOURCES,a,t);o&&n.push(o)}}return n.length?{error:n.join(", ")}:void 0},update:async(a,d)=>{if(t.isReadonly)return s();i("Updating source...");const u={sourceId:a,patchSourceRequest:{...d,currentStreamName:c}},{data:l,error:E}=await z(r,e.UPDATE_SOURCE,u,t);E?n(C.Update,E,a):l?.updateK8sActualSource&&o(C.Update,`Successfully updated "${a.name}" source`,a)},restartWorkloads:async a=>{if(t.isReadonly)return s();i("Restarting sources...");const{data:c,error:d}=await z(r,e.RESTART_WORKLOADS,{sourceIds:a},t);d?n(C.Update,d):c?.restartWorkloads&&o(C.Update,`Successfully restarted ${a.length} sources`)},restartPod:async(a,c)=>{if(t.isReadonly)return s();i("Restarting pod...");const{data:d,error:u}=await z(r,e.RESTART_POD,{namespace:a,name:c},t);u?n(C.Update,u):d?.restartPod&&o(C.Update,`Successfully restarted pod ${a}/${c}`)},recoverFromRollback:async a=>{if(t.isReadonly)return s();i("Recovering from rollback...");const{data:c,error:d}=await z(r,e.RECOVER_FROM_ROLLBACK,{sourceId:a},t);d?n(C.Update,d,a):c?.recoverFromRollbackForWorkload&&o(C.Update,"Successfully triggered recovery from rollback")}}})(t,r),s=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Destination),{selectedStreamName:i}=P(),s=async()=>{const{error:n}=await Q(r,e.GET_DESTINATIONS,void 0,t);n&&a(C.Read,n)};return{useDestinations:()=>{const e=ae("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.destinations??e.data?.destinations??Se,loading:e.loading,refetch:s}},useDestinationCategories:()=>{const e=ae("GET_DESTINATION_CATEGORIES",void 0);return{data:e.data,loading:e.loading}},usePotentialDestinations:()=>{const e=ae("GET_POTENTIAL_DESTINATIONS",void 0);return{data:e.data,loading:e.loading}},fetchAll:s,testConnection:async a=>{const{data:n}=await z(r,e.TEST_DESTINATION_CONNECTION,{destination:ye(a,i)},t);return n},create:async c=>{if(t.isReadonly)return o();const{error:d}=await z(r,e.CREATE_DESTINATION,{destination:ye(c,i)},t);d?a(C.Create,d):(n(C.Create,`Successfully created "${c.type}" destination`),await s())},update:async(c,d)=>{if(t.isReadonly)return o();const{data:u,error:l}=await z(r,e.UPDATE_DESTINATION,{id:c,destination:ye(d,i)},t);l?a(C.Update,l,c):u?.updateDestination&&(n(C.Update,`Successfully updated "${d.type}" destination`,c),await s())},remove:async c=>{if(t.isReadonly)return o();const{data:d}=await Q(r,e.GET_DESTINATIONS,void 0,t,"cache-first"),u=d?.computePlatform?.destinations??d?.destinations??Se,l=u.find(e=>w(e)===c)?.destinationType?.type,{error:E}=await z(r,e.DELETE_DESTINATION,{id:c,currentStreamName:i},t);E?a(C.Delete,E,c):(n(C.Delete,`Successfully deleted "${l??c}" destination`,c),await s())}}})(t,r),c=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Action),i=async()=>{const{error:n}=await Q(r,e.GET_ACTIONS,void 0,t);n&&a(C.Read,n)};return{useActions:()=>{const e=ae("GET_ACTIONS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.actions??e.data?.actions??le,loading:e.loading,refetch:i}},fetchAll:i,create:async s=>{if(t.isReadonly)return o();if(!e.CREATE_ACTION)return;const{error:c}=await z(r,e.CREATE_ACTION,{action:s},t);c?a(C.Create,c):(n(C.Create,`Successfully created "${s.type}" action`),await i())},update:async(s,c)=>{if(t.isReadonly)return o();if(!e.UPDATE_ACTION)return;const{error:d}=await z(r,e.UPDATE_ACTION,{id:s,action:c},t);d?a(C.Update,d,s):(n(C.Update,`Successfully updated "${c.type}" action`,s),await i())},remove:async(s,c)=>{if(t.isReadonly)return o();if(!e.DELETE_ACTION)return;const{error:d}=await z(r,e.DELETE_ACTION,{id:s,actionType:c},t);d?a(C.Delete,d,s):(n(C.Delete,`Successfully deleted "${c}" action`,s),await i())}}})(t,r),d=((t,r)=>{const a=f(),{notifyError:n,notifySuccess:o,notifyReadonly:i}=K(h.InstrumentationRule),s=async()=>{const{error:e}=await Q(a,t.GET_INSTRUMENTATION_RULES,void 0,r);e&&n(C.Read,e)};return{useRules:()=>{const t=ae("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e(()=>(t.data?.computePlatform?.instrumentationRules??t.data?.instrumentationRules??[]).map(M),[t.data]),loading:t.loading,refetch:s}},fetchAll:s,create:async(e,c)=>{if(r.isReadonly)return i();if(!t.CREATE_INSTRUMENTATION_RULE)return;const{error:d}=await z(a,t.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:F(e)},r);d?n(C.Create,d):(o(C.Create,`Successfully created${c?` "${c}"`:""} rule`),await s())},update:async(e,c,d)=>{if(r.isReadonly)return i();if(!t.UPDATE_INSTRUMENTATION_RULE)return;const{error:u}=await z(a,t.UPDATE_INSTRUMENTATION_RULE,{ruleId:e,instrumentationRule:F(c)},r);u?n(C.Update,u,e):(o(C.Update,`Successfully updated${d?` "${d}"`:""} rule`,e),await s())},remove:async(e,c)=>{if(r.isReadonly)return i();if(!t.DELETE_INSTRUMENTATION_RULE)return;const{error:d}=await z(a,t.DELETE_INSTRUMENTATION_RULE,{ruleId:e},r);d?n(C.Delete,d,e):(o(C.Delete,`Successfully deleted${c?` "${c}"`:""} rule`,e),await s())}}})(t,r),u=((e,t)=>{const r=f(),{addNotification:a}=m(),{setDataStreams:n}=P(),i=(e,t)=>a({type:I.Error,title:e,message:t}),s=async()=>{const{data:a,error:o}=await Q(r,e.GET_DATA_STREAMS,void 0,t);if(o)i(C.Read,o);else if(a){const e=a.computePlatform?.dataStreams??a.dataStreams??[];n(e)}},c=e.CREATE_DATA_STREAM?async n=>{if(t.isReadonly)return V(a);const{error:o}=await z(r,e.CREATE_DATA_STREAM,{stream:n},t);o?i(C.Create,o):await s()}:void 0;return{useDataStreams:()=>{const e=ae("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first"}),t=e.data?.computePlatform?.dataStreams??e.data?.dataStreams??_e;return o(()=>{n(t)},[JSON.stringify(t.map(e=>e.name))]),{items:t,loading:e.loading,refetch:s}},fetchAll:s,create:c,update:async(n,o)=>{if(t.isReadonly)return V(a);const{error:c}=await z(r,e.UPDATE_DATA_STREAM,{id:n,dataStream:o},t);c?i(C.Update,c):await s()},remove:async n=>{if(t.isReadonly)return V(a);const{error:o}=await z(r,e.DELETE_DATA_STREAM,{id:n},t);o?i(C.Delete,o):await s()}}})(t,r),l=((e,t)=>{const r=f(),{notifyError:a,notifyReadonly:n}=K(h.Namespace),o=async()=>{const n=await Q(r,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return n.error&&a(C.Read,n.error),n};return{useNamespaces:()=>{const e=ae("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.namespaces??Te,loading:e.loading,refetch:o}},fetchAll:o,persist:async o=>{if(t.isReadonly)return n();const{error:i}=await z(r,e.PERSIST_NAMESPACES,o,t);return i&&a(C.Update,i),i?{error:i}:void 0}}})(t,r),E=((e,t)=>{const r=f(),{notifyError:a}=K(h.Source);return{fetch:async n=>{const o=await Q(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(C.Read,o.error),o}}})(t,r),T=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.Source);return{useEffectiveConfig:(e,t)=>ae("GET_EFFECTIVE_CONFIG",e,t),useConfigYamls:e=>ae("GET_CONFIG_YAMLS",void 0,e),getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?Q(r,e.GET_EFFECTIVE_CONFIG,{id:a},t):{error:"GET_EFFECTIVE_CONFIG not configured"},applyConfigurations:e.UPDATE_REMOTE_CONFIG?async(n,i)=>{if(t.isReadonly)return o();const{error:s}=await z(r,e.UPDATE_REMOTE_CONFIG,{formData:n,connectionIds:i},t);return s&&a(C.Update,s),s?{error:s}:void 0}:void 0,getConfigYamls:e.GET_CONFIG_YAMLS?async()=>Q(r,e.GET_CONFIG_YAMLS,void 0,t):void 0,updateLocalUiConfig:e.UPDATE_LOCAL_UI_CONFIG?async i=>{if(t.isReadonly)return o();const{error:s}=await z(r,e.UPDATE_LOCAL_UI_CONFIG,{config:i},t);return s?a(C.Update,s):n(C.Update,"Local UI configuration updated successfully"),s?{error:s}:void 0}:void 0,resetLocalUiConfigToDefaults:e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS?async()=>{if(t.isReadonly)return o();const{error:i}=await z(r,e.RESET_LOCAL_UI_CONFIG_TO_FACTORY_DEFAULTS,void 0,t);return i?a(C.Update,i):n(C.Update,"Local UI configuration reset to factory defaults"),i?{error:i}:void 0}:void 0}})(t,r),_=((e,t)=>{const r=f(),{apolloConfig:a}=H();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>Q(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>Q(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const i=await Q(r,e.GET_DIAGNOSE,{input:n,dryRun:o?.dryRun??!1},t),s=i?.data?.stats?.fileCount??0;return!i.error&&s>0&&!o?.dryRun&&await Ee(a),i}:void 0}})(t,r),S=((e,t)=>{const r=f(),{notifyError:a,notifyReadonly:n}=K(h.Source),o=async()=>{e.GET_TOKENS&&await Q(r,e.GET_TOKENS,void 0,t)};return{useTokens:()=>{const e=ae("GET_TOKENS",void 0,{fetchPolicy:"cache-first"});return{items:e.data??ie,loading:e.loading,refetch:o}},updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:i}=await z(r,e.UPDATE_TOKEN,{token:o},t);return i&&a(C.Update,i),i?{error:i}:void 0}:void 0}})(t,r),y=((e,t)=>{const r=f();return{useMetrics:e=>ae("GET_METRICS",void 0,e),fetch:async()=>Q(r,e.GET_METRICS,void 0,t)}})(t,r),R=((e,t)=>{const r=f();return{useServiceMap:e=>ae("GET_SERVICE_MAP",void 0,e),fetch:e.GET_SERVICE_MAP?async()=>Q(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(t,r),p=((e,t)=>{const r=f();return{useSlots:e=>ae("GET_PROFILING_SLOTS",void 0,e),useSourceProfiling:(e,t)=>ae("GET_SOURCE_PROFILING",e,t),fetchSlots:e.GET_PROFILING_SLOTS?async()=>Q(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>Q(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>z(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0}})(t,r),O=((e,t)=>{const r=f();return{useGatewayInfo:e=>ae("GET_GATEWAY_INFO",void 0,e),useGatewayPods:e=>ae("GET_GATEWAY_PODS",void 0,e),useNodeCollectorInfo:e=>ae("GET_NODE_COLLECTOR_INFO",void 0,e),useNodeCollectorPods:e=>ae("GET_NODE_COLLECTOR_PODS",void 0,e),usePodInfo:(e,t)=>ae("GET_COLLECTOR_POD_INFO",e,t),getGatewayInfo:e.GET_GATEWAY_INFO?async()=>Q(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>Q(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>Q(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>Q(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>Q(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(t,r),A=((e,t)=>{const r=f(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=K(h.SamplingRule),i=async()=>{e.GET_SAMPLING_RULES&&await Q(r,e.GET_SAMPLING_RULES,void 0,t)},s=(e,s)=>e?async c=>{if(t.isReadonly)return o();const{error:d}=await z(r,e,c,t);return d?a(s,d):(n(C.Create,"Successfully created sampling rule"),await i()),d?{error:d}:void 0}:void 0,c=(e,s)=>e?async(c,d)=>{if(t.isReadonly)return o();const{error:u}=await z(r,e,{samplingId:d.samplingId,ruleId:c,rule:d.rule},t);return u?a(s,u):(n(C.Update,"Successfully updated sampling rule"),await i()),u?{error:u}:void 0}:void 0,d=e=>e?async(s,c)=>{if(t.isReadonly)return o();const{error:d}=await z(r,e,{samplingId:c,ruleId:s},t);return d?a(C.Delete,d):(n(C.Delete,"Successfully deleted sampling rule"),await i()),d?{error:d}:void 0}:void 0;return{useSamplingRules:()=>{const e=ae("GET_SAMPLING_RULES",void 0,{fetchPolicy:"cache-first"});return{items:e.data?.computePlatform?.samplingRules??e.data?.samplingRules??fe,k8sHealthProbesConfig:e.data?.computePlatform?.k8sHealthProbesConfig??e.data?.k8sHealthProbesConfig??null,loading:e.loading,refetch:i}},fetchAll:e.GET_SAMPLING_RULES?async()=>Q(r,e.GET_SAMPLING_RULES,void 0,t):void 0,createNoisy:s(e.CREATE_NOISY_OPERATION_RULE,C.Create),updateNoisy:c(e.UPDATE_NOISY_OPERATION_RULE,C.Update),deleteNoisy:d(e.DELETE_NOISY_OPERATION_RULE),createHighlyRelevant:s(e.CREATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Create),updateHighlyRelevant:c(e.UPDATE_HIGHLY_RELEVANT_OPERATION_RULE,C.Update),deleteHighlyRelevant:d(e.DELETE_HIGHLY_RELEVANT_OPERATION_RULE),createCostReduction:s(e.CREATE_COST_REDUCTION_RULE,C.Create),updateCostReduction:c(e.UPDATE_COST_REDUCTION_RULE,C.Update),deleteCostReduction:d(e.DELETE_COST_REDUCTION_RULE),updateK8sHealthProbesConfig:e.UPDATE_LOCAL_UI_SAMPLING_CONFIG?async n=>{if(t.isReadonly)return o();const{error:s}=await z(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:{k8sHealthProbesSampling:n}},t);return s?a(C.Update,s):await i(),s?{error:s}:void 0}:void 0}})(t,r),N=((e,t)=>{const r=f();return{useSnapshots:()=>{const e=ae("GET_ALL_CLUSTER_SNAPSHOTS",void 0,{fetchPolicy:"cache-first"});return{data:e.data,loading:e.loading,unsupported:e.unsupported,refetch:e.refetch}},getAllClusterSnapshots:e.GET_ALL_CLUSTER_SNAPSHOTS?async()=>Q(r,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,t):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async a=>Q(r,e.GET_CLUSTER_SNAPSHOT,{clusterId:a},t):void 0}})(t,r);return{sourcesApi:i,destinationsApi:s,actionsApi:c,instrumentationRulesApi:d,dataStreamsApi:u,namespacesApi:l,k8sManifestApi:E,configApi:T,describeApi:_,tokensApi:S,metricsApi:y,serviceMapApi:R,profilingApi:p,collectorsApi:O,samplingApi:A,snapshotsApi:N,capabilities:e(()=>((e,t)=>{const r=t.platformType===g.Vm,a=t.tier===L.Onprem,n=!r;return{canBulkPersistSources:n&&!!e.PERSIST_SOURCES,canInstrumentNamespaces:n&&!!e.PERSIST_NAMESPACES,canFetchSnapshots:n&&!!e.GET_ALL_CLUSTER_SNAPSHOTS,canRecoverFromRollback:n&&!!e.RECOVER_FROM_ROLLBACK,canRestartWorkloads:n&&!!e.RESTART_WORKLOADS,canFetchPeerSources:!!e.GET_PEER_SOURCES,canFetchSourceLibraries:!!e.GET_SOURCE_LIBRARIES,canFetchK8sManifest:n&&!!e.GET_K8S_MANIFEST,canCreateDestination:n&&!!e.CREATE_DESTINATION,canTestConnection:n&&!!e.TEST_DESTINATION_CONNECTION,canFetchDestinationCategories:!!e.GET_DESTINATION_CATEGORIES,canFetchPotentialDestinations:n&&!!e.GET_POTENTIAL_DESTINATIONS,canCreateAction:n&&!!e.CREATE_ACTION,canCreateInstrumentationRule:n&&!!e.CREATE_INSTRUMENTATION_RULE,canApplyEffectiveConfig:n&&!!e.UPDATE_REMOTE_CONFIG&&!!e.GET_EFFECTIVE_CONFIG,canFetchEffectiveConfig:!!e.GET_EFFECTIVE_CONFIG,canFetchConfigYamls:!!e.GET_CONFIG_YAMLS,canFetchProfiling:n&&!!e.GET_PROFILING_SLOTS,canFetchCollectorInfo:n&&!!e.GET_GATEWAY_INFO,canManageSamplingRules:!!e.GET_SAMPLING_RULES,isEnterprise:a,isVm:r}})(t,r),[t,r]),resetCache:a(async()=>{await n.cache.reset()},[n])}};export{W as O,Y as _,se as a,oe as b,ae as c,Re as d,H as e,J as f,ce as p,z as r,ne as u};
|