@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.4 → 1.1.0-alpha.6
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 +86 -40
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +86 -40
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/components/organisms/DynamicComponents/types.d.ts +7 -1
- package/dist/types/hooks/useApiResource.d.ts +1 -0
- package/dist/types/hooks/useBuiltinResource.d.ts +1 -0
- package/dist/types/hooks/useCrdResource.d.ts +1 -0
- package/dist/types/hooks/useListThenWatch/types.d.ts +6 -1
- package/dist/types/localTypes/k8s.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8357,9 +8357,9 @@ const useK8sVerbs = ({
|
|
|
8357
8357
|
}).toString()}`;
|
|
8358
8358
|
const { data, isError, isLoading, error } = useDirectUnknownResource({
|
|
8359
8359
|
uri,
|
|
8360
|
-
queryKey: ["k8s-verbs", group || "", version, plural],
|
|
8360
|
+
queryKey: ["k8s-verbs", cluster, group || "", version, plural],
|
|
8361
8361
|
refetchInterval: false,
|
|
8362
|
-
isEnabled
|
|
8362
|
+
isEnabled: Boolean(isEnabled && cluster && version && plural)
|
|
8363
8363
|
});
|
|
8364
8364
|
const verbs = data?.verbs || [];
|
|
8365
8365
|
const canList = verbs.includes("list");
|
|
@@ -8373,11 +8373,7 @@ const useK8sVerbs = ({
|
|
|
8373
8373
|
};
|
|
8374
8374
|
};
|
|
8375
8375
|
|
|
8376
|
-
const eventKey$1 = (e) => {
|
|
8377
|
-
const n = e.metadata?.name ?? "";
|
|
8378
|
-
const ns = e.metadata?.namespace ?? "";
|
|
8379
|
-
return `${ns}/${n}`;
|
|
8380
|
-
};
|
|
8376
|
+
const eventKey$1 = (e) => e.metadata?.uid ?? `${e.metadata?.namespace ?? ""}/${e.metadata?.name ?? ""}`;
|
|
8381
8377
|
const compareRV$1 = (a, b) => {
|
|
8382
8378
|
if (a.length !== b.length) return a.length > b.length ? 1 : -1;
|
|
8383
8379
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
@@ -8632,19 +8628,6 @@ const useListWatch = ({
|
|
|
8632
8628
|
wsRef.current = null;
|
|
8633
8629
|
connect();
|
|
8634
8630
|
}, [closeWS, connect, setStatusSafe]);
|
|
8635
|
-
useEffect(() => {
|
|
8636
|
-
if (!mountedRef.current) return;
|
|
8637
|
-
if (isEnabled) {
|
|
8638
|
-
connect();
|
|
8639
|
-
} else {
|
|
8640
|
-
if (reconnectTimerRef.current) {
|
|
8641
|
-
window.clearTimeout(reconnectTimerRef.current);
|
|
8642
|
-
reconnectTimerRef.current = null;
|
|
8643
|
-
}
|
|
8644
|
-
closeWS();
|
|
8645
|
-
setStatusSafe("closed");
|
|
8646
|
-
}
|
|
8647
|
-
}, [isEnabled, closeWS, connect, setStatusSafe]);
|
|
8648
8631
|
const setUrl = useCallback(
|
|
8649
8632
|
(next) => {
|
|
8650
8633
|
const changed = next !== urlRef.current;
|
|
@@ -8698,6 +8681,12 @@ const useListWatch = ({
|
|
|
8698
8681
|
return;
|
|
8699
8682
|
}
|
|
8700
8683
|
if (!frame) return;
|
|
8684
|
+
if (frame.type === "SERVER_LOG") {
|
|
8685
|
+
const level = frame.level || "info";
|
|
8686
|
+
const msg = frame.message;
|
|
8687
|
+
(console[level] || console.log).call(console, "[useListWatch][server]", msg);
|
|
8688
|
+
return;
|
|
8689
|
+
}
|
|
8701
8690
|
if (frame.type === "INITIAL") {
|
|
8702
8691
|
dispatch({ type: "RESET", items: frame.items });
|
|
8703
8692
|
setContToken(frame.continue);
|
|
@@ -8768,6 +8757,19 @@ const useListWatch = ({
|
|
|
8768
8757
|
useEffect(() => {
|
|
8769
8758
|
if (wsUrl !== urlRef.current) setUrl(wsUrl);
|
|
8770
8759
|
}, [wsUrl, setUrl]);
|
|
8760
|
+
useEffect(() => {
|
|
8761
|
+
if (!mountedRef.current) return;
|
|
8762
|
+
if (isEnabled) {
|
|
8763
|
+
connect();
|
|
8764
|
+
} else {
|
|
8765
|
+
if (reconnectTimerRef.current) {
|
|
8766
|
+
window.clearTimeout(reconnectTimerRef.current);
|
|
8767
|
+
reconnectTimerRef.current = null;
|
|
8768
|
+
}
|
|
8769
|
+
closeWS();
|
|
8770
|
+
setStatusSafe("closed");
|
|
8771
|
+
}
|
|
8772
|
+
}, [isEnabled, closeWS, connect, setStatusSafe]);
|
|
8771
8773
|
useEffect(() => {
|
|
8772
8774
|
if (resIdRef.current !== resId) {
|
|
8773
8775
|
clearErrorSafe();
|
|
@@ -8917,7 +8919,7 @@ const useK8sSmartResource = ({
|
|
|
8917
8919
|
group,
|
|
8918
8920
|
version,
|
|
8919
8921
|
plural,
|
|
8920
|
-
isEnabled
|
|
8922
|
+
isEnabled: Boolean(isEnabled && cluster && cluster.length > 0)
|
|
8921
8923
|
});
|
|
8922
8924
|
const listUri = buildListUri({
|
|
8923
8925
|
cluster,
|
|
@@ -8929,7 +8931,9 @@ const useK8sSmartResource = ({
|
|
|
8929
8931
|
labelSelector,
|
|
8930
8932
|
limit
|
|
8931
8933
|
});
|
|
8932
|
-
const restEnabled = Boolean(
|
|
8934
|
+
const restEnabled = Boolean(
|
|
8935
|
+
cluster && cluster.length > 0 && isEnabled && canList && !canWatch && !verbsLoading && !verbsIsError
|
|
8936
|
+
);
|
|
8933
8937
|
const {
|
|
8934
8938
|
data: restData,
|
|
8935
8939
|
isLoading: restLoading,
|
|
@@ -8950,7 +8954,9 @@ const useK8sSmartResource = ({
|
|
|
8950
8954
|
refetchInterval: listRefetchInterval,
|
|
8951
8955
|
isEnabled: restEnabled
|
|
8952
8956
|
});
|
|
8953
|
-
const watchEnabled = Boolean(
|
|
8957
|
+
const watchEnabled = Boolean(
|
|
8958
|
+
cluster && cluster.length > 0 && isEnabled && canList && canWatch && !verbsLoading && !verbsIsError
|
|
8959
|
+
);
|
|
8954
8960
|
const { state, status, lastError } = useListWatch({
|
|
8955
8961
|
wsUrl: `/api/clusters/${cluster}/openapi-bff-ws/listThenWatch/listWatchWs`,
|
|
8956
8962
|
paused: false,
|
|
@@ -34275,6 +34281,7 @@ const EnrichedTable$1 = ({
|
|
|
34275
34281
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34276
34282
|
id,
|
|
34277
34283
|
fetchUrl,
|
|
34284
|
+
k8sResourceToFetch,
|
|
34278
34285
|
pathToItems,
|
|
34279
34286
|
clusterNamePartOfUrl,
|
|
34280
34287
|
labelSelector,
|
|
@@ -34318,7 +34325,13 @@ const EnrichedTable$1 = ({
|
|
|
34318
34325
|
verb: "create",
|
|
34319
34326
|
refetchInterval: false
|
|
34320
34327
|
});
|
|
34321
|
-
const fetchUrlPrepared = parseAll({ text: fetchUrl, replaceValues, multiQueryData });
|
|
34328
|
+
const fetchUrlPrepared = fetchUrl ? parseAll({ text: fetchUrl, replaceValues, multiQueryData }) : void 0;
|
|
34329
|
+
const k8sResourceToFetchPrepared = k8sResourceToFetch ? {
|
|
34330
|
+
group: k8sResourceToFetch.group ? parseAll({ text: k8sResourceToFetch.group, replaceValues, multiQueryData }) : void 0,
|
|
34331
|
+
version: parseAll({ text: k8sResourceToFetch.version, replaceValues, multiQueryData }),
|
|
34332
|
+
plural: parseAll({ text: k8sResourceToFetch.plural, replaceValues, multiQueryData }),
|
|
34333
|
+
namespace: k8sResourceToFetch.namespace ? parseAll({ text: k8sResourceToFetch.namespace, replaceValues, multiQueryData }) : void 0
|
|
34334
|
+
} : void 0;
|
|
34322
34335
|
const sParams = new URLSearchParams();
|
|
34323
34336
|
if (labelSelector && Object.keys(labelSelector).length > 0) {
|
|
34324
34337
|
const parsedObject = Object.fromEntries(
|
|
@@ -34355,21 +34368,48 @@ const EnrichedTable$1 = ({
|
|
|
34355
34368
|
} = useDirectUnknownResource({
|
|
34356
34369
|
uri: `${fetchUrlPrepared}${searchParams ? `?${searchParams}` : ""}`,
|
|
34357
34370
|
queryKey: [`${fetchUrlPrepared}${searchParams ? `?${searchParams}` : ""}`],
|
|
34358
|
-
isEnabled: !isMultiqueryLoading
|
|
34371
|
+
isEnabled: Boolean(!isMultiqueryLoading && fetchUrlPrepared)
|
|
34359
34372
|
});
|
|
34360
|
-
|
|
34373
|
+
const {
|
|
34374
|
+
data: fetchedDataSocket,
|
|
34375
|
+
isLoading: isFetchedDataSocketLoading,
|
|
34376
|
+
error: fetchedDataSocketError
|
|
34377
|
+
} = useK8sSmartResource({
|
|
34378
|
+
cluster: clusterName || "",
|
|
34379
|
+
namespace: k8sResourceToFetchPrepared?.namespace,
|
|
34380
|
+
group: k8sResourceToFetchPrepared?.group,
|
|
34381
|
+
version: k8sResourceToFetchPrepared?.version || "",
|
|
34382
|
+
plural: k8sResourceToFetchPrepared?.plural || "",
|
|
34383
|
+
fieldSelector: sParams.get("fieldSelector") || void 0,
|
|
34384
|
+
labelSelector: sParams.get("labelSelector") || void 0,
|
|
34385
|
+
isEnabled: Boolean(!isMultiqueryLoading && k8sResourceToFetchPrepared)
|
|
34386
|
+
});
|
|
34387
|
+
if (fetchUrlPrepared && isMultiqueryLoading) {
|
|
34388
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
34389
|
+
}
|
|
34390
|
+
if (k8sResourceToFetchPrepared && isMultiqueryLoading) {
|
|
34361
34391
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
34362
34392
|
}
|
|
34363
|
-
if (isFetchedDataLoading) {
|
|
34393
|
+
if (fetchUrlPrepared && isFetchedDataLoading) {
|
|
34394
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {}) });
|
|
34395
|
+
}
|
|
34396
|
+
if (k8sResourceToFetchPrepared && isFetchedDataSocketLoading) {
|
|
34364
34397
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {}) });
|
|
34365
34398
|
}
|
|
34366
|
-
if (fetchedDataError) {
|
|
34399
|
+
if (fetchUrlPrepared && fetchedDataError) {
|
|
34400
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
34401
|
+
"Error: ",
|
|
34402
|
+
JSON.stringify(fetchedDataError)
|
|
34403
|
+
] });
|
|
34404
|
+
}
|
|
34405
|
+
if (k8sResourceToFetchPrepared && fetchedDataSocketError) {
|
|
34367
34406
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
34368
34407
|
"Error: ",
|
|
34369
34408
|
JSON.stringify(fetchedDataError)
|
|
34370
34409
|
] });
|
|
34371
34410
|
}
|
|
34372
|
-
const
|
|
34411
|
+
const dataFromOneOfHooks = fetchedData || fetchedDataSocket?.items;
|
|
34412
|
+
const items = Array.isArray(pathToItems) ? _$1.get(dataFromOneOfHooks, pathToItems) : jp.query(dataFromOneOfHooks, `$${pathToItems}`)[0];
|
|
34373
34413
|
if (!items) {
|
|
34374
34414
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
34375
34415
|
"No data on this path ",
|
|
@@ -34504,15 +34544,18 @@ const PodTerminal$1 = ({
|
|
|
34504
34544
|
const namespacePrepared = parseAll({ text: namespace, replaceValues, multiQueryData });
|
|
34505
34545
|
const podNamePrepared = parseAll({ text: podName, replaceValues, multiQueryData });
|
|
34506
34546
|
const {
|
|
34507
|
-
data:
|
|
34547
|
+
data: podInfoList,
|
|
34508
34548
|
isError: isPodInfoError,
|
|
34509
34549
|
isLoading: isLoadingPodInfo
|
|
34510
|
-
} =
|
|
34511
|
-
|
|
34512
|
-
|
|
34513
|
-
|
|
34550
|
+
} = useK8sSmartResource({
|
|
34551
|
+
cluster: clusterPrepared,
|
|
34552
|
+
namespace: namespacePrepared,
|
|
34553
|
+
version: "v1",
|
|
34554
|
+
plural: "pods",
|
|
34555
|
+
fieldSelector: `metadata.name=${podNamePrepared}`,
|
|
34514
34556
|
isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
|
|
34515
34557
|
});
|
|
34558
|
+
const podInfo = podInfoList?.items && podInfoList.items.length > 0 ? podInfoList.items[0] : void 0;
|
|
34516
34559
|
if (isMultiqueryLoading) {
|
|
34517
34560
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
34518
34561
|
}
|
|
@@ -34620,15 +34663,18 @@ const PodLogs$1 = ({
|
|
|
34620
34663
|
const namespacePrepared = parseAll({ text: namespace, replaceValues, multiQueryData });
|
|
34621
34664
|
const podNamePrepared = parseAll({ text: podName, replaceValues, multiQueryData });
|
|
34622
34665
|
const {
|
|
34623
|
-
data:
|
|
34666
|
+
data: podInfoList,
|
|
34624
34667
|
isError: isPodInfoError,
|
|
34625
34668
|
isLoading: isLoadingPodInfo
|
|
34626
|
-
} =
|
|
34627
|
-
|
|
34628
|
-
|
|
34629
|
-
|
|
34669
|
+
} = useK8sSmartResource({
|
|
34670
|
+
cluster: clusterPrepared,
|
|
34671
|
+
namespace: namespacePrepared,
|
|
34672
|
+
version: "v1",
|
|
34673
|
+
plural: "pods",
|
|
34674
|
+
fieldSelector: `metadata.name=${podNamePrepared}`,
|
|
34630
34675
|
isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
|
|
34631
34676
|
});
|
|
34677
|
+
const podInfo = podInfoList?.items && podInfoList.items.length > 0 ? podInfoList.items[0] : void 0;
|
|
34632
34678
|
if (isMultiqueryLoading) {
|
|
34633
34679
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
34634
34680
|
}
|
|
@@ -50960,7 +51006,7 @@ const ProjectInfoCard = ({
|
|
|
50960
51006
|
fieldSelector: `metadata.name=${namespace}`,
|
|
50961
51007
|
isEnabled: Boolean(clusterName !== void 0)
|
|
50962
51008
|
});
|
|
50963
|
-
const project = projectArr && projectArr.length > 0 ? projectArr[0] : void 0;
|
|
51009
|
+
const project = projectArr && projectArr.items && projectArr.items.length > 0 ? projectArr.items[0] : void 0;
|
|
50964
51010
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
|
50965
51011
|
const updatePermission = usePermissions({
|
|
50966
51012
|
group: baseProjectApiGroup,
|