@stoplight/elements-core 9.0.1 → 9.0.3
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 -0
- package/components/Docs/HttpOperation/Body.d.ts +7 -1
- package/components/Docs/HttpOperation/HttpOperation.d.ts +6 -2
- package/components/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +25 -0
- package/components/Docs/HttpOperation/Request.d.ts +6 -0
- package/components/Docs/HttpOperation/Responses.d.ts +11 -1
- package/index.esm.js +267 -17
- package/index.js +267 -17
- package/index.mjs +267 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -136,6 +136,8 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
136
136
|
return !!someObject[originalObjectSymbol];
|
|
137
137
|
};
|
|
138
138
|
const getOriginalObject = (resolvedObject) => {
|
|
139
|
+
if (!resolvedObject)
|
|
140
|
+
return resolvedObject;
|
|
139
141
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
140
142
|
if (!originalObject) {
|
|
141
143
|
return resolvedObject;
|
|
@@ -715,6 +717,7 @@ const persistAtom = (key, atomInstance) => {
|
|
|
715
717
|
};
|
|
716
718
|
|
|
717
719
|
const convertRequestToSample = (language, library, request) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
720
|
+
var _a;
|
|
718
721
|
if (!httpsnippetLite.isValidTargetId(language))
|
|
719
722
|
return null;
|
|
720
723
|
try {
|
|
@@ -728,6 +731,12 @@ const convertRequestToSample = (language, library, request) => tslib.__awaiter(v
|
|
|
728
731
|
}
|
|
729
732
|
if (typeof converted === 'string') {
|
|
730
733
|
converted = converted.replace(/%7B/g, '{').replace(/%7D/g, '}');
|
|
734
|
+
if (language === 'shell' && library === 'curl') {
|
|
735
|
+
const isUrlEncoded = (_a = request === null || request === void 0 ? void 0 : request.headers) === null || _a === void 0 ? void 0 : _a.some(header => header.name.toLowerCase() === 'content-type' && header.value === 'application/x-www-form-urlencoded');
|
|
736
|
+
if (isUrlEncoded) {
|
|
737
|
+
converted = converted.replace(/--data\b/g, '--data-urlencode');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
731
740
|
}
|
|
732
741
|
return converted;
|
|
733
742
|
}
|
|
@@ -2749,13 +2758,214 @@ const PanelContent = ({ schemes }) => {
|
|
|
2749
2758
|
})));
|
|
2750
2759
|
};
|
|
2751
2760
|
|
|
2761
|
+
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2762
|
+
function resolvePointer(obj, pointer) {
|
|
2763
|
+
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2764
|
+
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2765
|
+
}
|
|
2766
|
+
function detectCircularPath(path) {
|
|
2767
|
+
const ignored = ['properties', 'items'];
|
|
2768
|
+
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2769
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2770
|
+
const current = parts[i];
|
|
2771
|
+
const rest = parts.slice(i + 1);
|
|
2772
|
+
if (rest.includes(current)) {
|
|
2773
|
+
return true;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return false;
|
|
2777
|
+
}
|
|
2778
|
+
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2779
|
+
if (!node || typeof node !== 'object')
|
|
2780
|
+
return node;
|
|
2781
|
+
if (depth > maxDepth)
|
|
2782
|
+
return node;
|
|
2783
|
+
if (node.$ref || node['x-iata-$ref']) {
|
|
2784
|
+
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2785
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2786
|
+
if (visited.has(node))
|
|
2787
|
+
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2788
|
+
visited.add(node);
|
|
2789
|
+
const target = resolvePointer(root, refPath);
|
|
2790
|
+
if (!target)
|
|
2791
|
+
return node;
|
|
2792
|
+
const result = Object.assign({}, target);
|
|
2793
|
+
if ('description' in node)
|
|
2794
|
+
result.description = node.description;
|
|
2795
|
+
if ('title' in node)
|
|
2796
|
+
result.title = node.title;
|
|
2797
|
+
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2798
|
+
}
|
|
2799
|
+
if (Array.isArray(node)) {
|
|
2800
|
+
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2801
|
+
}
|
|
2802
|
+
const result = {};
|
|
2803
|
+
for (const key in node) {
|
|
2804
|
+
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2805
|
+
}
|
|
2806
|
+
return result;
|
|
2807
|
+
}
|
|
2808
|
+
const trimSlashes = (str) => {
|
|
2809
|
+
return str.replace(/^\/|\/$/g, '');
|
|
2810
|
+
};
|
|
2811
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], parentRequired, propertyKey, subType, }) => {
|
|
2812
|
+
var _a, _b, _c, _d;
|
|
2813
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
2814
|
+
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2815
|
+
React.useState(() => {
|
|
2816
|
+
const disabledPaths = hideData || [];
|
|
2817
|
+
const initialState = {};
|
|
2818
|
+
if (disabledPaths) {
|
|
2819
|
+
for (const p of disabledPaths) {
|
|
2820
|
+
const { path } = p;
|
|
2821
|
+
initialState[path] = { checked: false, required: 0 };
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
return initialState;
|
|
2825
|
+
});
|
|
2826
|
+
const shouldHideNode = React.useMemo(() => {
|
|
2827
|
+
const currentPath = trimSlashes(path);
|
|
2828
|
+
const data = hideData.some(hideEntry => {
|
|
2829
|
+
const hideEntryPath = trimSlashes(hideEntry.path);
|
|
2830
|
+
return hideEntryPath === currentPath;
|
|
2831
|
+
});
|
|
2832
|
+
return data;
|
|
2833
|
+
}, [path, hideData]);
|
|
2834
|
+
if (!schema || shouldHideNode) {
|
|
2835
|
+
return null;
|
|
2836
|
+
}
|
|
2837
|
+
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';
|
|
2838
|
+
const handleToggle = () => {
|
|
2839
|
+
const circular = detectCircularPath(path);
|
|
2840
|
+
if (!circular) {
|
|
2841
|
+
setExpanded(prev => !prev);
|
|
2842
|
+
}
|
|
2843
|
+
};
|
|
2844
|
+
const renderChildren = () => {
|
|
2845
|
+
var _a, _b, _c, _d;
|
|
2846
|
+
if (!expanded && !isRoot)
|
|
2847
|
+
return null;
|
|
2848
|
+
const children = [];
|
|
2849
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2850
|
+
for (const [key, child] of Object.entries(schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2851
|
+
const childPath = `${path}/properties/${key}`;
|
|
2852
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2853
|
+
const resolved = dereference(child, root);
|
|
2854
|
+
if (!shouldHideChild) {
|
|
2855
|
+
children.push(React.createElement("li", { key: key },
|
|
2856
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, 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 })));
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2861
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2862
|
+
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2863
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2864
|
+
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2865
|
+
const itemsPath = `${path}/items`;
|
|
2866
|
+
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2867
|
+
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2868
|
+
const childPath = `${itemsPath}/properties/${key}`;
|
|
2869
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2870
|
+
if (!shouldHideChild) {
|
|
2871
|
+
children.push(React.createElement("li", { key: key },
|
|
2872
|
+
React.createElement(LazySchemaTreePreviewer, { schema: dereference(child, root), root: root, title: key, level: level + 2, path: childPath, hideData: hideData, parentRequired: resolvedItems.required, propertyKey: key, subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2877
|
+
const childPath = `${path}/items`;
|
|
2878
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2879
|
+
if (!shouldHideChild) {
|
|
2880
|
+
children.push(React.createElement("li", { key: "items" },
|
|
2881
|
+
React.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, 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 })));
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
return children.length > 0 ? React.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2886
|
+
};
|
|
2887
|
+
const renderMinEnums = (schema) => {
|
|
2888
|
+
if (!schema || typeof schema !== 'object')
|
|
2889
|
+
return null;
|
|
2890
|
+
const boxStyle = {
|
|
2891
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
2892
|
+
border: '1px solid #a0aec0',
|
|
2893
|
+
borderRadius: '4px',
|
|
2894
|
+
padding: '0px 2px',
|
|
2895
|
+
display: 'inline-block',
|
|
2896
|
+
overflowWrap: 'break-word',
|
|
2897
|
+
textAlign: 'left',
|
|
2898
|
+
maxWidth: 'fit-content',
|
|
2899
|
+
maxHeight: 'fit-content',
|
|
2900
|
+
};
|
|
2901
|
+
if ('minItems' in schema) {
|
|
2902
|
+
const schemaWithMinItems = schema;
|
|
2903
|
+
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
2904
|
+
return (React.createElement(mosaic.Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
2908
|
+
return (React.createElement("div", null,
|
|
2909
|
+
"Allowed values:",
|
|
2910
|
+
' ',
|
|
2911
|
+
schema.enum.map((val, idx) => (React.createElement(mosaic.Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
2912
|
+
}
|
|
2913
|
+
return null;
|
|
2914
|
+
};
|
|
2915
|
+
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
2916
|
+
let showRequiredLabel = false;
|
|
2917
|
+
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
2918
|
+
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
2919
|
+
showRequiredLabel = true;
|
|
2920
|
+
}
|
|
2921
|
+
return (React.createElement("div", { className: "mb-1" },
|
|
2922
|
+
React.createElement(mosaic.Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
2923
|
+
React.createElement(mosaic.VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
2924
|
+
React.createElement(mosaic.Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
2925
|
+
!isRoot ? (React.createElement(mosaic.Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
2926
|
+
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
2927
|
+
!detectCircularPath(path) &&
|
|
2928
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
2929
|
+
!(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" })),
|
|
2930
|
+
' ' + displayTitle)) : null,
|
|
2931
|
+
!isRoot ? (React.createElement(mosaic.Box, { mr: 2 },
|
|
2932
|
+
React.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
2933
|
+
(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.type) || (root === null || root === void 0 ? void 0 : root.title),
|
|
2934
|
+
(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,
|
|
2935
|
+
subType ? `[${subType}]` : ''),
|
|
2936
|
+
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))) : null),
|
|
2937
|
+
React.createElement(mosaic.Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
2938
|
+
(schema === null || schema === void 0 ? void 0 : schema.description) && (React.createElement(mosaic.Box, { fontFamily: "ui", fontWeight: "light" },
|
|
2939
|
+
React.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
2940
|
+
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React.createElement(mosaic.Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
2941
|
+
React.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
2942
|
+
React.createElement(mosaic.Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
2943
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
2944
|
+
border: '1px solid #a0aec0',
|
|
2945
|
+
borderRadius: '4px',
|
|
2946
|
+
padding: '4px 8px',
|
|
2947
|
+
display: 'inline-block',
|
|
2948
|
+
overflowWrap: 'break-word',
|
|
2949
|
+
textAlign: 'left',
|
|
2950
|
+
maxWidth: '530px',
|
|
2951
|
+
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
2952
|
+
React.createElement(mosaic.Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
2953
|
+
typeof schema === 'object' &&
|
|
2954
|
+
('minItems' in schema || 'enum' in schema) &&
|
|
2955
|
+
renderMinEnums(schema))),
|
|
2956
|
+
!isRoot && (React.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
2957
|
+
React.createElement(mosaic.Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
2958
|
+
React.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
2959
|
+
renderChildren()));
|
|
2960
|
+
};
|
|
2961
|
+
|
|
2752
2962
|
const isBodyEmpty = (body) => {
|
|
2753
2963
|
if (!body)
|
|
2754
2964
|
return true;
|
|
2755
2965
|
const { contents = [], description } = body;
|
|
2756
2966
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2757
2967
|
};
|
|
2758
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
2968
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
|
|
2759
2969
|
var _a;
|
|
2760
2970
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2761
2971
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
@@ -2768,13 +2978,25 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
|
2768
2978
|
const { contents = [], description } = body;
|
|
2769
2979
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
2770
2980
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
2981
|
+
const getMaskProperties = () => {
|
|
2982
|
+
const disablePropsConfig = disableProps || [];
|
|
2983
|
+
const absolutePathsToHide = [];
|
|
2984
|
+
disablePropsConfig.forEach(configEntry => {
|
|
2985
|
+
const { location, paths } = configEntry;
|
|
2986
|
+
paths.forEach(item => {
|
|
2987
|
+
const fullPath = `${location}/${item.path}`;
|
|
2988
|
+
absolutePathsToHide.push({ path: fullPath });
|
|
2989
|
+
});
|
|
2990
|
+
});
|
|
2991
|
+
return absolutePathsToHide;
|
|
2992
|
+
};
|
|
2771
2993
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2772
2994
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2773
2995
|
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" })))),
|
|
2774
2996
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2775
2997
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2776
2998
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2777
|
-
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
2999
|
+
schema && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties() })) : (isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
|
|
2778
3000
|
};
|
|
2779
3001
|
Body.displayName = 'HttpOperation.Body';
|
|
2780
3002
|
|
|
@@ -2841,7 +3063,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2841
3063
|
return schema;
|
|
2842
3064
|
};
|
|
2843
3065
|
|
|
2844
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3066
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
|
|
2845
3067
|
if (!request || typeof request !== 'object')
|
|
2846
3068
|
return null;
|
|
2847
3069
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2869,7 +3091,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2869
3091
|
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2870
3092
|
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2871
3093
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2872
|
-
body && React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3094
|
+
body && (React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
|
|
2873
3095
|
};
|
|
2874
3096
|
Request.displayName = 'HttpOperation.Request';
|
|
2875
3097
|
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2900,7 +3122,7 @@ const OptionalMessage$1 = () => {
|
|
|
2900
3122
|
return React__namespace.createElement(mosaic.Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
2901
3123
|
};
|
|
2902
3124
|
|
|
2903
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3125
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
|
|
2904
3126
|
var _a, _b;
|
|
2905
3127
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
2906
3128
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -2933,11 +3155,11 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2933
3155
|
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)))));
|
|
2934
3156
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2935
3157
|
React__namespace.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
2936
|
-
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 },
|
|
2937
|
-
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3158
|
+
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 },
|
|
3159
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
|
|
2938
3160
|
};
|
|
2939
3161
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2940
|
-
const Response = ({ response, onMediaTypeChange }) => {
|
|
3162
|
+
const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
|
|
2941
3163
|
const { contents = [], headers = [], description } = response;
|
|
2942
3164
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
2943
3165
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -2948,6 +3170,18 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2948
3170
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2949
3171
|
}, [responseContent]);
|
|
2950
3172
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3173
|
+
const getMaskProperties = () => {
|
|
3174
|
+
if (!disableProps || !statusCode)
|
|
3175
|
+
return [];
|
|
3176
|
+
const configEntries = disableProps[statusCode] || [];
|
|
3177
|
+
const absolutePathsToHide = [];
|
|
3178
|
+
configEntries.forEach(({ location, paths }) => {
|
|
3179
|
+
paths.forEach(item => {
|
|
3180
|
+
absolutePathsToHide.push({ path: `${location}/${item.path}` });
|
|
3181
|
+
});
|
|
3182
|
+
});
|
|
3183
|
+
return absolutePathsToHide;
|
|
3184
|
+
};
|
|
2951
3185
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2952
3186
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2953
3187
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -2959,7 +3193,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2959
3193
|
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2960
3194
|
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2961
3195
|
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" }))),
|
|
2962
|
-
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 }))))));
|
|
3196
|
+
schema && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties() })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
2963
3197
|
};
|
|
2964
3198
|
Response.displayName = 'HttpOperation.Response';
|
|
2965
3199
|
const codeToIntentVal = (code) => {
|
|
@@ -3005,7 +3239,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
3005
3239
|
};
|
|
3006
3240
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
3007
3241
|
|
|
3008
|
-
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3242
|
+
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
|
|
3009
3243
|
var _a;
|
|
3010
3244
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3011
3245
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3036,8 +3270,8 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
3036
3270
|
React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3037
3271
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3038
3272
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3039
|
-
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3040
|
-
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3273
|
+
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 }),
|
|
3274
|
+
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 })),
|
|
3041
3275
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3042
3276
|
isCompact && tryItPanel));
|
|
3043
3277
|
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
@@ -3291,7 +3525,7 @@ const HttpServiceComponent = React__namespace.memo(({ data: unresolvedData, loca
|
|
|
3291
3525
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3292
3526
|
const HttpService = reactErrorBoundary.withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3293
3527
|
|
|
3294
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3528
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
|
|
3295
3529
|
var _a, _b;
|
|
3296
3530
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3297
3531
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3314,13 +3548,27 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3314
3548
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3315
3549
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3316
3550
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3551
|
+
const getMaskProperties = () => {
|
|
3552
|
+
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3553
|
+
const absolutePathsToHide = [];
|
|
3554
|
+
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3555
|
+
disablePropsConfig.forEach((configEntry) => {
|
|
3556
|
+
const { location, paths } = configEntry;
|
|
3557
|
+
paths.forEach((item) => {
|
|
3558
|
+
const fullPath = `${location}/${item.path}`;
|
|
3559
|
+
absolutePathsToHide.push({ path: fullPath });
|
|
3560
|
+
});
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
3563
|
+
return absolutePathsToHide;
|
|
3564
|
+
};
|
|
3317
3565
|
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
3318
3566
|
data.description && data.type === 'object' && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
3319
3567
|
React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3320
3568
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
3321
3569
|
React__namespace.createElement(NodeVendorExtensions, { data: data }),
|
|
3322
|
-
isCompact && modelExamples,
|
|
3323
|
-
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3570
|
+
localStorage.getItem('use_new_mask_workflow') !== 'true' && isCompact && modelExamples,
|
|
3571
|
+
data && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React__namespace.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties() })) : (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
|
|
3324
3572
|
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3325
3573
|
};
|
|
3326
3574
|
const ModelExamples = React__namespace.memo(({ data, isCollapsible = false }) => {
|
|
@@ -3356,17 +3604,19 @@ const Docs = React__namespace.memo((_a) => {
|
|
|
3356
3604
|
return (React__namespace.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3357
3605
|
});
|
|
3358
3606
|
const ParsedDocs = (_a) => {
|
|
3607
|
+
var _b;
|
|
3359
3608
|
var { node, nodeUnsupported } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported"]);
|
|
3609
|
+
const disableProps = (_b = node.data) === null || _b === void 0 ? void 0 : _b.disableProps;
|
|
3360
3610
|
switch (node.type) {
|
|
3361
3611
|
case 'article':
|
|
3362
3612
|
return React__namespace.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3363
3613
|
case 'http_operation':
|
|
3364
3614
|
case 'http_webhook':
|
|
3365
|
-
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3615
|
+
return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: disableProps }, commonProps));
|
|
3366
3616
|
case 'http_service':
|
|
3367
3617
|
return React__namespace.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3368
3618
|
case 'model':
|
|
3369
|
-
return React__namespace.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3619
|
+
return React__namespace.createElement(Model, Object.assign({ data: node.data, disableProps: disableProps }, commonProps));
|
|
3370
3620
|
default:
|
|
3371
3621
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3372
3622
|
return null;
|