@scalar/api-client 2.21.0 → 2.22.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 +54 -0
- package/dist/components/OpenApiClientButton.vue.d.ts.map +1 -1
- package/dist/components/OpenApiClientButton.vue.js +2 -2
- package/dist/components/OpenApiClientButton.vue2.js +1 -1
- package/dist/hooks/useClientConfig.d.ts +9 -0
- package/dist/hooks/useClientConfig.d.ts.map +1 -1
- package/dist/layouts/App/create-api-client-app.d.ts +2 -2
- package/dist/layouts/Web/create-api-client-web.d.ts +2 -2
- package/dist/libs/create-client.d.ts +2 -2
- package/dist/store/request-example.d.ts +2 -2
- package/dist/store/store.d.ts +2 -2
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts +2 -2
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.js +29 -22
- package/dist/v2/blocks/operation-block/index.d.ts +1 -0
- package/dist/v2/blocks/operation-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/index.js +2 -0
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +4 -4
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +3 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.js +96 -78
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue3.js +5 -0
- package/dist/v2/features/app/App.vue.d.ts +3 -0
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +43 -42
- package/dist/v2/features/app/app-events.d.ts +1 -3
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +37 -43
- package/dist/v2/features/app/app-state.d.ts +0 -2
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +87 -90
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.js +14 -8
- package/dist/v2/features/app/index.d.ts +1 -0
- package/dist/v2/features/app/index.d.ts.map +1 -1
- package/dist/v2/features/app/index.js +11 -7
- package/dist/v2/features/command-palette/{components/TheCommandPalette.vue.d.ts → TheCommandPalette.vue.d.ts} +3 -3
- package/dist/v2/features/command-palette/TheCommandPalette.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/TheCommandPalette.vue.js +7 -0
- package/dist/v2/features/command-palette/TheCommandPalette.vue2.js +152 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +9 -2
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +61 -55
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts +2 -2
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.js +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue2.js +26 -26
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.js +30 -24
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +240 -151
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -1
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.js +114 -102
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js +2 -2
- package/dist/v2/features/modal/Modal.vue2.js +17 -15
- package/dist/v2/features/operation/Operation.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts +2 -2
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +17 -22
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue2.js +0 -4
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +0 -1
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.js +0 -7
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue2.js +0 -172
- package/dist/v2/features/command-palette/components/index.d.ts +0 -2
- package/dist/v2/features/command-palette/components/index.d.ts.map +0 -1
- package/dist/v2/features/command-palette/components/index.js +0 -4
- package/dist/v2/features/command-palette/types.d.ts +0 -83
- package/dist/v2/features/command-palette/types.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
2
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CommandPaletteState } from './hooks/use-command-palette-state.js';
|
|
4
4
|
/**
|
|
5
5
|
* The Command Palette Component
|
|
6
6
|
*
|
|
@@ -24,14 +24,14 @@ import type { UseCommandPaletteStateReturn } from '../../../../v2/features/comma
|
|
|
24
24
|
*/
|
|
25
25
|
declare const _default: import("vue").DefineComponent<{
|
|
26
26
|
/** The command palette state management hook */
|
|
27
|
-
paletteState:
|
|
27
|
+
paletteState: CommandPaletteState;
|
|
28
28
|
/** The workspace store for accessing documents and operations */
|
|
29
29
|
workspaceStore: WorkspaceStore;
|
|
30
30
|
/** Event bus for emitting workspace events */
|
|
31
31
|
eventBus: WorkspaceEventBus;
|
|
32
32
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
33
33
|
/** The command palette state management hook */
|
|
34
|
-
paletteState:
|
|
34
|
+
paletteState: CommandPaletteState;
|
|
35
35
|
/** The workspace store for accessing documents and operations */
|
|
36
36
|
workspaceStore: WorkspaceStore;
|
|
37
37
|
/** Event bus for emitting workspace events */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TheCommandPalette.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/command-palette/TheCommandPalette.vue"],"names":[],"mappings":"AAkWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AAWvC,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,mCAAmC,CAAA;AAG1C;;;;;;;;;;;;;;;;;;;;GAoBG;;IAGD,gDAAgD;kBAClC,mBAAmB;IACjC,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;IAL3B,gDAAgD;kBAClC,mBAAmB;IACjC,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;AAP7B,wBA+bC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { defineComponent as V, ref as E, computed as f, watch as K, onBeforeMount as R, onBeforeUnmount as X, createBlock as v, openBlock as l, unref as r, withCtx as p, createElementVNode as u, createVNode as i, createElementBlock as s, createTextVNode as I, createCommentVNode as S, withKeys as x, withModifiers as C, Fragment as h, renderList as B, withDirectives as Q, toDisplayString as D, vShow as A, normalizeClass as F, resolveDynamicComponent as O, mergeProps as G, nextTick as H } from "vue";
|
|
2
|
+
import { Dialog as U, DialogPanel as W, DialogTitle as $ } from "@headlessui/vue";
|
|
3
|
+
import { ScalarIconMagnifyingGlass as j, ScalarIconCaretLeft as q } from "@scalar/icons";
|
|
4
|
+
import { useRouter as J } from "vue-router";
|
|
5
|
+
const Y = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "custom-scroll max-h-[50dvh] min-h-0 flex-1 rounded-lg p-1.5"
|
|
8
|
+
}, Z = { class: "bg-b-2 focus-within:bg-b-1 sticky top-0 flex items-center rounded-md border border-transparent pl-2 shadow-[0_-8px_0_8px_var(--scalar-background-1),0_0_8px_8px_var(--scalar-background-1)] focus-within:border-(--scalar-background-3)" }, _ = { for: "commandmenu" }, ee = ["value", "onKeydown"], te = ["id", "onClick"], ne = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "text-c-3 p-2 pt-3 text-center text-sm"
|
|
11
|
+
}, ae = {
|
|
12
|
+
key: 1,
|
|
13
|
+
class: "flex-1 p-1.5"
|
|
14
|
+
}, oe = {}, de = /* @__PURE__ */ V({
|
|
15
|
+
...oe,
|
|
16
|
+
__name: "TheCommandPalette",
|
|
17
|
+
props: {
|
|
18
|
+
paletteState: {},
|
|
19
|
+
workspaceStore: {},
|
|
20
|
+
eventBus: {}
|
|
21
|
+
},
|
|
22
|
+
setup(e) {
|
|
23
|
+
const T = J(), c = E(-1), b = E(null), d = f(
|
|
24
|
+
() => e.paletteState.filteredCommands.value.flatMap((t) => t.commands)
|
|
25
|
+
), m = f(
|
|
26
|
+
() => d.value[c.value]
|
|
27
|
+
);
|
|
28
|
+
K(
|
|
29
|
+
() => e.paletteState.filterQuery.value,
|
|
30
|
+
(t) => {
|
|
31
|
+
c.value = t && d.value.length > 0 ? 0 : -1;
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
const z = (t) => {
|
|
35
|
+
e.paletteState.setFilterQuery(t), t.trim().toLowerCase().startsWith("curl") && e.paletteState.open("import-curl-command", { inputValue: t });
|
|
36
|
+
}, k = (t, a) => {
|
|
37
|
+
if (!e.paletteState.isOpen.value)
|
|
38
|
+
return;
|
|
39
|
+
a.preventDefault();
|
|
40
|
+
const n = t === "up" ? -1 : 1, o = d.value.length;
|
|
41
|
+
c.value = (c.value + n + o) % o;
|
|
42
|
+
}, L = (t) => {
|
|
43
|
+
!m.value || e.paletteState.activeCommand.value || (t.preventDefault(), t.stopPropagation(), y(m.value));
|
|
44
|
+
}, y = (t) => {
|
|
45
|
+
if ("to" in t) {
|
|
46
|
+
T.push(t.to), w();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
e.paletteState.open(t.id, {});
|
|
50
|
+
}, g = () => {
|
|
51
|
+
e.paletteState.reset(), H(() => b.value?.focus());
|
|
52
|
+
}, P = () => {
|
|
53
|
+
e.paletteState.close();
|
|
54
|
+
}, w = () => {
|
|
55
|
+
e.paletteState.close(), c.value = -1;
|
|
56
|
+
}, M = f(() => ({
|
|
57
|
+
workspaceStore: e.workspaceStore,
|
|
58
|
+
eventBus: e.eventBus,
|
|
59
|
+
...e.paletteState.activeCommandProps.value
|
|
60
|
+
})), N = (t) => {
|
|
61
|
+
t ? e.paletteState.open(t.action, t.payload) : e.paletteState.open();
|
|
62
|
+
};
|
|
63
|
+
return R(() => e.eventBus.on("ui:open:command-palette", N)), X(() => e.eventBus.off("ui:open:command-palette", N)), (t, a) => (l(), v(r(U), {
|
|
64
|
+
open: e.paletteState.isOpen.value,
|
|
65
|
+
onClose: w
|
|
66
|
+
}, {
|
|
67
|
+
default: p(() => [
|
|
68
|
+
a[4] || (a[4] = u("div", { class: "commandmenu-overlay z-overlay" }, null, -1)),
|
|
69
|
+
i(r(W), { class: "commandmenu z-overlay flex flex-col" }, {
|
|
70
|
+
default: p(() => [
|
|
71
|
+
i(r($), { class: "sr-only" }, {
|
|
72
|
+
default: p(() => [...a[3] || (a[3] = [
|
|
73
|
+
I("API Client Command Menu", -1)
|
|
74
|
+
])]),
|
|
75
|
+
_: 1
|
|
76
|
+
}),
|
|
77
|
+
e.paletteState.activeCommand.value ? (l(), s("div", ae, [
|
|
78
|
+
u("button", {
|
|
79
|
+
class: "hover:bg-b-3 text-c-3 active:text-c-1 absolute z-1 mt-[0.5px] rounded p-1.5",
|
|
80
|
+
type: "button",
|
|
81
|
+
onClick: g
|
|
82
|
+
}, [
|
|
83
|
+
i(r(q), { size: "md" })
|
|
84
|
+
]),
|
|
85
|
+
e.paletteState.activeCommand.value ? (l(), v(O(e.paletteState.activeCommand.value.component), G({ key: 0 }, M.value, {
|
|
86
|
+
onBack: g,
|
|
87
|
+
onClose: P
|
|
88
|
+
}), null, 16)) : S("", !0)
|
|
89
|
+
])) : (l(), s("div", Y, [
|
|
90
|
+
u("div", Z, [
|
|
91
|
+
u("label", _, [
|
|
92
|
+
i(r(j), {
|
|
93
|
+
class: "text-c-2 mr-2.5",
|
|
94
|
+
size: "md",
|
|
95
|
+
thickness: "1.5"
|
|
96
|
+
})
|
|
97
|
+
]),
|
|
98
|
+
u("input", {
|
|
99
|
+
id: "commandmenu",
|
|
100
|
+
ref_key: "commandInputRef",
|
|
101
|
+
ref: b,
|
|
102
|
+
autocomplete: "off",
|
|
103
|
+
autofocus: "",
|
|
104
|
+
class: "w-full rounded border-none bg-none py-1.5 text-sm focus:outline-none",
|
|
105
|
+
placeholder: "Search commands...",
|
|
106
|
+
type: "text",
|
|
107
|
+
value: e.paletteState.filterQuery.value,
|
|
108
|
+
onInput: a[0] || (a[0] = (n) => z(n.target.value)),
|
|
109
|
+
onKeydown: [
|
|
110
|
+
a[1] || (a[1] = x(C((n) => k("down", n), ["stop"]), ["down"])),
|
|
111
|
+
x(C(L, ["stop"]), ["enter"]),
|
|
112
|
+
a[2] || (a[2] = x(C((n) => k("up", n), ["stop"]), ["up"]))
|
|
113
|
+
]
|
|
114
|
+
}, null, 40, ee)
|
|
115
|
+
]),
|
|
116
|
+
(l(!0), s(h, null, B(e.paletteState.filteredCommands.value, (n) => (l(), s(h, {
|
|
117
|
+
key: n.label || "100"
|
|
118
|
+
}, [
|
|
119
|
+
Q(u("div", { class: "text-c-3 mt-2 mb-1 px-2 text-xs font-medium" }, D(n.label), 513), [
|
|
120
|
+
[A, n.commands.length > 0]
|
|
121
|
+
]),
|
|
122
|
+
(l(!0), s(h, null, B(n.commands, (o) => (l(), s("button", {
|
|
123
|
+
id: o.id,
|
|
124
|
+
key: o.id,
|
|
125
|
+
class: F(["commandmenu-item hover:bg-b-2 flex w-full cursor-pointer items-center rounded px-2 py-1.5 text-left text-sm", {
|
|
126
|
+
"bg-b-2": o.id === m.value?.id
|
|
127
|
+
}]),
|
|
128
|
+
type: "button",
|
|
129
|
+
onClick: (se) => y(o)
|
|
130
|
+
}, [
|
|
131
|
+
"icon" in o ? (l(), v(O(o.icon), {
|
|
132
|
+
key: 0,
|
|
133
|
+
class: "text-c-2 mr-2.5",
|
|
134
|
+
size: "md",
|
|
135
|
+
thickness: "1.5"
|
|
136
|
+
})) : S("", !0),
|
|
137
|
+
I(" " + D(o.name), 1)
|
|
138
|
+
], 10, te))), 128))
|
|
139
|
+
], 64))), 128)),
|
|
140
|
+
e.paletteState.filteredCommands.value.flatMap((n) => n.commands).length ? S("", !0) : (l(), s("div", ne, " No commands found "))
|
|
141
|
+
]))
|
|
142
|
+
]),
|
|
143
|
+
_: 1
|
|
144
|
+
})
|
|
145
|
+
]),
|
|
146
|
+
_: 1
|
|
147
|
+
}, 8, ["open"]));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
export {
|
|
151
|
+
de as default
|
|
152
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
|
+
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
2
3
|
/**
|
|
3
4
|
* Command Palette Import Component
|
|
4
5
|
*
|
|
@@ -20,13 +21,19 @@ import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
|
20
21
|
declare const _default: import("vue").DefineComponent<{
|
|
21
22
|
/** The workspace store for adding documents */
|
|
22
23
|
workspaceStore: WorkspaceStore;
|
|
24
|
+
/** Event bus for emitting operation creation events */
|
|
25
|
+
eventBus: WorkspaceEventBus;
|
|
23
26
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
24
|
-
|
|
27
|
+
close: () => any;
|
|
28
|
+
back: (keyboardEvent: KeyboardEvent) => any;
|
|
25
29
|
}, string, import("vue").PublicProps, Readonly<{
|
|
26
30
|
/** The workspace store for adding documents */
|
|
27
31
|
workspaceStore: WorkspaceStore;
|
|
32
|
+
/** Event bus for emitting operation creation events */
|
|
33
|
+
eventBus: WorkspaceEventBus;
|
|
28
34
|
}> & Readonly<{
|
|
29
|
-
|
|
35
|
+
onClose?: (() => any) | undefined;
|
|
36
|
+
onBack?: ((keyboardEvent: KeyboardEvent) => any) | undefined;
|
|
30
37
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
38
|
export default _default;
|
|
32
39
|
//# sourceMappingURL=CommandPaletteImport.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImport.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImport.vue"],"names":[],"mappings":"AAwYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAkBvE;;;;;;;;;;;;;;;;;GAiBG;;IAMD,+CAA+C;oBAC/B,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;;;;;IAH3B,+CAA+C;oBAC/B,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;;;;;AAR7B,wBAygBC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as z, ref as
|
|
2
|
-
import { useLoadingState as Y, ScalarButton as
|
|
1
|
+
import { defineComponent as z, ref as V, computed as x, watch as J, createBlock as S, openBlock as o, unref as l, withCtx as m, createElementBlock as d, Fragment as p, createElementVNode as C, createCommentVNode as X, createVNode as g, createTextVNode as r, toDisplayString as L } from "vue";
|
|
2
|
+
import { useLoadingState as Y, ScalarButton as P, ScalarCodeBlock as G, ScalarIcon as H, ScalarTooltip as K } from "@scalar/components";
|
|
3
3
|
import { normalize as Q } from "@scalar/openapi-parser";
|
|
4
4
|
import { generateUniqueValue as Z } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
5
5
|
import { useRouter as ee } from "vue-router";
|
|
6
6
|
import { getOpenApiDocumentDetails as te } from "../helpers/get-openapi-document-details.js";
|
|
7
|
-
import { getOpenApiFromPostman as
|
|
8
|
-
import { getPostmanDocumentDetails as
|
|
9
|
-
import { isPostmanCollection as
|
|
7
|
+
import { getOpenApiFromPostman as ae } from "../helpers/get-openapi-from-postman.js";
|
|
8
|
+
import { getPostmanDocumentDetails as oe } from "../helpers/get-postman-document-details.js";
|
|
9
|
+
import { isPostmanCollection as R } from "../helpers/is-postman-collection.js";
|
|
10
10
|
import { isUrl as F } from "../../../helpers/is-url.js";
|
|
11
11
|
import { slugify as ne } from "../../../helpers/slugify.js";
|
|
12
12
|
import se from "./CommandActionForm.vue.js";
|
|
@@ -18,88 +18,94 @@ const ce = { class: "flex justify-between" }, ue = { class: "flex w-full flex-ro
|
|
|
18
18
|
}, Ie = /* @__PURE__ */ z({
|
|
19
19
|
...me,
|
|
20
20
|
props: {
|
|
21
|
-
workspaceStore: {}
|
|
21
|
+
workspaceStore: {},
|
|
22
|
+
eventBus: {}
|
|
22
23
|
},
|
|
23
|
-
emits: ["close", "back"
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
24
|
+
emits: ["close", "back"],
|
|
25
|
+
setup(f, { emit: T }) {
|
|
26
|
+
const k = T, B = 100, b = "document", E = ee(), w = Y(), a = V(""), y = V(!0), i = x(() => F(a.value)), n = x(() => R(a.value) ? oe(a.value) : te(a.value)), U = x(
|
|
26
27
|
() => n.value ? n.value.type : "json"
|
|
27
|
-
),
|
|
28
|
+
), O = x(() => !a.value.trim());
|
|
28
29
|
J(i, (e) => {
|
|
29
|
-
|
|
30
|
+
y.value = e;
|
|
30
31
|
});
|
|
31
|
-
const j = (e) => !Object.keys(
|
|
32
|
+
const j = (e) => !Object.keys(f.workspaceStore.workspace.documents).includes(e), h = async (e) => await Z({
|
|
32
33
|
defaultValue: e,
|
|
33
34
|
validation: j,
|
|
34
|
-
maxRetries:
|
|
35
|
+
maxRetries: B,
|
|
35
36
|
transformation: ne
|
|
36
37
|
}), q = (e) => typeof e.info == "object" && e.info !== null && "title" in e.info && typeof e.info.title == "string" ? e.info.title : b, A = async (e) => {
|
|
37
38
|
if (F(e)) {
|
|
38
39
|
const s = await h(b);
|
|
39
|
-
return s ? { success: await
|
|
40
|
+
return s ? { success: await f.workspaceStore.addDocument({
|
|
40
41
|
name: s,
|
|
41
42
|
url: e,
|
|
42
43
|
meta: {
|
|
43
|
-
"x-scalar-watch-mode":
|
|
44
|
+
"x-scalar-watch-mode": y.value
|
|
44
45
|
}
|
|
45
46
|
}), name: s } : (console.error("Failed to generate a unique name"), { success: !1 });
|
|
46
47
|
}
|
|
47
|
-
if (
|
|
48
|
-
const s =
|
|
49
|
-
return D ? { success: await
|
|
48
|
+
if (R(e)) {
|
|
49
|
+
const s = ae(e), v = s.info?.title ?? b, D = await h(v);
|
|
50
|
+
return D ? { success: await f.workspaceStore.addDocument({
|
|
50
51
|
name: D,
|
|
51
52
|
document: s
|
|
52
53
|
}), name: D } : (console.error("Failed to generate a unique name"), { success: !1 });
|
|
53
54
|
}
|
|
54
55
|
const t = Q(e), c = q(t), u = await h(c);
|
|
55
|
-
return u ? { success: await
|
|
56
|
+
return u ? { success: await f.workspaceStore.addDocument({
|
|
56
57
|
name: u,
|
|
57
58
|
document: t
|
|
58
59
|
}), name: u } : (console.error("Failed to generate a unique name"), { success: !1 });
|
|
59
60
|
}, I = (e) => {
|
|
60
|
-
|
|
61
|
+
E.push({
|
|
61
62
|
name: "document.overview",
|
|
62
63
|
params: { documentSlug: e }
|
|
63
64
|
});
|
|
64
|
-
}, { open:
|
|
65
|
+
}, { open: M } = ie({
|
|
65
66
|
onChange: (e) => {
|
|
66
67
|
const [t] = e ?? [];
|
|
67
68
|
if (!t)
|
|
68
69
|
return;
|
|
69
70
|
const c = async (N) => {
|
|
70
|
-
const s = N.target?.result,
|
|
71
|
-
|
|
71
|
+
const s = N.target?.result, v = await A(s);
|
|
72
|
+
v.success && I(v.name), k("close");
|
|
72
73
|
}, u = new FileReader();
|
|
73
74
|
u.onload = c, u.readAsText(t);
|
|
74
75
|
},
|
|
75
76
|
multiple: !1,
|
|
76
77
|
accept: ".json,.yaml,.yml"
|
|
77
|
-
}),
|
|
78
|
-
|
|
79
|
-
const e = await A(
|
|
80
|
-
e.success ? (await
|
|
78
|
+
}), _ = async () => {
|
|
79
|
+
w.start();
|
|
80
|
+
const e = await A(a.value);
|
|
81
|
+
e.success ? (await w.clear(), I(e.name)) : await w.invalidate(), k("close");
|
|
81
82
|
}, W = (e) => {
|
|
82
83
|
if (e.trim().toLowerCase().startsWith("curl"))
|
|
83
|
-
return
|
|
84
|
-
|
|
84
|
+
return f.eventBus.emit("ui:open:command-palette", {
|
|
85
|
+
action: "import-curl-command",
|
|
86
|
+
payload: {
|
|
87
|
+
inputValue: e
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
a.value = e;
|
|
85
91
|
}, $ = (e) => {
|
|
86
|
-
|
|
92
|
+
k("back", e);
|
|
87
93
|
};
|
|
88
|
-
return (e, t) => (
|
|
89
|
-
disabled:
|
|
90
|
-
loader: l(
|
|
91
|
-
onSubmit:
|
|
94
|
+
return (e, t) => (o(), S(se, {
|
|
95
|
+
disabled: O.value,
|
|
96
|
+
loader: l(w),
|
|
97
|
+
onSubmit: _
|
|
92
98
|
}, {
|
|
93
99
|
options: m(() => [
|
|
94
100
|
C("div", ue, [
|
|
95
|
-
|
|
101
|
+
g(l(P), {
|
|
96
102
|
class: "hover:bg-b-2 relative max-h-8 gap-1.5 p-2 text-xs",
|
|
97
103
|
variant: "outlined",
|
|
98
|
-
onClick: l(
|
|
104
|
+
onClick: l(M)
|
|
99
105
|
}, {
|
|
100
106
|
default: m(() => [
|
|
101
107
|
t[4] || (t[4] = r(" JSON, or YAML File ", -1)),
|
|
102
|
-
|
|
108
|
+
g(l(H), {
|
|
103
109
|
class: "text-c-3",
|
|
104
110
|
icon: "Upload",
|
|
105
111
|
size: "md"
|
|
@@ -107,14 +113,14 @@ const ce = { class: "flex justify-between" }, ue = { class: "flex w-full flex-ro
|
|
|
107
113
|
]),
|
|
108
114
|
_: 1
|
|
109
115
|
}, 8, ["onClick"]),
|
|
110
|
-
|
|
116
|
+
g(l(K), {
|
|
111
117
|
content: i.value ? "Watch mode automatically updates the API client when the OpenAPI URL content changes, ensuring your client remains up-to-date." : "Watch mode is only available for URL imports. When enabled it automatically updates the API client when the OpenAPI URL content changes.",
|
|
112
118
|
placement: "bottom"
|
|
113
119
|
}, {
|
|
114
120
|
default: m(() => [
|
|
115
|
-
|
|
116
|
-
modelValue:
|
|
117
|
-
"onUpdate:modelValue": t[1] || (t[1] = (c) =>
|
|
121
|
+
g(re, {
|
|
122
|
+
modelValue: y.value,
|
|
123
|
+
"onUpdate:modelValue": t[1] || (t[1] = (c) => y.value = c),
|
|
118
124
|
disabled: !i.value
|
|
119
125
|
}, null, 8, ["modelValue", "disabled"])
|
|
120
126
|
]),
|
|
@@ -124,32 +130,32 @@ const ce = { class: "flex justify-between" }, ue = { class: "flex w-full flex-ro
|
|
|
124
130
|
]),
|
|
125
131
|
submit: m(() => [
|
|
126
132
|
t[5] || (t[5] = r(" Import ", -1)),
|
|
127
|
-
i.value ? (
|
|
133
|
+
i.value ? (o(), d(p, { key: 0 }, [
|
|
128
134
|
r("from URL")
|
|
129
|
-
], 64)) : n.value && U.value ? (
|
|
130
|
-
n.value.title ? (
|
|
131
|
-
r(' "' +
|
|
132
|
-
], 64)) : (
|
|
133
|
-
r(
|
|
135
|
+
], 64)) : n.value && U.value ? (o(), d(p, { key: 1 }, [
|
|
136
|
+
n.value.title ? (o(), d(p, { key: 0 }, [
|
|
137
|
+
r(' "' + L(n.value.title) + '" ', 1)
|
|
138
|
+
], 64)) : (o(), d(p, { key: 1 }, [
|
|
139
|
+
r(L(n.value.version), 1)
|
|
134
140
|
], 64))
|
|
135
|
-
], 64)) : (
|
|
141
|
+
], 64)) : (o(), d(p, { key: 2 }, [
|
|
136
142
|
r("Collection")
|
|
137
143
|
], 64))
|
|
138
144
|
]),
|
|
139
145
|
default: m(() => [
|
|
140
|
-
!n.value || i.value ? (
|
|
146
|
+
!n.value || i.value ? (o(), S(le, {
|
|
141
147
|
key: 0,
|
|
142
|
-
modelValue:
|
|
148
|
+
modelValue: a.value,
|
|
143
149
|
placeholder: "OpenAPI/Swagger/Postman URL or cURL",
|
|
144
150
|
onDelete: $,
|
|
145
151
|
"onUpdate:modelValue": W
|
|
146
|
-
}, null, 8, ["modelValue"])) : (
|
|
152
|
+
}, null, 8, ["modelValue"])) : (o(), d(p, { key: 1 }, [
|
|
147
153
|
C("div", ce, [
|
|
148
154
|
t[3] || (t[3] = C("div", { class: "text-c-2 min-h-8 w-full py-2 pl-12 text-center text-xs" }, " Preview ", -1)),
|
|
149
|
-
|
|
155
|
+
g(l(P), {
|
|
150
156
|
class: "hover:bg-b-2 relative ml-auto max-h-8 gap-1.5 p-2 text-xs",
|
|
151
157
|
variant: "ghost",
|
|
152
|
-
onClick: t[0] || (t[0] = (c) =>
|
|
158
|
+
onClick: t[0] || (t[0] = (c) => a.value = "")
|
|
153
159
|
}, {
|
|
154
160
|
default: m(() => [...t[2] || (t[2] = [
|
|
155
161
|
r(" Clear ", -1)
|
|
@@ -157,10 +163,10 @@ const ce = { class: "flex justify-between" }, ue = { class: "flex w-full flex-ro
|
|
|
157
163
|
_: 1
|
|
158
164
|
})
|
|
159
165
|
]),
|
|
160
|
-
n.value && !i.value ? (
|
|
166
|
+
n.value && !i.value ? (o(), S(l(G), {
|
|
161
167
|
key: 0,
|
|
162
168
|
class: "bg-b-2 mt-1 max-h-[40dvh] rounded border px-2 py-1 text-sm",
|
|
163
|
-
content:
|
|
169
|
+
content: a.value,
|
|
164
170
|
copy: !1,
|
|
165
171
|
lang: U.value
|
|
166
172
|
}, null, 8, ["content", "lang"])) : X("", !0)
|
|
@@ -24,7 +24,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
24
24
|
/** Event bus for emitting operation creation events */
|
|
25
25
|
eventBus: WorkspaceEventBus;
|
|
26
26
|
/** The cURL command string to parse and import */
|
|
27
|
-
|
|
27
|
+
inputValue: string;
|
|
28
28
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
29
29
|
close: () => any;
|
|
30
30
|
back: (keyboardEvent: KeyboardEvent) => any;
|
|
@@ -34,7 +34,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
34
34
|
/** Event bus for emitting operation creation events */
|
|
35
35
|
eventBus: WorkspaceEventBus;
|
|
36
36
|
/** The cURL command string to parse and import */
|
|
37
|
-
|
|
37
|
+
inputValue: string;
|
|
38
38
|
}> & Readonly<{
|
|
39
39
|
onClose?: (() => any) | undefined;
|
|
40
40
|
onBack?: ((keyboardEvent: KeyboardEvent) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandPaletteImportCurl.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImportCurl.vue"],"names":[],"mappings":"AAuOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAUvE;;;;;;;;;;;;;;;;;GAiBG;;IAGD,iEAAiE;oBACjD,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;IAC3B,kDAAkD;
|
|
1
|
+
{"version":3,"file":"CommandPaletteImportCurl.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImportCurl.vue"],"names":[],"mappings":"AAuOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAUvE;;;;;;;;;;;;;;;;;GAiBG;;IAGD,iEAAiE;oBACjD,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;IAC3B,kDAAkD;gBACtC,MAAM;;;;;IALlB,iEAAiE;oBACjD,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;IAC3B,kDAAkD;gBACtC,MAAM;;;;;AAPpB,wBA2TC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./CommandPaletteImportCurl.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-
|
|
4
|
+
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-f4568236"]]);
|
|
5
5
|
export {
|
|
6
6
|
p as default
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as y, ref as b, computed as i, createBlock as B, openBlock as N, withCtx as
|
|
1
|
+
import { defineComponent as y, ref as b, computed as i, createBlock as B, openBlock as N, withCtx as s, createVNode as r, createElementVNode as m, unref as l, toDisplayString as d, createTextVNode as D, normalizeClass as I } from "vue";
|
|
2
2
|
import { ScalarListbox as $, ScalarButton as K, ScalarIcon as R } from "@scalar/components";
|
|
3
3
|
import { useRouter as U } from "vue-router";
|
|
4
4
|
import j from "../../../blocks/operation-code-sample/components/HttpMethod.vue.js";
|
|
@@ -12,30 +12,30 @@ const O = { class: "flex flex-1 flex-col gap-2" }, T = { class: "flex h-9 flex-r
|
|
|
12
12
|
props: {
|
|
13
13
|
workspaceStore: {},
|
|
14
14
|
eventBus: {},
|
|
15
|
-
|
|
15
|
+
inputValue: {}
|
|
16
16
|
},
|
|
17
17
|
emits: ["close", "back"],
|
|
18
18
|
setup(a, { emit: w }) {
|
|
19
|
-
const p = w, S = U(),
|
|
19
|
+
const p = w, S = U(), c = b(""), u = i(() => c.value.trim()), { path: f, method: v, operation: V } = k(a.inputValue), x = i(
|
|
20
20
|
() => Object.keys(a.workspaceStore.workspace.documents).map((t) => ({
|
|
21
21
|
id: t,
|
|
22
22
|
label: t
|
|
23
23
|
}))
|
|
24
24
|
), o = b(
|
|
25
25
|
x.value[0]
|
|
26
|
-
), h = i(() => !!(!
|
|
26
|
+
), h = i(() => !!(!u.value || !o.value || a.workspaceStore.workspace.documents[o.value.id]?.paths?.[f]?.[v])), C = () => {
|
|
27
27
|
const t = o.value;
|
|
28
28
|
if (h.value || !t)
|
|
29
29
|
return;
|
|
30
|
-
const e = k(a.
|
|
30
|
+
const e = k(a.inputValue, u.value);
|
|
31
31
|
a.eventBus.emit("operation:create:operation", {
|
|
32
32
|
documentName: t.id,
|
|
33
33
|
path: e.path,
|
|
34
34
|
method: e.method,
|
|
35
35
|
operation: e.operation,
|
|
36
|
-
exampleKey:
|
|
37
|
-
callback: (
|
|
38
|
-
if (
|
|
36
|
+
exampleKey: u.value,
|
|
37
|
+
callback: (n) => {
|
|
38
|
+
if (n) {
|
|
39
39
|
a.workspaceStore.buildSidebar(t.id);
|
|
40
40
|
const _ = e.path.startsWith("/") ? e.path : `/${e.path}`;
|
|
41
41
|
S.push({
|
|
@@ -44,36 +44,36 @@ const O = { class: "flex flex-1 flex-col gap-2" }, T = { class: "flex h-9 flex-r
|
|
|
44
44
|
documentSlug: t.id,
|
|
45
45
|
pathEncoded: encodeURIComponent(_),
|
|
46
46
|
method: e.method,
|
|
47
|
-
exampleName:
|
|
47
|
+
exampleName: u.value
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}), p("close");
|
|
53
|
-
},
|
|
53
|
+
}, g = (t) => {
|
|
54
54
|
p("back", t);
|
|
55
55
|
};
|
|
56
56
|
return (t, e) => (N(), B(z, {
|
|
57
57
|
disabled: h.value,
|
|
58
|
-
onSubmit:
|
|
58
|
+
onSubmit: C
|
|
59
59
|
}, {
|
|
60
|
-
options:
|
|
60
|
+
options: s(() => [
|
|
61
61
|
m("div", F, [
|
|
62
|
-
|
|
62
|
+
r(l($), {
|
|
63
63
|
modelValue: o.value,
|
|
64
|
-
"onUpdate:modelValue": e[1] || (e[1] = (
|
|
64
|
+
"onUpdate:modelValue": e[1] || (e[1] = (n) => o.value = n),
|
|
65
65
|
options: x.value
|
|
66
66
|
}, {
|
|
67
|
-
default:
|
|
68
|
-
|
|
67
|
+
default: s(() => [
|
|
68
|
+
r(l(K), {
|
|
69
69
|
class: "hover:bg-b-2 max-h-8 w-full justify-between gap-1 p-2 text-xs",
|
|
70
70
|
variant: "outlined"
|
|
71
71
|
}, {
|
|
72
|
-
default:
|
|
72
|
+
default: s(() => [
|
|
73
73
|
m("span", {
|
|
74
74
|
class: I(["whitespace-nowrap", o.value ? "text-c-1" : "text-c-3"])
|
|
75
75
|
}, d(o.value ? o.value.label : "Select Collection"), 3),
|
|
76
|
-
|
|
76
|
+
r(l(R), {
|
|
77
77
|
class: "text-c-3",
|
|
78
78
|
icon: "ChevronDown",
|
|
79
79
|
size: "md"
|
|
@@ -86,23 +86,23 @@ const O = { class: "flex flex-1 flex-col gap-2" }, T = { class: "flex h-9 flex-r
|
|
|
86
86
|
}, 8, ["modelValue", "options"])
|
|
87
87
|
])
|
|
88
88
|
]),
|
|
89
|
-
submit:
|
|
89
|
+
submit: s(() => [...e[2] || (e[2] = [
|
|
90
90
|
D("Import Request", -1)
|
|
91
91
|
])]),
|
|
92
|
-
default:
|
|
93
|
-
|
|
94
|
-
modelValue:
|
|
95
|
-
"onUpdate:modelValue": e[0] || (e[0] = (
|
|
92
|
+
default: s(() => [
|
|
93
|
+
r(E, {
|
|
94
|
+
modelValue: c.value,
|
|
95
|
+
"onUpdate:modelValue": e[0] || (e[0] = (n) => c.value = n),
|
|
96
96
|
placeholder: "Curl example key (e.g., example-1)",
|
|
97
|
-
onDelete:
|
|
97
|
+
onDelete: g
|
|
98
98
|
}, null, 8, ["modelValue"]),
|
|
99
99
|
m("div", O, [
|
|
100
100
|
m("div", T, [
|
|
101
|
-
|
|
101
|
+
r(j, {
|
|
102
102
|
class: "border-r-1 px-1",
|
|
103
103
|
method: l(v)
|
|
104
104
|
}, null, 8, ["method"]),
|
|
105
|
-
m("span", q, d(l(
|
|
105
|
+
m("span", q, d(l(V).servers?.[0]?.url || "") + d(l(f)), 1)
|
|
106
106
|
])
|
|
107
107
|
])
|
|
108
108
|
]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-operation-from-curl.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/helpers/get-operation-from-curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,8DAA8D,CAAA;AAIrE;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,eAAe,CAAA;CAC3B,CAAA;
|
|
1
|
+
{"version":3,"file":"get-operation-from-curl.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/helpers/get-operation-from-curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,8DAA8D,CAAA;AAIrE;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,eAAe,CAAA;CAC3B,CAAA;AAgJD;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,EAAE,mBAAmB,KAAG,mBAoCxE,CAAA"}
|