@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.3 → 1.2.0-alpha.5

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 (24) hide show
  1. package/dist/openapi-k8s-toolkit.es.js +309 -42
  2. package/dist/openapi-k8s-toolkit.es.js.map +1 -1
  3. package/dist/openapi-k8s-toolkit.umd.js +309 -42
  4. package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
  5. package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTable/EnrichedTable.d.ts +2 -1
  6. package/dist/types/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.d.ts +4 -2
  7. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterBytes/ConverterBytes.d.ts +11 -9
  8. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/ConverterCores.d.ts +19 -0
  9. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/index.d.ts +1 -0
  10. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/types.d.ts +7 -0
  11. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/utils.d.ts +45 -0
  12. package/dist/types/components/organisms/DynamicComponents/molecules/ConverterCores/utilts.test.d.ts +1 -0
  13. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/MemoryChart.d.ts +6 -0
  14. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/MemoryChartMulti.d.ts +6 -0
  15. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/usePrometheusQueryRange.d.ts +7 -0
  16. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/hooks/usePrometheusQueryRangeMulti.d.ts +7 -0
  17. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/prometheus.d.ts +10 -0
  18. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/prometheus.test.d.ts +1 -0
  19. package/dist/types/components/organisms/DynamicComponents/molecules/PrometheusGraph/utils/prometheusAdapter.d.ts +21 -0
  20. package/dist/types/components/organisms/DynamicComponents/molecules/index.d.ts +1 -0
  21. package/dist/types/components/organisms/DynamicComponents/types.d.ts +21 -1
  22. package/dist/types/localTypes/bff/table.d.ts +2 -1
  23. package/dist/types/localTypes/richTable.d.ts +2 -0
  24. package/package.json +2 -1
@@ -1,6 +1,6 @@
1
1
  import React, { FC, ReactNode } from 'react';
2
2
  import { TableProps, TablePaginationConfig } from 'antd';
3
- import { TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsKeyTypeProps, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsUndefinedValues } from '../../../../../localTypes/richTable';
3
+ import { TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsKeyTypeProps, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsUndefinedValues, TAdditionalPrinterColumnsDisableSortersAndFilters } from '../../../../../localTypes/richTable';
4
4
  export type TEnrichedTableProps = {
5
5
  theme: 'light' | 'dark';
6
6
  baseprefix?: string;
@@ -14,6 +14,7 @@ export type TEnrichedTableProps = {
14
14
  additionalPrinterColumnsTrimLengths?: TAdditionalPrinterColumnsTrimLengths;
15
15
  additionalPrinterColumnsColWidths?: TAdditionalPrinterColumnsColWidths;
16
16
  additionalPrinterColumnsKeyTypeProps?: TAdditionalPrinterColumnsKeyTypeProps;
17
+ additionalPrinterColumnsDisableSortersAndFilters?: TAdditionalPrinterColumnsDisableSortersAndFilters;
17
18
  selectData?: {
18
19
  onChange: (selectedRowKeys: React.Key[], selectedRowsData: {
19
20
  name: string;
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { NavigateFunction } from 'react-router-dom';
3
3
  import { TableProps } from 'antd';
4
- import { TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsUndefinedValues, TAdditionalPrinterColumnsKeyTypeProps } from '../../../../../localTypes/richTable';
4
+ import { TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsUndefinedValues, TAdditionalPrinterColumnsKeyTypeProps, TAdditionalPrinterColumnsDisableSortersAndFilters } from '../../../../../localTypes/richTable';
5
5
  import { TJSON } from '../../../../../localTypes/JSON';
6
6
  export declare const getCellRender: ({ value, record, possibleTrimLength, possibleUndefinedValue, possibleCustomTypeWithProps, theme, }: {
7
7
  value: TJSON;
@@ -14,13 +14,15 @@ export declare const getCellRender: ({ value, record, possibleTrimLength, possib
14
14
  } | undefined;
15
15
  theme: 'dark' | 'light';
16
16
  }) => JSX.Element;
17
- export declare const getEnrichedColumns: ({ columns, additionalPrinterColumnsUndefinedValues, additionalPrinterColumnsTrimLengths, additionalPrinterColumnsColWidths, additionalPrinterColumnsKeyTypeProps, theme, }: {
17
+ export declare const getEnrichedColumns: ({ columns, additionalPrinterColumnsUndefinedValues, additionalPrinterColumnsTrimLengths, additionalPrinterColumnsColWidths, additionalPrinterColumnsKeyTypeProps, additionalPrinterColumnsDisableSortersAndFilters, theme, getRowKey, }: {
18
18
  columns: TableProps['columns'];
19
19
  additionalPrinterColumnsUndefinedValues?: TAdditionalPrinterColumnsUndefinedValues | undefined;
20
20
  additionalPrinterColumnsTrimLengths?: TAdditionalPrinterColumnsTrimLengths | undefined;
21
21
  additionalPrinterColumnsColWidths?: TAdditionalPrinterColumnsColWidths | undefined;
22
22
  additionalPrinterColumnsKeyTypeProps?: TAdditionalPrinterColumnsKeyTypeProps | undefined;
23
+ additionalPrinterColumnsDisableSortersAndFilters?: TAdditionalPrinterColumnsDisableSortersAndFilters | undefined;
23
24
  theme: 'dark' | 'light';
25
+ getRowKey: (record: any) => React.Key;
24
26
  }) => TableProps['columns'] | undefined;
25
27
  export declare const getEnrichedColumnsWithControls: ({ enrichedColumns, navigate, baseprefix, editIcon, deleteIcon, }: {
26
28
  enrichedColumns: TableProps['columns'];
@@ -1,15 +1,17 @@
1
1
  import { FC } from 'react';
2
2
  import { TDynamicComponentsAppTypeMap } from '../../types';
3
3
  /**
4
- * Idea:
5
- * 1. bytesValue may now be:
6
- * - "1234567890" → raw number (bytes)
7
- * - "12312312Ki" → number + source unit
8
- * 2. We parse it using parseValueWithUnit.
9
- * 3. If the input contains a unit, we treat that as the from-unit (unless overridden with an explicit fromUnit prop).
10
- * 4. Then:
11
- * - If there’s a target unit (unit or toUnit), we use convertStorage.
12
- * - If not, we convert to bytes and auto-scale with formatBytesAuto.
4
+ * Idea (extended for arrays):
5
+ * 1. bytesValue may be:
6
+ * - "1234567890" → raw number (bytes)
7
+ * - "12312312Ki" → number + source unit
8
+ * - ["10GiB", "512Mi", "1024"] array; all converted to bytes, summed, then formatted
9
+ * 2. Each entry is resolved via parseAll, then parsed with parseValueWithUnit.
10
+ * 3. Each value is converted to base bytes (respecting fromUnit override).
11
+ * 4. All bytes are summed into totalBytes.
12
+ * 5. Finally:
13
+ * - If there’s a target unit (unit or toUnit), we convert totalBytes to that.
14
+ * - If not, we auto-scale totalBytes with formatBytesAuto.
13
15
  */
14
16
  export declare const ConverterBytes: FC<{
15
17
  data: TDynamicComponentsAppTypeMap['ConverterBytes'];
@@ -0,0 +1,19 @@
1
+ import { FC } from 'react';
2
+ import { TDynamicComponentsAppTypeMap } from '../../types';
3
+ /**
4
+ * Idea (extended for arrays):
5
+ * 1. coresValue may be:
6
+ * - "0.5" → raw number (cores)
7
+ * - "500m" → number + source unit (millicores)
8
+ * - "2 vcpu" → number + alias for "core"
9
+ * - ["500m", "0.5 core", "1"] → array of such values
10
+ * 2. Each entry is resolved via parseAll, then parsed with parseCoresWithUnit.
11
+ * 3. Each value is converted to base "cores" (respecting fromUnit override).
12
+ * 4. All cores are summed into totalCores.
13
+ * 5. Finally:
14
+ * - If there’s a target unit (unit or toUnit), we convert totalCores to that.
15
+ * - Otherwise, we auto-scale totalCores with formatCoresAuto.
16
+ */
17
+ export declare const ConverterCores: FC<{
18
+ data: TDynamicComponentsAppTypeMap['ConverterCores'];
19
+ }>;
@@ -0,0 +1 @@
1
+ export { ConverterCores } from './ConverterCores';
@@ -0,0 +1,7 @@
1
+ export type TCoreCanonicalUnit = 'core' | 'mcore' | 'ucore' | 'ncore';
2
+ export type TCoreUnitInput = string | TCoreCanonicalUnit;
3
+ export type TCoreConvertOptions = {
4
+ format?: boolean;
5
+ precision?: number;
6
+ locale?: string;
7
+ };
@@ -0,0 +1,45 @@
1
+ import type { TCoreUnitInput, TCoreConvertOptions } from './types';
2
+ /**
3
+ * Convert cores -> target unit (core/mcore/ucore/ncore).
4
+ * The input `cores` is ALWAYS in **cores** (base unit).
5
+ *
6
+ * @returns number by default (e.g., 0.5 -> 500 when unit="mcore"),
7
+ * or "500 mcore" if format=true
8
+ */
9
+ export declare const convertCores: (cores: number, unit: TCoreUnitInput, opts?: TCoreConvertOptions) => number | string;
10
+ /**
11
+ * Auto-scale cores across core/mcore/ucore/ncore.
12
+ *
13
+ * - cores >= 1 -> core
14
+ * - 1e-3 <= cores < 1 -> mcore
15
+ * - 1e-6 <= cores < 1e-3 -> ucore
16
+ * - cores < 1e-6 -> ncore
17
+ */
18
+ export declare const formatCoresAuto: (cores: number, options?: {
19
+ precision?: number;
20
+ locale?: string;
21
+ }) => string;
22
+ /** Internal helper: convert value in given unit -> cores (number). */
23
+ export declare const toCores: (value: number, from: TCoreUnitInput) => number;
24
+ /**
25
+ * Generic helper: convert value in some unit -> target unit.
26
+ * Uses cores as intermediate.
27
+ *
28
+ * Examples:
29
+ * convertCompute(500, "m", "core") // 0.5
30
+ * convertCompute(2, "core", "m", {format: true}) // "2,000 mcore" (or locale variant)
31
+ * convertCompute(1_000_000, "n", "core") // 0.001
32
+ */
33
+ export declare const convertCompute: (value: number, from: TCoreUnitInput, to: TCoreUnitInput, opts?: TCoreConvertOptions) => number | string;
34
+ /**
35
+ * Try to parse a string like:
36
+ * "500m"
37
+ * " 0.5 core"
38
+ * "2 vcpu"
39
+ * "1000000n"
40
+ * "1.5" (no unit -> unit undefined, treated as raw number-of-cores upstream)
41
+ */
42
+ export declare const parseCoresWithUnit: (input: string) => {
43
+ value: number;
44
+ unit?: string | undefined;
45
+ } | null;
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ type MemoryChartProps = {
3
+ range?: string;
4
+ };
5
+ export declare const MemoryChart: FC<MemoryChartProps>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ type MemoryChartProps = {
3
+ range?: string;
4
+ };
5
+ export declare const MemoryChartMulti: FC<MemoryChartProps>;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ChartPoint } from '../utils/prometheusAdapter';
2
+ export declare const usePrometheusQueryRange: ({ query, range, refetchInterval, enabled, }: {
3
+ query: string;
4
+ range?: string | undefined;
5
+ refetchInterval?: number | false | undefined;
6
+ enabled?: boolean | undefined;
7
+ }) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<ChartPoint[], Error>;
@@ -0,0 +1,7 @@
1
+ import { RechartsSeries } from '../utils/prometheusAdapter';
2
+ export declare const usePrometheusQueryRangeMulti: ({ query, range, refetchInterval, enabled, }: {
3
+ query: string;
4
+ range?: string | undefined;
5
+ refetchInterval?: number | false | undefined;
6
+ enabled?: boolean | undefined;
7
+ }) => import("@tanstack/react-query/build/legacy/types").UseQueryResult<RechartsSeries[], Error>;
@@ -0,0 +1,10 @@
1
+ export type PrometheusRangeParams = {
2
+ start: string;
3
+ end: string;
4
+ step: string;
5
+ };
6
+ /**
7
+ * Converts a duration string like "30m", "2h", "7d" into start/end ISO timestamps
8
+ * and a safe step value to ensure < 11k data points for Prometheus query_range.
9
+ */
10
+ export declare const buildPrometheusRangeParams: (range?: string) => PrometheusRangeParams;
@@ -0,0 +1,21 @@
1
+ export type PrometheusRangeResponse = {
2
+ status: 'success' | 'error';
3
+ data: {
4
+ resultType: 'matrix';
5
+ result: {
6
+ metric: Record<string, string>;
7
+ values: [number, string][];
8
+ }[];
9
+ };
10
+ };
11
+ export type ChartPoint = {
12
+ timestamp: number;
13
+ value: number;
14
+ };
15
+ export declare const prometheusToRechartsSingle: (resp: PrometheusRangeResponse) => ChartPoint[];
16
+ export type RechartsSeries = {
17
+ id: string;
18
+ metric: Record<string, string>;
19
+ data: ChartPoint[];
20
+ };
21
+ export declare const prometheusToRechartsMulti: (resp: PrometheusRangeResponse) => RechartsSeries[];
@@ -31,6 +31,7 @@ export { Taints } from './Taints';
31
31
  export { Tolerations } from './Tolerations';
32
32
  export { Annotations } from './Annotations';
33
33
  export { ConverterBytes } from './ConverterBytes';
34
+ export { ConverterCores } from './ConverterCores';
34
35
  export { SecretBase64Plain } from './SecretBase64Plain';
35
36
  export { ResourceBadge } from './ResourceBadge';
36
37
  export { Events } from './Events';
@@ -5,6 +5,7 @@ import type { LinkProps } from 'antd/es/typography/Link';
5
5
  import type { TContentCardProps, TSpacerProps } from '../../atoms';
6
6
  import type { TManageableSidebarProviderProps, TEnrichedTableProviderProps } from '../../molecules';
7
7
  import type { TUnitInput } from './molecules/ConverterBytes/types';
8
+ import type { TCoreUnitInput } from './molecules/ConverterCores/types';
8
9
  export type TDynamicComponentsAppTypeMap = {
9
10
  DefaultDiv: {
10
11
  id: number | string;
@@ -282,7 +283,7 @@ export type TDynamicComponentsAppTypeMap = {
282
283
  };
283
284
  ConverterBytes: {
284
285
  id: number | string;
285
- bytesValue: string;
286
+ bytesValue: string | string[];
286
287
  unit?: TUnitInput;
287
288
  /** If true, returns "12.3 GiB" instead of just 12.3 */
288
289
  format?: boolean;
@@ -298,6 +299,25 @@ export type TDynamicComponentsAppTypeMap = {
298
299
  /** If provided, convert to this explicit unit */
299
300
  toUnit?: TUnitInput;
300
301
  };
302
+ ConverterCores: {
303
+ id: number | string;
304
+ /** Raw text that may contain a number or number+unit like "0.5", "500m", "2 vcpu" */
305
+ coresValue: string | string[];
306
+ /** Target unit; omit to auto format (core vs mcore) */
307
+ unit?: TCoreUnitInput;
308
+ /** If true, returns "500 mcore" instead of just 500 */
309
+ format?: boolean;
310
+ /** Max fraction digits when formatting (default 2) */
311
+ precision?: number;
312
+ /** Locale for number formatting (default: undefined => user agent) */
313
+ locale?: string;
314
+ notANumberText?: string;
315
+ style?: CSSProperties;
316
+ /** If provided, value is in this unit instead of raw "cores" */
317
+ fromUnit?: TCoreUnitInput;
318
+ /** If provided, convert to this explicit unit; omit for auto-format */
319
+ toUnit?: TCoreUnitInput;
320
+ };
301
321
  SecretBase64Plain: {
302
322
  id: number | string;
303
323
  base64Value?: string;
@@ -1,4 +1,4 @@
1
- import { TAdditionalPrinterColumns, TAdditionalPrinterColumnsUndefinedValues, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsKeyTypeProps } from '../richTable';
1
+ import { TAdditionalPrinterColumns, TAdditionalPrinterColumnsUndefinedValues, TAdditionalPrinterColumnsTrimLengths, TAdditionalPrinterColumnsColWidths, TAdditionalPrinterColumnsKeyTypeProps, TAdditionalPrinterColumnsDisableSortersAndFilters } from '../richTable';
2
2
  export type TPrepareTableReq = {
3
3
  customizationId?: string;
4
4
  tableMappingsReplaceValues?: Record<string, string | undefined>;
@@ -17,6 +17,7 @@ export type TPrepareTableRes = {
17
17
  additionalPrinterColumnsTrimLengths?: TAdditionalPrinterColumnsTrimLengths;
18
18
  additionalPrinterColumnsColWidths?: TAdditionalPrinterColumnsColWidths;
19
19
  additionalPrinterColumnsKeyTypeProps?: TAdditionalPrinterColumnsKeyTypeProps;
20
+ additionalPrinterColumnsDisableSortersAndFilters?: TAdditionalPrinterColumnsDisableSortersAndFilters;
20
21
  pathToNavigate?: string;
21
22
  recordKeysForNavigation?: string | string[];
22
23
  recordKeysForNavigationSecond?: string | string[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type TAdditionalPrinterColumns = {
2
3
  name: string;
3
4
  jsonPath?: string;
@@ -20,3 +21,4 @@ export type TAdditionalPrinterColumnsKeyTypeProps = Record<string, {
20
21
  type: string;
21
22
  customProps?: unknown;
22
23
  }>;
24
+ export type TAdditionalPrinterColumnsDisableSortersAndFilters = React.Key[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prorobotech/openapi-k8s-toolkit",
3
- "version": "1.2.0-alpha.3",
3
+ "version": "1.2.0-alpha.5",
4
4
  "description": "ProRobotech OpenAPI k8s tools",
5
5
  "main": "dist/openapi-k8s-toolkit.cjs.js",
6
6
  "module": "dist/openapi-k8s-toolkit.es.js",
@@ -54,6 +54,7 @@
54
54
  "lodash": "4.17.21",
55
55
  "openapi-types": "12.1.3",
56
56
  "react-redux": "9.1.2",
57
+ "recharts": "3.5.1",
57
58
  "spoiled": "0.4.0",
58
59
  "styled-components": "6.0.7",
59
60
  "typescript": "4.9.5",