@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.86 → 0.0.1-alpha.87
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 +86 -1
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +86 -1
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/components/organisms/DynamicComponents/molecules/ArrayOfObjectsToKeyValues/ArrayOfObjectsToKeyValues.d.ts +6 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ArrayOfObjectsToKeyValues/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/ArrayOfObjectsToKeyValues/utils.d.ts +5 -0
- package/dist/types/components/organisms/DynamicComponents/molecules/index.d.ts +1 -0
- package/dist/types/components/organisms/DynamicComponents/types.d.ts +36 -24
- package/package.json +1 -1
|
@@ -46587,6 +46587,90 @@ const VisibilityContainer = ({
|
|
|
46587
46587
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.VisibilityContainer, { $hidden: valuePrepared === "~undefined-value~", children });
|
|
46588
46588
|
};
|
|
46589
46589
|
|
|
46590
|
+
const unknownToString = (value) => {
|
|
46591
|
+
if (!value) {
|
|
46592
|
+
return "No value";
|
|
46593
|
+
}
|
|
46594
|
+
if (typeof value === "object") {
|
|
46595
|
+
return JSON.stringify(value);
|
|
46596
|
+
}
|
|
46597
|
+
return value.toString();
|
|
46598
|
+
};
|
|
46599
|
+
const flattenOnce = (arr) => arr.reduce((acc, row) => [...acc, ...row], []);
|
|
46600
|
+
const isRecordArray = (val) => {
|
|
46601
|
+
return Array.isArray(val) && val.every(
|
|
46602
|
+
(item) => item !== null && typeof item === "object" && // exclude nested Arrays if you want “plain” objects only:
|
|
46603
|
+
!Array.isArray(item)
|
|
46604
|
+
);
|
|
46605
|
+
};
|
|
46606
|
+
const parseArrayOfAny = (value) => {
|
|
46607
|
+
if (!Array.isArray(value)) {
|
|
46608
|
+
return { error: "Value on jsonPath is not an array" };
|
|
46609
|
+
}
|
|
46610
|
+
let flattenArrayOfUnknown = [];
|
|
46611
|
+
try {
|
|
46612
|
+
flattenArrayOfUnknown = flattenOnce(value);
|
|
46613
|
+
} catch (e) {
|
|
46614
|
+
console.log(e);
|
|
46615
|
+
return { error: "Error while flattening" };
|
|
46616
|
+
}
|
|
46617
|
+
if (isRecordArray(flattenArrayOfUnknown)) {
|
|
46618
|
+
return { data: flattenArrayOfUnknown };
|
|
46619
|
+
}
|
|
46620
|
+
return { error: "Value on jsonPath is not a record array" };
|
|
46621
|
+
};
|
|
46622
|
+
|
|
46623
|
+
const ArrayOfObjectsToKeyValues = ({ data, children }) => {
|
|
46624
|
+
const {
|
|
46625
|
+
id,
|
|
46626
|
+
reqIndex,
|
|
46627
|
+
jsonPathToArray,
|
|
46628
|
+
keyFieldName,
|
|
46629
|
+
valueFieldName,
|
|
46630
|
+
separator,
|
|
46631
|
+
containerStyle,
|
|
46632
|
+
rowStyle,
|
|
46633
|
+
keyFieldStyle,
|
|
46634
|
+
valueFieldStyle
|
|
46635
|
+
} = data;
|
|
46636
|
+
const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
|
|
46637
|
+
if (isMultiQueryLoading) {
|
|
46638
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
|
|
46639
|
+
}
|
|
46640
|
+
if (isMultiQueryErrors) {
|
|
46641
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
46642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
|
|
46643
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: e.message }, i)) })
|
|
46644
|
+
] });
|
|
46645
|
+
}
|
|
46646
|
+
const jsonRoot = multiQueryData[`req${reqIndex}`];
|
|
46647
|
+
if (jsonRoot === void 0) {
|
|
46648
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
|
|
46649
|
+
}
|
|
46650
|
+
const anythingForNow = jp.query(jsonRoot, `$${jsonPathToArray}`);
|
|
46651
|
+
const { data: arrayOfObjects, error: errorArrayOfObjects } = parseArrayOfAny(anythingForNow);
|
|
46652
|
+
if (!arrayOfObjects) {
|
|
46653
|
+
if (errorArrayOfObjects) {
|
|
46654
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: errorArrayOfObjects });
|
|
46655
|
+
}
|
|
46656
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Not a valid data structure" });
|
|
46657
|
+
}
|
|
46658
|
+
const separatorPrepared = separator || ":";
|
|
46659
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
|
|
46660
|
+
arrayOfObjects.map((item) => {
|
|
46661
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: rowStyle, children: [
|
|
46662
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: keyFieldStyle, children: [
|
|
46663
|
+
unknownToString(item[keyFieldName]),
|
|
46664
|
+
separatorPrepared,
|
|
46665
|
+
" "
|
|
46666
|
+
] }),
|
|
46667
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: valueFieldStyle, children: unknownToString(item[valueFieldName]) })
|
|
46668
|
+
] }, JSON.stringify(item));
|
|
46669
|
+
}),
|
|
46670
|
+
children
|
|
46671
|
+
] });
|
|
46672
|
+
};
|
|
46673
|
+
|
|
46590
46674
|
const DynamicComponents = {
|
|
46591
46675
|
DefaultDiv,
|
|
46592
46676
|
antdText: AntdText,
|
|
@@ -46611,7 +46695,8 @@ const DynamicComponents = {
|
|
|
46611
46695
|
NodeTerminal,
|
|
46612
46696
|
PodLogs,
|
|
46613
46697
|
YamlEditorSingleton,
|
|
46614
|
-
VisibilityContainer
|
|
46698
|
+
VisibilityContainer,
|
|
46699
|
+
ArrayOfObjectsToKeyValues
|
|
46615
46700
|
};
|
|
46616
46701
|
|
|
46617
46702
|
const prepareUrlsToFetchForDynamicRenderer = ({
|