@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.7 → 1.2.0-alpha.9
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 +138 -80
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +138 -79
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResource.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useK8sSmartResourceWithoutKinds.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useManyK8sSmartResource.d.ts +1 -0
- package/dist/types/hooks/useK8sSmartResource/useSmartResourceParams.d.ts +5 -5
- package/dist/types/hooks/useListThenWatch/useListWatch.d.ts +1 -0
- package/dist/types/hooks/useResourceScope/index.d.ts +1 -0
- package/dist/types/hooks/useResourceScope/useResourceScope.d.ts +12 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8802,6 +8802,7 @@
|
|
|
8802
8802
|
}) => {
|
|
8803
8803
|
const resId = `${query.apiGroup ?? ""}|${query.apiVersion}|${query.plural}|${query.namespace ?? ""}|${query.fieldSelector ?? ""}|${query.labelSelector ?? ""}`;
|
|
8804
8804
|
const resIdRef = K.useRef(resId);
|
|
8805
|
+
const [debugTick, bumpTick] = K.useReducer((x) => x + 1, 0);
|
|
8805
8806
|
const [state, dispatch] = K.useReducer(reducer$1, { order: [], byKey: {} });
|
|
8806
8807
|
const [contToken, setContToken] = K.useState();
|
|
8807
8808
|
const [hasMore, setHasMore] = K.useState(false);
|
|
@@ -9049,6 +9050,7 @@
|
|
|
9049
9050
|
}
|
|
9050
9051
|
if (frame.type === "INITIAL") {
|
|
9051
9052
|
dispatch({ type: "RESET", items: frame.items });
|
|
9053
|
+
bumpTick();
|
|
9052
9054
|
setContToken(frame.continue);
|
|
9053
9055
|
setHasMore(Boolean(frame.continue));
|
|
9054
9056
|
setErrorSafe(void 0);
|
|
@@ -9064,6 +9066,7 @@
|
|
|
9064
9066
|
}
|
|
9065
9067
|
if (frame.type === "PAGE") {
|
|
9066
9068
|
dispatch({ type: "APPEND_PAGE", items: frame.items });
|
|
9069
|
+
bumpTick();
|
|
9067
9070
|
setContToken(frame.continue);
|
|
9068
9071
|
setHasMore(Boolean(frame.continue));
|
|
9069
9072
|
fetchingRef.current = false;
|
|
@@ -9086,9 +9089,11 @@
|
|
|
9086
9089
|
}
|
|
9087
9090
|
if (!pausedRef.current) {
|
|
9088
9091
|
if (frame.type === "ADDED" || frame.type === "MODIFIED") {
|
|
9092
|
+
bumpTick();
|
|
9089
9093
|
dispatch({ type: "UPSERT", item: frame.item });
|
|
9090
9094
|
}
|
|
9091
9095
|
if (!ignoreRemoveRef.current && frame.type === "DELETED") {
|
|
9096
|
+
bumpTick();
|
|
9092
9097
|
dispatch({ type: "REMOVE", key: eventKey$1(frame.item) });
|
|
9093
9098
|
}
|
|
9094
9099
|
}
|
|
@@ -9229,7 +9234,8 @@
|
|
|
9229
9234
|
drainAll,
|
|
9230
9235
|
reconnect,
|
|
9231
9236
|
setUrl,
|
|
9232
|
-
setQuery
|
|
9237
|
+
setQuery,
|
|
9238
|
+
debugTick
|
|
9233
9239
|
};
|
|
9234
9240
|
};
|
|
9235
9241
|
|
|
@@ -9320,7 +9326,7 @@
|
|
|
9320
9326
|
const watchEnabled = Boolean(
|
|
9321
9327
|
cluster && cluster.length > 0 && isEnabled && canList && canWatch && !verbsLoading && !verbsIsError
|
|
9322
9328
|
);
|
|
9323
|
-
const { state, status, hasInitial, lastError } = useListWatch({
|
|
9329
|
+
const { state, status, hasInitial, lastError, debugTick } = useListWatch({
|
|
9324
9330
|
wsUrl: `/api/clusters/${cluster}/openapi-bff-ws/listThenWatch/listWatchWs`,
|
|
9325
9331
|
paused: false,
|
|
9326
9332
|
ignoreRemove: false,
|
|
@@ -9352,7 +9358,7 @@
|
|
|
9352
9358
|
else if (used === "list" && restIsError) error = restError;
|
|
9353
9359
|
const isError = Boolean(error);
|
|
9354
9360
|
const data = used === "watch" ? watchData : used === "list" ? restData : void 0;
|
|
9355
|
-
return { data, isLoading, isError, error, _meta: { used } };
|
|
9361
|
+
return { data, isLoading, isError, error, _meta: { used }, debugTick };
|
|
9356
9362
|
};
|
|
9357
9363
|
|
|
9358
9364
|
const hasItemsArray = (value) => {
|
|
@@ -9439,22 +9445,98 @@
|
|
|
9439
9445
|
return results;
|
|
9440
9446
|
};
|
|
9441
9447
|
|
|
9448
|
+
const checkIfApiInstanceNamespaceScoped = async ({
|
|
9449
|
+
plural,
|
|
9450
|
+
apiGroup,
|
|
9451
|
+
apiVersion,
|
|
9452
|
+
cluster
|
|
9453
|
+
}) => {
|
|
9454
|
+
const payload = {
|
|
9455
|
+
plural,
|
|
9456
|
+
apiGroup,
|
|
9457
|
+
apiVersion,
|
|
9458
|
+
cluster
|
|
9459
|
+
};
|
|
9460
|
+
const { data } = await axios.post(
|
|
9461
|
+
`/api/clusters/${cluster}/openapi-bff/scopes/checkScopes/checkIfApiNamespaceScoped`,
|
|
9462
|
+
payload
|
|
9463
|
+
);
|
|
9464
|
+
return data;
|
|
9465
|
+
};
|
|
9466
|
+
const checkIfBuiltInInstanceNamespaceScoped = async ({
|
|
9467
|
+
plural,
|
|
9468
|
+
cluster
|
|
9469
|
+
}) => {
|
|
9470
|
+
const payload = {
|
|
9471
|
+
plural,
|
|
9472
|
+
cluster
|
|
9473
|
+
};
|
|
9474
|
+
const { data } = await axios.post(
|
|
9475
|
+
`/api/clusters/${cluster}/openapi-bff/scopes/checkScopes/checkIfBuiltInNamespaceScoped`,
|
|
9476
|
+
payload
|
|
9477
|
+
);
|
|
9478
|
+
return data;
|
|
9479
|
+
};
|
|
9480
|
+
|
|
9442
9481
|
const useSmartResourceParams = ({ cluster, namespace }) => {
|
|
9443
9482
|
const [searchParams] = reactRouterDom.useSearchParams();
|
|
9444
|
-
|
|
9483
|
+
const rawEntries = K.useMemo(() => {
|
|
9445
9484
|
const raw = searchParams.get("resources");
|
|
9446
9485
|
if (!raw) return [];
|
|
9447
9486
|
return raw.split(",").map((entry) => {
|
|
9448
|
-
const [apiGroup = "", apiVersion = "", plural] = entry.split("/");
|
|
9487
|
+
const [apiGroup = "", apiVersion = "", plural = ""] = entry.split("/");
|
|
9488
|
+
const normalizedGroup = apiGroup === "builtin" || apiGroup === "" ? void 0 : apiGroup;
|
|
9449
9489
|
return {
|
|
9450
9490
|
cluster,
|
|
9451
|
-
|
|
9452
|
-
apiGroup:
|
|
9453
|
-
apiVersion
|
|
9454
|
-
|
|
9491
|
+
plural,
|
|
9492
|
+
apiGroup: normalizedGroup,
|
|
9493
|
+
apiVersion
|
|
9494
|
+
};
|
|
9495
|
+
}).filter((e) => Boolean(e.plural));
|
|
9496
|
+
}, [searchParams, cluster]);
|
|
9497
|
+
const scopeQueries = reactQuery.useQueries({
|
|
9498
|
+
queries: rawEntries.map((e) => {
|
|
9499
|
+
const isApi = Boolean(e.apiGroup);
|
|
9500
|
+
return {
|
|
9501
|
+
queryKey: ["resource-scope", e.cluster, isApi ? e.apiGroup : "builtin", e.apiVersion ?? "", e.plural],
|
|
9502
|
+
enabled: Boolean(e.cluster && e.plural && (!isApi || e.apiVersion)),
|
|
9503
|
+
queryFn: () => {
|
|
9504
|
+
if (isApi) {
|
|
9505
|
+
return checkIfApiInstanceNamespaceScoped({
|
|
9506
|
+
plural: e.plural,
|
|
9507
|
+
apiGroup: e.apiGroup,
|
|
9508
|
+
apiVersion: e.apiVersion || "",
|
|
9509
|
+
cluster: e.cluster
|
|
9510
|
+
});
|
|
9511
|
+
}
|
|
9512
|
+
return checkIfBuiltInInstanceNamespaceScoped({
|
|
9513
|
+
plural: e.plural,
|
|
9514
|
+
cluster: e.cluster
|
|
9515
|
+
});
|
|
9516
|
+
},
|
|
9517
|
+
staleTime: 5 * 60 * 1e3
|
|
9518
|
+
};
|
|
9519
|
+
})
|
|
9520
|
+
});
|
|
9521
|
+
const scopesLoading = scopeQueries.some((q) => q.isLoading);
|
|
9522
|
+
const scopesError = scopeQueries.find((q) => q.error)?.error;
|
|
9523
|
+
const paramsList = K.useMemo(() => {
|
|
9524
|
+
return rawEntries.map((e, i) => {
|
|
9525
|
+
const isClusterWide = scopeQueries[i]?.data?.isNamespaceScoped === false;
|
|
9526
|
+
return {
|
|
9527
|
+
cluster: e.cluster,
|
|
9528
|
+
plural: e.plural,
|
|
9529
|
+
apiGroup: e.apiGroup,
|
|
9530
|
+
apiVersion: e.apiVersion || "",
|
|
9531
|
+
namespace: isClusterWide ? void 0 : namespace
|
|
9455
9532
|
};
|
|
9456
9533
|
});
|
|
9457
|
-
}, [
|
|
9534
|
+
}, [rawEntries, scopeQueries, namespace]);
|
|
9535
|
+
return {
|
|
9536
|
+
paramsList,
|
|
9537
|
+
scopesLoading,
|
|
9538
|
+
scopesError
|
|
9539
|
+
};
|
|
9458
9540
|
};
|
|
9459
9541
|
|
|
9460
9542
|
const prepareTemplate = ({
|
|
@@ -34099,7 +34181,6 @@
|
|
|
34099
34181
|
const key = String(u).trim().toLowerCase();
|
|
34100
34182
|
const canon = CORE_ALIASES[key];
|
|
34101
34183
|
if (!canon) {
|
|
34102
|
-
console.error(`Unknown core unit: "${u}"`);
|
|
34103
34184
|
return "core";
|
|
34104
34185
|
}
|
|
34105
34186
|
return canon;
|
|
@@ -47071,9 +47152,9 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
47071
47152
|
}
|
|
47072
47153
|
return columns.map((el, colIndex) => {
|
|
47073
47154
|
const possibleAdditionalPrinterColumnsCustomSortersAndFiltersType = additionalPrinterColumnsCustomSortersAndFilters?.find(({ key }) => key === el.key)?.type;
|
|
47074
|
-
const
|
|
47075
|
-
const
|
|
47076
|
-
const
|
|
47155
|
+
const isSortersAndFiltersDisabled = possibleAdditionalPrinterColumnsCustomSortersAndFiltersType === "disabled";
|
|
47156
|
+
const isSortersAndFiltersCPU = possibleAdditionalPrinterColumnsCustomSortersAndFiltersType === "cpu";
|
|
47157
|
+
const isSortersAndFiltersMemory = possibleAdditionalPrinterColumnsCustomSortersAndFiltersType === "memory";
|
|
47077
47158
|
const possibleUndefinedValue = additionalPrinterColumnsUndefinedValues?.find(({ key }) => key === el.key)?.value;
|
|
47078
47159
|
const possibleTrimLength = additionalPrinterColumnsTrimLengths?.find(({ key }) => key === el.key)?.value;
|
|
47079
47160
|
const possibleColWidth = additionalPrinterColumnsColWidths?.find(({ key }) => key === el.key)?.value;
|
|
@@ -47087,36 +47168,25 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
47087
47168
|
if (!cell) return "";
|
|
47088
47169
|
return (cell.innerText || cell.textContent || "").trim().toLowerCase();
|
|
47089
47170
|
};
|
|
47090
|
-
const getEntry = (record) => {
|
|
47091
|
-
const { dataIndex } = el;
|
|
47092
|
-
return Array.isArray(dataIndex) ? lodashExports.get(record, dataIndex) : record[dataIndex];
|
|
47093
|
-
};
|
|
47094
|
-
const getTextForNumericUnitSort = (record) => {
|
|
47095
|
-
if (useFactorySearch) {
|
|
47096
|
-
const textFromDom = getCellTextFromDOM(record);
|
|
47097
|
-
if (textFromDom) return textFromDom;
|
|
47098
|
-
}
|
|
47099
|
-
const raw = getEntry(record);
|
|
47100
|
-
if (raw == null) return null;
|
|
47101
|
-
return String(raw);
|
|
47102
|
-
};
|
|
47103
47171
|
const getMemoryInBytes = (record) => {
|
|
47104
|
-
const text =
|
|
47105
|
-
if (!text) return
|
|
47172
|
+
const text = getCellTextFromDOM(record);
|
|
47173
|
+
if (!text) return 0;
|
|
47106
47174
|
const parsed = parseValueWithUnit(text);
|
|
47107
|
-
if (!parsed) return
|
|
47175
|
+
if (!parsed) return 0;
|
|
47108
47176
|
if (parsed.unit) {
|
|
47109
|
-
|
|
47177
|
+
const bytes = toBytes(parsed.value, parsed.unit);
|
|
47178
|
+
return bytes >= 0 ? bytes : 0;
|
|
47110
47179
|
}
|
|
47111
47180
|
return parsed.value;
|
|
47112
47181
|
};
|
|
47113
47182
|
const getCpuInCores = (record) => {
|
|
47114
|
-
const text =
|
|
47115
|
-
if (!text) return
|
|
47183
|
+
const text = getCellTextFromDOM(record);
|
|
47184
|
+
if (!text) return 0;
|
|
47116
47185
|
const parsed = parseCoresWithUnit(text);
|
|
47117
|
-
if (!parsed) return
|
|
47186
|
+
if (!parsed) return 0;
|
|
47118
47187
|
if (parsed.unit) {
|
|
47119
|
-
|
|
47188
|
+
const cores = toCores(parsed.value, parsed.unit);
|
|
47189
|
+
return cores >= 0 ? cores : 0;
|
|
47120
47190
|
}
|
|
47121
47191
|
return parsed.value;
|
|
47122
47192
|
};
|
|
@@ -47148,7 +47218,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
47148
47218
|
};
|
|
47149
47219
|
},
|
|
47150
47220
|
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => {
|
|
47151
|
-
if (
|
|
47221
|
+
if (isSortersAndFiltersDisabled || isSortersAndFiltersMemory || isSortersAndFiltersCPU) {
|
|
47152
47222
|
return null;
|
|
47153
47223
|
}
|
|
47154
47224
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -47163,13 +47233,13 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
47163
47233
|
);
|
|
47164
47234
|
},
|
|
47165
47235
|
filterIcon: (filtered) => {
|
|
47166
|
-
if (
|
|
47236
|
+
if (isSortersAndFiltersDisabled || isSortersAndFiltersMemory || isSortersAndFiltersCPU) {
|
|
47167
47237
|
return null;
|
|
47168
47238
|
}
|
|
47169
47239
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(icons.SearchOutlined, { style: { color: filtered ? "#1677ff" : void 0 } });
|
|
47170
47240
|
},
|
|
47171
47241
|
onFilter: (value, record) => {
|
|
47172
|
-
if (
|
|
47242
|
+
if (isSortersAndFiltersDisabled || isSortersAndFiltersMemory || isSortersAndFiltersCPU) {
|
|
47173
47243
|
return false;
|
|
47174
47244
|
}
|
|
47175
47245
|
if (useFactorySearch) {
|
|
@@ -47196,22 +47266,22 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
47196
47266
|
}
|
|
47197
47267
|
return false;
|
|
47198
47268
|
},
|
|
47199
|
-
sorter:
|
|
47200
|
-
if (
|
|
47201
|
-
const aText = getCellTextFromDOM(a);
|
|
47202
|
-
const bText = getCellTextFromDOM(b);
|
|
47203
|
-
return aText.localeCompare(bText);
|
|
47204
|
-
}
|
|
47205
|
-
if (isSortersAndFitlersMemory) {
|
|
47269
|
+
sorter: isSortersAndFiltersDisabled ? false : (a, b) => {
|
|
47270
|
+
if (isSortersAndFiltersMemory) {
|
|
47206
47271
|
const aBytes = getMemoryInBytes(a);
|
|
47207
47272
|
const bBytes = getMemoryInBytes(b);
|
|
47208
47273
|
return safeNumericCompare(aBytes, bBytes);
|
|
47209
47274
|
}
|
|
47210
|
-
if (
|
|
47275
|
+
if (isSortersAndFiltersCPU) {
|
|
47211
47276
|
const aCores = getCpuInCores(a);
|
|
47212
47277
|
const bCores = getCpuInCores(b);
|
|
47213
47278
|
return safeNumericCompare(aCores, bCores);
|
|
47214
47279
|
}
|
|
47280
|
+
if (useFactorySearch) {
|
|
47281
|
+
const aText = getCellTextFromDOM(a);
|
|
47282
|
+
const bText = getCellTextFromDOM(b);
|
|
47283
|
+
return aText.localeCompare(bText);
|
|
47284
|
+
}
|
|
47215
47285
|
const { dataIndex } = el;
|
|
47216
47286
|
const aEntry = Array.isArray(dataIndex) ? lodashExports.get(a, dataIndex) : a[dataIndex];
|
|
47217
47287
|
const bEntry = Array.isArray(dataIndex) ? lodashExports.get(b, dataIndex) : b[dataIndex];
|
|
@@ -54721,39 +54791,6 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
54721
54791
|
return axios.get(`/api/clusters/${cluster}/openapi-bff/swagger/swagger/${cluster}`);
|
|
54722
54792
|
};
|
|
54723
54793
|
|
|
54724
|
-
const checkIfApiInstanceNamespaceScoped = async ({
|
|
54725
|
-
plural,
|
|
54726
|
-
apiGroup,
|
|
54727
|
-
apiVersion,
|
|
54728
|
-
cluster
|
|
54729
|
-
}) => {
|
|
54730
|
-
const payload = {
|
|
54731
|
-
plural,
|
|
54732
|
-
apiGroup,
|
|
54733
|
-
apiVersion,
|
|
54734
|
-
cluster
|
|
54735
|
-
};
|
|
54736
|
-
const { data } = await axios.post(
|
|
54737
|
-
`/api/clusters/${cluster}/openapi-bff/scopes/checkScopes/checkIfApiNamespaceScoped`,
|
|
54738
|
-
payload
|
|
54739
|
-
);
|
|
54740
|
-
return data;
|
|
54741
|
-
};
|
|
54742
|
-
const checkIfBuiltInInstanceNamespaceScoped = async ({
|
|
54743
|
-
plural,
|
|
54744
|
-
cluster
|
|
54745
|
-
}) => {
|
|
54746
|
-
const payload = {
|
|
54747
|
-
plural,
|
|
54748
|
-
cluster
|
|
54749
|
-
};
|
|
54750
|
-
const { data } = await axios.post(
|
|
54751
|
-
`/api/clusters/${cluster}/openapi-bff/scopes/checkScopes/checkIfBuiltInNamespaceScoped`,
|
|
54752
|
-
payload
|
|
54753
|
-
);
|
|
54754
|
-
return data;
|
|
54755
|
-
};
|
|
54756
|
-
|
|
54757
54794
|
const useClusterList = ({ refetchInterval }) => {
|
|
54758
54795
|
return reactQuery.useQuery({
|
|
54759
54796
|
queryKey: ["useClusterList"],
|
|
@@ -55009,6 +55046,27 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
55009
55046
|
}, [sentinelRef, hasMore, onNeedMore]);
|
|
55010
55047
|
};
|
|
55011
55048
|
|
|
55049
|
+
const useResourceScope = ({ plural, cluster, apiGroup, apiVersion }) => {
|
|
55050
|
+
const computedResourceType = apiGroup ? "api" : "builtin";
|
|
55051
|
+
const enabled = Boolean(cluster) && Boolean(plural) && (computedResourceType === "builtin" || Boolean(apiVersion));
|
|
55052
|
+
return reactQuery.useQuery({
|
|
55053
|
+
queryKey: ["resource-scope", computedResourceType, cluster, plural, apiGroup, apiVersion],
|
|
55054
|
+
enabled,
|
|
55055
|
+
queryFn: async () => {
|
|
55056
|
+
if (computedResourceType === "builtin") {
|
|
55057
|
+
return checkIfBuiltInInstanceNamespaceScoped({ plural, cluster });
|
|
55058
|
+
}
|
|
55059
|
+
return checkIfApiInstanceNamespaceScoped({
|
|
55060
|
+
plural,
|
|
55061
|
+
apiGroup: apiGroup || "",
|
|
55062
|
+
apiVersion: apiVersion || "",
|
|
55063
|
+
cluster
|
|
55064
|
+
});
|
|
55065
|
+
},
|
|
55066
|
+
staleTime: 5 * 60 * 1e3
|
|
55067
|
+
});
|
|
55068
|
+
};
|
|
55069
|
+
|
|
55012
55070
|
exports.BackToDefaultIcon = BackToDefaultIcon;
|
|
55013
55071
|
exports.BlackholeForm = BlackholeForm;
|
|
55014
55072
|
exports.BlackholeFormProvider = BlackholeFormProvider;
|
|
@@ -55145,6 +55203,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
|
|
|
55145
55203
|
exports.useListWatch = useListWatch;
|
|
55146
55204
|
exports.useManyK8sSmartResource = useManyK8sSmartResource;
|
|
55147
55205
|
exports.usePermissions = usePermissions;
|
|
55206
|
+
exports.useResourceScope = useResourceScope;
|
|
55148
55207
|
exports.useSmartResourceParams = useSmartResourceParams;
|
|
55149
55208
|
|
|
55150
55209
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|