@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.1 → 1.1.0-alpha.3

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('styled-components'), require('react'), require('antd'), require('@ant-design/icons'), require('react-router-dom'), require('@tanstack/react-query')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'styled-components', 'react', 'antd', '@ant-design/icons', 'react-router-dom', '@tanstack/react-query'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@prorobotech/openapi-k8s-toolkit"] = {}, global.styled, global.React, global.antd, global.antdIcons, global.ReactRouterDOM, global.reactQuery));
5
- })(this, (function (exports, styled, K, antd, icons, reactRouterDom, reactQuery) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('styled-components'), require('react'), require('antd'), require('@ant-design/icons'), require('@tanstack/react-query'), require('react-router-dom')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'styled-components', 'react', 'antd', '@ant-design/icons', '@tanstack/react-query', 'react-router-dom'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@prorobotech/openapi-k8s-toolkit"] = {}, global.styled, global.React, global.antd, global.antdIcons, global.reactQuery, global.ReactRouterDOM));
5
+ })(this, (function (exports, styled, K, antd, icons, reactQuery, reactRouterDom) { 'use strict';
6
6
 
7
7
  const Spacer$1 = styled.div`
8
8
  height: ${({ $space, $spaceMob, $samespace }) => {
@@ -8315,6 +8315,63 @@
8315
8315
  padding: ${({ $padding }) => $padding};
8316
8316
  `;
8317
8317
 
8318
+ const getDirectUnknownResource = async ({ uri }) => {
8319
+ return axios.get(uri);
8320
+ };
8321
+
8322
+ const useDirectUnknownResource = ({
8323
+ uri,
8324
+ queryKey,
8325
+ refetchInterval,
8326
+ isEnabled
8327
+ }) => {
8328
+ return reactQuery.useQuery({
8329
+ queryKey,
8330
+ queryFn: async () => {
8331
+ const response = await getDirectUnknownResource({
8332
+ uri
8333
+ });
8334
+ const data = JSON.parse(JSON.stringify(response.data));
8335
+ if (data.metadata?.resourceVersion) {
8336
+ delete data.metadata.resourceVersion;
8337
+ }
8338
+ return data;
8339
+ },
8340
+ refetchInterval: refetchInterval !== void 0 ? refetchInterval : 5e3,
8341
+ enabled: isEnabled
8342
+ });
8343
+ };
8344
+
8345
+ const useK8sVerbs = ({
8346
+ cluster,
8347
+ group,
8348
+ version,
8349
+ plural,
8350
+ isEnabled = true
8351
+ }) => {
8352
+ const uri = `/api/clusters/${cluster}/openapi-bff/verbs/getResourceVerbs?${new URLSearchParams({
8353
+ ...group ? { group } : {},
8354
+ version,
8355
+ plural
8356
+ }).toString()}`;
8357
+ const { data, isError, isLoading, error } = useDirectUnknownResource({
8358
+ uri,
8359
+ queryKey: ["k8s-verbs", group || "", version, plural],
8360
+ refetchInterval: false,
8361
+ isEnabled
8362
+ });
8363
+ const verbs = data?.verbs || [];
8364
+ const canList = verbs.includes("list");
8365
+ const canWatch = verbs.includes("watch");
8366
+ return {
8367
+ canList,
8368
+ canWatch,
8369
+ isError,
8370
+ isLoading,
8371
+ error
8372
+ };
8373
+ };
8374
+
8318
8375
  const eventKey$1 = (e) => {
8319
8376
  const n = e.metadata?.name ?? "";
8320
8377
  const ns = e.metadata?.namespace ?? "";
@@ -8810,17 +8867,122 @@
8810
8867
  };
8811
8868
  };
8812
8869
 
8813
- const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
8814
- K.useEffect(() => {
8815
- const el = sentinelRef.current;
8816
- if (!el) return void 0;
8817
- const io = new IntersectionObserver((entries) => {
8818
- const visible = entries.some((e) => e.isIntersecting);
8819
- if (visible && hasMore) onNeedMore();
8820
- });
8821
- io.observe(el);
8822
- return () => io.disconnect();
8823
- }, [sentinelRef, hasMore, onNeedMore]);
8870
+ const buildApiPrefix = (group, version) => {
8871
+ const g = (group ?? "").trim();
8872
+ const v = (version ?? "").trim();
8873
+ const isCore = !g || g === "core" || g === "v1";
8874
+ return isCore ? `/api/${v}` : `/apis/${g}/${v}`;
8875
+ };
8876
+ const buildListUri = ({
8877
+ cluster,
8878
+ group,
8879
+ version,
8880
+ plural,
8881
+ namespace,
8882
+ fieldSelector,
8883
+ labelSelector,
8884
+ limit
8885
+ }) => {
8886
+ const prefix = buildApiPrefix(group, version);
8887
+ const ns = namespace ? `/namespaces/${namespace}` : "";
8888
+ const base = `/api/clusters/${cluster}/k8s${prefix}${ns}/${plural}/`;
8889
+ const params = new URLSearchParams();
8890
+ if (fieldSelector) params.append("fieldSelector", fieldSelector);
8891
+ if (labelSelector) params.append("labelSelector", labelSelector);
8892
+ if (limit) params.append("limit", String(limit));
8893
+ return params.toString() ? `${base}?${params.toString()}` : base;
8894
+ };
8895
+ const useK8sSmartResource = ({
8896
+ cluster,
8897
+ group,
8898
+ version,
8899
+ plural,
8900
+ namespace,
8901
+ fieldSelector,
8902
+ labelSelector,
8903
+ isEnabled = true,
8904
+ listRefetchInterval = 5e3,
8905
+ limit,
8906
+ mapListWatchState
8907
+ }) => {
8908
+ const {
8909
+ canList,
8910
+ canWatch,
8911
+ isLoading: verbsLoading,
8912
+ isError: verbsIsError,
8913
+ error: verbsErrorObj
8914
+ } = useK8sVerbs({
8915
+ cluster,
8916
+ group,
8917
+ version,
8918
+ plural,
8919
+ isEnabled
8920
+ });
8921
+ const listUri = buildListUri({
8922
+ cluster,
8923
+ group,
8924
+ version,
8925
+ plural,
8926
+ namespace,
8927
+ fieldSelector,
8928
+ labelSelector,
8929
+ limit
8930
+ });
8931
+ const restEnabled = Boolean(isEnabled && canList && !canWatch && !verbsLoading && !verbsIsError);
8932
+ const {
8933
+ data: restData,
8934
+ isLoading: restLoading,
8935
+ isError: restIsError,
8936
+ error: restError
8937
+ } = useDirectUnknownResource({
8938
+ uri: listUri,
8939
+ queryKey: [
8940
+ "k8s-list",
8941
+ cluster,
8942
+ group || "",
8943
+ version,
8944
+ namespace || "",
8945
+ plural,
8946
+ fieldSelector || "",
8947
+ labelSelector || ""
8948
+ ],
8949
+ refetchInterval: listRefetchInterval,
8950
+ isEnabled: restEnabled
8951
+ });
8952
+ const watchEnabled = Boolean(isEnabled && canList && canWatch && !verbsLoading && !verbsIsError);
8953
+ const { state, status, lastError } = useListWatch({
8954
+ wsUrl: `/api/clusters/${cluster}/openapi-bff-ws/listThenWatch/listWatchWs`,
8955
+ paused: false,
8956
+ ignoreRemove: false,
8957
+ autoDrain: true,
8958
+ preserveStateOnUrlChange: true,
8959
+ isEnabled: watchEnabled,
8960
+ pageSize: limit,
8961
+ query: {
8962
+ apiGroup: group,
8963
+ apiVersion: version,
8964
+ plural,
8965
+ namespace,
8966
+ fieldSelector,
8967
+ labelSelector
8968
+ }
8969
+ });
8970
+ const defaultMap = (s) => ({ items: s.order.map((k) => s.byKey[k]) });
8971
+ const watchData = K.useMemo(
8972
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8973
+ () => watchEnabled ? (mapListWatchState ?? defaultMap)(state) : void 0,
8974
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8975
+ [watchEnabled, state, mapListWatchState]
8976
+ );
8977
+ const used = !isEnabled ? "disabled" : verbsLoading ? "verbs-loading" : verbsIsError ? "verbs-error" : watchEnabled ? "watch" : restEnabled ? "list" : "disabled";
8978
+ const isLoading = isEnabled && verbsLoading || used === "watch" && status === "connecting" || used === "list" && restLoading;
8979
+ let error;
8980
+ if (verbsIsError) error = verbsErrorObj;
8981
+ else if (used === "watch" && status === "closed" && lastError) error = lastError;
8982
+ else if (used === "list" && restIsError) error = restError;
8983
+ const isError = Boolean(error);
8984
+ const data = used === "watch" ? watchData : used === "list" ? restData : void 0;
8985
+ return { data, isLoading, isError, error, _meta: { used } };
8824
8986
  };
8825
8987
 
8826
8988
  const prepareTemplate = ({
@@ -8960,7 +9122,7 @@
8960
9122
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$v.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleBreadcrumb, { items: data.breadcrumbItems }) });
8961
9123
  };
8962
9124
  const ManageableBreadcrumbsWithDataProvider = ({
8963
- wsUrl,
9125
+ cluster,
8964
9126
  apiGroup,
8965
9127
  apiVersion,
8966
9128
  plural,
@@ -8969,28 +9131,17 @@
8969
9131
  pathname,
8970
9132
  idToCompare
8971
9133
  }) => {
8972
- const { state, status, lastError } = useListWatch({
8973
- wsUrl,
8974
- paused: false,
8975
- ignoreRemove: false,
8976
- autoDrain: true,
8977
- preserveStateOnUrlChange: true,
8978
- query: {
8979
- apiVersion,
8980
- apiGroup,
8981
- plural
8982
- },
9134
+ const {
9135
+ data: rawData,
9136
+ isError: rawDataError,
9137
+ isLoading: rawDataLoading
9138
+ } = useK8sSmartResource({
9139
+ cluster: cluster || "",
9140
+ group: apiGroup,
9141
+ version: apiVersion,
9142
+ plural,
8983
9143
  isEnabled
8984
9144
  });
8985
- const rawDataLoading = status === "connecting";
8986
- const rawDataError = status === "closed" && lastError ? lastError : void 0;
8987
- const rawData = {
8988
- items: state.order.map((key) => {
8989
- const res = state.byKey[key];
8990
- return res;
8991
- })
8992
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8993
- };
8994
9145
  if (rawDataError) {
8995
9146
  return null;
8996
9147
  }
@@ -9176,7 +9327,7 @@
9176
9327
  );
9177
9328
  };
9178
9329
  const ManageableSidebarWithDataProvider = ({
9179
- wsUrl,
9330
+ cluster,
9180
9331
  apiGroup,
9181
9332
  apiVersion,
9182
9333
  plural,
@@ -9188,28 +9339,17 @@
9188
9339
  hidden,
9189
9340
  noMarginTop
9190
9341
  }) => {
9191
- const { state, status, lastError } = useListWatch({
9192
- wsUrl,
9193
- paused: false,
9194
- ignoreRemove: false,
9195
- autoDrain: true,
9196
- preserveStateOnUrlChange: true,
9197
- query: {
9198
- apiVersion,
9199
- apiGroup,
9200
- plural
9201
- },
9342
+ const {
9343
+ data: rawData,
9344
+ isError: rawDataError,
9345
+ isLoading: rawDataLoading
9346
+ } = useK8sSmartResource({
9347
+ cluster,
9348
+ group: apiGroup,
9349
+ version: apiVersion,
9350
+ plural,
9202
9351
  isEnabled
9203
9352
  });
9204
- const rawDataLoading = status === "connecting";
9205
- const rawDataError = status === "closed" && lastError ? lastError : void 0;
9206
- const rawData = {
9207
- items: state.order.map((key) => {
9208
- const res = state.byKey[key];
9209
- return res;
9210
- })
9211
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9212
- };
9213
9353
  if (rawDataError) {
9214
9354
  return null;
9215
9355
  }
@@ -33468,49 +33608,95 @@
33468
33608
  };
33469
33609
 
33470
33610
  const MultiQueryContext = K.createContext(void 0);
33471
- const MultiQueryProvider = ({ urls, dataToApplyToContext, children }) => {
33472
- const queries = reactQuery.useQueries({
33473
- queries: urls.map((url, index) => ({
33474
- queryKey: ["multi", index, url],
33611
+ const makeEmptyEntry = () => ({
33612
+ data: void 0,
33613
+ isLoading: false,
33614
+ isError: false,
33615
+ error: null
33616
+ });
33617
+ const aggReducer = (state, action) => {
33618
+ switch (action.type) {
33619
+ case "RESET":
33620
+ return { entries: Array.from({ length: action.total }, makeEmptyEntry) };
33621
+ case "SET_ENTRY": {
33622
+ const entries = state.entries.slice();
33623
+ entries[action.index] = action.entry;
33624
+ return { entries };
33625
+ }
33626
+ default:
33627
+ return state;
33628
+ }
33629
+ };
33630
+ const K8sFetcher = ({ index, params, dispatch }) => {
33631
+ const res = useK8sSmartResource(params);
33632
+ K.useEffect(() => {
33633
+ dispatch({
33634
+ type: "SET_ENTRY",
33635
+ index,
33636
+ entry: {
33637
+ data: res.data,
33638
+ isLoading: res.isLoading,
33639
+ isError: res.isError,
33640
+ error: res.error ?? null
33641
+ }
33642
+ });
33643
+ }, [index, res.data, res.isLoading, res.isError, res.error, dispatch]);
33644
+ return null;
33645
+ };
33646
+ const MultiQueryProvider = ({ items, dataToApplyToContext, children }) => {
33647
+ const k8sItems = K.useMemo(
33648
+ () => items.filter((x) => typeof x !== "string"),
33649
+ [items]
33650
+ );
33651
+ const urlItems = K.useMemo(() => items.filter((x) => typeof x === "string"), [items]);
33652
+ const k8sCount = k8sItems.length;
33653
+ const urlCount = urlItems.length;
33654
+ const [state, dispatch] = K.useReducer(aggReducer, { entries: Array.from({ length: k8sCount }, makeEmptyEntry) });
33655
+ K.useEffect(() => {
33656
+ dispatch({ type: "RESET", total: k8sCount });
33657
+ }, [k8sCount]);
33658
+ const urlQueries = reactQuery.useQueries({
33659
+ queries: urlItems.map((url, i) => ({
33660
+ queryKey: ["multi-url", i, url],
33475
33661
  queryFn: async () => {
33476
- const response = await axios.get(url);
33477
- return response.data;
33662
+ const res = await axios.get(url);
33663
+ return res.data;
33478
33664
  }
33479
33665
  }))
33480
33666
  });
33481
- const data = {};
33482
- const errors = [];
33483
- let isLoading;
33484
- let isError;
33485
- if (!dataToApplyToContext) {
33486
- queries.forEach((q, i) => {
33487
- data[`req${i}`] = q.data;
33488
- errors[i] = q.error ?? null;
33489
- });
33490
- isLoading = queries.some((q) => q.isLoading);
33491
- isError = queries.some((q) => q.isError);
33492
- } else {
33493
- data.req0 = dataToApplyToContext;
33494
- isLoading = false;
33495
- isError = false;
33496
- }
33497
- const value = K.useMemo(
33498
- () => ({ data, isLoading, isError, errors }),
33499
- /*
33500
- We use JSON.stringify(data) and JSON.stringify(errors) as dependencies to safely memoize when values deeply change (since data is a new object every render).
33501
- Alternatively, you could use a deep comparison hook or lodash.isEqual if needed.
33502
- */
33503
- // eslint-disable-next-line react-hooks/exhaustive-deps
33504
- [JSON.stringify(data), isLoading, isError, JSON.stringify(errors)]
33505
- );
33506
- return /* @__PURE__ */ jsxRuntimeExports.jsx(MultiQueryContext.Provider, { value, children });
33667
+ const value = K.useMemo(() => {
33668
+ if (typeof dataToApplyToContext !== "undefined") {
33669
+ return { data: { req0: dataToApplyToContext }, isLoading: false, isError: false, errors: [] };
33670
+ }
33671
+ const data = {};
33672
+ const errors = [];
33673
+ for (let i = 0; i < k8sCount; i++) {
33674
+ const e = state.entries[i] ?? makeEmptyEntry();
33675
+ data[`req${i}`] = e.data;
33676
+ errors[i] = e.isError ? e.error : null;
33677
+ }
33678
+ for (let i = 0; i < urlCount; i++) {
33679
+ const q = urlQueries[i];
33680
+ const idx = k8sCount + i;
33681
+ data[`req${idx}`] = q?.data;
33682
+ errors[idx] = q?.isError ? q.error ?? null : null;
33683
+ }
33684
+ const isLoading = state.entries.some((e) => e.isLoading) || urlQueries.some((q) => q.isLoading);
33685
+ const isError = state.entries.some((e) => e.isError) || urlQueries.some((q) => q.isError);
33686
+ return { data, isLoading, isError, errors };
33687
+ }, [dataToApplyToContext, k8sCount, urlCount, state.entries, urlQueries]);
33688
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(MultiQueryContext.Provider, { value, children: [
33689
+ k8sItems.map((params, i) => (
33690
+ // eslint-disable-next-line react/no-array-index-key
33691
+ /* @__PURE__ */ jsxRuntimeExports.jsx(K8sFetcher, { index: i, params, dispatch }, i)
33692
+ )),
33693
+ children
33694
+ ] });
33507
33695
  };
33508
33696
  const useMultiQuery = () => {
33509
- const context = K.useContext(MultiQueryContext);
33510
- if (!context) {
33511
- throw new Error("useMultiQuery must be used within a MultiQueryProvider");
33512
- }
33513
- return context;
33697
+ const ctx = K.useContext(MultiQueryContext);
33698
+ if (!ctx) throw new Error("useMultiQuery must be used within a MultiQueryProvider");
33699
+ return ctx;
33514
33700
  };
33515
33701
 
33516
33702
  const createContextFactory = () => {
@@ -33738,7 +33924,7 @@
33738
33924
  if (isError) {
33739
33925
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33740
33926
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
33741
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
33927
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
33742
33928
  ] });
33743
33929
  }
33744
33930
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: preparedText });
@@ -33768,7 +33954,7 @@
33768
33954
  if (isError) {
33769
33955
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33770
33956
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
33771
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
33957
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
33772
33958
  ] });
33773
33959
  }
33774
33960
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -33805,7 +33991,7 @@
33805
33991
  if (isError) {
33806
33992
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33807
33993
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
33808
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
33994
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
33809
33995
  ] });
33810
33996
  }
33811
33997
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ProjectInfoCard, { clusterName, namespace, accessGroups: parsedAccessGroups, ...props, children });
@@ -33922,7 +34108,7 @@
33922
34108
  if (isError) {
33923
34109
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
33924
34110
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
33925
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
34111
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
33926
34112
  ] });
33927
34113
  }
33928
34114
  const { type, text } = getResult({
@@ -34008,33 +34194,6 @@
34008
34194
  });
34009
34195
  };
34010
34196
 
34011
- const getDirectUnknownResource = async ({ uri }) => {
34012
- return axios.get(uri);
34013
- };
34014
-
34015
- const useDirectUnknownResource = ({
34016
- uri,
34017
- queryKey,
34018
- refetchInterval,
34019
- isEnabled
34020
- }) => {
34021
- return reactQuery.useQuery({
34022
- queryKey,
34023
- queryFn: async () => {
34024
- const response = await getDirectUnknownResource({
34025
- uri
34026
- });
34027
- const data = JSON.parse(JSON.stringify(response.data));
34028
- if (data.metadata?.resourceVersion) {
34029
- delete data.metadata.resourceVersion;
34030
- }
34031
- return data;
34032
- },
34033
- refetchInterval: refetchInterval !== void 0 ? refetchInterval : 5e3,
34034
- enabled: isEnabled
34035
- });
34036
- };
34037
-
34038
34197
  const getBackLinkToTable = ({ fullPath }) => {
34039
34198
  return encodeURIComponent(fullPath);
34040
34199
  };
@@ -34654,7 +34813,7 @@
34654
34813
  if (isMultiQueryErrors) {
34655
34814
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34656
34815
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
34657
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
34816
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
34658
34817
  ] });
34659
34818
  }
34660
34819
  const jsonRoot = multiQueryData[`req${reqIndex}`];
@@ -34721,7 +34880,7 @@
34721
34880
  if (isMultiQueryErrors) {
34722
34881
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34723
34882
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
34724
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
34883
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
34725
34884
  ] });
34726
34885
  }
34727
34886
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -34778,7 +34937,7 @@
34778
34937
  if (isMultiQueryErrors) {
34779
34938
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
34780
34939
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
34781
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
34940
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
34782
34941
  ] });
34783
34942
  }
34784
34943
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -35163,7 +35322,7 @@
35163
35322
  if (isMultiQueryErrors) {
35164
35323
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35165
35324
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
35166
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
35325
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
35167
35326
  ] });
35168
35327
  }
35169
35328
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -35438,7 +35597,7 @@
35438
35597
  if (isMultiQueryErrors) {
35439
35598
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35440
35599
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
35441
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
35600
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
35442
35601
  ] });
35443
35602
  }
35444
35603
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -35707,7 +35866,7 @@
35707
35866
  if (isMultiQueryErrors) {
35708
35867
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35709
35868
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
35710
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
35869
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
35711
35870
  ] });
35712
35871
  }
35713
35872
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -36080,7 +36239,7 @@
36080
36239
  if (isMultiQueryErrors) {
36081
36240
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
36082
36241
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
36083
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
36242
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
36084
36243
  ] });
36085
36244
  }
36086
36245
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -36361,7 +36520,7 @@
36361
36520
  if (isMultiQueryErrors) {
36362
36521
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
36363
36522
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
36364
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
36523
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
36365
36524
  ] });
36366
36525
  }
36367
36526
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -36579,7 +36738,7 @@
36579
36738
  if (isError) {
36580
36739
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
36581
36740
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
36582
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
36741
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
36583
36742
  ] });
36584
36743
  }
36585
36744
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -37396,7 +37555,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
37396
37555
  if (isError) {
37397
37556
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
37398
37557
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
37399
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
37558
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
37400
37559
  ] });
37401
37560
  }
37402
37561
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
@@ -37528,7 +37687,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
37528
37687
  if (isError) {
37529
37688
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
37530
37689
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
37531
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
37690
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
37532
37691
  ] });
37533
37692
  }
37534
37693
  const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value2, index) => {
@@ -37709,13 +37868,30 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
37709
37868
  );
37710
37869
  };
37711
37870
 
37871
+ const STRING_KEYS = ["cluster", "group", "version", "plural", "namespace", "fieldSelector", "labelSelector"];
37712
37872
  const DynamicRendererWithProviders = (props) => {
37713
37873
  const location = reactRouterDom.useLocation();
37714
37874
  const { urlsToFetch, dataToApplyToContext, theme, nodeTerminalDefaultProfile, disableEventBubbling } = props;
37875
+ const directUrls = urlsToFetch.filter((el) => typeof el === "string");
37876
+ const k8sResourcesUrls = urlsToFetch.filter((el) => typeof el !== "string");
37715
37877
  const preparedUrlsToFetch = prepareUrlsToFetchForDynamicRenderer({
37716
- urls: urlsToFetch,
37878
+ urls: directUrls,
37717
37879
  locationPathname: location.pathname
37718
37880
  });
37881
+ const preparedK8sResoucesUrls = k8sResourcesUrls.map((res) => {
37882
+ let next = { ...res };
37883
+ for (const key of STRING_KEYS) {
37884
+ const val = next[key];
37885
+ if (typeof val === "string" && val.length > 0) {
37886
+ const prepared = prepareUrlsToFetchForDynamicRenderer({
37887
+ urls: [val],
37888
+ locationPathname: location.pathname
37889
+ });
37890
+ next = { ...next, [key]: prepared[0] ?? val };
37891
+ }
37892
+ }
37893
+ return next;
37894
+ });
37719
37895
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
37720
37896
  CursorDefaultDiv,
37721
37897
  {
@@ -37725,7 +37901,14 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
37725
37901
  e.stopPropagation();
37726
37902
  }
37727
37903
  },
37728
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FactoryConfigContextProvider, { value: { nodeTerminalDefaultProfile }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PartsOfUrlProvider, { value: { partsOfUrl: location.pathname.split("/") }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MultiQueryProvider, { urls: preparedUrlsToFetch, dataToApplyToContext, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicRenderer, { ...props }) }) }) }) })
37904
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FactoryConfigContextProvider, { value: { nodeTerminalDefaultProfile }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PartsOfUrlProvider, { value: { partsOfUrl: location.pathname.split("/") }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
37905
+ MultiQueryProvider,
37906
+ {
37907
+ items: [...preparedK8sResoucesUrls, ...preparedUrlsToFetch],
37908
+ dataToApplyToContext,
37909
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicRenderer, { ...props })
37910
+ }
37911
+ ) }) }) })
37729
37912
  }
37730
37913
  );
37731
37914
  };
@@ -50308,28 +50491,14 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
50308
50491
  apiVersion,
50309
50492
  baseprefix
50310
50493
  });
50311
- const { state, status, lastError } = useListWatch({
50312
- wsUrl: `/api/clusters/${clusterName}/openapi-bff-ws/listThenWatch/listWatchWs`,
50313
- paused: false,
50314
- ignoreRemove: false,
50315
- autoDrain: true,
50316
- preserveStateOnUrlChange: true,
50317
- query: {
50318
- namespace,
50319
- apiVersion: apiVersion || "",
50320
- apiGroup,
50321
- plural: type
50322
- },
50494
+ const { data: k8sList, error: k8sListError } = useK8sSmartResource({
50495
+ cluster: clusterName || "",
50496
+ namespace,
50497
+ group: apiGroup,
50498
+ version: apiVersion || "",
50499
+ plural: type,
50323
50500
  isEnabled: Boolean(apiVersion && addedMode && type !== "direct")
50324
50501
  });
50325
- const k8sListError = status === "closed" && lastError ? lastError : void 0;
50326
- const k8sList = {
50327
- items: state.order.map((key) => {
50328
- const res = state.byKey[key];
50329
- return res;
50330
- })
50331
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50332
- };
50333
50502
  if (addedMode && (k8sListError || type === "direct") && !showZeroResources) {
50334
50503
  return null;
50335
50504
  }
@@ -50458,30 +50627,17 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
50458
50627
  const [filteredAndSortedData, setFilterAndSortedData] = K.useState([]);
50459
50628
  const [uniqueTags, setUniqueTags] = K.useState([]);
50460
50629
  const [selectedTags, setSelectedTags] = K.useState([]);
50461
- const { state, status, lastError } = useListWatch({
50462
- wsUrl: `/api/clusters/${clusterName}/openapi-bff-ws/listThenWatch/listWatchWs`,
50463
- paused: false,
50464
- ignoreRemove: false,
50465
- autoDrain: true,
50466
- preserveStateOnUrlChange: true,
50467
- query: {
50468
- apiVersion: baseApiVersion,
50469
- apiGroup: baseApiGroup,
50470
- plural: mpResourceName
50471
- },
50472
- isEnabled: clusterName !== void 0
50630
+ const {
50631
+ data: marketplacePanels,
50632
+ isLoading,
50633
+ error
50634
+ } = useK8sSmartResource({
50635
+ cluster: clusterName || "",
50636
+ group: baseApiGroup,
50637
+ version: baseApiVersion,
50638
+ plural: mpResourceName,
50639
+ isEnabled: Boolean(clusterName !== void 0)
50473
50640
  });
50474
- const isLoading = status === "connecting";
50475
- const error = status === "closed" && lastError ? lastError : void 0;
50476
- const marketplacePanels = K.useMemo(() => {
50477
- return {
50478
- items: state.order.map((key) => {
50479
- const res = state.byKey[key];
50480
- return res;
50481
- })
50482
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50483
- };
50484
- }, [state]);
50485
50641
  const createPermission = usePermissions({
50486
50642
  group: baseApiGroup,
50487
50643
  resource: mpResourceName,
@@ -50780,52 +50936,30 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
50780
50936
  children
50781
50937
  }) => {
50782
50938
  const navigate = reactRouterDom.useNavigate();
50783
- const { state, status } = useListWatch({
50784
- wsUrl: `/api/clusters/${clusterName}/openapi-bff-ws/listThenWatch/listWatchWs`,
50785
- paused: false,
50786
- ignoreRemove: false,
50787
- autoDrain: true,
50788
- preserveStateOnUrlChange: true,
50789
- query: {
50790
- apiVersion: baseApiVersion,
50791
- apiGroup: baseApiGroup,
50792
- plural: mpResourceName
50793
- },
50794
- isEnabled: clusterName !== void 0
50795
- });
50796
- const marketplaceIsLoading = status === "connecting";
50797
- const marketplacePanels = {
50798
- items: state.order.map((key) => {
50799
- const res = state.byKey[key];
50800
- return res;
50801
- })
50802
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50803
- };
50804
50939
  const {
50805
- state: stateProject,
50806
- status: statusProject,
50807
- lastError: lastErrorProject
50808
- } = useListWatch({
50809
- wsUrl: `/api/clusters/${clusterName}/openapi-bff-ws/listThenWatch/listWatchWs`,
50810
- paused: false,
50811
- ignoreRemove: false,
50812
- autoDrain: true,
50813
- preserveStateOnUrlChange: true,
50814
- query: {
50815
- apiVersion: baseProjectVersion,
50816
- apiGroup: baseProjectApiGroup,
50817
- plural: projectResourceName,
50818
- fieldSelector: `metadata.name=${namespace}`
50819
- },
50820
- isEnabled: clusterName !== void 0
50940
+ data: marketplacePanels,
50941
+ isLoading: marketplaceIsLoading
50942
+ // error: marketplaceError,
50943
+ } = useK8sSmartResource({
50944
+ cluster: clusterName || "",
50945
+ group: baseApiGroup,
50946
+ version: baseApiVersion,
50947
+ plural: mpResourceName,
50948
+ isEnabled: Boolean(clusterName !== void 0)
50821
50949
  });
50822
- const isLoading = statusProject === "connecting";
50823
- const error = statusProject === "closed" && lastErrorProject ? lastErrorProject : void 0;
50824
- const projectArr = stateProject.order.map((key) => {
50825
- const res = stateProject.byKey[key];
50826
- return res;
50950
+ const {
50951
+ data: projectArr,
50952
+ isLoading,
50953
+ error
50954
+ } = useK8sSmartResource({
50955
+ cluster: clusterName || "",
50956
+ group: baseProjectApiGroup,
50957
+ version: baseProjectVersion,
50958
+ plural: projectResourceName,
50959
+ fieldSelector: `metadata.name=${namespace}`,
50960
+ isEnabled: Boolean(clusterName !== void 0)
50827
50961
  });
50828
- const project = projectArr.length > 0 ? projectArr[0] : void 0;
50962
+ const project = projectArr && projectArr.length > 0 ? projectArr[0] : void 0;
50829
50963
  const [isDeleteModalOpen, setIsDeleteModalOpen] = K.useState(false);
50830
50964
  const updatePermission = usePermissions({
50831
50965
  group: baseProjectApiGroup,
@@ -53467,6 +53601,19 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
53467
53601
  });
53468
53602
  };
53469
53603
 
53604
+ const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
53605
+ K.useEffect(() => {
53606
+ const el = sentinelRef.current;
53607
+ if (!el) return void 0;
53608
+ const io = new IntersectionObserver((entries) => {
53609
+ const visible = entries.some((e) => e.isIntersecting);
53610
+ if (visible && hasMore) onNeedMore();
53611
+ });
53612
+ io.observe(el);
53613
+ return () => io.disconnect();
53614
+ }, [sentinelRef, hasMore, onNeedMore]);
53615
+ };
53616
+
53470
53617
  exports.BackToDefaultIcon = BackToDefaultIcon;
53471
53618
  exports.BlackholeForm = BlackholeForm;
53472
53619
  exports.BlackholeFormDataProvider = BlackholeFormDataProvider;
@@ -53585,6 +53732,8 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
53585
53732
  exports.useCrdResources = useCrdResources;
53586
53733
  exports.useDirectUnknownResource = useDirectUnknownResource;
53587
53734
  exports.useInfiniteSentinel = useInfiniteSentinel;
53735
+ exports.useK8sSmartResource = useK8sSmartResource;
53736
+ exports.useK8sVerbs = useK8sVerbs;
53588
53737
  exports.useListWatch = useListWatch;
53589
53738
  exports.usePermissions = usePermissions;
53590
53739