@odigos/ui-kit 0.0.252 → 0.0.254
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 +15 -0
- package/docs/api-context.md +44 -38
- package/lib/chunks/{connections-scope-Cb3gZ8MW.js → connections-scope-DDNmfpzA.js} +1 -1
- package/lib/chunks/{flow-CAOY59Tu.js → flow-Bu1VbeQt.js} +1 -1
- package/lib/chunks/{helpers-CXxRJd5C.js → helpers-Cy9W3KCg.js} +1 -1
- package/lib/chunks/{index-BgflYoEI.js → index-D2nQHheF.js} +1 -1
- package/lib/chunks/source-instrument-form-context-BJGS7jKX.js +1 -0
- package/lib/chunks/{ui-components-Dc15jc-B.js → ui-components-D_eeOuIL.js} +7 -7
- package/lib/chunks/use-odigos-api-W15RTo5l.js +5 -0
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/strings/index.d.ts +2 -1
- package/lib/constants.js +1 -1
- package/lib/containers/v2.js +138 -138
- package/lib/containers.js +7 -7
- package/lib/contexts/odigos-api/hooks/use-actions-api.d.ts +16 -8
- package/lib/contexts/odigos-api/hooks/use-collectors-api.d.ts +12 -1
- package/lib/contexts/odigos-api/hooks/use-config-api.d.ts +10 -1
- package/lib/contexts/odigos-api/hooks/use-data-streams-api.d.ts +19 -13
- package/lib/contexts/odigos-api/hooks/use-destinations-api.d.ts +30 -21
- package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +12 -4
- package/lib/contexts/odigos-api/hooks/use-metrics-api.d.ts +9 -3
- package/lib/contexts/odigos-api/hooks/use-namespace-api.d.ts +14 -4
- package/lib/contexts/odigos-api/hooks/use-profiling-api.d.ts +5 -0
- package/lib/contexts/odigos-api/hooks/use-sampling-api.d.ts +18 -1
- package/lib/contexts/odigos-api/hooks/use-service-map-api.d.ts +8 -1
- package/lib/contexts/odigos-api/hooks/use-snapshots-api.d.ts +24 -0
- package/lib/contexts/odigos-api/hooks/use-sources-api.d.ts +24 -6
- package/lib/contexts/odigos-api/hooks/use-tokens-api.d.ts +11 -4
- package/lib/contexts/odigos-api/index.d.ts +4 -3
- package/lib/contexts/odigos-api/platform-helpers.d.ts +4 -2
- package/lib/contexts/odigos-api/types.d.ts +41 -28
- package/lib/contexts/odigos-api/use-odigos-api.d.ts +21 -36
- package/lib/contexts/odigos-api.js +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +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.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/source-instrument-form-context-Rk2YlyRb.js +0 -1
- package/lib/chunks/use-odigos-api-qSWLSy9S.js +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.254](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.253...ui-kit-v0.0.254) (2026-06-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* init vm aligments ([#1010](https://github.com/odigos-io/ui-kit/issues/1010)) ([4b7265f](https://github.com/odigos-io/ui-kit/commit/4b7265fa6f74248512b9391a793be56a0996da24))
|
|
9
|
+
* React encountered two children with the same key ([#1009](https://github.com/odigos-io/ui-kit/issues/1009)) ([1b51af5](https://github.com/odigos-io/ui-kit/commit/1b51af5080a4750e0801a2991b622c1af12c1806))
|
|
10
|
+
|
|
11
|
+
## [0.0.253](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.252...ui-kit-v0.0.253) (2026-06-17)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **api:** streamline operation execution by introducing custom executor support and removing legacy types ([#1006](https://github.com/odigos-io/ui-kit/issues/1006)) ([c425b82](https://github.com/odigos-io/ui-kit/commit/c425b82568dfa61bf96b4fefc068085c1548d79b))
|
|
17
|
+
|
|
3
18
|
## [0.0.252](https://github.com/odigos-io/ui-kit/compare/ui-kit-v0.0.251...ui-kit-v0.0.252) (2026-06-16)
|
|
4
19
|
|
|
5
20
|
|
package/docs/api-context.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- **Containers fetch their own data.** Every `_v2` container that previously took a forest of API-function props now consumes `useOdigosApi()` / `useApiQuery(key)` from the kit's API context. Pages collapse to one-liners.
|
|
10
10
|
- **Hosts ship a thin adapter** (~250 lines) mapping GraphQL documents to typed `Operation` slots. No more 16 CRUD hooks per host (`useSourceCRUD`, `useDestinationCRUD`, …).
|
|
11
11
|
- **Apollo cache is the entity store.** The kit's `useEntityStore` Zustand store is gone — sources/destinations/actions/rules/namespaces all flow through Apollo's normalized cache via `useApiQuery('GET_X', …, { fetchPolicy: 'cache-first' })`. Mutations call `runMutation` then `await fetchAll()`; cache writes broadcast to every active subscriber.
|
|
12
|
-
- **Uniform API surface.** `useOdigosApi()` returns `{ sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi, …, capabilities, resetCache }` — every
|
|
12
|
+
- **Uniform API surface.** `useOdigosApi()` returns `{ sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi, …, capabilities, resetCache }` — every namespace exposes its reactive reads as `use…()` sub-hooks (`sourcesApi.useSources()` → `{ items, loading, refetch }`) plus imperative methods (`fetchAll`, `create`, …) as top-level keys. No aliasing on destructure, no stuttery `sourcesApi.sources`.
|
|
13
13
|
- **Strict types end-to-end.** ~80 named `OdigosApiOperations` slots, each typed as `Operation<TData, TVars>`. Zero `any`, zero envelope/bare unions, zero `unknown` data fields at the public hook surface.
|
|
14
14
|
- **Storybook is production-unaware.** The kit's runtime has no mock context, no interceptor hooks. The Storybook mock provider uses a custom Apollo `ApolloLink` that intercepts stub queries with predefined data.
|
|
15
15
|
- **Mock data lives in `.storybook/`.** `src/mock-data/` was relocated; production builds never touch it.
|
|
@@ -89,7 +89,7 @@ graph TB
|
|
|
89
89
|
ADAPTER --> PROVIDER[OdigosApiProvider]
|
|
90
90
|
PROVIDER --> APOLLO["ApolloClient<br/>(normalized cache)"]
|
|
91
91
|
PROVIDER --> CTX[OdigosApiContext]
|
|
92
|
-
CTX --> HOOK1["useOdigosApi()<br/>sourcesApi.
|
|
92
|
+
CTX --> HOOK1["useOdigosApi()<br/>sourcesApi.useSources(), fetchAll, …"]
|
|
93
93
|
CTX --> HOOK2["useApiQuery('GET_X')"]
|
|
94
94
|
CTX --> HOOK3["useApiMutation('CREATE_X')"]
|
|
95
95
|
HOOK1 -.reads / writes.-> APOLLO
|
|
@@ -353,16 +353,17 @@ const [updateToken, { loading: saving }] = useApiMutation('UPDATE_TOKEN', {
|
|
|
353
353
|
|
|
354
354
|
`useApiQuery` consults the operations map, applies `transformVariables` / `transformResult` automatically, and returns `{ data: SlotData<K>, loading, error, refetch, unsupported }`. The `unsupported` flag is `true` when the host adapter omitted the slot — containers either render an "operation not supported" UI or hide the affordance via `capabilities.canX`.
|
|
355
355
|
|
|
356
|
-
### Imperative — `useOdigosApi()` + per-domain APIs
|
|
356
|
+
### Imperative + reactive — `useOdigosApi()` + per-domain APIs
|
|
357
357
|
|
|
358
358
|
For places that need both a cached list and dispatchable methods (event handlers, side-effect chains, drawers):
|
|
359
359
|
|
|
360
360
|
```typescript
|
|
361
|
-
|
|
362
|
-
const { sourcesApi } = useOdigosApi({ subscribe: ['sources'] });
|
|
361
|
+
const { sourcesApi } = useOdigosApi();
|
|
363
362
|
|
|
364
|
-
// Cached list — read
|
|
365
|
-
|
|
363
|
+
// Cached list — read it via the domain's reactive `use…()` sub-hook. The
|
|
364
|
+
// sub-hook owns `useApiQuery('GET_WORKLOADS')`, so calling it IS the
|
|
365
|
+
// subscription. Kept fresh by Apollo's cache + SSE-driven refetch.
|
|
366
|
+
const { items: sources, loading } = sourcesApi.useSources();
|
|
366
367
|
|
|
367
368
|
const onClick = async () => {
|
|
368
369
|
await sourcesApi.update(sourceId, formData);
|
|
@@ -371,50 +372,55 @@ const onClick = async () => {
|
|
|
371
372
|
};
|
|
372
373
|
```
|
|
373
374
|
|
|
374
|
-
Every
|
|
375
|
+
Every domain API splits its surface into two consistent halves:
|
|
375
376
|
|
|
376
|
-
|
|
377
|
+
- **Reactive reads** are exposed as `use…()` sub-hooks (`sourcesApi.useSources()`, `actionsApi.useActions()`, `destinationsApi.useDestinations()`, `collectorsApi.useGatewayInfo()`, `configApi.useEffectiveConfig()`, …). Each owns a `useApiQuery('GET_…')` and returns the reactive `{ items, loading, refetch }` (list hooks) or `{ data, loading, … }` (single/parameterized hooks).
|
|
378
|
+
- **Imperative methods** (`fetchAll`, `create`, `update`, `remove`, `persist`, `testConnection`, …) stay as plain top-level keys.
|
|
377
379
|
|
|
378
|
-
The
|
|
380
|
+
The `*Api` suffix on the top-level keys means destructuring stays rename-free even when the consumer has a local `sources` / `destinations` variable.
|
|
379
381
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
382
|
+
#### Reactive reads via `use…()` sub-hooks
|
|
383
|
+
|
|
384
|
+
Calling a `use…()` sub-hook is the opt-in: the underlying `useApiQuery('GET_…')` only mounts (and the network request only fires) for the queries a container actually reads. `useOdigosApi()` itself fires nothing — calling it from a page that only needs `configApi` (e.g. `/settings`) does NOT trigger any list query. Because the sub-hooks are React hooks, call them unconditionally at the top level of a container, exactly like any other hook:
|
|
383
385
|
|
|
386
|
+
```typescript
|
|
384
387
|
export const Columns: FC = () => {
|
|
385
|
-
const { sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi } = useOdigosApi(
|
|
386
|
-
|
|
387
|
-
});
|
|
388
|
-
const { items:
|
|
388
|
+
const { sourcesApi, destinationsApi, actionsApi, instrumentationRulesApi } = useOdigosApi();
|
|
389
|
+
const { items: sources, loading: sourcesLoading } = sourcesApi.useSources();
|
|
390
|
+
const { items: destinations } = destinationsApi.useDestinations();
|
|
391
|
+
const { items: actions } = actionsApi.useActions();
|
|
392
|
+
const { items: rules } = instrumentationRulesApi.useRules();
|
|
389
393
|
// …
|
|
390
394
|
};
|
|
391
395
|
```
|
|
392
396
|
|
|
393
|
-
Symptoms of forgetting the
|
|
394
|
-
|
|
395
|
-
| Container |
|
|
396
|
-
| --------------------------------------- |
|
|
397
|
-
| `_v2/overview/columns` | `
|
|
398
|
-
| `_v2/overview/drawers` | `
|
|
399
|
-
| `_v2/overview/filters` | `
|
|
400
|
-
| `_v2/overview/search` | `
|
|
401
|
-
| `_v2/overview/data-stream-select` | `
|
|
402
|
-
| `_v2/sampling-rules` | `
|
|
403
|
-
| `service-map` | `
|
|
404
|
-
| `_v2/_drawers/edit-source-drawer/peers` | `
|
|
405
|
-
| `_v2/_drawers/system-drawer/diagnose` | `
|
|
406
|
-
| `
|
|
397
|
+
Symptoms of forgetting to call the sub-hook: empty lists in the UI, `loading` permanently `false`, no auto-refresh on SSE. The fix is always to call the missing `use…()` sub-hook. Containers that only call imperative methods (create / update / delete / fetchAll) never call the sub-hook — the domain still exposes those methods, just without any auto-fetch.
|
|
398
|
+
|
|
399
|
+
| Container | Reactive sub-hooks called |
|
|
400
|
+
| --------------------------------------- | ------------------------------------------------------------------------------- |
|
|
401
|
+
| `_v2/overview/columns` | `useSources()`, `useDestinations()`, `useActions()`, `useRules()` |
|
|
402
|
+
| `_v2/overview/drawers` | `useSources()` |
|
|
403
|
+
| `_v2/overview/filters` | `useSources()`, `useNamespaces()` |
|
|
404
|
+
| `_v2/overview/search` | `useSources()`, `useDestinations()`, `useActions()`, `useRules()` |
|
|
405
|
+
| `_v2/overview/data-stream-select` | `useDataStreams()` |
|
|
406
|
+
| `_v2/sampling-rules` | `useSources()`, `useSamplingRules()` |
|
|
407
|
+
| `service-map` | `useSources()` |
|
|
408
|
+
| `_v2/_drawers/edit-source-drawer/peers` | `useSources()` |
|
|
409
|
+
| `_v2/_drawers/system-drawer/diagnose` | `useNamespaces()` |
|
|
410
|
+
| `_v2/_drawers/add-source-drawer` | `useSnapshots()`, `useNamespaces()` |
|
|
411
|
+
| `_v2/_drawers/add-destination-drawer` | `useDestinations()`, `useDestinationCategories()`, `usePotentialDestinations()` |
|
|
412
|
+
| `contexts/destination-form-context` | `useDestinations()` |
|
|
407
413
|
|
|
408
414
|
The full surface returned by `useOdigosApi()`:
|
|
409
415
|
|
|
410
416
|
```typescript
|
|
411
417
|
const {
|
|
412
|
-
sourcesApi, // {
|
|
413
|
-
destinationsApi, // {
|
|
414
|
-
actionsApi, // {
|
|
415
|
-
instrumentationRulesApi, // {
|
|
416
|
-
namespacesApi, // {
|
|
417
|
-
dataStreamsApi, // {
|
|
418
|
+
sourcesApi, // { useSources, fetchAll, fetchByTargets, fetchById, persist, update, usePeerSources, … }
|
|
419
|
+
destinationsApi, // { useDestinations, useDestinationCategories, usePotentialDestinations, fetchAll, create, update, remove, testConnection }
|
|
420
|
+
actionsApi, // { useActions, fetchAll, create, update, remove }
|
|
421
|
+
instrumentationRulesApi, // { useRules, fetchAll, create, update, remove }
|
|
422
|
+
namespacesApi, // { useNamespaces, fetchAll, persist }
|
|
423
|
+
dataStreamsApi, // { useDataStreams, fetchAll, create, update, remove }
|
|
418
424
|
k8sManifestApi,
|
|
419
425
|
configApi,
|
|
420
426
|
describeApi,
|
|
@@ -463,7 +469,7 @@ graph LR
|
|
|
463
469
|
|
|
464
470
|
**Reads.** Every consumer of `useOdigosApi().sourcesApi` registers an Apollo observer of `GET_WORKLOADS` via `useApiQuery`. The first observer fetches over the network, every subsequent one hits the shared cache (`fetchPolicy: 'cache-first'`). Cache writes broadcast — when _any_ refetch lands, every observer re-renders with the new list.
|
|
465
471
|
|
|
466
|
-
**Writes.** Mutations call `runMutation` and `await fetchAll()` immediately after success. The runner's `client.query({ fetchPolicy: 'network-only' })` writes the response into the cache, which broadcasts. Every container that reads `sourcesApi.items` updates within one render — no Zustand selector hop, no manual `setEntities`. Apollo's request dedup keeps the cost of "fan-out from one mutation" at a single network round-trip.
|
|
472
|
+
**Writes.** Mutations call `runMutation` and `await fetchAll()` immediately after success. The runner's `client.query({ fetchPolicy: 'network-only' })` writes the response into the cache, which broadcasts. Every container that reads `sourcesApi.useSources().items` updates within one render — no Zustand selector hop, no manual `setEntities`. Apollo's request dedup keeps the cost of "fan-out from one mutation" at a single network round-trip.
|
|
467
473
|
|
|
468
474
|
**SSE.** Both host SSE handlers (`useSSE.ts`) drop their old `useEntityStore` imports and refresh through the same `sourcesApi.fetchAll()` / `destinationsApi.fetchAll()` entry points. The deleted-target eviction primitive is gone — for an envelope-aware kit (central-ui's `REMOTE_FETCH` makes generic `cache.modify` impractical), refetching the canonical list is simpler and the result is identical.
|
|
469
475
|
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-W15RTo5l.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,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{memo as i,useRef as r,useEffect as n}from"react";import"@xyflow/react/dist/style.css";import d,{useTheme as s}from"styled-components";import{N as a,F as l,I as c,T as p,S as h,g as m,u,a as g,b}from"./ui-components-
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{memo as i,useRef as r,useEffect as n}from"react";import"@xyflow/react/dist/style.css";import d,{useTheme as s}from"styled-components";import{N as a,F as l,I as c,T as p,S as h,g as m,u,a as g,b}from"./ui-components-D_eeOuIL.js";import{Handle as x,Position as f,ReactFlowProvider as y,ReactFlow as w,Controls as v,ControlButton as N,useReactFlow as k}from"@xyflow/react";import{RefreshIcon as $}from"../icons.js";const C=d(l)`
|
|
2
2
|
max-width: 300px;
|
|
3
3
|
padding: 12px;
|
|
4
4
|
border-radius: 12px;
|
|
@@ -1,4 +1,4 @@
|
|
|
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,c as u,P as l,d as c,e as p,f as d,h as f}from"./ui-components-
|
|
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,c as u,P as l,d as c,e as p,f as d,h as f}from"./ui-components-D_eeOuIL.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 M(e){if("custom"===e.durationPreset){const t=parseFloat(e.customDurationMs);return isNaN(t)?null:t}return parseInt(e.durationPreset,10)}function D(e){return{httpServer:{[e.routeType]:e.route||null,method:e.method||null}}}function I(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"httpClient"===e.operationType?{httpClient:{serverAddress:e.serverAddress||null,["route"===e.routeType?"templatedPath":"templatedPathPrefix"]:e.route||null,method:e.method||null}}:null}function $(e){return"all"===e.operationType?null:"httpServer"===e.operationType?D(e):"kafkaConsumer"===e.operationType?{kafkaConsumer:{kafkaTopic:e.kafkaTopic||null}}:"kafkaProducer"===e.operationType?{kafkaProducer:{kafkaTopic:e.kafkaTopic||null}}:null}function C(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?M(e):null,percentageAtLeast:b(e),operation:$(e)}}function w(e){return{ruleId:"",name:e.name||null,disabled:!1,notes:e.notes||null,sourceScopes:R(e),percentageAtMost:b(e)??0,operation:$(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?M(e):null,operation:$(e),percentageAtLeast:b(e),notes:e.notes||null}}function N(e){return{name:e.name||null,disabled:e.disabled,sourceScopes:P(e),operation:$(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
2
|
font-family: ${({theme:e,$isMono:t})=>t?e.font_family.secondary:e.font_family.primary};
|
|
3
3
|
font-size: ${({theme:e})=>e.v2.text.size.xxs}px;
|
|
4
4
|
line-height: 20px;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aA as e,ag as a,L as t,a9 as l,aa as r,dT as n,a5 as i,aN as s,ar as o,a7 as d,J as c,ab as u,an as p,dU as h,ae as g,af as m,dV as v,dW as f,V as b,Q as y,U as x,R as C,O as S,aw as $,au as k,b4 as T,c as w,n as A,F as P,a4 as M,ah as L,aJ as I,dX as O,dY as D,aU as z,dZ as N,f as X,d_ as R,ad as H,h as E,d$ as B,e0 as V,e1 as q,e2 as j,e3 as G,e4 as J,e5 as U,ak as K,e6 as F,e7 as W,e8 as Y,e9 as Q,ea as Z,bV as _,eb as ee,ec as ae,ed as te,ee as le,ef as re,eg as ne,eh as ie,ei as se,ej as oe,ek as de,el as ce,aK as ue,em as pe,en as he,eo as ge,ep as me,eq as ve,bI as fe,er as be,es as ye,et as xe,eu as Ce,ev as Se,ew as $e,ex as ke,ey as Te,ez as we,a_ as Ae,q as Pe,eA as Me,S as Le,eB as Ie,b5 as Oe,eC as De,eD as ze,eE as Ne,eF as Xe,by as Re,az as He,eG as Ee,eH as Be,eI as Ve,di as qe,eJ as je,eK as Ge,eL as Je,s as Ue,dg as Ke,a6 as Fe,eM as We,bk as Ye,aM as Qe,N as Ze,l as _e,aQ as ea,du as aa,bj as ta,bq as la,bi as ra,bY as na,eN as ia}from"./ui-components-
|
|
1
|
+
import{aA as e,ag as a,L as t,a9 as l,aa as r,dT as n,a5 as i,aN as s,ar as o,a7 as d,J as c,ab as u,an as p,dU as h,ae as g,af as m,dV as v,dW as f,V as b,Q as y,U as x,R as C,O as S,aw as $,au as k,b4 as T,c as w,n as A,F as P,a4 as M,ah as L,aJ as I,dX as O,dY as D,aU as z,dZ as N,f as X,d_ as R,ad as H,h as E,d$ as B,e0 as V,e1 as q,e2 as j,e3 as G,e4 as J,e5 as U,ak as K,e6 as F,e7 as W,e8 as Y,e9 as Q,ea as Z,bV as _,eb as ee,ec as ae,ed as te,ee as le,ef as re,eg as ne,eh as ie,ei as se,ej as oe,ek as de,el as ce,aK as ue,em as pe,en as he,eo as ge,ep as me,eq as ve,bI as fe,er as be,es as ye,et as xe,eu as Ce,ev as Se,ew as $e,ex as ke,ey as Te,ez as we,a_ as Ae,q as Pe,eA as Me,S as Le,eB as Ie,b5 as Oe,eC as De,eD as ze,eE as Ne,eF as Xe,by as Re,az as He,eG as Ee,eH as Be,eI as Ve,di as qe,eJ as je,eK as Ge,eL as Je,s as Ue,dg as Ke,a6 as Fe,eM as We,bk as Ye,aM as Qe,N as Ze,l as _e,aQ as ea,du as aa,bj as ta,bq as la,bi as ra,bY as na,eN as ia}from"./ui-components-D_eeOuIL.js";import{jsx as sa,jsxs as oa,Fragment as da}from"react/jsx-runtime";import{D as ca,C as ua,E as pa,u as ha,F as ga,h as ma,f as va,e as fa,G as ba,H as ya,I as xa,i as Ca,m as Sa}from"./helpers-Cy9W3KCg.js";import{EditIcon as $a,OdigosLogoTextCentral as ka,OdigosLogoTextEnterprise as Ta,OdigosLogoTextCommunity as wa,OdigosLogoTextColoredCentral as Aa,OdigosLogoTextColoredEnterprise as Pa,OdigosLogoTextColoredCommunity as Ma,ArrowLeftIcon as La,ArrowRightIcon as Ia,VSquareIcon as Oa,VIcon as Da,CopyIcon as za,YamlIcon as Na}from"../icons.js";import Xa,{useMemo as Ra,useCallback as Ha,useState as Ea,useRef as Ba,useEffect as Va,forwardRef as qa,useImperativeHandle as ja}from"react";import Ga,{useTheme as Ja}from"styled-components";const Ua=({isOpen:t,onClose:l,onDeny:r,onApprove:n})=>sa(e,{title:"Discard changes?",description:"You have unsaved changes.\nIf you cancel now, your changes won't be saved.",isOpen:t,onClose:l,denyButton:{label:"Keep editing",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:"Discard changes",variant:a.Primary,onClick:()=>{n?.(),l()}}}),Ka=({isOpen:t,onClose:l,onDeny:r,onApprove:n,action:i="delete",target:s,description:o,overrideApproveButtonLabel:d,overrideDenyButtonLabel:c})=>{const u=i.charAt(0).toUpperCase()+i.substring(1),p=s?.endsWith("s")?"these":"this";return sa(e,{title:`${u}${s?` ${s}`:""}?`,description:o??`Are you sure you want to ${i}${s?` ${p} ${s}`:""}?`,isOpen:t,onClose:l,denyButton:{label:c??"Go back",variant:a.Secondary,onClick:()=>{r?.(),l()}},approveButton:{label:d??u,variant:a.Primary,onClick:()=>{n?.(),l()}}})},Fa=({componentType:e,inputType:a,name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C,setValue:S,errorMessage:$,warnMessage:k,helpMessage:T,dropdownOptions:w,dropdownNoSearch:A,dropdownNoCheckbox:P,timeUnits:M,timeDefaultUnit:L})=>{switch(e){case t.Input:return sa(p,{name:g,type:a,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C??"",onChange:e=>{const t=e.target.value;S(a===h.Number?""===t?null:Number(t):t)},errorMessage:$,warnMessage:k,helpMessage:T},g);case t.MultiInput:return sa(u,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,values:Array.isArray(C)?C:c(C,[]),setValues:e=>S(e),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.KeyValuePair:return sa(d,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,limitFieldsPerRow:2,columns:[{keyName:"key",label:"Key",placeholder:"Key"},{keyName:"value",label:"Value",placeholder:"Value"}],values:Array.isArray(C)?C:c(C,[]),setValues:e=>S(e),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.TextArea:return sa(o,{name:g,label:m,tooltip:v,badge:f,required:y,disabled:x,placeholder:b,value:C??"",onChange:e=>S(e.target.value),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Dropdown:return sa(s,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,withSearch:!A,options:w?.map(e=>({id:e.id||"",label:e.label||"",withCheckbox:!P}))||[],values:C?[String(C)]:[],setValues:e=>S(e[0]),errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Checkbox:return sa(i,{name:g,label:m,tooltip:v,badge:f,value:!0===C||"true"===C,onChange:e=>S(e),disabled:x,errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Time:return sa(n,{name:g,label:m,tooltip:v,badge:f,placeholder:b,required:y,disabled:x,value:C??"",setValue:e=>S(e),units:M,defaultUnit:L,errorMessage:$,warnMessage:k,helpMessage:T},g);case t.Toggle:return sa(l,{name:g,labelAlign:r.Right,label:m,tooltip:v,badge:f,value:!0===C||"true"===C,onChange:e=>S(e),disabled:x,errorMessage:$,warnMessage:k,helpMessage:T},g);default:return null}},Wa=Ga.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 24px;
|
|
@@ -0,0 +1 @@
|
|
|
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 D,K as E,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-D_eeOuIL.js";import{d as P}from"./use-odigos-api-W15RTo5l.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-Cy9W3KCg.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,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 r=i.find(e=>e.name===a.name&&e.name!==m);if(r)return E.current=e,void D({preparedFormData:a,existingName:r.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=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={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:r,displayName:n,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=D(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}}),re=({children:n})=>{const{selectedStreamName:s}=f(),{items:o}=P().destinationsApi.useDestinations(),[c,u]=t(null),[m,g]=t(ee.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({...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 r of t){const t=r.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const r=D(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=ae(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 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:n})},ne=()=>n(te),se={disabled:!1,ruleName:"",notes:"",sourceScopes:T(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:n,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: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(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]||[],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(oe.Provider,{value:f,children:n})},le=()=>{const e=n(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: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:de.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(ce.Provider,{value:v,children:d})},he=({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 D=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),E=a(()=>{n&&(g(K(n)),y(null),p(!0))},[n,g]),S=a(()=>{p(!1),y(null)},[]),k=r(()=>({formType:de.View,data:n,isEditing:m,formData:h,handleChange:D,handleEdit:E,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[n,m,h,D,E,S,b,d,c]);return e(ce.Provider,{value:k,children:u})};function fe(e){const[a,n]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>me(e)),[l,d]=t(()=>"custom"===me(e)?String(e):"");i(()=>{n(0===e?"all":"sample");const t=me(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 ge=({enabled:a,keepPercentage:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=r(()=>({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:n,children:s})=>{const[o,l]=t(a),d=fe(n);i(()=>{l(a)},[a]);const c=r(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=r(()=>({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:n})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=r(()=>M(s?{disabled:!1}:null),[s]),d=r(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:n})},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=n(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:n})=>{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=r(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(Se.Provider,{value:m,children:n})},Ce=()=>{const e=n(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:r}=Fe(e);return t||a||r}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=({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=>{Ae.has(e.kind)&&!c||(e.selected=!0)})}),a}return r})})},[h,s,o]);const{formDiff:y,isFormDirty:D}=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]),E=a(e=>!c&&Ae.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=>!E(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=>{E(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}return s})},[E]),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&&E(e.kind)||we(e,c,s||{showOnlySelected:!1})&&(i[n].namespaces[o].workloads[t].selected=a)});const e=i[n].namespaces[o].workloads.filter(e=>!E(e.kind)).every(e=>e.selected);i[n].namespaces[o].selected=e}else{if(!Ie(i[n].namespaces[o],l,s||{showOnlySelected:!1}))return;i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&E(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})}else i[n].namespaces[o].selected=a,r.forEach((e,t)=>{a&&E(e.kind)||(i[n].namespaces[o].workloads[t].selected=a)})})}),i})},[E]);return e(Ne.Provider,{value:{snapshots:h,setSnapshots:g,isFetching:m,setIsFetching:p,formData:v,handleSourceChange:S,handleSelectAll:k,formDiff:y,isFormDirty:D},children:n})},Re=()=>n(Ne);export{Q as A,X as D,Ae as E,ie as R,de as S,re as a,ye as b,ke as c,xe as d,Y as e,ne as f,le as g,De as h,Ce as i,Re as j,we as k,Ie as l,Fe as m,W as u};
|