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