@odigos/ui-kit 0.0.252 → 0.0.253

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/docs/api-context.md +44 -38
  3. package/lib/chunks/connections-scope-h3bbPbRd.js +1 -0
  4. package/lib/chunks/{flow-CAOY59Tu.js → flow-BnkrFBJL.js} +1 -1
  5. package/lib/chunks/{helpers-CXxRJd5C.js → helpers-BEkhis3j.js} +1 -1
  6. package/lib/chunks/{index-BgflYoEI.js → index-DIVbcB6F.js} +1 -1
  7. package/lib/chunks/source-instrument-form-context-6ViZM1Z_.js +1 -0
  8. package/lib/chunks/{ui-components-Dc15jc-B.js → ui-components-TeG65JGy.js} +1 -1
  9. package/lib/chunks/use-odigos-api-li2VrVHH.js +5 -0
  10. package/lib/components/v2.js +1 -1
  11. package/lib/components.js +1 -1
  12. package/lib/constants.js +1 -1
  13. package/lib/containers/v2.js +138 -138
  14. package/lib/containers.js +7 -7
  15. package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +16 -8
  16. package/lib/contexts/odigos-api/hooks/use-collectors-api.d.ts +12 -1
  17. package/lib/contexts/odigos-api/hooks/use-config-api.d.ts +10 -1
  18. package/lib/contexts/odigos-api/hooks/use-data-streams-api.d.ts +19 -13
  19. package/lib/contexts/odigos-api/hooks/use-destinations-api.d.ts +30 -21
  20. package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +12 -4
  21. package/lib/contexts/odigos-api/hooks/use-metrics-api.d.ts +9 -3
  22. package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +14 -4
  23. package/lib/contexts/odigos-api/hooks/use-profiling-api.d.ts +5 -0
  24. package/lib/contexts/odigos-api/hooks/use-sampling-api.d.ts +18 -1
  25. package/lib/contexts/odigos-api/hooks/use-service-map-api.d.ts +8 -1
  26. package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +24 -0
  27. package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +24 -6
  28. package/lib/contexts/odigos-api/hooks/use-tokens-api.d.ts +11 -4
  29. package/lib/contexts/odigos-api/index.d.ts +3 -3
  30. package/lib/contexts/odigos-api/types.d.ts +26 -27
  31. package/lib/contexts/odigos-api/use-odigos-api.d.ts +21 -36
  32. package/lib/contexts/odigos-api.js +1 -1
  33. package/lib/contexts.js +1 -1
  34. package/lib/functions.js +1 -1
  35. package/lib/hooks.js +1 -1
  36. package/lib/snippets/v2.js +1 -1
  37. package/lib/snippets.js +1 -1
  38. package/lib/store.js +1 -1
  39. package/lib/theme.js +1 -1
  40. package/lib/types.js +1 -1
  41. package/lib/visuals.js +1 -1
  42. package/package.json +1 -1
  43. package/lib/chunks/connections-scope-Cb3gZ8MW.js +0 -1
  44. package/lib/chunks/source-instrument-form-context-Rk2YlyRb.js +0 -1
  45. package/lib/chunks/use-odigos-api-qSWLSy9S.js +0 -5
@@ -143,6 +143,32 @@ export interface Operation<TData = unknown, TVars = unknown> {
143
143
  transformResult?(raw: unknown, ctx: OperationContext): TData | undefined;
144
144
  /** Massage the raw Apollo response into per-proxy multi-fetch results. */
145
145
  transformMultiResult?(raw: unknown, ctx: OperationContext): MultiFetchResult<TData>[];
146
+ /**
147
+ * Optional full-custom executor. When present, the imperative runner
148
+ * (`runQuery` / `runMutation`) delegates the ENTIRE execution to this
149
+ * function instead of doing its own
150
+ * `document` -> `transformVariables` -> `client.query` -> `transformResult`
151
+ * dance. Use it when an operation can't be expressed as a single Apollo
152
+ * call — e.g. an op that needs multiple sequential round-trips or
153
+ * host-specific control flow (central-ui's legacy `<v1.20` fallbacks
154
+ * that fetch a base entity and then enrich it from follow-up queries).
155
+ *
156
+ * The hook receives the resolved ApolloClient (honoring `op.client`),
157
+ * the slot's typed `vars`, and the operation context; it returns the
158
+ * same `{ data, error }` shape the runner produces. All host-specific
159
+ * branching (e.g. version checks, shape mapping) lives inside the
160
+ * adapter's `run` — the kit stays oblivious.
161
+ *
162
+ * NOTE: this is consulted ONLY by the imperative runner. The
163
+ * declarative `useApiQuery` / `useApiLazyQuery` path is built on a
164
+ * single Apollo `useQuery` and does not call `run`; ops whose
165
+ * results are consumed via that subscription must remain expressible
166
+ * as a single `document` + `transformVariables` + `transformResult`.
167
+ */
168
+ run?(client: ApolloClient<unknown>, vars: TVars | undefined, ctx: OperationContext): Promise<{
169
+ data?: TData;
170
+ error?: string;
171
+ }>;
146
172
  /**
147
173
  * Optional override of the ApolloClient this single operation runs against.
148
174
  *
@@ -375,9 +401,6 @@ export interface DeleteDataStreamVars {
375
401
  export interface GetNamespacesWithWorkloadsData {
376
402
  namespaces?: Namespace[];
377
403
  }
378
- export interface GetNamespaceVars {
379
- namespaceName: string;
380
- }
381
404
  /** Variables for `GET_K8S_MANIFEST`. */
382
405
  export interface GetK8sManifestVars {
383
406
  kind: K8sResourceKind | string;
@@ -629,20 +652,6 @@ export interface DeleteCostReductionRuleResult {
629
652
  export interface UpdateLocalUiSamplingConfigResult {
630
653
  updateLocalUiSamplingConfig: boolean;
631
654
  }
632
- export interface SourceConditionEntry {
633
- namespace: string;
634
- name: string;
635
- kind: string;
636
- conditions: {
637
- status: string;
638
- type: string;
639
- reason: string;
640
- message: string;
641
- }[];
642
- }
643
- export interface GetSourceConditionsData {
644
- sourceConditions: SourceConditionEntry[];
645
- }
646
655
  export interface OdigosApiOperations {
647
656
  GET_WORKLOADS: Operation<GetWorkloadsData, GetWorkloadsVars | undefined>;
648
657
  GET_WORKLOADS_BY_IDS: Operation<GetWorkloadsByIdsData, GetWorkloadsByIdsVars>;
@@ -650,10 +659,6 @@ export interface OdigosApiOperations {
650
659
  GET_SOURCE: Operation<{
651
660
  source?: Workload;
652
661
  }, WorkloadId>;
653
- /** central-ui only, legacy <v1.20 path */
654
- GET_SOURCES?: Operation<GetWorkloadsData, GetWorkloadsVars | undefined>;
655
- /** central-ui only, legacy <v1.20 path */
656
- GET_SOURCE_CONDITIONS?: Operation<GetSourceConditionsData, WorkloadId>;
657
662
  GET_SOURCE_LIBRARIES: Operation<GetSourceLibrariesData, GetSourceLibrariesVars>;
658
663
  GET_PEER_SOURCES: Operation<{
659
664
  peerSources?: PeerSources;
@@ -692,12 +697,6 @@ export interface OdigosApiOperations {
692
697
  UPDATE_DATA_STREAM: Operation<UpdateDataStreamResult, UpdateDataStreamVars>;
693
698
  DELETE_DATA_STREAM: Operation<DeleteDataStreamResult, DeleteDataStreamVars>;
694
699
  GET_NAMESPACES_WITH_WORKLOADS: Operation<GetNamespacesWithWorkloadsData, undefined>;
695
- /** central-ui legacy <v1.20 path */
696
- GET_NAMESPACES?: Operation<GetNamespacesWithWorkloadsData, undefined>;
697
- /** central-ui legacy <v1.20 path */
698
- GET_NAMESPACE?: Operation<{
699
- namespace?: Namespace;
700
- }, GetNamespaceVars>;
701
700
  PERSIST_NAMESPACES: Operation<PersistNamespacesResult, PersistNamespacesVars>;
702
701
  GET_K8S_MANIFEST: Operation<GetK8sManifestData, GetK8sManifestVars>;
703
702
  GET_CONFIG?: Operation<FetchedConfig, undefined>;
@@ -13,32 +13,31 @@
13
13
  * configApi.applyConfigurations?.(formData, ids);
14
14
  * sourcesApi.update(workloadId, payload);
15
15
  *
16
- * // Subscribe-to-data — reads `.items` / `.loading` and lets the kit
17
- * // auto-fetch the underlying list query.
18
- * const { sourcesApi } = useOdigosApi({ subscribe: ['sources'] });
19
- * sourcesApi.items.length; // Workload[]
16
+ * // Subscribe-to-data — call the domain's reactive `use…()` sub-hook
17
+ * // (a hook, so call it at the top level of the container). Calling it
18
+ * // IS the subscription: it owns the underlying `useApiQuery('GET_…')`.
19
+ * const { sourcesApi } = useOdigosApi();
20
+ * const { items, loading, refetch } = sourcesApi.useSources();
21
+ * items.length; // Workload[]
20
22
  * ```
21
23
  *
22
- * ### Subscribe opt-in
24
+ * ### Reactive reads via `use…()` sub-hooks
23
25
  *
24
- * The six entity-list domain APIs (`sourcesApi`, `destinationsApi`,
25
- * `actionsApi`, `instrumentationRulesApi`, `namespacesApi`, `dataStreamsApi`) own a
26
- * `useApiQuery('GET_…')` subscription that auto-fetches and broadcasts
27
- * to every consumer via Apollo's normalized cache.
26
+ * Every domain API exposes its reactive reads as `use…()` sub-hooks
27
+ * (e.g. `sourcesApi.useSources()`, `actionsApi.useActions()`,
28
+ * `collectorsApi.useGatewayInfo()`, `configApi.useEffectiveConfig()`).
29
+ * Each sub-hook owns a `useApiQuery('GET_…')`, so the network request
30
+ * only fires for the queries a container actually reads — calling the
31
+ * sub-hook is the opt-in. Imperative methods (create/update/delete/
32
+ * fetchAll/persist/…) stay as plain top-level keys on the `*Api` object.
28
33
  *
29
- * Without an opt-in, calling `useOdigosApi()` from a page like
30
- * `/settings` (which only needs `configApi`) used to fire all six
31
- * list queries unconditionally, plus a redundant fetch on every host
32
- * page that mounts a header/system-drawer. The `subscribe` option
33
- * makes the auto-fetch explicit: containers that read `.items` /
34
- * `.loading` list which entities they need; everyone else gets the
35
- * imperative methods (create/update/delete/fetchAll) but no auto-fetch.
34
+ * This is why `useOdigosApi()` itself fires nothing: it just wires up
35
+ * the per-domain objects. A page like `/settings` that only needs
36
+ * `configApi.updateLocalUiConfig` never mounts a single list query.
36
37
  *
37
- * Containers that opt out still receive a fully-typed `*Api` object —
38
- * `.items` will be an empty array (the slot is `skip: true`'d), and
39
- * `.loading` will stay `false`. Reading those is a no-op the
40
- * type system happily allows; missing the opt-in for a container
41
- * that DOES need data shows up as "no rows" in the UI.
38
+ * Because the sub-hooks are React hooks, call them unconditionally at
39
+ * the top level of a container (never inside a loop/condition), exactly
40
+ * like any other hook.
42
41
  *
43
42
  * All data flow runs through the operations map supplied to
44
43
  * `<OdigosApiProvider>`. Build-time tooling (Storybook) installs its
@@ -62,20 +61,6 @@ import { type DataStreamsApi } from './hooks/use-data-streams-api';
62
61
  import { type K8sManifestApi } from './hooks/use-k8s-manifest-api';
63
62
  import { type DestinationsApi } from './hooks/use-destinations-api';
64
63
  import { type InstrumentationRulesApi } from './hooks/use-instrumentation-rules-api';
65
- /**
66
- * Names of entity-list domain hooks whose `useApiQuery` subscription
67
- * is opt-in. Pass any subset to `useOdigosApi({ subscribe: [...] })`.
68
- */
69
- export type SubscribableDomain = 'sources' | 'destinations' | 'actions' | 'rules' | 'namespaces' | 'dataStreams' | 'destinationCategories' | 'potentialDestinations';
70
- export interface UseOdigosApiOptions {
71
- /**
72
- * Which entity-list domains should auto-fetch their list query.
73
- * Containers that read `.items` / `.loading` from a domain MUST list it here;
74
- * otherwise the kit hands back an empty array and `false` loading.
75
- * Containers that only need imperative methods (create/update/delete/fetchAll) should omit the option entirely — no list query fires.
76
- */
77
- subscribe?: SubscribableDomain[];
78
- }
79
64
  export interface UseOdigosApiReturn {
80
65
  sourcesApi: SourcesApi;
81
66
  destinationsApi: DestinationsApi;
@@ -100,4 +85,4 @@ export interface UseOdigosApiReturn {
100
85
  */
101
86
  resetCache: () => Promise<void>;
102
87
  }
103
- export declare const useOdigosApi: (options?: UseOdigosApiOptions) => UseOdigosApiReturn;
88
+ export declare const useOdigosApi: () => UseOdigosApiReturn;
@@ -1 +1 @@
1
- import{e as o,r,f as t}from"../chunks/use-odigos-api-qSWLSy9S.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-qSWLSy9S.js";export{O as OdigosApiConnectionsScope}from"../chunks/connections-scope-Cb3gZ8MW.js";import{useApolloClient as e}from"@apollo/client";import{P as s,t as i}from"../chunks/ui-components-Dc15jc-B.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.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};
1
+ import{b as o,r,c as t}from"../chunks/use-odigos-api-li2VrVHH.js";export{O as OdigosApiProvider,p as prepareNamespacePayloads,a as prepareSourcePayloads,u as useOdigosApi}from"../chunks/use-odigos-api-li2VrVHH.js";export{O as OdigosApiConnectionsScope}from"../chunks/connections-scope-h3bbPbRd.js";import{useApolloClient as e}from"@apollo/client";import{P as s,t as n}from"../chunks/ui-components-TeG65JGy.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 i=()=>{const s=e(),{operations:n,context:i}=o();return{multiFetch:async(o,r,e)=>{const a=n[o];return a?t(s,a,r,e,i):{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={...i,proxyID:a},{error:c}=await r(s,n.PERSIST_SOURCES,t,o);c&&e.push(`${a}: ${c}`)}return e.length?{error:e.join(", ")}:void 0},applyConfigurations:async(o,t)=>{if(!n.UPDATE_REMOTE_CONFIG)return{error:"UPDATE_REMOTE_CONFIG not configured"};const{error:e}=await r(s,n.UPDATE_REMOTE_CONFIG,{formData:t,connectionIds:o},i);return e?{error:e}:void 0}}},c=(o,r)=>o.platformType===s.K8s?r.K8s:o.platformType===s.Vm?r.Vm:void 0,m=o=>r=>{const t=o[r.platformType];if(!t)return;const e=Object.keys(t);if(0===e.length)return;const s=n(r.version),i=[...e].sort((o,r)=>n(r)-n(o)).find(o=>s>=n(o));return i?t[i]:void 0},l=(o,r)=>{const t={};for(const e of Object.keys(o))t[e]=r(o[e]);return t};export{c as pickByPlatform,i as useApiForConnections,m as versionedDocument,l 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-Rk2YlyRb.js";export{O as OdigosProvider,c as checkVersionSupport,u as useOdigos}from"./chunks/helpers-CXxRJd5C.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-Cb3gZ8MW.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-qSWLSy9S.js";export{pickByPlatform,useApiForConnections,versionedDocument,vmDialectMap}from"./contexts/odigos-api.js";import"./chunks/ui-components-Dc15jc-B.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};
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-6ViZM1Z_.js";export{O as OdigosProvider,c as checkVersionSupport,u as useOdigos}from"./chunks/helpers-BEkhis3j.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-h3bbPbRd.js";export{O as OdigosApiProvider,p as prepareNamespacePayloads,a as prepareSourcePayloads,u as useOdigosApi}from"./chunks/use-odigos-api-li2VrVHH.js";export{pickByPlatform,useApiForConnections,versionedDocument,vmDialectMap}from"./contexts/odigos-api.js";import"./chunks/ui-components-TeG65JGy.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{a2 as adaptInstrumentationRuleFromWire,a3 as adaptInstrumentationRuleInputForWire,b9 as buildBadgeForDesiredStatus,fe as capitalizeFirstLetter,ff as cleanObjectEmptyStringsValues,as as compareCondition,fg as decimalsOnly,s as deepClone,dm as entityIdKey,ds as filterActions,dr as filterDestinations,b2 as filterDestinationsByStream,dq as filterSources,de as filterSourcesByStream,fh as flattenObjectKeys,bp as formatBytes,fi as formatDuration,bY as generateId,b0 as getActionIcon,k as getConditionsBooleans,bB as getContainersIcons,fj as getContainersInstrumentedCount,fk as getDeepValue,aS as getDestinationIcon,fl as getDetectedLanguageIcons,be as getEffectiveLanguage,bw as getEffectiveRuntimeVersion,dn as getEntityIcon,a1 as getEntityId,dk as getEntityIdKey,dl as getEntityLabel,fm as getHealthBadgeLabel,a0 as getIdFromSseTarget,b6 as getInstrumentationRuleIcon,fn as getMainContainerLanguage,fo as getMetricForEntity,fp as getMonitorIcon,fq as getPlatformIcon,fr as getPlatformLabel,az as getProgrammingLanguageIcon,fs as getRecursiveValues,j as getSourceLanguageIcons,X as getSseTargetFromId,ft as getStatusColor,dw as getStatusFromPodStatus,g as getStatusIcon,br as getStatusTypeFromOdigosHealth,fu as getValueForRange,i as getVirtualServiceIcon,bm as getWorkloadId,b3 as getYamlFieldsForDestination,fv as hasUnhealthyInstances,fw as instrumentationRuleSourceScopesFromWire,fx as instrumentationRuleSourceScopesToWire,x as isEmpty,B as isLegalK8sLabel,bU as isOverTime,fy as isStringABoolean,fz as isTimeElapsed,bv as isValidVersion,fA as mapConditions,bc as mapDesiredStatusToConditionStatus,b1 as mapDestinationFieldsForDisplay,K as mapExportedSignals,G as mapSupportedSignals,fB as numbersOnly,fC as parseBooleanFromString,fD as parseJsonStringToPrettyString,at as prepareDestinationFormData,fE as removeEmptyValuesFromObject,J as safeJsonParse,fF as safeJsonStringify,fG as setDeepValue,fH as sleep,b4 as splitCamelString,fI as stringifyNonStringValues,t as trimVersion}from"./chunks/ui-components-Dc15jc-B.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
+ export{a3 as adaptInstrumentationRuleFromWire,a2 as adaptInstrumentationRuleInputForWire,b9 as buildBadgeForDesiredStatus,fe as capitalizeFirstLetter,ff as cleanObjectEmptyStringsValues,as as compareCondition,fg as decimalsOnly,s as deepClone,dm as entityIdKey,ds as filterActions,dr as filterDestinations,b2 as filterDestinationsByStream,dq as filterSources,de as filterSourcesByStream,fh as flattenObjectKeys,bp as formatBytes,fi as formatDuration,bY as generateId,b0 as getActionIcon,k as getConditionsBooleans,bB as getContainersIcons,fj as getContainersInstrumentedCount,fk as getDeepValue,aS as getDestinationIcon,fl as getDetectedLanguageIcons,be as getEffectiveLanguage,bw as getEffectiveRuntimeVersion,dn as getEntityIcon,a1 as getEntityId,dk as getEntityIdKey,dl as getEntityLabel,fm as getHealthBadgeLabel,a0 as getIdFromSseTarget,b6 as getInstrumentationRuleIcon,fn as getMainContainerLanguage,fo as getMetricForEntity,fp as getMonitorIcon,fq as getPlatformIcon,fr as getPlatformLabel,az as getProgrammingLanguageIcon,fs as getRecursiveValues,j as getSourceLanguageIcons,X as getSseTargetFromId,ft as getStatusColor,dw as getStatusFromPodStatus,g as getStatusIcon,br as getStatusTypeFromOdigosHealth,fu as getValueForRange,i as getVirtualServiceIcon,bm as getWorkloadId,b3 as getYamlFieldsForDestination,fv as hasUnhealthyInstances,fw as instrumentationRuleSourceScopesFromWire,fx as instrumentationRuleSourceScopesToWire,x as isEmpty,B as isLegalK8sLabel,bU as isOverTime,fy as isStringABoolean,fz as isTimeElapsed,bv as isValidVersion,fA as mapConditions,bc as mapDesiredStatusToConditionStatus,b1 as mapDestinationFieldsForDisplay,K as mapExportedSignals,G as mapSupportedSignals,fB as numbersOnly,fC as parseBooleanFromString,fD as parseJsonStringToPrettyString,at as prepareDestinationFormData,fE as removeEmptyValuesFromObject,J as safeJsonParse,fF as safeJsonStringify,fG as setDeepValue,fH as sleep,b4 as splitCamelString,fI as stringifyNonStringValues,t as trimVersion}from"./chunks/ui-components-TeG65JGy.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/hooks.js CHANGED
@@ -1 +1 @@
1
- export{fT as IGNORE_OUTSIDE_CLICK_ATTR,fU as useActionFormData,fV as useBodyScroll,u as useClickNode,p as useClickNotification,dp as useContainerSize,bq as useCopy,fW as useDataStreamFormData,fX as useDestinationFormData,r as useGenericForm,fY as useInstrumentationRuleFormData,bT as useKeyDown,bs as useOnClickOutside,fZ as useOverflow,d as usePopup,b8 as useScrollIntoViewWhen,dS as useScrollTo,dh as useSessionStorage,f_ as useSourceFormData,b7 as useTimeAgo}from"./chunks/ui-components-Dc15jc-B.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
+ export{fT as IGNORE_OUTSIDE_CLICK_ATTR,fU as useActionFormData,fV as useBodyScroll,u as useClickNode,p as useClickNotification,dp as useContainerSize,bq as useCopy,fW as useDataStreamFormData,fX as useDestinationFormData,r as useGenericForm,fY as useInstrumentationRuleFormData,bT as useKeyDown,bs as useOnClickOutside,fZ as useOverflow,d as usePopup,b8 as useScrollIntoViewWhen,dS as useScrollTo,dh as useSessionStorage,f_ as useSourceFormData,b7 as useTimeAgo}from"./chunks/ui-components-TeG65JGy.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 +1 @@
1
- export{bi as ActionType,dv as Actions,du as RichTitle}from"../chunks/ui-components-Dc15jc-B.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-BgflYoEI.js";export{C as ColoredSpan,D as ColoredSpanVariant}from"../chunks/helpers-CXxRJd5C.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
+ export{bi as ActionType,dv as Actions,du as RichTitle}from"../chunks/ui-components-TeG65JGy.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-DIVbcB6F.js";export{C as ColoredSpan,D as ColoredSpanVariant}from"../chunks/helpers-BEkhis3j.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{F as Flow,M as MapItemNode,N as NoDataNode}from"./chunks/flow-CAOY59Tu.js";import"react/jsx-runtime";import"react";import"@xyflow/react/dist/style.css";import"styled-components";import"./chunks/ui-components-Dc15jc-B.js";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"@xyflow/react";
1
+ export{F as Flow,M as MapItemNode,N as NoDataNode}from"./chunks/flow-BnkrFBJL.js";import"react/jsx-runtime";import"react";import"@xyflow/react/dist/style.css";import"styled-components";import"./chunks/ui-components-TeG65JGy.js";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"@xyflow/react";
package/lib/store.js CHANGED
@@ -1 +1 @@
1
- export{$ as ProgressKeys,a as useActiveNodeStore,fS as useDarkMode,z as useDataStreamStore,bl as useDrawerStore,dd as useFilterStore,bZ as useModalStore,o as useNotificationStore,Z as useProgressStore,dj as useSelectedStore,_ as useSetupStore}from"./chunks/ui-components-Dc15jc-B.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
+ export{$ as ProgressKeys,a as useActiveNodeStore,fS as useDarkMode,z as useDataStreamStore,bl as useDrawerStore,dd as useFilterStore,bZ as useModalStore,o as useNotificationStore,Z as useProgressStore,dj as useSelectedStore,_ as useSetupStore}from"./chunks/ui-components-TeG65JGy.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{f$ as Provider,g0 as animations,g1 as opacity,g2 as palettes}from"./chunks/ui-components-Dc15jc-B.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
+ export{f$ as Provider,g0 as animations,g1 as opacity,g2 as palettes}from"./chunks/ui-components-TeG65JGy.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/types.js CHANGED
@@ -1 +1 @@
1
- export{v as ActionKeyTypes,w as ActionType,eO as AddNodeTypes,eP as AgentInjectedReason,eQ as BooleanOperation,au as CodeAttributesKeyTypes,eR as ConditionType,Y as Crud,Q as CustomInstrumentationsKeyTypes,ba as DesiredStateProgress,eS as DestinationTypes,eT as EdgeTypes,E as EntityTypes,aj as ExtractionDataFormat,L as FieldTypes,R as GolangCustomProbe,O as HeadersCollectionKeyTypes,dU as InputTypes,eU as InstallationMethod,eV as InstallationStatus,V as InstrumentationRuleType,eW as IntrumentationStatus,U as JavaCustomProbe,eX as JsonOperation,a8 as K8sAttributesFrom,W as K8sResourceKind,eY as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,eZ as ListDirection,b as NodeTypes,e_ as NumberOperation,e$ as OtelDistroName,f0 as OtherEntityTypes,bf as OtherStatus,aT as OtherStatusType,aw as PayloadCollectionKeyTypes,P as PlatformType,f1 as PodContainerLifecycleStatus,f2 as PodContainerStatus,f3 as PodPhase,f4 as Profile,by as ProgrammingLanguages,f5 as SIGNAL_KEY_TO_TYPE,f6 as SIGNAL_TYPE_TO_KEY,f7 as SignalKey,H as SignalType,f8 as SortDirection,S as StatusType,f9 as StringOperation,c as Tier,fa as WorkloadRolloutReason,dx as WorkloadRolloutStatus}from"./chunks/ui-components-Dc15jc-B.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
+ export{v as ActionKeyTypes,w as ActionType,eO as AddNodeTypes,eP as AgentInjectedReason,eQ as BooleanOperation,au as CodeAttributesKeyTypes,eR as ConditionType,Y as Crud,Q as CustomInstrumentationsKeyTypes,ba as DesiredStateProgress,eS as DestinationTypes,eT as EdgeTypes,E as EntityTypes,aj as ExtractionDataFormat,L as FieldTypes,R as GolangCustomProbe,O as HeadersCollectionKeyTypes,dU as InputTypes,eU as InstallationMethod,eV as InstallationStatus,V as InstrumentationRuleType,eW as IntrumentationStatus,U as JavaCustomProbe,eX as JsonOperation,a8 as K8sAttributesFrom,W as K8sResourceKind,eY as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,eZ as ListDirection,b as NodeTypes,e_ as NumberOperation,e$ as OtelDistroName,f0 as OtherEntityTypes,bf as OtherStatus,aT as OtherStatusType,aw as PayloadCollectionKeyTypes,P as PlatformType,f1 as PodContainerLifecycleStatus,f2 as PodContainerStatus,f3 as PodPhase,f4 as Profile,by as ProgrammingLanguages,f5 as SIGNAL_KEY_TO_TYPE,f6 as SIGNAL_TYPE_TO_KEY,f7 as SignalKey,H as SignalType,f8 as SortDirection,S as StatusType,f9 as StringOperation,c as Tier,fa as WorkloadRolloutReason,dx as WorkloadRolloutStatus}from"./chunks/ui-components-TeG65JGy.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{fb as VISUAL_ODIGOS_LOGO_HEIGHT,fc as VISUAL_ODIGOS_LOGO_WIDTH,eM as VisualGreenRings,fd as VisualOdigosLogo,c8 as VisualPurpleRings}from"./chunks/ui-components-Dc15jc-B.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
+ export{fb as VISUAL_ODIGOS_LOGO_HEIGHT,fc as VISUAL_ODIGOS_LOGO_WIDTH,eM as VisualGreenRings,fd as VisualOdigosLogo,c8 as VisualPurpleRings}from"./chunks/ui-components-TeG65JGy.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@odigos/ui-kit",
3
- "version": "0.0.252",
3
+ "version": "0.0.253",
4
4
  "author": "Odigos",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- import{jsx as o}from"react/jsx-runtime";import{useMemo as n}from"react";import{e as t,_ as e}from"./use-odigos-api-qSWLSy9S.js";const r=({connectionIds:r,children:i})=>{const s=t(),a=n(()=>({operations:s.operations,context:{...s.context,connectionIds:r},apolloConfig:s.apolloConfig}),[s.operations,s.context,s.apolloConfig,r.join(",")]);return o(e.Provider,{value:a,children:i})};export{r as O};
@@ -1 +0,0 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as r,useContext as n,createContext as s,useRef as o,useEffect as i}from"react";import{r as l,s as d,A as c,v as u,w as m,x as p,y as h,z as f,B as g,C as v,G as b,H as y,J as E,K as D,L as S,M as k,O as C,Q as A,R as F,U as I,V as w,W as N,c as x,E as R}from"./ui-components-Dc15jc-B.js";import{d as P}from"./use-odigos-api-qSWLSy9S.js";import{n as O,m as T,i as L,b as M,a as U,d as j,v as K,g as V,u as G}from"./helpers-CXxRJd5C.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(r=a)?!r.trim():p(r));var r}),Q=({children:n})=>{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:r,signals:n,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!r,signals:n??[],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||{},r=a[u.UrlTemplatizationRulesGroups];r?.length&&(a[u.UrlTemplatizationRulesGroups]=r.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const n=a[u.AttributeNamesToDelete];n?.length&&(a[u.AttributeNamesToDelete]=n.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 r={},n=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(n[u.CollectContainerAttributes]||n[u.CollectReplicaSetAttributes]||n[u.CollectWorkloadId]||n[u.CollectClusterId]),t=!n[u.LabelsAttributes]?.length,a=!n[u.AnnotationsAttributes]?.length;e&&t&&a&&(r[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=n[u.LabelsAttributes];s?.some(e=>!J(e,["labelKey","attributeKey","fromSources"]))&&(r[u.LabelsAttributes]=H);const o=n[u.AnnotationsAttributes];o?.some(e=>!J(e,["annotationKey","attributeKey","fromSources"]))&&(r[u.AnnotationsAttributes]=H);break}case m.AddClusterInfo:{const e=n[u.ClusterAttributes];e?.length?e.some(e=>!J(e,["attributeName","attributeStringValue"]))&&(r[u.ClusterAttributes]=H):r[u.ClusterAttributes]=z;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=n[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(r[u.AttributeNamesToDelete]=H):r[u.AttributeNamesToDelete]=e.length?H:z;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(n[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(r[u.Renames]=H):r[u.Renames]=e.length?H:z;break}case m.PiiMasking:{const e=n[u.PiiCategories];e?.length||(r[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=n[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(r[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case m.ExtractAttribute:{const e=n[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}))r[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)})&&(r[u.ExtractAttribute]="Each new span attribute name must be unique")}else r[u.ExtractAttribute]=t.length?H:z;break}}return r})(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=r(()=>({selectedOption:s,onSelectOption:f,loadAction:g,genericForm:i,validateFormData:v}),[s,f,g,i,v]);return e(q.Provider,{value:b,children:n})},W=()=>{const e=n(q);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:n,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[v,b]=t(void 0),[y,E]=t(null),D=o(null),S=l($),k=a(e=>{S.resetFormData({name:e}),S.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),b(e),E(null),D.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 r=i.find(e=>e.name===a.name&&e.name!==m);if(r)return D.current=e,void E({preparedFormData:a,existingName:r.name,editingName:v});await e(a)},[C,i,m,v]),F=a(async()=>{const e=D.current,t=y?.preparedFormData;D.current=null,E(null),e&&t&&await e(t)},[y]),I=a(()=>{D.current=null,E(null)},[]),w=r(()=>({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:n})},Y=()=>{const e=n(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z=["destinations"],ee={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},te={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(ee)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},ae=s(te),re=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:r,displayName:n,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=E(r,{});return{componentType:a,renderCondition:o,name:t,title:n,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:n})=>{const{selectedStreamName:s}=f(),{items:o}=P({subscribe:Z}).destinationsApi,[c,u]=t(null),[m,g]=t(te.unsavedDestinations),S=r(()=>"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,r)=>r===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({...ee,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?re(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const r of t){const t=r.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const r=E(e.fields,{}),n={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:r[e.name]??e.initialValue})):[]},s=re(n.fields);u({listType:v.EXISTS,option:n,dynamicFields:s})},[]),N=a(()=>{const e=d(F.formData),t={};c?.dynamicFields.forEach(({name:a,required:r})=>{if(r){const r=e.fields.find(e=>e.key===a)?.value;p(r)&&(t[a]=h.FIELD_IS_REQUIRED)}});return D(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(ae.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:n})},se=()=>n(ae),oe={disabled:!1,ruleName:"",notes:"",sourceScopes:T(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},ie=s(null),le=({children:n,sourceOptions:s=[],namespaceOptions:o=[]})=>{const[i,c]=t(null),u=l(oe),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:r,instrumentationLibraries:n,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,sourceScopes:O(r),workloads:null,instrumentationLibraries:n??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(oe)};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]||[],r=t.customInstrumentations?.[A.Java]||[];if(!e.length&&!r.length){a.customInstrumentations="Custom instrumentation are required";break}const n=e.findIndex(e=>!new F(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==n){a.customInstrumentations=`Golang probe #${n+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=r.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=r(()=>({selectedOption:i,onSelectOption:m,loadRule:p,genericForm:u,validateFormData:h,sourceOptions:s,namespaceOptions:o}),[i,m,p,u,h,s,o]);return e(ie.Provider,{value:f,children:n})},de=()=>{const e=n(ie);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var ce;!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"}(ce||(ce={}));const ue=s(null),me=["50","25","10","1"];function pe(e){const t=String(e);return me.includes(t)?t:"custom"}const he=({category:n,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(V(n)),[p,h]=t(null);i(()=>{m(V(n)),h(null)},[n]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),g=a(()=>{m(V(n)),h(null)},[n,m]),v=r(()=>({formType:ce.Create,category:n,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[n,c,f,g,p,s,o]);return e(ue.Provider,{value:v,children:d})},fe=({data:n,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(()=>{n!==v.current&&(v.current=n,n&&s?(g(K(n)),y(null),p(!0)):(p(!1),y(null)))},[n,s]);const E=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),D=a(()=>{n&&(g(K(n)),y(null),p(!0))},[n,g]),S=a(()=>{p(!1),y(null)},[]),k=r(()=>({formType:ce.View,data:n,isEditing:m,formData:h,handleChange:E,handleEdit:D,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[n,m,h,E,D,S,b,d,c]);return e(ue.Provider,{value:k,children:u})};function ge(e){const[a,n]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>pe(e)),[l,d]=t(()=>"custom"===pe(e)?String(e):"");i(()=>{n(0===e?"all":"sample");const t=pe(e);o(t),d("custom"===t?String(e):"")},[e]);const c=r(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:n,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ve=({enabled:a,keepPercentage:n,children:s})=>{const[o,l]=t(a),d=ge(n);i(()=>{l(a)},[a]);const c=r(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=r(()=>({formType:ce.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ue.Provider,{value:u,children:s})},be=({enabled:a,dropPercentage:n,children:s})=>{const[o,l]=t(a),d=ge(n);i(()=>{l(a)},[a]);const c=r(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=r(()=>({formType:ce.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ue.Provider,{value:u,children:s})},ye=({enabled:a,children:n})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=r(()=>M(s?{disabled:!1}:null),[s]),d=r(()=>({formType:ce.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ue.Provider,{value:d,children:n})},Ee=t=>{switch(t.formType){case ce.Create:return e(he,{...t});case ce.View:return e(fe,{...t});case ce.EditAutoNoisy:return e(ve,{...t});case ce.EditAutoCostReduction:return e(be,{...t});case ce.EditAutoHighlyRelevant:return e(ye,{...t})}};function De(e){const t=n(ue);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 Se={otelServiceName:"",currentStreamName:""},ke=s(null),Ce=({children:n})=>{const[s,o]=t(void 0),i=l(Se),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=r(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(ke.Provider,{value:m,children:n})},Ae=()=>{const e=n(ke);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Fe=new Set([N.StaticPod]),Ie=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}},we=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:r}=Ie(e);return t||a||r}return!0},Ne=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),xe=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),Re=({children:n,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=G(),c=l===x.Onprem,{selectedStreamName:u}=f(),[m,p]=t(!1),[h,g]=t(null),[v,b]=t([]);i(()=>{h&&b(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(h,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),r=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(r);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=>{Fe.has(e.kind)&&!c||(e.selected=!0)})}),a}return r})})},[h,s,o]);const{formDiff:y,isFormDirty:E}=r(()=>{const e=((e,t,a)=>{const r={};return e.forEach(e=>{e.namespaces.forEach(n=>{const s=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===n.name),o=n.selected||!1;if(o!==s?.selected)r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push({namespace:n.name,selected:o,currentStreamName:a}),o?r[e.clusterId]=r[e.clusterId].filter(e=>e.namespace!==n.name||e.namespace===n.name&&(!e.name||!e.kind)):n.workloads.forEach(t=>{t.selected&&r[e.clusterId].push({namespace:n.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=((e,t,a)=>{const r=[];return t.workloads.forEach(n=>{const s=e?.workloads.find(e=>e.name===n.name&&e.kind===n.kind);n.selected!==s?.selected&&r.push({namespace:t.name,name:n.name,kind:n.kind,selected:n.selected||!1,currentStreamName:a})}),r})(s,n,a);t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t))}})}),r})(v,h?.clusters||[],u);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[v,h,u]),D=a(e=>!c&&Fe.has(e),[c]),S=a(({clusterId:e,workloadId:t,selected:a,auto:r})=>{b(n=>{const s=d(n),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 r="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=r,r){s[o].namespaces[i].workloads.filter(e=>!D(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else{const e="boolean"==typeof r?r:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{D(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[D]),k=a(({clusterId:e,namespaceName:t,boolean:a,searchText:r="",searchBy:n="",filters:s})=>{b(o=>{const i=d(o),l=n===R.Namespace?r:"",c=n===R.Source?r:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((r,n)=>{e&&r.clusterId!==e||r.namespaces.forEach(({name:e,workloads:r},o)=>{if(!t||e===t)if(u)if(t){r.forEach((e,t)=>{a&&D(e.kind)||Ne(e,c,s||{showOnlySelected:!1})&&(i[n].namespaces[o].workloads[t].selected=a)});const e=i[n].namespaces[o].workloads.filter(e=>!D(e.kind)).every(e=>e.selected);i[n].namespaces[o].selected=e}else{if(!we(i[n].namespaces[o],l,s||{showOnlySelected:!1}))return;i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&D(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})}else i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&D(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})})}),i})},[D]);return e(xe.Provider,{value:{snapshots:h,setSnapshots:g,isFetching:m,setIsFetching:p,formData:v,handleSourceChange:S,handleSelectAll:k,formDiff:y,isFormDirty:E},children:n})},Pe=()=>n(xe);export{Q as A,X as D,Fe as E,le as R,ce as S,ne as a,Ee as b,Ce as c,Re as d,Y as e,se as f,de as g,De as h,Ae as i,Pe as j,Ne as k,we as l,Ie 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,useApolloClient as E,useLazyQuery as f,useQuery as T,gql as _}from"@apollo/client";import{jsx as p}from"react/jsx-runtime";import{onError as y}from"@apollo/client/link/error";import{setContext as S}from"@apollo/client/link/context";import{getMainDefinition as R}from"@apollo/client/utilities";import{o as m,y as A,D as O,S as I,X as N,Y as C,E as g,P as h,c as L,z as U,Z as P,_ as G,$ as D,a0 as v,a1 as w,a2 as b,a3 as F}from"./ui-components-Dc15jc-B.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")},M=r(null),Y=()=>{const e=t(M);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},H=({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=S(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=R(e);return"OperationDefinition"===t.kind&&"subscription"===t.operation},e.wsLink,o));const l=e.defaultFetchPolicies;return new d({link:o,cache:new u({addTypename:e.addTypename??!0,typePolicies:e.cacheTypePolicies}),defaultOptions:{watchQuery:{fetchPolicy:l?.watchQuery??"cache-and-network"},query:{fetchPolicy:l?.query??"cache-first"},mutate:{fetchPolicy:l?.mutate??"network-only"}}})})(t),[t.httpUrl,t.wsLink,t.addTypename,t.credentials]),E=e(()=>({operations:r,context:a,apolloConfig:t}),[r,a,t]);return p(l,{client:o,children:p(M.Provider,{value:E,children:n})})},W=M,x=e=>({error:e,results:[],allSucceeded:!1,anySucceeded:!1,successCount:0,failureCount:0}),K=(e,t)=>{if(e)return"function"==typeof e?e(t):e},V=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)},$=(e,t)=>e.client??t,B=async(e,t,r,a,n)=>{if(!t)return{error:"Query operation not configured"};const o=K(t.document,a);if(!o)return{error:"Query operation not supported in this context"};if(t.canRun&&!t.canRun(a))return{data:void 0};const i=t.transformVariables?t.transformVariables(r,a):r,s=$(t,e);try{const e=await s.query({query:o,variables:i,fetchPolicy:"network-only"});return{data:t.transformResult?t.transformResult(e.data,a):e.data,error:e.error?V(e.error):void 0}}catch(e){return{error:V(e)}}},j=async(e,t,r,a)=>{if(!t)return{error:"Mutation operation not configured"};const n=K(t.document,a);if(!n)return{error:"Mutation operation not supported in this context"};if(t.canRun&&!t.canRun(a))return{data:void 0};const o=t.transformVariables?t.transformVariables(r,a):r,i=$(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:V(e)}}},q=async(e,t,r,a,n)=>{if(!t)return x("Multi fetch operation not configured");if(!r.length)return x("No proxy ids supplied for multi fetch");const o=$(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=V(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 B(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}},Q=(e,t)=>{if(e)return"string"==typeof e?e:N(e,t)},z=e=>{const{addNotification:t}=m(),r=(r,a,n,o,i)=>t({type:r,title:a,message:n,crdType:e,target:Q(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:O.READONLY,message:A.READONLY_WARNING,hideFromHistory:!0})}}},X=e=>{e({type:I.Warning,title:O.READONLY,message:A.READONLY_WARNING,hideFromHistory:!0})},J=_`
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}=Y(),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??J,{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]),p=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:p,unsupported:u}},ne=(t,r)=>{const{operations:n,context:o}=Y(),i=ee(n,t),s=e(()=>Z(i?.document,o),[i,o]),c=!i||!s,[d,u]=f(s??J,{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}=Y(),s=E(),c=ee(o,t),d=e(()=>Z(c?.document,i),[c,i]),u=!c||!d,[l,f]=n({loading:!1,called:!1}),T=a(()=>f({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;f(e=>({...e,loading:!0,called:!0}));try{const e=await a.mutate({mutation:d,variables:t}),n=te(c,e.data,i);if(f({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 f({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=(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}},se=(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}},ce={filter:{markedForInstrumentation:!0}},de=[],ue=[],le=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){}},Ee=[],fe=[],Te=[],_e=(e,t)=>({...e,fields:e.fields.filter(({value:e})=>void 0!==e),currentStreamName:t}),pe=t=>{const{operations:r,context:n}=Y(),i=E(),s=t?.subscribe,c=!!s&&s.includes("sources"),d=!!s&&s.includes("destinations"),u=!!s&&s.includes("actions"),l=!!s&&s.includes("rules"),f=!!s&&s.includes("namespaces"),T=!!s&&s.includes("dataStreams"),_=!!s&&s.includes("destinationCategories"),p=!!s&&s.includes("potentialDestinations"),y=((e,t,r)=>{const n=E(),{notifyError:o,notifySuccess:i,notifyPending:s,notifyReadonly:c}=z(g.Source),{selectedStreamName:d}=U(),{setProgress:u,resetProgress:l}=P(),{setConfiguredSources:f,setConfiguredFutureApps:T}=G(),_=ae("GET_WORKLOADS",ce,{fetchPolicy:"cache-first",skip:!r?.subscribe}),p=_.data?.workloads??de,y=(e,t)=>{const{progress:r}=P.getState();e>0&&u(D.Instrumenting,{total:(r[D.Instrumenting]?.total||0)+e,current:r[D.Instrumenting]?.current||0}),t>0&&u(D.Uninstrumenting,{total:(r[D.Uninstrumenting]?.total||0)+t,current:r[D.Uninstrumenting]?.current||0})},S=a(async()=>{const{error:r}=await B(n,e.GET_WORKLOADS,ce,t);r&&o(C.Read,r)},[n,e.GET_WORKLOADS,t,o]);return{items:p,loading:_.loading,fetchAll:S,fetchByTargets:async(r,a)=>{const i=!!a?.slim,s=r.map(e=>v(e,g.Source)).filter(e=>e.namespace&&e.name&&e.kind);if(0===s.length)return;if(s.length>50)return void await S();const c=i&&e.GET_WORKLOADS_BY_IDS_SLIM?e.GET_WORKLOADS_BY_IDS_SLIM:e.GET_WORKLOADS_BY_IDS,{error:d}=await B(n,c,{ids:s.map(({namespace:e,kind:t,name:r})=>({namespace:e,kind:t,name:r}))},t);d?o(C.Read,d):await S()},fetchById:async r=>{const{data:a,error:i}=await B(n,e.GET_WORKLOADS_BY_IDS,{ids:[{namespace:r.namespace,kind:r.kind,name:r.name}]},t);if(!i)return await S(),a?.workloadsByIds?.find(e=>e.id.namespace===r.namespace&&e.id.kind===r.kind&&e.id.name===r.name);o(C.Read,i)},fetchLibraries:async r=>B(n,e.GET_SOURCE_LIBRARIES,r,t),fetchPeerSources:async r=>B(n,e.GET_PEER_SOURCES,{serviceName:r},t),persist:async(r,a)=>{if(t.isReadonly)return c();const{payload:i,isEmpty:u}=ie(r,p,d,y),{payload:E,isEmpty:_}=se(a,d);let S=!1;u||(S=!0,s("Persisting sources...")),_||S||s("Persisting namespaces...");const{error:R}=await j(n,e.PERSIST_SOURCES,i,t);if(R&&(l(D.Instrumenting),l(D.Uninstrumenting),o(C.Update,R)),e.PERSIST_NAMESPACES){const{error:r}=await j(n,e.PERSIST_NAMESPACES,E,t);r&&o(C.Update,r)}f({}),T({})},persistV2:async r=>{if(t.isReadonly)return c(),{error:"readonly"};const a=[];for(const[,o]of Object.entries(r)){const r={sources:[]},i={namespaces:[]};for(const e of o)e.name&&e.kind?r.sources.push(e):i.namespaces.push(e);if(i.namespaces.length>0&&e.PERSIST_NAMESPACES){const{error:r}=await j(n,e.PERSIST_NAMESPACES,i,t);r&&a.push(r)}if(r.sources.length>0){const{error:o}=await j(n,e.PERSIST_SOURCES,r,t);o&&a.push(o)}}return a.length?{error:a.join(", ")}:void 0},update:async(r,a)=>{if(t.isReadonly)return c();s("Updating source...");const u={sourceId:r,patchSourceRequest:{...a,currentStreamName:d}},{data:l,error:E}=await j(n,e.UPDATE_SOURCE,u,t);E?o(C.Update,E,r):l?.updateK8sActualSource&&i(C.Update,`Successfully updated "${r.name}" source`,r)},restartWorkloads:async r=>{if(t.isReadonly)return c();s("Restarting sources...");const{data:a,error:d}=await j(n,e.RESTART_WORKLOADS,{sourceIds:r},t);d?o(C.Update,d):a?.restartWorkloads&&i(C.Update,`Successfully restarted ${r.length} sources`)},restartPod:async(r,a)=>{if(t.isReadonly)return c();s("Restarting pod...");const{data:d,error:u}=await j(n,e.RESTART_POD,{namespace:r,name:a},t);u?o(C.Update,u):d?.restartPod&&i(C.Update,`Successfully restarted pod ${r}/${a}`)},recoverFromRollback:async r=>{if(t.isReadonly)return c();s("Recovering from rollback...");const{data:a,error:d}=await j(n,e.RECOVER_FROM_ROLLBACK,{sourceId:r},t);d?o(C.Update,d,r):a?.recoverFromRollbackForWorkload&&i(C.Update,"Successfully triggered recovery from rollback")}}})(r,n,{subscribe:c}),S=((e,t,r)=>{const a=E(),{notifyError:n,notifySuccess:o,notifyReadonly:i}=z(g.Destination),{selectedStreamName:s}=U(),c=ae("GET_DESTINATIONS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe}),d=ae("GET_DESTINATION_CATEGORIES",void 0,{skip:!r?.subscribeCategories}),u=ae("GET_POTENTIAL_DESTINATIONS",void 0,{skip:!r?.subscribePotential}),l=c.data?.computePlatform?.destinations??c.data?.destinations??Te,f=async()=>{const{error:r}=await B(a,e.GET_DESTINATIONS,void 0,t);r&&n(C.Read,r)};return{items:l,loading:c.loading,fetchAll:f,categoriesResult:d.data,categoriesLoading:d.loading,potentialResult:u.data,potentialLoading:u.loading,testConnection:async r=>{const{data:n}=await j(a,e.TEST_DESTINATION_CONNECTION,{destination:_e(r,s)},t);return n},create:async r=>{if(t.isReadonly)return i();const{error:c}=await j(a,e.CREATE_DESTINATION,{destination:_e(r,s)},t);c?n(C.Create,c):(o(C.Create,`Successfully created "${r.type}" destination`),await f())},update:async(r,c)=>{if(t.isReadonly)return i();const{data:d,error:u}=await j(a,e.UPDATE_DESTINATION,{id:r,destination:_e(c,s)},t);u?n(C.Update,u,r):d?.updateDestination&&(o(C.Update,`Successfully updated "${c.type}" destination`,r),await f())},remove:async r=>{if(t.isReadonly)return i();const c=l.find(e=>w(e)===r)?.destinationType?.type,{error:d}=await j(a,e.DELETE_DESTINATION,{id:r,currentStreamName:s},t);d?n(C.Delete,d,r):(o(C.Delete,`Successfully deleted "${c??r}" destination`,r),await f())}}})(r,n,{subscribe:d,subscribeCategories:_,subscribePotential:p}),R=((e,t,r)=>{const a=E(),{notifyError:n,notifySuccess:o,notifyReadonly:i}=z(g.Action),s=ae("GET_ACTIONS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe}),c=s.data?.computePlatform?.actions??s.data?.actions??ue,d=async()=>{const{error:r}=await B(a,e.GET_ACTIONS,void 0,t);r&&n(C.Read,r)};return{items:c,loading:s.loading,fetchAll:d,create:async r=>{if(t.isReadonly)return i();if(!e.CREATE_ACTION)return;const{error:s}=await j(a,e.CREATE_ACTION,{action:r},t);s?n(C.Create,s):(o(C.Create,`Successfully created "${r.type}" action`),await d())},update:async(r,s)=>{if(t.isReadonly)return i();if(!e.UPDATE_ACTION)return;const{error:c}=await j(a,e.UPDATE_ACTION,{id:r,action:s},t);c?n(C.Update,c,r):(o(C.Update,`Successfully updated "${s.type}" action`,r),await d())},remove:async(r,s)=>{if(t.isReadonly)return i();if(!e.DELETE_ACTION)return;const{error:c}=await j(a,e.DELETE_ACTION,{id:r,actionType:s},t);c?n(C.Delete,c,r):(o(C.Delete,`Successfully deleted "${s}" action`,r),await d())}}})(r,n,{subscribe:u}),A=((t,r,a)=>{const n=E(),{notifyError:o,notifySuccess:i,notifyReadonly:s}=z(g.InstrumentationRule),c=ae("GET_INSTRUMENTATION_RULES",void 0,{fetchPolicy:"cache-first",skip:!a?.subscribe}),d=e(()=>(c.data?.computePlatform?.instrumentationRules??c.data?.instrumentationRules??[]).map(b),[c.data]),u=async()=>{const{error:e}=await B(n,t.GET_INSTRUMENTATION_RULES,void 0,r);e&&o(C.Read,e)};return{items:d,loading:c.loading,fetchAll:u,create:async(e,a)=>{if(r.isReadonly)return s();if(!t.CREATE_INSTRUMENTATION_RULE)return;const{error:c}=await j(n,t.CREATE_INSTRUMENTATION_RULE,{instrumentationRule:F(e)},r);c?o(C.Create,c):(i(C.Create,`Successfully created${a?` "${a}"`:""} rule`),await u())},update:async(e,a,c)=>{if(r.isReadonly)return s();if(!t.UPDATE_INSTRUMENTATION_RULE)return;const{error:d}=await j(n,t.UPDATE_INSTRUMENTATION_RULE,{ruleId:e,instrumentationRule:F(a)},r);d?o(C.Update,d,e):(i(C.Update,`Successfully updated${c?` "${c}"`:""} rule`,e),await u())},remove:async(e,a)=>{if(r.isReadonly)return s();if(!t.DELETE_INSTRUMENTATION_RULE)return;const{error:c}=await j(n,t.DELETE_INSTRUMENTATION_RULE,{ruleId:e},r);c?o(C.Delete,c,e):(i(C.Delete,`Successfully deleted${a?` "${a}"`:""} rule`,e),await u())}}})(r,n,{subscribe:l}),O=((e,t,r)=>{const a=E(),{addNotification:n}=m(),{setDataStreams:i}=U(),s=!!r?.subscribe,c=(e,t)=>n({type:I.Error,title:e,message:t}),d=ae("GET_DATA_STREAMS",void 0,{fetchPolicy:"cache-first",skip:!s}),u=d.data?.computePlatform?.dataStreams??d.data?.dataStreams??fe;o(()=>{s&&i(u)},[s,JSON.stringify(u.map(e=>e.name))]);const l=async()=>{const{data:r,error:n}=await B(a,e.GET_DATA_STREAMS,void 0,t);if(n)c(C.Read,n);else if(r){const e=r.computePlatform?.dataStreams??r.dataStreams??[];i(e)}},f=e.CREATE_DATA_STREAM?async r=>{if(t.isReadonly)return X(n);const{error:o}=await j(a,e.CREATE_DATA_STREAM,{stream:r},t);o?c(C.Create,o):await l()}:void 0;return{items:u,loading:d.loading,fetchAll:l,create:f,update:async(r,o)=>{if(t.isReadonly)return X(n);const{error:i}=await j(a,e.UPDATE_DATA_STREAM,{id:r,dataStream:o},t);i?c(C.Update,i):await l()},remove:async r=>{if(t.isReadonly)return X(n);const{error:o}=await j(a,e.DELETE_DATA_STREAM,{id:r},t);o?c(C.Delete,o):await l()}}})(r,n,{subscribe:T}),N=((e,t,r)=>{const a=E(),{notifyError:n,notifyReadonly:o}=z(g.Namespace),i=ae("GET_NAMESPACES_WITH_WORKLOADS",void 0,{fetchPolicy:"cache-first",skip:!r?.subscribe});return{items:i.data?.namespaces??Ee,loading:i.loading,fetchAll:async()=>{const r=await B(a,e.GET_NAMESPACES_WITH_WORKLOADS,void 0,t);return r.error&&n(C.Read,r.error),r},persist:async r=>{if(t.isReadonly)return o();const{error:i}=await j(a,e.PERSIST_NAMESPACES,r,t);return i&&n(C.Update,i),i?{error:i}:void 0}}})(r,n,{subscribe:f}),k=((e,t)=>{const r=E(),{notifyError:a}=z(g.Source);return{fetch:async n=>{const o=await B(r,e.GET_K8S_MANIFEST,n,t);return o.error&&a(C.Read,o.error),o}}})(r,n),M=((e,t)=>{const r=E(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=z(g.Source);return{getEffectiveConfig:async a=>e.GET_EFFECTIVE_CONFIG?B(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 j(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()=>B(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 j(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 j(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}})(r,n),H=((e,t)=>{const r=E(),{apolloConfig:a}=Y();return{fetchDescribeOdigos:e.GET_DESCRIBE_ODIGOS?async()=>B(r,e.GET_DESCRIBE_ODIGOS,void 0,t):void 0,fetchDescribeSource:e.GET_DESCRIBE_SOURCE?async a=>B(r,e.GET_DESCRIBE_SOURCE,a,t):void 0,downloadDiagnose:e.GET_DIAGNOSE?async(n,o)=>{const i=await B(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 le(a),i}:void 0}})(r,n),W=((e,t)=>{const r=E(),{notifyError:a,notifyReadonly:n}=z(g.Source);return{fetchTokens:e.GET_TOKENS?async()=>B(r,e.GET_TOKENS,void 0,t):void 0,updateToken:e.UPDATE_TOKEN?async o=>{if(t.isReadonly)return n();const{error:i}=await j(r,e.UPDATE_TOKEN,{token:o},t);return i&&a(C.Update,i),i?{error:i}:void 0}:void 0}})(r,n),x=((e,t)=>{const r=E();return{fetch:async()=>B(r,e.GET_METRICS,void 0,t)}})(r,n),K=((e,t)=>{const r=E();return{fetch:e.GET_SERVICE_MAP?async()=>B(r,e.GET_SERVICE_MAP,void 0,t):void 0}})(r,n),V=((e,t)=>{const r=E();return{fetchSlots:e.GET_PROFILING_SLOTS?async()=>B(r,e.GET_PROFILING_SLOTS,void 0,t):void 0,fetchSourceProfiling:e.GET_SOURCE_PROFILING?async a=>B(r,e.GET_SOURCE_PROFILING,a,t):void 0,enableProfiling:e.ENABLE_SOURCE_PROFILING?async a=>j(r,e.ENABLE_SOURCE_PROFILING,a,t):void 0}})(r,n),$=((e,t)=>{const r=E();return{getGatewayInfo:e.GET_GATEWAY_INFO?async()=>B(r,e.GET_GATEWAY_INFO,void 0,t):void 0,getGatewayPods:e.GET_GATEWAY_PODS?async()=>B(r,e.GET_GATEWAY_PODS,void 0,t):void 0,getNodeCollectorInfo:e.GET_NODE_COLLECTOR_INFO?async()=>B(r,e.GET_NODE_COLLECTOR_INFO,void 0,t):void 0,getNodeCollectorPods:e.GET_NODE_COLLECTOR_PODS?async()=>B(r,e.GET_NODE_COLLECTOR_PODS,void 0,t):void 0,getExtendedPodInfo:e.GET_COLLECTOR_POD_INFO?async(a,n)=>B(r,e.GET_COLLECTOR_POD_INFO,{namespace:a,name:n},t):void 0}})(r,n),q=((e,t)=>{const r=E(),{notifyError:a,notifySuccess:n,notifyReadonly:o}=z(g.SamplingRule),i=async()=>{e.GET_SAMPLING_RULES&&await B(r,e.GET_SAMPLING_RULES,void 0,t)},s=(e,s)=>e?async c=>{if(t.isReadonly)return o();const{error:d}=await j(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 j(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 j(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{fetchAll:e.GET_SAMPLING_RULES?async()=>B(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 j(r,e.UPDATE_LOCAL_UI_SAMPLING_CONFIG,{config:n},t);return s?a(C.Update,s):await i(),s?{error:s}:void 0}:void 0}})(r,n),Q=((e,t)=>{const r=E();return{getAllClusterSnapshots:e.GET_ALL_CLUSTER_SNAPSHOTS?async()=>B(r,e.GET_ALL_CLUSTER_SNAPSHOTS,void 0,t):void 0,getClusterSnapshot:e.GET_CLUSTER_SNAPSHOT?async a=>B(r,e.GET_CLUSTER_SNAPSHOT,{clusterId:a},t):void 0}})(r,n);return{sourcesApi:y,destinationsApi:S,actionsApi:R,instrumentationRulesApi:A,dataStreamsApi:O,namespacesApi:N,k8sManifestApi:k,configApi:M,describeApi:H,tokensApi:W,metricsApi:x,serviceMapApi:K,profilingApi:V,collectorsApi:$,samplingApi:q,snapshotsApi:Q,capabilities:e(()=>((e,t)=>{const r=t.platformType===h.Vm,a=t.tier===L.Onprem,n=!r;return{canBulkPersistSources:n&&!!e.PERSIST_SOURCES,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}})(r,n),[r,n]),resetCache:a(async()=>{await i.cache.reset()},[i])}};export{H as O,W as _,ie as a,oe as b,ae as c,pe as d,Y as e,q as f,se as p,j as r,ne as u};