@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.4 → 1.1.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.
@@ -8372,11 +8372,7 @@
8372
8372
  };
8373
8373
  };
8374
8374
 
8375
- const eventKey$1 = (e) => {
8376
- const n = e.metadata?.name ?? "";
8377
- const ns = e.metadata?.namespace ?? "";
8378
- return `${ns}/${n}`;
8379
- };
8375
+ const eventKey$1 = (e) => e.metadata?.uid ?? `${e.metadata?.namespace ?? ""}/${e.metadata?.name ?? ""}`;
8380
8376
  const compareRV$1 = (a, b) => {
8381
8377
  if (a.length !== b.length) return a.length > b.length ? 1 : -1;
8382
8378
  return a > b ? 1 : a < b ? -1 : 0;
@@ -34274,6 +34270,7 @@
34274
34270
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
34275
34271
  id,
34276
34272
  fetchUrl,
34273
+ k8sResourceToFetch,
34277
34274
  pathToItems,
34278
34275
  clusterNamePartOfUrl,
34279
34276
  labelSelector,
@@ -34317,7 +34314,13 @@
34317
34314
  verb: "create",
34318
34315
  refetchInterval: false
34319
34316
  });
34320
- const fetchUrlPrepared = parseAll({ text: fetchUrl, replaceValues, multiQueryData });
34317
+ const fetchUrlPrepared = fetchUrl ? parseAll({ text: fetchUrl, replaceValues, multiQueryData }) : void 0;
34318
+ const k8sResourceToFetchPrepared = k8sResourceToFetch ? {
34319
+ group: k8sResourceToFetch.group ? parseAll({ text: k8sResourceToFetch.group, replaceValues, multiQueryData }) : void 0,
34320
+ version: parseAll({ text: k8sResourceToFetch.version, replaceValues, multiQueryData }),
34321
+ plural: parseAll({ text: k8sResourceToFetch.plural, replaceValues, multiQueryData }),
34322
+ namespace: k8sResourceToFetch.namespace ? parseAll({ text: k8sResourceToFetch.namespace, replaceValues, multiQueryData }) : void 0
34323
+ } : void 0;
34321
34324
  const sParams = new URLSearchParams();
34322
34325
  if (labelSelector && Object.keys(labelSelector).length > 0) {
34323
34326
  const parsedObject = Object.fromEntries(
@@ -34354,21 +34357,48 @@
34354
34357
  } = useDirectUnknownResource({
34355
34358
  uri: `${fetchUrlPrepared}${searchParams ? `?${searchParams}` : ""}`,
34356
34359
  queryKey: [`${fetchUrlPrepared}${searchParams ? `?${searchParams}` : ""}`],
34357
- isEnabled: !isMultiqueryLoading
34360
+ isEnabled: Boolean(!isMultiqueryLoading && fetchUrlPrepared)
34358
34361
  });
34359
- if (isMultiqueryLoading) {
34362
+ const {
34363
+ data: fetchedDataSocket,
34364
+ isLoading: isFetchedDataSocketLoading,
34365
+ error: fetchedDataSocketError
34366
+ } = useK8sSmartResource({
34367
+ cluster: clusterName || "",
34368
+ namespace: k8sResourceToFetchPrepared?.namespace,
34369
+ group: k8sResourceToFetchPrepared?.group,
34370
+ version: k8sResourceToFetchPrepared?.version || "",
34371
+ plural: k8sResourceToFetchPrepared?.plural || "",
34372
+ fieldSelector: sParams.get("fieldSelector") || void 0,
34373
+ labelSelector: sParams.get("labelSelector") || void 0,
34374
+ isEnabled: Boolean(!isMultiqueryLoading && k8sResourceToFetchPrepared)
34375
+ });
34376
+ if (fetchUrlPrepared && isMultiqueryLoading) {
34360
34377
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
34361
34378
  }
34362
- if (isFetchedDataLoading) {
34379
+ if (k8sResourceToFetchPrepared && isMultiqueryLoading) {
34380
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
34381
+ }
34382
+ if (fetchUrlPrepared && isFetchedDataLoading) {
34363
34383
  return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}) });
34364
34384
  }
34365
- if (fetchedDataError) {
34385
+ if (k8sResourceToFetchPrepared && isFetchedDataSocketLoading) {
34386
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}) });
34387
+ }
34388
+ if (fetchUrlPrepared && fetchedDataError) {
34389
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34390
+ "Error: ",
34391
+ JSON.stringify(fetchedDataError)
34392
+ ] });
34393
+ }
34394
+ if (k8sResourceToFetchPrepared && fetchedDataSocketError) {
34366
34395
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34367
34396
  "Error: ",
34368
34397
  JSON.stringify(fetchedDataError)
34369
34398
  ] });
34370
34399
  }
34371
- const items = Array.isArray(pathToItems) ? _$1.get(fetchedData, pathToItems) : jp.query(fetchedData, `$${pathToItems}`)[0];
34400
+ const dataFromOneOfHooks = fetchedData || fetchedDataSocket?.items;
34401
+ const items = Array.isArray(pathToItems) ? _$1.get(dataFromOneOfHooks, pathToItems) : jp.query(dataFromOneOfHooks, `$${pathToItems}`)[0];
34372
34402
  if (!items) {
34373
34403
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34374
34404
  "No data on this path ",
@@ -34503,15 +34533,18 @@
34503
34533
  const namespacePrepared = parseAll({ text: namespace, replaceValues, multiQueryData });
34504
34534
  const podNamePrepared = parseAll({ text: podName, replaceValues, multiQueryData });
34505
34535
  const {
34506
- data: podInfo,
34536
+ data: podInfoList,
34507
34537
  isError: isPodInfoError,
34508
34538
  isLoading: isLoadingPodInfo
34509
- } = useDirectUnknownResource({
34510
- uri: `/api/clusters/${clusterPrepared}/k8s/api/v1/namespaces/${namespacePrepared}/pods/${podNamePrepared}`,
34511
- refetchInterval: 5e3,
34512
- queryKey: [clusterPrepared || "no-cluster", "pods", podNamePrepared],
34539
+ } = useK8sSmartResource({
34540
+ cluster: clusterPrepared,
34541
+ namespace: namespacePrepared,
34542
+ version: "v1",
34543
+ plural: "pods",
34544
+ fieldSelector: `metadata.name=${podNamePrepared}`,
34513
34545
  isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
34514
34546
  });
34547
+ const podInfo = podInfoList?.items && podInfoList.items.length > 0 ? podInfoList.items[0] : void 0;
34515
34548
  if (isMultiqueryLoading) {
34516
34549
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
34517
34550
  }
@@ -34619,15 +34652,18 @@
34619
34652
  const namespacePrepared = parseAll({ text: namespace, replaceValues, multiQueryData });
34620
34653
  const podNamePrepared = parseAll({ text: podName, replaceValues, multiQueryData });
34621
34654
  const {
34622
- data: podInfo,
34655
+ data: podInfoList,
34623
34656
  isError: isPodInfoError,
34624
34657
  isLoading: isLoadingPodInfo
34625
- } = useDirectUnknownResource({
34626
- uri: `/api/clusters/${clusterPrepared}/k8s/api/v1/namespaces/${namespacePrepared}/pods/${podNamePrepared}`,
34627
- refetchInterval: 5e3,
34628
- queryKey: [clusterPrepared || "no-cluster", "pods", podNamePrepared],
34658
+ } = useK8sSmartResource({
34659
+ cluster: clusterPrepared,
34660
+ namespace: namespacePrepared,
34661
+ version: "v1",
34662
+ plural: "pods",
34663
+ fieldSelector: `metadata.name=${podNamePrepared}`,
34629
34664
  isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
34630
34665
  });
34666
+ const podInfo = podInfoList?.items && podInfoList.items.length > 0 ? podInfoList.items[0] : void 0;
34631
34667
  if (isMultiqueryLoading) {
34632
34668
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
34633
34669
  }