@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.20 → 1.2.0-alpha.21

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.
@@ -75665,7 +75665,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75665
75665
  refetchInterval,
75666
75666
  width,
75667
75667
  height,
75668
- formatValue
75668
+ formatValue,
75669
+ formatTimestamp: formatTimestamp$1
75669
75670
  }) => {
75670
75671
  const {
75671
75672
  data: series,
@@ -75704,11 +75705,12 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75704
75705
  ] });
75705
75706
  }
75706
75707
  const valueFormatter = formatValue ?? formatBytes;
75708
+ const timestampFormatter = formatTimestamp$1 ?? formatTimestamp;
75707
75709
  return /* @__PURE__ */ jsxRuntimeExports.jsx(WidthHeightDiv, { $width: width, $height: height, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AreaChart, { data: chartData, children: [
75708
75710
  /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3" }),
75709
- /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: formatTimestamp }),
75711
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: timestampFormatter }),
75710
75712
  /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: valueFormatter }),
75711
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => formatTimestamp(v) }),
75713
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => timestampFormatter(v) }),
75712
75714
  series?.map((s, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
75713
75715
  Area,
75714
75716
  {
@@ -75755,7 +75757,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75755
75757
  refetchInterval,
75756
75758
  width,
75757
75759
  height,
75758
- formatValue
75760
+ formatValue,
75761
+ formatTimestamp: formatTimestamp$1
75759
75762
  }) => {
75760
75763
  const { data = [], isLoading, error } = usePromMatrixToLineSingle({ baseUrl, query, range, refetchInterval });
75761
75764
  if (isLoading) {
@@ -75768,25 +75771,25 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75768
75771
  ] });
75769
75772
  }
75770
75773
  const valueFormatter = formatValue ?? formatBytes;
75774
+ const xAxisFormatter = formatTimestamp$1 ?? ((value) => {
75775
+ const ts = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
75776
+ if (!Number.isFinite(ts)) {
75777
+ return "";
75778
+ }
75779
+ return new Date(ts).toLocaleTimeString();
75780
+ });
75781
+ const tooltipTimestampFormatter = formatTimestamp$1 ?? formatTimestamp;
75771
75782
  return /* @__PURE__ */ jsxRuntimeExports.jsx(WidthHeightDiv, { $width: width, $height: height, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AreaChart, { data, children: [
75772
75783
  /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3" }),
75784
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["auto", "auto"], tickFormatter: xAxisFormatter }),
75785
+ /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: (value) => valueFormatter(value) }),
75773
75786
  /* @__PURE__ */ jsxRuntimeExports.jsx(
75774
- XAxis,
75787
+ Tooltip,
75775
75788
  {
75776
- dataKey: "timestamp",
75777
- type: "number",
75778
- domain: ["auto", "auto"],
75779
- tickFormatter: (value) => {
75780
- const ts = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
75781
- if (!Number.isFinite(ts)) {
75782
- return "";
75783
- }
75784
- return new Date(ts).toLocaleTimeString();
75785
- }
75789
+ formatter: (value) => valueFormatter(value),
75790
+ labelFormatter: (value) => tooltipTimestampFormatter(value)
75786
75791
  }
75787
75792
  ),
75788
- /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: (value) => valueFormatter(value) }),
75789
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (value) => valueFormatter(value), labelFormatter: (value) => formatTimestamp(value) }),
75790
75793
  /* @__PURE__ */ jsxRuntimeExports.jsx(
75791
75794
  Area,
75792
75795
  {
@@ -75827,7 +75830,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75827
75830
  refetchInterval,
75828
75831
  width,
75829
75832
  height,
75830
- formatValue
75833
+ formatValue,
75834
+ formatTimestamp: formatTimestamp$1
75831
75835
  }) => {
75832
75836
  const { data: series = [], isLoading, error } = usePromMatrixToLineMulti({ baseUrl, query, range, refetchInterval });
75833
75837
  const chartData = React$1.useMemo(() => matrixToStackedAreaData(series), [series]);
@@ -75841,11 +75845,12 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75841
75845
  ] });
75842
75846
  }
75843
75847
  const valueFormatter = formatValue ?? formatBytes;
75848
+ const timestampFormatter = formatTimestamp$1 ?? formatTimestamp;
75844
75849
  return /* @__PURE__ */ jsxRuntimeExports.jsx(WidthHeightDiv, { $width: width, $height: height, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AreaChart, { data: chartData, children: [
75845
75850
  /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3" }),
75846
- /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: formatTimestamp }),
75851
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: timestampFormatter }),
75847
75852
  /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: valueFormatter }),
75848
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => formatTimestamp(v) }),
75853
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => timestampFormatter(v) }),
75849
75854
  series.map((s, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
75850
75855
  Area,
75851
75856
  {
@@ -75871,7 +75876,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75871
75876
  refetchInterval,
75872
75877
  width,
75873
75878
  height,
75874
- formatValue
75879
+ formatValue,
75880
+ formatTimestamp: formatTimestamp$1
75875
75881
  }) => {
75876
75882
  const {
75877
75883
  data: series,
@@ -75910,11 +75916,12 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75910
75916
  ] });
75911
75917
  }
75912
75918
  const valueFormatter = formatValue ?? formatBytes;
75919
+ const timestampFormatter = formatTimestamp$1 ?? formatTimestamp;
75913
75920
  return /* @__PURE__ */ jsxRuntimeExports.jsx(WidthHeightDiv, { $width: width, $height: height, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(LineChart, { data: chartData, children: [
75914
75921
  /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3" }),
75915
- /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: formatTimestamp }),
75922
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", tickFormatter: timestampFormatter }),
75916
75923
  /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: valueFormatter }),
75917
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => formatTimestamp(v) }),
75924
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (v) => valueFormatter(v), labelFormatter: (v) => timestampFormatter(v) }),
75918
75925
  series?.map((s, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
75919
75926
  Line,
75920
75927
  {
@@ -75937,7 +75944,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75937
75944
  refetchInterval,
75938
75945
  width,
75939
75946
  height,
75940
- formatValue
75947
+ formatValue,
75948
+ formatTimestamp: formatTimestamp$1
75941
75949
  }) => {
75942
75950
  const {
75943
75951
  data = [],
@@ -75959,25 +75967,25 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
75959
75967
  ] });
75960
75968
  }
75961
75969
  const valueFormatter = formatValue ?? formatBytes;
75970
+ const xAxisFormatter = formatTimestamp$1 ?? ((value) => {
75971
+ const ts = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
75972
+ if (!Number.isFinite(ts)) {
75973
+ return "";
75974
+ }
75975
+ return new Date(ts).toLocaleTimeString();
75976
+ });
75977
+ const tooltipTimestampFormatter = formatTimestamp$1 ?? formatTimestamp;
75962
75978
  return /* @__PURE__ */ jsxRuntimeExports.jsx(WidthHeightDiv, { $width: width, $height: height, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(LineChart, { data, children: [
75963
75979
  /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3" }),
75980
+ /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["auto", "auto"], tickFormatter: xAxisFormatter }),
75981
+ /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: (value) => valueFormatter(value) }),
75964
75982
  /* @__PURE__ */ jsxRuntimeExports.jsx(
75965
- XAxis,
75983
+ Tooltip,
75966
75984
  {
75967
- dataKey: "timestamp",
75968
- type: "number",
75969
- domain: ["auto", "auto"],
75970
- tickFormatter: (value) => {
75971
- const ts = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
75972
- if (!Number.isFinite(ts)) {
75973
- return "";
75974
- }
75975
- return new Date(ts).toLocaleTimeString();
75976
- }
75985
+ formatter: (value) => valueFormatter(value),
75986
+ labelFormatter: (value) => tooltipTimestampFormatter(value)
75977
75987
  }
75978
75988
  ),
75979
- /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { tickFormatter: (value) => valueFormatter(value) }),
75980
- /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { formatter: (value) => valueFormatter(value), labelFormatter: (value) => formatTimestamp(value) }),
75981
75989
  /* @__PURE__ */ jsxRuntimeExports.jsx(
75982
75990
  Line,
75983
75991
  {
@@ -76087,7 +76095,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76087
76095
  range = "1h",
76088
76096
  refetchInterval,
76089
76097
  title = "Memory usage (min / max / current)",
76090
- formatValue
76098
+ formatValue,
76099
+ formatTimestamp: formatTimestamp$1
76091
76100
  }) => {
76092
76101
  const {
76093
76102
  data: series = [],
@@ -76128,6 +76137,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76128
76137
  });
76129
76138
  }, [series]);
76130
76139
  const valueFormatter = formatValue ?? formatBytes;
76140
+ const timestampFormatter = formatTimestamp$1 ?? formatTimestamp;
76131
76141
  const columns = React$1.useMemo(
76132
76142
  () => [
76133
76143
  {
@@ -76172,11 +76182,11 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76172
76182
  dataIndex: "currentTs",
76173
76183
  key: "currentTs",
76174
76184
  width: 180,
76175
- render: (ts) => ts == null ? "" : formatTimestamp(ts),
76185
+ render: (ts) => ts == null ? "-" : timestampFormatter(ts),
76176
76186
  sorter: (a, b) => (a.currentTs ?? -Infinity) - (b.currentTs ?? -Infinity)
76177
76187
  }
76178
76188
  ],
76179
- [valueFormatter]
76189
+ [valueFormatter, timestampFormatter]
76180
76190
  );
76181
76191
  if (error) {
76182
76192
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
@@ -76492,6 +76502,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76492
76502
  query = "container_memory_usage_bytes",
76493
76503
  refetchInterval,
76494
76504
  formatValue,
76505
+ formatTimestamp: formatTimestamp$1,
76495
76506
  title = "Vector → Table"
76496
76507
  }) => {
76497
76508
  const { data, isLoading, error } = usePromVector({ baseUrl, query, refetchInterval });
@@ -76500,6 +76511,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76500
76511
  return rows.map((r) => ({ key: r.id, ...r }));
76501
76512
  }, [data]);
76502
76513
  const valueFormatter = formatValue ?? formatBytes;
76514
+ const timestampFormatter = formatTimestamp$1 ?? formatTimestamp;
76503
76515
  const columns = React$1.useMemo(
76504
76516
  () => [
76505
76517
  {
@@ -76524,12 +76536,12 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76524
76536
  title: "timestamp",
76525
76537
  dataIndex: "timestamp",
76526
76538
  key: "timestamp",
76527
- render: (ts) => formatTimestamp?.(ts) ?? new Date(ts).toLocaleString(),
76539
+ render: (ts) => timestampFormatter(ts),
76528
76540
  sorter: (a, b) => a.timestamp - b.timestamp,
76529
76541
  width: 220
76530
76542
  }
76531
76543
  ],
76532
- [valueFormatter]
76544
+ [valueFormatter, timestampFormatter]
76533
76545
  );
76534
76546
  if (error) {
76535
76547
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
@@ -76665,6 +76677,95 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76665
76677
  ] });
76666
76678
  };
76667
76679
 
76680
+ const toDate = (input) => {
76681
+ const d = input instanceof Date ? input : new Date(input);
76682
+ return Number.isFinite(d.getTime()) ? d : null;
76683
+ };
76684
+ const formatRelative = (date, { locale, timeZone, relative }) => {
76685
+ const nowDate = relative?.now ? toDate(relative.now) ?? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date();
76686
+ const diffMs = date.getTime() - nowDate.getTime();
76687
+ const absMs = Math.abs(diffMs);
76688
+ const divisions = [
76689
+ ["year", 1e3 * 60 * 60 * 24 * 365],
76690
+ ["month", 1e3 * 60 * 60 * 24 * 30],
76691
+ ["week", 1e3 * 60 * 60 * 24 * 7],
76692
+ ["day", 1e3 * 60 * 60 * 24],
76693
+ ["hour", 1e3 * 60 * 60],
76694
+ ["minute", 1e3 * 60],
76695
+ ["second", 1e3]
76696
+ ];
76697
+ const forcedUnit = relative?.unit;
76698
+ const [unit, unitMs] = forcedUnit ? divisions.find((d) => d[0] === forcedUnit) ?? ["second", 1e3] : divisions.find(([, ms]) => absMs >= ms) ?? ["second", 1e3];
76699
+ const value = Math.round(diffMs / unitMs);
76700
+ const rtf = new Intl.RelativeTimeFormat(locale, { numeric: relative?.numeric ?? "auto" });
76701
+ return rtf.format(value, unit);
76702
+ };
76703
+ const presetIntlOptions = (style, opts) => {
76704
+ const { hour12 = false, seconds, timeZoneName } = opts;
76705
+ switch (style) {
76706
+ case "date":
76707
+ return { year: "numeric", month: "long", day: "numeric" };
76708
+ case "time":
76709
+ return {
76710
+ hour: "2-digit",
76711
+ minute: "2-digit",
76712
+ ...seconds ? { second: "2-digit" } : {},
76713
+ hour12
76714
+ };
76715
+ case "datetime":
76716
+ return {
76717
+ year: "numeric",
76718
+ month: "long",
76719
+ day: "numeric",
76720
+ hour: "2-digit",
76721
+ minute: "2-digit",
76722
+ ...seconds ? { second: "2-digit" } : {},
76723
+ hour12
76724
+ };
76725
+ case "timestamp":
76726
+ return {
76727
+ year: "numeric",
76728
+ month: "2-digit",
76729
+ day: "2-digit",
76730
+ hour: "2-digit",
76731
+ minute: "2-digit",
76732
+ second: "2-digit",
76733
+ hour12
76734
+ };
76735
+ case "full":
76736
+ return {
76737
+ year: "numeric",
76738
+ month: "long",
76739
+ day: "numeric",
76740
+ hour: "2-digit",
76741
+ minute: "2-digit",
76742
+ second: "2-digit",
76743
+ hour12,
76744
+ timeZoneName: timeZoneName ?? "short"
76745
+ };
76746
+ case "custom":
76747
+ return opts.intl ?? {};
76748
+ default:
76749
+ return {};
76750
+ }
76751
+ };
76752
+ const formatDateAuto = (input, options = {}) => {
76753
+ const date = toDate(input);
76754
+ if (!date) return "Invalid date";
76755
+ const style = options.style ?? "datetime";
76756
+ if (style === "iso") {
76757
+ return date.toISOString();
76758
+ }
76759
+ if (style === "relative") {
76760
+ return formatRelative(date, options);
76761
+ }
76762
+ const intlOpts = presetIntlOptions(style, options);
76763
+ return date.toLocaleString(options.locale, {
76764
+ ...intlOpts,
76765
+ ...options.timeZone ? { timeZone: options.timeZone } : {}
76766
+ });
76767
+ };
76768
+
76668
76769
  const createValueFormatter = ({
76669
76770
  formatter,
76670
76771
  unit
@@ -76694,6 +76795,30 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76694
76795
  }
76695
76796
  return void 0;
76696
76797
  };
76798
+ const createDateFormatter = (options) => {
76799
+ if (!options) {
76800
+ return void 0;
76801
+ }
76802
+ return (value) => {
76803
+ if (value == null) {
76804
+ return "";
76805
+ }
76806
+ let input = null;
76807
+ if (value instanceof Date) {
76808
+ input = value;
76809
+ } else if (typeof value === "number") {
76810
+ input = value;
76811
+ } else if (typeof value === "string") {
76812
+ const num = Number(value);
76813
+ input = Number.isFinite(num) ? num : value;
76814
+ }
76815
+ if (input == null) {
76816
+ return "";
76817
+ }
76818
+ const formatted = formatDateAuto(input, options);
76819
+ return formatted === "Invalid date" ? "" : formatted;
76820
+ };
76821
+ };
76697
76822
 
76698
76823
  const COMPONENTS = {
76699
76824
  MatrixToAreaMulti,
@@ -76730,6 +76855,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76730
76855
  topN,
76731
76856
  formatter,
76732
76857
  unit,
76858
+ dateFormatter,
76733
76859
  ...props
76734
76860
  } = data;
76735
76861
  const partsOfUrl = usePartsOfUrl();
@@ -76744,7 +76870,8 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
76744
76870
  ])
76745
76871
  );
76746
76872
  const formatValue = createValueFormatter({ formatter, unit });
76747
- const preparedProps = { width, height, refetchInterval, min, max, topN, formatValue, ...parsedProps };
76873
+ const formatTimestamp = createDateFormatter(dateFormatter);
76874
+ const preparedProps = { width, height, refetchInterval, min, max, topN, formatValue, formatTimestamp, ...parsedProps };
76748
76875
  if (isMultiqueryLoading) {
76749
76876
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
76750
76877
  }
@@ -85670,6 +85797,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
85670
85797
  exports.floorToDecimal = floorToDecimal;
85671
85798
  exports.formatBytesAuto = formatBytesAuto;
85672
85799
  exports.formatCoresAuto = formatCoresAuto;
85800
+ exports.formatDateAuto = formatDateAuto;
85673
85801
  exports.getAllPathsFromObj = getAllPathsFromObj;
85674
85802
  exports.getApiResourceSingle = getApiResourceSingle;
85675
85803
  exports.getApiResourceTypes = getApiResourceTypes;