@prorobotech/openapi-k8s-toolkit 1.4.0-alpha.17 → 1.4.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.
@@ -8754,6 +8754,7 @@ const useDirectUnknownResource = ({
8754
8754
  uri,
8755
8755
  queryKey,
8756
8756
  refetchInterval,
8757
+ staleTime,
8757
8758
  isEnabled
8758
8759
  }) => {
8759
8760
  return useQuery({
@@ -8769,6 +8770,7 @@ const useDirectUnknownResource = ({
8769
8770
  return data;
8770
8771
  },
8771
8772
  refetchInterval: refetchInterval !== void 0 ? refetchInterval : 5e3,
8773
+ staleTime,
8772
8774
  enabled: isEnabled
8773
8775
  });
8774
8776
  };
@@ -8789,6 +8791,7 @@ const useK8sVerbs = ({
8789
8791
  uri,
8790
8792
  queryKey: ["k8s-verbs", cluster, group || "", version, plural],
8791
8793
  refetchInterval: false,
8794
+ staleTime: 5 * 60 * 1e3,
8792
8795
  isEnabled: Boolean(isEnabled && cluster && version && plural)
8793
8796
  });
8794
8797
  const verbs = data?.verbs || [];
@@ -9122,8 +9125,14 @@ const useListWatch = ({
9122
9125
  return;
9123
9126
  }
9124
9127
  if (frame.type === "INITIAL_ERROR") {
9125
- const msg = frame.message;
9128
+ const needsCodeSuffix = typeof frame.statusCode === "number" && !frame.message.includes(`(${frame.statusCode})`);
9129
+ const msg = needsCodeSuffix ? `${frame.message} (${frame.statusCode})` : frame.message;
9126
9130
  setErrorSafe(msg);
9131
+ console.error("[useListWatch][initial]", {
9132
+ message: frame.message,
9133
+ statusCode: frame.statusCode,
9134
+ reason: frame.reason
9135
+ });
9127
9136
  return;
9128
9137
  }
9129
9138
  if (frame.type === "INITIAL") {
@@ -9429,10 +9438,11 @@ const useK8sSmartResourceWithoutKinds = ({
9429
9438
  [watchEnabled, state, mapListWatchState]
9430
9439
  );
9431
9440
  const used = !isEnabled ? "disabled" : verbsLoading ? "verbs-loading" : verbsIsError ? "verbs-error" : watchEnabled ? "watch" : restEnabled ? "list" : "disabled";
9432
- const isLoading = isEnabled && verbsLoading || used === "watch" && status === "connecting" || used === "watch" && status === "open" && !hasInitial || used === "list" && restLoading;
9441
+ const watchHasBlockingError = used === "watch" && Boolean(lastError) && (!hasInitial || status === "closed");
9442
+ const isLoading = isEnabled && verbsLoading || used === "watch" && status === "connecting" || used === "watch" && status === "open" && !hasInitial && !watchHasBlockingError || used === "list" && restLoading;
9433
9443
  let error;
9434
9444
  if (verbsIsError) error = verbsErrorObj;
9435
- else if (used === "watch" && status === "closed" && lastError) error = lastError;
9445
+ else if (watchHasBlockingError) error = lastError;
9436
9446
  else if (used === "list" && restIsError) error = restError;
9437
9447
  const isError = Boolean(error);
9438
9448
  const data = used === "watch" ? watchData : used === "list" ? restData : void 0;
@@ -35271,6 +35281,28 @@ const ParsedText = ({ data }) => {
35271
35281
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: data.style, children: formattedText });
35272
35282
  };
35273
35283
 
35284
+ const MappedParsedText = ({ data }) => {
35285
+ const { value, valueMap, style } = data;
35286
+ const { data: multiQueryData, isLoading, isError, errors } = useMultiQuery();
35287
+ const partsOfUrl = usePartsOfUrl();
35288
+ if (isLoading) {
35289
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
35290
+ }
35291
+ if (isError) {
35292
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35293
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
35294
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
35295
+ ] });
35296
+ }
35297
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, item, index) => {
35298
+ acc[index.toString()] = item;
35299
+ return acc;
35300
+ }, {});
35301
+ const parsedValue = parseAll({ text: value, replaceValues, multiQueryData });
35302
+ const renderedValue = Object.prototype.hasOwnProperty.call(valueMap, parsedValue) ? valueMap[parsedValue] : parsedValue;
35303
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style, children: renderedValue });
35304
+ };
35305
+
35274
35306
  const ProjectInfoCard$1 = ({
35275
35307
  data,
35276
35308
  children
@@ -35712,7 +35744,7 @@ const EnrichedTable$1 = ({
35712
35744
  if (k8sResourceToFetchPrepared && fetchedDataSocketError) {
35713
35745
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
35714
35746
  "Error: ",
35715
- JSON.stringify(fetchedDataError)
35747
+ JSON.stringify(fetchedDataSocketError)
35716
35748
  ] });
35717
35749
  }
35718
35750
  const dataFromOneOfHooks = fetchedData || fetchedDataSocket || {};
@@ -47361,6 +47393,18 @@ const serializeLabelsWithNoEncoding = (input) => {
47361
47393
  return entries.map(([k, v]) => `${k}=${v}`).join(",");
47362
47394
  };
47363
47395
 
47396
+ const extractStatusCode = (error) => {
47397
+ const asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
47398
+ const toCode = (value) => {
47399
+ if (typeof value === "number" && Number.isFinite(value)) return value;
47400
+ if (typeof value === "string" && /^\d+$/.test(value)) return Number(value);
47401
+ return void 0;
47402
+ };
47403
+ const root = asRecord(error) || {};
47404
+ const response = asRecord(root.response) || {};
47405
+ const body = asRecord(root.body) || {};
47406
+ return toCode(response.status) ?? toCode(root.statusCode) ?? toCode(root.status) ?? toCode(root.code) ?? toCode(body.code);
47407
+ };
47364
47408
  const Events$1 = ({
47365
47409
  data,
47366
47410
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -47429,9 +47473,48 @@ const Events$1 = ({
47429
47473
  }
47430
47474
  const searchParams = params.toString();
47431
47475
  const wsUrlWithParams = `${wsUrlPrepared}${searchParams ? `?${searchParams}` : ""}`;
47476
+ const namespaceFromWsUrl = (() => {
47477
+ try {
47478
+ const parsedUrl = new URL(wsUrlWithParams, window.location.origin);
47479
+ const namespace = parsedUrl.searchParams.get("namespace");
47480
+ return namespace && namespace.length > 0 ? namespace : void 0;
47481
+ } catch {
47482
+ return void 0;
47483
+ }
47484
+ })();
47485
+ const isPermissionCheckEnabled = Boolean(!isMultiqueryLoading && clusterPrepared);
47486
+ const listPermission = usePermissions({
47487
+ cluster: clusterPrepared || "",
47488
+ namespace: namespaceFromWsUrl,
47489
+ apiGroup: "events.k8s.io",
47490
+ plural: "events",
47491
+ verb: "list",
47492
+ refetchInterval: false,
47493
+ enabler: isPermissionCheckEnabled
47494
+ });
47495
+ const watchPermission = usePermissions({
47496
+ cluster: clusterPrepared || "",
47497
+ namespace: namespaceFromWsUrl,
47498
+ apiGroup: "events.k8s.io",
47499
+ plural: "events",
47500
+ verb: "watch",
47501
+ refetchInterval: false,
47502
+ enabler: isPermissionCheckEnabled
47503
+ });
47432
47504
  if (isMultiqueryLoading) {
47433
47505
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
47434
47506
  }
47507
+ if (isPermissionCheckEnabled && (listPermission.isPending || watchPermission.isPending)) {
47508
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { type: "info", message: "Checking permissions for events stream...", showIcon: true }) });
47509
+ }
47510
+ if (isPermissionCheckEnabled && (listPermission.isError || watchPermission.isError)) {
47511
+ const statusCode = extractStatusCode(listPermission.error) ?? extractStatusCode(watchPermission.error);
47512
+ const message = statusCode ? `Failed to check permissions for events stream (${statusCode})` : "Failed to check permissions for events stream";
47513
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { type: "error", message, showIcon: true }) });
47514
+ }
47515
+ if (isPermissionCheckEnabled && (listPermission.data?.status?.allowed !== true || watchPermission.data?.status?.allowed !== true)) {
47516
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { type: "error", message: "Access denied (403)", showIcon: true }) });
47517
+ }
47435
47518
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47436
47519
  /* @__PURE__ */ jsxRuntimeExports.jsx(
47437
47520
  Events,
@@ -78596,7 +78679,7 @@ const TolerationsModal = ({
78596
78679
  };
78597
78680
 
78598
78681
  const LazyEnrichedTableModal = lazy(
78599
- () => import('./index-CTYM2Lu_.mjs').then((mod) => ({ default: mod.EnrichedTableModal }))
78682
+ () => import('./index-Cs_5F1Gd.mjs').then((mod) => ({ default: mod.EnrichedTableModal }))
78600
78683
  );
78601
78684
  const renderActiveType = (activeType, extraProps) => {
78602
78685
  if (!activeType) return null;
@@ -81262,6 +81345,7 @@ const DynamicComponents = {
81262
81345
  partsOfUrl: PartsOfUrl,
81263
81346
  multiQuery: MultiQuery,
81264
81347
  parsedText: ParsedText,
81348
+ MappedParsedText,
81265
81349
  ProjectInfoCard: ProjectInfoCard$1,
81266
81350
  MarketplaceCard: MarketplaceCard$1,
81267
81351
  ContentCard,
@@ -89973,6 +90057,7 @@ const Events = ({
89973
90057
  const [hasMore, setHasMore] = useState(false);
89974
90058
  const [connStatus, setConnStatus] = useState("connecting");
89975
90059
  const [lastError, setLastError] = useState(void 0);
90060
+ const [fatalError, setFatalError] = useState(void 0);
89976
90061
  const wsRef = useRef(null);
89977
90062
  const listRef = useRef(null);
89978
90063
  const sentinelRef = useRef(null);
@@ -90018,11 +90103,31 @@ const Events = ({
90018
90103
  return;
90019
90104
  }
90020
90105
  if (!frame) return;
90106
+ if (frame.type === "SERVER_LOG") {
90107
+ const level = frame.level || "info";
90108
+ const msg = frame.message;
90109
+ (console[level] || console.log).call(console, "[Events][server]", msg);
90110
+ return;
90111
+ }
90112
+ if (frame.type === "INITIAL_ERROR") {
90113
+ const needsCodeSuffix = typeof frame.statusCode === "number" && !frame.message.includes(`(${frame.statusCode})`);
90114
+ const msg = needsCodeSuffix ? `${frame.message} (${frame.statusCode})` : frame.message;
90115
+ setFatalError(msg);
90116
+ setLastError(msg);
90117
+ fetchingRef.current = false;
90118
+ console.error("[Events][initial]", {
90119
+ message: frame.message,
90120
+ statusCode: frame.statusCode,
90121
+ reason: frame.reason
90122
+ });
90123
+ return;
90124
+ }
90021
90125
  if (frame.type === "INITIAL") {
90022
90126
  dispatch({ type: "RESET", items: frame.items });
90023
90127
  setContToken(frame.continue);
90024
90128
  setHasMore(Boolean(frame.continue));
90025
90129
  setLastError(void 0);
90130
+ setFatalError(void 0);
90026
90131
  fetchingRef.current = false;
90027
90132
  const snapshotRV = frame.resourceVersion || getMaxRV(frame.items);
90028
90133
  if (snapshotRV) {
@@ -90170,6 +90275,29 @@ const Events = ({
90170
90275
  const total = state.order.length;
90171
90276
  const getPlural = kindsData?.kindsWithVersion ? pluralByKind(kindsData?.kindsWithVersion) : void 0;
90172
90277
  const baseFactoriesMapping = navigationDataArr && navigationDataArr.items && navigationDataArr.items.length > 0 ? navigationDataArr.items[0].spec?.baseFactoriesMapping : void 0;
90278
+ const listContent = (() => {
90279
+ if (fatalError && state.order.length === 0) return /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { type: "error", message: fatalError, showIcon: true });
90280
+ if (state.order.length > 0) {
90281
+ return state.order.map((k) => /* @__PURE__ */ jsxRuntimeExports.jsx(
90282
+ EventRow,
90283
+ {
90284
+ e: state.byKey[k],
90285
+ theme: theme$1,
90286
+ baseprefix,
90287
+ cluster,
90288
+ getPlural,
90289
+ baseFactoryNamespacedAPIKey,
90290
+ baseFactoryClusterSceopedAPIKey,
90291
+ baseFactoryNamespacedBuiltinKey,
90292
+ baseFactoryClusterSceopedBuiltinKey,
90293
+ baseNamespaceFactoryKey,
90294
+ baseFactoriesMapping
90295
+ },
90296
+ k
90297
+ ));
90298
+ }
90299
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Empty, { description: "No events" });
90300
+ })();
90173
90301
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.Root, { $substractHeight: substractHeight || 340, children: [
90174
90302
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.Header, { children: [
90175
90303
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.HeaderLeftSide, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { justify: "start", align: "center", gap: 10, children: [
@@ -90218,23 +90346,7 @@ const Events = ({
90218
90346
  ] })
90219
90347
  ] }),
90220
90348
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.List, { ref: listRef, onScroll, children: [
90221
- state.order.length > 0 ? state.order.map((k) => /* @__PURE__ */ jsxRuntimeExports.jsx(
90222
- EventRow,
90223
- {
90224
- e: state.byKey[k],
90225
- theme: theme$1,
90226
- baseprefix,
90227
- cluster,
90228
- getPlural,
90229
- baseFactoryNamespacedAPIKey,
90230
- baseFactoryClusterSceopedAPIKey,
90231
- baseFactoryNamespacedBuiltinKey,
90232
- baseFactoryClusterSceopedBuiltinKey,
90233
- baseNamespaceFactoryKey,
90234
- baseFactoriesMapping
90235
- },
90236
- k
90237
- )) : /* @__PURE__ */ jsxRuntimeExports.jsx(Empty, { description: "No events" }),
90349
+ listContent,
90238
90350
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.Sentinel, { ref: sentinelRef })
90239
90351
  ] }),
90240
90352
  state.order.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.Timeline, { $colorText: token.colorText, $substractHeight: substractHeight || 340 })
@@ -90876,4 +90988,4 @@ const usePluginManifest = ({
90876
90988
  };
90877
90989
 
90878
90990
  export { useInfiniteSentinel as $, getBuiltinResourceTypes as A, getCrdData as B, getDirectUnknownResource as C, DeleteIcon as D, EnrichedTableProvider as E, checkPermission as F, getSwagger as G, filterIfApiInstanceNamespaceScoped as H, filterIfBuiltInInstanceNamespaceScoped as I, checkIfApiInstanceNamespaceScoped as J, checkIfBuiltInInstanceNamespaceScoped as K, getKinds as L, useClusterList as M, useApiResources as N, useApiResourceSingle as O, PaddingContainer as P, useBuiltinResources as Q, ReadOnlyModal as R, useBuiltinResourceSingle as S, useCrdResources as T, useCrdResourceSingle as U, useApisResourceTypes as V, useApiResourceTypesByGroup as W, useBuiltinResourceTypes as X, useCrdData as Y, useListWatch as Z, _$1 as _, useTheme as a, parseQuotaValueCpu as a$, useK8sVerbs as a0, useManyK8sSmartResource as a1, useSmartResourceParams as a2, useResourceScope as a3, useKinds as a4, usePluginManifest as a5, Spacer$1 as a6, TreeWithSearch as a7, ConfirmModal as a8, UpIcon as a9, EnrichedTable as aA, ClusterListTable as aB, getEnrichedColumns as aC, getEnrichedColumnsWithControls as aD, YamlEditorSingleton$1 as aE, BlackholeFormProvider as aF, BlackholeForm as aG, getObjectFormItemsDraft as aH, MarketPlace as aI, MarketplaceCard as aJ, ProjectInfoCard as aK, PodTerminal as aL, NodeTerminal as aM, PodLogs as aN, PodLogsMonaco as aO, VMVNC as aP, Search as aQ, Events as aR, DynamicRenderer as aS, DynamicComponents as aT, DynamicRendererWithProviders as aU, prepareTemplate as aV, isFlatObject as aW, filterSelectOptions as aX, getStringByName as aY, floorToDecimal as aZ, parseQuotaValue as a_, DownIcon as aa, BackToDefaultIcon as ab, SuccessIcon as ac, feedbackIcons as ad, PlusIcon as ae, MinusIcon as af, LockedIcon as ag, UnlockedIcon as ah, PauseCircleIcon as ai, ResumeCircleIcon as aj, LookingGlassIcon as ak, EarthIcon as al, ContentCard$1 as am, FlexGrow as an, UncontrolledSelect as ao, CustomSelect$4 as ap, CursorPointerTag as aq, CursorPointerTagMinContent as ar, CursorDefaultDiv as as, ResourceLink as at, ManageableBreadcrumbsProvider as au, prepareDataForManageableBreadcrumbs as av, ManageableBreadcrumbs as aw, ManageableSidebarProvider as ax, prepareDataForManageableSidebar as ay, ManageableSidebar as az, usePartsOfUrl as b, parseQuotaValueMemoryAndStorage as b0, normalizeValuesForQuotasToNumber as b1, getAllPathsFromObj as b2, getPrefixSubarrays as b3, groupsToTreeData as b4, getBuiltinTreeData as b5, getGroupsByCategory as b6, createContextFactory as b7, prepareUrlsToFetchForDynamicRenderer as b8, deepMerge as b9, getSortedKinds as ba, getSortedKindsAll as bb, hslFromString as bc, getUppercase as bd, kindByGvr as be, pluralByKind as bf, namespacedByGvr as bg, getLinkToBuiltinForm as bh, getLinkToApiForm as bi, isMultilineString as bj, isMultilineFromYaml as bk, includesArray as bl, getResourceLink as bm, getNamespaceLink as bn, convertBytes as bo, formatBytesAuto as bp, toBytes as bq, convertStorage as br, parseValueWithUnit as bs, convertCores as bt, formatCoresAuto as bu, toCores as bv, convertCompute as bw, parseCoresWithUnit as bx, formatDateAuto as by, isValidRFC3339 as bz, usePermissions as c, useDirectUnknownResource as d, useK8sSmartResource as e, jsxRuntimeExports as f, EditIcon as g, getLinkToForm as h, DeleteModal as i, jp as j, DeleteModalMany as k, getClusterList as l, createNewEntry as m, updateEntry as n, deleteEntry as o, parseAll as p, getApiResources as q, getApiResourceSingle as r, serializeLabelsWithNoEncoding$1 as s, getBuiltinResources as t, useMultiQuery as u, getBuiltinResourceSingle as v, getCrdResources as w, getCrdResourceSingle as x, getApiResourceTypes as y, getApiResourceTypesByApiGroup as z };
90879
- //# sourceMappingURL=index-B50_esSW.mjs.map
90991
+ //# sourceMappingURL=index-BLeZv2uT.mjs.map