@stoplight/elements-core 9.0.9 → 9.0.10
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/Docs.d.ts +14 -1
- package/components/Docs/HttpOperation/Body.d.ts +9 -1
- package/components/Docs/HttpOperation/HttpOperation.d.ts +6 -2
- package/components/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +34 -0
- package/components/Docs/HttpOperation/Request.d.ts +6 -0
- package/components/Docs/HttpOperation/Responses.d.ts +12 -1
- package/index.esm.js +453 -22
- package/index.js +453 -22
- package/index.mjs +453 -22
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -136,6 +136,8 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
136
136
|
return !!someObject[originalObjectSymbol];
|
|
137
137
|
};
|
|
138
138
|
const getOriginalObject = (resolvedObject) => {
|
|
139
|
+
if (!resolvedObject)
|
|
140
|
+
return resolvedObject;
|
|
139
141
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
140
142
|
if (!originalObject) {
|
|
141
143
|
return resolvedObject;
|
|
@@ -2761,13 +2763,358 @@ const PanelContent = ({ schemes }) => {
|
|
|
2761
2763
|
})));
|
|
2762
2764
|
};
|
|
2763
2765
|
|
|
2766
|
+
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2767
|
+
function resolvePointer(obj, pointer) {
|
|
2768
|
+
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2769
|
+
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2770
|
+
}
|
|
2771
|
+
function detectCircularPath(path) {
|
|
2772
|
+
const ignored = ['properties', 'items'];
|
|
2773
|
+
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2774
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2775
|
+
const current = parts[i];
|
|
2776
|
+
const rest = parts.slice(i + 1);
|
|
2777
|
+
if (rest.includes(current)) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return false;
|
|
2782
|
+
}
|
|
2783
|
+
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2784
|
+
if (!node || typeof node !== 'object')
|
|
2785
|
+
return node;
|
|
2786
|
+
if (depth > maxDepth)
|
|
2787
|
+
return node;
|
|
2788
|
+
if (node.$ref || node['x-iata-$ref']) {
|
|
2789
|
+
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2790
|
+
if (refPath.includes('#/%24defs')) {
|
|
2791
|
+
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2792
|
+
}
|
|
2793
|
+
else {
|
|
2794
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2795
|
+
}
|
|
2796
|
+
if (visited.has(node))
|
|
2797
|
+
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2798
|
+
visited.add(node);
|
|
2799
|
+
const target = resolvePointer(root, refPath);
|
|
2800
|
+
if (!target)
|
|
2801
|
+
return node;
|
|
2802
|
+
const result = Object.assign({}, target);
|
|
2803
|
+
if ('description' in node)
|
|
2804
|
+
result.description = node.description;
|
|
2805
|
+
if ('title' in node)
|
|
2806
|
+
result.title = node.title;
|
|
2807
|
+
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2808
|
+
}
|
|
2809
|
+
if (Array.isArray(node)) {
|
|
2810
|
+
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2811
|
+
}
|
|
2812
|
+
const result = {};
|
|
2813
|
+
for (const key in node) {
|
|
2814
|
+
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2815
|
+
}
|
|
2816
|
+
return result;
|
|
2817
|
+
}
|
|
2818
|
+
const trimSlashes = (str) => {
|
|
2819
|
+
return str.replace(/^\/|\/$/g, '');
|
|
2820
|
+
};
|
|
2821
|
+
function isPropertiesAllHidden(path, hideData) {
|
|
2822
|
+
const current = trimSlashes(path);
|
|
2823
|
+
const parts = current.split('/');
|
|
2824
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
2825
|
+
if (parts[i - 1] === 'properties') {
|
|
2826
|
+
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2827
|
+
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2828
|
+
if (block && block.required === undefined) {
|
|
2829
|
+
return true;
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
return false;
|
|
2834
|
+
}
|
|
2835
|
+
function isRequiredOverride(path, hideData) {
|
|
2836
|
+
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2837
|
+
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2838
|
+
}
|
|
2839
|
+
function isPathHidden(path, hideData, complexData) {
|
|
2840
|
+
const isComplex = checkIfIsComplex(path, complexData);
|
|
2841
|
+
if (isComplex === null) {
|
|
2842
|
+
return false;
|
|
2843
|
+
}
|
|
2844
|
+
else if (isComplex) {
|
|
2845
|
+
const normalizedPath = trimSlashes(path);
|
|
2846
|
+
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2847
|
+
if (direct && direct.required === undefined)
|
|
2848
|
+
return true;
|
|
2849
|
+
if (isPropertiesAllHidden(path, hideData))
|
|
2850
|
+
return true;
|
|
2851
|
+
for (const h of hideData) {
|
|
2852
|
+
const hPath = trimSlashes(h.path);
|
|
2853
|
+
if (h.required !== undefined)
|
|
2854
|
+
continue;
|
|
2855
|
+
if (normalizedPath.length > hPath.length &&
|
|
2856
|
+
normalizedPath.startsWith(hPath) &&
|
|
2857
|
+
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2858
|
+
return true;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
return false;
|
|
2862
|
+
}
|
|
2863
|
+
else {
|
|
2864
|
+
return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
const checkIfIsComplex = (path, complexData) => {
|
|
2868
|
+
let isComplex = null;
|
|
2869
|
+
for (const complex of complexData) {
|
|
2870
|
+
if (path.startsWith(complex.location)) {
|
|
2871
|
+
isComplex = complex === null || complex === void 0 ? void 0 : complex.isComplex;
|
|
2872
|
+
break;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
return isComplex;
|
|
2876
|
+
};
|
|
2877
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], complexData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2878
|
+
var _a, _b, _c, _d;
|
|
2879
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
2880
|
+
const [selectedSchemaIndex, setSelectedSchemaIndex] = React.useState(0);
|
|
2881
|
+
const [showSchemaDropdown, setShowSchemaDropdown] = React.useState(false);
|
|
2882
|
+
const [isHoveringSelector, setIsHoveringSelector] = React.useState(false);
|
|
2883
|
+
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2884
|
+
React.useEffect(() => {
|
|
2885
|
+
setSelectedSchemaIndex(0);
|
|
2886
|
+
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2887
|
+
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2888
|
+
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2889
|
+
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2890
|
+
const shouldHideNode = React.useMemo(() => {
|
|
2891
|
+
if (isRoot)
|
|
2892
|
+
return false;
|
|
2893
|
+
if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined)
|
|
2894
|
+
return true;
|
|
2895
|
+
return false;
|
|
2896
|
+
}, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
|
|
2897
|
+
if (!schema || shouldHideNode) {
|
|
2898
|
+
return null;
|
|
2899
|
+
}
|
|
2900
|
+
const displayTitle = level === 1 && (title === undefined || path === '') ? '' : (_a = title !== null && title !== void 0 ? title : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _a !== void 0 ? _a : 'Node';
|
|
2901
|
+
const handleToggle = () => {
|
|
2902
|
+
const circular = detectCircularPath(path);
|
|
2903
|
+
if (!circular) {
|
|
2904
|
+
setExpanded(prev => !prev);
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
const renderChildren = () => {
|
|
2908
|
+
var _a, _b, _c, _d;
|
|
2909
|
+
if (shouldHideAllChildren)
|
|
2910
|
+
return null;
|
|
2911
|
+
if (!expanded && !isRoot)
|
|
2912
|
+
return null;
|
|
2913
|
+
const children = [];
|
|
2914
|
+
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))) {
|
|
2915
|
+
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2916
|
+
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2917
|
+
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2918
|
+
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2922
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2923
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2924
|
+
}
|
|
2925
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2926
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2927
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2928
|
+
}
|
|
2929
|
+
for (const [key, child] of Object.entries(props || {})) {
|
|
2930
|
+
const childPath = `${path}/properties/${key}`;
|
|
2931
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2932
|
+
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2933
|
+
const resolved = dereference(child, root);
|
|
2934
|
+
if (!shouldHideChild) {
|
|
2935
|
+
children.push(React.createElement("li", { key: key },
|
|
2936
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, complexData: complexData, 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 })));
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2941
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2942
|
+
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2943
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2944
|
+
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2945
|
+
const itemsPath = `${path}/items`;
|
|
2946
|
+
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2947
|
+
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2948
|
+
const childPath = `${itemsPath}/properties/${key}`;
|
|
2949
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2950
|
+
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2951
|
+
const resolved = dereference(child, root);
|
|
2952
|
+
if (!shouldHideChild) {
|
|
2953
|
+
children.push(React.createElement("li", { key: key },
|
|
2954
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 2, path: childPath, hideData: hideData, complexData: complexData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2959
|
+
const childPath = `${path}/items`;
|
|
2960
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2961
|
+
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2962
|
+
if (!shouldHideChild) {
|
|
2963
|
+
children.push(React.createElement("li", { key: "items" },
|
|
2964
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, complexData: complexData, 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 })));
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
return children.length > 0 ? React.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2969
|
+
};
|
|
2970
|
+
const combinedSchemaSelector = () => {
|
|
2971
|
+
var _a;
|
|
2972
|
+
return (React.createElement(React.Fragment, null,
|
|
2973
|
+
React.createElement(mosaic.Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2974
|
+
React.createElement(mosaic.Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2975
|
+
zIndex: 1000,
|
|
2976
|
+
top: '100%',
|
|
2977
|
+
left: 0,
|
|
2978
|
+
minWidth: '150px',
|
|
2979
|
+
maxWidth: '200px',
|
|
2980
|
+
marginTop: '2px',
|
|
2981
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2982
|
+
}, 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: {
|
|
2983
|
+
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',
|
|
2984
|
+
gap: '8px',
|
|
2985
|
+
}, onMouseEnter: (e) => {
|
|
2986
|
+
if (selectedSchemaIndex !== index) {
|
|
2987
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2988
|
+
}
|
|
2989
|
+
}, onMouseLeave: (e) => {
|
|
2990
|
+
if (selectedSchemaIndex !== index) {
|
|
2991
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2992
|
+
}
|
|
2993
|
+
}, onClick: () => {
|
|
2994
|
+
setSelectedSchemaIndex(index);
|
|
2995
|
+
setShowSchemaDropdown(false);
|
|
2996
|
+
} },
|
|
2997
|
+
React.createElement(mosaic.Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2998
|
+
selectedSchemaIndex === index && (React.createElement(mosaic.Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2999
|
+
};
|
|
3000
|
+
const renderMinEnums = (schema) => {
|
|
3001
|
+
if (!schema || typeof schema !== 'object')
|
|
3002
|
+
return null;
|
|
3003
|
+
const boxStyle = {
|
|
3004
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
3005
|
+
border: '1px solid #a0aec0',
|
|
3006
|
+
borderRadius: '4px',
|
|
3007
|
+
padding: '0px 2px',
|
|
3008
|
+
display: 'inline-block',
|
|
3009
|
+
overflowWrap: 'break-word',
|
|
3010
|
+
textAlign: 'left',
|
|
3011
|
+
maxWidth: 'fit-content',
|
|
3012
|
+
maxHeight: 'fit-content',
|
|
3013
|
+
};
|
|
3014
|
+
if ('minItems' in schema) {
|
|
3015
|
+
const schemaWithMinItems = schema;
|
|
3016
|
+
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
3017
|
+
return (React.createElement(mosaic.Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
3021
|
+
return (React.createElement("div", null,
|
|
3022
|
+
"Allowed values:",
|
|
3023
|
+
' ',
|
|
3024
|
+
schema.enum.map((val, idx) => (React.createElement(mosaic.Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
3025
|
+
}
|
|
3026
|
+
return null;
|
|
3027
|
+
};
|
|
3028
|
+
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
3029
|
+
let showRequiredLabel = false;
|
|
3030
|
+
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
3031
|
+
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
3032
|
+
showRequiredLabel = true;
|
|
3033
|
+
}
|
|
3034
|
+
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
3035
|
+
schema = dereference(schema, root);
|
|
3036
|
+
}
|
|
3037
|
+
return (React.createElement("div", { className: "mb-1" },
|
|
3038
|
+
React.createElement(mosaic.Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
3039
|
+
React.createElement(mosaic.VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
3040
|
+
React.createElement(mosaic.Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
3041
|
+
!isRoot ? (React.createElement(mosaic.Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
3042
|
+
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
3043
|
+
!detectCircularPath(path) &&
|
|
3044
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
3045
|
+
!(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" })),
|
|
3046
|
+
' ' + displayTitle)) : null,
|
|
3047
|
+
!isRoot ? (React.createElement(mosaic.Box, { mr: 2, pos: "relative" },
|
|
3048
|
+
React.createElement(mosaic.Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3049
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3050
|
+
setIsHoveringSelector(true);
|
|
3051
|
+
}
|
|
3052
|
+
}, onMouseLeave: () => {
|
|
3053
|
+
if (!showSchemaDropdown) {
|
|
3054
|
+
setIsHoveringSelector(false);
|
|
3055
|
+
}
|
|
3056
|
+
}, onClick: (e) => {
|
|
3057
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3058
|
+
e.stopPropagation();
|
|
3059
|
+
setShowSchemaDropdown(prev => !prev);
|
|
3060
|
+
}
|
|
3061
|
+
}, style: {
|
|
3062
|
+
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3063
|
+
} },
|
|
3064
|
+
React.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3065
|
+
(() => {
|
|
3066
|
+
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);
|
|
3067
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3068
|
+
return `any of ${typeDisplay}`;
|
|
3069
|
+
}
|
|
3070
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3071
|
+
return `one of ${typeDisplay}`;
|
|
3072
|
+
}
|
|
3073
|
+
return typeDisplay;
|
|
3074
|
+
})(),
|
|
3075
|
+
(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),
|
|
3076
|
+
((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: {
|
|
3077
|
+
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3078
|
+
transition: 'opacity 0.2s',
|
|
3079
|
+
} },
|
|
3080
|
+
React.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3081
|
+
fontSize: '10px',
|
|
3082
|
+
opacity: 0.6,
|
|
3083
|
+
} })))),
|
|
3084
|
+
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),
|
|
3085
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
3086
|
+
React.createElement(mosaic.Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
3087
|
+
(schema === null || schema === void 0 ? void 0 : schema.description) && (React.createElement(mosaic.Box, { fontFamily: "ui", fontWeight: "light" },
|
|
3088
|
+
React.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
3089
|
+
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React.createElement(mosaic.Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
3090
|
+
React.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
3091
|
+
React.createElement(mosaic.Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
3092
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
3093
|
+
border: '1px solid #a0aec0',
|
|
3094
|
+
borderRadius: '4px',
|
|
3095
|
+
padding: '4px 8px',
|
|
3096
|
+
display: 'inline-block',
|
|
3097
|
+
overflowWrap: 'break-word',
|
|
3098
|
+
textAlign: 'left',
|
|
3099
|
+
maxWidth: '530px',
|
|
3100
|
+
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
3101
|
+
React.createElement(mosaic.Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
3102
|
+
typeof schema === 'object' &&
|
|
3103
|
+
('minItems' in schema || 'enum' in schema) &&
|
|
3104
|
+
renderMinEnums(schema))),
|
|
3105
|
+
!isRoot && (React.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
3106
|
+
React.createElement(mosaic.Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
3107
|
+
React.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
3108
|
+
renderChildren()));
|
|
3109
|
+
};
|
|
3110
|
+
|
|
2764
3111
|
const isBodyEmpty = (body) => {
|
|
2765
3112
|
if (!body)
|
|
2766
3113
|
return true;
|
|
2767
3114
|
const { contents = [], description } = body;
|
|
2768
3115
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2769
3116
|
};
|
|
2770
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
3117
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
|
|
2771
3118
|
var _a;
|
|
2772
3119
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2773
3120
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
@@ -2780,13 +3127,36 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
|
2780
3127
|
const { contents = [], description } = body;
|
|
2781
3128
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
2782
3129
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
3130
|
+
const getMaskProperties = () => {
|
|
3131
|
+
const disablePropsConfig = disableProps || [];
|
|
3132
|
+
const absolutePathsToHide = [];
|
|
3133
|
+
disablePropsConfig.forEach(configEntry => {
|
|
3134
|
+
const { location, paths, isComplex } = configEntry;
|
|
3135
|
+
if (paths.length === 0 && !isComplex) {
|
|
3136
|
+
absolutePathsToHide.push({ path: location });
|
|
3137
|
+
}
|
|
3138
|
+
else {
|
|
3139
|
+
paths.forEach((item) => {
|
|
3140
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3141
|
+
let object = { path: fullPath };
|
|
3142
|
+
if (item.hasOwnProperty('required')) {
|
|
3143
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3144
|
+
}
|
|
3145
|
+
absolutePathsToHide.push(object);
|
|
3146
|
+
});
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3149
|
+
return absolutePathsToHide;
|
|
3150
|
+
};
|
|
3151
|
+
const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
|
|
3152
|
+
console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
|
|
2783
3153
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2784
3154
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2785
3155
|
React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
2786
3156
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2787
3157
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2788
3158
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2789
|
-
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
3159
|
+
schema && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties(), complexData: disableProps })) : (isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
|
|
2790
3160
|
};
|
|
2791
3161
|
Body.displayName = 'HttpOperation.Body';
|
|
2792
3162
|
|
|
@@ -2853,7 +3223,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2853
3223
|
return schema;
|
|
2854
3224
|
};
|
|
2855
3225
|
|
|
2856
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3226
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
|
|
2857
3227
|
if (!request || typeof request !== 'object')
|
|
2858
3228
|
return null;
|
|
2859
3229
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2881,7 +3251,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2881
3251
|
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2882
3252
|
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2883
3253
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2884
|
-
body && React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3254
|
+
body && (React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
|
|
2885
3255
|
};
|
|
2886
3256
|
Request.displayName = 'HttpOperation.Request';
|
|
2887
3257
|
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2912,7 +3282,7 @@ const OptionalMessage$1 = () => {
|
|
|
2912
3282
|
return React__namespace.createElement(mosaic.Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
2913
3283
|
};
|
|
2914
3284
|
|
|
2915
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3285
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
|
|
2916
3286
|
var _a, _b;
|
|
2917
3287
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
2918
3288
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -2945,11 +3315,12 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2945
3315
|
const tabResponses = (React__namespace.createElement(mosaic.TabList, { density: "compact" }, responses.map(({ code }) => (React__namespace.createElement(mosaic.Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
2946
3316
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2947
3317
|
React__namespace.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
2948
|
-
isCompact ? (React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
2949
|
-
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3318
|
+
isCompact ? (React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: activeResponseId })) : (React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
3319
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
|
|
2950
3320
|
};
|
|
2951
3321
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2952
|
-
const Response = ({ response, onMediaTypeChange }) => {
|
|
3322
|
+
const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
|
|
3323
|
+
var _a, _b;
|
|
2953
3324
|
const { contents = [], headers = [], description } = response;
|
|
2954
3325
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
2955
3326
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -2960,6 +3331,29 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2960
3331
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2961
3332
|
}, [responseContent]);
|
|
2962
3333
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3334
|
+
const getMaskProperties = () => {
|
|
3335
|
+
if (!disableProps || !statusCode)
|
|
3336
|
+
return [];
|
|
3337
|
+
const configEntries = disableProps[statusCode] || [];
|
|
3338
|
+
const absolutePathsToHide = [];
|
|
3339
|
+
configEntries.forEach(({ location, paths, isComplex }) => {
|
|
3340
|
+
if (paths.length === 0 && !isComplex) {
|
|
3341
|
+
absolutePathsToHide.push({ path: location });
|
|
3342
|
+
}
|
|
3343
|
+
else {
|
|
3344
|
+
paths.forEach((item) => {
|
|
3345
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3346
|
+
let object = { path: fullPath };
|
|
3347
|
+
if (item.hasOwnProperty('required')) {
|
|
3348
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3349
|
+
}
|
|
3350
|
+
absolutePathsToHide.push(object);
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3353
|
+
});
|
|
3354
|
+
return absolutePathsToHide;
|
|
3355
|
+
};
|
|
3356
|
+
const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
|
|
2963
3357
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2964
3358
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2965
3359
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -2971,7 +3365,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2971
3365
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2972
3366
|
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2973
3367
|
React__namespace.createElement(mosaic.Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
2974
|
-
schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3368
|
+
schema && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties(), complexData: disableProps && statusCode ? disableProps[statusCode] : [] })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
2975
3369
|
};
|
|
2976
3370
|
Response.displayName = 'HttpOperation.Response';
|
|
2977
3371
|
const codeToIntentVal = (code) => {
|
|
@@ -3020,7 +3414,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
3020
3414
|
};
|
|
3021
3415
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
3022
3416
|
|
|
3023
|
-
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3417
|
+
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
|
|
3024
3418
|
var _a;
|
|
3025
3419
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3026
3420
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3051,11 +3445,11 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
3051
3445
|
React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3052
3446
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3053
3447
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3054
|
-
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3055
|
-
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3448
|
+
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data), disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.request }),
|
|
3449
|
+
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact, disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.response })),
|
|
3056
3450
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3057
3451
|
isCompact && tryItPanel));
|
|
3058
|
-
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
3452
|
+
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideOperationTryIt) && !isCompact && tryItPanel }));
|
|
3059
3453
|
});
|
|
3060
3454
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
3061
3455
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
@@ -3306,7 +3700,7 @@ const HttpServiceComponent = React__namespace.memo(({ data: unresolvedData, loca
|
|
|
3306
3700
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3307
3701
|
const HttpService = reactErrorBoundary.withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3308
3702
|
|
|
3309
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3703
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
|
|
3310
3704
|
var _a, _b;
|
|
3311
3705
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3312
3706
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3329,14 +3723,40 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3329
3723
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3330
3724
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3331
3725
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3726
|
+
const getMaskProperties = () => {
|
|
3727
|
+
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3728
|
+
const absolutePathsToHide = [];
|
|
3729
|
+
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3730
|
+
disablePropsConfig.forEach((configEntry) => {
|
|
3731
|
+
const { location, paths, isComplex } = configEntry;
|
|
3732
|
+
if (paths.length === 0 && !isComplex) {
|
|
3733
|
+
absolutePathsToHide.push({ path: location });
|
|
3734
|
+
}
|
|
3735
|
+
else {
|
|
3736
|
+
paths.forEach((item) => {
|
|
3737
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3738
|
+
let object = { path: fullPath };
|
|
3739
|
+
if (item.hasOwnProperty('required')) {
|
|
3740
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3741
|
+
}
|
|
3742
|
+
absolutePathsToHide.push(object);
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
return absolutePathsToHide;
|
|
3748
|
+
};
|
|
3749
|
+
const shouldUseLazySchema = disableProps && (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models)
|
|
3750
|
+
? disableProps.models.some((entry) => entry.isComplex === true)
|
|
3751
|
+
: false;
|
|
3332
3752
|
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
3333
3753
|
data.description && data.type === 'object' && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
3334
3754
|
React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3335
3755
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3336
3756
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3337
|
-
isCompact && modelExamples,
|
|
3338
|
-
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3339
|
-
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3757
|
+
!(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && isCompact && modelExamples,
|
|
3758
|
+
data && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties(), complexData: disableProps === null || disableProps === void 0 ? void 0 : disableProps.models })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
|
|
3759
|
+
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && !isCompact && modelExamples }));
|
|
3340
3760
|
};
|
|
3341
3761
|
const ModelExamples = React__namespace.memo(({ data, isCollapsible = false }) => {
|
|
3342
3762
|
var _a;
|
|
@@ -3358,30 +3778,41 @@ const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverable
|
|
|
3358
3778
|
|
|
3359
3779
|
const Docs = React__namespace.memo((_a) => {
|
|
3360
3780
|
var _b;
|
|
3361
|
-
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3781
|
+
var { nodeType, nodeData, disableProps, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "disableProps", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3362
3782
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
3363
3783
|
if (!parsedNode) {
|
|
3364
3784
|
(_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
|
|
3365
3785
|
return null;
|
|
3366
3786
|
}
|
|
3367
|
-
let elem = React__namespace.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
3787
|
+
let elem = React__namespace.createElement(ParsedDocs, Object.assign({ node: parsedNode, disableProps: disableProps }, commonProps));
|
|
3368
3788
|
if (useNodeForRefResolving) {
|
|
3369
3789
|
elem = (React__namespace.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
|
|
3370
3790
|
}
|
|
3371
3791
|
return (React__namespace.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3372
3792
|
});
|
|
3793
|
+
const getTryItVisibility = (disableProps) => {
|
|
3794
|
+
var _a, _b, _c, _d;
|
|
3795
|
+
if (!disableProps)
|
|
3796
|
+
return { hideOperationTryIt: false, hideModelTryIt: false };
|
|
3797
|
+
const requestHasComplex = (_b = (_a = disableProps.request) === null || _a === void 0 ? void 0 : _a.some(item => item.isComplex)) !== null && _b !== void 0 ? _b : false;
|
|
3798
|
+
const responseHasComplex = Object.values(disableProps.response || {}).some(arr => arr.some(item => item.isComplex));
|
|
3799
|
+
const hideOperationTryIt = requestHasComplex || responseHasComplex;
|
|
3800
|
+
const hideModelTryIt = (_d = (_c = disableProps.models) === null || _c === void 0 ? void 0 : _c.some(item => item.isComplex)) !== null && _d !== void 0 ? _d : false;
|
|
3801
|
+
return { hideOperationTryIt, hideModelTryIt };
|
|
3802
|
+
};
|
|
3373
3803
|
const ParsedDocs = (_a) => {
|
|
3374
|
-
var { node, nodeUnsupported } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported"]);
|
|
3804
|
+
var { node, nodeUnsupported, disableProps } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported", "disableProps"]);
|
|
3805
|
+
const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
|
|
3375
3806
|
switch (node.type) {
|
|
3376
3807
|
case 'article':
|
|
3377
3808
|
return React__namespace.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3378
3809
|
case 'http_operation':
|
|
3379
3810
|
case 'http_webhook':
|
|
3380
|
-
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3811
|
+
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideOperationTryIt }) }, commonProps));
|
|
3381
3812
|
case 'http_service':
|
|
3382
3813
|
return React__namespace.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3383
3814
|
case 'model':
|
|
3384
|
-
return React__namespace.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3815
|
+
return React__namespace.createElement(Model, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideModelTryIt }) }, commonProps));
|
|
3385
3816
|
default:
|
|
3386
3817
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3387
3818
|
return null;
|