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

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.
@@ -1,5 +1,16 @@
1
1
  import { FC } from 'react';
2
2
  import { TDynamicComponentsAppTypeMap } from '../../types';
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.
13
+ */
3
14
  export declare const ConverterBytes: FC<{
4
15
  data: TDynamicComponentsAppTypeMap['ConverterBytes'];
5
16
  }>;
@@ -1,5 +1,5 @@
1
1
  export type TCanonicalUnit = 'B' | 'kB' | 'MB' | 'GB' | 'TB' | 'PB' | 'EB' | 'KiB' | 'MiB' | 'GiB' | 'TiB' | 'PiB' | 'EiB';
2
- export type TUnitInput = TCanonicalUnit | 'k' | 'm' | 'g' | 't' | 'p' | 'e' | 'K' | 'M' | 'G' | 'T' | 'P' | 'E' | 'KB' | 'Mb' | 'MB' | 'Gb' | 'GB' | 'Tb' | 'TB' | 'Pb' | 'PB' | 'Eb' | 'EB' | 'Ki' | 'Mi' | 'Gi' | 'Ti' | 'Pi' | 'Ei' | 'KiB' | 'MiB' | 'GiB' | 'TiB' | 'PiB' | 'EiB';
2
+ export type TUnitInput = TCanonicalUnit | 'b' | 'byte' | 'bytes' | 'k' | 'm' | 'g' | 't' | 'p' | 'e' | 'K' | 'M' | 'G' | 'T' | 'P' | 'E' | 'kb' | 'KB' | 'mb' | 'Mb' | 'MB' | 'gb' | 'Gb' | 'GB' | 'tb' | 'Tb' | 'TB' | 'pb' | 'Pb' | 'PB' | 'eb' | 'Eb' | 'EB' | 'ki' | 'mi' | 'gi' | 'ti' | 'pi' | 'ei' | 'kib' | 'mib' | 'gib' | 'tib' | 'pib' | 'eib' | 'Ki' | 'Mi' | 'Gi' | 'Ti' | 'Pi' | 'Ei' | 'KiB' | 'MiB' | 'GiB' | 'TiB' | 'PiB' | 'EiB';
3
3
  export type TConvertOptions = {
4
4
  /** If true, returns "12.3 GiB" instead of just 12.3 */
5
5
  format?: boolean;
@@ -13,3 +13,20 @@ export declare const formatBytesAuto: (bytes: number, options?: {
13
13
  precision?: number;
14
14
  locale?: string;
15
15
  }) => string;
16
+ /** Internal helper: convert value in given unit -> bytes (number) */
17
+ export declare const toBytes: (value: number, from: TUnitInput) => number;
18
+ /**
19
+ * Generic helper: convert value in some unit -> target unit.
20
+ * Uses bytes as intermediate.
21
+ */
22
+ export declare const convertStorage: (value: number, from: TUnitInput, to: TUnitInput, opts?: TConvertOptions) => number | string;
23
+ /**
24
+ * Try to parse a string like:
25
+ * "12312312Ki"
26
+ * " 12.5 GiB"
27
+ * "1000" (no unit -> unit undefined)
28
+ */
29
+ export declare const parseValueWithUnit: (input: string) => {
30
+ value: number;
31
+ unit?: TUnitInput | undefined;
32
+ } | null;
@@ -10,10 +10,11 @@ export declare const parseMutliqueryText: ({ text, multiQueryData, customFallbac
10
10
  multiQueryData: TDataMap;
11
11
  customFallback?: string | undefined;
12
12
  }) => string;
13
- export declare const parseJsonPathTemplate: ({ text, multiQueryData, customFallback, }: {
13
+ export declare const parseJsonPathTemplate: ({ text, multiQueryData, customFallback, replaceValues, }: {
14
14
  text?: string | undefined;
15
15
  multiQueryData: TDataMap;
16
16
  customFallback?: string | undefined;
17
+ replaceValues?: Record<string, string | undefined> | undefined;
17
18
  }) => string;
18
19
  export declare const parseWithoutPartsOfUrl: ({ text, multiQueryData, customFallback, }: {
19
20
  text: string;
@@ -293,6 +293,10 @@ export type TDynamicComponentsAppTypeMap = {
293
293
  standard?: 'si' | 'iec';
294
294
  notANumberText?: string;
295
295
  style?: CSSProperties;
296
+ /** If provided, value is in this unit instead of raw bytes */
297
+ fromUnit?: TUnitInput;
298
+ /** If provided, convert to this explicit unit */
299
+ toUnit?: TUnitInput;
296
300
  };
297
301
  SecretBase64Plain: {
298
302
  id: number | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prorobotech/openapi-k8s-toolkit",
3
- "version": "1.2.0-alpha.1",
3
+ "version": "1.2.0-alpha.3",
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",