@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.20 → 1.1.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.
@@ -9431,6 +9431,32 @@
9431
9431
  };
9432
9432
  };
9433
9433
 
9434
+ const useManyK8sSmartResource = (paramsList) => {
9435
+ const results = [];
9436
+ for (let i = 0; i < paramsList.length; i++) {
9437
+ results[i] = useK8sSmartResource(paramsList[i]);
9438
+ }
9439
+ return results;
9440
+ };
9441
+
9442
+ const useSmartResourceParams = ({ cluster, namespace }) => {
9443
+ const [searchParams] = reactRouterDom.useSearchParams();
9444
+ return K.useMemo(() => {
9445
+ const raw = searchParams.get("resources");
9446
+ if (!raw) return [];
9447
+ return raw.split(",").map((entry) => {
9448
+ const [apiGroup = "", apiVersion = "", plural] = entry.split("/");
9449
+ return {
9450
+ cluster,
9451
+ namespace,
9452
+ apiGroup: apiGroup === "builtin" ? void 0 : apiGroup,
9453
+ apiVersion,
9454
+ plural
9455
+ };
9456
+ });
9457
+ }, [searchParams, cluster, namespace]);
9458
+ };
9459
+
9434
9460
  const prepareTemplate = ({
9435
9461
  template,
9436
9462
  replaceValues
@@ -34040,22 +34066,26 @@
34040
34066
  }))
34041
34067
  });
34042
34068
  const value = (() => {
34043
- if (typeof dataToApplyToContext !== "undefined") {
34044
- return { data: { req0: dataToApplyToContext }, isLoading: false, isError: false, errors: [] };
34045
- }
34046
34069
  const data = {};
34047
34070
  const errors = [];
34071
+ const hasExtraReq0 = typeof dataToApplyToContext !== "undefined";
34072
+ const baseIndex = hasExtraReq0 ? 1 : 0;
34048
34073
  for (let i = 0; i < k8sCount; i++) {
34049
34074
  const e = state.entries[i] ?? makeEmptyEntry();
34050
- data[`req${i}`] = e.data;
34051
- errors[i] = e.isError ? e.error : null;
34075
+ const idx = baseIndex + i;
34076
+ data[`req${idx}`] = e.data;
34077
+ errors[idx] = e.isError ? e.error : null;
34052
34078
  }
34053
34079
  for (let i = 0; i < urlCount; i++) {
34054
34080
  const q = urlQueries[i];
34055
- const idx = k8sCount + i;
34081
+ const idx = baseIndex + k8sCount + i;
34056
34082
  data[`req${idx}`] = q?.data;
34057
34083
  errors[idx] = q?.isError ? q.error ?? null : null;
34058
34084
  }
34085
+ if (hasExtraReq0) {
34086
+ data.req0 = dataToApplyToContext;
34087
+ errors[0] = null;
34088
+ }
34059
34089
  const isLoading = state.entries.some((e) => e.isLoading) || urlQueries.some((q) => q.isLoading);
34060
34090
  const isError = state.entries.some((e) => e.isError) || urlQueries.some((q) => q.isError);
34061
34091
  return { data, isLoading, isError, errors };
@@ -34646,6 +34676,7 @@
34646
34676
  fetchUrl,
34647
34677
  k8sResourceToFetch,
34648
34678
  pathToItems,
34679
+ additionalReqsDataToEachItem,
34649
34680
  cluster,
34650
34681
  labelSelector,
34651
34682
  labelSelectorFull,
@@ -34771,6 +34802,17 @@
34771
34802
  const dataFromOneOfHooks = fetchedData || fetchedDataSocket || {};
34772
34803
  const items = Array.isArray(pathToItems) ? _$1.get(dataFromOneOfHooks || {}, pathToItems) : jp.query(dataFromOneOfHooks || {}, `$${pathToItems}`)[0];
34773
34804
  const itemsAlwaysArr = Array.isArray(items) ? items : [];
34805
+ let additionalReqsData = [];
34806
+ if (additionalReqsDataToEachItem) {
34807
+ additionalReqsDataToEachItem.forEach((item) => {
34808
+ additionalReqsData?.push(multiQueryData[`req${item}`]);
34809
+ });
34810
+ }
34811
+ additionalReqsData = additionalReqsData.length > 0 ? additionalReqsData : void 0;
34812
+ const itemsAlwaysArrWithAdditionalData = itemsAlwaysArr.map((el) => ({
34813
+ ...el,
34814
+ ...additionalReqsData ? { additionalReqsData } : {}
34815
+ }));
34774
34816
  const clearSelected = () => {
34775
34817
  setSelectedRowKeys([]);
34776
34818
  setSelectedRowsData([]);
@@ -34787,7 +34829,7 @@
34787
34829
  cluster: clusterPrepared,
34788
34830
  namespace: namespacePrepared,
34789
34831
  theme,
34790
- dataItems: itemsAlwaysArr,
34832
+ dataItems: itemsAlwaysArrWithAdditionalData,
34791
34833
  tableProps: {
34792
34834
  borderless: true,
34793
34835
  paginationPosition: ["bottomRight"],
@@ -38915,7 +38957,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
38915
38957
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
38916
38958
  DynamicRendererWithProviders,
38917
38959
  {
38918
- urlsToFetch: [],
38960
+ urlsToFetch: customProps.urlsToFetch || [],
38919
38961
  dataToApplyToContext: record,
38920
38962
  theme,
38921
38963
  disableEventBubbling: customProps.disableEventBubbling,
@@ -54678,7 +54720,9 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
54678
54720
  exports.useK8sSmartResource = useK8sSmartResource;
54679
54721
  exports.useK8sVerbs = useK8sVerbs;
54680
54722
  exports.useListWatch = useListWatch;
54723
+ exports.useManyK8sSmartResource = useManyK8sSmartResource;
54681
54724
  exports.usePermissions = usePermissions;
54725
+ exports.useSmartResourceParams = useSmartResourceParams;
54682
54726
 
54683
54727
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
54684
54728