@odigos/ui-kit 0.0.261 → 0.0.262
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 +14 -0
- package/lib/chunks/{connections-scope-DhNWocBO.js → connections-scope-7HTW_FyZ.js} +1 -1
- package/lib/chunks/{index-DILEVYlK.js → index-raAGXSYj.js} +7 -7
- package/lib/chunks/{odigos-context-BYgtdAtj.js → odigos-context-nQT2LWDb.js} +1 -2
- package/lib/chunks/source-instrument-form-context-BDrkrejS.js +1 -0
- package/lib/chunks/ui-components-p39Q_a1_.js +1703 -0
- package/lib/chunks/use-odigos-api-CPlk79JW.js +5 -0
- package/lib/components/_v2/input-table/card-table.d.ts +10 -0
- package/lib/components/_v2/input-table/dynamic-field/index.d.ts +1 -0
- package/lib/components/_v2/input-table/index.d.ts +2 -0
- package/lib/components/_v2/input-table/types.d.ts +13 -1
- package/lib/components/v2.js +1 -1
- package/lib/components.js +1 -1
- package/lib/constants/instrumentation-rules/index.d.ts +2 -1
- package/lib/constants.js +1 -1
- package/lib/containers/_v2/_forms/add-action-form/dynamic-fields/index.d.ts +1 -0
- package/lib/containers/_v2/_forms/add-rule-form/custom-fields/index.d.ts +2 -1
- package/lib/containers/v2.js +146 -146
- package/lib/containers.js +1 -1
- package/lib/contexts/odigos-api/capabilities.d.ts +1 -0
- package/lib/contexts/odigos-api/hooks/use-instrumentation-rules-api.d.ts +13 -1
- package/lib/contexts/odigos-api/types.d.ts +2 -1
- package/lib/contexts/odigos-api.js +1 -1
- package/lib/contexts/rule-form-context.d.ts +1 -1
- package/lib/contexts.js +1 -1
- package/lib/functions.js +1 -1
- package/lib/hooks.js +1 -1
- package/lib/icons.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/common/index.d.ts +1 -0
- package/lib/types/instrumentation-rules/index.d.ts +22 -3
- package/lib/types.js +1 -1
- package/lib/visuals.js +1 -1
- package/package.json +1 -1
- package/lib/chunks/source-instrument-form-context-oDlfTrOD.js +0 -1
- package/lib/chunks/ui-components-BDSEcaSZ.js +0 -1692
- package/lib/chunks/use-odigos-api-DHCLONPK.js +0 -5
package/lib/snippets/v2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{bj as ActionType,dx as Actions,dw as RichTitle}from"../chunks/ui-components-p39Q_a1_.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-raAGXSYj.js";export{C as ColoredSpan,G as ColoredSpanVariant}from"../chunks/odigos-context-nQT2LWDb.js";import"react/jsx-runtime";import"styled-components";import"../icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"../chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/snippets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{bj as ActionType,dx as Actions,dw as RichTitle}from"./chunks/ui-components-p39Q_a1_.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-raAGXSYj.js";export{C as ColoredSpan,G as ColoredSpanVariant}from"./chunks/odigos-context-nQT2LWDb.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a1 as ProgressKeys,
|
|
1
|
+
export{a1 as ProgressKeys,fV as useDarkMode,h as useDataStreamStore,bk as useDrawerStore,de as useFilterStore,b$ as useModalStore,W as useNotificationStore,$ as useProgressStore,dk as useSelectedStore,a0 as useSetupStore}from"./chunks/ui-components-p39Q_a1_.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{g2 as Provider,g3 as animations,g4 as opacity,g5 as palettes}from"./chunks/ui-components-p39Q_a1_.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";
|
|
@@ -125,6 +125,7 @@ export declare enum FieldTypes {
|
|
|
125
125
|
TextArea = "textarea",
|
|
126
126
|
Dropdown = "dropdown",
|
|
127
127
|
Checkbox = "checkbox",
|
|
128
|
+
CheckboxList = "checkboxList",
|
|
128
129
|
Toggle = "toggle",// not used by dests, but is in form components
|
|
129
130
|
Time = "time",
|
|
130
131
|
FieldGroup = "fieldGroup"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WorkloadId } from '../workload';
|
|
2
2
|
import type { SourcesScopes } from '../sampling';
|
|
3
|
-
import type { Condition, ProgrammingLanguages, SVG } from '../common';
|
|
3
|
+
import type { Condition, FieldTypes, ProgrammingLanguages, SVG } from '../common';
|
|
4
4
|
export declare enum InstrumentationRuleType {
|
|
5
5
|
CodeAttributes = "CodeAttributes",
|
|
6
6
|
HeadersCollection = "HeadersCollection",
|
|
@@ -122,13 +122,32 @@ export interface PayloadCollection {
|
|
|
122
122
|
[PayloadCollectionKeyTypes.DbQuery]?: DbQueryPayloadCollection | null;
|
|
123
123
|
[PayloadCollectionKeyTypes.Messaging]?: MessagingPayloadCollection | null;
|
|
124
124
|
}
|
|
125
|
+
export interface InstrumentationRuleYamlProperties {
|
|
126
|
+
name: string;
|
|
127
|
+
componentType: FieldTypes;
|
|
128
|
+
componentProperties?: string;
|
|
129
|
+
displayName?: string;
|
|
130
|
+
initialValue?: string;
|
|
131
|
+
renderCondition?: string[];
|
|
132
|
+
}
|
|
133
|
+
export interface InstrumentationRuleTypeOption {
|
|
134
|
+
type: InstrumentationRuleType;
|
|
135
|
+
displayName: string;
|
|
136
|
+
description: string;
|
|
137
|
+
supportedLanguages: ProgrammingLanguages[];
|
|
138
|
+
docsUrl: string;
|
|
139
|
+
fields: InstrumentationRuleYamlProperties[];
|
|
140
|
+
}
|
|
141
|
+
export interface GetInstrumentationRuleTypesResult {
|
|
142
|
+
instrumentationRuleTypes: InstrumentationRuleTypeOption[] | null;
|
|
143
|
+
}
|
|
125
144
|
export interface InstrumentationRuleOption {
|
|
126
145
|
type: InstrumentationRuleType;
|
|
127
146
|
icon: SVG;
|
|
128
147
|
label: string;
|
|
129
148
|
description: string;
|
|
130
|
-
|
|
131
|
-
docsDescription: string;
|
|
149
|
+
docsUrl: string;
|
|
132
150
|
supportedLanguages: ProgrammingLanguages[];
|
|
151
|
+
fields?: InstrumentationRuleYamlProperties[];
|
|
133
152
|
}
|
|
134
153
|
export {};
|
package/lib/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as ActionKeyTypes,g as ActionType,
|
|
1
|
+
export{f as ActionKeyTypes,g as ActionType,eP as AgentInjectedReason,eQ as BooleanOperation,ax as CodeAttributesKeyTypes,eR as ConditionType,_ as Crud,C as CustomInstrumentationsKeyTypes,bc as DesiredStateProgress,eS as DestinationTypes,E as EntityTypes,aj as ExtractionDataFormat,l as FieldTypes,G as GolangCustomProbe,H as HeadersCollectionKeyTypes,dW as InputTypes,eT as InstallationMethod,eU as InstallationStatus,n as InstrumentationRuleType,eV as IntrumentationStatus,J as JavaCustomProbe,eW as JsonOperation,ac as K8sAttributesFrom,K as K8sResourceKind,eX as K8sWorkloadContainerAgentConfigTracesHeadSamplingSpanMetricsMode,eY as ListDirection,eZ as NumberOperation,e_ as OtelDistroName,e$ as OtherEntityTypes,ay as PayloadCollectionKeyTypes,c as PlatformType,f0 as PodContainerLifecycleStatus,f1 as PodContainerStatus,f2 as PodPhase,f3 as Profile,bv as ProgrammingLanguages,f4 as SIGNAL_KEY_TO_TYPE,f5 as SIGNAL_TYPE_TO_KEY,f6 as SignalKey,S as SignalType,f7 as SortDirection,o as StatusType,f8 as StringOperation,b as Tier,f9 as WorkloadRolloutReason,dz as WorkloadRolloutStatus}from"./chunks/ui-components-p39Q_a1_.js";import"react/jsx-runtime";import"styled-components";import"./icons.js";import"zustand";import"react";import"javascript-time-ago";import"javascript-time-ago/locale/en";import"prism-react-renderer";import"./chunks/vendor-BFqT13Me.js";import"zustand/middleware";import"react-error-boundary";import"react-dom";import"virtua";
|
package/lib/visuals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{fa as VISUAL_ODIGOS_LOGO_HEIGHT,fb as VISUAL_ODIGOS_LOGO_WIDTH,eN as VisualGreenRings,fc as VisualOdigosLogo,ca as VisualPurpleRings}from"./chunks/ui-components-p39Q_a1_.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 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as a,useMemo as n,useContext as r,createContext as s,useRef as o,useEffect as i}from"react";import{d as l,e as d,A as c,f as u,g as m,i as p,F as h,h as f,j as g,D as v,m as b,S as y,s as D,k as E,l as S,I as k,H as C,C as A,G as F,J as I,n as w,K as N,b as x,E as R}from"./ui-components-BDSEcaSZ.js";import{d as P}from"./use-odigos-api-DHCLONPK.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 G,u as V}from"./odigos-context-BYgtdAtj.js";const _={type:"",disabled:!1,name:"",notes:"",signals:[],fields:{}},q=s(null),H="All row fields are required",z="At least one row is required",J=(e,t)=>!!e&&t.every(t=>{const a=e[t];return Array.isArray(a)?a.length>0:!("string"==typeof(n=a)?!n.trim():p(n));var n}),Q=({children:r})=>{const[s,o]=t(null),i=l(_),f=a(e=>{i.resetFormData(),i.handleErrorChange(void 0,void 0,{}),e?.type&&i.handleFormChange("type",e.type),o(e)},[]),g=a((e,t)=>{var a;i.resetFormData((({type:e,name:t,notes:a,disabled:n,signals:r,fields:s})=>({type:e,name:t||"",notes:a||"",disabled:!!n,signals:r??[],fields:s??{}}))(e)),i.handleErrorChange(void 0,void 0,{}),o(t??(a=e.type,c.find(e=>e.type===a)??null))},[]),v=a(()=>{if(!s)return{errorMessage:"No action type selected",preparedFormData:d(_)};const e=(e=>{const t=d(e),a=t.fields||{},n=a[u.UrlTemplatizationRulesGroups];n?.length&&(a[u.UrlTemplatizationRulesGroups]=n.map(e=>({...e,templatizationRules:(e.templatizationRules||[]).filter(e=>!!e.template?.trim())})));const r=a[u.AttributeNamesToDelete];r?.length&&(a[u.AttributeNamesToDelete]=r.filter(e=>!!e?.trim()));const s=a[u.Renames];s&&(a[u.Renames]=Object.fromEntries(Object.entries(s).filter(([e,t])=>!!e?.trim()&&!!t?.trim())));const o=a[u.ExtractAttribute];return o?.extractions?.length&&(a[u.ExtractAttribute]={extractions:o.extractions.map(e=>({targetAttributeName:e.targetAttributeName?.trim()||"",lookupKey:e.lookupKey?.trim()||"",dataFormat:e.dataFormat||"",regex:e.regex?.trim()||""})).filter(e=>!!(e.targetAttributeName||e.lookupKey||e.dataFormat||e.regex))}),t.fields=a,t})(i.formData),t={};p(e.signals)&&(t.signals=h.FIELD_IS_REQUIRED),s.type&&Object.assign(t,((e,t,a)=>{const n={},r=t.fields||{},s=a.fields||{};switch(e){case m.K8sAttributes:{const e=!(r[u.CollectContainerAttributes]||r[u.CollectReplicaSetAttributes]||r[u.CollectWorkloadId]||r[u.CollectClusterId]),t=!r[u.LabelsAttributes]?.length,a=!r[u.AnnotationsAttributes]?.length;e&&t&&a&&(n[u.CollectContainerAttributes]="Enable at least one option or add a label/annotation row");const s=r[u.LabelsAttributes];s?.some(e=>!J(e,["labelKey","attributeKey","fromSources"]))&&(n[u.LabelsAttributes]=H);const o=r[u.AnnotationsAttributes];o?.some(e=>!J(e,["annotationKey","attributeKey","fromSources"]))&&(n[u.AnnotationsAttributes]=H);break}case m.AddClusterInfo:{const e=r[u.ClusterAttributes];e?.length?e.some(e=>!J(e,["attributeName","attributeStringValue"]))&&(n[u.ClusterAttributes]=H):n[u.ClusterAttributes]=z;break}case m.DeleteAttributes:{const e=s[u.AttributeNamesToDelete]||[],t=r[u.AttributeNamesToDelete]||[];t.length?e.length>t.length&&(n[u.AttributeNamesToDelete]=H):n[u.AttributeNamesToDelete]=e.length?H:z;break}case m.RenameAttributes:{const e=Object.entries(s[u.Renames]||{}),t=Object.entries(r[u.Renames]||{}),a=e.some(([e,t])=>!e?.trim()||!t?.trim());t.length?a&&(n[u.Renames]=H):n[u.Renames]=e.length?H:z;break}case m.PiiMasking:{const e=r[u.PiiCategories];e?.length||(n[u.PiiCategories]="Select at least one attribute to mask");break}case m.URLTemplatization:{const e=r[u.UrlTemplatizationRulesGroups];(!e?.length||e.some(e=>!e.templatizationRules?.length))&&(n[u.UrlTemplatizationRulesGroups]="Each rule group needs at least one non-blank template");break}case m.ExtractAttribute:{const e=r[u.ExtractAttribute]?.extractions||[],t=s[u.ExtractAttribute]?.extractions||[];if(e.length)if(e.some(e=>{if(!e.targetAttributeName?.trim())return!0;const t=!!e.regex?.trim(),a=!!e.lookupKey?.trim();return a!==!!e.dataFormat||t===a}))n[u.ExtractAttribute]="Each row needs a target attribute name and either a regex or both lookup key and data format";else{const t=new Set;e.some(e=>{const a=e.targetAttributeName?.trim()||"";return!!t.has(a)||(t.add(a),!1)})&&(n[u.ExtractAttribute]="Each new span attribute name must be unique")}else n[u.ExtractAttribute]=t.length?H:z;break}}return n})(s.type,e,i.formData)),i.handleErrorChange(void 0,void 0,t);return{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[i,s]),b=n(()=>({selectedOption:s,onSelectOption:f,loadAction:g,genericForm:i,validateFormData:v}),[s,f,g,i,v]);return e(q.Provider,{value:b,children:r})},W=()=>{const e=r(q);if(!e)throw new Error("useActionFormContext must be used within an ActionFormContextProvider");return e},$={name:""},B=s(null),X=({children:r,defaultExcludeName:s=""})=>{const{dataStreams:i}=f(),[c,u]=t(void 0),[m,p]=t(s),[v,b]=t(void 0),[y,D]=t(null),E=o(null),S=l($),k=a(e=>{S.resetFormData({name:e}),S.handleErrorChange(void 0,void 0,{}),u(void 0),p(e),b(e),D(null),E.current=null},[]),C=a(()=>{const e=d(S.formData),t=(e=>{const t={};return e.name?g(e.name)||(t.name=h.ILLEGAL_K8S_LABEL):t.name=h.FIELD_IS_REQUIRED,t})(e);S.handleErrorChange(void 0,void 0,t);const a=Object.keys(t).length>0?h.REQUIRED_FIELDS:void 0;return u(a),{errorMessage:a,preparedFormData:e}},[S]),A=a(async e=>{const{errorMessage:t,preparedFormData:a}=C();if(t)return;const n=i.find(e=>e.name===a.name&&e.name!==m);if(n)return E.current=e,void D({preparedFormData:a,existingName:n.name,editingName:v});await e(a)},[C,i,m,v]),F=a(async()=>{const e=E.current,t=y?.preparedFormData;E.current=null,D(null),e&&t&&await e(t)},[y]),I=a(()=>{E.current=null,D(null)},[]),w=n(()=>({genericForm:S,loadDataStream:k,editingName:v,validateFormData:C,requestSubmit:A,pendingMerge:y,confirmMerge:F,cancelMerge:I,errorMessage:c,excludeName:m,setExcludeName:p}),[S,k,v,C,A,y,F,I,c,m]);return e(B.Provider,{value:w,children:r})},Y=()=>{const e=r(B);if(!e)throw new Error("useDataStreamFormContext must be used within a DataStreamFormContextProvider");return e},Z={type:"",name:"",currentStreamName:"",disabled:!1,exportedSignals:{logs:!1,metrics:!1,traces:!1,profiles:!1},fields:[]},ee={activeForm:null,onChangeActiveForm:()=>{},loadDestination:()=>{},genericForm:void 0,validateFormData:()=>({isOk:!1,preparedFormData:d(Z)}),unsavedDestinations:[],thisUnsavedDestination:void 0,setUnsavedDestinations:()=>{},addUnsavedDestination:()=>{},updateUnsavedDestination:()=>{},deleteUnsavedDestination:()=>{}},te=s(ee),ae=e=>e.filter(e=>!!e).map(e=>{const{name:t,componentType:a,componentProperties:n,displayName:r,initialValue:s,renderCondition:o}=e,i=a===S.Dropdown,l=D(n,{});return{componentType:a,renderCondition:o,name:t,title:r,value:s,placeholder:l.placeholder||(i?"Select an option":void 0),options:i&&Array.isArray(l.values)?l.values.map(e=>({id:e,label:e})):void 0,...l}}),ne=({children:r})=>{const{selectedStreamName:s}=f(),{items:o}=P().destinationsApi.useDestinations(),[c,u]=t(null),[m,g]=t(ee.unsavedDestinations),S=n(()=>"number"==typeof c?.unsavedIdx?m[c.unsavedIdx]:void 0,[c,m]),k=a((e,t)=>{c&&(g(t=>[...t,{...e,option:c.option}]),u(t?e=>e?{...e,listType:v.UNSAVED,unsavedIdx:m.length}:null:null))},[c,m.length]),C=a((e,t,a)=>{c&&(g(a=>a.map((a,n)=>n===e?{...a,...t,option:c.option}:a)),u(a?e=>e?{...e,listType:v.UNSAVED}:null:null))},[c]),A=a(e=>{g(t=>t.filter((t,a)=>a!==e)),u(null)},[]),F=l({...Z,currentStreamName:s});i(()=>{if(!c)return;if(S)return void F.resetFormData({...S.formData});if(c.listType===v.EXISTS&&c.option.id){const e=o.find(e=>e.id===c.option.id);if(e)return void F.resetFormData({type:e.destinationType.type,name:e.name||e.destinationType.displayName,currentStreamName:s,disabled:!!e.disabled,exportedSignals:{logs:!!e.exportedSignals?.logs,metrics:!!e.exportedSignals?.metrics,traces:!!e.exportedSignals?.traces,profiles:!!e.exportedSignals?.profiles},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})}const e=b(c.option.supportedSignals);F.resetFormData({type:c.option.type,name:c.option.displayName,currentStreamName:s,disabled:!1,exportedSignals:{logs:e.includes(y.Logs),metrics:e.includes(y.Metrics),traces:e.includes(y.Traces),profiles:e.includes(y.Profiles)},fields:c.dynamicFields.map(e=>({key:e.name,value:e.value}))})},[c,S]);const I=a(e=>{F.resetFormData(),F.handleErrorChange(void 0,void 0,{}),u(e?{...e,dynamicFields:e.option?.fields?ae(e.option.fields):[]}:null)},[]),w=a((e,t)=>{let a;for(const n of t){const t=n.items.find(t=>t.type===e.destinationType.type);if(t){a=t;break}}const n=D(e.fields,{}),r={id:e.id,type:e.destinationType.type,displayName:e.name||e.destinationType.displayName,selected:!0,testConnectionSupported:a?.testConnectionSupported??!1,supportedSignals:e.destinationType.supportedSignals,fields:a?a.fields.map(e=>({...e,initialValue:n[e.name]??e.initialValue})):[]},s=ae(r.fields);u({listType:v.EXISTS,option:r,dynamicFields:s})},[]),N=a(()=>{const e=d(F.formData),t={};c?.dynamicFields.forEach(({name:a,required:n})=>{if(n){const n=e.fields.find(e=>e.key===a)?.value;p(n)&&(t[a]=h.FIELD_IS_REQUIRED)}});return E(e.exportedSignals).length||(t.exportedSignals=h.FIELD_IS_REQUIRED),F.handleErrorChange(void 0,void 0,t),{errorMessage:0===Object.keys(t).length?void 0:"Invalid form values",preparedFormData:e}},[F,c]);return e(te.Provider,{value:{activeForm:c,onChangeActiveForm:I,loadDestination:w,genericForm:F,validateFormData:N,unsavedDestinations:m,thisUnsavedDestination:S,setUnsavedDestinations:g,addUnsavedDestination:k,updateUnsavedDestination:C,deleteUnsavedDestination:A},children:r})},re=()=>r(te),se={disabled:!1,ruleName:"",notes:"",sourceScopes:T(),workloads:null,instrumentationLibraries:null,payloadCollection:null,codeAttributes:null,headersCollection:null,customInstrumentations:null},oe=s(null),ie=({children:r,sourceOptions:s=[],namespaceOptions:o=[]})=>{const[i,c]=t(null),u=l(se),m=a(e=>{u.resetFormData(),u.handleErrorChange(void 0,void 0,{}),c(e)},[]),p=a(e=>{var t;u.resetFormData((({ruleName:e,notes:t,disabled:a,sourceScopes:n,instrumentationLibraries:r,payloadCollection:s,codeAttributes:o,headersCollection:i,customInstrumentations:l})=>({ruleName:e||"",notes:t||"",disabled:!!a,sourceScopes:O(n),workloads:null,instrumentationLibraries:r??null,payloadCollection:s??null,codeAttributes:o??null,headersCollection:i??null,customInstrumentations:l??null}))(e)),u.handleErrorChange(void 0,void 0,{}),c((t=e.type,k.find(e=>e.type===t)??null))},[]),h=a(()=>{if(!i)return{errorMessage:"No rule type selected",preparedFormData:d(se)};const e=(e=>{const t=d(e),a={...t,sourceScopes:L(t.sourceScopes)?null:t.sourceScopes,workloads:null};return a.headersCollection?.[C.HeaderKeys]?.length&&(a.headersCollection[C.HeaderKeys]=a.headersCollection[C.HeaderKeys].map(e=>e.trim()).filter(e=>e)),a.customInstrumentations?.[A.Golang]?.length&&(a.customInstrumentations[A.Golang]=a.customInstrumentations[A.Golang].map(e=>new F(e.packageName,e.functionName,e.receiverName,e.receiverMethodName)).filter(e=>{return t=e,!!(t.packageName?.trim()||t.functionName?.trim()||t.receiverName?.trim()||t.receiverMethodName?.trim());var t})),a.customInstrumentations?.[A.Java]?.length&&(a.customInstrumentations[A.Java]=a.customInstrumentations[A.Java].map(e=>new I(e.className,e.methodName)).filter(e=>{return t=e,!(!t.className?.trim()&&!t.methodName?.trim());var t})),a})(u.formData),t=((e,t)=>{const a={};switch(e){case w.CodeAttributes:Object.values(t.codeAttributes||{}).some(e=>null!=e)||(a.codeAttributes="Code attributes are required");break;case w.PayloadCollection:Object.values(t.payloadCollection||{}).some(e=>null!=e)||(a.payloadCollection="Payload collection are required");break;case w.HeadersCollection:t.headersCollection?.[C.HeaderKeys]?.length||(a.headersCollection="Header keys are required");break;case w.CustomInstrumentation:{const e=t.customInstrumentations?.[A.Golang]||[],n=t.customInstrumentations?.[A.Java]||[];if(!e.length&&!n.length){a.customInstrumentations="Custom instrumentation are required";break}const r=e.findIndex(e=>!new F(e.packageName,e.functionName,e.receiverName,e.receiverMethodName).Verify());if(-1!==r){a.customInstrumentations=`Golang probe #${r+1} is invalid: provide a package name plus either a function name OR both a receiver name and receiver method name`;break}const s=n.findIndex(e=>!new I(e.className,e.methodName).Verify());if(-1!==s){a.customInstrumentations=`Java probe #${s+1} is invalid: both class name and method name are required`;break}break}}return a})(i.type,e);return u.handleErrorChange(void 0,void 0,t),{errorMessage:Object.keys(t).length>0?"Invalid form values":void 0,preparedFormData:e}},[u,i]),f=n(()=>({selectedOption:i,onSelectOption:m,loadRule:p,genericForm:u,validateFormData:h,sourceOptions:s,namespaceOptions:o}),[i,m,p,u,h,s,o]);return e(oe.Provider,{value:f,children:r})},le=()=>{const e=r(oe);if(!e)throw new Error("useRuleFormContext must be used within a RuleFormContextProvider");return e};var de;!function(e){e.Create="create",e.View="view",e.EditAutoNoisy="edit-auto-noisy",e.EditAutoCostReduction="edit-auto-cost-reduction",e.EditAutoHighlyRelevant="edit-auto-highly-relevant"}(de||(de={}));const ce=s(null),ue=["50","25","10","1"];function me(e){const t=String(e);return ue.includes(t)?t:"custom"}const pe=({category:r,sourceOptions:s=[],namespaceOptions:o=[],children:d})=>{const{formData:c,handleFormChange:u,resetFormData:m}=l(G(r)),[p,h]=t(null);i(()=>{m(G(r)),h(null)},[r]);const f=a(e=>{h(null),u(void 0,void 0,{...c,...e})},[c,u]),g=a(()=>{m(G(r)),h(null)},[r,m]),v=n(()=>({formType:de.Create,category:r,formData:c,handleChange:f,resetForm:g,duplicateWarning:p,setDuplicateWarning:h,sourceOptions:s,namespaceOptions:o}),[r,c,f,g,p,s,o]);return e(ce.Provider,{value:v,children:d})},he=({data:r,defaultEditMode:s,sourceOptions:d=[],namespaceOptions:c=[],children:u})=>{const[m,p]=t(!1),{formData:h,handleFormChange:f,resetFormData:g}=l(void 0),v=o(null),[b,y]=t(null);i(()=>{r!==v.current&&(v.current=r,r&&s?(g(K(r)),y(null),p(!0)):(p(!1),y(null)))},[r,s]);const D=a(e=>{y(null),f(void 0,void 0,{...h,...e})},[h,f]),E=a(()=>{r&&(g(K(r)),y(null),p(!0))},[r,g]),S=a(()=>{p(!1),y(null)},[]),k=n(()=>({formType:de.View,data:r,isEditing:m,formData:h,handleChange:D,handleEdit:E,handleCancelEdit:S,duplicateWarning:b,setDuplicateWarning:y,sourceOptions:d,namespaceOptions:c}),[r,m,h,D,E,S,b,d,c]);return e(ce.Provider,{value:k,children:u})};function fe(e){const[a,r]=t(()=>0===e?"all":"sample"),[s,o]=t(()=>me(e)),[l,d]=t(()=>"custom"===me(e)?String(e):"");i(()=>{r(0===e?"all":"sample");const t=me(e);o(t),d("custom"===t?String(e):"")},[e]);const c=n(()=>"all"===a?0:"custom"===s?Number(l)||0:Number(s),[a,s,l]);return{percentageMode:a,setPercentageMode:r,percentagePreset:s,setPercentagePreset:o,customPercentage:l,setCustomPercentage:d,resolvedPercentage:c}}const ge=({enabled:a,keepPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>j({enabled:o,keepPercentage:d.resolvedPercentage}),[o,d.resolvedPercentage]),u=n(()=>({formType:de.EditAutoNoisy,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},ve=({enabled:a,dropPercentage:r,children:s})=>{const[o,l]=t(a),d=fe(r);i(()=>{l(a)},[a]);const c=n(()=>U(o?{disabled:!1,percentageAtMost:d.resolvedPercentage}:null),[o,d.resolvedPercentage]),u=n(()=>({formType:de.EditAutoCostReduction,localEnabled:o,setLocalEnabled:l,...d,summary:c}),[o,d,c]);return e(ce.Provider,{value:u,children:s})},be=({enabled:a,children:r})=>{const[s,o]=t(a);i(()=>{o(a)},[a]);const l=n(()=>M(s?{disabled:!1}:null),[s]),d=n(()=>({formType:de.EditAutoHighlyRelevant,localEnabled:s,setLocalEnabled:o,summary:l}),[s,l]);return e(ce.Provider,{value:d,children:r})},ye=t=>{switch(t.formType){case de.Create:return e(pe,{...t});case de.View:return e(he,{...t});case de.EditAutoNoisy:return e(ge,{...t});case de.EditAutoCostReduction:return e(ve,{...t});case de.EditAutoHighlyRelevant:return e(be,{...t})}};function De(e){const t=r(ce);if(!t)throw new Error("useSamplingRulesFormContext must be used within a SamplingRulesFormProvider");if(e&&t.formType!==e)throw new Error(`Expected formType "${e}" but found "${t.formType}"`);return t}const Ee={otelServiceName:"",currentStreamName:""},Se=s(null),ke=({children:r})=>{const[s,o]=t(void 0),i=l(Ee),c=a(e=>{i.resetFormData((({serviceName:e,id:t})=>({otelServiceName:e||t.name||"",currentStreamName:""}))(e)),i.handleErrorChange(void 0,void 0,{}),o(void 0)},[]),u=a(()=>{const e=d(i.formData);return i.handleErrorChange(void 0,void 0,{}),o(void 0),{errorMessage:void 0,preparedFormData:e}},[i]),m=n(()=>({loadSource:c,genericForm:i,validateFormData:u,errorMessage:s}),[c,i,u,s]);return e(Se.Provider,{value:m,children:r})},Ce=()=>{const e=r(Se);if(!e)throw new Error("useSourceEditFormContext must be used within a SourceEditFormContextProvider");return e},Ae=new Set([N.StaticPod]),Fe=e=>{const t=e.workloads.filter(({selected:e})=>e).length,a=e.workloads.length;return{selectedCount:t,isAllSourced:t>0&&t===a,isSomeSourced:t>0&&t<a,isFutureApps:e.selected||!1}},Ie=(e,t,a)=>{if(t&&!e.name.toLowerCase().includes(t.toLowerCase()))return!1;if(a.showOnlySelected){const{isAllSourced:t,isSomeSourced:a,isFutureApps:n}=Fe(e);return t||a||n}return!0},we=(e,t,a)=>!(t&&!e.name.toLowerCase().includes(t.toLowerCase()))&&(!a.showOnlySelected||e.selected),Ne=s({snapshots:null,setSnapshots:()=>{},isFetching:!1,setIsFetching:()=>{},formData:[],handleSourceChange:()=>{},handleSelectAll:()=>{},formDiff:{},isFormDirty:!1}),xe=(e,t,a)=>{const n=[];return t.workloads.forEach(r=>{const s=e?.workloads.find(e=>e.name===r.name&&e.kind===r.kind);r.selected!==s?.selected&&n.push({namespace:t.name,name:r.name,kind:r.kind,selected:r.selected||!1,currentStreamName:a})}),n},Re=({children:r,selectedConnectionIds:s,initialInputs:o})=>{const{tier:l}=V(),c=l===x.Onprem,{capabilities:u}=P(),m=u.canInstrumentNamespaces,{selectedStreamName:p}=f(),[h,g]=t(!1),[v,b]=t(null),[y,D]=t([]);i(()=>{v&&D(e=>{const t=((e,t)=>d(((e,t)=>e.clusters.filter(({clusterId:e})=>!t||t.includes(e)))(e,t)))(v,s);return t.map(t=>{const a=e?.find(e=>e.clusterId===t.clusterId),n=a??t;if(o?.[t.clusterId]){const e=o[t.clusterId],a=d(n);return e.forEach(e=>{const t=a.namespaces.find(t=>t.name===e.namespace);if(t)if(e.name&&e.kind){const a=t.workloads.find(t=>t.name===e.name&&t.kind===e.kind);a&&(a.selected=e.selected)}else t.selected=e.selected,e.selected&&t.workloads.forEach(e=>{Ae.has(e.kind)&&!c||(e.selected=!0)})}),a}return n})})},[v,s,o]);const{formDiff:E,isFormDirty:S}=n(()=>{const e=((e,t,a,n)=>{const r={};return e.forEach(e=>{e.namespaces.forEach(s=>{const o=t.find(t=>t.clusterId===e.clusterId)?.namespaces.find(e=>e.name===s.name);if(!n){const t=xe(o,s,a);return void(t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t)))}const i=s.selected||!1;if(i!==o?.selected)r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push({namespace:s.name,selected:i,currentStreamName:a}),i?r[e.clusterId]=r[e.clusterId].filter(e=>e.namespace!==s.name||e.namespace===s.name&&(!e.name||!e.kind)):s.workloads.forEach(t=>{t.selected&&r[e.clusterId].push({namespace:s.name,name:t.name,kind:t.kind,selected:!0,currentStreamName:a})});else{const t=xe(o,s,a);t.length>0&&(r[e.clusterId]||(r[e.clusterId]=[]),r[e.clusterId].push(...t))}})}),r})(y,v?.clusters||[],p,m);return{formDiff:e,isFormDirty:Object.keys(e).length>0}},[y,v,p,m]),k=a(e=>!c&&Ae.has(e),[c]),C=a(({clusterId:e,workloadId:t,selected:a,auto:n})=>{D(r=>{const s=d(r),o=s.findIndex(t=>t.clusterId===e);if(-1===o)return s;const i=s[o].namespaces.findIndex(e=>e.name===t.namespace);if(-1===i)return s;if(t.kind&&t.name){const e=s[o].namespaces[i].workloads.findIndex(e=>e.name===t.name&&e.kind===t.kind);if(-1===e)return s;const n="boolean"==typeof a?a:!s[o].namespaces[i].workloads[e].selected;if(s[o].namespaces[i].workloads[e].selected=n,m)if(n){s[o].namespaces[i].workloads.filter(e=>!k(e.kind)).every(e=>e.selected)&&(s[o].namespaces[i].selected=!0)}else s[o].namespaces[i].selected=!1}else if(m){const e="boolean"==typeof n?n:!s[o].namespaces[i].selected;s[o].namespaces[i].selected=e,e?s[o].namespaces[i].workloads.forEach(e=>{k(e.kind)||(e.selected=!0)}):"boolean"!=typeof a||a||s[o].namespaces[i].workloads.forEach(e=>{e.selected=!1})}else{const e="boolean"==typeof a?a:"boolean"!=typeof n||n;s[o].namespaces[i].workloads.forEach(t=>{e&&k(t.kind)||(t.selected=e)})}return s})},[k,m]),A=a(({clusterId:e,namespaceName:t,boolean:a,searchText:n="",searchBy:r="",filters:s})=>{D(o=>{const i=d(o),l=r===R.Namespace?n:"",c=r===R.Source?n:"",u=!!l||!!c||!!s?.showOnlySelected;return i.forEach((n,r)=>{e&&n.clusterId!==e||n.namespaces.forEach(({name:e,workloads:n},o)=>{if(!t||e===t)if(u)if(t){if(n.forEach((e,t)=>{a&&k(e.kind)||we(e,c,s||{showOnlySelected:!1})&&(i[r].namespaces[o].workloads[t].selected=a)}),m){const e=i[r].namespaces[o].workloads.filter(e=>!k(e.kind)).every(e=>e.selected);i[r].namespaces[o].selected=e}}else{if(!Ie(i[r].namespaces[o],l,s||{showOnlySelected:!1}))return;m&&(i[r].namespaces[o].selected=a),n.forEach((e,t)=>{a&&k(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})}else m&&(i[r].namespaces[o].selected=a),n.forEach((e,t)=>{a&&k(e.kind)||(i[r].namespaces[o].workloads[t].selected=a)})})}),i})},[k,m]);return e(Ne.Provider,{value:{snapshots:v,setSnapshots:b,isFetching:h,setIsFetching:g,formData:y,handleSourceChange:C,handleSelectAll:A,formDiff:E,isFormDirty:S},children:r})},Pe=()=>r(Ne);export{Q as A,X as D,Ae as E,ie as R,de as S,ne as a,ye as b,ke as c,Re as d,Y as e,re as f,le as g,De as h,Ce as i,Pe as j,we as k,Ie as l,Fe as m,W as u};
|