@scalar/api-client 2.18.4 → 2.19.0
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/CHANGELOG.md +37 -0
- package/dist/components/AddressBar/AddressBar.vue2.js +5 -5
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +6 -6
- package/dist/components/ImportCollection/DropEventListener.vue.d.ts.map +1 -1
- package/dist/components/ImportCollection/DropEventListener.vue.js +26 -28
- package/dist/components/ImportCollection/utils/get-openapi-version.d.ts.map +1 -1
- package/dist/components/ImportCollection/utils/import-collection.d.ts +1 -1
- package/dist/components/ImportCollection/utils/import-collection.d.ts.map +1 -1
- package/dist/components/Search/useSearch.d.ts.map +1 -1
- package/dist/components/Search/useSearch.js +16 -16
- package/dist/components/Server/index.d.ts +1 -1
- package/dist/components/Server/index.d.ts.map +1 -1
- package/dist/components/Server/index.js +6 -6
- package/dist/components/SideNav/SideNav.vue.js +3 -3
- package/dist/components/Sidebar/index.d.ts +1 -2
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useResponseBody.d.ts +1 -1
- package/dist/hooks/useResponseBody.d.ts.map +1 -1
- package/dist/hooks/useResponseBody.js +4 -4
- package/dist/hooks/useSidebar.d.ts +1 -1
- package/dist/hooks/useSidebar.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/layouts/App/ApiClientApp.vue.js +5 -5
- package/dist/layouts/App/MainLayout.vue.js +4 -4
- package/dist/layouts/App/create-api-client-app.d.ts +12 -12
- package/dist/layouts/App/index.d.ts +1 -1
- package/dist/layouts/App/index.d.ts.map +1 -1
- package/dist/layouts/Web/ApiClientWeb.vue.js +6 -6
- package/dist/layouts/Web/create-api-client-web.d.ts +12 -12
- package/dist/layouts/Web/index.d.ts +1 -1
- package/dist/layouts/Web/index.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +12 -12
- package/dist/libs/get-request-uid-by-path-method.d.ts +1 -1
- package/dist/libs/get-request-uid-by-path-method.d.ts.map +1 -1
- package/dist/libs/hot-keys.d.ts +2 -2
- package/dist/libs/hot-keys.d.ts.map +1 -1
- package/dist/libs/importers/curl.d.ts.map +1 -1
- package/dist/libs/index.d.ts +14 -15
- package/dist/libs/index.d.ts.map +1 -1
- package/dist/libs/index.js +33 -33
- package/dist/libs/parse-curl.js +4 -4
- package/dist/libs/send-request/create-fetch-body.d.ts +1 -1
- package/dist/libs/send-request/create-fetch-body.d.ts.map +1 -1
- package/dist/libs/send-request/create-fetch-body.js +1 -1
- package/dist/libs/send-request/create-fetch-headers.d.ts.map +1 -1
- package/dist/libs/send-request/create-fetch-query-params.d.ts.map +1 -1
- package/dist/libs/send-request/create-fetch-query-params.js +2 -1
- package/dist/libs/send-request/index.d.ts +1 -1
- package/dist/libs/send-request/index.d.ts.map +1 -1
- package/dist/libs/send-request/index.js +4 -4
- package/dist/libs/send-request/set-request-cookies.d.ts.map +1 -1
- package/dist/libs/send-request/set-request-cookies.js +4 -4
- package/dist/store/active-entities.d.ts +1 -1
- package/dist/store/collections.d.ts +1 -1
- package/dist/store/collections.d.ts.map +1 -1
- package/dist/store/collections.js +4 -4
- package/dist/store/environment.d.ts +1 -1
- package/dist/store/environment.d.ts.map +1 -1
- package/dist/store/environment.js +4 -4
- package/dist/store/import-spec.d.ts +2 -2
- package/dist/store/import-spec.d.ts.map +1 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/request-example.d.ts +1 -1
- package/dist/store/request-example.d.ts.map +1 -1
- package/dist/store/request-example.js +6 -6
- package/dist/store/requests.d.ts +1 -1
- package/dist/store/requests.d.ts.map +1 -1
- package/dist/store/requests.js +8 -8
- package/dist/store/security-schemes.d.ts +1 -1
- package/dist/store/security-schemes.d.ts.map +1 -1
- package/dist/store/security-schemes.js +4 -4
- package/dist/store/servers.d.ts +1 -1
- package/dist/store/servers.d.ts.map +1 -1
- package/dist/store/servers.js +4 -4
- package/dist/store/store.d.ts +12 -12
- package/dist/store/tags.d.ts +1 -1
- package/dist/store/tags.d.ts.map +1 -1
- package/dist/store/tags.js +5 -5
- package/dist/store/workspace.d.ts +13 -13
- package/dist/store/workspace.d.ts.map +1 -1
- package/dist/store/workspace.js +7 -7
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +4 -5
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +17 -16
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +3 -3
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +22 -22
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +14 -13
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +43 -41
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts +14 -0
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/filter-global-cookies.js +14 -0
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts +25 -0
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/get-resolved-url.js +17 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +10 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue2.js +29 -25
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +6 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +27 -23
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +10 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +48 -39
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +49 -46
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +6 -2
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +2 -2
- package/dist/v2/blocks/request-block/RequestBlock.vue2.js +200 -115
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +4 -4
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js +21 -17
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts +16 -10
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.js +32 -45
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +16 -13
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js +4 -4
- package/dist/v2/blocks/request-block/components/RequestTable.vue2.js +32 -33
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +33 -18
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js +106 -106
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts +10 -5
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +60 -31
- package/dist/v2/blocks/request-block/helpers/get-default-headers.d.ts +41 -0
- package/dist/v2/blocks/request-block/helpers/get-default-headers.d.ts.map +1 -0
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +25 -0
- package/dist/v2/blocks/request-block/helpers/group-by.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/group-by.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/group-by.js +6 -3
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +13 -0
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +1 -0
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +7 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +61 -63
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +2 -2
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +2 -0
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +2 -2
- package/dist/v2/components/code-input/CodeInput.vue2.js +57 -51
- package/dist/v2/features/app/App.vue.js +6 -6
- package/dist/v2/features/app/app-events.d.ts +5 -9
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +146 -120
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +69 -71
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue2.js +5 -5
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js +1 -1
- package/dist/v2/features/modal/Modal.vue2.js +21 -22
- package/dist/v2/features/modal/index.d.ts +1 -1
- package/dist/v2/features/modal/index.d.ts.map +1 -1
- package/dist/v2/features/modal/index.js +4 -4
- package/dist/v2/features/modal/modal-events.d.ts +13 -0
- package/dist/v2/features/modal/modal-events.d.ts.map +1 -0
- package/dist/v2/features/modal/modal-events.js +31 -0
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +30 -43
- package/dist/v2/workspace-events.d.ts +25 -0
- package/dist/v2/workspace-events.d.ts.map +1 -0
- package/dist/v2/workspace-events.js +202 -0
- package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.d.ts.map +1 -1
- package/dist/views/Components/CodeSnippet/helpers/get-snippet.d.ts +1 -1
- package/dist/views/Components/CodeSnippet/helpers/get-snippet.d.ts.map +1 -1
- package/dist/views/Cookies/Cookies.vue2.js +3 -3
- package/dist/views/Environment/handle-drag.d.ts +1 -1
- package/dist/views/Environment/handle-drag.d.ts.map +1 -1
- package/dist/views/Request/RequestRoot.vue2.js +9 -9
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue2.js +4 -4
- package/dist/views/Request/RequestSection/RequestCodeExample.vue2.js +4 -4
- package/dist/views/Request/RequestSection/RequestSection.vue2.js +5 -5
- package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue2.js +6 -6
- package/dist/views/Request/RequestSidebarItem.vue2.js +6 -6
- package/dist/views/Request/RequestSubpageHeader.vue2.js +4 -4
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/ResponseSection/index.d.ts +1 -1
- package/dist/views/Request/ResponseSection/index.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/index.js +4 -4
- package/dist/views/Request/consts/index.d.ts +2 -3
- package/dist/views/Request/consts/index.d.ts.map +1 -1
- package/dist/views/Request/consts/new-auth-options.d.ts +1 -1
- package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -1
- package/dist/views/Request/handle-drag.d.ts +1 -1
- package/dist/views/Request/handle-drag.d.ts.map +1 -1
- package/dist/views/Request/hooks/useOpenApiWatcher.d.ts.map +1 -1
- package/dist/views/Request/hooks/useOpenApiWatcher.js +14 -14
- package/dist/views/Request/libs/auth.d.ts +1 -1
- package/dist/views/Request/libs/auth.d.ts.map +1 -1
- package/dist/views/Request/libs/index.d.ts +3 -3
- package/dist/views/Request/libs/index.d.ts.map +1 -1
- package/dist/views/Request/libs/oauth2.js +1 -1
- package/dist/views/Request/libs/watch-mode.js +6 -6
- package/dist/views/Request/types/index.d.ts +1 -1
- package/dist/views/Request/types/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts +0 -18
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.d.ts.map +0 -1
- package/dist/v2/features/modal/hooks/use-workspace-client-modal-events.js +0 -39
- package/dist/v2/features/operation/helpers/get-operation-header.js +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as $, computed as o, ref as b, watch as D, useId as I, createBlock as u, createCommentVNode as d, openBlock as s, unref as a, withCtx as n, createVNode as r, createSlots as N, createElementVNode as
|
|
1
|
+
import { defineComponent as $, computed as o, ref as b, watch as D, useId as I, createBlock as u, createCommentVNode as d, openBlock as s, unref as a, withCtx as n, createVNode as r, createSlots as N, createElementVNode as g, createElementBlock as x, renderSlot as y, createTextVNode as W, toDisplayString as R } from "vue";
|
|
2
2
|
import { ScalarCard as S, ScalarCardHeader as z, ScalarCombobox as U, ScalarButton as A, ScalarCardSection as T, ScalarCodeBlock as F, ScalarVirtualText as M, ScalarCardFooter as K } from "@scalar/components";
|
|
3
3
|
import { freezeElement as Z } from "@scalar/helpers/dom/freeze-element";
|
|
4
4
|
import { ScalarIconCaretDown as G } from "@scalar/icons";
|
|
@@ -18,6 +18,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
18
18
|
...ne,
|
|
19
19
|
__name: "OperationCodeSample",
|
|
20
20
|
props: {
|
|
21
|
+
integration: {},
|
|
21
22
|
clientOptions: {},
|
|
22
23
|
selectedClient: {},
|
|
23
24
|
selectedServer: { default: null },
|
|
@@ -30,7 +31,8 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
30
31
|
operation: {},
|
|
31
32
|
fallback: { type: Boolean },
|
|
32
33
|
generateLabel: { type: Function },
|
|
33
|
-
isWebhook: { type: Boolean }
|
|
34
|
+
isWebhook: { type: Boolean },
|
|
35
|
+
globalCookies: {}
|
|
34
36
|
},
|
|
35
37
|
setup(e) {
|
|
36
38
|
const i = o(() => {
|
|
@@ -50,7 +52,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
50
52
|
l && (c.value = l);
|
|
51
53
|
}
|
|
52
54
|
);
|
|
53
|
-
const
|
|
55
|
+
const k = o(() => {
|
|
54
56
|
if (!e.isWebhook) return null;
|
|
55
57
|
try {
|
|
56
58
|
return P({
|
|
@@ -62,7 +64,8 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
62
64
|
} catch (t) {
|
|
63
65
|
return console.error("[webhookHar]", t), null;
|
|
64
66
|
}
|
|
65
|
-
}), h = o(() => e.isWebhook ?
|
|
67
|
+
}), h = o(() => e.isWebhook ? k.value?.postData?.text ?? "" : _({
|
|
68
|
+
includeDefaultHeaders: e.integration === "client",
|
|
66
69
|
clientId: c.value?.id,
|
|
67
70
|
customCodeSamples: C.value,
|
|
68
71
|
operation: e.operation,
|
|
@@ -71,42 +74,43 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
71
74
|
contentType: e.selectedContentType,
|
|
72
75
|
server: e.selectedServer,
|
|
73
76
|
securitySchemes: e.securitySchemes,
|
|
74
|
-
example: m.value
|
|
77
|
+
example: m.value,
|
|
78
|
+
globalCookies: e.globalCookies
|
|
75
79
|
})), B = o(() => e.isWebhook ? w.value : c.value?.lang), w = o(() => {
|
|
76
|
-
if (!
|
|
77
|
-
const t =
|
|
80
|
+
if (!k.value?.postData) return "json";
|
|
81
|
+
const t = k.value.postData.mimeType;
|
|
78
82
|
return t?.includes("json") ? "json" : t?.includes("xml") ? "xml" : t?.includes("yaml") || t?.includes("yml") ? "yaml" : t?.includes("text/plain") ? "text" : "json";
|
|
79
|
-
}),
|
|
80
|
-
if (
|
|
81
|
-
const l = Z(
|
|
83
|
+
}), H = o(() => Y(e.securitySchemes)), p = b(null), O = (t) => {
|
|
84
|
+
if (p.value) {
|
|
85
|
+
const l = Z(p.value.$el);
|
|
82
86
|
setTimeout(() => {
|
|
83
87
|
l();
|
|
84
88
|
}, 300);
|
|
85
89
|
}
|
|
86
90
|
c.value = t, t && !t.id.startsWith("custom") && e.eventBus.emit("workspace:update:selected-client", t.id);
|
|
87
|
-
},
|
|
88
|
-
() => (h.value.length ?? 0) >
|
|
91
|
+
}, j = 2e4, E = o(
|
|
92
|
+
() => (h.value.length ?? 0) > j
|
|
89
93
|
), L = I();
|
|
90
94
|
return (t, l) => h.value ? (s(), u(a(S), {
|
|
91
95
|
key: 0,
|
|
92
96
|
ref_key: "elem",
|
|
93
|
-
ref:
|
|
97
|
+
ref: p,
|
|
94
98
|
class: "request-card dark-mode"
|
|
95
99
|
}, {
|
|
96
100
|
default: n(() => [
|
|
97
101
|
r(a(z), { class: "pr-2.5" }, N({
|
|
98
102
|
default: n(() => [
|
|
99
|
-
l[2] || (l[2] =
|
|
103
|
+
l[2] || (l[2] = g("span", { class: "sr-only" }, "Request Example for", -1)),
|
|
100
104
|
r(V, {
|
|
101
105
|
as: "span",
|
|
102
106
|
class: "request-method",
|
|
103
107
|
method: e.method
|
|
104
108
|
}, null, 8, ["method"]),
|
|
105
|
-
e.generateLabel ? (s(),
|
|
109
|
+
e.generateLabel ? (s(), x("span", {
|
|
106
110
|
key: 0,
|
|
107
111
|
innerHTML: e.generateLabel()
|
|
108
112
|
}, null, 8, te)) : d("", !0),
|
|
109
|
-
|
|
113
|
+
y(t.$slots, "header", {}, void 0, !0)
|
|
110
114
|
]),
|
|
111
115
|
_: 2
|
|
112
116
|
}, [
|
|
@@ -119,7 +123,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
119
123
|
options: f.value,
|
|
120
124
|
placement: "bottom-end",
|
|
121
125
|
teleport: "",
|
|
122
|
-
"onUpdate:modelValue": l[0] || (l[0] = (v) =>
|
|
126
|
+
"onUpdate:modelValue": l[0] || (l[0] = (v) => O(v))
|
|
123
127
|
}, {
|
|
124
128
|
default: n(() => [
|
|
125
129
|
r(a(A), {
|
|
@@ -145,11 +149,11 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
145
149
|
]), 1024),
|
|
146
150
|
r(a(T), { class: "request-editor-section custom-scroll p-0" }, {
|
|
147
151
|
default: n(() => [
|
|
148
|
-
|
|
152
|
+
g("div", {
|
|
149
153
|
id: `${a(L)}-example`,
|
|
150
154
|
class: "code-snippet"
|
|
151
155
|
}, [
|
|
152
|
-
|
|
156
|
+
E.value ? (s(), u(a(M), {
|
|
153
157
|
key: 1,
|
|
154
158
|
containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
|
|
155
159
|
contentClass: "language-plaintext whitespace-pre font-code text-base",
|
|
@@ -159,7 +163,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
159
163
|
key: 0,
|
|
160
164
|
class: "bg-b-2 !min-h-full -outline-offset-2",
|
|
161
165
|
content: h.value,
|
|
162
|
-
hideCredentials:
|
|
166
|
+
hideCredentials: H.value,
|
|
163
167
|
lang: B.value,
|
|
164
168
|
lineNumbers: ""
|
|
165
169
|
}, null, 8, ["content", "hideCredentials", "lang"]))
|
|
@@ -172,7 +176,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
172
176
|
class: "request-card-footer bg-b-3"
|
|
173
177
|
}, {
|
|
174
178
|
default: n(() => [
|
|
175
|
-
Object.keys(i.value).length > 1 ? (s(),
|
|
179
|
+
Object.keys(i.value).length > 1 ? (s(), x("div", ae, [
|
|
176
180
|
Object.keys(i.value).length ? (s(), u(ee, {
|
|
177
181
|
key: 0,
|
|
178
182
|
modelValue: m.value,
|
|
@@ -180,7 +184,7 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
180
184
|
examples: i.value
|
|
181
185
|
}, null, 8, ["modelValue", "examples"])) : d("", !0)
|
|
182
186
|
])) : d("", !0),
|
|
183
|
-
|
|
187
|
+
y(t.$slots, "footer", {}, void 0, !0)
|
|
184
188
|
]),
|
|
185
189
|
_: 3
|
|
186
190
|
})) : d("", !0)
|
|
@@ -193,15 +197,15 @@ const te = ["innerHTML"], le = ["id"], ae = {
|
|
|
193
197
|
default: n(() => [
|
|
194
198
|
r(a(T), { class: "request-card-simple" }, {
|
|
195
199
|
default: n(() => [
|
|
196
|
-
|
|
200
|
+
g("div", oe, [
|
|
197
201
|
r(V, {
|
|
198
202
|
as: "span",
|
|
199
203
|
class: "request-method",
|
|
200
204
|
method: e.method
|
|
201
205
|
}, null, 8, ["method"]),
|
|
202
|
-
|
|
206
|
+
y(t.$slots, "header", {}, void 0, !0)
|
|
203
207
|
]),
|
|
204
|
-
|
|
208
|
+
y(t.$slots, "footer", {}, void 0, !0)
|
|
205
209
|
]),
|
|
206
210
|
_: 3
|
|
207
211
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
2
|
import type { AvailableClient } from '@scalar/snippetz';
|
|
3
|
+
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
3
4
|
import type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation';
|
|
4
5
|
import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
5
6
|
import { type CustomCodeSampleId } from './generate-client-options.js';
|
|
@@ -22,8 +23,12 @@ type GenerateCodeSnippetProps = {
|
|
|
22
23
|
securitySchemes: SecuritySchemeObject[];
|
|
23
24
|
/** The server object defining the base URL for the API request. */
|
|
24
25
|
server: ServerObject | null;
|
|
26
|
+
/** Workspace + document cookies */
|
|
27
|
+
globalCookies?: XScalarCookie[];
|
|
28
|
+
/** Whether to include default headers (e.g., Accept, Content-Type) automatically. */
|
|
29
|
+
includeDefaultHeaders?: boolean;
|
|
25
30
|
};
|
|
26
31
|
/** Generate the code snippet for the selected example OR operation */
|
|
27
|
-
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, operation, method, path, example, contentType, server, securitySchemes, }: GenerateCodeSnippetProps) => string;
|
|
32
|
+
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, }: GenerateCodeSnippetProps) => string;
|
|
28
33
|
export {};
|
|
29
34
|
//# sourceMappingURL=generate-code-snippet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,2BAA2B,CAAA;AAErF,KAAK,wBAAwB,GAAG;IAC9B,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAA;IAClB,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,EAAE,oBAAoB,EAAE,CAAA;IACvC,mEAAmE;IACnE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AACvF,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAKrE,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,2BAA2B,CAAA;AAErF,KAAK,wBAAwB,GAAG;IAC9B,wGAAwG;IACxG,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAA;IAC1D,qFAAqF;IACrF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mFAAmF;IACnF,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,MAAM,EAAE,UAAU,CAAA;IAClB,wEAAwE;IACxE,SAAS,EAAE,eAAe,CAAA;IAC1B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,eAAe,EAAE,oBAAoB,EAAE,CAAA;IACvC,mEAAmE;IACnE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B,qFAAqF;IACrF,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,gJAYjC,wBAAwB,KAAG,MAuC7B,CAAA"}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
import { operationToHar as
|
|
2
|
-
import { getSnippet as
|
|
3
|
-
import { generateCustomId as
|
|
4
|
-
const
|
|
1
|
+
import { operationToHar as y } from "./operation-to-har/operation-to-har.js";
|
|
2
|
+
import { getSnippet as S } from "../../../../views/Components/CodeSnippet/helpers/get-snippet.js";
|
|
3
|
+
import { generateCustomId as h } from "./generate-client-options.js";
|
|
4
|
+
const q = ({
|
|
5
5
|
clientId: e,
|
|
6
6
|
customCodeSamples: o,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
includeDefaultHeaders: n = !1,
|
|
8
|
+
operation: p,
|
|
9
|
+
method: s,
|
|
10
|
+
path: a,
|
|
11
|
+
example: i,
|
|
12
|
+
contentType: g,
|
|
13
|
+
server: m,
|
|
14
|
+
securitySchemes: u,
|
|
15
|
+
globalCookies: c
|
|
14
16
|
}) => {
|
|
15
17
|
try {
|
|
16
18
|
if (!e)
|
|
17
19
|
return "";
|
|
18
20
|
if (e.startsWith("custom"))
|
|
19
|
-
return o.find((
|
|
20
|
-
const r =
|
|
21
|
-
operation:
|
|
22
|
-
contentType:
|
|
23
|
-
method:
|
|
24
|
-
path:
|
|
25
|
-
server:
|
|
26
|
-
securitySchemes:
|
|
27
|
-
example:
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
return o.find((l) => h(l) === e)?.source ?? "Custom example not found";
|
|
22
|
+
const r = y({
|
|
23
|
+
operation: p,
|
|
24
|
+
contentType: g,
|
|
25
|
+
method: s,
|
|
26
|
+
path: a,
|
|
27
|
+
server: m,
|
|
28
|
+
securitySchemes: u,
|
|
29
|
+
example: i,
|
|
30
|
+
globalCookies: c,
|
|
31
|
+
includeDefaultHeaders: n
|
|
32
|
+
}), [f, d] = e.split("/"), [t, C] = S(f, d, r);
|
|
33
|
+
return t ? (console.error("[generateCodeSnippet]", t), t.message ?? "Error generating code snippet") : C;
|
|
30
34
|
} catch (r) {
|
|
31
35
|
return console.error("[generateCodeSnippet]", r), "Error generating code snippet";
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
export {
|
|
35
|
-
|
|
39
|
+
q as generateCodeSnippet
|
|
36
40
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
2
3
|
import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
4
|
import type { Request as HarRequest } from 'har-format';
|
|
4
5
|
export type OperationToHarProps = {
|
|
@@ -25,6 +26,14 @@ export type OperationToHarProps = {
|
|
|
25
26
|
server?: ServerObject | null;
|
|
26
27
|
/** OpenAPI SecurityScheme objects which are applicable to the operation */
|
|
27
28
|
securitySchemes?: SecuritySchemeObject[];
|
|
29
|
+
/** Workspace + document cookies */
|
|
30
|
+
globalCookies?: XScalarCookie[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether to include default headers (e.g., Accept, Content-Type) automatically.
|
|
33
|
+
* If false, default headers will be omitted from the HAR request.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
includeDefaultHeaders?: boolean;
|
|
28
37
|
};
|
|
29
38
|
/**
|
|
30
39
|
* Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.
|
|
@@ -48,5 +57,5 @@ export type OperationToHarProps = {
|
|
|
48
57
|
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
49
58
|
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
50
59
|
*/
|
|
51
|
-
export declare const operationToHar: ({ operation, contentType, method, path, server, example, securitySchemes, }: OperationToHarProps) => HarRequest;
|
|
60
|
+
export declare const operationToHar: ({ includeDefaultHeaders, operation, contentType, method, path, server, example, securitySchemes, globalCookies, }: OperationToHarProps) => HarRequest;
|
|
52
61
|
//# sourceMappingURL=operation-to-har.d.ts.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAUvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACxC,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,mHAU5B,mBAAmB,KAAG,UAgGxB,CAAA"}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
|
-
import { getResolvedRef as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { getResolvedRef as k } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
2
|
+
import { filterGlobalCookie as q } from "../../../operation-block/helpers/filter-global-cookies.js";
|
|
3
|
+
import { getDefaultHeaders as T } from "../../../request-block/helpers/get-default-headers.js";
|
|
4
|
+
import { processBody as C } from "./process-body.js";
|
|
5
|
+
import { processParameters as H } from "./process-parameters.js";
|
|
6
|
+
import { processSecuritySchemes as z } from "./process-security-schemes.js";
|
|
7
|
+
import { processServerUrl as D } from "./process-server-url.js";
|
|
8
|
+
const w = ({
|
|
9
|
+
includeDefaultHeaders: f = !1,
|
|
7
10
|
operation: t,
|
|
8
|
-
contentType:
|
|
9
|
-
method:
|
|
10
|
-
path:
|
|
11
|
-
server:
|
|
12
|
-
example:
|
|
13
|
-
securitySchemes:
|
|
11
|
+
contentType: l,
|
|
12
|
+
method: n,
|
|
13
|
+
path: p,
|
|
14
|
+
server: c = null,
|
|
15
|
+
example: a,
|
|
16
|
+
securitySchemes: d,
|
|
17
|
+
globalCookies: h
|
|
14
18
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
method:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const y = f ? T({
|
|
20
|
+
method: n,
|
|
21
|
+
operation: t,
|
|
22
|
+
exampleKey: a ?? "default",
|
|
23
|
+
hideDisabledHeaders: !0
|
|
24
|
+
}).filter((e) => !e.isOverridden) : [], g = t["x-scalar-disable-parameters"]?.["global-cookies"]?.[a ?? "default"] ?? {}, v = D(c, p), r = {
|
|
25
|
+
method: n,
|
|
26
|
+
url: v,
|
|
27
|
+
headers: y.map((e) => ({ name: e.name, value: e.defaultValue })),
|
|
19
28
|
queryString: [],
|
|
20
29
|
postData: void 0,
|
|
21
30
|
httpVersion: "HTTP/1.1",
|
|
@@ -23,37 +32,37 @@ const b = ({
|
|
|
23
32
|
headersSize: -1,
|
|
24
33
|
bodySize: -1
|
|
25
34
|
};
|
|
26
|
-
if (
|
|
27
|
-
const { url:
|
|
28
|
-
harRequest:
|
|
35
|
+
if (t.parameters) {
|
|
36
|
+
const { url: e, headers: s, queryString: o, cookies: S } = H({
|
|
37
|
+
harRequest: r,
|
|
29
38
|
parameters: t.parameters,
|
|
30
|
-
example:
|
|
31
|
-
contentType:
|
|
32
|
-
});
|
|
33
|
-
|
|
39
|
+
example: a,
|
|
40
|
+
contentType: l
|
|
41
|
+
}), b = h?.filter((i) => q({ cookie: i, url: e, disabledGlobalCookies: g }))?.map((i) => ({ name: i.name, value: i.value })) ?? [];
|
|
42
|
+
r.url = e, r.headers = s, r.queryString = o, r.cookies = [...b, ...S];
|
|
34
43
|
}
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
(
|
|
44
|
+
const m = k(t.requestBody);
|
|
45
|
+
if (m?.content) {
|
|
46
|
+
const e = C({ requestBody: m, contentType: l, example: a });
|
|
47
|
+
if (e && (r.postData = e, r.bodySize = e.text?.length ?? -1, e.mimeType)) {
|
|
48
|
+
const s = r.headers.find(
|
|
49
|
+
(o) => o.name.toLowerCase() === "content-type"
|
|
41
50
|
);
|
|
42
|
-
|
|
51
|
+
s && !s.value ? s.value = e.mimeType : s || r.headers.push({
|
|
43
52
|
name: "Content-Type",
|
|
44
|
-
value:
|
|
53
|
+
value: e.mimeType
|
|
45
54
|
});
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
|
-
if (
|
|
49
|
-
const { headers:
|
|
50
|
-
|
|
57
|
+
if (d) {
|
|
58
|
+
const { headers: e, queryString: s, cookies: o } = z(d);
|
|
59
|
+
r.headers.push(...e), r.queryString.push(...s), r.cookies.push(...o);
|
|
51
60
|
}
|
|
52
|
-
let
|
|
53
|
-
for (const
|
|
54
|
-
|
|
55
|
-
return
|
|
61
|
+
let u = 0;
|
|
62
|
+
for (const e of r.headers)
|
|
63
|
+
u += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
|
|
64
|
+
return r.headersSize = u, r;
|
|
56
65
|
};
|
|
57
66
|
export {
|
|
58
|
-
|
|
67
|
+
w as operationToHar
|
|
59
68
|
};
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAKvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAuED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,mDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,KAAG,mBAqNH,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getResolvedRef as d } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
2
2
|
import { getExampleFromSchema as p } from "../get-example-from-schema.js";
|
|
3
3
|
import { getExample as h } from "../../../operation-block/helpers/get-example.js";
|
|
4
|
-
|
|
4
|
+
import { isParamDisabled as A } from "../../../request-block/helpers/is-param-disabled.js";
|
|
5
|
+
const g = (e) => (e ?? []).map((o) => d(o)), S = (e) => {
|
|
5
6
|
if (e.in === "header")
|
|
6
7
|
return { style: "simple", explode: "explode" in e && e.explode !== void 0 ? e.explode : !1 };
|
|
7
8
|
if (e.in === "cookie")
|
|
@@ -11,53 +12,55 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
11
12
|
query: "form",
|
|
12
13
|
header: "simple",
|
|
13
14
|
cookie: "form"
|
|
14
|
-
}[e.in], t = "style" in e && e.style ? e.style : o,
|
|
15
|
-
return { style: t, explode:
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
}[e.in], t = "style" in e && e.style ? e.style : o, y = "explode" in e && e.explode !== void 0 ? e.explode : t === "form";
|
|
16
|
+
return { style: t, explode: y };
|
|
17
|
+
}, k = (e, o, t) => {
|
|
18
|
+
const y = h(e, o, t);
|
|
19
|
+
if (A(e, y))
|
|
20
|
+
return;
|
|
21
|
+
if (y?.value !== void 0)
|
|
22
|
+
return y.value;
|
|
23
|
+
if (!("schema" in e) || !e.schema)
|
|
24
|
+
return;
|
|
25
|
+
const f = e.in === "path" ? { emptyString: `{${e.name}}` } : {};
|
|
26
|
+
return p(d(e.schema), f);
|
|
27
|
+
}, E = ({
|
|
25
28
|
harRequest: e,
|
|
26
29
|
parameters: o,
|
|
27
30
|
example: t,
|
|
28
|
-
contentType:
|
|
31
|
+
contentType: y
|
|
29
32
|
}) => {
|
|
30
33
|
const f = [...e.headers], i = [...e.queryString];
|
|
31
|
-
let
|
|
32
|
-
const u =
|
|
34
|
+
let c = e.url;
|
|
35
|
+
const u = g(o);
|
|
33
36
|
for (const s of u) {
|
|
34
37
|
if (!s.in || !s.name)
|
|
35
38
|
continue;
|
|
36
|
-
const n =
|
|
39
|
+
const n = k(s, t, y);
|
|
37
40
|
if (n === void 0)
|
|
38
41
|
continue;
|
|
39
|
-
const { style:
|
|
42
|
+
const { style: m, explode: v } = S(s);
|
|
40
43
|
switch (s.in) {
|
|
41
44
|
case "path": {
|
|
42
|
-
|
|
45
|
+
c = x(c, s, n, m, v);
|
|
43
46
|
break;
|
|
44
47
|
}
|
|
45
48
|
case "query": {
|
|
46
|
-
switch (
|
|
49
|
+
switch (m) {
|
|
47
50
|
case "form": {
|
|
48
51
|
if (v)
|
|
49
52
|
if (Array.isArray(n))
|
|
50
53
|
for (const l of n)
|
|
51
54
|
i.push({ name: s.name, value: String(l) });
|
|
52
55
|
else if (typeof n == "object" && n !== null)
|
|
53
|
-
for (const [l,
|
|
54
|
-
i.push({ name: l, value: String(
|
|
56
|
+
for (const [l, r] of Object.entries(n))
|
|
57
|
+
i.push({ name: l, value: String(r) });
|
|
55
58
|
else
|
|
56
59
|
i.push({ name: s.name, value: String(n) });
|
|
57
60
|
else if (Array.isArray(n))
|
|
58
61
|
i.push({ name: s.name, value: n.join(",") });
|
|
59
62
|
else if (typeof n == "object" && n !== null) {
|
|
60
|
-
const l = Object.entries(n).map(([
|
|
63
|
+
const l = Object.entries(n).map(([r, $]) => `${r},${$}`).join(",");
|
|
61
64
|
i.push({ name: s.name, value: l });
|
|
62
65
|
} else
|
|
63
66
|
i.push({ name: s.name, value: String(n) });
|
|
@@ -67,7 +70,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
67
70
|
if (Array.isArray(n))
|
|
68
71
|
i.push({ name: s.name, value: n.join(" ") });
|
|
69
72
|
else if (typeof n == "object" && n !== null) {
|
|
70
|
-
const l = Object.entries(n).map(([
|
|
73
|
+
const l = Object.entries(n).map(([r, $]) => `${r} ${$}`).join(" ");
|
|
71
74
|
i.push({ name: s.name, value: l });
|
|
72
75
|
}
|
|
73
76
|
break;
|
|
@@ -83,8 +86,8 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
83
86
|
}
|
|
84
87
|
case "deepObject": {
|
|
85
88
|
if (v && typeof n == "object" && n !== null)
|
|
86
|
-
for (const [l,
|
|
87
|
-
i.push({ name: `${s.name}[${l}]`, value: String(
|
|
89
|
+
for (const [l, r] of Object.entries(n))
|
|
90
|
+
i.push({ name: `${s.name}[${l}]`, value: String(r) });
|
|
88
91
|
break;
|
|
89
92
|
}
|
|
90
93
|
// Default to form style
|
|
@@ -99,14 +102,14 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
99
102
|
for (const l of n)
|
|
100
103
|
f.push({ name: s.name, value: String(l) });
|
|
101
104
|
else if (typeof n == "object" && n !== null) {
|
|
102
|
-
const l = Object.entries(n).map(([
|
|
105
|
+
const l = Object.entries(n).map(([r, $]) => `${r}=${$}`).join(",");
|
|
103
106
|
f.push({ name: s.name, value: l });
|
|
104
107
|
} else
|
|
105
108
|
f.push({ name: s.name, value: String(n) });
|
|
106
109
|
else if (Array.isArray(n))
|
|
107
110
|
f.push({ name: s.name, value: n.join(",") });
|
|
108
111
|
else if (typeof n == "object" && n !== null) {
|
|
109
|
-
const l = Object.entries(n).map(([
|
|
112
|
+
const l = Object.entries(n).map(([r, $]) => `${r},${$}`).join(",");
|
|
110
113
|
f.push({ name: s.name, value: l });
|
|
111
114
|
} else
|
|
112
115
|
f.push({ name: s.name, value: String(n) });
|
|
@@ -117,42 +120,42 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
117
120
|
for (const l of n)
|
|
118
121
|
e.cookies.push({ name: s.name, value: l === null ? "null" : String(l) });
|
|
119
122
|
else if (typeof n == "object" && n !== null)
|
|
120
|
-
for (const [l,
|
|
121
|
-
e.cookies.push({ name: l, value:
|
|
123
|
+
for (const [l, r] of Object.entries(n))
|
|
124
|
+
e.cookies.push({ name: l, value: r === null ? "null" : String(r) });
|
|
122
125
|
else
|
|
123
126
|
e.cookies.push({ name: s.name, value: n === null ? "null" : String(n) });
|
|
124
127
|
else if (Array.isArray(n)) {
|
|
125
|
-
const l = n.map((
|
|
128
|
+
const l = n.map((r) => r === null ? "null" : String(r)).join(",");
|
|
126
129
|
e.cookies.push({ name: s.name, value: l });
|
|
127
130
|
} else if (typeof n == "object" && n !== null) {
|
|
128
|
-
const l = (
|
|
131
|
+
const l = ($) => {
|
|
129
132
|
const a = [];
|
|
130
|
-
for (const [
|
|
131
|
-
typeof j == "object" && j !== null && !Array.isArray(j) ? a.push(
|
|
133
|
+
for (const [b, j] of Object.entries($))
|
|
134
|
+
typeof j == "object" && j !== null && !Array.isArray(j) ? a.push(b, ...l(j)) : a.push(b, j === null ? "null" : String(j));
|
|
132
135
|
return a;
|
|
133
|
-
},
|
|
134
|
-
e.cookies.push({ name: s.name, value:
|
|
136
|
+
}, r = l(n).join(",");
|
|
137
|
+
e.cookies.push({ name: s.name, value: r });
|
|
135
138
|
} else
|
|
136
139
|
e.cookies.push({ name: s.name, value: n === null ? "null" : String(n) });
|
|
137
140
|
break;
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
return {
|
|
141
|
-
url:
|
|
144
|
+
url: c,
|
|
142
145
|
headers: f,
|
|
143
146
|
queryString: i,
|
|
144
147
|
cookies: e.cookies
|
|
145
148
|
};
|
|
146
|
-
},
|
|
147
|
-
switch (
|
|
149
|
+
}, x = (e, o, t, y, f) => {
|
|
150
|
+
switch (y) {
|
|
148
151
|
case "matrix": {
|
|
149
152
|
if (f) {
|
|
150
153
|
if (Array.isArray(t)) {
|
|
151
|
-
const i = t.map((
|
|
154
|
+
const i = t.map((c) => `${o.name}=${c}`).join(";");
|
|
152
155
|
return e.replace(`{;${o.name}}`, `;${i}`);
|
|
153
156
|
}
|
|
154
157
|
if (typeof t == "object" && t !== null) {
|
|
155
|
-
const i = Object.entries(t).map(([
|
|
158
|
+
const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(";");
|
|
156
159
|
return e.replace(`{;${o.name}}`, `;${i}`);
|
|
157
160
|
}
|
|
158
161
|
return e.replace(`{;${o.name}}`, `;${o.name}=${t}`);
|
|
@@ -160,7 +163,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
160
163
|
if (Array.isArray(t))
|
|
161
164
|
return e.replace(`{;${o.name}}`, `;${o.name}=${t.join(",")}`);
|
|
162
165
|
if (typeof t == "object" && t !== null) {
|
|
163
|
-
const i = Object.entries(t).map(([
|
|
166
|
+
const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
|
|
164
167
|
return e.replace(`{;${o.name}}`, `;${o.name}=${i}`);
|
|
165
168
|
}
|
|
166
169
|
return e.replace(`{;${o.name}}`, `;${o.name}=${t}`);
|
|
@@ -170,7 +173,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
170
173
|
if (Array.isArray(t))
|
|
171
174
|
return e.replace(`{.${o.name}}`, `.${t.join(".")}`);
|
|
172
175
|
if (typeof t == "object" && t !== null) {
|
|
173
|
-
const i = Object.entries(t).map(([
|
|
176
|
+
const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(".");
|
|
174
177
|
return e.replace(`{.${o.name}}`, `.${i}`);
|
|
175
178
|
}
|
|
176
179
|
return e.replace(`{.${o.name}}`, `.${t}`);
|
|
@@ -178,7 +181,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
178
181
|
if (Array.isArray(t))
|
|
179
182
|
return e.replace(`{.${o.name}}`, `.${t.join(",")}`);
|
|
180
183
|
if (typeof t == "object" && t !== null) {
|
|
181
|
-
const i = Object.entries(t).map(([
|
|
184
|
+
const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
|
|
182
185
|
return e.replace(`{.${o.name}}`, `.${i}`);
|
|
183
186
|
}
|
|
184
187
|
return e.replace(`{.${o.name}}`, `.${t}`);
|
|
@@ -188,7 +191,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
188
191
|
if (Array.isArray(t))
|
|
189
192
|
return e.replace(`{${o.name}}`, t.join(","));
|
|
190
193
|
if (typeof t == "object" && t !== null) {
|
|
191
|
-
const i = Object.entries(t).map(([
|
|
194
|
+
const i = Object.entries(t).map(([c, u]) => `${c}=${u}`).join(",");
|
|
192
195
|
return e.replace(`{${o.name}}`, i);
|
|
193
196
|
}
|
|
194
197
|
return e.replace(`{${o.name}}`, String(t));
|
|
@@ -196,7 +199,7 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
196
199
|
if (Array.isArray(t))
|
|
197
200
|
return e.replace(`{${o.name}}`, t.join(","));
|
|
198
201
|
if (typeof t == "object" && t !== null) {
|
|
199
|
-
const i = Object.entries(t).map(([
|
|
202
|
+
const i = Object.entries(t).map(([c, u]) => `${c},${u}`).join(",");
|
|
200
203
|
return e.replace(`{${o.name}}`, i);
|
|
201
204
|
}
|
|
202
205
|
return e.replace(`{${o.name}}`, String(t));
|
|
@@ -207,5 +210,5 @@ const A = (e) => (e ?? []).map((o) => d(o)), g = (e) => {
|
|
|
207
210
|
}
|
|
208
211
|
};
|
|
209
212
|
export {
|
|
210
|
-
|
|
213
|
+
E as processParameters
|
|
211
214
|
};
|