@odigos/ui-kit 0.0.98 → 0.0.100

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/lib/functions.js CHANGED
@@ -1,141 +1 @@
1
- export { c as capitalizeFirstLetter, f as flattenObjectKeys, g as getConditionsBooleans, a as getMonitorIcon, b as getStatusIcon, i as isStringABoolean, d as isValidVersion, m as mapConditions, n as numbersOnly, p as parseBooleanFromString, e as parseJsonStringToPrettyString, r as removeEmptyValuesFromObject, s as safeJsonStringify, h as splitCamelString } from './index-9475009f.js';
2
- import { K as K8sLogo } from './index-89edd01d.js';
3
- export { c as compareCondition, g as getActionIcon, d as getEntityId, e as getInstrumentationRuleIcon, f as getProgrammingLanguageIcon } from './index-89edd01d.js';
4
- export { d as deepClone, i as isEmpty, s as safeJsonParse } from './index-5e5f7bda.js';
5
- export { f as filterActions, a as filterDestinations, b as filterDestinationsByStream, c as filterSources, d as filterSourcesByStream, e as formatBytes, g as formatDuration, i as getContainersIcons, h as getContainersInstrumentedCount, j as getDestinationIcon, k as getEntityIcon, l as getEntityLabel, m as getMetricForEntity, n as getRecursiveValues, o as getValueForRange, p as getWorkloadId, q as getYamlFieldsForDestination, r as hasUnhealthyInstances, s as isOverTime, t as mapDestinationFieldsForDisplay, u as sleep } from './index-c823fbfb.js';
6
- export { g as getIdFromSseTarget, i as isLegalK8sLabel, m as mapExportedSignals } from './index-6a6bea6e.js';
7
- import { ProgrammingLanguages, PlatformType, EntityTypes } from './types.js';
8
- import 'react';
9
- import 'styled-components';
10
- import { O as OdigosLogo } from './index-f18c8530.js';
11
- import { V as VmLogo } from './index-0a77c1be.js';
12
- import './index-195415d4.js';
13
-
14
- const cleanObjectEmptyStringsValues = (obj) => {
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const cleanArray = (arr) => arr.filter((item) => {
17
- if (typeof item === 'object' && item !== null) {
18
- return item.key !== '' && item.value !== '';
19
- }
20
- return item !== '';
21
- });
22
- const cleanObject = (o) => Object.fromEntries(Object.entries(o)
23
- .filter(([key, value]) => key !== '' && value !== '')
24
- .map(([key, value]) => {
25
- if (Array.isArray(value))
26
- return [key, cleanArray(value)];
27
- else if (typeof value === 'object' && value !== null)
28
- return [key, cleanObject(value)];
29
- return [key, value];
30
- }));
31
- return Object.entries(obj).reduce((acc, [key, value]) => {
32
- try {
33
- const parsed = JSON.parse(value);
34
- if (Array.isArray(parsed)) {
35
- acc[key] = JSON.stringify(cleanArray(parsed));
36
- }
37
- else if (typeof parsed === 'object' && parsed !== null) {
38
- acc[key] = JSON.stringify(cleanObject(parsed));
39
- }
40
- else {
41
- acc[key] = value;
42
- }
43
- }
44
- catch (_) {
45
- // Handle non-stringified objects or arrays directly
46
- if (typeof value === 'object' && value !== null) {
47
- if (Array.isArray(value))
48
- acc[key] = JSON.stringify(cleanArray(value));
49
- else
50
- acc[key] = JSON.stringify(cleanObject(value));
51
- }
52
- else {
53
- // In case JSON.parse fails, assume value is a plain string or non-object/array
54
- acc[key] = value;
55
- }
56
- }
57
- return acc;
58
- }, {});
59
- };
60
-
61
- // while odigos lists language per container, we want to aggregate one single language for the workload.
62
- // the process is mostly heuristic, we iterate over the containers and return the first valid language we find.
63
- // there are additional cases for when the workload programming language is not available.
64
- const getMainContainerLanguage = (source) => {
65
- const { numberOfInstances, containers } = source;
66
- if (!containers) {
67
- if (!!numberOfInstances && numberOfInstances > 0) {
68
- return ProgrammingLanguages.Processing;
69
- }
70
- else {
71
- return ProgrammingLanguages.NoRunningPods;
72
- }
73
- }
74
- // we will filter out the ignored languages as we don't want to account them in the main language
75
- const noneIgnoredLanguages = containers?.filter((container) => container.language !== ProgrammingLanguages.Ignored);
76
- if (!noneIgnoredLanguages.length)
77
- return ProgrammingLanguages.NoContainers;
78
- // find the first container with valid language
79
- const mainContainer = noneIgnoredLanguages.find((container) => container.language !== ProgrammingLanguages.Unknown);
80
- // no valid language found, return the first one
81
- if (!mainContainer)
82
- return ProgrammingLanguages.Unknown;
83
- return mainContainer.language;
84
- };
85
-
86
- const getPlatformIcon = (type) => {
87
- if (!type)
88
- return OdigosLogo;
89
- const LOGOS = {
90
- [PlatformType.K8s]: K8sLogo,
91
- [PlatformType.Vm]: VmLogo,
92
- };
93
- return LOGOS[type];
94
- };
95
-
96
- const getPlatformLabel = (type) => {
97
- if (!type)
98
- return 'Unknown';
99
- const LABELS = {
100
- [PlatformType.K8s]: 'Kubernetes Cluster',
101
- [PlatformType.Vm]: 'Virtual Machine',
102
- };
103
- return LABELS[type];
104
- };
105
-
106
- const getSseTargetFromId = (id, type) => {
107
- switch (type) {
108
- case EntityTypes.Source: {
109
- let target = '';
110
- Object.entries(id).forEach(([key, value]) => {
111
- target += `${key}=${value}&`;
112
- });
113
- target.slice(0, -1);
114
- return target;
115
- }
116
- default:
117
- return id;
118
- }
119
- };
120
-
121
- const isTimeElapsed = (originDate, difference = 0) => {
122
- const now = new Date().getTime();
123
- const compareWith = new Date(originDate).getTime();
124
- return now - compareWith >= difference;
125
- };
126
-
127
- const stringifyNonStringValues = (obj) => {
128
- return Object.entries(obj).reduce((acc, [key, value]) => {
129
- // Check if the value is already a string
130
- if (typeof value === 'string') {
131
- acc[key] = value;
132
- }
133
- else {
134
- // If not, stringify the value
135
- acc[key] = JSON.stringify(value);
136
- }
137
- return acc;
138
- }, {});
139
- };
140
-
141
- export { cleanObjectEmptyStringsValues, getMainContainerLanguage, getPlatformIcon, getPlatformLabel, getSseTargetFromId, isTimeElapsed, stringifyNonStringValues };
1
+ export{a$ as capitalizeFirstLetter,bX as cleanObjectEmptyStringsValues,aU as compareCondition,b2 as deepClone,a2 as filterActions,ax as filterDestinations,aw as filterDestinationsByStream,av as filterSources,au as filterSourcesByStream,bY as flattenObjectKeys,ai as formatBytes,bI as formatDuration,y as getActionIcon,W as getConditionsBooleans,an as getContainersIcons,by as getContainersInstrumentedCount,aq as getDestinationIcon,a9 as getEntityIcon,aE as getEntityId,a4 as getEntityLabel,bZ as getIdFromSseTarget,am as getInstrumentationRuleIcon,b_ as getMainContainerLanguage,b5 as getMetricForEntity,b$ as getMonitorIcon,c0 as getPlatformIcon,c1 as getPlatformLabel,bc as getProgrammingLanguageIcon,bK as getRecursiveValues,c2 as getSseTargetFromId,a0 as getStatusIcon,ao as getValueForRange,bh as getWorkloadId,aZ as getYamlFieldsForDestination,bm as hasUnhealthyInstances,i as isEmpty,c3 as isLegalK8sLabel,bz as isOverTime,bq as isStringABoolean,c4 as isTimeElapsed,c5 as isValidVersion,Z as mapConditions,aT as mapDestinationFieldsForDisplay,ap as mapExportedSignals,c6 as numbersOnly,br as parseBooleanFromString,c7 as parseJsonStringToPrettyString,c8 as removeEmptyValuesFromObject,aV as safeJsonParse,c9 as safeJsonStringify,ag as sleep,aG as splitCamelString,ca as stringifyNonStringValues}from"./chunks/ui-components-bd79fd1d.js";import"./icons.js";import"react";import"zustand";import"javascript-time-ago";import"./chunks/vendor-1dea551d.js";import"styled-components";import"@xyflow/react";import"react-dom";import"prism-react-renderer";import"react-error-boundary";import"lottie-react";