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