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