@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.17 → 1.2.0-alpha.19
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 +152 -78
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +152 -78
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/components/molecules/Terminals/NodeTerminal/NodeTerminal.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/XTerminal.d.ts +3 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/types.d.ts +7 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/types.d.ts +12 -0
- package/dist/types/components/organisms/DynamicComponents/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
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]
|
|
@@ -35414,6 +35415,7 @@ const NodeTerminal$1 = ({
|
|
|
35414
35415
|
cluster,
|
|
35415
35416
|
nodeName,
|
|
35416
35417
|
substractHeight,
|
|
35418
|
+
listPodTemplatesNs,
|
|
35417
35419
|
...props
|
|
35418
35420
|
} = data;
|
|
35419
35421
|
const { nodeTerminalDefaultProfile } = useFactoryConfig();
|
|
@@ -35423,6 +35425,7 @@ const NodeTerminal$1 = ({
|
|
|
35423
35425
|
return acc;
|
|
35424
35426
|
}, {});
|
|
35425
35427
|
const clusterPrepared = parseAll({ text: cluster, replaceValues, multiQueryData });
|
|
35428
|
+
const listPodTemplatesNsPrepared = listPodTemplatesNs ? parseAll({ text: listPodTemplatesNs, replaceValues, multiQueryData }) : void 0;
|
|
35426
35429
|
const nodeNamePrepared = parseAll({ text: nodeName, replaceValues, multiQueryData });
|
|
35427
35430
|
if (isMultiqueryLoading) {
|
|
35428
35431
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
@@ -35435,6 +35438,7 @@ const NodeTerminal$1 = ({
|
|
|
35435
35438
|
nodeName: nodeNamePrepared,
|
|
35436
35439
|
substractHeight: substractHeight || 340,
|
|
35437
35440
|
defaultProfile: nodeTerminalDefaultProfile,
|
|
35441
|
+
listPodTemplatesNs: listPodTemplatesNsPrepared,
|
|
35438
35442
|
...props
|
|
35439
35443
|
}
|
|
35440
35444
|
),
|
|
@@ -46496,23 +46500,6 @@ const pluralByKind = (entries) => (kind, apiVersion) => {
|
|
|
46496
46500
|
return uniq.length === 1 ? uniq[0] : void 0;
|
|
46497
46501
|
};
|
|
46498
46502
|
|
|
46499
|
-
const useKinds = ({
|
|
46500
|
-
cluster,
|
|
46501
|
-
refetchInterval,
|
|
46502
|
-
isEnabled
|
|
46503
|
-
}) => {
|
|
46504
|
-
return useQuery({
|
|
46505
|
-
queryKey: ["useKinds", cluster],
|
|
46506
|
-
queryFn: () => getKinds({ cluster }),
|
|
46507
|
-
select: (data) => ({
|
|
46508
|
-
kindIndex: data.data,
|
|
46509
|
-
kindsWithVersion: getSortedKindsAll(data.data)
|
|
46510
|
-
}),
|
|
46511
|
-
refetchInterval: refetchInterval !== void 0 ? refetchInterval : 6e4,
|
|
46512
|
-
enabled: isEnabled
|
|
46513
|
-
});
|
|
46514
|
-
};
|
|
46515
|
-
|
|
46516
46503
|
const findOwnerReferencePath = (rawObject, jsonPathToArrayOfRefs, reference) => {
|
|
46517
46504
|
if (!rawObject || !jsonPathToArrayOfRefs) return void 0;
|
|
46518
46505
|
let arrayJsonPath = jsonPathToArrayOfRefs.trim();
|
|
@@ -82559,6 +82546,19 @@ const PodTerminal = ({ cluster, namespace, podName, containers, substractHeight
|
|
|
82559
82546
|
] });
|
|
82560
82547
|
};
|
|
82561
82548
|
|
|
82549
|
+
const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
|
|
82550
|
+
useEffect(() => {
|
|
82551
|
+
const el = sentinelRef.current;
|
|
82552
|
+
if (!el) return void 0;
|
|
82553
|
+
const io = new IntersectionObserver((entries) => {
|
|
82554
|
+
const visible = entries.some((e) => e.isIntersecting);
|
|
82555
|
+
if (visible && hasMore) onNeedMore();
|
|
82556
|
+
});
|
|
82557
|
+
io.observe(el);
|
|
82558
|
+
return () => io.disconnect();
|
|
82559
|
+
}, [sentinelRef, hasMore, onNeedMore]);
|
|
82560
|
+
};
|
|
82561
|
+
|
|
82562
82562
|
const CustomCard$3 = styled.div`
|
|
82563
82563
|
visibility: ${({ $isVisible }) => $isVisible ? "visible" : "hidden"};
|
|
82564
82564
|
height: calc(100vh - ${({ $substractHeight }) => $substractHeight}px);
|
|
@@ -82588,7 +82588,15 @@ const Styled$a = {
|
|
|
82588
82588
|
ProgressContainer
|
|
82589
82589
|
};
|
|
82590
82590
|
|
|
82591
|
-
const XTerminal$1 = ({
|
|
82591
|
+
const XTerminal$1 = ({
|
|
82592
|
+
endpoint,
|
|
82593
|
+
nodeName,
|
|
82594
|
+
profile,
|
|
82595
|
+
isCustomTemplate,
|
|
82596
|
+
podTemplateNamespace,
|
|
82597
|
+
containerName,
|
|
82598
|
+
substractHeight
|
|
82599
|
+
}) => {
|
|
82592
82600
|
const [isLoading, setIsLoading] = useState(true);
|
|
82593
82601
|
const [error, setError] = useState();
|
|
82594
82602
|
const [isTerminalVisible, setIsTerminalVisible] = useState(false);
|
|
@@ -82633,12 +82641,13 @@ const XTerminal$1 = ({ endpoint, nodeName, profile, substractHeight }) => {
|
|
|
82633
82641
|
const socket = new WebSocket(endpoint);
|
|
82634
82642
|
socketRef.current = socket;
|
|
82635
82643
|
socket.onopen = () => {
|
|
82636
|
-
|
|
82637
|
-
|
|
82638
|
-
|
|
82639
|
-
|
|
82640
|
-
|
|
82641
|
-
|
|
82644
|
+
const payload = { nodeName, profile };
|
|
82645
|
+
if (isCustomTemplate) {
|
|
82646
|
+
payload.podTemplateName = profile;
|
|
82647
|
+
payload.podTemplateNamespace = podTemplateNamespace;
|
|
82648
|
+
payload.containerName = containerName;
|
|
82649
|
+
}
|
|
82650
|
+
socket.send(JSON.stringify({ type: "init", payload }));
|
|
82642
82651
|
console.log(`[${nodeName}/${profile}]: WebSocket Client Connected`);
|
|
82643
82652
|
setIsLoading(false);
|
|
82644
82653
|
};
|
|
@@ -82712,7 +82721,7 @@ const XTerminal$1 = ({ endpoint, nodeName, profile, substractHeight }) => {
|
|
|
82712
82721
|
socket.close();
|
|
82713
82722
|
}
|
|
82714
82723
|
};
|
|
82715
|
-
}, [terminal, endpoint, nodeName, profile]);
|
|
82724
|
+
}, [terminal, endpoint, nodeName, profile, isCustomTemplate, podTemplateNamespace, containerName]);
|
|
82716
82725
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
82717
82726
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Styled$a.CustomCard, { $isVisible: isTerminalVisible, $substractHeight: substractHeight, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$a.FullWidthDiv, { $substractHeight: substractHeight, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: terminalRef, style: { width: "100%", height: "100%" } }) }) }),
|
|
82718
82727
|
!isTerminalVisible && !error && isWarmingUp && /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$a.ProgressContainer, { $substractHeight: substractHeight, children: [
|
|
@@ -82740,32 +82749,110 @@ const Styled$9 = {
|
|
|
82740
82749
|
CustomSelect: CustomSelect$2
|
|
82741
82750
|
};
|
|
82742
82751
|
|
|
82743
|
-
const
|
|
82752
|
+
const PREDEFINED_PROFILES = ["legacy", "general", "baseline", "netadmin", "restricted", "sysadmin"];
|
|
82753
|
+
const NodeTerminal = ({
|
|
82754
|
+
cluster,
|
|
82755
|
+
nodeName,
|
|
82756
|
+
substractHeight,
|
|
82757
|
+
defaultProfile,
|
|
82758
|
+
listPodTemplatesNs
|
|
82759
|
+
}) => {
|
|
82744
82760
|
const [currentProfile, setCurrentProfile] = useState(defaultProfile || "general");
|
|
82761
|
+
const [currentContainer, setCurrentContainer] = useState();
|
|
82745
82762
|
const endpoint = `/api/clusters/${cluster}/openapi-bff-ws/terminal/terminalNode/terminalNode`;
|
|
82746
|
-
const
|
|
82763
|
+
const isUsingPodTemplates = Boolean(listPodTemplatesNs && listPodTemplatesNs.length > 0);
|
|
82764
|
+
const podTemplatesWsUrl = `/api/clusters/${cluster}/openapi-bff-ws/listThenWatch/listWatchWs`;
|
|
82765
|
+
const podTemplates = useListWatch({
|
|
82766
|
+
wsUrl: podTemplatesWsUrl,
|
|
82767
|
+
query: {
|
|
82768
|
+
apiVersion: "v1",
|
|
82769
|
+
plural: "podtemplates",
|
|
82770
|
+
namespace: listPodTemplatesNs
|
|
82771
|
+
},
|
|
82772
|
+
isEnabled: isUsingPodTemplates
|
|
82773
|
+
});
|
|
82774
|
+
const podTemplateNames = useMemo(() => {
|
|
82775
|
+
const values = Object.values(podTemplates.state.byKey ?? {}).map((it) => String(it?.metadata?.name ?? "")).filter(Boolean);
|
|
82776
|
+
return Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
|
|
82777
|
+
}, [podTemplates.state.byKey]);
|
|
82778
|
+
const hasPodTemplates = podTemplateNames.length > 0;
|
|
82779
|
+
const isPodTemplatesExist = isUsingPodTemplates && hasPodTemplates;
|
|
82780
|
+
useEffect(() => {
|
|
82781
|
+
if (hasPodTemplates && !podTemplateNames.includes(currentProfile)) {
|
|
82782
|
+
setCurrentProfile(podTemplateNames[0]);
|
|
82783
|
+
} else if (!hasPodTemplates && !PREDEFINED_PROFILES.includes(currentProfile)) {
|
|
82784
|
+
setCurrentProfile(defaultProfile || "general");
|
|
82785
|
+
}
|
|
82786
|
+
}, [hasPodTemplates, podTemplateNames, currentProfile, defaultProfile]);
|
|
82787
|
+
const containerNames = useMemo(() => {
|
|
82788
|
+
if (!isPodTemplatesExist) {
|
|
82789
|
+
return [];
|
|
82790
|
+
}
|
|
82791
|
+
const selectedTemplate = Object.values(podTemplates.state.byKey ?? {}).find(
|
|
82792
|
+
(it) => it?.metadata?.name === currentProfile
|
|
82793
|
+
);
|
|
82794
|
+
const containers = selectedTemplate?.template?.spec?.containers ?? [];
|
|
82795
|
+
return containers.map((c) => c.name).filter((name) => Boolean(name));
|
|
82796
|
+
}, [isPodTemplatesExist, podTemplates.state.byKey, currentProfile]);
|
|
82797
|
+
const hasMultipleContainers = containerNames.length > 1;
|
|
82798
|
+
useEffect(() => {
|
|
82799
|
+
if (isPodTemplatesExist && containerNames.length > 0) {
|
|
82800
|
+
setCurrentContainer(containerNames[0]);
|
|
82801
|
+
} else {
|
|
82802
|
+
setCurrentContainer(void 0);
|
|
82803
|
+
}
|
|
82804
|
+
}, [isPodTemplatesExist, containerNames]);
|
|
82805
|
+
const selectOptions = useMemo(() => {
|
|
82806
|
+
if (hasPodTemplates) {
|
|
82807
|
+
return podTemplateNames.map((name) => ({ value: name, label: name }));
|
|
82808
|
+
}
|
|
82809
|
+
return PREDEFINED_PROFILES.map((profile) => ({
|
|
82810
|
+
value: profile,
|
|
82811
|
+
label: profile
|
|
82812
|
+
}));
|
|
82813
|
+
}, [hasPodTemplates, podTemplateNames]);
|
|
82814
|
+
const canShowTerminal = currentProfile && (!isPodTemplatesExist || currentContainer);
|
|
82747
82815
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
82748
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
82749
|
-
|
|
82750
|
-
|
|
82751
|
-
|
|
82752
|
-
|
|
82753
|
-
|
|
82754
|
-
|
|
82755
|
-
|
|
82756
|
-
|
|
82757
|
-
|
|
82758
|
-
|
|
82816
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 16, children: [
|
|
82817
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.CustomSelect, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82818
|
+
Select,
|
|
82819
|
+
{
|
|
82820
|
+
placeholder: "Select profile",
|
|
82821
|
+
options: selectOptions,
|
|
82822
|
+
filterOption: filterSelectOptions,
|
|
82823
|
+
showSearch: true,
|
|
82824
|
+
value: currentProfile,
|
|
82825
|
+
onChange: (value) => {
|
|
82826
|
+
setCurrentProfile(value);
|
|
82827
|
+
setCurrentContainer(void 0);
|
|
82828
|
+
}
|
|
82829
|
+
}
|
|
82830
|
+
) }),
|
|
82831
|
+
isPodTemplatesExist && hasMultipleContainers && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.CustomSelect, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82832
|
+
Select,
|
|
82833
|
+
{
|
|
82834
|
+
placeholder: "Select container",
|
|
82835
|
+
options: containerNames.map((name) => ({ value: name, label: name })),
|
|
82836
|
+
filterOption: filterSelectOptions,
|
|
82837
|
+
showSearch: true,
|
|
82838
|
+
value: currentContainer,
|
|
82839
|
+
onChange: (value) => setCurrentContainer(value)
|
|
82840
|
+
}
|
|
82841
|
+
) })
|
|
82842
|
+
] }),
|
|
82759
82843
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Spacer$1, { $space: 16, $samespace: true }),
|
|
82760
|
-
|
|
82844
|
+
canShowTerminal && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82761
82845
|
XTerminal$1,
|
|
82762
82846
|
{
|
|
82763
82847
|
endpoint,
|
|
82764
82848
|
nodeName,
|
|
82765
82849
|
profile: currentProfile,
|
|
82850
|
+
isCustomTemplate: isPodTemplatesExist,
|
|
82851
|
+
podTemplateNamespace: isPodTemplatesExist ? listPodTemplatesNs : void 0,
|
|
82852
|
+
containerName: isPodTemplatesExist ? currentContainer : void 0,
|
|
82766
82853
|
substractHeight
|
|
82767
82854
|
},
|
|
82768
|
-
`${cluster}-${nodeName}-${currentProfile}`
|
|
82855
|
+
`${cluster}-${nodeName}-${listPodTemplatesNs}-${currentProfile}-${currentContainer}`
|
|
82769
82856
|
)
|
|
82770
82857
|
] });
|
|
82771
82858
|
};
|
|
@@ -85412,19 +85499,6 @@ const useCrdData = ({
|
|
|
85412
85499
|
});
|
|
85413
85500
|
};
|
|
85414
85501
|
|
|
85415
|
-
const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
|
|
85416
|
-
useEffect(() => {
|
|
85417
|
-
const el = sentinelRef.current;
|
|
85418
|
-
if (!el) return void 0;
|
|
85419
|
-
const io = new IntersectionObserver((entries) => {
|
|
85420
|
-
const visible = entries.some((e) => e.isIntersecting);
|
|
85421
|
-
if (visible && hasMore) onNeedMore();
|
|
85422
|
-
});
|
|
85423
|
-
io.observe(el);
|
|
85424
|
-
return () => io.disconnect();
|
|
85425
|
-
}, [sentinelRef, hasMore, onNeedMore]);
|
|
85426
|
-
};
|
|
85427
|
-
|
|
85428
85502
|
const useResourceScope = ({ plural, cluster, apiGroup, apiVersion }) => {
|
|
85429
85503
|
const computedResourceType = apiGroup ? "api" : "builtin";
|
|
85430
85504
|
const enabled = Boolean(cluster) && Boolean(plural) && (computedResourceType === "builtin" || Boolean(apiVersion));
|