@stoplight/elements-core 9.0.9 → 9.0.11
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 +458 -41
- package/index.js +458 -42
- package/index.mjs +458 -41
- package/package.json +1 -1
- package/styled.d.ts +3 -10
package/index.js
CHANGED
|
@@ -54,7 +54,6 @@ var omitBy = require('lodash/omitBy.js');
|
|
|
54
54
|
var reactQuery = require('react-query');
|
|
55
55
|
var server_js = require('react-router-dom/server.js');
|
|
56
56
|
var $RefParser = require('@stoplight/json-schema-ref-parser');
|
|
57
|
-
var PropTypes = require('prop-types');
|
|
58
57
|
var isEqual = require('lodash/isEqual.js');
|
|
59
58
|
var ReactDOM = require('react-dom');
|
|
60
59
|
|
|
@@ -77,7 +76,6 @@ function _interopNamespaceDefault(e) {
|
|
|
77
76
|
|
|
78
77
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
79
78
|
var Sampler__namespace = /*#__PURE__*/_interopNamespaceDefault(Sampler);
|
|
80
|
-
var PropTypes__namespace = /*#__PURE__*/_interopNamespaceDefault(PropTypes);
|
|
81
79
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
|
|
82
80
|
|
|
83
81
|
const defaultResolver = (contextObject) => ({ pointer }, _, currentObject) => {
|
|
@@ -136,6 +134,8 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
136
134
|
return !!someObject[originalObjectSymbol];
|
|
137
135
|
};
|
|
138
136
|
const getOriginalObject = (resolvedObject) => {
|
|
137
|
+
if (!resolvedObject)
|
|
138
|
+
return resolvedObject;
|
|
139
139
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
140
140
|
if (!originalObject) {
|
|
141
141
|
return resolvedObject;
|
|
@@ -2761,13 +2761,358 @@ const PanelContent = ({ schemes }) => {
|
|
|
2761
2761
|
})));
|
|
2762
2762
|
};
|
|
2763
2763
|
|
|
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
|
+
|
|
2764
3109
|
const isBodyEmpty = (body) => {
|
|
2765
3110
|
if (!body)
|
|
2766
3111
|
return true;
|
|
2767
3112
|
const { contents = [], description } = body;
|
|
2768
3113
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2769
3114
|
};
|
|
2770
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
3115
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
|
|
2771
3116
|
var _a;
|
|
2772
3117
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2773
3118
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
@@ -2780,13 +3125,36 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
|
2780
3125
|
const { contents = [], description } = body;
|
|
2781
3126
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
2782
3127
|
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);
|
|
2783
3151
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2784
3152
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2785
3153
|
React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
2786
3154
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2787
3155
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2788
3156
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2789
|
-
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
3157
|
+
schema && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties(), complexData: disableProps })) : (isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
|
|
2790
3158
|
};
|
|
2791
3159
|
Body.displayName = 'HttpOperation.Body';
|
|
2792
3160
|
|
|
@@ -2853,7 +3221,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2853
3221
|
return schema;
|
|
2854
3222
|
};
|
|
2855
3223
|
|
|
2856
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3224
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
|
|
2857
3225
|
if (!request || typeof request !== 'object')
|
|
2858
3226
|
return null;
|
|
2859
3227
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2881,7 +3249,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2881
3249
|
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2882
3250
|
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2883
3251
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2884
|
-
body && React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3252
|
+
body && (React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
|
|
2885
3253
|
};
|
|
2886
3254
|
Request.displayName = 'HttpOperation.Request';
|
|
2887
3255
|
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2912,7 +3280,7 @@ const OptionalMessage$1 = () => {
|
|
|
2912
3280
|
return React__namespace.createElement(mosaic.Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
2913
3281
|
};
|
|
2914
3282
|
|
|
2915
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3283
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
|
|
2916
3284
|
var _a, _b;
|
|
2917
3285
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
2918
3286
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -2945,11 +3313,12 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2945
3313
|
const tabResponses = (React__namespace.createElement(mosaic.TabList, { density: "compact" }, responses.map(({ code }) => (React__namespace.createElement(mosaic.Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
2946
3314
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2947
3315
|
React__namespace.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
2948
|
-
isCompact ? (React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
2949
|
-
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3316
|
+
isCompact ? (React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: activeResponseId })) : (React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
3317
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
|
|
2950
3318
|
};
|
|
2951
3319
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2952
|
-
const Response = ({ response, onMediaTypeChange }) => {
|
|
3320
|
+
const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
|
|
3321
|
+
var _a, _b;
|
|
2953
3322
|
const { contents = [], headers = [], description } = response;
|
|
2954
3323
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
2955
3324
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -2960,6 +3329,29 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2960
3329
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2961
3330
|
}, [responseContent]);
|
|
2962
3331
|
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;
|
|
2963
3355
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2964
3356
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2965
3357
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -2971,7 +3363,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2971
3363
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2972
3364
|
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2973
3365
|
React__namespace.createElement(mosaic.Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
2974
|
-
schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3366
|
+
schema && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties(), complexData: disableProps && statusCode ? disableProps[statusCode] : [] })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
2975
3367
|
};
|
|
2976
3368
|
Response.displayName = 'HttpOperation.Response';
|
|
2977
3369
|
const codeToIntentVal = (code) => {
|
|
@@ -3020,7 +3412,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
3020
3412
|
};
|
|
3021
3413
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
3022
3414
|
|
|
3023
|
-
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3415
|
+
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
|
|
3024
3416
|
var _a;
|
|
3025
3417
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3026
3418
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3051,11 +3443,11 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
3051
3443
|
React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3052
3444
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3053
3445
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3054
|
-
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3055
|
-
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3446
|
+
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data), disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.request }),
|
|
3447
|
+
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact, disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.response })),
|
|
3056
3448
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3057
3449
|
isCompact && tryItPanel));
|
|
3058
|
-
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
3450
|
+
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideOperationTryIt) && !isCompact && tryItPanel }));
|
|
3059
3451
|
});
|
|
3060
3452
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
3061
3453
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
@@ -3306,7 +3698,7 @@ const HttpServiceComponent = React__namespace.memo(({ data: unresolvedData, loca
|
|
|
3306
3698
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3307
3699
|
const HttpService = reactErrorBoundary.withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3308
3700
|
|
|
3309
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3701
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
|
|
3310
3702
|
var _a, _b;
|
|
3311
3703
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3312
3704
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3329,14 +3721,40 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3329
3721
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3330
3722
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3331
3723
|
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;
|
|
3332
3750
|
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
3333
3751
|
data.description && data.type === 'object' && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
3334
3752
|
React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3335
3753
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3336
3754
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3337
|
-
isCompact && modelExamples,
|
|
3338
|
-
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3339
|
-
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3755
|
+
!(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && isCompact && modelExamples,
|
|
3756
|
+
data && shouldUseLazySchema ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties(), complexData: disableProps === null || disableProps === void 0 ? void 0 : disableProps.models })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
|
|
3757
|
+
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && !isCompact && modelExamples }));
|
|
3340
3758
|
};
|
|
3341
3759
|
const ModelExamples = React__namespace.memo(({ data, isCollapsible = false }) => {
|
|
3342
3760
|
var _a;
|
|
@@ -3358,30 +3776,41 @@ const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverable
|
|
|
3358
3776
|
|
|
3359
3777
|
const Docs = React__namespace.memo((_a) => {
|
|
3360
3778
|
var _b;
|
|
3361
|
-
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3779
|
+
var { nodeType, nodeData, disableProps, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "disableProps", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3362
3780
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
3363
3781
|
if (!parsedNode) {
|
|
3364
3782
|
(_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
|
|
3365
3783
|
return null;
|
|
3366
3784
|
}
|
|
3367
|
-
let elem = React__namespace.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
3785
|
+
let elem = React__namespace.createElement(ParsedDocs, Object.assign({ node: parsedNode, disableProps: disableProps }, commonProps));
|
|
3368
3786
|
if (useNodeForRefResolving) {
|
|
3369
3787
|
elem = (React__namespace.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
|
|
3370
3788
|
}
|
|
3371
3789
|
return (React__namespace.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3372
3790
|
});
|
|
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
|
+
};
|
|
3373
3801
|
const ParsedDocs = (_a) => {
|
|
3374
|
-
var { node, nodeUnsupported } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported"]);
|
|
3802
|
+
var { node, nodeUnsupported, disableProps } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported", "disableProps"]);
|
|
3803
|
+
const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
|
|
3375
3804
|
switch (node.type) {
|
|
3376
3805
|
case 'article':
|
|
3377
3806
|
return React__namespace.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3378
3807
|
case 'http_operation':
|
|
3379
3808
|
case 'http_webhook':
|
|
3380
|
-
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3809
|
+
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideOperationTryIt }) }, commonProps));
|
|
3381
3810
|
case 'http_service':
|
|
3382
3811
|
return React__namespace.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3383
3812
|
case 'model':
|
|
3384
|
-
return React__namespace.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3813
|
+
return React__namespace.createElement(Model, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideModelTryIt }) }, commonProps));
|
|
3385
3814
|
default:
|
|
3386
3815
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3387
3816
|
return null;
|
|
@@ -4127,25 +4556,12 @@ const doBundle = (data, baseUrl) => {
|
|
|
4127
4556
|
}
|
|
4128
4557
|
};
|
|
4129
4558
|
|
|
4130
|
-
const
|
|
4131
|
-
|
|
4132
|
-
getChildContext() {
|
|
4133
|
-
return {
|
|
4134
|
-
blueprintPortalClassName: scopeClassName,
|
|
4135
|
-
};
|
|
4136
|
-
}
|
|
4137
|
-
render() {
|
|
4138
|
-
return (React__namespace.createElement(mosaic.Box, { className: "sl-elements sl-antialiased", fontFamily: "ui", fontSize: "base", color: "body", h: "full" }, this.props.children));
|
|
4139
|
-
}
|
|
4140
|
-
}
|
|
4141
|
-
Styled.childContextTypes = {
|
|
4142
|
-
blueprintPortalClassName: PropTypes__namespace.string,
|
|
4559
|
+
const Styled = ({ children }) => {
|
|
4560
|
+
return (React__namespace.createElement(mosaic.Box, { className: "sl-elements sl-antialiased", fontFamily: "ui", fontSize: "base", color: "body", h: "full" }, children));
|
|
4143
4561
|
};
|
|
4144
4562
|
function withStyles(Component) {
|
|
4145
|
-
const Inner = props =>
|
|
4146
|
-
|
|
4147
|
-
React__namespace.createElement(Component, Object.assign({}, props))));
|
|
4148
|
-
};
|
|
4563
|
+
const Inner = props => (React__namespace.createElement(Styled, null,
|
|
4564
|
+
React__namespace.createElement(Component, Object.assign({}, props))));
|
|
4149
4565
|
Inner.displayName = `withStyles(${getDisplayName(Component)})`;
|
|
4150
4566
|
return Inner;
|
|
4151
4567
|
}
|
|
@@ -4195,7 +4611,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
4195
4611
|
}
|
|
4196
4612
|
disconnectedCallback() {
|
|
4197
4613
|
if (this._mountPoint) {
|
|
4198
|
-
ReactDOM__namespace.
|
|
4614
|
+
ReactDOM__namespace.render(null, this._mountPoint);
|
|
4199
4615
|
this.removeChild(this._mountPoint);
|
|
4200
4616
|
this._mountPoint = undefined;
|
|
4201
4617
|
}
|