@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.16 → 1.2.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.
@@ -8615,10 +8615,6 @@ const ManageableBreadcrumbs = ({ data }) => {
8615
8615
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$y.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleBreadcrumb, { items: data.breadcrumbItems }) });
8616
8616
  };
8617
8617
 
8618
- const getKinds = async ({ cluster }) => {
8619
- return axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
8620
- };
8621
-
8622
8618
  const kindByGvr = (entries) => (gvr) => {
8623
8619
  const [group = "", v = "", resource = ""] = gvr.split("~", 3);
8624
8620
  const norm = (s) => s.trim();
@@ -8627,6 +8623,10 @@ const kindByGvr = (entries) => (gvr) => {
8627
8623
  return uniq.length === 1 ? uniq[0] : void 0;
8628
8624
  };
8629
8625
 
8626
+ const getKinds = async ({ cluster }) => {
8627
+ return axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
8628
+ };
8629
+
8630
8630
  const parseK8sVersion$1 = (raw) => {
8631
8631
  const m = /^v(?<major>\d+)(?:(?<stage>alpha|beta)(?<stageNum>\d+)?)?$/i.exec(raw ?? "");
8632
8632
  if (!m?.groups) return { rank: 0, major: -1, stageNum: -1 };
@@ -8671,6 +8671,23 @@ const getSortedKindsAll = (index) => {
8671
8671
  );
8672
8672
  };
8673
8673
 
8674
+ const useKinds = ({
8675
+ cluster,
8676
+ refetchInterval,
8677
+ isEnabled
8678
+ }) => {
8679
+ return useQuery({
8680
+ queryKey: ["useKinds", cluster],
8681
+ queryFn: () => getKinds({ cluster }),
8682
+ select: (data) => ({
8683
+ kindIndex: data.data,
8684
+ kindsWithVersion: getSortedKindsAll(data.data)
8685
+ }),
8686
+ refetchInterval: refetchInterval !== void 0 ? refetchInterval : 6e4,
8687
+ enabled: isEnabled
8688
+ });
8689
+ };
8690
+
8674
8691
  const getDirectUnknownResource = async ({ uri }) => {
8675
8692
  return axios.get(uri);
8676
8693
  };
@@ -9377,27 +9394,11 @@ const hasItemsArray = (value) => {
9377
9394
  const useK8sSmartResource = (params) => {
9378
9395
  const { cluster, apiGroup, apiVersion, plural } = params;
9379
9396
  const base = useK8sSmartResourceWithoutKinds(params);
9380
- const [kindsWithVersion, setKindsWithVersion] = useState(void 0);
9381
- useEffect(() => {
9382
- let cancelled = false;
9383
- if (!cluster) {
9384
- setKindsWithVersion(void 0);
9385
- return void 0;
9386
- }
9387
- getKinds({ cluster }).then((data) => {
9388
- if (cancelled) {
9389
- return;
9390
- }
9391
- setKindsWithVersion(getSortedKindsAll(data.data));
9392
- }).catch(() => {
9393
- if (!cancelled) {
9394
- setKindsWithVersion(void 0);
9395
- }
9396
- });
9397
- return () => {
9398
- cancelled = true;
9399
- };
9400
- }, [cluster]);
9397
+ const { data: kindsData } = useKinds({
9398
+ cluster,
9399
+ isEnabled: !!cluster
9400
+ });
9401
+ const kindsWithVersion = kindsData?.kindsWithVersion;
9401
9402
  const resolveKindByGvr = useMemo(
9402
9403
  () => kindsWithVersion ? kindByGvr(kindsWithVersion) : void 0,
9403
9404
  [kindsWithVersion]
@@ -35096,6 +35097,7 @@ const EnrichedTable$1 = ({
35096
35097
  k8sResource,
35097
35098
  dataForControls,
35098
35099
  baseprefix,
35100
+ pathToKey,
35099
35101
  ...props
35100
35102
  } = data;
35101
35103
  const theme = useTheme();
@@ -35261,6 +35263,7 @@ const EnrichedTable$1 = ({
35261
35263
  dataForControls: dataForControlsPrepared,
35262
35264
  withoutControls: !dataForControlsPrepared,
35263
35265
  baseprefix,
35266
+ pathToKey,
35264
35267
  ...props
35265
35268
  }
35266
35269
  ),
@@ -46494,23 +46497,6 @@ const pluralByKind = (entries) => (kind, apiVersion) => {
46494
46497
  return uniq.length === 1 ? uniq[0] : void 0;
46495
46498
  };
46496
46499
 
46497
- const useKinds = ({
46498
- cluster,
46499
- refetchInterval,
46500
- isEnabled
46501
- }) => {
46502
- return useQuery({
46503
- queryKey: ["useKinds", cluster],
46504
- queryFn: () => getKinds({ cluster }),
46505
- select: (data) => ({
46506
- kindIndex: data.data,
46507
- kindsWithVersion: getSortedKindsAll(data.data)
46508
- }),
46509
- refetchInterval: refetchInterval !== void 0 ? refetchInterval : 6e4,
46510
- enabled: isEnabled
46511
- });
46512
- };
46513
-
46514
46500
  const findOwnerReferencePath = (rawObject, jsonPathToArrayOfRefs, reference) => {
46515
46501
  if (!rawObject || !jsonPathToArrayOfRefs) return void 0;
46516
46502
  let arrayJsonPath = jsonPathToArrayOfRefs.trim();
@@ -77283,6 +77269,7 @@ const EnrichedTable = ({
77283
77269
 
77284
77270
  const prepare = ({
77285
77271
  dataItems,
77272
+ pathToKey,
77286
77273
  resourceSchema,
77287
77274
  dataForControls,
77288
77275
  additionalPrinterColumns
@@ -77353,13 +77340,15 @@ const prepare = ({
77353
77340
  onDeleteHandle: dataForControls.onDeleteHandle,
77354
77341
  permissions: dataForControls.permissions
77355
77342
  };
77343
+ const key2 = pathToKey ? jp.query(el, `$${pathToKey}`)[0] : `${el.metadata.name}${el.metadata.namespace ? `-${el.metadata.namespace}` : ""}`;
77356
77344
  return {
77357
- key: `${el.metadata.name}${el.metadata.namespace ? `-${el.metadata.namespace}` : ""}`,
77345
+ key: key2,
77358
77346
  ...el,
77359
77347
  internalDataForControls
77360
77348
  };
77361
77349
  }
77362
- return { key: JSON.stringify(el), ...el };
77350
+ const key = pathToKey ? jp.query(el, `$${pathToKey}`)[0] : JSON.stringify(el);
77351
+ return { key, ...el };
77363
77352
  }
77364
77353
  return {};
77365
77354
  });
@@ -77436,13 +77425,15 @@ const prepare = ({
77436
77425
  onDeleteHandle: dataForControls.onDeleteHandle,
77437
77426
  permissions: dataForControls.permissions
77438
77427
  };
77428
+ const key2 = pathToKey ? jp.query(el, `$${pathToKey}`)[0] : `${el.metadata.name}${el.metadata.namespace ? `-${el.metadata.namespace}` : ""}`;
77439
77429
  return {
77440
- key: `${el.metadata.name}${el.metadata.namespace ? `-${el.metadata.namespace}` : ""}`,
77430
+ key: key2,
77441
77431
  ...el.spec,
77442
77432
  internalDataForControls
77443
77433
  };
77444
77434
  }
77445
- return { key: JSON.stringify(el.spec), ...el.spec };
77435
+ const key = pathToKey ? jp.query(el, `$${pathToKey}`)[0] : JSON.stringify(el.spec);
77436
+ return { key, ...el.spec };
77446
77437
  }
77447
77438
  return {};
77448
77439
  });
@@ -77467,7 +77458,8 @@ const EnrichedTableProvider = ({
77467
77458
  forceDefaultAdditionalPrinterColumns,
77468
77459
  selectData,
77469
77460
  tableProps,
77470
- withoutControls
77461
+ withoutControls,
77462
+ pathToKey
77471
77463
  }) => {
77472
77464
  const location = useLocation();
77473
77465
  const [preparedProps, setPreparedProps] = useState();
@@ -77530,6 +77522,7 @@ const EnrichedTableProvider = ({
77530
77522
  const fullPath = `${location.pathname}${location.search}`;
77531
77523
  const { dataSource, columns } = prepare({
77532
77524
  dataItems,
77525
+ pathToKey,
77533
77526
  resourceSchema,
77534
77527
  dataForControls: dataForControls ? {
77535
77528
  ...dataForControls,