@stoplight/elements-core 9.0.4 → 9.0.5
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/components/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +1 -1
- package/index.esm.js +184 -31
- package/index.js +184 -31
- package/index.mjs +184 -31
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ interface LazySchemaTreePreviewerProps {
|
|
|
19
19
|
}>;
|
|
20
20
|
parentRequired?: string[];
|
|
21
21
|
propertyKey?: string;
|
|
22
|
-
|
|
22
|
+
_subType?: string;
|
|
23
23
|
}
|
|
24
24
|
declare const LazySchemaTreePreviewer: React.FC<LazySchemaTreePreviewerProps>;
|
|
25
25
|
export default LazySchemaTreePreviewer;
|
package/index.esm.js
CHANGED
|
@@ -2760,7 +2760,12 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2760
2760
|
return node;
|
|
2761
2761
|
if (node.$ref || node['x-iata-$ref']) {
|
|
2762
2762
|
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2763
|
-
|
|
2763
|
+
if (refPath.includes('#/%24defs')) {
|
|
2764
|
+
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2765
|
+
}
|
|
2766
|
+
else {
|
|
2767
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2768
|
+
}
|
|
2764
2769
|
if (visited.has(node))
|
|
2765
2770
|
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2766
2771
|
visited.add(node);
|
|
@@ -2786,9 +2791,49 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2786
2791
|
const trimSlashes = (str) => {
|
|
2787
2792
|
return str.replace(/^\/|\/$/g, '');
|
|
2788
2793
|
};
|
|
2789
|
-
|
|
2794
|
+
function isPropertiesAllHidden(path, hideData) {
|
|
2795
|
+
const current = trimSlashes(path);
|
|
2796
|
+
const parts = current.split('/');
|
|
2797
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
2798
|
+
if (parts[i - 1] === 'properties') {
|
|
2799
|
+
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2800
|
+
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2801
|
+
if (block && block.required === undefined) {
|
|
2802
|
+
return true;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
return false;
|
|
2807
|
+
}
|
|
2808
|
+
function isRequiredOverride(path, hideData) {
|
|
2809
|
+
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2810
|
+
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2811
|
+
}
|
|
2812
|
+
function isPathHidden(path, hideData) {
|
|
2813
|
+
const normalizedPath = trimSlashes(path);
|
|
2814
|
+
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2815
|
+
if (direct && direct.required === undefined)
|
|
2816
|
+
return true;
|
|
2817
|
+
if (isPropertiesAllHidden(path, hideData))
|
|
2818
|
+
return true;
|
|
2819
|
+
for (const h of hideData) {
|
|
2820
|
+
const hPath = trimSlashes(h.path);
|
|
2821
|
+
if (h.required !== undefined)
|
|
2822
|
+
continue;
|
|
2823
|
+
if (normalizedPath.length > hPath.length &&
|
|
2824
|
+
normalizedPath.startsWith(hPath) &&
|
|
2825
|
+
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2826
|
+
return true;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
return false;
|
|
2830
|
+
}
|
|
2831
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2790
2832
|
var _a, _b, _c, _d;
|
|
2791
2833
|
const [expanded, setExpanded] = useState(false);
|
|
2834
|
+
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
2835
|
+
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
2836
|
+
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
2792
2837
|
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2793
2838
|
useState(() => {
|
|
2794
2839
|
const disabledPaths = hideData || [];
|
|
@@ -2801,14 +2846,19 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2801
2846
|
}
|
|
2802
2847
|
return initialState;
|
|
2803
2848
|
});
|
|
2849
|
+
useEffect(() => {
|
|
2850
|
+
setSelectedSchemaIndex(0);
|
|
2851
|
+
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2852
|
+
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2853
|
+
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2854
|
+
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2804
2855
|
const shouldHideNode = useMemo(() => {
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
return
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
}, [path, hideData]);
|
|
2856
|
+
if (isRoot)
|
|
2857
|
+
return false;
|
|
2858
|
+
if (isPathHidden(path, hideData) && thisNodeRequiredOverride === undefined)
|
|
2859
|
+
return true;
|
|
2860
|
+
return false;
|
|
2861
|
+
}, [path, hideData, isRoot, thisNodeRequiredOverride]);
|
|
2812
2862
|
if (!schema || shouldHideNode) {
|
|
2813
2863
|
return null;
|
|
2814
2864
|
}
|
|
@@ -2821,17 +2871,34 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2821
2871
|
};
|
|
2822
2872
|
const renderChildren = () => {
|
|
2823
2873
|
var _a, _b, _c, _d;
|
|
2874
|
+
if (shouldHideAllChildren)
|
|
2875
|
+
return null;
|
|
2824
2876
|
if (!expanded && !isRoot)
|
|
2825
2877
|
return null;
|
|
2826
2878
|
const children = [];
|
|
2827
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2828
|
-
|
|
2879
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2880
|
+
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2881
|
+
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2882
|
+
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2883
|
+
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2887
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2888
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2889
|
+
}
|
|
2890
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2891
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2892
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2893
|
+
}
|
|
2894
|
+
for (const [key, child] of Object.entries(props || {})) {
|
|
2829
2895
|
const childPath = `${path}/properties/${key}`;
|
|
2830
|
-
const
|
|
2896
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2897
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2831
2898
|
const resolved = dereference(child, root);
|
|
2832
2899
|
if (!shouldHideChild) {
|
|
2833
2900
|
children.push(React__default.createElement("li", { key: key },
|
|
2834
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key,
|
|
2901
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
|
|
2835
2902
|
}
|
|
2836
2903
|
}
|
|
2837
2904
|
}
|
|
@@ -2843,25 +2910,57 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2843
2910
|
const itemsPath = `${path}/items`;
|
|
2844
2911
|
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2845
2912
|
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2846
|
-
const childPath = `${itemsPath}
|
|
2847
|
-
const
|
|
2913
|
+
const childPath = `${itemsPath}/${key}`;
|
|
2914
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2915
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2848
2916
|
if (!shouldHideChild) {
|
|
2849
2917
|
children.push(React__default.createElement("li", { key: key },
|
|
2850
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key,
|
|
2918
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2851
2919
|
}
|
|
2852
2920
|
}
|
|
2853
2921
|
}
|
|
2854
2922
|
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2855
2923
|
const childPath = `${path}/items`;
|
|
2856
|
-
const
|
|
2924
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2925
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2857
2926
|
if (!shouldHideChild) {
|
|
2858
2927
|
children.push(React__default.createElement("li", { key: "items" },
|
|
2859
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items",
|
|
2928
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
|
|
2860
2929
|
}
|
|
2861
2930
|
}
|
|
2862
2931
|
}
|
|
2863
2932
|
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2864
2933
|
};
|
|
2934
|
+
const combinedSchemaSelector = () => {
|
|
2935
|
+
var _a;
|
|
2936
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
2937
|
+
React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2938
|
+
React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2939
|
+
zIndex: 1000,
|
|
2940
|
+
top: '100%',
|
|
2941
|
+
left: 0,
|
|
2942
|
+
minWidth: '150px',
|
|
2943
|
+
maxWidth: '200px',
|
|
2944
|
+
marginTop: '2px',
|
|
2945
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2946
|
+
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
2947
|
+
borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
2948
|
+
gap: '8px',
|
|
2949
|
+
}, onMouseEnter: (e) => {
|
|
2950
|
+
if (selectedSchemaIndex !== index) {
|
|
2951
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2952
|
+
}
|
|
2953
|
+
}, onMouseLeave: (e) => {
|
|
2954
|
+
if (selectedSchemaIndex !== index) {
|
|
2955
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2956
|
+
}
|
|
2957
|
+
}, onClick: () => {
|
|
2958
|
+
setSelectedSchemaIndex(index);
|
|
2959
|
+
setShowSchemaDropdown(false);
|
|
2960
|
+
} },
|
|
2961
|
+
React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2962
|
+
selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2963
|
+
};
|
|
2865
2964
|
const renderMinEnums = (schema) => {
|
|
2866
2965
|
if (!schema || typeof schema !== 'object')
|
|
2867
2966
|
return null;
|
|
@@ -2896,6 +2995,9 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2896
2995
|
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
2897
2996
|
showRequiredLabel = true;
|
|
2898
2997
|
}
|
|
2998
|
+
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
2999
|
+
schema = dereference(schema, root);
|
|
3000
|
+
}
|
|
2899
3001
|
return (React__default.createElement("div", { className: "mb-1" },
|
|
2900
3002
|
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
2901
3003
|
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
@@ -2906,12 +3008,45 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2906
3008
|
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
2907
3009
|
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
2908
3010
|
' ' + displayTitle)) : null,
|
|
2909
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2 },
|
|
2910
|
-
React__default.createElement(
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3011
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
|
|
3012
|
+
React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3013
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3014
|
+
setIsHoveringSelector(true);
|
|
3015
|
+
}
|
|
3016
|
+
}, onMouseLeave: () => {
|
|
3017
|
+
if (!showSchemaDropdown) {
|
|
3018
|
+
setIsHoveringSelector(false);
|
|
3019
|
+
}
|
|
3020
|
+
}, onClick: (e) => {
|
|
3021
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3022
|
+
e.stopPropagation();
|
|
3023
|
+
setShowSchemaDropdown(prev => !prev);
|
|
3024
|
+
}
|
|
3025
|
+
}, style: {
|
|
3026
|
+
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3027
|
+
} },
|
|
3028
|
+
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3029
|
+
(() => {
|
|
3030
|
+
let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
|
|
3031
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3032
|
+
return `any of ${typeDisplay}`;
|
|
3033
|
+
}
|
|
3034
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3035
|
+
return `one of ${typeDisplay}`;
|
|
3036
|
+
}
|
|
3037
|
+
return typeDisplay;
|
|
3038
|
+
})(),
|
|
3039
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
|
|
3040
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3041
|
+
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3042
|
+
transition: 'opacity 0.2s',
|
|
3043
|
+
} },
|
|
3044
|
+
React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3045
|
+
fontSize: '10px',
|
|
3046
|
+
opacity: 0.6,
|
|
3047
|
+
} })))),
|
|
3048
|
+
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3049
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
2915
3050
|
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
2916
3051
|
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
2917
3052
|
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
@@ -2961,9 +3096,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
|
|
|
2961
3096
|
const absolutePathsToHide = [];
|
|
2962
3097
|
disablePropsConfig.forEach(configEntry => {
|
|
2963
3098
|
const { location, paths } = configEntry;
|
|
2964
|
-
paths.forEach(item => {
|
|
3099
|
+
paths.forEach((item) => {
|
|
2965
3100
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
2966
|
-
|
|
3101
|
+
let object = { path: fullPath };
|
|
3102
|
+
if (item.hasOwnProperty('required')) {
|
|
3103
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3104
|
+
}
|
|
3105
|
+
absolutePathsToHide.push(object);
|
|
2967
3106
|
});
|
|
2968
3107
|
});
|
|
2969
3108
|
return absolutePathsToHide;
|
|
@@ -3154,8 +3293,14 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3154
3293
|
const configEntries = disableProps[statusCode] || [];
|
|
3155
3294
|
const absolutePathsToHide = [];
|
|
3156
3295
|
configEntries.forEach(({ location, paths }) => {
|
|
3157
|
-
paths.forEach(item => {
|
|
3158
|
-
|
|
3296
|
+
paths.forEach((item) => {
|
|
3297
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3298
|
+
let object = { path: fullPath };
|
|
3299
|
+
if (item.hasOwnProperty('required')) {
|
|
3300
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3301
|
+
}
|
|
3302
|
+
absolutePathsToHide.push(object);
|
|
3303
|
+
console.log('object::', object, item);
|
|
3159
3304
|
});
|
|
3160
3305
|
});
|
|
3161
3306
|
return absolutePathsToHide;
|
|
@@ -3487,7 +3632,9 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3487
3632
|
React.createElement(Box, { pos: "relative" },
|
|
3488
3633
|
React.createElement(Heading, { size: 1, mb: 4, fontWeight: "semibold" }, data.name),
|
|
3489
3634
|
React.createElement(NodeAnnotation, { change: nameChanged })),
|
|
3490
|
-
|
|
3635
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3636
|
+
? null
|
|
3637
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps)))),
|
|
3491
3638
|
data.version && (React.createElement(Box, { mb: 5, pos: "relative" },
|
|
3492
3639
|
React.createElement(VersionBadge, { value: data.version }),
|
|
3493
3640
|
React.createElement(NodeAnnotation, { change: versionChanged }))),
|
|
@@ -3523,7 +3670,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3523
3670
|
isDeprecated && React.createElement(DeprecatedBadge, null),
|
|
3524
3671
|
isInternal && React.createElement(InternalBadge, null))),
|
|
3525
3672
|
React.createElement(NodeAnnotation, { change: titleChanged })),
|
|
3526
|
-
|
|
3673
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3674
|
+
? null
|
|
3675
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3527
3676
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3528
3677
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3529
3678
|
const getMaskProperties = () => {
|
|
@@ -3534,7 +3683,11 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3534
3683
|
const { location, paths } = configEntry;
|
|
3535
3684
|
paths.forEach((item) => {
|
|
3536
3685
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3537
|
-
|
|
3686
|
+
let object = { path: fullPath };
|
|
3687
|
+
if (item.hasOwnProperty('required')) {
|
|
3688
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3689
|
+
}
|
|
3690
|
+
absolutePathsToHide.push(object);
|
|
3538
3691
|
});
|
|
3539
3692
|
});
|
|
3540
3693
|
}
|
package/index.js
CHANGED
|
@@ -2782,7 +2782,12 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2782
2782
|
return node;
|
|
2783
2783
|
if (node.$ref || node['x-iata-$ref']) {
|
|
2784
2784
|
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2785
|
-
|
|
2785
|
+
if (refPath.includes('#/%24defs')) {
|
|
2786
|
+
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2787
|
+
}
|
|
2788
|
+
else {
|
|
2789
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2790
|
+
}
|
|
2786
2791
|
if (visited.has(node))
|
|
2787
2792
|
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2788
2793
|
visited.add(node);
|
|
@@ -2808,9 +2813,49 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2808
2813
|
const trimSlashes = (str) => {
|
|
2809
2814
|
return str.replace(/^\/|\/$/g, '');
|
|
2810
2815
|
};
|
|
2811
|
-
|
|
2816
|
+
function isPropertiesAllHidden(path, hideData) {
|
|
2817
|
+
const current = trimSlashes(path);
|
|
2818
|
+
const parts = current.split('/');
|
|
2819
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
2820
|
+
if (parts[i - 1] === 'properties') {
|
|
2821
|
+
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2822
|
+
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2823
|
+
if (block && block.required === undefined) {
|
|
2824
|
+
return true;
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
return false;
|
|
2829
|
+
}
|
|
2830
|
+
function isRequiredOverride(path, hideData) {
|
|
2831
|
+
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2832
|
+
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2833
|
+
}
|
|
2834
|
+
function isPathHidden(path, hideData) {
|
|
2835
|
+
const normalizedPath = trimSlashes(path);
|
|
2836
|
+
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2837
|
+
if (direct && direct.required === undefined)
|
|
2838
|
+
return true;
|
|
2839
|
+
if (isPropertiesAllHidden(path, hideData))
|
|
2840
|
+
return true;
|
|
2841
|
+
for (const h of hideData) {
|
|
2842
|
+
const hPath = trimSlashes(h.path);
|
|
2843
|
+
if (h.required !== undefined)
|
|
2844
|
+
continue;
|
|
2845
|
+
if (normalizedPath.length > hPath.length &&
|
|
2846
|
+
normalizedPath.startsWith(hPath) &&
|
|
2847
|
+
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2848
|
+
return true;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
return false;
|
|
2852
|
+
}
|
|
2853
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2812
2854
|
var _a, _b, _c, _d;
|
|
2813
2855
|
const [expanded, setExpanded] = React.useState(false);
|
|
2856
|
+
const [selectedSchemaIndex, setSelectedSchemaIndex] = React.useState(0);
|
|
2857
|
+
const [showSchemaDropdown, setShowSchemaDropdown] = React.useState(false);
|
|
2858
|
+
const [isHoveringSelector, setIsHoveringSelector] = React.useState(false);
|
|
2814
2859
|
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2815
2860
|
React.useState(() => {
|
|
2816
2861
|
const disabledPaths = hideData || [];
|
|
@@ -2823,14 +2868,19 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2823
2868
|
}
|
|
2824
2869
|
return initialState;
|
|
2825
2870
|
});
|
|
2871
|
+
React.useEffect(() => {
|
|
2872
|
+
setSelectedSchemaIndex(0);
|
|
2873
|
+
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2874
|
+
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2875
|
+
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2876
|
+
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2826
2877
|
const shouldHideNode = React.useMemo(() => {
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
return
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
}, [path, hideData]);
|
|
2878
|
+
if (isRoot)
|
|
2879
|
+
return false;
|
|
2880
|
+
if (isPathHidden(path, hideData) && thisNodeRequiredOverride === undefined)
|
|
2881
|
+
return true;
|
|
2882
|
+
return false;
|
|
2883
|
+
}, [path, hideData, isRoot, thisNodeRequiredOverride]);
|
|
2834
2884
|
if (!schema || shouldHideNode) {
|
|
2835
2885
|
return null;
|
|
2836
2886
|
}
|
|
@@ -2843,17 +2893,34 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2843
2893
|
};
|
|
2844
2894
|
const renderChildren = () => {
|
|
2845
2895
|
var _a, _b, _c, _d;
|
|
2896
|
+
if (shouldHideAllChildren)
|
|
2897
|
+
return null;
|
|
2846
2898
|
if (!expanded && !isRoot)
|
|
2847
2899
|
return null;
|
|
2848
2900
|
const children = [];
|
|
2849
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2850
|
-
|
|
2901
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2902
|
+
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2903
|
+
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2904
|
+
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2905
|
+
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2909
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2910
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2911
|
+
}
|
|
2912
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2913
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2914
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2915
|
+
}
|
|
2916
|
+
for (const [key, child] of Object.entries(props || {})) {
|
|
2851
2917
|
const childPath = `${path}/properties/${key}`;
|
|
2852
|
-
const
|
|
2918
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2919
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2853
2920
|
const resolved = dereference(child, root);
|
|
2854
2921
|
if (!shouldHideChild) {
|
|
2855
2922
|
children.push(React.createElement("li", { key: key },
|
|
2856
|
-
React.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key,
|
|
2923
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
|
|
2857
2924
|
}
|
|
2858
2925
|
}
|
|
2859
2926
|
}
|
|
@@ -2865,25 +2932,57 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2865
2932
|
const itemsPath = `${path}/items`;
|
|
2866
2933
|
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2867
2934
|
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2868
|
-
const childPath = `${itemsPath}
|
|
2869
|
-
const
|
|
2935
|
+
const childPath = `${itemsPath}/${key}`;
|
|
2936
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2937
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2870
2938
|
if (!shouldHideChild) {
|
|
2871
2939
|
children.push(React.createElement("li", { key: key },
|
|
2872
|
-
React.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key,
|
|
2940
|
+
React.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2873
2941
|
}
|
|
2874
2942
|
}
|
|
2875
2943
|
}
|
|
2876
2944
|
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2877
2945
|
const childPath = `${path}/items`;
|
|
2878
|
-
const
|
|
2946
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2947
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2879
2948
|
if (!shouldHideChild) {
|
|
2880
2949
|
children.push(React.createElement("li", { key: "items" },
|
|
2881
|
-
React.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items",
|
|
2950
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
|
|
2882
2951
|
}
|
|
2883
2952
|
}
|
|
2884
2953
|
}
|
|
2885
2954
|
return children.length > 0 ? React.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2886
2955
|
};
|
|
2956
|
+
const combinedSchemaSelector = () => {
|
|
2957
|
+
var _a;
|
|
2958
|
+
return (React.createElement(React.Fragment, null,
|
|
2959
|
+
React.createElement(mosaic.Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2960
|
+
React.createElement(mosaic.Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2961
|
+
zIndex: 1000,
|
|
2962
|
+
top: '100%',
|
|
2963
|
+
left: 0,
|
|
2964
|
+
minWidth: '150px',
|
|
2965
|
+
maxWidth: '200px',
|
|
2966
|
+
marginTop: '2px',
|
|
2967
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2968
|
+
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React.createElement(mosaic.Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
2969
|
+
borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
2970
|
+
gap: '8px',
|
|
2971
|
+
}, onMouseEnter: (e) => {
|
|
2972
|
+
if (selectedSchemaIndex !== index) {
|
|
2973
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2974
|
+
}
|
|
2975
|
+
}, onMouseLeave: (e) => {
|
|
2976
|
+
if (selectedSchemaIndex !== index) {
|
|
2977
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2978
|
+
}
|
|
2979
|
+
}, onClick: () => {
|
|
2980
|
+
setSelectedSchemaIndex(index);
|
|
2981
|
+
setShowSchemaDropdown(false);
|
|
2982
|
+
} },
|
|
2983
|
+
React.createElement(mosaic.Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2984
|
+
selectedSchemaIndex === index && (React.createElement(mosaic.Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2985
|
+
};
|
|
2887
2986
|
const renderMinEnums = (schema) => {
|
|
2888
2987
|
if (!schema || typeof schema !== 'object')
|
|
2889
2988
|
return null;
|
|
@@ -2918,6 +3017,9 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2918
3017
|
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
2919
3018
|
showRequiredLabel = true;
|
|
2920
3019
|
}
|
|
3020
|
+
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
3021
|
+
schema = dereference(schema, root);
|
|
3022
|
+
}
|
|
2921
3023
|
return (React.createElement("div", { className: "mb-1" },
|
|
2922
3024
|
React.createElement(mosaic.Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
2923
3025
|
React.createElement(mosaic.VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
@@ -2928,12 +3030,45 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2928
3030
|
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
2929
3031
|
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
2930
3032
|
' ' + displayTitle)) : null,
|
|
2931
|
-
!isRoot ? (React.createElement(mosaic.Box, { mr: 2 },
|
|
2932
|
-
React.createElement(
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
3033
|
+
!isRoot ? (React.createElement(mosaic.Box, { mr: 2, pos: "relative" },
|
|
3034
|
+
React.createElement(mosaic.Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3035
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3036
|
+
setIsHoveringSelector(true);
|
|
3037
|
+
}
|
|
3038
|
+
}, onMouseLeave: () => {
|
|
3039
|
+
if (!showSchemaDropdown) {
|
|
3040
|
+
setIsHoveringSelector(false);
|
|
3041
|
+
}
|
|
3042
|
+
}, onClick: (e) => {
|
|
3043
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3044
|
+
e.stopPropagation();
|
|
3045
|
+
setShowSchemaDropdown(prev => !prev);
|
|
3046
|
+
}
|
|
3047
|
+
}, style: {
|
|
3048
|
+
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3049
|
+
} },
|
|
3050
|
+
React.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3051
|
+
(() => {
|
|
3052
|
+
let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
|
|
3053
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3054
|
+
return `any of ${typeDisplay}`;
|
|
3055
|
+
}
|
|
3056
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3057
|
+
return `one of ${typeDisplay}`;
|
|
3058
|
+
}
|
|
3059
|
+
return typeDisplay;
|
|
3060
|
+
})(),
|
|
3061
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
|
|
3062
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React.createElement(mosaic.Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3063
|
+
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3064
|
+
transition: 'opacity 0.2s',
|
|
3065
|
+
} },
|
|
3066
|
+
React.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3067
|
+
fontSize: '10px',
|
|
3068
|
+
opacity: 0.6,
|
|
3069
|
+
} })))),
|
|
3070
|
+
React.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3071
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
2937
3072
|
React.createElement(mosaic.Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
2938
3073
|
(schema === null || schema === void 0 ? void 0 : schema.description) && (React.createElement(mosaic.Box, { fontFamily: "ui", fontWeight: "light" },
|
|
2939
3074
|
React.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
@@ -2983,9 +3118,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
|
|
|
2983
3118
|
const absolutePathsToHide = [];
|
|
2984
3119
|
disablePropsConfig.forEach(configEntry => {
|
|
2985
3120
|
const { location, paths } = configEntry;
|
|
2986
|
-
paths.forEach(item => {
|
|
3121
|
+
paths.forEach((item) => {
|
|
2987
3122
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
2988
|
-
|
|
3123
|
+
let object = { path: fullPath };
|
|
3124
|
+
if (item.hasOwnProperty('required')) {
|
|
3125
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3126
|
+
}
|
|
3127
|
+
absolutePathsToHide.push(object);
|
|
2989
3128
|
});
|
|
2990
3129
|
});
|
|
2991
3130
|
return absolutePathsToHide;
|
|
@@ -3176,8 +3315,14 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3176
3315
|
const configEntries = disableProps[statusCode] || [];
|
|
3177
3316
|
const absolutePathsToHide = [];
|
|
3178
3317
|
configEntries.forEach(({ location, paths }) => {
|
|
3179
|
-
paths.forEach(item => {
|
|
3180
|
-
|
|
3318
|
+
paths.forEach((item) => {
|
|
3319
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3320
|
+
let object = { path: fullPath };
|
|
3321
|
+
if (item.hasOwnProperty('required')) {
|
|
3322
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3323
|
+
}
|
|
3324
|
+
absolutePathsToHide.push(object);
|
|
3325
|
+
console.log('object::', object, item);
|
|
3181
3326
|
});
|
|
3182
3327
|
});
|
|
3183
3328
|
return absolutePathsToHide;
|
|
@@ -3509,7 +3654,9 @@ const HttpServiceComponent = React__namespace.memo(({ data: unresolvedData, loca
|
|
|
3509
3654
|
React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
3510
3655
|
React__namespace.createElement(mosaic.Heading, { size: 1, mb: 4, fontWeight: "semibold" }, data.name),
|
|
3511
3656
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: nameChanged })),
|
|
3512
|
-
|
|
3657
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3658
|
+
? null
|
|
3659
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React__namespace.createElement(ExportButton, Object.assign({}, exportProps)))),
|
|
3513
3660
|
data.version && (React__namespace.createElement(mosaic.Box, { mb: 5, pos: "relative" },
|
|
3514
3661
|
React__namespace.createElement(VersionBadge, { value: data.version }),
|
|
3515
3662
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: versionChanged }))),
|
|
@@ -3545,7 +3692,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3545
3692
|
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
3546
3693
|
isInternal && React__namespace.createElement(InternalBadge, null))),
|
|
3547
3694
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: titleChanged })),
|
|
3548
|
-
|
|
3695
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3696
|
+
? null
|
|
3697
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3549
3698
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3550
3699
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3551
3700
|
const getMaskProperties = () => {
|
|
@@ -3556,7 +3705,11 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3556
3705
|
const { location, paths } = configEntry;
|
|
3557
3706
|
paths.forEach((item) => {
|
|
3558
3707
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3559
|
-
|
|
3708
|
+
let object = { path: fullPath };
|
|
3709
|
+
if (item.hasOwnProperty('required')) {
|
|
3710
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3711
|
+
}
|
|
3712
|
+
absolutePathsToHide.push(object);
|
|
3560
3713
|
});
|
|
3561
3714
|
});
|
|
3562
3715
|
}
|
package/index.mjs
CHANGED
|
@@ -2760,7 +2760,12 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2760
2760
|
return node;
|
|
2761
2761
|
if (node.$ref || node['x-iata-$ref']) {
|
|
2762
2762
|
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2763
|
-
|
|
2763
|
+
if (refPath.includes('#/%24defs')) {
|
|
2764
|
+
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2765
|
+
}
|
|
2766
|
+
else {
|
|
2767
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2768
|
+
}
|
|
2764
2769
|
if (visited.has(node))
|
|
2765
2770
|
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2766
2771
|
visited.add(node);
|
|
@@ -2786,9 +2791,49 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
|
|
|
2786
2791
|
const trimSlashes = (str) => {
|
|
2787
2792
|
return str.replace(/^\/|\/$/g, '');
|
|
2788
2793
|
};
|
|
2789
|
-
|
|
2794
|
+
function isPropertiesAllHidden(path, hideData) {
|
|
2795
|
+
const current = trimSlashes(path);
|
|
2796
|
+
const parts = current.split('/');
|
|
2797
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
2798
|
+
if (parts[i - 1] === 'properties') {
|
|
2799
|
+
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2800
|
+
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2801
|
+
if (block && block.required === undefined) {
|
|
2802
|
+
return true;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
return false;
|
|
2807
|
+
}
|
|
2808
|
+
function isRequiredOverride(path, hideData) {
|
|
2809
|
+
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2810
|
+
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2811
|
+
}
|
|
2812
|
+
function isPathHidden(path, hideData) {
|
|
2813
|
+
const normalizedPath = trimSlashes(path);
|
|
2814
|
+
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2815
|
+
if (direct && direct.required === undefined)
|
|
2816
|
+
return true;
|
|
2817
|
+
if (isPropertiesAllHidden(path, hideData))
|
|
2818
|
+
return true;
|
|
2819
|
+
for (const h of hideData) {
|
|
2820
|
+
const hPath = trimSlashes(h.path);
|
|
2821
|
+
if (h.required !== undefined)
|
|
2822
|
+
continue;
|
|
2823
|
+
if (normalizedPath.length > hPath.length &&
|
|
2824
|
+
normalizedPath.startsWith(hPath) &&
|
|
2825
|
+
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2826
|
+
return true;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
return false;
|
|
2830
|
+
}
|
|
2831
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2790
2832
|
var _a, _b, _c, _d;
|
|
2791
2833
|
const [expanded, setExpanded] = useState(false);
|
|
2834
|
+
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
2835
|
+
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
2836
|
+
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
2792
2837
|
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2793
2838
|
useState(() => {
|
|
2794
2839
|
const disabledPaths = hideData || [];
|
|
@@ -2801,14 +2846,19 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2801
2846
|
}
|
|
2802
2847
|
return initialState;
|
|
2803
2848
|
});
|
|
2849
|
+
useEffect(() => {
|
|
2850
|
+
setSelectedSchemaIndex(0);
|
|
2851
|
+
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2852
|
+
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2853
|
+
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2854
|
+
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2804
2855
|
const shouldHideNode = useMemo(() => {
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
return
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
}, [path, hideData]);
|
|
2856
|
+
if (isRoot)
|
|
2857
|
+
return false;
|
|
2858
|
+
if (isPathHidden(path, hideData) && thisNodeRequiredOverride === undefined)
|
|
2859
|
+
return true;
|
|
2860
|
+
return false;
|
|
2861
|
+
}, [path, hideData, isRoot, thisNodeRequiredOverride]);
|
|
2812
2862
|
if (!schema || shouldHideNode) {
|
|
2813
2863
|
return null;
|
|
2814
2864
|
}
|
|
@@ -2821,17 +2871,34 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2821
2871
|
};
|
|
2822
2872
|
const renderChildren = () => {
|
|
2823
2873
|
var _a, _b, _c, _d;
|
|
2874
|
+
if (shouldHideAllChildren)
|
|
2875
|
+
return null;
|
|
2824
2876
|
if (!expanded && !isRoot)
|
|
2825
2877
|
return null;
|
|
2826
2878
|
const children = [];
|
|
2827
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2828
|
-
|
|
2879
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2880
|
+
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2881
|
+
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2882
|
+
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2883
|
+
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2887
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2888
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2889
|
+
}
|
|
2890
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2891
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2892
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2893
|
+
}
|
|
2894
|
+
for (const [key, child] of Object.entries(props || {})) {
|
|
2829
2895
|
const childPath = `${path}/properties/${key}`;
|
|
2830
|
-
const
|
|
2896
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2897
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2831
2898
|
const resolved = dereference(child, root);
|
|
2832
2899
|
if (!shouldHideChild) {
|
|
2833
2900
|
children.push(React__default.createElement("li", { key: key },
|
|
2834
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key,
|
|
2901
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
|
|
2835
2902
|
}
|
|
2836
2903
|
}
|
|
2837
2904
|
}
|
|
@@ -2843,25 +2910,57 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2843
2910
|
const itemsPath = `${path}/items`;
|
|
2844
2911
|
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2845
2912
|
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2846
|
-
const childPath = `${itemsPath}
|
|
2847
|
-
const
|
|
2913
|
+
const childPath = `${itemsPath}/${key}`;
|
|
2914
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2915
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2848
2916
|
if (!shouldHideChild) {
|
|
2849
2917
|
children.push(React__default.createElement("li", { key: key },
|
|
2850
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key,
|
|
2918
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2851
2919
|
}
|
|
2852
2920
|
}
|
|
2853
2921
|
}
|
|
2854
2922
|
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2855
2923
|
const childPath = `${path}/items`;
|
|
2856
|
-
const
|
|
2924
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2925
|
+
const shouldHideChild = isPathHidden(childPath, hideData) && childRequiredOverride === undefined;
|
|
2857
2926
|
if (!shouldHideChild) {
|
|
2858
2927
|
children.push(React__default.createElement("li", { key: "items" },
|
|
2859
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items",
|
|
2928
|
+
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
|
|
2860
2929
|
}
|
|
2861
2930
|
}
|
|
2862
2931
|
}
|
|
2863
2932
|
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2864
2933
|
};
|
|
2934
|
+
const combinedSchemaSelector = () => {
|
|
2935
|
+
var _a;
|
|
2936
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
2937
|
+
React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2938
|
+
React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2939
|
+
zIndex: 1000,
|
|
2940
|
+
top: '100%',
|
|
2941
|
+
left: 0,
|
|
2942
|
+
minWidth: '150px',
|
|
2943
|
+
maxWidth: '200px',
|
|
2944
|
+
marginTop: '2px',
|
|
2945
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2946
|
+
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
2947
|
+
borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
2948
|
+
gap: '8px',
|
|
2949
|
+
}, onMouseEnter: (e) => {
|
|
2950
|
+
if (selectedSchemaIndex !== index) {
|
|
2951
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2952
|
+
}
|
|
2953
|
+
}, onMouseLeave: (e) => {
|
|
2954
|
+
if (selectedSchemaIndex !== index) {
|
|
2955
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2956
|
+
}
|
|
2957
|
+
}, onClick: () => {
|
|
2958
|
+
setSelectedSchemaIndex(index);
|
|
2959
|
+
setShowSchemaDropdown(false);
|
|
2960
|
+
} },
|
|
2961
|
+
React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2962
|
+
selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2963
|
+
};
|
|
2865
2964
|
const renderMinEnums = (schema) => {
|
|
2866
2965
|
if (!schema || typeof schema !== 'object')
|
|
2867
2966
|
return null;
|
|
@@ -2896,6 +2995,9 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2896
2995
|
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
2897
2996
|
showRequiredLabel = true;
|
|
2898
2997
|
}
|
|
2998
|
+
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
2999
|
+
schema = dereference(schema, root);
|
|
3000
|
+
}
|
|
2899
3001
|
return (React__default.createElement("div", { className: "mb-1" },
|
|
2900
3002
|
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
2901
3003
|
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
@@ -2906,12 +3008,45 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
|
|
|
2906
3008
|
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
2907
3009
|
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
2908
3010
|
' ' + displayTitle)) : null,
|
|
2909
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2 },
|
|
2910
|
-
React__default.createElement(
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3011
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
|
|
3012
|
+
React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3013
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3014
|
+
setIsHoveringSelector(true);
|
|
3015
|
+
}
|
|
3016
|
+
}, onMouseLeave: () => {
|
|
3017
|
+
if (!showSchemaDropdown) {
|
|
3018
|
+
setIsHoveringSelector(false);
|
|
3019
|
+
}
|
|
3020
|
+
}, onClick: (e) => {
|
|
3021
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3022
|
+
e.stopPropagation();
|
|
3023
|
+
setShowSchemaDropdown(prev => !prev);
|
|
3024
|
+
}
|
|
3025
|
+
}, style: {
|
|
3026
|
+
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3027
|
+
} },
|
|
3028
|
+
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3029
|
+
(() => {
|
|
3030
|
+
let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
|
|
3031
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3032
|
+
return `any of ${typeDisplay}`;
|
|
3033
|
+
}
|
|
3034
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3035
|
+
return `one of ${typeDisplay}`;
|
|
3036
|
+
}
|
|
3037
|
+
return typeDisplay;
|
|
3038
|
+
})(),
|
|
3039
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
|
|
3040
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3041
|
+
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3042
|
+
transition: 'opacity 0.2s',
|
|
3043
|
+
} },
|
|
3044
|
+
React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3045
|
+
fontSize: '10px',
|
|
3046
|
+
opacity: 0.6,
|
|
3047
|
+
} })))),
|
|
3048
|
+
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3049
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
2915
3050
|
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
2916
3051
|
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
2917
3052
|
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
@@ -2961,9 +3096,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
|
|
|
2961
3096
|
const absolutePathsToHide = [];
|
|
2962
3097
|
disablePropsConfig.forEach(configEntry => {
|
|
2963
3098
|
const { location, paths } = configEntry;
|
|
2964
|
-
paths.forEach(item => {
|
|
3099
|
+
paths.forEach((item) => {
|
|
2965
3100
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
2966
|
-
|
|
3101
|
+
let object = { path: fullPath };
|
|
3102
|
+
if (item.hasOwnProperty('required')) {
|
|
3103
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3104
|
+
}
|
|
3105
|
+
absolutePathsToHide.push(object);
|
|
2967
3106
|
});
|
|
2968
3107
|
});
|
|
2969
3108
|
return absolutePathsToHide;
|
|
@@ -3154,8 +3293,14 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3154
3293
|
const configEntries = disableProps[statusCode] || [];
|
|
3155
3294
|
const absolutePathsToHide = [];
|
|
3156
3295
|
configEntries.forEach(({ location, paths }) => {
|
|
3157
|
-
paths.forEach(item => {
|
|
3158
|
-
|
|
3296
|
+
paths.forEach((item) => {
|
|
3297
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3298
|
+
let object = { path: fullPath };
|
|
3299
|
+
if (item.hasOwnProperty('required')) {
|
|
3300
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3301
|
+
}
|
|
3302
|
+
absolutePathsToHide.push(object);
|
|
3303
|
+
console.log('object::', object, item);
|
|
3159
3304
|
});
|
|
3160
3305
|
});
|
|
3161
3306
|
return absolutePathsToHide;
|
|
@@ -3487,7 +3632,9 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3487
3632
|
React.createElement(Box, { pos: "relative" },
|
|
3488
3633
|
React.createElement(Heading, { size: 1, mb: 4, fontWeight: "semibold" }, data.name),
|
|
3489
3634
|
React.createElement(NodeAnnotation, { change: nameChanged })),
|
|
3490
|
-
|
|
3635
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3636
|
+
? null
|
|
3637
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps)))),
|
|
3491
3638
|
data.version && (React.createElement(Box, { mb: 5, pos: "relative" },
|
|
3492
3639
|
React.createElement(VersionBadge, { value: data.version }),
|
|
3493
3640
|
React.createElement(NodeAnnotation, { change: versionChanged }))),
|
|
@@ -3523,7 +3670,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3523
3670
|
isDeprecated && React.createElement(DeprecatedBadge, null),
|
|
3524
3671
|
isInternal && React.createElement(InternalBadge, null))),
|
|
3525
3672
|
React.createElement(NodeAnnotation, { change: titleChanged })),
|
|
3526
|
-
|
|
3673
|
+
localStorage.getItem('use_new_mask_workflow') === 'true'
|
|
3674
|
+
? null
|
|
3675
|
+
: exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3527
3676
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3528
3677
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3529
3678
|
const getMaskProperties = () => {
|
|
@@ -3534,7 +3683,11 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3534
3683
|
const { location, paths } = configEntry;
|
|
3535
3684
|
paths.forEach((item) => {
|
|
3536
3685
|
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3537
|
-
|
|
3686
|
+
let object = { path: fullPath };
|
|
3687
|
+
if (item.hasOwnProperty('required')) {
|
|
3688
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3689
|
+
}
|
|
3690
|
+
absolutePathsToHide.push(object);
|
|
3538
3691
|
});
|
|
3539
3692
|
});
|
|
3540
3693
|
}
|