@scalar/api-client 2.19.3 → 2.20.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 +34 -0
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +0 -9
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +126 -67
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +6 -0
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js +2 -2
- package/dist/v2/blocks/operation-block/components/Header.vue2.js +25 -24
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +1 -1
- 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 +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +41 -39
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts +42 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js +31 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.d.ts +66 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.js +43 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +1 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +40 -38
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +6 -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 +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +24 -23
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts +2 -3
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue2.js +20 -20
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +5 -0
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.js +60 -54
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +53 -42
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +72 -72
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue2.js +84 -76
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js +82 -43
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +2 -3
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +12 -6
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +13 -13
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
import { isDefined as C } from "@scalar/helpers/array/is-defined";
|
|
2
|
-
import { sortByOrder as
|
|
3
|
-
import { isHttpMethod as
|
|
4
|
-
import { createSidebarState as
|
|
2
|
+
import { sortByOrder as H } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { isHttpMethod as V } from "@scalar/helpers/http/is-http-method";
|
|
4
|
+
import { createSidebarState as Y, generateReverseIndex as j } from "@scalar/sidebar";
|
|
5
5
|
import { createWorkspaceStore as D } from "@scalar/workspace-store/client";
|
|
6
|
-
import { createWorkspaceEventBus as
|
|
7
|
-
import { generateUniqueValue as
|
|
6
|
+
import { createWorkspaceEventBus as q } from "@scalar/workspace-store/events";
|
|
7
|
+
import { generateUniqueValue as z } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
8
8
|
import { getParentEntry as p } from "@scalar/workspace-store/navigation";
|
|
9
|
-
import { createWorkspaceStorePersistence as
|
|
10
|
-
import { persistencePlugin as
|
|
11
|
-
import { extensions as
|
|
12
|
-
import { shallowRef as g, computed as i, ref as u, watch as
|
|
13
|
-
import { getActiveEnvironment as
|
|
14
|
-
import { getTabDetails as
|
|
15
|
-
import { slugify as
|
|
16
|
-
import { workspaceStorage as
|
|
17
|
-
import { useCommandPaletteState as
|
|
18
|
-
import { initializeAppEventHandlers as
|
|
19
|
-
const
|
|
9
|
+
import { createWorkspaceStorePersistence as J } from "@scalar/workspace-store/persistence";
|
|
10
|
+
import { persistencePlugin as M } from "@scalar/workspace-store/plugins/client";
|
|
11
|
+
import { extensions as G } from "@scalar/workspace-store/schemas/extensions";
|
|
12
|
+
import { shallowRef as g, computed as i, ref as u, watch as Q } from "vue";
|
|
13
|
+
import { getActiveEnvironment as X } from "../../helpers/get-active-environment.js";
|
|
14
|
+
import { getTabDetails as Z } from "../../helpers/get-tab-details.js";
|
|
15
|
+
import { slugify as ee } from "../../helpers/slugify.js";
|
|
16
|
+
import { workspaceStorage as te } from "../../helpers/storage.js";
|
|
17
|
+
import { useCommandPaletteState as ae } from "../command-palette/hooks/use-command-palette-state.js";
|
|
18
|
+
import { initializeAppEventHandlers as ne } from "./app-events.js";
|
|
19
|
+
const re = 1e3, v = q({
|
|
20
20
|
debug: !1
|
|
21
|
-
}), x = u(void 0),
|
|
22
|
-
|
|
23
|
-
e && e.afterEach((t) =>
|
|
21
|
+
}), x = u(void 0), f = u(void 0), R = u(void 0), A = u(void 0), U = u(void 0), m = u(!1), c = g(null);
|
|
22
|
+
Q(c, (e) => {
|
|
23
|
+
e && e.afterEach((t) => xe(t));
|
|
24
24
|
});
|
|
25
|
-
const
|
|
25
|
+
const d = i(() => c.value?.currentRoute.value ?? null);
|
|
26
26
|
function s(e, t) {
|
|
27
27
|
const a = t?.params[e];
|
|
28
28
|
if (typeof a == "string")
|
|
29
|
-
return e === "method" ? a &&
|
|
29
|
+
return e === "method" ? a && V(a) ? a : void 0 : decodeURIComponent(a);
|
|
30
30
|
}
|
|
31
|
-
const S = g(null), y = u([]), n = g(null), E = i(() => n.value?.workspace.documents[
|
|
31
|
+
const S = g(null), y = u([]), n = g(null), E = i(() => n.value?.workspace.documents[f.value ?? ""] || null), oe = i(() => X(n.value, E.value)), { workspace: h } = await J();
|
|
32
32
|
y.value = await h.getAll().then((e) => e.map(({ id: t, name: a }) => ({ id: t, label: a })));
|
|
33
|
-
const
|
|
34
|
-
plugins: [await
|
|
35
|
-
}),
|
|
33
|
+
const se = async ({ workspaceId: e }) => D({
|
|
34
|
+
plugins: [await M({ workspaceId: e, debounceDelay: re })]
|
|
35
|
+
}), ce = async (e) => {
|
|
36
36
|
const t = await h.getItem(e);
|
|
37
37
|
if (!t)
|
|
38
38
|
return {
|
|
39
39
|
success: !1
|
|
40
40
|
};
|
|
41
|
-
const a = await
|
|
41
|
+
const a = await se({ workspaceId: e });
|
|
42
42
|
return a.loadWorkspace(t.workspace), S.value = { id: e, label: t.name }, n.value = a, {
|
|
43
43
|
success: !0,
|
|
44
44
|
workspace: a.workspace
|
|
45
45
|
};
|
|
46
|
-
},
|
|
46
|
+
}, ie = async ({ id: e, name: t }) => {
|
|
47
47
|
const a = D();
|
|
48
48
|
await a.addDocument({
|
|
49
49
|
name: "drafts",
|
|
@@ -75,35 +75,35 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
75
75
|
name: t
|
|
76
76
|
}) => {
|
|
77
77
|
n.value = null;
|
|
78
|
-
const a = await
|
|
78
|
+
const a = await z({
|
|
79
79
|
defaultValue: e ?? t,
|
|
80
80
|
// Use the provided id if it exists, otherwise use the name
|
|
81
81
|
validation: async (l) => !await h.has(l),
|
|
82
82
|
maxRetries: 100,
|
|
83
|
-
transformation:
|
|
83
|
+
transformation: ee
|
|
84
84
|
});
|
|
85
85
|
if (!a)
|
|
86
86
|
return;
|
|
87
87
|
const o = { id: a, name: t };
|
|
88
|
-
return await
|
|
89
|
-
},
|
|
90
|
-
n.value = null,
|
|
91
|
-
const t = await
|
|
88
|
+
return await ie(o), await B(a), o;
|
|
89
|
+
}, le = async (e) => {
|
|
90
|
+
n.value = null, m.value = !0;
|
|
91
|
+
const t = await ce(e);
|
|
92
92
|
if (t.success) {
|
|
93
93
|
const o = t.workspace["x-scalar-active-tab"] ?? 0, l = t.workspace["x-scalar-tabs"], W = l?.[o];
|
|
94
|
-
W && await c.value?.replace(W.path), l && o >= l.length &&
|
|
94
|
+
W && await c.value?.replace(W.path), l && o >= l.length && v.emit("tabs:update:tabs", {
|
|
95
95
|
"x-scalar-active-tab": 0
|
|
96
|
-
}), l ||
|
|
97
|
-
"x-scalar-tabs": [I(
|
|
96
|
+
}), l || v.emit("tabs:update:tabs", {
|
|
97
|
+
"x-scalar-tabs": [I(d.value)],
|
|
98
98
|
"x-scalar-active-tab": 0
|
|
99
|
-
}),
|
|
99
|
+
}), m.value = !1;
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
const a = await P({
|
|
103
103
|
name: "Default Workspace",
|
|
104
104
|
id: "default"
|
|
105
105
|
});
|
|
106
|
-
if (
|
|
106
|
+
if (m.value = !1, !a)
|
|
107
107
|
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
108
108
|
r.reset();
|
|
109
109
|
}, O = i(() => {
|
|
@@ -111,14 +111,14 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
111
111
|
if (!e)
|
|
112
112
|
return [];
|
|
113
113
|
const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
114
|
-
return
|
|
115
|
-
}), r =
|
|
114
|
+
return H(Object.keys(e.workspace.documents), t, (a) => a).map((a) => e.workspace.documents[a]?.["x-scalar-navigation"]).filter(C);
|
|
115
|
+
}), r = Y(O), b = ({
|
|
116
116
|
document: e,
|
|
117
117
|
path: t,
|
|
118
118
|
method: a,
|
|
119
119
|
example: o
|
|
120
120
|
}) => JSON.stringify([e, t, a, o].filter(C)), T = i(
|
|
121
|
-
() =>
|
|
121
|
+
() => j({
|
|
122
122
|
items: O.value,
|
|
123
123
|
nestedKey: "children",
|
|
124
124
|
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
@@ -189,14 +189,14 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
r.setExpanded(e, !r.isExpanded(e));
|
|
192
|
-
},
|
|
192
|
+
}, ue = async () => {
|
|
193
193
|
if (!n.value)
|
|
194
194
|
return;
|
|
195
195
|
const e = n.value.workspace["x-scalar-active-tab"] ?? 0, t = n.value.workspace["x-scalar-tabs"]?.[e];
|
|
196
196
|
t && await c.value?.replace(t.path);
|
|
197
197
|
}, N = (e) => {
|
|
198
198
|
e && n.value?.buildSidebar(e);
|
|
199
|
-
},
|
|
199
|
+
}, pe = (e) => {
|
|
200
200
|
const t = E.value?.["x-scalar-navigation"]?.name;
|
|
201
201
|
if (!t)
|
|
202
202
|
return;
|
|
@@ -206,20 +206,20 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
206
206
|
method: e.method,
|
|
207
207
|
example: e.exampleKey
|
|
208
208
|
});
|
|
209
|
-
(!a || a.type !== "example") && N(t);
|
|
210
|
-
},
|
|
209
|
+
(!a || a.type !== "example") && (N(t), d.value && K(d.value));
|
|
210
|
+
}, de = 288, me = i(() => n.value?.workspace?.["x-scalar-sidebar-width"] ?? de), ve = (e) => n.value?.update("x-scalar-sidebar-width", e), k = u(!0), fe = "x-scalar-tabs", he = "x-scalar-active-tab", I = (e) => {
|
|
211
211
|
const t = s("method", e), a = s("pathEncoded", e), o = s("documentSlug", e), l = s("workspaceSlug", e);
|
|
212
212
|
return {
|
|
213
|
-
...
|
|
213
|
+
...Z({
|
|
214
214
|
workspace: l,
|
|
215
215
|
document: o,
|
|
216
216
|
path: a,
|
|
217
217
|
method: t,
|
|
218
218
|
getEntryByLocation: w
|
|
219
219
|
}),
|
|
220
|
-
path:
|
|
220
|
+
path: d.value?.path ?? ""
|
|
221
221
|
};
|
|
222
|
-
}, _ = i(() => n.value?.workspace[
|
|
222
|
+
}, _ = i(() => n.value?.workspace[fe] ?? [I(d.value)]), we = i(() => n.value?.workspace[he] ?? 0), F = async (e) => {
|
|
223
223
|
const t = _.value[e];
|
|
224
224
|
if (!t) {
|
|
225
225
|
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
@@ -231,19 +231,19 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
231
231
|
} catch (o) {
|
|
232
232
|
console.error("Failed to copy URL to clipboard:", o);
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, xe = (e) => {
|
|
235
235
|
const t = s("workspaceSlug", e), a = s("documentSlug", e);
|
|
236
|
-
if (x.value = t,
|
|
237
|
-
if (e.path !== "" &&
|
|
238
|
-
return
|
|
239
|
-
if (a && a !== n.value?.workspace[
|
|
236
|
+
if (x.value = t, f.value = a, R.value = s("method", e), A.value = s("pathEncoded", e), U.value = s("exampleName", e), !!t) {
|
|
237
|
+
if (e.path !== "" && te.setCurrentPath(e.path), t !== S.value?.id)
|
|
238
|
+
return le(t);
|
|
239
|
+
if (a && a !== n.value?.workspace[G.workspace.activeDocument])
|
|
240
240
|
return n?.value?.update("x-scalar-active-document", a);
|
|
241
|
-
|
|
241
|
+
be(e), K(e);
|
|
242
242
|
}
|
|
243
|
-
},
|
|
243
|
+
}, be = (e) => {
|
|
244
244
|
const t = n.value?.workspace["x-scalar-tabs"] ?? [], a = n.value?.workspace["x-scalar-active-tab"] ?? 0, o = t[a];
|
|
245
245
|
!o || o.path === e.path || (t[a] = I(e));
|
|
246
|
-
},
|
|
246
|
+
}, K = (e) => {
|
|
247
247
|
const t = s("documentSlug", e);
|
|
248
248
|
if (!t) {
|
|
249
249
|
r.setSelected(null);
|
|
@@ -256,15 +256,15 @@ const oe = async ({ workspaceId: e }) => D({
|
|
|
256
256
|
example: s("exampleName", e)
|
|
257
257
|
});
|
|
258
258
|
a && (r.setSelected(a.id), r.setExpanded(a.id, !0));
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
eventBus:
|
|
259
|
+
}, $ = ae();
|
|
260
|
+
ne({
|
|
261
|
+
eventBus: v,
|
|
262
262
|
router: c,
|
|
263
263
|
store: n,
|
|
264
|
-
navigateToCurrentTab:
|
|
264
|
+
navigateToCurrentTab: ue,
|
|
265
265
|
rebuildSidebar: N,
|
|
266
|
-
onAfterExampleCreation:
|
|
267
|
-
onOpenCommandPalette:
|
|
266
|
+
onAfterExampleCreation: pe,
|
|
267
|
+
onOpenCommandPalette: $.open,
|
|
268
268
|
onSelectSidebarItem: L,
|
|
269
269
|
onCopyTabUrl: (e) => F(e),
|
|
270
270
|
onToggleSidebar: () => k.value = !k.value
|
|
@@ -275,15 +275,15 @@ function _e(e) {
|
|
|
275
275
|
store: n,
|
|
276
276
|
sidebar: {
|
|
277
277
|
state: r,
|
|
278
|
-
width:
|
|
278
|
+
width: me,
|
|
279
279
|
isOpen: k,
|
|
280
280
|
handleSelectItem: L,
|
|
281
|
-
handleSidebarWidthUpdate:
|
|
281
|
+
handleSidebarWidthUpdate: ve,
|
|
282
282
|
getEntryByLocation: w
|
|
283
283
|
},
|
|
284
284
|
tabs: {
|
|
285
285
|
state: _,
|
|
286
|
-
activeTabIndex:
|
|
286
|
+
activeTabIndex: we,
|
|
287
287
|
copyTabUrl: F
|
|
288
288
|
},
|
|
289
289
|
workspace: {
|
|
@@ -291,21 +291,21 @@ function _e(e) {
|
|
|
291
291
|
workspaceList: y,
|
|
292
292
|
activeWorkspace: S,
|
|
293
293
|
setId: B,
|
|
294
|
-
isOpen: i(() => !!(x.value && !
|
|
294
|
+
isOpen: i(() => !!(x.value && !f.value))
|
|
295
295
|
},
|
|
296
|
-
commandPalette:
|
|
297
|
-
eventBus:
|
|
296
|
+
commandPalette: $,
|
|
297
|
+
eventBus: v,
|
|
298
298
|
router: c,
|
|
299
|
-
currentRoute:
|
|
300
|
-
loading:
|
|
299
|
+
currentRoute: d,
|
|
300
|
+
loading: m,
|
|
301
301
|
activeEntities: {
|
|
302
302
|
workspaceSlug: x,
|
|
303
|
-
documentSlug:
|
|
303
|
+
documentSlug: f,
|
|
304
304
|
path: A,
|
|
305
305
|
method: R,
|
|
306
306
|
exampleName: U
|
|
307
307
|
},
|
|
308
|
-
environment:
|
|
308
|
+
environment: oe,
|
|
309
309
|
document: E
|
|
310
310
|
};
|
|
311
311
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"AAqdA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAUhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,KAAK,WAAW,GAAG;IACf;;OAEG;IACH,MAAM,EAAE,YAAY,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;IAE1C;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,eAAe,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C;;;OAGG;IACH,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC;;;OAGG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAA;CACtB,CAAC;AAgBJ,KAAK,WAAW,GAAG;IACjB,oEAAoE;IACpE,kBAAkB,CAAC,IAAI,OAAO,CAAA;CAC/B,CAAC;AAmLF,KAAK,iBAAiB,GAAG,WAAW,GAAG;IACvC,6CAA6C;IAC7C,eAAe,EAAE,OAAO,CAAC;IACzB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;CACtB,CAAC;AAwdF,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;kFAOnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./AppSidebar.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import p from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const e = /* @__PURE__ */ p(o, [["__scopeId", "data-v-
|
|
4
|
+
const e = /* @__PURE__ */ p(o, [["__scopeId", "data-v-e30bf25b"]]);
|
|
5
5
|
export {
|
|
6
6
|
e as default
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as q, mergeModels as
|
|
1
|
+
import { defineComponent as q, mergeModels as C, computed as f, capitalize as V, useModel as W, ref as G, createElementBlock as g, openBlock as u, createVNode as l, createBlock as B, createCommentVNode as c, unref as i, createSlots as R, withCtx as r, createTextVNode as y, createElementVNode as d, withKeys as k, withModifiers as p, toDisplayString as j, renderSlot as F, normalizeClass as H, nextTick as L } from "vue";
|
|
2
2
|
import { useModal as U, ScalarSidebarItem as I, ScalarIconButton as J, ScalarButton as $, ScalarModal as Y } from "@scalar/components";
|
|
3
3
|
import { ScalarIconPlus as Q, ScalarIconDotsThree as X, ScalarIconGlobe as Z } from "@scalar/icons";
|
|
4
4
|
import { getParentEntry as w } from "@scalar/workspace-store/navigation";
|
|
@@ -10,11 +10,14 @@ import ae from "./SidebarItemMenu.vue.js";
|
|
|
10
10
|
import { dragHandleFactory as oe } from "../../../helpers/drag-handle-factory.js";
|
|
11
11
|
import ne from "../../../components/sidebar/Sidebar.vue.js";
|
|
12
12
|
const ie = { class: "flex" }, se = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "flex items-center"
|
|
15
|
+
}, re = {
|
|
13
16
|
key: 0,
|
|
14
17
|
class: "empty-sidebar-item-content overflow-hidden px-2.5 py-2.5"
|
|
15
|
-
},
|
|
18
|
+
}, le = { class: "rabbit-ascii relative m-auto mt-2 h-[68px] w-[60px]" }, de = { class: "gap-1.5 p-2" }, ge = /* @__PURE__ */ q({
|
|
16
19
|
__name: "AppSidebar",
|
|
17
|
-
props: /* @__PURE__ */
|
|
20
|
+
props: /* @__PURE__ */ C({
|
|
18
21
|
layout: {},
|
|
19
22
|
sidebarState: {},
|
|
20
23
|
isWorkspaceOpen: { type: Boolean },
|
|
@@ -31,65 +34,65 @@ const ie = { class: "flex" }, se = {
|
|
|
31
34
|
},
|
|
32
35
|
sidebarWidthModifiers: {}
|
|
33
36
|
}),
|
|
34
|
-
emits: /* @__PURE__ */
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
37
|
+
emits: /* @__PURE__ */ C(["click:workspace", "selectItem", "select:workspace", "create:workspace"], ["update:isSidebarOpen", "update:sidebarWidth"]),
|
|
38
|
+
setup(a, { emit: O }) {
|
|
39
|
+
const v = O, A = f(() => V(a.activeWorkspace.label)), M = W(a, "isSidebarOpen"), h = W(a, "sidebarWidth"), S = f(() => a.sidebarState.items.value.length <= 1), x = f(
|
|
37
40
|
() => oe({
|
|
38
|
-
store:
|
|
39
|
-
sidebarState:
|
|
41
|
+
store: a.store,
|
|
42
|
+
sidebarState: a.sidebarState
|
|
40
43
|
})
|
|
41
|
-
), D = (
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
+
), D = (o, e) => x.value.handleDragEnd(o, e), N = (o, e) => x.value.isDroppable(o, e), s = G(null), b = U(), T = f(() => {
|
|
45
|
+
const o = s.value?.item;
|
|
46
|
+
return o?.type === "document" ? "This cannot be undone. You're about to delete the document and all tags and operations inside it." : `Are you sure you want to delete this ${o?.type ?? "item"}? This action cannot be undone.`;
|
|
44
47
|
}), z = () => {
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
48
|
+
const o = s.value?.item;
|
|
49
|
+
if (!o)
|
|
47
50
|
return;
|
|
48
|
-
const e =
|
|
51
|
+
const e = a.sidebarState.getEntryById(o.id), t = w("document", e), n = w("operation", e);
|
|
49
52
|
if (t) {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
else if (
|
|
53
|
-
|
|
53
|
+
if (o.type === "document")
|
|
54
|
+
a.eventBus.emit("document:delete:document", { name: t.name });
|
|
55
|
+
else if (o.type === "tag")
|
|
56
|
+
a.eventBus.emit("tag:delete:tag", {
|
|
54
57
|
documentName: t.name,
|
|
55
|
-
name:
|
|
58
|
+
name: o.name
|
|
56
59
|
});
|
|
57
|
-
else if (
|
|
60
|
+
else if (o.type === "operation") {
|
|
58
61
|
if (!n)
|
|
59
62
|
return;
|
|
60
|
-
|
|
63
|
+
a.eventBus.emit("operation:delete:operation", {
|
|
61
64
|
meta: {
|
|
62
65
|
method: n.method,
|
|
63
66
|
path: n.path
|
|
64
67
|
},
|
|
65
68
|
documentName: t.name
|
|
66
69
|
});
|
|
67
|
-
} else if (
|
|
70
|
+
} else if (o.type === "example") {
|
|
68
71
|
if (!n)
|
|
69
72
|
return;
|
|
70
|
-
|
|
73
|
+
a.eventBus.emit("operation:delete:example", {
|
|
71
74
|
meta: {
|
|
72
75
|
method: n.method,
|
|
73
76
|
path: n.path,
|
|
74
|
-
exampleKey:
|
|
77
|
+
exampleKey: o.name
|
|
75
78
|
},
|
|
76
79
|
documentName: t.name
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
b.hide(), s.value = null;
|
|
80
83
|
}
|
|
81
|
-
},
|
|
84
|
+
}, m = async (o, e) => {
|
|
82
85
|
if (s.value?.showMenu)
|
|
83
86
|
return;
|
|
84
|
-
const t =
|
|
87
|
+
const t = o.currentTarget;
|
|
85
88
|
s.value = { item: e, el: t, showMenu: !0 }, await L();
|
|
86
|
-
const n =
|
|
89
|
+
const n = o instanceof MouseEvent ? new MouseEvent(o.type, o) : new KeyboardEvent(o.type, o);
|
|
87
90
|
s.value?.el.dispatchEvent(n);
|
|
88
91
|
}, K = () => {
|
|
89
92
|
s.value && (s.value.showMenu = !1);
|
|
90
|
-
}, P = (
|
|
91
|
-
const e =
|
|
92
|
-
|
|
93
|
+
}, P = (o) => {
|
|
94
|
+
const e = a.sidebarState.getEntryById(o.id), t = w("document", e), n = w("tag", e);
|
|
95
|
+
a.eventBus.emit("ui:open:command-palette", {
|
|
93
96
|
action: "create-request",
|
|
94
97
|
payload: {
|
|
95
98
|
documentId: t?.id,
|
|
@@ -97,33 +100,33 @@ const ie = { class: "flex" }, se = {
|
|
|
97
100
|
}
|
|
98
101
|
});
|
|
99
102
|
};
|
|
100
|
-
return (
|
|
103
|
+
return (o, e) => (u(), g("div", ie, [
|
|
101
104
|
l(i(ne), {
|
|
102
|
-
isSidebarOpen:
|
|
103
|
-
"onUpdate:isSidebarOpen": e[3] || (e[3] = (t) =>
|
|
104
|
-
sidebarWidth:
|
|
105
|
-
"onUpdate:sidebarWidth": e[4] || (e[4] = (t) =>
|
|
106
|
-
activeWorkspace:
|
|
107
|
-
documents: Object.values(
|
|
108
|
-
eventBus:
|
|
105
|
+
isSidebarOpen: M.value,
|
|
106
|
+
"onUpdate:isSidebarOpen": e[3] || (e[3] = (t) => M.value = t),
|
|
107
|
+
sidebarWidth: h.value,
|
|
108
|
+
"onUpdate:sidebarWidth": e[4] || (e[4] = (t) => h.value = t),
|
|
109
|
+
activeWorkspace: a.activeWorkspace,
|
|
110
|
+
documents: Object.values(a.store.workspace.documents),
|
|
111
|
+
eventBus: a.eventBus,
|
|
109
112
|
isDroppable: N,
|
|
110
|
-
layout:
|
|
111
|
-
sidebarState:
|
|
112
|
-
workspaces:
|
|
113
|
-
"onCreate:workspace": e[5] || (e[5] = (t) =>
|
|
113
|
+
layout: a.layout,
|
|
114
|
+
sidebarState: a.sidebarState,
|
|
115
|
+
workspaces: a.workspaces,
|
|
116
|
+
"onCreate:workspace": e[5] || (e[5] = (t) => v("create:workspace")),
|
|
114
117
|
onReorder: e[6] || (e[6] = (t, n) => D(t, n)),
|
|
115
|
-
"onSelect:workspace": e[7] || (e[7] = (t) =>
|
|
116
|
-
onSelectItem: e[8] || (e[8] = (t) =>
|
|
118
|
+
"onSelect:workspace": e[7] || (e[7] = (t) => v("select:workspace", t)),
|
|
119
|
+
onSelectItem: e[8] || (e[8] = (t) => v("selectItem", t))
|
|
117
120
|
}, R({
|
|
118
121
|
sidebarMenuActions: r(() => [
|
|
119
|
-
F(
|
|
122
|
+
F(o.$slots, "sidebarMenuActions", {}, void 0, !0)
|
|
120
123
|
]),
|
|
121
124
|
workspaceButton: r(() => [
|
|
122
125
|
l(i(I), {
|
|
123
126
|
is: "button",
|
|
124
|
-
active:
|
|
127
|
+
active: a.isWorkspaceOpen,
|
|
125
128
|
icon: i(Z),
|
|
126
|
-
onClick: e[0] || (e[0] = (t) =>
|
|
129
|
+
onClick: e[0] || (e[0] = (t) => v("click:workspace"))
|
|
127
130
|
}, {
|
|
128
131
|
default: r(() => [
|
|
129
132
|
y(j(A.value), 1)
|
|
@@ -139,15 +142,20 @@ const ie = { class: "flex" }, se = {
|
|
|
139
142
|
label: "More options",
|
|
140
143
|
size: "sm",
|
|
141
144
|
weight: "bold",
|
|
142
|
-
onClick:
|
|
145
|
+
onClick: p((n) => m(n, t), ["stop"]),
|
|
143
146
|
onKeydown: [
|
|
144
|
-
k(
|
|
145
|
-
k(
|
|
146
|
-
k(
|
|
147
|
-
k(
|
|
147
|
+
k(p((n) => m(n, t), ["stop"]), ["down"]),
|
|
148
|
+
k(p((n) => m(n, t), ["stop"]), ["enter"]),
|
|
149
|
+
k(p((n) => m(n, t), ["stop"]), ["space"]),
|
|
150
|
+
k(p((n) => m(n, t), ["stop"]), ["up"])
|
|
148
151
|
]
|
|
149
152
|
}, null, 8, ["icon", "onClick", "onKeydown"])
|
|
150
153
|
]),
|
|
154
|
+
icon: r(({ item: t }) => [
|
|
155
|
+
t.type === "document" && a.store.workspace.documents[t.name]?.["x-scalar-is-dirty"] === !0 ? (u(), g("div", se, [...e[11] || (e[11] = [
|
|
156
|
+
d("div", { class: "h-2 w-2 rounded-full bg-white" }, null, -1)
|
|
157
|
+
])])) : c("", !0)
|
|
158
|
+
]),
|
|
151
159
|
empty: r(({ item: t }) => [
|
|
152
160
|
l(i(I), {
|
|
153
161
|
is: "button",
|
|
@@ -156,7 +164,7 @@ const ie = { class: "flex" }, se = {
|
|
|
156
164
|
icon: r(() => [
|
|
157
165
|
l(i(Q))
|
|
158
166
|
]),
|
|
159
|
-
default: r(() => [...e[
|
|
167
|
+
default: r(() => [...e[12] || (e[12] = [
|
|
160
168
|
y("Add operation", -1)
|
|
161
169
|
])]),
|
|
162
170
|
_: 1
|
|
@@ -164,7 +172,7 @@ const ie = { class: "flex" }, se = {
|
|
|
164
172
|
]),
|
|
165
173
|
_: 2
|
|
166
174
|
}, [
|
|
167
|
-
|
|
175
|
+
a.layout !== "modal" ? {
|
|
168
176
|
name: "footer",
|
|
169
177
|
fn: r(() => [
|
|
170
178
|
d("div", {
|
|
@@ -172,8 +180,8 @@ const ie = { class: "flex" }, se = {
|
|
|
172
180
|
"empty-sidebar-item border-t": S.value
|
|
173
181
|
})
|
|
174
182
|
}, [
|
|
175
|
-
S.value ? (
|
|
176
|
-
d("div",
|
|
183
|
+
S.value ? (u(), g("div", re, [
|
|
184
|
+
d("div", le, [
|
|
177
185
|
l(E, {
|
|
178
186
|
art: i(_),
|
|
179
187
|
class: "rabbitsit font-bold"
|
|
@@ -183,34 +191,34 @@ const ie = { class: "flex" }, se = {
|
|
|
183
191
|
class: "rabbitjump absolute top-0 left-0 font-bold"
|
|
184
192
|
}, null, 8, ["art"])
|
|
185
193
|
]),
|
|
186
|
-
e[
|
|
194
|
+
e[13] || (e[13] = d("div", { class: "mt-2 mb-2 text-center text-sm text-balance" }, [
|
|
187
195
|
d("b", { class: "font-medium" }, "Let's Get Started"),
|
|
188
196
|
d("p", { class: "mt-2 leading-3" }, " Create request, folder, collection or import from OpenAPI/Postman ")
|
|
189
197
|
], -1))
|
|
190
|
-
])) :
|
|
191
|
-
d("div",
|
|
192
|
-
S.value ? (
|
|
198
|
+
])) : c("", !0),
|
|
199
|
+
d("div", de, [
|
|
200
|
+
S.value ? (u(), B(i($), {
|
|
193
201
|
key: 0,
|
|
194
202
|
class: "w-full",
|
|
195
203
|
size: "sm",
|
|
196
|
-
onClick: e[1] || (e[1] = (t) =>
|
|
204
|
+
onClick: e[1] || (e[1] = (t) => a.eventBus.emit("ui:open:command-palette", {
|
|
197
205
|
action: "import-from-openapi-swagger-postman-curl",
|
|
198
206
|
payload: void 0
|
|
199
207
|
}))
|
|
200
208
|
}, {
|
|
201
|
-
default: r(() => [...e[
|
|
209
|
+
default: r(() => [...e[14] || (e[14] = [
|
|
202
210
|
y(" Import Collection ", -1)
|
|
203
211
|
])]),
|
|
204
212
|
_: 1
|
|
205
|
-
})) :
|
|
213
|
+
})) : c("", !0),
|
|
206
214
|
l(i($), {
|
|
207
215
|
class: "w-full",
|
|
208
216
|
hotkey: "K",
|
|
209
217
|
size: "sm",
|
|
210
218
|
variant: "outlined",
|
|
211
|
-
onClick: e[2] || (e[2] = (t) =>
|
|
219
|
+
onClick: e[2] || (e[2] = (t) => a.eventBus.emit("ui:open:command-palette"))
|
|
212
220
|
}, {
|
|
213
|
-
default: r(() => [...e[
|
|
221
|
+
default: r(() => [...e[15] || (e[15] = [
|
|
214
222
|
y(" Add Item ", -1)
|
|
215
223
|
])]),
|
|
216
224
|
_: 1
|
|
@@ -221,34 +229,34 @@ const ie = { class: "flex" }, se = {
|
|
|
221
229
|
key: "0"
|
|
222
230
|
} : void 0
|
|
223
231
|
]), 1032, ["isSidebarOpen", "sidebarWidth", "activeWorkspace", "documents", "eventBus", "layout", "sidebarState", "workspaces"]),
|
|
224
|
-
s.value?.showMenu ? (
|
|
232
|
+
s.value?.showMenu ? (u(), B(ae, {
|
|
225
233
|
key: 0,
|
|
226
|
-
eventBus:
|
|
234
|
+
eventBus: a.eventBus,
|
|
227
235
|
item: s.value.item,
|
|
228
|
-
sidebarState:
|
|
236
|
+
sidebarState: a.sidebarState,
|
|
229
237
|
target: s.value.el,
|
|
230
238
|
onCloseMenu: K,
|
|
231
|
-
onShowDeleteModal: e[9] || (e[9] = (t) => i(
|
|
232
|
-
}, null, 8, ["eventBus", "item", "sidebarState", "target"])) :
|
|
233
|
-
s.value ? (
|
|
239
|
+
onShowDeleteModal: e[9] || (e[9] = (t) => i(b).show())
|
|
240
|
+
}, null, 8, ["eventBus", "item", "sidebarState", "target"])) : c("", !0),
|
|
241
|
+
s.value ? (u(), B(i(Y), {
|
|
234
242
|
key: 1,
|
|
235
243
|
size: "xxs",
|
|
236
|
-
state: i(
|
|
244
|
+
state: i(b),
|
|
237
245
|
title: `Delete ${s.value.item.title}`
|
|
238
246
|
}, {
|
|
239
247
|
default: r(() => [
|
|
240
248
|
l(te, {
|
|
241
249
|
variableName: s.value.item.title,
|
|
242
250
|
warningMessage: T.value,
|
|
243
|
-
onClose: e[10] || (e[10] = (t) => i(
|
|
251
|
+
onClose: e[10] || (e[10] = (t) => i(b).hide()),
|
|
244
252
|
onDelete: z
|
|
245
253
|
}, null, 8, ["variableName", "warningMessage"])
|
|
246
254
|
]),
|
|
247
255
|
_: 1
|
|
248
|
-
}, 8, ["state", "title"])) :
|
|
256
|
+
}, 8, ["state", "title"])) : c("", !0)
|
|
249
257
|
]));
|
|
250
258
|
}
|
|
251
259
|
});
|
|
252
260
|
export {
|
|
253
|
-
|
|
261
|
+
ge as default
|
|
254
262
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentCollection.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/collection/DocumentCollection.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentCollection.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/collection/DocumentCollection.vue"],"names":[],"mappings":"AAiJA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAMlE;;;;;;;GAOG;;AACH,wBAmVC"}
|