@stoplight/elements-core 9.0.12 → 9.0.13-beta-0.2
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 +479 -27
- package/index.js +480 -27
- package/index.mjs +479 -27
- package/package.json +1 -1
- package/styled.d.ts +10 -3
package/index.esm.js
CHANGED
|
@@ -54,6 +54,7 @@ import omitBy from 'lodash/omitBy.js';
|
|
|
54
54
|
import { QueryClient, useQueryClient, QueryClientProvider } from 'react-query';
|
|
55
55
|
import { StaticRouter } from 'react-router-dom/server.js';
|
|
56
56
|
import $RefParser from '@stoplight/json-schema-ref-parser';
|
|
57
|
+
import * as PropTypes from 'prop-types';
|
|
57
58
|
import isEqual from 'lodash/isEqual.js';
|
|
58
59
|
import * as ReactDOM from 'react-dom';
|
|
59
60
|
|
|
@@ -113,6 +114,8 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
113
114
|
return !!someObject[originalObjectSymbol];
|
|
114
115
|
};
|
|
115
116
|
const getOriginalObject = (resolvedObject) => {
|
|
117
|
+
if (!resolvedObject)
|
|
118
|
+
return resolvedObject;
|
|
116
119
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
117
120
|
if (!originalObject) {
|
|
118
121
|
return resolvedObject;
|
|
@@ -2738,13 +2741,360 @@ const PanelContent = ({ schemes }) => {
|
|
|
2738
2741
|
})));
|
|
2739
2742
|
};
|
|
2740
2743
|
|
|
2744
|
+
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2745
|
+
function resolvePointer(obj, pointer) {
|
|
2746
|
+
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2747
|
+
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2748
|
+
}
|
|
2749
|
+
function detectCircularPath(path) {
|
|
2750
|
+
const ignored = ['properties', 'items'];
|
|
2751
|
+
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2752
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2753
|
+
const current = parts[i];
|
|
2754
|
+
const rest = parts.slice(i + 1);
|
|
2755
|
+
if (rest.includes(current)) {
|
|
2756
|
+
return true;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
return false;
|
|
2760
|
+
}
|
|
2761
|
+
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2762
|
+
if (!node || typeof node !== 'object')
|
|
2763
|
+
return node;
|
|
2764
|
+
if (depth > maxDepth)
|
|
2765
|
+
return node;
|
|
2766
|
+
if (node.$ref || node['x-iata-$ref']) {
|
|
2767
|
+
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2768
|
+
if (refPath.includes('#/%24defs')) {
|
|
2769
|
+
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2770
|
+
}
|
|
2771
|
+
else {
|
|
2772
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2773
|
+
}
|
|
2774
|
+
if (visited.has(node))
|
|
2775
|
+
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2776
|
+
visited.add(node);
|
|
2777
|
+
const target = resolvePointer(root, refPath);
|
|
2778
|
+
if (!target)
|
|
2779
|
+
return node;
|
|
2780
|
+
const result = Object.assign({}, target);
|
|
2781
|
+
if ('description' in node)
|
|
2782
|
+
result.description = node.description;
|
|
2783
|
+
if ('title' in node)
|
|
2784
|
+
result.title = node.title;
|
|
2785
|
+
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2786
|
+
}
|
|
2787
|
+
if (Array.isArray(node)) {
|
|
2788
|
+
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2789
|
+
}
|
|
2790
|
+
const result = {};
|
|
2791
|
+
for (const key in node) {
|
|
2792
|
+
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2793
|
+
}
|
|
2794
|
+
return result;
|
|
2795
|
+
}
|
|
2796
|
+
const trimSlashes = (str) => {
|
|
2797
|
+
return str.replace(/^\/|\/$/g, '');
|
|
2798
|
+
};
|
|
2799
|
+
function isPropertiesAllHidden(path, hideData) {
|
|
2800
|
+
const current = trimSlashes(path);
|
|
2801
|
+
const parts = current.split('/');
|
|
2802
|
+
for (let i = parts.length; i >= 2; i--) {
|
|
2803
|
+
if (parts[i - 1] === 'properties') {
|
|
2804
|
+
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2805
|
+
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2806
|
+
if (block && block.required === undefined) {
|
|
2807
|
+
return true;
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
return false;
|
|
2812
|
+
}
|
|
2813
|
+
function isRequiredOverride(path, hideData) {
|
|
2814
|
+
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2815
|
+
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2816
|
+
}
|
|
2817
|
+
function isPathHidden(path, hideData, complexData) {
|
|
2818
|
+
const isComplex = checkIfIsComplex(path, complexData);
|
|
2819
|
+
if (isComplex === null) {
|
|
2820
|
+
return false;
|
|
2821
|
+
}
|
|
2822
|
+
else if (isComplex) {
|
|
2823
|
+
const normalizedPath = trimSlashes(path);
|
|
2824
|
+
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2825
|
+
if (direct && direct.required === undefined)
|
|
2826
|
+
return true;
|
|
2827
|
+
if (isPropertiesAllHidden(path, hideData))
|
|
2828
|
+
return true;
|
|
2829
|
+
for (const h of hideData) {
|
|
2830
|
+
const hPath = trimSlashes(h.path);
|
|
2831
|
+
if (h.required !== undefined)
|
|
2832
|
+
continue;
|
|
2833
|
+
if (normalizedPath.length > hPath.length &&
|
|
2834
|
+
normalizedPath.startsWith(hPath) &&
|
|
2835
|
+
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2836
|
+
return true;
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
return false;
|
|
2840
|
+
}
|
|
2841
|
+
else {
|
|
2842
|
+
return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
const checkIfIsComplex = (path, complexData) => {
|
|
2846
|
+
let isComplex = null;
|
|
2847
|
+
for (const complex of complexData) {
|
|
2848
|
+
if (path.startsWith(complex.location)) {
|
|
2849
|
+
isComplex = complex === null || complex === void 0 ? void 0 : complex.isComplex;
|
|
2850
|
+
break;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
return isComplex;
|
|
2854
|
+
};
|
|
2855
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], complexData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2856
|
+
var _a, _b, _c, _d;
|
|
2857
|
+
const [expanded, setExpanded] = useState(false);
|
|
2858
|
+
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
2859
|
+
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
2860
|
+
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
2861
|
+
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2862
|
+
if (isRoot)
|
|
2863
|
+
console.log('LazySchemaTreePreviewer 9.0.13-beta-0.2----------', schema);
|
|
2864
|
+
useEffect(() => {
|
|
2865
|
+
setSelectedSchemaIndex(0);
|
|
2866
|
+
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2867
|
+
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2868
|
+
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2869
|
+
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2870
|
+
const shouldHideNode = useMemo(() => {
|
|
2871
|
+
if (isRoot)
|
|
2872
|
+
return false;
|
|
2873
|
+
if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined)
|
|
2874
|
+
return true;
|
|
2875
|
+
return false;
|
|
2876
|
+
}, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
|
|
2877
|
+
if (!schema || shouldHideNode) {
|
|
2878
|
+
return null;
|
|
2879
|
+
}
|
|
2880
|
+
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';
|
|
2881
|
+
const handleToggle = () => {
|
|
2882
|
+
const circular = detectCircularPath(path);
|
|
2883
|
+
if (!circular) {
|
|
2884
|
+
setExpanded(prev => !prev);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
const renderChildren = () => {
|
|
2888
|
+
var _a, _b, _c, _d;
|
|
2889
|
+
if (shouldHideAllChildren)
|
|
2890
|
+
return null;
|
|
2891
|
+
if (!expanded && !isRoot)
|
|
2892
|
+
return null;
|
|
2893
|
+
const children = [];
|
|
2894
|
+
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))) {
|
|
2895
|
+
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2896
|
+
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2897
|
+
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2898
|
+
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2902
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2903
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2904
|
+
}
|
|
2905
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2906
|
+
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2907
|
+
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2908
|
+
}
|
|
2909
|
+
for (const [key, child] of Object.entries(props || {})) {
|
|
2910
|
+
const childPath = `${path}/properties/${key}`;
|
|
2911
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2912
|
+
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2913
|
+
const resolved = dereference(child, root);
|
|
2914
|
+
if (!shouldHideChild) {
|
|
2915
|
+
children.push(React__default.createElement("li", { key: key },
|
|
2916
|
+
React__default.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 })));
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2921
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2922
|
+
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2923
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2924
|
+
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2925
|
+
const itemsPath = `${path}/items`;
|
|
2926
|
+
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2927
|
+
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2928
|
+
const childPath = `${itemsPath}/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__default.createElement("li", { key: key },
|
|
2934
|
+
React__default.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 })));
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2939
|
+
const childPath = `${path}/items`;
|
|
2940
|
+
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2941
|
+
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2942
|
+
if (!shouldHideChild) {
|
|
2943
|
+
children.push(React__default.createElement("li", { key: "items" },
|
|
2944
|
+
React__default.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 })));
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2949
|
+
};
|
|
2950
|
+
const combinedSchemaSelector = () => {
|
|
2951
|
+
var _a;
|
|
2952
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
2953
|
+
React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2954
|
+
React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2955
|
+
zIndex: 1000,
|
|
2956
|
+
top: '100%',
|
|
2957
|
+
left: 0,
|
|
2958
|
+
minWidth: '150px',
|
|
2959
|
+
maxWidth: '200px',
|
|
2960
|
+
marginTop: '2px',
|
|
2961
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2962
|
+
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
2963
|
+
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',
|
|
2964
|
+
gap: '8px',
|
|
2965
|
+
}, onMouseEnter: (e) => {
|
|
2966
|
+
if (selectedSchemaIndex !== index) {
|
|
2967
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2968
|
+
}
|
|
2969
|
+
}, onMouseLeave: (e) => {
|
|
2970
|
+
if (selectedSchemaIndex !== index) {
|
|
2971
|
+
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2972
|
+
}
|
|
2973
|
+
}, onClick: () => {
|
|
2974
|
+
setSelectedSchemaIndex(index);
|
|
2975
|
+
setShowSchemaDropdown(false);
|
|
2976
|
+
} },
|
|
2977
|
+
React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2978
|
+
selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2979
|
+
};
|
|
2980
|
+
const renderMinEnums = (schema) => {
|
|
2981
|
+
if (!schema || typeof schema !== 'object')
|
|
2982
|
+
return null;
|
|
2983
|
+
const boxStyle = {
|
|
2984
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
2985
|
+
border: '1px solid #a0aec0',
|
|
2986
|
+
borderRadius: '4px',
|
|
2987
|
+
padding: '0px 2px',
|
|
2988
|
+
display: 'inline-block',
|
|
2989
|
+
overflowWrap: 'break-word',
|
|
2990
|
+
textAlign: 'left',
|
|
2991
|
+
maxWidth: 'fit-content',
|
|
2992
|
+
maxHeight: 'fit-content',
|
|
2993
|
+
};
|
|
2994
|
+
if ('minItems' in schema) {
|
|
2995
|
+
const schemaWithMinItems = schema;
|
|
2996
|
+
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
2997
|
+
return (React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
3001
|
+
return (React__default.createElement("div", null,
|
|
3002
|
+
"Allowed values:",
|
|
3003
|
+
' ',
|
|
3004
|
+
schema.enum.map((val, idx) => (React__default.createElement(Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
3005
|
+
}
|
|
3006
|
+
return null;
|
|
3007
|
+
};
|
|
3008
|
+
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
3009
|
+
let showRequiredLabel = false;
|
|
3010
|
+
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
3011
|
+
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
3012
|
+
showRequiredLabel = true;
|
|
3013
|
+
}
|
|
3014
|
+
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
3015
|
+
schema = dereference(schema, root);
|
|
3016
|
+
}
|
|
3017
|
+
return (React__default.createElement("div", { className: "mb-1" },
|
|
3018
|
+
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
3019
|
+
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
3020
|
+
React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
3021
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
3022
|
+
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
3023
|
+
!detectCircularPath(path) &&
|
|
3024
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
3025
|
+
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
3026
|
+
' ' + displayTitle)) : null,
|
|
3027
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
|
|
3028
|
+
React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3029
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3030
|
+
setIsHoveringSelector(true);
|
|
3031
|
+
}
|
|
3032
|
+
}, onMouseLeave: () => {
|
|
3033
|
+
if (!showSchemaDropdown) {
|
|
3034
|
+
setIsHoveringSelector(false);
|
|
3035
|
+
}
|
|
3036
|
+
}, onClick: (e) => {
|
|
3037
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3038
|
+
e.stopPropagation();
|
|
3039
|
+
setShowSchemaDropdown(prev => !prev);
|
|
3040
|
+
}
|
|
3041
|
+
}, style: {
|
|
3042
|
+
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3043
|
+
} },
|
|
3044
|
+
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3045
|
+
(() => {
|
|
3046
|
+
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);
|
|
3047
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3048
|
+
return `any of ${typeDisplay}`;
|
|
3049
|
+
}
|
|
3050
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3051
|
+
return `one of ${typeDisplay}`;
|
|
3052
|
+
}
|
|
3053
|
+
return typeDisplay;
|
|
3054
|
+
})(),
|
|
3055
|
+
(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),
|
|
3056
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3057
|
+
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3058
|
+
transition: 'opacity 0.2s',
|
|
3059
|
+
} },
|
|
3060
|
+
React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3061
|
+
fontSize: '10px',
|
|
3062
|
+
opacity: 0.6,
|
|
3063
|
+
} })))),
|
|
3064
|
+
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3065
|
+
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
3066
|
+
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
3067
|
+
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
3068
|
+
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
3069
|
+
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React__default.createElement(Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
3070
|
+
React__default.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
3071
|
+
React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
3072
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
3073
|
+
border: '1px solid #a0aec0',
|
|
3074
|
+
borderRadius: '4px',
|
|
3075
|
+
padding: '4px 8px',
|
|
3076
|
+
display: 'inline-block',
|
|
3077
|
+
overflowWrap: 'break-word',
|
|
3078
|
+
textAlign: 'left',
|
|
3079
|
+
maxWidth: '530px',
|
|
3080
|
+
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
3081
|
+
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
3082
|
+
typeof schema === 'object' &&
|
|
3083
|
+
('minItems' in schema || 'enum' in schema) &&
|
|
3084
|
+
renderMinEnums(schema))),
|
|
3085
|
+
!isRoot && (React__default.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
3086
|
+
React__default.createElement(Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React__default.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
3087
|
+
React__default.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
3088
|
+
renderChildren()));
|
|
3089
|
+
};
|
|
3090
|
+
|
|
2741
3091
|
const isBodyEmpty = (body) => {
|
|
2742
3092
|
if (!body)
|
|
2743
3093
|
return true;
|
|
2744
3094
|
const { contents = [], description } = body;
|
|
2745
3095
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2746
3096
|
};
|
|
2747
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
3097
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
|
|
2748
3098
|
var _a;
|
|
2749
3099
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2750
3100
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -2757,13 +3107,37 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
|
2757
3107
|
const { contents = [], description } = body;
|
|
2758
3108
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
2759
3109
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
3110
|
+
const getMaskProperties = () => {
|
|
3111
|
+
const disablePropsConfig = disableProps || [];
|
|
3112
|
+
const absolutePathsToHide = [];
|
|
3113
|
+
disablePropsConfig.forEach(configEntry => {
|
|
3114
|
+
const { location, paths, isComplex } = configEntry;
|
|
3115
|
+
if (paths.length === 0 && !isComplex) {
|
|
3116
|
+
absolutePathsToHide.push({ path: location });
|
|
3117
|
+
}
|
|
3118
|
+
else {
|
|
3119
|
+
paths.forEach((item) => {
|
|
3120
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3121
|
+
let object = { path: fullPath };
|
|
3122
|
+
if (item.hasOwnProperty('required')) {
|
|
3123
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3124
|
+
}
|
|
3125
|
+
absolutePathsToHide.push(object);
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
});
|
|
3129
|
+
return absolutePathsToHide;
|
|
3130
|
+
};
|
|
3131
|
+
const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
|
|
3132
|
+
console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
|
|
3133
|
+
console.log("Responses 9.0.13-beta-0.2----", disableProps);
|
|
2760
3134
|
return (React.createElement(VStack, { spacing: 6 },
|
|
2761
3135
|
React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2762
3136
|
React.createElement(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" })))),
|
|
2763
3137
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2764
3138
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
2765
3139
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2766
|
-
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
3140
|
+
schema && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties(), complexData: disableProps })) : (isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
|
|
2767
3141
|
};
|
|
2768
3142
|
Body.displayName = 'HttpOperation.Body';
|
|
2769
3143
|
|
|
@@ -2830,7 +3204,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2830
3204
|
return schema;
|
|
2831
3205
|
};
|
|
2832
3206
|
|
|
2833
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3207
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
|
|
2834
3208
|
if (!request || typeof request !== 'object')
|
|
2835
3209
|
return null;
|
|
2836
3210
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2858,7 +3232,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2858
3232
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
2859
3233
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2860
3234
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2861
|
-
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3235
|
+
body && (React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
|
|
2862
3236
|
};
|
|
2863
3237
|
Request.displayName = 'HttpOperation.Request';
|
|
2864
3238
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2889,7 +3263,7 @@ const OptionalMessage$1 = () => {
|
|
|
2889
3263
|
return React.createElement(Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
2890
3264
|
};
|
|
2891
3265
|
|
|
2892
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3266
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
|
|
2893
3267
|
var _a, _b;
|
|
2894
3268
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
2895
3269
|
const [activeResponseId, setActiveResponseId] = React.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -2922,11 +3296,12 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2922
3296
|
const tabResponses = (React.createElement(TabList, { density: "compact" }, responses.map(({ code }) => (React.createElement(Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
2923
3297
|
return (React.createElement(VStack, { spacing: 8, as: Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2924
3298
|
React.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
2925
|
-
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
2926
|
-
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3299
|
+
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: activeResponseId })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
3300
|
+
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
|
|
2927
3301
|
};
|
|
2928
3302
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2929
|
-
const Response = ({ response, onMediaTypeChange }) => {
|
|
3303
|
+
const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
|
|
3304
|
+
var _a, _b;
|
|
2930
3305
|
const { contents = [], headers = [], description } = response;
|
|
2931
3306
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
2932
3307
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -2937,6 +3312,30 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2937
3312
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2938
3313
|
}, [responseContent]);
|
|
2939
3314
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3315
|
+
const getMaskProperties = () => {
|
|
3316
|
+
if (!disableProps || !statusCode)
|
|
3317
|
+
return [];
|
|
3318
|
+
const configEntries = disableProps[statusCode] || [];
|
|
3319
|
+
const absolutePathsToHide = [];
|
|
3320
|
+
configEntries.forEach(({ location, paths, isComplex }) => {
|
|
3321
|
+
if (paths.length === 0 && !isComplex) {
|
|
3322
|
+
absolutePathsToHide.push({ path: location });
|
|
3323
|
+
}
|
|
3324
|
+
else {
|
|
3325
|
+
paths.forEach((item) => {
|
|
3326
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3327
|
+
let object = { path: fullPath };
|
|
3328
|
+
if (item.hasOwnProperty('required')) {
|
|
3329
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3330
|
+
}
|
|
3331
|
+
absolutePathsToHide.push(object);
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
});
|
|
3335
|
+
return absolutePathsToHide;
|
|
3336
|
+
};
|
|
3337
|
+
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;
|
|
3338
|
+
console.log("Responses 9.0.13-beta-0.2----", disableProps);
|
|
2940
3339
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
2941
3340
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2942
3341
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -2948,7 +3347,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2948
3347
|
React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2949
3348
|
React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2950
3349
|
React.createElement(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" }))),
|
|
2951
|
-
schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3350
|
+
schema && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties(), complexData: disableProps && statusCode ? disableProps[statusCode] : [] })) : (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
2952
3351
|
};
|
|
2953
3352
|
Response.displayName = 'HttpOperation.Response';
|
|
2954
3353
|
const codeToIntentVal = (code) => {
|
|
@@ -2997,7 +3396,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
2997
3396
|
};
|
|
2998
3397
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
2999
3398
|
|
|
3000
|
-
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3399
|
+
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
|
|
3001
3400
|
var _a;
|
|
3002
3401
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3003
3402
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3010,6 +3409,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
3010
3409
|
const [requestBodyIndex, setTextRequestBodyIndex] = React.useState(0);
|
|
3011
3410
|
const prettyName = (data.summary || data.iid || '').trim();
|
|
3012
3411
|
const hasBadges = isDeprecated || isInternal;
|
|
3412
|
+
console.log("HttpOperationComponent 9.0.13-beta-0.2----", disableProps);
|
|
3013
3413
|
let path;
|
|
3014
3414
|
if (isHttpOperation(data)) {
|
|
3015
3415
|
path = data.path;
|
|
@@ -3028,11 +3428,11 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
3028
3428
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3029
3429
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3030
3430
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3031
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3032
|
-
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3431
|
+
React.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 }),
|
|
3432
|
+
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact, disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.response })),
|
|
3033
3433
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3034
3434
|
isCompact && tryItPanel));
|
|
3035
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
3435
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideOperationTryIt) && !isCompact && tryItPanel }));
|
|
3036
3436
|
});
|
|
3037
3437
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
3038
3438
|
const HttpOperation = withErrorBoundary(HttpOperationComponent, {
|
|
@@ -3283,7 +3683,7 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3283
3683
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3284
3684
|
const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3285
3685
|
|
|
3286
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3686
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
|
|
3287
3687
|
var _a, _b;
|
|
3288
3688
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3289
3689
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3294,6 +3694,7 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3294
3694
|
const isDeprecated = !!data['deprecated'];
|
|
3295
3695
|
const isInternal = !!data['x-internal'];
|
|
3296
3696
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
3697
|
+
console.log("ModelComponent 9.0.13-beta-0.2----", disableProps);
|
|
3297
3698
|
const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
|
|
3298
3699
|
const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
|
|
3299
3700
|
React.createElement(Box, { pos: "relative" },
|
|
@@ -3306,14 +3707,40 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3306
3707
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3307
3708
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3308
3709
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3710
|
+
const getMaskProperties = () => {
|
|
3711
|
+
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3712
|
+
const absolutePathsToHide = [];
|
|
3713
|
+
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3714
|
+
disablePropsConfig.forEach((configEntry) => {
|
|
3715
|
+
const { location, paths, isComplex } = configEntry;
|
|
3716
|
+
if (paths.length === 0 && !isComplex) {
|
|
3717
|
+
absolutePathsToHide.push({ path: location });
|
|
3718
|
+
}
|
|
3719
|
+
else {
|
|
3720
|
+
paths.forEach((item) => {
|
|
3721
|
+
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3722
|
+
let object = { path: fullPath };
|
|
3723
|
+
if (item.hasOwnProperty('required')) {
|
|
3724
|
+
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3725
|
+
}
|
|
3726
|
+
absolutePathsToHide.push(object);
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
});
|
|
3730
|
+
}
|
|
3731
|
+
return absolutePathsToHide;
|
|
3732
|
+
};
|
|
3733
|
+
const shouldUseLazySchema = disableProps && (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models)
|
|
3734
|
+
? disableProps.models.some((entry) => entry.isComplex === true)
|
|
3735
|
+
: false;
|
|
3309
3736
|
const description = (React.createElement(VStack, { spacing: 10 },
|
|
3310
3737
|
data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
|
|
3311
3738
|
React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3312
3739
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3313
3740
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3314
|
-
isCompact && modelExamples,
|
|
3315
|
-
React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3316
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3741
|
+
!(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && isCompact && modelExamples,
|
|
3742
|
+
data && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties(), complexData: disableProps === null || disableProps === void 0 ? void 0 : disableProps.models })) : (React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
|
|
3743
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && !isCompact && modelExamples }));
|
|
3317
3744
|
};
|
|
3318
3745
|
const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
|
|
3319
3746
|
var _a;
|
|
@@ -3335,30 +3762,42 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
|
3335
3762
|
|
|
3336
3763
|
const Docs = React.memo((_a) => {
|
|
3337
3764
|
var _b;
|
|
3338
|
-
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3765
|
+
var { nodeType, nodeData, disableProps, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "disableProps", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3339
3766
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
3340
3767
|
if (!parsedNode) {
|
|
3341
3768
|
(_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
|
|
3342
3769
|
return null;
|
|
3343
3770
|
}
|
|
3344
|
-
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
3771
|
+
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode, disableProps: disableProps }, commonProps));
|
|
3345
3772
|
if (useNodeForRefResolving) {
|
|
3346
3773
|
elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
|
|
3347
3774
|
}
|
|
3348
3775
|
return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3349
3776
|
});
|
|
3777
|
+
const getTryItVisibility = (disableProps) => {
|
|
3778
|
+
var _a, _b, _c, _d;
|
|
3779
|
+
if (!disableProps)
|
|
3780
|
+
return { hideOperationTryIt: false, hideModelTryIt: false };
|
|
3781
|
+
const requestHasComplex = (_b = (_a = disableProps.request) === null || _a === void 0 ? void 0 : _a.some(item => item.isComplex)) !== null && _b !== void 0 ? _b : false;
|
|
3782
|
+
const responseHasComplex = Object.values(disableProps.response || {}).some(arr => arr.some(item => item.isComplex));
|
|
3783
|
+
const hideOperationTryIt = requestHasComplex || responseHasComplex;
|
|
3784
|
+
const hideModelTryIt = (_d = (_c = disableProps.models) === null || _c === void 0 ? void 0 : _c.some(item => item.isComplex)) !== null && _d !== void 0 ? _d : false;
|
|
3785
|
+
return { hideOperationTryIt, hideModelTryIt };
|
|
3786
|
+
};
|
|
3350
3787
|
const ParsedDocs = (_a) => {
|
|
3351
|
-
var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
|
|
3788
|
+
var { node, nodeUnsupported, disableProps } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported", "disableProps"]);
|
|
3789
|
+
const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
|
|
3790
|
+
console.log("Parsed Docs 9.0.13-beta-0.2----", disableProps);
|
|
3352
3791
|
switch (node.type) {
|
|
3353
3792
|
case 'article':
|
|
3354
3793
|
return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3355
3794
|
case 'http_operation':
|
|
3356
3795
|
case 'http_webhook':
|
|
3357
|
-
return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3796
|
+
return React.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideOperationTryIt }) }, commonProps));
|
|
3358
3797
|
case 'http_service':
|
|
3359
3798
|
return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3360
3799
|
case 'model':
|
|
3361
|
-
return React.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3800
|
+
return React.createElement(Model, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideModelTryIt }) }, commonProps));
|
|
3362
3801
|
default:
|
|
3363
3802
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3364
3803
|
return null;
|
|
@@ -4104,12 +4543,25 @@ const doBundle = (data, baseUrl) => {
|
|
|
4104
4543
|
}
|
|
4105
4544
|
};
|
|
4106
4545
|
|
|
4107
|
-
const
|
|
4108
|
-
|
|
4546
|
+
const scopeClassName = 'sl-elements';
|
|
4547
|
+
class Styled extends React.Component {
|
|
4548
|
+
getChildContext() {
|
|
4549
|
+
return {
|
|
4550
|
+
blueprintPortalClassName: scopeClassName,
|
|
4551
|
+
};
|
|
4552
|
+
}
|
|
4553
|
+
render() {
|
|
4554
|
+
return (React.createElement(Box, { className: "sl-elements sl-antialiased", fontFamily: "ui", fontSize: "base", color: "body", h: "full" }, this.props.children));
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
Styled.childContextTypes = {
|
|
4558
|
+
blueprintPortalClassName: PropTypes.string,
|
|
4109
4559
|
};
|
|
4110
4560
|
function withStyles(Component) {
|
|
4111
|
-
const Inner = props =>
|
|
4112
|
-
React.createElement(
|
|
4561
|
+
const Inner = props => {
|
|
4562
|
+
return (React.createElement(Styled, null,
|
|
4563
|
+
React.createElement(Component, Object.assign({}, props))));
|
|
4564
|
+
};
|
|
4113
4565
|
Inner.displayName = `withStyles(${getDisplayName(Component)})`;
|
|
4114
4566
|
return Inner;
|
|
4115
4567
|
}
|
|
@@ -4159,7 +4611,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
4159
4611
|
}
|
|
4160
4612
|
disconnectedCallback() {
|
|
4161
4613
|
if (this._mountPoint) {
|
|
4162
|
-
ReactDOM.
|
|
4614
|
+
ReactDOM.unmountComponentAtNode(this._mountPoint);
|
|
4163
4615
|
this.removeChild(this._mountPoint);
|
|
4164
4616
|
this._mountPoint = undefined;
|
|
4165
4617
|
}
|