docusaurus-theme-openapi-docs 0.0.0-1000
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/LICENSE +21 -0
- package/babel.config.js +35 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +81 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +15 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +149 -0
- package/lib/markdown/utils.d.ts +10 -0
- package/lib/markdown/utils.js +49 -0
- package/lib/markdown/utils.test.d.ts +1 -0
- package/lib/markdown/utils.test.js +43 -0
- package/lib/theme/ApiExplorer/Accept/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Accept/index.js +38 -0
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +11 -0
- package/lib/theme/ApiExplorer/Accept/slice.js +22 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +35 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +41 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +153 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +147 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +58 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +248 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +34 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +59 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +51 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +110 -0
- package/lib/theme/ApiExplorer/Authorization/auth-types.d.ts +3 -0
- package/lib/theme/ApiExplorer/Authorization/auth-types.js +28 -0
- package/lib/theme/ApiExplorer/Authorization/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Authorization/index.js +160 -0
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +40 -0
- package/lib/theme/ApiExplorer/Authorization/slice.js +102 -0
- package/lib/theme/ApiExplorer/Body/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/Body/index.js +381 -0
- package/lib/theme/ApiExplorer/Body/json2xml.js +43 -0
- package/lib/theme/ApiExplorer/Body/slice.d.ts +82 -0
- package/lib/theme/ApiExplorer/Body/slice.js +97 -0
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +21 -0
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.js +8 -0
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +389 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +5 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +95 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +501 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +271 -0
- package/lib/theme/ApiExplorer/ContentType/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ContentType/index.js +40 -0
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +11 -0
- package/lib/theme/ApiExplorer/ContentType/slice.js +22 -0
- package/lib/theme/ApiExplorer/Export/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Export/index.js +57 -0
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +27 -0
- package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/FloatingButton/index.js +28 -0
- package/lib/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +74 -0
- package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +173 -0
- package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/FormItem/index.js +44 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/_FormMultiSelect.scss +30 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.js +51 -0
- package/lib/theme/ApiExplorer/FormSelect/_FormSelect.scss +43 -0
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/FormSelect/index.js +35 -0
- package/lib/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +73 -0
- package/lib/theme/ApiExplorer/LiveEditor/_LiveEditor.scss +15 -0
- package/lib/theme/ApiExplorer/LiveEditor/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/LiveEditor/index.js +168 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +8 -0
- package/lib/theme/ApiExplorer/MethodEndpoint/index.js +86 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +220 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +63 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +89 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +63 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +6 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +38 -0
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +123 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +223 -0
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +25 -0
- package/lib/theme/ApiExplorer/Request/_Request.scss +129 -0
- package/lib/theme/ApiExplorer/Request/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/Request/index.js +396 -0
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +4 -0
- package/lib/theme/ApiExplorer/Request/makeRequest.js +222 -0
- package/lib/theme/ApiExplorer/Response/_Response.scss +121 -0
- package/lib/theme/ApiExplorer/Response/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/Response/index.js +193 -0
- package/lib/theme/ApiExplorer/Response/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/Response/slice.js +51 -0
- package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +380 -0
- package/lib/theme/ApiExplorer/Server/_Server.scss +26 -0
- package/lib/theme/ApiExplorer/Server/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/Server/index.js +199 -0
- package/lib/theme/ApiExplorer/Server/slice.d.ts +13 -0
- package/lib/theme/ApiExplorer/Server/slice.js +33 -0
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +20 -0
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +465 -0
- package/lib/theme/ApiExplorer/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/index.js +41 -0
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +3 -0
- package/lib/theme/ApiExplorer/persistanceMiddleware.js +54 -0
- package/lib/theme/ApiExplorer/storage-utils.d.ts +4 -0
- package/lib/theme/ApiExplorer/storage-utils.js +41 -0
- package/lib/theme/ApiItem/Layout/index.d.ts +3 -0
- package/lib/theme/ApiItem/Layout/index.js +121 -0
- package/lib/theme/ApiItem/Layout/styles.module.css +17 -0
- package/lib/theme/ApiItem/hooks.d.ts +12 -0
- package/lib/theme/ApiItem/hooks.js +13 -0
- package/lib/theme/ApiItem/index.d.ts +2 -0
- package/lib/theme/ApiItem/index.js +238 -0
- package/lib/theme/ApiItem/store.d.ts +46 -0
- package/lib/theme/ApiItem/store.js +53 -0
- package/lib/theme/ApiLogo/index.d.ts +2 -0
- package/lib/theme/ApiLogo/index.js +51 -0
- package/lib/theme/ApiTabs/_ApiTabs.scss +142 -0
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +270 -0
- package/lib/theme/ArrayBrackets/index.d.ts +3 -0
- package/lib/theme/ArrayBrackets/index.js +50 -0
- package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +98 -0
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +258 -0
- package/lib/theme/Markdown/Details/_Details.scss +122 -0
- package/lib/theme/Markdown/index.js +179 -0
- package/lib/theme/MimeTabs/_MimeTabs.scss +70 -0
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +286 -0
- package/lib/theme/OperationTabs/_OperationTabs.scss +72 -0
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +248 -0
- package/lib/theme/ParamsDetails/index.d.ts +6 -0
- package/lib/theme/ParamsDetails/index.js +85 -0
- package/lib/theme/ParamsItem/_ParamsItem.scss +54 -0
- package/lib/theme/ParamsItem/index.d.ts +25 -0
- package/lib/theme/ParamsItem/index.js +218 -0
- package/lib/theme/RequestSchema/index.d.ts +15 -0
- package/lib/theme/RequestSchema/index.js +194 -0
- package/lib/theme/ResponseExamples/index.d.ts +18 -0
- package/lib/theme/ResponseExamples/index.js +193 -0
- package/lib/theme/ResponseHeaders/index.d.ts +13 -0
- package/lib/theme/ResponseHeaders/index.js +39 -0
- package/lib/theme/ResponseSamples/_ResponseSamples.scss +3 -0
- package/lib/theme/ResponseSamples/index.d.ts +8 -0
- package/lib/theme/ResponseSamples/index.js +27 -0
- package/lib/theme/ResponseSchema/index.d.ts +15 -0
- package/lib/theme/ResponseSchema/index.js +159 -0
- package/lib/theme/Schema/index.d.ts +8 -0
- package/lib/theme/Schema/index.js +885 -0
- package/lib/theme/SchemaItem/_SchemaItem.scss +89 -0
- package/lib/theme/SchemaItem/index.d.ts +12 -0
- package/lib/theme/SchemaItem/index.js +213 -0
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +61 -0
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +255 -0
- package/lib/theme/SkeletonLoader/index.d.ts +6 -0
- package/lib/theme/SkeletonLoader/index.js +20 -0
- package/lib/theme/StatusCodes/index.d.ts +9 -0
- package/lib/theme/StatusCodes/index.js +81 -0
- package/lib/theme/styles.scss +212 -0
- package/lib/types.d.ts +157 -0
- package/lib/types.js +8 -0
- package/package.json +83 -0
- package/src/index.ts +85 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/schema.ts +181 -0
- package/src/markdown/utils.test.ts +49 -0
- package/src/markdown/utils.ts +59 -0
- package/src/plugin-content-docs.d.ts +20 -0
- package/src/postman-code-generators.d.ts +9 -0
- package/src/react-magic-dropzone.d.ts +9 -0
- package/src/theme/ApiExplorer/Accept/index.tsx +36 -0
- package/src/theme/ApiExplorer/Accept/slice.ts +29 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +32 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/Element.tsx +34 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +134 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +79 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.tsx +55 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.tsx +166 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +34 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +48 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.tsx +54 -0
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +45 -0
- package/src/theme/ApiExplorer/Authorization/auth-types.ts +30 -0
- package/src/theme/ApiExplorer/Authorization/index.tsx +158 -0
- package/src/theme/ApiExplorer/Authorization/slice.ts +146 -0
- package/src/theme/ApiExplorer/Body/index.tsx +376 -0
- package/src/theme/ApiExplorer/Body/json2xml.js +43 -0
- package/src/theme/ApiExplorer/Body/slice.ts +133 -0
- package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +57 -0
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +338 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +96 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +501 -0
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +248 -0
- package/src/theme/ApiExplorer/ContentType/index.tsx +38 -0
- package/src/theme/ApiExplorer/ContentType/slice.ts +29 -0
- package/src/theme/ApiExplorer/Export/index.tsx +47 -0
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +27 -0
- package/src/theme/ApiExplorer/FloatingButton/index.tsx +29 -0
- package/src/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +74 -0
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +119 -0
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
- package/src/theme/ApiExplorer/FormItem/index.tsx +33 -0
- package/src/theme/ApiExplorer/FormMultiSelect/_FormMultiSelect.scss +30 -0
- package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +57 -0
- package/src/theme/ApiExplorer/FormSelect/_FormSelect.scss +43 -0
- package/src/theme/ApiExplorer/FormSelect/index.tsx +38 -0
- package/src/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +80 -0
- package/src/theme/ApiExplorer/LiveEditor/_LiveEditor.scss +15 -0
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +114 -0
- package/src/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +91 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +175 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +64 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +86 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +65 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +38 -0
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +123 -0
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +146 -0
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +37 -0
- package/src/theme/ApiExplorer/Request/_Request.scss +129 -0
- package/src/theme/ApiExplorer/Request/index.tsx +309 -0
- package/src/theme/ApiExplorer/Request/makeRequest.ts +254 -0
- package/src/theme/ApiExplorer/Response/_Response.scss +121 -0
- package/src/theme/ApiExplorer/Response/index.tsx +157 -0
- package/src/theme/ApiExplorer/Response/slice.ts +52 -0
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +287 -0
- package/src/theme/ApiExplorer/Server/_Server.scss +26 -0
- package/src/theme/ApiExplorer/Server/index.tsx +130 -0
- package/src/theme/ApiExplorer/Server/slice.ts +39 -0
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +526 -0
- package/src/theme/ApiExplorer/index.tsx +41 -0
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +71 -0
- package/src/theme/ApiExplorer/postman-collection.d.ts +10 -0
- package/src/theme/ApiExplorer/react-modal.d.ts +8 -0
- package/src/theme/ApiExplorer/storage-utils.ts +39 -0
- package/src/theme/ApiItem/Layout/index.tsx +85 -0
- package/src/theme/ApiItem/Layout/styles.module.css +17 -0
- package/src/theme/ApiItem/hooks.ts +13 -0
- package/src/theme/ApiItem/index.tsx +222 -0
- package/src/theme/ApiItem/store.ts +51 -0
- package/src/theme/ApiLogo/index.tsx +52 -0
- package/src/theme/ApiTabs/_ApiTabs.scss +142 -0
- package/src/theme/ApiTabs/index.tsx +238 -0
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +98 -0
- package/src/theme/DiscriminatorTabs/index.tsx +229 -0
- package/src/theme/Markdown/Details/_Details.scss +122 -0
- package/src/theme/Markdown/index.js +179 -0
- package/src/theme/MimeTabs/_MimeTabs.scss +70 -0
- package/src/theme/MimeTabs/index.tsx +257 -0
- package/src/theme/OperationTabs/_OperationTabs.scss +72 -0
- package/src/theme/OperationTabs/index.tsx +220 -0
- package/src/theme/ParamsDetails/index.tsx +81 -0
- package/src/theme/ParamsItem/_ParamsItem.scss +54 -0
- package/src/theme/ParamsItem/index.tsx +205 -0
- package/src/theme/RequestSchema/index.tsx +157 -0
- package/src/theme/ResponseExamples/index.tsx +192 -0
- package/src/theme/ResponseHeaders/index.tsx +49 -0
- package/src/theme/ResponseSamples/_ResponseSamples.scss +3 -0
- package/src/theme/ResponseSamples/index.tsx +31 -0
- package/src/theme/ResponseSchema/index.tsx +144 -0
- package/src/theme/Schema/index.tsx +939 -0
- package/src/theme/SchemaItem/_SchemaItem.scss +89 -0
- package/src/theme/SchemaItem/index.tsx +198 -0
- package/src/theme/SchemaTabs/_SchemaTabs.scss +61 -0
- package/src/theme/SchemaTabs/index.tsx +224 -0
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +212 -0
- package/src/theme-classic.d.ts +80 -0
- package/src/theme-openapi.d.ts +288 -0
- package/src/theme-translations.d.ts +9 -0
- package/src/types.ts +182 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
64
|
+
var __importDefault =
|
|
65
|
+
(this && this.__importDefault) ||
|
|
66
|
+
function (mod) {
|
|
67
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
// @ts-nocheck
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
72
|
+
const client_1 = require("@docusaurus/plugin-content-docs/client");
|
|
73
|
+
const Accept_1 = __importDefault(require("@theme/ApiExplorer/Accept"));
|
|
74
|
+
const Authorization_1 = __importDefault(
|
|
75
|
+
require("@theme/ApiExplorer/Authorization")
|
|
76
|
+
);
|
|
77
|
+
const Body_1 = __importDefault(require("@theme/ApiExplorer/Body"));
|
|
78
|
+
const buildPostmanRequest_1 = __importDefault(
|
|
79
|
+
require("@theme/ApiExplorer/buildPostmanRequest")
|
|
80
|
+
);
|
|
81
|
+
const ContentType_1 = __importDefault(
|
|
82
|
+
require("@theme/ApiExplorer/ContentType")
|
|
83
|
+
);
|
|
84
|
+
const ParamOptions_1 = __importDefault(
|
|
85
|
+
require("@theme/ApiExplorer/ParamOptions")
|
|
86
|
+
);
|
|
87
|
+
const slice_1 = require("@theme/ApiExplorer/Response/slice");
|
|
88
|
+
const Server_1 = __importDefault(require("@theme/ApiExplorer/Server"));
|
|
89
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
90
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
91
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
92
|
+
const makeRequest_1 = __importDefault(require("./makeRequest"));
|
|
93
|
+
function Request({ item }) {
|
|
94
|
+
const postman = new postman_collection_1.default.Request(item.postman);
|
|
95
|
+
const metadata = (0, client_1.useDoc)();
|
|
96
|
+
const { proxy, hide_send_button: hideSendButton } = metadata.frontMatter;
|
|
97
|
+
const pathParams = (0, hooks_1.useTypedSelector)(
|
|
98
|
+
(state) => state.params.path
|
|
99
|
+
);
|
|
100
|
+
const queryParams = (0, hooks_1.useTypedSelector)(
|
|
101
|
+
(state) => state.params.query
|
|
102
|
+
);
|
|
103
|
+
const cookieParams = (0, hooks_1.useTypedSelector)(
|
|
104
|
+
(state) => state.params.cookie
|
|
105
|
+
);
|
|
106
|
+
const contentType = (0, hooks_1.useTypedSelector)(
|
|
107
|
+
(state) => state.contentType.value
|
|
108
|
+
);
|
|
109
|
+
const headerParams = (0, hooks_1.useTypedSelector)(
|
|
110
|
+
(state) => state.params.header
|
|
111
|
+
);
|
|
112
|
+
const body = (0, hooks_1.useTypedSelector)((state) => state.body);
|
|
113
|
+
const accept = (0, hooks_1.useTypedSelector)((state) => state.accept.value);
|
|
114
|
+
const acceptOptions = (0, hooks_1.useTypedDispatch)(
|
|
115
|
+
(state) => state.accept.options
|
|
116
|
+
);
|
|
117
|
+
const authSelected = (0, hooks_1.useTypedSelector)(
|
|
118
|
+
(state) => state.auth.selected
|
|
119
|
+
);
|
|
120
|
+
const server = (0, hooks_1.useTypedSelector)((state) => state.server.value);
|
|
121
|
+
const serverOptions = (0, hooks_1.useTypedSelector)(
|
|
122
|
+
(state) => state.server.options
|
|
123
|
+
);
|
|
124
|
+
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
125
|
+
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
126
|
+
const [expandAccept, setExpandAccept] = (0, react_1.useState)(true);
|
|
127
|
+
const [expandAuth, setExpandAuth] = (0, react_1.useState)(true);
|
|
128
|
+
const [expandBody, setExpandBody] = (0, react_1.useState)(true);
|
|
129
|
+
const [expandParams, setExpandParams] = (0, react_1.useState)(true);
|
|
130
|
+
const [expandServer, setExpandServer] = (0, react_1.useState)(true);
|
|
131
|
+
const allParams = [
|
|
132
|
+
...pathParams,
|
|
133
|
+
...queryParams,
|
|
134
|
+
...cookieParams,
|
|
135
|
+
...headerParams,
|
|
136
|
+
];
|
|
137
|
+
const postmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
138
|
+
queryParams,
|
|
139
|
+
pathParams,
|
|
140
|
+
cookieParams,
|
|
141
|
+
contentType,
|
|
142
|
+
accept,
|
|
143
|
+
headerParams,
|
|
144
|
+
body,
|
|
145
|
+
server,
|
|
146
|
+
auth,
|
|
147
|
+
});
|
|
148
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
149
|
+
const paramsObject = {
|
|
150
|
+
path: [],
|
|
151
|
+
query: [],
|
|
152
|
+
header: [],
|
|
153
|
+
cookie: [],
|
|
154
|
+
};
|
|
155
|
+
item.parameters?.forEach((param) => {
|
|
156
|
+
const paramType = param.in;
|
|
157
|
+
const paramsArray = paramsObject[paramType];
|
|
158
|
+
paramsArray.push(param);
|
|
159
|
+
});
|
|
160
|
+
const methods = (0, react_hook_form_1.useForm)({ shouldFocusError: false });
|
|
161
|
+
const handleEventStream = async (res) => {
|
|
162
|
+
res.headers &&
|
|
163
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
164
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
165
|
+
const reader = res.body.getReader();
|
|
166
|
+
const decoder = new TextDecoder();
|
|
167
|
+
let result = "";
|
|
168
|
+
while (true) {
|
|
169
|
+
const { done, value } = await reader.read();
|
|
170
|
+
if (done) break;
|
|
171
|
+
result += decoder.decode(value, { stream: true });
|
|
172
|
+
dispatch((0, slice_1.setResponse)(result));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const handleResponse = async (res) => {
|
|
176
|
+
dispatch((0, slice_1.setResponse)(await res.text()));
|
|
177
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
178
|
+
res.headers &&
|
|
179
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
180
|
+
};
|
|
181
|
+
const onSubmit = async (data) => {
|
|
182
|
+
dispatch((0, slice_1.setResponse)("Fetching..."));
|
|
183
|
+
try {
|
|
184
|
+
await delay(1200);
|
|
185
|
+
const res = await (0, makeRequest_1.default)(postmanRequest, proxy, body);
|
|
186
|
+
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
187
|
+
await handleEventStream(res);
|
|
188
|
+
} else {
|
|
189
|
+
await handleResponse(res);
|
|
190
|
+
}
|
|
191
|
+
} catch (e) {
|
|
192
|
+
console.log(e);
|
|
193
|
+
dispatch((0, slice_1.setResponse)("Connection failed"));
|
|
194
|
+
dispatch((0, slice_1.clearCode)());
|
|
195
|
+
dispatch((0, slice_1.clearHeaders)());
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const showServerOptions = serverOptions.length > 0;
|
|
199
|
+
const showAcceptOptions = acceptOptions.length > 1;
|
|
200
|
+
const showRequestBody = contentType !== undefined;
|
|
201
|
+
const showRequestButton = item.servers && !hideSendButton;
|
|
202
|
+
const showAuth = authSelected !== undefined;
|
|
203
|
+
const showParams = allParams.length > 0;
|
|
204
|
+
const requestBodyRequired = item.requestBody?.required;
|
|
205
|
+
if (
|
|
206
|
+
!showAcceptOptions &&
|
|
207
|
+
!showAuth &&
|
|
208
|
+
!showParams &&
|
|
209
|
+
!showRequestBody &&
|
|
210
|
+
!showServerOptions
|
|
211
|
+
) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
const expandAllDetails = () => {
|
|
215
|
+
setExpandAccept(true);
|
|
216
|
+
setExpandAuth(true);
|
|
217
|
+
setExpandBody(true);
|
|
218
|
+
setExpandParams(true);
|
|
219
|
+
setExpandServer(true);
|
|
220
|
+
};
|
|
221
|
+
const collapseAllDetails = () => {
|
|
222
|
+
setExpandAccept(false);
|
|
223
|
+
setExpandAuth(false);
|
|
224
|
+
setExpandBody(false);
|
|
225
|
+
setExpandParams(false);
|
|
226
|
+
setExpandServer(false);
|
|
227
|
+
};
|
|
228
|
+
const allDetailsExpanded =
|
|
229
|
+
expandParams && expandBody && expandServer && expandAuth && expandAccept;
|
|
230
|
+
return react_1.default.createElement(
|
|
231
|
+
react_hook_form_1.FormProvider,
|
|
232
|
+
{ ...methods },
|
|
233
|
+
react_1.default.createElement(
|
|
234
|
+
"form",
|
|
235
|
+
{
|
|
236
|
+
className: "openapi-explorer__request-form",
|
|
237
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
238
|
+
},
|
|
239
|
+
react_1.default.createElement(
|
|
240
|
+
"div",
|
|
241
|
+
{ className: "openapi-explorer__request-header-container" },
|
|
242
|
+
react_1.default.createElement(
|
|
243
|
+
"span",
|
|
244
|
+
{ className: "openapi-explorer__request-title" },
|
|
245
|
+
"Request "
|
|
246
|
+
),
|
|
247
|
+
allDetailsExpanded
|
|
248
|
+
? react_1.default.createElement(
|
|
249
|
+
"span",
|
|
250
|
+
{
|
|
251
|
+
className: "openapi-explorer__expand-details-btn",
|
|
252
|
+
onClick: collapseAllDetails,
|
|
253
|
+
},
|
|
254
|
+
"Collapse all"
|
|
255
|
+
)
|
|
256
|
+
: react_1.default.createElement(
|
|
257
|
+
"span",
|
|
258
|
+
{
|
|
259
|
+
className: "openapi-explorer__expand-details-btn",
|
|
260
|
+
onClick: expandAllDetails,
|
|
261
|
+
},
|
|
262
|
+
"Expand all"
|
|
263
|
+
)
|
|
264
|
+
),
|
|
265
|
+
react_1.default.createElement(
|
|
266
|
+
"div",
|
|
267
|
+
{ className: "openapi-explorer__details-outer-container" },
|
|
268
|
+
showServerOptions &&
|
|
269
|
+
item.method !== "event" &&
|
|
270
|
+
react_1.default.createElement(
|
|
271
|
+
"details",
|
|
272
|
+
{
|
|
273
|
+
open: expandServer,
|
|
274
|
+
className: "openapi-explorer__details-container",
|
|
275
|
+
},
|
|
276
|
+
react_1.default.createElement(
|
|
277
|
+
"summary",
|
|
278
|
+
{
|
|
279
|
+
className: "openapi-explorer__details-summary",
|
|
280
|
+
onClick: (e) => {
|
|
281
|
+
e.preventDefault();
|
|
282
|
+
setExpandServer(!expandServer);
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
"Base URL"
|
|
286
|
+
),
|
|
287
|
+
react_1.default.createElement(Server_1.default, null)
|
|
288
|
+
),
|
|
289
|
+
showAuth &&
|
|
290
|
+
react_1.default.createElement(
|
|
291
|
+
"details",
|
|
292
|
+
{
|
|
293
|
+
open: expandAuth,
|
|
294
|
+
className: "openapi-explorer__details-container",
|
|
295
|
+
},
|
|
296
|
+
react_1.default.createElement(
|
|
297
|
+
"summary",
|
|
298
|
+
{
|
|
299
|
+
className: "openapi-explorer__details-summary",
|
|
300
|
+
onClick: (e) => {
|
|
301
|
+
e.preventDefault();
|
|
302
|
+
setExpandAuth(!expandAuth);
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
"Auth"
|
|
306
|
+
),
|
|
307
|
+
react_1.default.createElement(Authorization_1.default, null)
|
|
308
|
+
),
|
|
309
|
+
showParams &&
|
|
310
|
+
react_1.default.createElement(
|
|
311
|
+
"details",
|
|
312
|
+
{
|
|
313
|
+
open:
|
|
314
|
+
expandParams || Object.keys(methods.formState.errors).length,
|
|
315
|
+
className: "openapi-explorer__details-container",
|
|
316
|
+
},
|
|
317
|
+
react_1.default.createElement(
|
|
318
|
+
"summary",
|
|
319
|
+
{
|
|
320
|
+
className: "openapi-explorer__details-summary",
|
|
321
|
+
onClick: (e) => {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
setExpandParams(!expandParams);
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
"Parameters"
|
|
327
|
+
),
|
|
328
|
+
react_1.default.createElement(ParamOptions_1.default, null)
|
|
329
|
+
),
|
|
330
|
+
showRequestBody &&
|
|
331
|
+
react_1.default.createElement(
|
|
332
|
+
"details",
|
|
333
|
+
{
|
|
334
|
+
open: expandBody,
|
|
335
|
+
className: "openapi-explorer__details-container",
|
|
336
|
+
},
|
|
337
|
+
react_1.default.createElement(
|
|
338
|
+
"summary",
|
|
339
|
+
{
|
|
340
|
+
className: "openapi-explorer__details-summary",
|
|
341
|
+
onClick: (e) => {
|
|
342
|
+
e.preventDefault();
|
|
343
|
+
setExpandBody(!expandBody);
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
"Body",
|
|
347
|
+
requestBodyRequired &&
|
|
348
|
+
react_1.default.createElement(
|
|
349
|
+
"span",
|
|
350
|
+
{ className: "openapi-schema__required" },
|
|
351
|
+
"\u00A0required"
|
|
352
|
+
)
|
|
353
|
+
),
|
|
354
|
+
react_1.default.createElement(
|
|
355
|
+
react_1.default.Fragment,
|
|
356
|
+
null,
|
|
357
|
+
react_1.default.createElement(ContentType_1.default, null),
|
|
358
|
+
react_1.default.createElement(Body_1.default, {
|
|
359
|
+
jsonRequestBodyExample: item.jsonRequestBodyExample,
|
|
360
|
+
requestBodyMetadata: item.requestBody,
|
|
361
|
+
required: requestBodyRequired,
|
|
362
|
+
})
|
|
363
|
+
)
|
|
364
|
+
),
|
|
365
|
+
showAcceptOptions &&
|
|
366
|
+
react_1.default.createElement(
|
|
367
|
+
"details",
|
|
368
|
+
{
|
|
369
|
+
open: expandAccept,
|
|
370
|
+
className: "openapi-explorer__details-container",
|
|
371
|
+
},
|
|
372
|
+
react_1.default.createElement(
|
|
373
|
+
"summary",
|
|
374
|
+
{
|
|
375
|
+
className: "openapi-explorer__details-summary",
|
|
376
|
+
onClick: (e) => {
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
setExpandAccept(!expandAccept);
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
"Accept"
|
|
382
|
+
),
|
|
383
|
+
react_1.default.createElement(Accept_1.default, null)
|
|
384
|
+
),
|
|
385
|
+
showRequestButton &&
|
|
386
|
+
item.method !== "event" &&
|
|
387
|
+
react_1.default.createElement(
|
|
388
|
+
"button",
|
|
389
|
+
{ className: "openapi-explorer__request-btn", type: "submit" },
|
|
390
|
+
"Send API Request"
|
|
391
|
+
)
|
|
392
|
+
)
|
|
393
|
+
)
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
exports.default = Request;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
function fetchWithtimeout(url, options, timeout = 5000) {
|
|
10
|
+
return Promise.race([
|
|
11
|
+
fetch(url, options),
|
|
12
|
+
new Promise((_, reject) =>
|
|
13
|
+
setTimeout(() => reject(new Error("Request timed out")), timeout)
|
|
14
|
+
),
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
async function loadImage(content) {
|
|
18
|
+
return new Promise((accept, reject) => {
|
|
19
|
+
const reader = new FileReader();
|
|
20
|
+
reader.onabort = () => {
|
|
21
|
+
console.log("file reading was aborted");
|
|
22
|
+
reject();
|
|
23
|
+
};
|
|
24
|
+
reader.onerror = () => {
|
|
25
|
+
console.log("file reading has failed");
|
|
26
|
+
reject();
|
|
27
|
+
};
|
|
28
|
+
reader.onload = () => {
|
|
29
|
+
// Do whatever you want with the file contents
|
|
30
|
+
const binaryStr = reader.result;
|
|
31
|
+
accept(binaryStr);
|
|
32
|
+
};
|
|
33
|
+
reader.readAsArrayBuffer(content);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function makeRequest(request, proxy, _body) {
|
|
37
|
+
const headers = request.toJSON().header;
|
|
38
|
+
let myHeaders = new Headers();
|
|
39
|
+
if (headers) {
|
|
40
|
+
headers.forEach((header) => {
|
|
41
|
+
if (header.key && header.value) {
|
|
42
|
+
myHeaders.append(header.key, header.value);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// The following code handles multiple files in the same formdata param.
|
|
47
|
+
// It removes the form data params where the src property is an array of filepath strings
|
|
48
|
+
// Splits that array into different form data params with src set as a single filepath string
|
|
49
|
+
// TODO:
|
|
50
|
+
// if (request.body && request.body.mode === 'formdata') {
|
|
51
|
+
// let formdata = request.body.formdata,
|
|
52
|
+
// formdataArray = [];
|
|
53
|
+
// formdata.members.forEach((param) => {
|
|
54
|
+
// let key = param.key,
|
|
55
|
+
// type = param.type,
|
|
56
|
+
// disabled = param.disabled,
|
|
57
|
+
// contentType = param.contentType;
|
|
58
|
+
// // check if type is file or text
|
|
59
|
+
// if (type === 'file') {
|
|
60
|
+
// // if src is not of type string we check for array(multiple files)
|
|
61
|
+
// if (typeof param.src !== 'string') {
|
|
62
|
+
// // if src is an array(not empty), iterate over it and add files as separate form fields
|
|
63
|
+
// if (Array.isArray(param.src) && param.src.length) {
|
|
64
|
+
// param.src.forEach((filePath) => {
|
|
65
|
+
// addFormParam(
|
|
66
|
+
// formdataArray,
|
|
67
|
+
// key,
|
|
68
|
+
// param.type,
|
|
69
|
+
// filePath,
|
|
70
|
+
// disabled,
|
|
71
|
+
// contentType
|
|
72
|
+
// );
|
|
73
|
+
// });
|
|
74
|
+
// }
|
|
75
|
+
// // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
|
|
76
|
+
// else {
|
|
77
|
+
// addFormParam(
|
|
78
|
+
// formdataArray,
|
|
79
|
+
// key,
|
|
80
|
+
// param.type,
|
|
81
|
+
// '/path/to/file',
|
|
82
|
+
// disabled,
|
|
83
|
+
// contentType
|
|
84
|
+
// );
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// // if src is string, directly add the param with src as filepath
|
|
88
|
+
// else {
|
|
89
|
+
// addFormParam(
|
|
90
|
+
// formdataArray,
|
|
91
|
+
// key,
|
|
92
|
+
// param.type,
|
|
93
|
+
// param.src,
|
|
94
|
+
// disabled,
|
|
95
|
+
// contentType
|
|
96
|
+
// );
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
// // if type is text, directly add it to formdata array
|
|
100
|
+
// else {
|
|
101
|
+
// addFormParam(
|
|
102
|
+
// formdataArray,
|
|
103
|
+
// key,
|
|
104
|
+
// param.type,
|
|
105
|
+
// param.value,
|
|
106
|
+
// disabled,
|
|
107
|
+
// contentType
|
|
108
|
+
// );
|
|
109
|
+
// }
|
|
110
|
+
// });
|
|
111
|
+
// request.body.update({
|
|
112
|
+
// mode: 'formdata',
|
|
113
|
+
// formdata: formdataArray,
|
|
114
|
+
// });
|
|
115
|
+
// }
|
|
116
|
+
const body = request.body?.toJSON();
|
|
117
|
+
let myBody = undefined;
|
|
118
|
+
if (body !== undefined && Object.keys(body).length > 0) {
|
|
119
|
+
switch (body.mode) {
|
|
120
|
+
case "urlencoded": {
|
|
121
|
+
myBody = new URLSearchParams();
|
|
122
|
+
if (Array.isArray(body.urlencoded)) {
|
|
123
|
+
for (const data of body.urlencoded) {
|
|
124
|
+
if (data.key && data.value) {
|
|
125
|
+
myBody.append(data.key, data.value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case "raw": {
|
|
132
|
+
myBody = (body.raw ?? "").toString();
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "formdata": {
|
|
136
|
+
// The Content-Type header will be set automatically based on the type of body.
|
|
137
|
+
myHeaders.delete("Content-Type");
|
|
138
|
+
myBody = new FormData();
|
|
139
|
+
if (Array.isArray(request.body.formdata.members)) {
|
|
140
|
+
for (const data of request.body.formdata.members) {
|
|
141
|
+
if (data.key && data.value.content) {
|
|
142
|
+
myBody.append(data.key, data.value.content);
|
|
143
|
+
}
|
|
144
|
+
// handle generic key-value payload
|
|
145
|
+
if (data.key && typeof data.value === "string") {
|
|
146
|
+
myBody.append(data.key, data.value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "file": {
|
|
153
|
+
if (_body.type === "raw" && _body.content?.type === "file") {
|
|
154
|
+
myBody = await loadImage(_body.content.value.content);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const requestOptions = {
|
|
163
|
+
method: request.method,
|
|
164
|
+
headers: myHeaders,
|
|
165
|
+
body: myBody,
|
|
166
|
+
};
|
|
167
|
+
let finalUrl = request.url.toString();
|
|
168
|
+
if (proxy) {
|
|
169
|
+
// Ensure the proxy ends with a slash.
|
|
170
|
+
let normalizedProxy = proxy.replace(/\/$/, "") + "/";
|
|
171
|
+
finalUrl = normalizedProxy + request.url.toString();
|
|
172
|
+
}
|
|
173
|
+
return fetchWithtimeout(finalUrl, requestOptions).then((response) => {
|
|
174
|
+
const contentType = response.headers.get("content-type");
|
|
175
|
+
let fileExtension = "";
|
|
176
|
+
if (contentType) {
|
|
177
|
+
if (contentType.includes("application/pdf")) {
|
|
178
|
+
fileExtension = ".pdf";
|
|
179
|
+
} else if (contentType.includes("image/jpeg")) {
|
|
180
|
+
fileExtension = ".jpg";
|
|
181
|
+
} else if (contentType.includes("image/png")) {
|
|
182
|
+
fileExtension = ".png";
|
|
183
|
+
} else if (contentType.includes("image/gif")) {
|
|
184
|
+
fileExtension = ".gif";
|
|
185
|
+
} else if (contentType.includes("image/webp")) {
|
|
186
|
+
fileExtension = ".webp";
|
|
187
|
+
} else if (contentType.includes("video/mpeg")) {
|
|
188
|
+
fileExtension = ".mpeg";
|
|
189
|
+
} else if (contentType.includes("video/mp4")) {
|
|
190
|
+
fileExtension = ".mp4";
|
|
191
|
+
} else if (contentType.includes("audio/mpeg")) {
|
|
192
|
+
fileExtension = ".mp3";
|
|
193
|
+
} else if (contentType.includes("audio/ogg")) {
|
|
194
|
+
fileExtension = ".ogg";
|
|
195
|
+
} else if (contentType.includes("application/octet-stream")) {
|
|
196
|
+
fileExtension = ".bin";
|
|
197
|
+
} else if (contentType.includes("application/zip")) {
|
|
198
|
+
fileExtension = ".zip";
|
|
199
|
+
}
|
|
200
|
+
if (fileExtension) {
|
|
201
|
+
return response.blob().then((blob) => {
|
|
202
|
+
const url = window.URL.createObjectURL(blob);
|
|
203
|
+
const link = document.createElement("a");
|
|
204
|
+
link.href = url;
|
|
205
|
+
// Now the file name includes the extension
|
|
206
|
+
link.setAttribute("download", `file${fileExtension}`);
|
|
207
|
+
// These two lines are necessary to make the link click in Firefox
|
|
208
|
+
link.style.display = "none";
|
|
209
|
+
document.body.appendChild(link);
|
|
210
|
+
link.click();
|
|
211
|
+
// After link is clicked, it's safe to remove it.
|
|
212
|
+
setTimeout(() => document.body.removeChild(link), 0);
|
|
213
|
+
return response;
|
|
214
|
+
});
|
|
215
|
+
} else {
|
|
216
|
+
return response;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return response;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
exports.default = makeRequest;
|