@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
|
@@ -47,6 +47,7 @@ export interface DocsProps extends BaseDocsProps {
|
|
|
47
47
|
}
|
|
48
48
|
export interface DocsComponentProps<T = unknown> extends BaseDocsProps {
|
|
49
49
|
data: T;
|
|
50
|
+
disableProps?: any;
|
|
50
51
|
}
|
|
51
52
|
export declare const Docs: React.NamedExoticComponent<DocsProps>;
|
|
52
53
|
export interface ParsedDocsProps extends BaseDocsProps {
|
|
@@ -3,9 +3,15 @@ export interface BodyProps {
|
|
|
3
3
|
body: IHttpOperationRequestBody;
|
|
4
4
|
onChange?: (requestBodyIndex: number) => void;
|
|
5
5
|
isHttpWebhookOperation?: boolean;
|
|
6
|
+
disableProps?: Array<{
|
|
7
|
+
location: string;
|
|
8
|
+
paths: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
6
12
|
}
|
|
7
13
|
export declare const isBodyEmpty: (body?: BodyProps['body']) => boolean;
|
|
8
14
|
export declare const Body: {
|
|
9
|
-
({ body, onChange, isHttpWebhookOperation }: BodyProps): JSX.Element | null;
|
|
15
|
+
({ body, onChange, isHttpWebhookOperation, disableProps }: BodyProps): JSX.Element | null;
|
|
10
16
|
displayName: string;
|
|
11
17
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { IHttpEndpointOperation } from '@stoplight/types';
|
|
2
2
|
import { DocsComponentProps } from '..';
|
|
3
|
-
export declare type HttpOperationProps = DocsComponentProps<IHttpEndpointOperation
|
|
4
|
-
|
|
3
|
+
export declare type HttpOperationProps = DocsComponentProps<IHttpEndpointOperation> & {
|
|
4
|
+
disableProps?: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
export declare const HttpOperation: import("react").FunctionComponent<DocsComponentProps<IHttpEndpointOperation<false>> & {
|
|
7
|
+
disableProps?: Record<string, any> | undefined;
|
|
8
|
+
} & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
5
9
|
export declare function OperationHeader({ id, noHeading, hasBadges, name, isDeprecated, isInternal, hideServerUrl, method, path, }: {
|
|
6
10
|
id: string;
|
|
7
11
|
noHeading?: boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface LazySchemaTreePreviewerProps {
|
|
3
|
+
schema: any;
|
|
4
|
+
root?: any;
|
|
5
|
+
title?: string;
|
|
6
|
+
level?: number;
|
|
7
|
+
path?: string;
|
|
8
|
+
maskState?: Record<string, {
|
|
9
|
+
checked: boolean;
|
|
10
|
+
required: 0 | 1 | 2;
|
|
11
|
+
}>;
|
|
12
|
+
setMaskState?: React.Dispatch<React.SetStateAction<Record<string, {
|
|
13
|
+
checked: boolean;
|
|
14
|
+
required: 0 | 1 | 2;
|
|
15
|
+
}>>>;
|
|
16
|
+
hideData?: Array<{
|
|
17
|
+
path: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
parentRequired?: string[];
|
|
21
|
+
propertyKey?: string;
|
|
22
|
+
subType?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const LazySchemaTreePreviewer: React.FC<LazySchemaTreePreviewerProps>;
|
|
25
|
+
export default LazySchemaTreePreviewer;
|
|
@@ -5,6 +5,12 @@ interface IRequestProps {
|
|
|
5
5
|
hideSecurityInfo?: boolean;
|
|
6
6
|
onChange?: (requestBodyIndex: number) => void;
|
|
7
7
|
isHttpWebhookOperation?: boolean;
|
|
8
|
+
disableProps?: Array<{
|
|
9
|
+
location: string;
|
|
10
|
+
paths: Array<{
|
|
11
|
+
path: string;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
8
14
|
}
|
|
9
15
|
export declare const Request: React.FunctionComponent<IRequestProps>;
|
|
10
16
|
export {};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { IHttpOperationResponse } from '@stoplight/types';
|
|
2
|
+
interface DisablePropEntry {
|
|
3
|
+
location: string;
|
|
4
|
+
paths: Array<{
|
|
5
|
+
path: string;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
interface DisablePropsByStatus {
|
|
9
|
+
[statusCode: string]: DisablePropEntry[];
|
|
10
|
+
}
|
|
2
11
|
interface ResponsesProps {
|
|
3
12
|
responses: IHttpOperationResponse[];
|
|
4
13
|
onMediaTypeChange?: (mediaType: string) => void;
|
|
5
14
|
onStatusCodeChange?: (statusCode: string) => void;
|
|
6
15
|
isCompact?: boolean;
|
|
16
|
+
disableProps?: DisablePropsByStatus;
|
|
7
17
|
}
|
|
8
18
|
export declare const Responses: {
|
|
9
|
-
({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }: ResponsesProps): JSX.Element | null;
|
|
19
|
+
({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }: ResponsesProps): JSX.Element | null;
|
|
10
20
|
displayName: string;
|
|
11
21
|
};
|
|
12
22
|
export {};
|
package/index.esm.js
CHANGED
|
@@ -114,6 +114,8 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
114
114
|
return !!someObject[originalObjectSymbol];
|
|
115
115
|
};
|
|
116
116
|
const getOriginalObject = (resolvedObject) => {
|
|
117
|
+
if (!resolvedObject)
|
|
118
|
+
return resolvedObject;
|
|
117
119
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
118
120
|
if (!originalObject) {
|
|
119
121
|
return resolvedObject;
|
|
@@ -693,6 +695,7 @@ const persistAtom = (key, atomInstance) => {
|
|
|
693
695
|
};
|
|
694
696
|
|
|
695
697
|
const convertRequestToSample = (language, library, request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
698
|
+
var _a;
|
|
696
699
|
if (!isValidTargetId(language))
|
|
697
700
|
return null;
|
|
698
701
|
try {
|
|
@@ -706,6 +709,12 @@ const convertRequestToSample = (language, library, request) => __awaiter(void 0,
|
|
|
706
709
|
}
|
|
707
710
|
if (typeof converted === 'string') {
|
|
708
711
|
converted = converted.replace(/%7B/g, '{').replace(/%7D/g, '}');
|
|
712
|
+
if (language === 'shell' && library === 'curl') {
|
|
713
|
+
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');
|
|
714
|
+
if (isUrlEncoded) {
|
|
715
|
+
converted = converted.replace(/--data\b/g, '--data-urlencode');
|
|
716
|
+
}
|
|
717
|
+
}
|
|
709
718
|
}
|
|
710
719
|
return converted;
|
|
711
720
|
}
|
|
@@ -2727,13 +2736,214 @@ const PanelContent = ({ schemes }) => {
|
|
|
2727
2736
|
})));
|
|
2728
2737
|
};
|
|
2729
2738
|
|
|
2739
|
+
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2740
|
+
function resolvePointer(obj, pointer) {
|
|
2741
|
+
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2742
|
+
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2743
|
+
}
|
|
2744
|
+
function detectCircularPath(path) {
|
|
2745
|
+
const ignored = ['properties', 'items'];
|
|
2746
|
+
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2747
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2748
|
+
const current = parts[i];
|
|
2749
|
+
const rest = parts.slice(i + 1);
|
|
2750
|
+
if (rest.includes(current)) {
|
|
2751
|
+
return true;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
return false;
|
|
2755
|
+
}
|
|
2756
|
+
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2757
|
+
if (!node || typeof node !== 'object')
|
|
2758
|
+
return node;
|
|
2759
|
+
if (depth > maxDepth)
|
|
2760
|
+
return node;
|
|
2761
|
+
if (node.$ref || node['x-iata-$ref']) {
|
|
2762
|
+
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2763
|
+
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2764
|
+
if (visited.has(node))
|
|
2765
|
+
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2766
|
+
visited.add(node);
|
|
2767
|
+
const target = resolvePointer(root, refPath);
|
|
2768
|
+
if (!target)
|
|
2769
|
+
return node;
|
|
2770
|
+
const result = Object.assign({}, target);
|
|
2771
|
+
if ('description' in node)
|
|
2772
|
+
result.description = node.description;
|
|
2773
|
+
if ('title' in node)
|
|
2774
|
+
result.title = node.title;
|
|
2775
|
+
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2776
|
+
}
|
|
2777
|
+
if (Array.isArray(node)) {
|
|
2778
|
+
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2779
|
+
}
|
|
2780
|
+
const result = {};
|
|
2781
|
+
for (const key in node) {
|
|
2782
|
+
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2783
|
+
}
|
|
2784
|
+
return result;
|
|
2785
|
+
}
|
|
2786
|
+
const trimSlashes = (str) => {
|
|
2787
|
+
return str.replace(/^\/|\/$/g, '');
|
|
2788
|
+
};
|
|
2789
|
+
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], parentRequired, propertyKey, subType, }) => {
|
|
2790
|
+
var _a, _b, _c, _d;
|
|
2791
|
+
const [expanded, setExpanded] = useState(false);
|
|
2792
|
+
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2793
|
+
useState(() => {
|
|
2794
|
+
const disabledPaths = hideData || [];
|
|
2795
|
+
const initialState = {};
|
|
2796
|
+
if (disabledPaths) {
|
|
2797
|
+
for (const p of disabledPaths) {
|
|
2798
|
+
const { path } = p;
|
|
2799
|
+
initialState[path] = { checked: false, required: 0 };
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
return initialState;
|
|
2803
|
+
});
|
|
2804
|
+
const shouldHideNode = useMemo(() => {
|
|
2805
|
+
const currentPath = trimSlashes(path);
|
|
2806
|
+
const data = hideData.some(hideEntry => {
|
|
2807
|
+
const hideEntryPath = trimSlashes(hideEntry.path);
|
|
2808
|
+
return hideEntryPath === currentPath;
|
|
2809
|
+
});
|
|
2810
|
+
return data;
|
|
2811
|
+
}, [path, hideData]);
|
|
2812
|
+
if (!schema || shouldHideNode) {
|
|
2813
|
+
return null;
|
|
2814
|
+
}
|
|
2815
|
+
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';
|
|
2816
|
+
const handleToggle = () => {
|
|
2817
|
+
const circular = detectCircularPath(path);
|
|
2818
|
+
if (!circular) {
|
|
2819
|
+
setExpanded(prev => !prev);
|
|
2820
|
+
}
|
|
2821
|
+
};
|
|
2822
|
+
const renderChildren = () => {
|
|
2823
|
+
var _a, _b, _c, _d;
|
|
2824
|
+
if (!expanded && !isRoot)
|
|
2825
|
+
return null;
|
|
2826
|
+
const children = [];
|
|
2827
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2828
|
+
for (const [key, child] of Object.entries(schema === null || schema === void 0 ? void 0 : schema.properties)) {
|
|
2829
|
+
const childPath = `${path}/properties/${key}`;
|
|
2830
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2831
|
+
const resolved = dereference(child, root);
|
|
2832
|
+
if (!shouldHideChild) {
|
|
2833
|
+
children.push(React__default.createElement("li", { key: key },
|
|
2834
|
+
React__default.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 })));
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2839
|
+
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2840
|
+
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2841
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2842
|
+
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2843
|
+
const itemsPath = `${path}/items`;
|
|
2844
|
+
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2845
|
+
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2846
|
+
const childPath = `${itemsPath}/properties/${key}`;
|
|
2847
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2848
|
+
if (!shouldHideChild) {
|
|
2849
|
+
children.push(React__default.createElement("li", { key: key },
|
|
2850
|
+
React__default.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 })));
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2855
|
+
const childPath = `${path}/items`;
|
|
2856
|
+
const shouldHideChild = hideData.some(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(childPath));
|
|
2857
|
+
if (!shouldHideChild) {
|
|
2858
|
+
children.push(React__default.createElement("li", { key: "items" },
|
|
2859
|
+
React__default.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 })));
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2864
|
+
};
|
|
2865
|
+
const renderMinEnums = (schema) => {
|
|
2866
|
+
if (!schema || typeof schema !== 'object')
|
|
2867
|
+
return null;
|
|
2868
|
+
const boxStyle = {
|
|
2869
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
2870
|
+
border: '1px solid #a0aec0',
|
|
2871
|
+
borderRadius: '4px',
|
|
2872
|
+
padding: '0px 2px',
|
|
2873
|
+
display: 'inline-block',
|
|
2874
|
+
overflowWrap: 'break-word',
|
|
2875
|
+
textAlign: 'left',
|
|
2876
|
+
maxWidth: 'fit-content',
|
|
2877
|
+
maxHeight: 'fit-content',
|
|
2878
|
+
};
|
|
2879
|
+
if ('minItems' in schema) {
|
|
2880
|
+
const schemaWithMinItems = schema;
|
|
2881
|
+
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
2882
|
+
return (React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
2886
|
+
return (React__default.createElement("div", null,
|
|
2887
|
+
"Allowed values:",
|
|
2888
|
+
' ',
|
|
2889
|
+
schema.enum.map((val, idx) => (React__default.createElement(Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
2890
|
+
}
|
|
2891
|
+
return null;
|
|
2892
|
+
};
|
|
2893
|
+
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
2894
|
+
let showRequiredLabel = false;
|
|
2895
|
+
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
2896
|
+
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
2897
|
+
showRequiredLabel = true;
|
|
2898
|
+
}
|
|
2899
|
+
return (React__default.createElement("div", { className: "mb-1" },
|
|
2900
|
+
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
2901
|
+
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
2902
|
+
React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
2903
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
2904
|
+
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
2905
|
+
!detectCircularPath(path) &&
|
|
2906
|
+
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
2907
|
+
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
2908
|
+
' ' + displayTitle)) : null,
|
|
2909
|
+
!isRoot ? (React__default.createElement(Box, { mr: 2 },
|
|
2910
|
+
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
2911
|
+
(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),
|
|
2912
|
+
(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,
|
|
2913
|
+
subType ? `[${subType}]` : ''),
|
|
2914
|
+
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null))) : null),
|
|
2915
|
+
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
2916
|
+
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
2917
|
+
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
2918
|
+
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React__default.createElement(Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
2919
|
+
React__default.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
2920
|
+
React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
2921
|
+
background: 'rgba(245, 247, 250, 0.5)',
|
|
2922
|
+
border: '1px solid #a0aec0',
|
|
2923
|
+
borderRadius: '4px',
|
|
2924
|
+
padding: '4px 8px',
|
|
2925
|
+
display: 'inline-block',
|
|
2926
|
+
overflowWrap: 'break-word',
|
|
2927
|
+
textAlign: 'left',
|
|
2928
|
+
maxWidth: '530px',
|
|
2929
|
+
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
2930
|
+
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
2931
|
+
typeof schema === 'object' &&
|
|
2932
|
+
('minItems' in schema || 'enum' in schema) &&
|
|
2933
|
+
renderMinEnums(schema))),
|
|
2934
|
+
!isRoot && (React__default.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
2935
|
+
React__default.createElement(Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React__default.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
2936
|
+
React__default.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
2937
|
+
renderChildren()));
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2730
2940
|
const isBodyEmpty = (body) => {
|
|
2731
2941
|
if (!body)
|
|
2732
2942
|
return true;
|
|
2733
2943
|
const { contents = [], description } = body;
|
|
2734
2944
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2735
2945
|
};
|
|
2736
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
2946
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
|
|
2737
2947
|
var _a;
|
|
2738
2948
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2739
2949
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -2746,13 +2956,25 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
|
2746
2956
|
const { contents = [], description } = body;
|
|
2747
2957
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
2748
2958
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
2959
|
+
const getMaskProperties = () => {
|
|
2960
|
+
const disablePropsConfig = disableProps || [];
|
|
2961
|
+
const absolutePathsToHide = [];
|
|
2962
|
+
disablePropsConfig.forEach(configEntry => {
|
|
2963
|
+
const { location, paths } = configEntry;
|
|
2964
|
+
paths.forEach(item => {
|
|
2965
|
+
const fullPath = `${location}/${item.path}`;
|
|
2966
|
+
absolutePathsToHide.push({ path: fullPath });
|
|
2967
|
+
});
|
|
2968
|
+
});
|
|
2969
|
+
return absolutePathsToHide;
|
|
2970
|
+
};
|
|
2749
2971
|
return (React.createElement(VStack, { spacing: 6 },
|
|
2750
2972
|
React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2751
2973
|
React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
2752
2974
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2753
2975
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
2754
2976
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2755
|
-
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
2977
|
+
schema && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties() })) : (isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
|
|
2756
2978
|
};
|
|
2757
2979
|
Body.displayName = 'HttpOperation.Body';
|
|
2758
2980
|
|
|
@@ -2819,7 +3041,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2819
3041
|
return schema;
|
|
2820
3042
|
};
|
|
2821
3043
|
|
|
2822
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3044
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
|
|
2823
3045
|
if (!request || typeof request !== 'object')
|
|
2824
3046
|
return null;
|
|
2825
3047
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2847,7 +3069,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2847
3069
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
2848
3070
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2849
3071
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2850
|
-
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3072
|
+
body && (React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
|
|
2851
3073
|
};
|
|
2852
3074
|
Request.displayName = 'HttpOperation.Request';
|
|
2853
3075
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2878,7 +3100,7 @@ const OptionalMessage$1 = () => {
|
|
|
2878
3100
|
return React.createElement(Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
2879
3101
|
};
|
|
2880
3102
|
|
|
2881
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3103
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
|
|
2882
3104
|
var _a, _b;
|
|
2883
3105
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
2884
3106
|
const [activeResponseId, setActiveResponseId] = React.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -2911,11 +3133,11 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2911
3133
|
const tabResponses = (React.createElement(TabList, { density: "compact" }, responses.map(({ code }) => (React.createElement(Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
2912
3134
|
return (React.createElement(VStack, { spacing: 8, as: Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2913
3135
|
React.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
2914
|
-
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
2915
|
-
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3136
|
+
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: activeResponseId })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
3137
|
+
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
|
|
2916
3138
|
};
|
|
2917
3139
|
Responses.displayName = 'HttpOperation.Responses';
|
|
2918
|
-
const Response = ({ response, onMediaTypeChange }) => {
|
|
3140
|
+
const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
|
|
2919
3141
|
const { contents = [], headers = [], description } = response;
|
|
2920
3142
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
2921
3143
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -2926,6 +3148,18 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2926
3148
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2927
3149
|
}, [responseContent]);
|
|
2928
3150
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3151
|
+
const getMaskProperties = () => {
|
|
3152
|
+
if (!disableProps || !statusCode)
|
|
3153
|
+
return [];
|
|
3154
|
+
const configEntries = disableProps[statusCode] || [];
|
|
3155
|
+
const absolutePathsToHide = [];
|
|
3156
|
+
configEntries.forEach(({ location, paths }) => {
|
|
3157
|
+
paths.forEach(item => {
|
|
3158
|
+
absolutePathsToHide.push({ path: `${location}/${item.path}` });
|
|
3159
|
+
});
|
|
3160
|
+
});
|
|
3161
|
+
return absolutePathsToHide;
|
|
3162
|
+
};
|
|
2929
3163
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
2930
3164
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2931
3165
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -2937,7 +3171,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2937
3171
|
React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2938
3172
|
React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2939
3173
|
React.createElement(Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
2940
|
-
schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3174
|
+
schema && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties() })) : (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
2941
3175
|
};
|
|
2942
3176
|
Response.displayName = 'HttpOperation.Response';
|
|
2943
3177
|
const codeToIntentVal = (code) => {
|
|
@@ -2983,7 +3217,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
2983
3217
|
};
|
|
2984
3218
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
2985
3219
|
|
|
2986
|
-
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3220
|
+
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
|
|
2987
3221
|
var _a;
|
|
2988
3222
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2989
3223
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3014,8 +3248,8 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
3014
3248
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3015
3249
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3016
3250
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3017
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3018
|
-
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3251
|
+
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data), disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.request }),
|
|
3252
|
+
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact, disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.response })),
|
|
3019
3253
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3020
3254
|
isCompact && tryItPanel));
|
|
3021
3255
|
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
@@ -3269,7 +3503,7 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3269
3503
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3270
3504
|
const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3271
3505
|
|
|
3272
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3506
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
|
|
3273
3507
|
var _a, _b;
|
|
3274
3508
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3275
3509
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3292,13 +3526,27 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3292
3526
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3293
3527
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3294
3528
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3529
|
+
const getMaskProperties = () => {
|
|
3530
|
+
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3531
|
+
const absolutePathsToHide = [];
|
|
3532
|
+
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3533
|
+
disablePropsConfig.forEach((configEntry) => {
|
|
3534
|
+
const { location, paths } = configEntry;
|
|
3535
|
+
paths.forEach((item) => {
|
|
3536
|
+
const fullPath = `${location}/${item.path}`;
|
|
3537
|
+
absolutePathsToHide.push({ path: fullPath });
|
|
3538
|
+
});
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
return absolutePathsToHide;
|
|
3542
|
+
};
|
|
3295
3543
|
const description = (React.createElement(VStack, { spacing: 10 },
|
|
3296
3544
|
data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
|
|
3297
3545
|
React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3298
3546
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3299
3547
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3300
|
-
isCompact && modelExamples,
|
|
3301
|
-
React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3548
|
+
localStorage.getItem('use_new_mask_workflow') !== 'true' && isCompact && modelExamples,
|
|
3549
|
+
data && localStorage.getItem('use_new_mask_workflow') === 'true' ? (React.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties() })) : (React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
|
|
3302
3550
|
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3303
3551
|
};
|
|
3304
3552
|
const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
|
|
@@ -3334,17 +3582,19 @@ const Docs = React.memo((_a) => {
|
|
|
3334
3582
|
return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3335
3583
|
});
|
|
3336
3584
|
const ParsedDocs = (_a) => {
|
|
3585
|
+
var _b;
|
|
3337
3586
|
var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
|
|
3587
|
+
const disableProps = (_b = node.data) === null || _b === void 0 ? void 0 : _b.disableProps;
|
|
3338
3588
|
switch (node.type) {
|
|
3339
3589
|
case 'article':
|
|
3340
3590
|
return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3341
3591
|
case 'http_operation':
|
|
3342
3592
|
case 'http_webhook':
|
|
3343
|
-
return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3593
|
+
return React.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: disableProps }, commonProps));
|
|
3344
3594
|
case 'http_service':
|
|
3345
3595
|
return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3346
3596
|
case 'model':
|
|
3347
|
-
return React.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3597
|
+
return React.createElement(Model, Object.assign({ data: node.data, disableProps: disableProps }, commonProps));
|
|
3348
3598
|
default:
|
|
3349
3599
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3350
3600
|
return null;
|