@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.16 → 1.1.0-alpha.18
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/dist/openapi-k8s-toolkit.es.js +174 -103
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +174 -103
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/hooks/useK8sSmartResource/index.d.ts +2 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResource.d.ts +28 -0
- package/dist/types/hooks/{useK8sSmartResource.d.ts → useK8sSmartResource/useK8sSmartResourceWithoutKinds.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -8612,6 +8612,63 @@ const ManageableBreadcrumbs = ({ data }) => {
|
|
|
8612
8612
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$w.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleBreadcrumb, { items: data.breadcrumbItems }) });
|
|
8613
8613
|
};
|
|
8614
8614
|
|
|
8615
|
+
const getKinds = async ({ cluster }) => {
|
|
8616
|
+
const result = await axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
|
|
8617
|
+
return result.data;
|
|
8618
|
+
};
|
|
8619
|
+
|
|
8620
|
+
const kindByGvr = (entries) => (gvr) => {
|
|
8621
|
+
const [group = "", v = "", resource = ""] = gvr.split("~", 3);
|
|
8622
|
+
const norm = (s) => s.trim();
|
|
8623
|
+
const kinds = entries.filter((e) => norm(e.group) === norm(group) && e.version.version === v && e.version.resource === resource).map((e) => e.kind);
|
|
8624
|
+
const uniq = Array.from(new Set(kinds));
|
|
8625
|
+
return uniq.length === 1 ? uniq[0] : void 0;
|
|
8626
|
+
};
|
|
8627
|
+
|
|
8628
|
+
const parseK8sVersion$1 = (raw) => {
|
|
8629
|
+
const m = /^v(?<major>\d+)(?:(?<stage>alpha|beta)(?<stageNum>\d+)?)?$/i.exec(raw ?? "");
|
|
8630
|
+
if (!m?.groups) return { rank: 0, major: -1, stageNum: -1 };
|
|
8631
|
+
const stage = (m.groups.stage ?? "").toLowerCase();
|
|
8632
|
+
const major = Number(m.groups.major);
|
|
8633
|
+
const stageNum = m.groups.stageNum ? Number(m.groups.stageNum) : 0;
|
|
8634
|
+
const rank = stage === "" ? 3 : stage === "beta" ? 2 : 1;
|
|
8635
|
+
return { rank, major, stageNum };
|
|
8636
|
+
};
|
|
8637
|
+
const versionToken$1 = (e) => e.version || (e.groupVersion?.split("/").pop() ?? "");
|
|
8638
|
+
const compareK8sVersionDesc$1 = (a, b) => {
|
|
8639
|
+
const pa = parseK8sVersion$1(versionToken$1(a));
|
|
8640
|
+
const pb = parseK8sVersion$1(versionToken$1(b));
|
|
8641
|
+
return pb.rank - pa.rank || pb.major - pa.major || pb.stageNum - pa.stageNum;
|
|
8642
|
+
};
|
|
8643
|
+
const orderVersions = (versions) => {
|
|
8644
|
+
const preferredIdx = versions.findIndex((v) => v.preferred === true);
|
|
8645
|
+
if (preferredIdx >= 0) {
|
|
8646
|
+
const preferred = versions[preferredIdx];
|
|
8647
|
+
const rest = versions.filter((_, i) => i !== preferredIdx).slice().sort(compareK8sVersionDesc$1);
|
|
8648
|
+
return [preferred, ...rest];
|
|
8649
|
+
}
|
|
8650
|
+
return versions.slice().sort(compareK8sVersionDesc$1);
|
|
8651
|
+
};
|
|
8652
|
+
const getSortedKindsAll = (index) => {
|
|
8653
|
+
const counts = index.items.reduce(
|
|
8654
|
+
(acc, item) => ({ ...acc, [item.kind]: (acc[item.kind] ?? 0) + 1 }),
|
|
8655
|
+
{}
|
|
8656
|
+
);
|
|
8657
|
+
const rows = index.items.flatMap((item) => {
|
|
8658
|
+
const ordered = orderVersions(item.versions);
|
|
8659
|
+
return ordered.map((v) => ({
|
|
8660
|
+
group: item.group,
|
|
8661
|
+
kind: item.kind,
|
|
8662
|
+
// clone to drop Readonly<> without changing fields (incl. preferred)
|
|
8663
|
+
version: { ...v },
|
|
8664
|
+
...counts[item.kind] > 1 ? { notUnique: true } : {}
|
|
8665
|
+
}));
|
|
8666
|
+
});
|
|
8667
|
+
return rows.sort(
|
|
8668
|
+
(a, b) => a.kind.localeCompare(b.kind, void 0, { sensitivity: "base" }) || a.group.localeCompare(b.group, void 0, { sensitivity: "base" })
|
|
8669
|
+
);
|
|
8670
|
+
};
|
|
8671
|
+
|
|
8615
8672
|
const getDirectUnknownResource = async ({ uri }) => {
|
|
8616
8673
|
return axios.get(uri);
|
|
8617
8674
|
};
|
|
@@ -9202,7 +9259,7 @@ const buildListUri = ({
|
|
|
9202
9259
|
if (limit) params.append("limit", String(limit));
|
|
9203
9260
|
return params.toString() ? `${base}?${params.toString()}` : base;
|
|
9204
9261
|
};
|
|
9205
|
-
const
|
|
9262
|
+
const useK8sSmartResourceWithoutKinds = ({
|
|
9206
9263
|
cluster,
|
|
9207
9264
|
apiGroup,
|
|
9208
9265
|
apiVersion,
|
|
@@ -9299,6 +9356,82 @@ const useK8sSmartResource = ({
|
|
|
9299
9356
|
return { data, isLoading, isError, error, _meta: { used } };
|
|
9300
9357
|
};
|
|
9301
9358
|
|
|
9359
|
+
const hasItemsArray = (value) => {
|
|
9360
|
+
if (!value || typeof value !== "object") {
|
|
9361
|
+
return false;
|
|
9362
|
+
}
|
|
9363
|
+
if (!("items" in value)) {
|
|
9364
|
+
return false;
|
|
9365
|
+
}
|
|
9366
|
+
const { items } = value;
|
|
9367
|
+
return Array.isArray(items);
|
|
9368
|
+
};
|
|
9369
|
+
const useK8sSmartResource = (params) => {
|
|
9370
|
+
const { cluster, apiGroup, apiVersion, plural } = params;
|
|
9371
|
+
const base = useK8sSmartResourceWithoutKinds(params);
|
|
9372
|
+
const [kindsWithVersion, setKindsWithVersion] = useState(void 0);
|
|
9373
|
+
useEffect(() => {
|
|
9374
|
+
let cancelled = false;
|
|
9375
|
+
if (!cluster) {
|
|
9376
|
+
setKindsWithVersion(void 0);
|
|
9377
|
+
return void 0;
|
|
9378
|
+
}
|
|
9379
|
+
getKinds({ cluster }).then((data) => {
|
|
9380
|
+
if (cancelled) {
|
|
9381
|
+
return;
|
|
9382
|
+
}
|
|
9383
|
+
setKindsWithVersion(getSortedKindsAll(data));
|
|
9384
|
+
}).catch(() => {
|
|
9385
|
+
if (!cancelled) {
|
|
9386
|
+
setKindsWithVersion(void 0);
|
|
9387
|
+
}
|
|
9388
|
+
});
|
|
9389
|
+
return () => {
|
|
9390
|
+
cancelled = true;
|
|
9391
|
+
};
|
|
9392
|
+
}, [cluster]);
|
|
9393
|
+
const resolveKindByGvr = useMemo(
|
|
9394
|
+
() => kindsWithVersion ? kindByGvr(kindsWithVersion) : void 0,
|
|
9395
|
+
[kindsWithVersion]
|
|
9396
|
+
);
|
|
9397
|
+
const gvr = useMemo(
|
|
9398
|
+
() => `${(apiGroup ?? "").trim()}~${apiVersion.trim()}~${plural.trim()}`,
|
|
9399
|
+
[apiGroup, apiVersion, plural]
|
|
9400
|
+
);
|
|
9401
|
+
const fullApiVersion = useMemo(() => {
|
|
9402
|
+
const g = (apiGroup ?? "").trim();
|
|
9403
|
+
const v = apiVersion.trim();
|
|
9404
|
+
if (!g || g === "core") {
|
|
9405
|
+
return v;
|
|
9406
|
+
}
|
|
9407
|
+
return `${g}/${v}`;
|
|
9408
|
+
}, [apiGroup, apiVersion]);
|
|
9409
|
+
const dataWithKinds = useMemo(() => {
|
|
9410
|
+
if (!base.data) return void 0;
|
|
9411
|
+
if (!hasItemsArray(base.data)) {
|
|
9412
|
+
return base.data;
|
|
9413
|
+
}
|
|
9414
|
+
const resolvedKind = resolveKindByGvr?.(gvr);
|
|
9415
|
+
const shouldAddKind = Boolean(resolvedKind);
|
|
9416
|
+
const itemsWithKindAndApiVersion = base.data.items.map((item) => {
|
|
9417
|
+
const typedItem = item;
|
|
9418
|
+
return {
|
|
9419
|
+
...typedItem,
|
|
9420
|
+
kind: typedItem.kind ?? (shouldAddKind ? resolvedKind : void 0),
|
|
9421
|
+
apiVersion: typedItem.apiVersion ?? fullApiVersion
|
|
9422
|
+
};
|
|
9423
|
+
});
|
|
9424
|
+
return {
|
|
9425
|
+
...base.data,
|
|
9426
|
+
items: itemsWithKindAndApiVersion
|
|
9427
|
+
};
|
|
9428
|
+
}, [base.data, resolveKindByGvr, gvr, fullApiVersion]);
|
|
9429
|
+
return {
|
|
9430
|
+
...base,
|
|
9431
|
+
data: dataWithKinds
|
|
9432
|
+
};
|
|
9433
|
+
};
|
|
9434
|
+
|
|
9302
9435
|
const prepareTemplate = ({
|
|
9303
9436
|
template,
|
|
9304
9437
|
replaceValues
|
|
@@ -9400,7 +9533,7 @@ const ManageableBreadcrumbsProvider = ({
|
|
|
9400
9533
|
if (!result) {
|
|
9401
9534
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$v.HeightDiv, {});
|
|
9402
9535
|
}
|
|
9403
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableBreadcrumbs, { data: result });
|
|
9536
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableBreadcrumbs, { data: result }, JSON.stringify(idToCompare));
|
|
9404
9537
|
};
|
|
9405
9538
|
|
|
9406
9539
|
const CustomMenu = styled(Menu)`
|
|
@@ -33987,7 +34120,7 @@ const parseMutliqueryText = ({
|
|
|
33987
34120
|
const path = Array.from(rawPath.matchAll(/['"]([^'"]+)['"]/g)).map(
|
|
33988
34121
|
(m) => m[1]
|
|
33989
34122
|
);
|
|
33990
|
-
const value = _$1.get(multiQueryData[`req${reqIndex}`], path, fallback !== void 0 ? fallback : void 0);
|
|
34123
|
+
const value = _$1.get(multiQueryData[`req${reqIndex}`] || {}, path, fallback !== void 0 ? fallback : void 0);
|
|
33991
34124
|
if (value == null && !customFallback) {
|
|
33992
34125
|
return fallback ?? "Undefined with no fallback";
|
|
33993
34126
|
}
|
|
@@ -34020,7 +34153,7 @@ const parseJsonPathTemplate = ({
|
|
|
34020
34153
|
if (jsonRoot === void 0 && customFallback) {
|
|
34021
34154
|
return customFallback;
|
|
34022
34155
|
}
|
|
34023
|
-
const results = jp.query(jsonRoot, `$${jsonPathExpr}`);
|
|
34156
|
+
const results = jp.query(jsonRoot || {}, `$${jsonPathExpr}`);
|
|
34024
34157
|
if (results.length === 0 || results[0] == null || results[0] === void 0) {
|
|
34025
34158
|
if (customFallback) {
|
|
34026
34159
|
return customFallback;
|
|
@@ -34572,7 +34705,7 @@ const EnrichedTable$1 = ({
|
|
|
34572
34705
|
}
|
|
34573
34706
|
if (labelSelectorFull) {
|
|
34574
34707
|
const root = multiQueryData[`req${labelSelectorFull.reqIndex}`];
|
|
34575
|
-
const value = Array.isArray(labelSelectorFull.pathToLabels) ? _$1.get(root, labelSelectorFull.pathToLabels) : jp.query(root, `$${labelSelectorFull.pathToLabels}`)[0];
|
|
34708
|
+
const value = Array.isArray(labelSelectorFull.pathToLabels) ? _$1.get(root || {}, labelSelectorFull.pathToLabels) : jp.query(root || {}, `$${labelSelectorFull.pathToLabels}`)[0];
|
|
34576
34709
|
const serializedLabels = serializeLabelsWithNoEncoding$1(value);
|
|
34577
34710
|
if (serializedLabels.length > 0) sParams.set("labelSelector", serializedLabels);
|
|
34578
34711
|
}
|
|
@@ -34636,14 +34769,9 @@ const EnrichedTable$1 = ({
|
|
|
34636
34769
|
JSON.stringify(fetchedDataError)
|
|
34637
34770
|
] });
|
|
34638
34771
|
}
|
|
34639
|
-
const dataFromOneOfHooks = fetchedData || fetchedDataSocket;
|
|
34640
|
-
const items = Array.isArray(pathToItems) ? _$1.get(dataFromOneOfHooks, pathToItems) : jp.query(dataFromOneOfHooks, `$${pathToItems}`)[0];
|
|
34641
|
-
|
|
34642
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
34643
|
-
"No data on this path ",
|
|
34644
|
-
JSON.stringify(pathToItems)
|
|
34645
|
-
] });
|
|
34646
|
-
}
|
|
34772
|
+
const dataFromOneOfHooks = fetchedData || fetchedDataSocket || {};
|
|
34773
|
+
const items = Array.isArray(pathToItems) ? _$1.get(dataFromOneOfHooks || {}, pathToItems) : jp.query(dataFromOneOfHooks || {}, `$${pathToItems}`)[0];
|
|
34774
|
+
const itemsAlwaysArr = Array.isArray(items) ? items : [];
|
|
34647
34775
|
const clearSelected = () => {
|
|
34648
34776
|
setSelectedRowKeys([]);
|
|
34649
34777
|
setSelectedRowsData([]);
|
|
@@ -34660,7 +34788,7 @@ const EnrichedTable$1 = ({
|
|
|
34660
34788
|
cluster: clusterPrepared,
|
|
34661
34789
|
namespace: namespacePrepared,
|
|
34662
34790
|
theme,
|
|
34663
|
-
dataItems:
|
|
34791
|
+
dataItems: itemsAlwaysArr,
|
|
34664
34792
|
tableProps: {
|
|
34665
34793
|
borderless: true,
|
|
34666
34794
|
paginationPosition: ["bottomRight"],
|
|
@@ -34942,7 +35070,7 @@ const getDataByPath = ({
|
|
|
34942
35070
|
prefillValuesRaw,
|
|
34943
35071
|
pathToData
|
|
34944
35072
|
}) => {
|
|
34945
|
-
return Array.isArray(pathToData) ? _$1.get(prefillValuesRaw, pathToData) : jp.query(prefillValuesRaw, `$${pathToData}`)[0];
|
|
35073
|
+
return Array.isArray(pathToData) ? _$1.get(prefillValuesRaw || {}, pathToData) : jp.query(prefillValuesRaw || {}, `$${pathToData}`)[0];
|
|
34946
35074
|
};
|
|
34947
35075
|
const getPrefillValuesWithForces = ({
|
|
34948
35076
|
prefillValues,
|
|
@@ -35130,7 +35258,7 @@ const ArrayOfObjectsToKeyValues = ({ data, children }) => {
|
|
|
35130
35258
|
if (jsonRoot === void 0) {
|
|
35131
35259
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
35132
35260
|
}
|
|
35133
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
|
|
35261
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToArray}`);
|
|
35134
35262
|
const { data: arrayOfObjects, error: errorArrayOfObjects } = parseArrayOfAny$2(anythingForNow);
|
|
35135
35263
|
if (!arrayOfObjects) {
|
|
35136
35264
|
if (errorArrayOfObjects) {
|
|
@@ -35202,7 +35330,7 @@ const ItemCounter = ({
|
|
|
35202
35330
|
console.log(`Item Counter: ${id}: No root for json path`);
|
|
35203
35331
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style, children: errorText });
|
|
35204
35332
|
}
|
|
35205
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
|
|
35333
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToArray}`);
|
|
35206
35334
|
const { counter, error: errorArrayOfObjects } = getItemsInside$4(anythingForNow);
|
|
35207
35335
|
if (errorArrayOfObjects) {
|
|
35208
35336
|
console.log(`Item Counter: ${id}: ${errorArrayOfObjects}`);
|
|
@@ -35259,7 +35387,7 @@ const KeyCounter = ({
|
|
|
35259
35387
|
console.log(`Key Counter: ${id}: No root for json path`);
|
|
35260
35388
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style, children: errorText });
|
|
35261
35389
|
}
|
|
35262
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToObj}`);
|
|
35390
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToObj}`);
|
|
35263
35391
|
const { counter, error: errorArrayOfObjects } = getItemsInside$3(anythingForNow);
|
|
35264
35392
|
if (errorArrayOfObjects) {
|
|
35265
35393
|
console.log(`Key Counter: ${id}: ${errorArrayOfObjects}`);
|
|
@@ -35639,7 +35767,7 @@ const Labels = ({ data, children }) => {
|
|
|
35639
35767
|
if (jsonRoot === void 0) {
|
|
35640
35768
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
35641
35769
|
}
|
|
35642
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToLabels}`);
|
|
35770
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToLabels}`);
|
|
35643
35771
|
const { data: labelsRaw, error: errorArrayOfObjects } = parseArrayOfAny$1(anythingForNow);
|
|
35644
35772
|
const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
|
|
35645
35773
|
text: notificationSuccessMessage,
|
|
@@ -35914,7 +36042,7 @@ const LabelsToSearchParams = ({ data, children }) => {
|
|
|
35914
36042
|
if (jsonRoot === void 0) {
|
|
35915
36043
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
35916
36044
|
}
|
|
35917
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToLabels}`);
|
|
36045
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToLabels}`);
|
|
35918
36046
|
const { data: labelsRaw, error: errorArrayOfObjects } = parseArrayOfAny(anythingForNow);
|
|
35919
36047
|
const linkPrefixPrepared = parseAll({ text: linkPrefix, replaceValues, multiQueryData });
|
|
35920
36048
|
if (!labelsRaw) {
|
|
@@ -36184,7 +36312,7 @@ const Taints = ({ data, children }) => {
|
|
|
36184
36312
|
console.log(`Item Counter: ${id}: No root for json path`);
|
|
36185
36313
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style, children: errorText });
|
|
36186
36314
|
}
|
|
36187
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
|
|
36315
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToArray}`);
|
|
36188
36316
|
const { counter, taints, error: errorArrayOfObjects } = getItemsInside$2(anythingForNow);
|
|
36189
36317
|
const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
|
|
36190
36318
|
text: notificationSuccessMessage,
|
|
@@ -36562,7 +36690,7 @@ const Tolerations = ({
|
|
|
36562
36690
|
console.log(`Item Counter: ${id}: No root for json path`);
|
|
36563
36691
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: containerStyle, children: errorText });
|
|
36564
36692
|
}
|
|
36565
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
|
|
36693
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToArray}`);
|
|
36566
36694
|
const { counter, tolerations, error: errorArrayOfObjects } = getItemsInside$1(anythingForNow);
|
|
36567
36695
|
const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
|
|
36568
36696
|
text: notificationSuccessMessage,
|
|
@@ -36843,7 +36971,7 @@ const Annotations = ({
|
|
|
36843
36971
|
console.log(`Item Counter: ${id}: No root for json path`);
|
|
36844
36972
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: containerStyle, children: errorText });
|
|
36845
36973
|
}
|
|
36846
|
-
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToObj}`);
|
|
36974
|
+
const anythingForNow = jp.query(jsonRoot || {}, `$${jsonPathToObj}`);
|
|
36847
36975
|
const { counter, annotations, error: errorArrayOfObjects } = getItemsInside(anythingForNow);
|
|
36848
36976
|
const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
|
|
36849
36977
|
text: notificationSuccessMessage,
|
|
@@ -38056,7 +38184,7 @@ const Events$1 = ({
|
|
|
38056
38184
|
}
|
|
38057
38185
|
if (labelSelectorFull) {
|
|
38058
38186
|
const root = multiQueryData[`req${labelSelectorFull.reqIndex}`];
|
|
38059
|
-
const value = Array.isArray(labelSelectorFull.pathToLabels) ? _$1.get(root, labelSelectorFull.pathToLabels) : jp.query(root, `$${labelSelectorFull.pathToLabels}`)[0];
|
|
38187
|
+
const value = Array.isArray(labelSelectorFull.pathToLabels) ? _$1.get(root || {}, labelSelectorFull.pathToLabels) : jp.query(root || {}, `$${labelSelectorFull.pathToLabels}`)[0];
|
|
38060
38188
|
const serializedLabels = serializeLabelsWithNoEncoding(value);
|
|
38061
38189
|
if (serializedLabels.length > 0) params.set("labelSelector", serializedLabels);
|
|
38062
38190
|
}
|
|
@@ -38101,55 +38229,6 @@ const Events$1 = ({
|
|
|
38101
38229
|
] });
|
|
38102
38230
|
};
|
|
38103
38231
|
|
|
38104
|
-
const getKinds = async ({ cluster }) => {
|
|
38105
|
-
const result = await axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
|
|
38106
|
-
return result.data;
|
|
38107
|
-
};
|
|
38108
|
-
|
|
38109
|
-
const parseK8sVersion$1 = (raw) => {
|
|
38110
|
-
const m = /^v(?<major>\d+)(?:(?<stage>alpha|beta)(?<stageNum>\d+)?)?$/i.exec(raw ?? "");
|
|
38111
|
-
if (!m?.groups) return { rank: 0, major: -1, stageNum: -1 };
|
|
38112
|
-
const stage = (m.groups.stage ?? "").toLowerCase();
|
|
38113
|
-
const major = Number(m.groups.major);
|
|
38114
|
-
const stageNum = m.groups.stageNum ? Number(m.groups.stageNum) : 0;
|
|
38115
|
-
const rank = stage === "" ? 3 : stage === "beta" ? 2 : 1;
|
|
38116
|
-
return { rank, major, stageNum };
|
|
38117
|
-
};
|
|
38118
|
-
const versionToken$1 = (e) => e.version || (e.groupVersion?.split("/").pop() ?? "");
|
|
38119
|
-
const compareK8sVersionDesc$1 = (a, b) => {
|
|
38120
|
-
const pa = parseK8sVersion$1(versionToken$1(a));
|
|
38121
|
-
const pb = parseK8sVersion$1(versionToken$1(b));
|
|
38122
|
-
return pb.rank - pa.rank || pb.major - pa.major || pb.stageNum - pa.stageNum;
|
|
38123
|
-
};
|
|
38124
|
-
const orderVersions = (versions) => {
|
|
38125
|
-
const preferredIdx = versions.findIndex((v) => v.preferred === true);
|
|
38126
|
-
if (preferredIdx >= 0) {
|
|
38127
|
-
const preferred = versions[preferredIdx];
|
|
38128
|
-
const rest = versions.filter((_, i) => i !== preferredIdx).slice().sort(compareK8sVersionDesc$1);
|
|
38129
|
-
return [preferred, ...rest];
|
|
38130
|
-
}
|
|
38131
|
-
return versions.slice().sort(compareK8sVersionDesc$1);
|
|
38132
|
-
};
|
|
38133
|
-
const getSortedKindsAll = (index) => {
|
|
38134
|
-
const counts = index.items.reduce(
|
|
38135
|
-
(acc, item) => ({ ...acc, [item.kind]: (acc[item.kind] ?? 0) + 1 }),
|
|
38136
|
-
{}
|
|
38137
|
-
);
|
|
38138
|
-
const rows = index.items.flatMap((item) => {
|
|
38139
|
-
const ordered = orderVersions(item.versions);
|
|
38140
|
-
return ordered.map((v) => ({
|
|
38141
|
-
group: item.group,
|
|
38142
|
-
kind: item.kind,
|
|
38143
|
-
// clone to drop Readonly<> without changing fields (incl. preferred)
|
|
38144
|
-
version: { ...v },
|
|
38145
|
-
...counts[item.kind] > 1 ? { notUnique: true } : {}
|
|
38146
|
-
}));
|
|
38147
|
-
});
|
|
38148
|
-
return rows.sort(
|
|
38149
|
-
(a, b) => a.kind.localeCompare(b.kind, void 0, { sensitivity: "base" }) || a.group.localeCompare(b.group, void 0, { sensitivity: "base" })
|
|
38150
|
-
);
|
|
38151
|
-
};
|
|
38152
|
-
|
|
38153
38232
|
const parseApiVersion = (apiVersion) => {
|
|
38154
38233
|
const parts = apiVersion.trim().split("/");
|
|
38155
38234
|
return parts.length === 1 ? { group: "", version: parts[0] } : { group: parts[0], version: parts[1] };
|
|
@@ -38239,7 +38318,7 @@ const RefElement = ({
|
|
|
38239
38318
|
let forcedName;
|
|
38240
38319
|
let objectNamespace;
|
|
38241
38320
|
if (keysToForcedLabel && rawObjectToFindLabel) {
|
|
38242
|
-
forcedName = Array.isArray(keysToForcedLabel) ? _$1.get(rawObjectToFindLabel, keysToForcedLabel) : jp.query(rawObjectToFindLabel, `$${keysToForcedLabel}`)[0];
|
|
38321
|
+
forcedName = Array.isArray(keysToForcedLabel) ? _$1.get(rawObjectToFindLabel || {}, keysToForcedLabel) : jp.query(rawObjectToFindLabel || {}, `$${keysToForcedLabel}`)[0];
|
|
38243
38322
|
}
|
|
38244
38323
|
if (forcedRelatedValuePath && rawObjectToFindLabel) {
|
|
38245
38324
|
try {
|
|
@@ -38251,15 +38330,15 @@ const RefElement = ({
|
|
|
38251
38330
|
);
|
|
38252
38331
|
const relatedPath = forcedRelatedValuePath && ownerRefPathSegs ? resolveFormPath$1(forcedRelatedValuePath, ownerRefPathSegs) : void 0;
|
|
38253
38332
|
if (relatedPath) {
|
|
38254
|
-
forcedName = _$1.get(rawObjectToFindLabel, relatedPath);
|
|
38333
|
+
forcedName = _$1.get(rawObjectToFindLabel || {}, relatedPath);
|
|
38255
38334
|
}
|
|
38256
38335
|
} catch {
|
|
38257
38336
|
}
|
|
38258
38337
|
}
|
|
38259
38338
|
if (rawObjectToFindLabel) {
|
|
38260
38339
|
try {
|
|
38261
|
-
const defaultFetched = _$1.get(rawObjectToFindLabel, ["metadata", "namespace"]);
|
|
38262
|
-
const socketFetched = _$1.get(rawObjectToFindLabel, ["items", 0, "metadata", "namespace"]);
|
|
38340
|
+
const defaultFetched = _$1.get(rawObjectToFindLabel || {}, ["metadata", "namespace"]);
|
|
38341
|
+
const socketFetched = _$1.get(rawObjectToFindLabel || {}, ["items", 0, "metadata", "namespace"]);
|
|
38263
38342
|
objectNamespace = socketFetched || defaultFetched;
|
|
38264
38343
|
} catch {
|
|
38265
38344
|
}
|
|
@@ -38414,7 +38493,7 @@ const OwnerRefs = ({
|
|
|
38414
38493
|
if (jsonRoot === void 0) {
|
|
38415
38494
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: containerStyle, children: errorText });
|
|
38416
38495
|
}
|
|
38417
|
-
const refsArr = jp.query(jsonRoot, `$${jsonPathToArrayOfRefs}`).flat();
|
|
38496
|
+
const refsArr = jp.query(jsonRoot || {}, `$${jsonPathToArrayOfRefs}`).flat();
|
|
38418
38497
|
if (!Array.isArray(refsArr)) {
|
|
38419
38498
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: containerStyle, children: notArrayErrorText });
|
|
38420
38499
|
}
|
|
@@ -38499,7 +38578,7 @@ const Toggler = ({ data, children }) => {
|
|
|
38499
38578
|
if (jsonRoot === void 0) {
|
|
38500
38579
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
38501
38580
|
}
|
|
38502
|
-
const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
|
|
38581
|
+
const valueToCompare = jp.query(jsonRoot || {}, `$${jsonPathToValue}`)[0];
|
|
38503
38582
|
let valueToSwitch = false;
|
|
38504
38583
|
if (criteria.type === "forSuccess") {
|
|
38505
38584
|
if (criteria.operator === "exists") {
|
|
@@ -38652,7 +38731,7 @@ const TogglerSegmented = ({
|
|
|
38652
38731
|
if (jsonRoot === void 0) {
|
|
38653
38732
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
38654
38733
|
}
|
|
38655
|
-
const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
|
|
38734
|
+
const valueToCompare = jp.query(jsonRoot || {}, `$${jsonPathToValue}`)[0];
|
|
38656
38735
|
const valueToSegmented = valuesMap?.find((el) => el.value === valueToCompare)?.renderedValue;
|
|
38657
38736
|
const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
|
|
38658
38737
|
text: notificationSuccessMessage,
|
|
@@ -39194,16 +39273,16 @@ const EnrichedTable = ({
|
|
|
39194
39273
|
return {
|
|
39195
39274
|
onClick: () => {
|
|
39196
39275
|
if (pathToNavigate && recordKeysForNavigation) {
|
|
39197
|
-
const recordValueRaw = Array.isArray(recordKeysForNavigation) ? lodashExports.get(record, recordKeysForNavigation) : jp.query(record, `$${recordKeysForNavigation}`)[0];
|
|
39276
|
+
const recordValueRaw = Array.isArray(recordKeysForNavigation) ? lodashExports.get(record, recordKeysForNavigation) : jp.query(record || {}, `$${recordKeysForNavigation}`)[0];
|
|
39198
39277
|
let recordValueRawSecond = "";
|
|
39199
39278
|
if (recordKeysForNavigationSecond) {
|
|
39200
|
-
recordValueRawSecond = Array.isArray(recordKeysForNavigationSecond) ? lodashExports.get(record, recordKeysForNavigationSecond) : jp.query(record, `$${recordKeysForNavigationSecond}`)[0];
|
|
39279
|
+
recordValueRawSecond = Array.isArray(recordKeysForNavigationSecond) ? lodashExports.get(record, recordKeysForNavigationSecond) : jp.query(record || {}, `$${recordKeysForNavigationSecond}`)[0];
|
|
39201
39280
|
} else {
|
|
39202
39281
|
recordValueRawSecond = "no-second-record-keys";
|
|
39203
39282
|
}
|
|
39204
39283
|
let recordValueRawThird = "";
|
|
39205
39284
|
if (recordKeysForNavigationThird) {
|
|
39206
|
-
recordValueRawThird = Array.isArray(recordKeysForNavigationThird) ? lodashExports.get(record, recordKeysForNavigationThird) : jp.query(record, `$${recordKeysForNavigationThird}`)[0];
|
|
39285
|
+
recordValueRawThird = Array.isArray(recordKeysForNavigationThird) ? lodashExports.get(record, recordKeysForNavigationThird) : jp.query(record || {}, `$${recordKeysForNavigationThird}`)[0];
|
|
39207
39286
|
} else {
|
|
39208
39287
|
recordValueRawThird = "no-second-record-keys";
|
|
39209
39288
|
}
|
|
@@ -39308,7 +39387,7 @@ const prepare = ({
|
|
|
39308
39387
|
dataSource = dataSource.map((el) => {
|
|
39309
39388
|
const newFieldsForComplexJsonPath = {};
|
|
39310
39389
|
customFields.forEach(({ dataIndex, jsonPath }) => {
|
|
39311
|
-
const jpQueryResult = jp.query(el, `$${jsonPath}`);
|
|
39390
|
+
const jpQueryResult = jp.query(el || {}, `$${jsonPath}`);
|
|
39312
39391
|
newFieldsForComplexJsonPath[dataIndex] = Array.isArray(jpQueryResult) && jpQueryResult.length === 1 ? jpQueryResult[0] : jpQueryResult;
|
|
39313
39392
|
});
|
|
39314
39393
|
if (typeof el === "object") {
|
|
@@ -39327,7 +39406,7 @@ const prepare = ({
|
|
|
39327
39406
|
if (!el || typeof el !== "object" || Array.isArray(el)) {
|
|
39328
39407
|
return;
|
|
39329
39408
|
}
|
|
39330
|
-
const mapValue = jp.query(el, `$${flatMapColumn.jsonPath}`)[0];
|
|
39409
|
+
const mapValue = jp.query(el || {}, `$${flatMapColumn.jsonPath}`)[0];
|
|
39331
39410
|
if (mapValue && typeof mapValue === "object" && !Array.isArray(mapValue) && mapValue !== null) {
|
|
39332
39411
|
const mapEntries = Object.entries(mapValue);
|
|
39333
39412
|
if (mapEntries.length > 0) {
|
|
@@ -47735,14 +47814,14 @@ const normalizeValuesForQuotasToNumber = (object, properties) => {
|
|
|
47735
47814
|
const memoryPaths = findAllPathsForObject(properties, "type", "rangeInputMemory");
|
|
47736
47815
|
memoryPaths.forEach((path) => {
|
|
47737
47816
|
const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
|
|
47738
|
-
const value = _$1.get(newObject, cleanPath);
|
|
47817
|
+
const value = _$1.get(newObject || {}, cleanPath);
|
|
47739
47818
|
if (value || value === 0) {
|
|
47740
47819
|
_$1.set(newObject, cleanPath, parseQuotaValueMemoryAndStorage(value));
|
|
47741
47820
|
}
|
|
47742
47821
|
});
|
|
47743
47822
|
cpuPaths.forEach((path) => {
|
|
47744
47823
|
const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
|
|
47745
|
-
const value = _$1.get(newObject, cleanPath);
|
|
47824
|
+
const value = _$1.get(newObject || {}, cleanPath);
|
|
47746
47825
|
if (value || value === 0) {
|
|
47747
47826
|
_$1.set(newObject, cleanPath, parseQuotaValueCpu(value));
|
|
47748
47827
|
}
|
|
@@ -48024,9 +48103,9 @@ const FormListInput = ({
|
|
|
48024
48103
|
if (isErrorOptionsObj && (!customProps.relatedValuePath || customProps.relatedValuePath && !!relatedFieldValue)) {
|
|
48025
48104
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(HeightContainer, { $height: 64, children: "Error" });
|
|
48026
48105
|
}
|
|
48027
|
-
const items = !isErrorOptionsObj && !isLoadingOptionsObj && optionsObj ? _$1.get(optionsObj, ["items"]) : [];
|
|
48106
|
+
const items = !isErrorOptionsObj && !isLoadingOptionsObj && optionsObj ? _$1.get(optionsObj || {}, ["items"]) : [];
|
|
48028
48107
|
const filteredItems = customProps.criteria ? items.filter((item) => {
|
|
48029
|
-
const objValue = Array.isArray(customProps.criteria?.keysToValue) ? _$1.get(item, customProps.criteria?.keysToValue || []) : jp.query(item, `$${customProps.criteria?.keysToValue}`)[0];
|
|
48108
|
+
const objValue = Array.isArray(customProps.criteria?.keysToValue) ? _$1.get(item || {}, customProps.criteria?.keysToValue || []) : jp.query(item || {}, `$${customProps.criteria?.keysToValue}`)[0];
|
|
48030
48109
|
if (customProps.criteria?.type === "equals") {
|
|
48031
48110
|
return objValue === customProps.criteria?.value;
|
|
48032
48111
|
}
|
|
@@ -48034,18 +48113,18 @@ const FormListInput = ({
|
|
|
48034
48113
|
}) : items;
|
|
48035
48114
|
const itemForPrefilledValue = customProps.criteria?.keepPrefilled !== false ? items.find((item) => {
|
|
48036
48115
|
if (Array.isArray(customProps.keysToValue)) {
|
|
48037
|
-
return _$1.get(item, customProps.keysToValue) === fieldValue;
|
|
48116
|
+
return _$1.get(item || {}, customProps.keysToValue) === fieldValue;
|
|
48038
48117
|
}
|
|
48039
|
-
return jp.query(item, `$${customProps.keysToValue}`)[0] === fieldValue;
|
|
48118
|
+
return jp.query(item || {}, `$${customProps.keysToValue}`)[0] === fieldValue;
|
|
48040
48119
|
}) : void 0;
|
|
48041
48120
|
const filteredItemsAndPrefilledValue = itemForPrefilledValue ? [itemForPrefilledValue, ...filteredItems] : filteredItems;
|
|
48042
48121
|
const options = Array.isArray(filteredItemsAndPrefilledValue) ? filteredItemsAndPrefilledValue.map((item) => {
|
|
48043
|
-
const value = Array.isArray(customProps.keysToValue) ? _$1.get(item, customProps.keysToValue) : jp.query(item, `$${customProps.keysToValue}`)[0];
|
|
48122
|
+
const value = Array.isArray(customProps.keysToValue) ? _$1.get(item || {}, customProps.keysToValue) : jp.query(item || {}, `$${customProps.keysToValue}`)[0];
|
|
48044
48123
|
let label = "";
|
|
48045
48124
|
if (customProps.keysToLabel) {
|
|
48046
|
-
label = Array.isArray(customProps.keysToLabel) ? _$1.get(item, customProps.keysToLabel) : jp.query(item, `$${customProps.keysToLabel}`)[0];
|
|
48125
|
+
label = Array.isArray(customProps.keysToLabel) ? _$1.get(item || {}, customProps.keysToLabel) : jp.query(item || {}, `$${customProps.keysToLabel}`)[0];
|
|
48047
48126
|
} else {
|
|
48048
|
-
label = Array.isArray(customProps.keysToValue) ? _$1.get(item, customProps.keysToValue) : jp.query(item, `$${customProps.keysToValue}`)[0];
|
|
48127
|
+
label = Array.isArray(customProps.keysToValue) ? _$1.get(item || {}, customProps.keysToValue) : jp.query(item || {}, `$${customProps.keysToValue}`)[0];
|
|
48049
48128
|
}
|
|
48050
48129
|
return {
|
|
48051
48130
|
value,
|
|
@@ -48105,7 +48184,7 @@ const getValue = ({
|
|
|
48105
48184
|
keysToValue,
|
|
48106
48185
|
logic
|
|
48107
48186
|
}) => {
|
|
48108
|
-
const dirtyValue = Array.isArray(keysToValue) ? _$1.get(valueObj, keysToValue) : jp.query(valueObj, `$${keysToValue}`)[0];
|
|
48187
|
+
const dirtyValue = Array.isArray(keysToValue) ? _$1.get(valueObj || {}, keysToValue) : jp.query(valueObj || {}, `$${keysToValue}`)[0];
|
|
48109
48188
|
if (logic === "cpuLike") {
|
|
48110
48189
|
return parseQuotaValueCpu(dirtyValue);
|
|
48111
48190
|
}
|
|
@@ -52796,14 +52875,6 @@ const PodLogsMonaco = ({
|
|
|
52796
52875
|
] });
|
|
52797
52876
|
};
|
|
52798
52877
|
|
|
52799
|
-
const kindByGvr = (entries) => (gvr) => {
|
|
52800
|
-
const [group = "", v = "", resource = ""] = gvr.split("~", 3);
|
|
52801
|
-
const norm = (s) => s.trim();
|
|
52802
|
-
const kinds = entries.filter((e) => norm(e.group) === norm(group) && e.version.version === v && e.version.resource === resource).map((e) => e.kind);
|
|
52803
|
-
const uniq = Array.from(new Set(kinds));
|
|
52804
|
-
return uniq.length === 1 ? uniq[0] : void 0;
|
|
52805
|
-
};
|
|
52806
|
-
|
|
52807
52878
|
const SelectTag = styled(Tag)`
|
|
52808
52879
|
margin-inline-end: 4px;
|
|
52809
52880
|
padding: 4px 6px;
|