@scalar/api-client
Version:
the open source API testing client
126 lines (125 loc) • 5.09 kB
JavaScript
import { defineComponent as w, computed as t, toValue as a, createBlock as C, createElementBlock as B, openBlock as m, unref as c, createElementVNode as U } from "vue";
import { getResolvedRef as s } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { mapHiddenClientsConfig as b } from "../modal/helpers/map-hidden-clients-config.js";
import { combineParams as M } from "./helpers/combine-params.js";
import { getSelectedServer as N } from "./helpers/get-selected-server.js";
import { getActiveProxyUrl as A } from "../../helpers/get-active-proxy-url.js";
import { getServers as E } from "../../helpers/get-servers.js";
import V from "../../blocks/operation-block/OperationBlock.vue.js";
const P = {
key: 1,
class: "flex h-full w-full items-center justify-center"
}, R = {}, W = /* @__PURE__ */ w({
...R,
__name: "Operation",
props: {
documentSlug: {},
document: {},
eventBus: {},
layout: {},
path: {},
method: {},
exampleName: {},
environment: {},
securitySchemes: {},
workspaceStore: {},
activeWorkspace: {},
plugins: {},
customThemes: {},
currentTheme: {},
isDarkMode: { type: Boolean },
options: {}
},
setup(e) {
const l = t(() => e.path ? s(e.document?.paths?.[e.path]) : null), r = t(() => {
if (!e.path || !e.method)
return null;
const n = s(e.document?.paths?.[e.path]?.[e.method]);
if (!n)
return null;
if (!l.value)
return n;
const o = M(
l.value.parameters,
n.parameters
);
return { ...n, parameters: o };
}), d = t(() => [
...(e.workspaceStore.workspace?.["x-scalar-cookies"] ?? []).map((n) => ({
...n,
location: "workspace"
})),
...(e.document?.["x-scalar-cookies"] ?? []).map((n) => ({
...n,
location: "document"
}))
]), u = t(() => {
const n = a(e.options)?.servers ?? r.value?.servers ?? // pathItem.value?.servers ?? TODO: add support for pathItem servers
e.document?.servers;
return E(n, {
baseServerUrl: a(e.options)?.baseServerURL,
documentUrl: e.document?.["x-scalar-original-source-url"]
});
}), v = t(() => a(e.options)?.servers != null ? e.document?.["x-scalar-selected-server"] : r.value?.servers != null ? r.value["x-scalar-selected-server"] : e.document?.["x-scalar-selected-server"]), h = t(
() => N(u.value, v.value)
), S = t(() => r.value?.servers != null ? { type: "operation", path: e.path ?? "", method: e.method ?? "get" } : { type: "document" }), y = t(() => e.workspaceStore.auth.getAuthSelectedSchemas({
type: "document",
documentName: e.documentSlug
})), i = t(() => e.workspaceStore.auth.getAuthSelectedSchemas({
type: "operation",
documentName: e.documentSlug,
path: e.path ?? "",
method: e.method ?? "get"
})), f = t(() => i.value !== void 0 ? {
type: "operation",
path: e.path ?? "",
method: e.method ?? "get"
} : { type: "document" }), k = t(() => Array.from(
new Set(
Object.keys({
...e.document?.["x-scalar-environments"],
...e.workspaceStore.workspace["x-scalar-environments"]
})
)
)), x = t(
() => b(a(e.options)?.hiddenClients)
), g = "2.36.1";
return (n, o) => e.path && e.method && e.exampleName && r.value ? (m(), C(c(V), {
key: 0,
activeEnvironment: e.workspaceStore.workspace["x-scalar-active-environment"],
appVersion: c(g),
authMeta: f.value,
documentSecurity: e.document?.security ?? [],
documentSelectedSecurity: y.value,
documentUrl: e.document?.["x-scalar-original-source-url"],
environment: e.environment,
environments: k.value,
eventBus: e.eventBus,
exampleKey: e.exampleName,
globalCookies: d.value,
hideClientButton: a(e.options)?.hideClientButton ?? !1,
history: e.workspaceStore.history.getHistory(e.documentSlug, e.path, e.method),
httpClients: x.value,
layout: e.layout,
method: e.method,
operation: r.value,
operationSelectedSecurity: i.value,
path: e.path,
plugins: e.plugins,
proxyUrl: c(A)(
e.workspaceStore.workspace["x-scalar-active-proxy"],
e.layout
) ?? "",
securitySchemes: e.securitySchemes,
selectedClient: e.workspaceStore.workspace["x-scalar-default-client"],
server: h.value,
serverMeta: S.value,
servers: u.value
}, null, 8, ["activeEnvironment", "appVersion", "authMeta", "documentSecurity", "documentSelectedSecurity", "documentUrl", "environment", "environments", "eventBus", "exampleKey", "globalCookies", "hideClientButton", "history", "httpClients", "layout", "method", "operation", "operationSelectedSecurity", "path", "plugins", "proxyUrl", "securitySchemes", "selectedClient", "server", "serverMeta", "servers"])) : (m(), B("div", P, [...o[0] || (o[0] = [
U("span", { class: "text-c-3" }, "Select an operation to view details", -1)
])]));
}
});
export {
W as default
};