@scalar/api-client 2.25.0 → 2.26.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 +39 -0
- package/dist/components/DataTable/DataTableCheckbox.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableCheckbox.vue.js +8 -8
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js +28 -19
- 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 +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js +18 -18
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.js +2 -2
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue2.js +19 -19
- 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/AuthSelector.vue.js +26 -26
- package/dist/v2/components/callout/Callout.vue.d.ts +17 -0
- package/dist/v2/components/callout/Callout.vue.d.ts.map +1 -0
- package/dist/v2/components/callout/Callout.vue.js +7 -0
- package/dist/v2/components/callout/Callout.vue2.js +43 -0
- package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableCheckbox.vue.js +8 -8
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.js +40 -41
- package/dist/v2/features/app/App.vue.d.ts +2 -2
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +84 -89
- package/dist/v2/features/app/app-events.d.ts +1 -1
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +10 -10
- package/dist/v2/features/app/app-state.d.ts +36 -87
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +339 -330
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/DesktopTabs.vue.js +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts +2 -2
- 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 +9 -9
- package/dist/v2/features/app/helpers/get-route-param.d.ts +7 -0
- package/dist/v2/features/app/helpers/get-route-param.d.ts.map +1 -0
- package/dist/v2/features/app/helpers/get-route-param.js +9 -0
- package/dist/v2/features/app/index.d.ts +1 -1
- package/dist/v2/features/app/index.d.ts.map +1 -1
- package/dist/v2/features/app/index.js +12 -12
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js +72 -65
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +29 -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 +110 -106
- package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts +5 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.js +41 -23
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +41 -8
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -1
- package/dist/v2/features/command-palette/index.d.ts +1 -2
- package/dist/v2/features/command-palette/index.d.ts.map +1 -1
- package/dist/v2/features/command-palette/index.js +4 -6
- package/dist/v2/features/operation/Operation.vue.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue2.js +24 -23
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +9 -9
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts +0 -41
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +0 -1
- package/dist/v2/features/app/components/WebTopNav.vue.js +0 -27
- package/dist/v2/features/app/components/WebTopNav.vue2.js +0 -4
|
@@ -1,363 +1,372 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { sortByOrder as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { generateUniqueValue as X } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
1
|
+
import { isDefined as Y } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { sortByOrder as pe } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { createSidebarState as ue, generateReverseIndex as me } from "@scalar/sidebar";
|
|
4
|
+
import { createWorkspaceStore as j } from "@scalar/workspace-store/client";
|
|
5
|
+
import { createWorkspaceEventBus as de } from "@scalar/workspace-store/events";
|
|
6
|
+
import { generateUniqueValue as ve } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
8
7
|
import { getParentEntry as v } from "@scalar/workspace-store/navigation";
|
|
9
|
-
import { createWorkspaceStorePersistence as
|
|
10
|
-
import { persistencePlugin as
|
|
11
|
-
import { extensions as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
const d = i(() => u.value?.currentRoute.value ?? null);
|
|
26
|
-
function l(e, a) {
|
|
27
|
-
const t = a?.params[e];
|
|
28
|
-
if (typeof t == "string")
|
|
29
|
-
return e === "method" ? t && J(t) ? t : void 0 : decodeURIComponent(t);
|
|
30
|
-
}
|
|
31
|
-
const A = D(null), f = p([]), U = i(() => le(f.value, R.value)), o = D(null), C = i(() => o.value?.workspace.documents[b.value ?? ""] || null), pe = i(() => ne(o.value, C.value)), { workspace: y } = await Z(), h = (e, a) => `${e}/${a}`;
|
|
32
|
-
f.value = await y.getAll().then(
|
|
33
|
-
(e) => e.map(({ teamUid: a, namespace: t, slug: n, name: c }) => ({
|
|
34
|
-
id: h(t, n),
|
|
35
|
-
teamUid: a,
|
|
36
|
-
namespace: t,
|
|
37
|
-
slug: n,
|
|
38
|
-
label: c
|
|
39
|
-
}))
|
|
40
|
-
);
|
|
41
|
-
const me = async ({ namespace: e, slug: a }) => N({
|
|
42
|
-
plugins: [
|
|
43
|
-
await ee({ workspaceId: h(e, a), debounceDelay: ie })
|
|
44
|
-
]
|
|
45
|
-
}), de = async (e, a) => {
|
|
46
|
-
const t = await y.getItem({ namespace: e, slug: a });
|
|
47
|
-
if (!t)
|
|
48
|
-
return {
|
|
49
|
-
success: !1
|
|
50
|
-
};
|
|
51
|
-
const n = await me({ namespace: e, slug: a });
|
|
52
|
-
return n.loadWorkspace(t.workspace), A.value = { id: h(t.namespace, t.slug), label: t.name }, o.value = n, {
|
|
53
|
-
success: !0,
|
|
54
|
-
workspace: n.workspace
|
|
55
|
-
};
|
|
56
|
-
}, ve = async ({
|
|
57
|
-
name: e,
|
|
58
|
-
teamUid: a,
|
|
59
|
-
namespace: t,
|
|
60
|
-
slug: n
|
|
8
|
+
import { createWorkspaceStorePersistence as fe } from "@scalar/workspace-store/persistence";
|
|
9
|
+
import { persistencePlugin as he } from "@scalar/workspace-store/plugins/client";
|
|
10
|
+
import { extensions as we } from "@scalar/workspace-store/schemas/extensions";
|
|
11
|
+
import { ref as u, computed as p, shallowRef as H } from "vue";
|
|
12
|
+
import { getRouteParam as l } from "./helpers/get-route-param.js";
|
|
13
|
+
import { groupWorkspacesByTeam as ke } from "./helpers/group-workspaces.js";
|
|
14
|
+
import { getActiveEnvironment as ge } from "../../helpers/get-active-environment.js";
|
|
15
|
+
import { getTabDetails as xe } from "../../helpers/get-tab-details.js";
|
|
16
|
+
import { slugify as be } from "../../helpers/slugify.js";
|
|
17
|
+
import { workspaceStorage as ye } from "../../helpers/storage.js";
|
|
18
|
+
import { initializeAppEventHandlers as Se } from "./app-events.js";
|
|
19
|
+
import { filterWorkspacesByTeam as Ee, canLoadWorkspace as We } from "./helpers/filter-workspaces.js";
|
|
20
|
+
const Ue = 1e3, Te = 288, h = (i, T) => `${i}/${T}`, He = async ({
|
|
21
|
+
router: i,
|
|
22
|
+
fileLoader: T
|
|
61
23
|
}) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
paths: {
|
|
72
|
-
"/": {
|
|
73
|
-
get: {}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"x-scalar-original-document-hash": "drafts",
|
|
77
|
-
"x-scalar-icon": "interface-edit-tool-pencil"
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const s = await y.setItem(
|
|
81
|
-
{ namespace: t, slug: n },
|
|
82
|
-
{
|
|
83
|
-
name: e,
|
|
24
|
+
const w = de({
|
|
25
|
+
debug: !1
|
|
26
|
+
}), { workspace: k } = await fe(), g = u("local"), x = u(void 0), I = u(void 0), b = u(void 0), L = u(void 0), O = u(void 0), N = u(void 0), y = u(!1);
|
|
27
|
+
i.afterEach((e) => ce(e));
|
|
28
|
+
const d = p(() => i.currentRoute.value ?? null), D = H(null), f = u([]), S = p(() => Ee(f.value, g.value)), z = p(() => ke(S.value, g.value)), s = H(null), A = p(() => s.value?.workspace.documents[b.value ?? ""] || null), G = p(() => ge(s.value, A.value));
|
|
29
|
+
f.value = await k.getAll().then(
|
|
30
|
+
(e) => e.map(({ teamUid: a, namespace: t, slug: n, name: c }) => ({
|
|
31
|
+
id: h(t, n),
|
|
84
32
|
teamUid: a,
|
|
85
|
-
|
|
86
|
-
|
|
33
|
+
namespace: t,
|
|
34
|
+
slug: n,
|
|
35
|
+
label: c
|
|
36
|
+
}))
|
|
87
37
|
);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
38
|
+
const J = async ({
|
|
39
|
+
namespace: e,
|
|
40
|
+
slug: a
|
|
41
|
+
}) => j({
|
|
42
|
+
plugins: [
|
|
43
|
+
await he({
|
|
44
|
+
workspaceId: h(e, a),
|
|
45
|
+
debounceDelay: Ue
|
|
46
|
+
})
|
|
47
|
+
],
|
|
48
|
+
fileLoader: T
|
|
49
|
+
}), Q = async (e, a) => {
|
|
50
|
+
const t = await k.getItem({ namespace: e, slug: a });
|
|
51
|
+
if (!t)
|
|
52
|
+
return {
|
|
53
|
+
success: !1
|
|
54
|
+
};
|
|
55
|
+
const n = await J({ namespace: e, slug: a });
|
|
56
|
+
return n.loadWorkspace(t.workspace), D.value = { id: h(t.namespace, t.slug), label: t.name }, s.value = n, {
|
|
57
|
+
success: !0,
|
|
58
|
+
workspace: n.workspace
|
|
59
|
+
};
|
|
60
|
+
}, X = async ({
|
|
61
|
+
name: e,
|
|
62
|
+
teamUid: a,
|
|
63
|
+
namespace: t,
|
|
64
|
+
slug: n
|
|
65
|
+
}) => {
|
|
66
|
+
const c = j();
|
|
67
|
+
await c.addDocument({
|
|
68
|
+
name: "drafts",
|
|
69
|
+
document: {
|
|
70
|
+
openapi: "3.1.0",
|
|
71
|
+
info: {
|
|
72
|
+
title: "Drafts",
|
|
73
|
+
version: "1.0.0"
|
|
74
|
+
},
|
|
75
|
+
paths: {
|
|
76
|
+
"/": {
|
|
77
|
+
get: {}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"x-scalar-original-document-hash": "drafts",
|
|
81
|
+
"x-scalar-icon": "interface-edit-tool-pencil"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const r = await k.setItem(
|
|
85
|
+
{ namespace: t, slug: n },
|
|
86
|
+
{
|
|
87
|
+
name: e,
|
|
88
|
+
teamUid: a,
|
|
89
|
+
workspace: c.exportWorkspace()
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
return f.value.push({
|
|
93
|
+
id: h(r.namespace, r.slug),
|
|
94
|
+
teamUid: r.teamUid,
|
|
95
|
+
namespace: r.namespace,
|
|
96
|
+
slug: r.slug,
|
|
97
|
+
label: r.name
|
|
98
|
+
}), r;
|
|
99
|
+
}, E = async (e, a) => {
|
|
100
|
+
await i.push({
|
|
101
|
+
name: "workspace.environment",
|
|
102
|
+
params: { namespace: e, workspaceSlug: a }
|
|
103
|
+
});
|
|
104
|
+
}, _ = async ({
|
|
117
105
|
teamUid: e,
|
|
118
106
|
namespace: a,
|
|
119
|
-
slug:
|
|
107
|
+
slug: t,
|
|
120
108
|
name: n
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
154
|
-
return z(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(O);
|
|
155
|
-
}), r = M(K), I = ({
|
|
156
|
-
document: e,
|
|
157
|
-
path: a,
|
|
158
|
-
method: t,
|
|
159
|
-
example: n
|
|
160
|
-
}) => JSON.stringify([e, a, t, n].filter(O)), L = i(
|
|
161
|
-
() => G({
|
|
162
|
-
items: K.value,
|
|
163
|
-
nestedKey: "children",
|
|
164
|
-
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
165
|
-
getId: (e) => {
|
|
166
|
-
const a = v("document", e), t = v("operation", e);
|
|
167
|
-
return I({
|
|
168
|
-
document: a?.name ?? "",
|
|
169
|
-
path: t?.path,
|
|
170
|
-
method: t?.method,
|
|
171
|
-
example: e.type === "example" ? e.name : void 0
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
), E = (e) => {
|
|
176
|
-
const a = L.value.get(I(e));
|
|
177
|
-
return a || L.value.get(
|
|
178
|
-
I({
|
|
179
|
-
document: e.document,
|
|
180
|
-
path: e.path,
|
|
181
|
-
method: e.method
|
|
182
|
-
})
|
|
183
|
-
);
|
|
184
|
-
}, V = (e) => {
|
|
185
|
-
const a = r.getEntryById(e);
|
|
186
|
-
if (!a) {
|
|
187
|
-
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (a.type === "document") {
|
|
191
|
-
if (r.selectedItem.value === e) {
|
|
192
|
-
r.setExpanded(e, !r.isExpanded(e));
|
|
109
|
+
}) => {
|
|
110
|
+
s.value = null;
|
|
111
|
+
const c = await ve({
|
|
112
|
+
defaultValue: t ?? n,
|
|
113
|
+
// Use the provided id if it exists, otherwise use the name
|
|
114
|
+
validation: async (U) => !await k.has({ namespace: a ?? "local", slug: U }),
|
|
115
|
+
maxRetries: 100,
|
|
116
|
+
transformation: be
|
|
117
|
+
});
|
|
118
|
+
if (!c)
|
|
119
|
+
return;
|
|
120
|
+
const m = await X({
|
|
121
|
+
teamUid: e,
|
|
122
|
+
namespace: a,
|
|
123
|
+
slug: c,
|
|
124
|
+
name: n
|
|
125
|
+
});
|
|
126
|
+
return await E(m.namespace, m.slug), m;
|
|
127
|
+
}, Z = async (e, a) => {
|
|
128
|
+
s.value = null, y.value = !0;
|
|
129
|
+
const t = await Q(e, a);
|
|
130
|
+
if (t.success) {
|
|
131
|
+
const r = t.workspace["x-scalar-active-tab"] ?? 0, m = t.workspace["x-scalar-tabs"], U = m?.[r];
|
|
132
|
+
U && await i.replace({
|
|
133
|
+
path: U.path,
|
|
134
|
+
query: d.value?.query ?? {}
|
|
135
|
+
}), m && r >= m.length && w.emit("tabs:update:tabs", {
|
|
136
|
+
"x-scalar-active-tab": 0
|
|
137
|
+
}), m || w.emit("tabs:update:tabs", {
|
|
138
|
+
"x-scalar-tabs": [B(d.value)],
|
|
139
|
+
"x-scalar-active-tab": 0
|
|
140
|
+
}), y.value = !1;
|
|
193
141
|
return;
|
|
194
142
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
143
|
+
const n = S.value.find((r) => r.teamUid === "local" && r.slug === "default") ?? S.value[0];
|
|
144
|
+
if (n)
|
|
145
|
+
return E(n.namespace, n.slug);
|
|
146
|
+
const c = await _({
|
|
147
|
+
name: "Default Workspace",
|
|
148
|
+
slug: "default"
|
|
198
149
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
150
|
+
if (y.value = !1, !c)
|
|
151
|
+
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
152
|
+
o.reset();
|
|
153
|
+
}, P = p(() => {
|
|
154
|
+
const e = s.value;
|
|
155
|
+
if (!e)
|
|
156
|
+
return [];
|
|
157
|
+
const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
158
|
+
return pe(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(Y);
|
|
159
|
+
}), o = ue(P), R = ({
|
|
160
|
+
document: e,
|
|
161
|
+
path: a,
|
|
162
|
+
method: t,
|
|
163
|
+
example: n
|
|
164
|
+
}) => JSON.stringify([e, a, t, n].filter(Y)), $ = p(
|
|
165
|
+
() => me({
|
|
166
|
+
items: P.value,
|
|
167
|
+
nestedKey: "children",
|
|
168
|
+
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
169
|
+
getId: (e) => {
|
|
170
|
+
const a = v("document", e), t = v("operation", e);
|
|
171
|
+
return R({
|
|
172
|
+
document: a?.name ?? "",
|
|
173
|
+
path: t?.path,
|
|
174
|
+
method: t?.method,
|
|
175
|
+
example: e.type === "example" ? e.name : void 0
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
), W = (e) => {
|
|
180
|
+
const a = $.value.get(R(e));
|
|
181
|
+
return a || $.value.get(
|
|
182
|
+
R({
|
|
183
|
+
document: e.document,
|
|
184
|
+
path: e.path,
|
|
185
|
+
method: e.method
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
}, F = (e) => {
|
|
189
|
+
const a = o.getEntryById(e);
|
|
190
|
+
if (!a) {
|
|
191
|
+
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
203
192
|
return;
|
|
204
193
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
documentSlug: v("document", a)?.name,
|
|
210
|
-
pathEncoded: encodeURIComponent(a.path),
|
|
211
|
-
method: a.method,
|
|
212
|
-
exampleName: t?.name ?? "default"
|
|
194
|
+
if (a.type === "document") {
|
|
195
|
+
if (o.selectedItem.value === e) {
|
|
196
|
+
o.setExpanded(e, !o.isExpanded(e));
|
|
197
|
+
return;
|
|
213
198
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
pathEncoded: encodeURIComponent(t?.path ?? ""),
|
|
224
|
-
method: t?.method,
|
|
225
|
-
exampleName: a.name
|
|
199
|
+
return o.setSelected(e), o.setExpanded(e, !0), i.push({
|
|
200
|
+
name: "document.overview",
|
|
201
|
+
params: { documentSlug: a.name }
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (a.type === "operation") {
|
|
205
|
+
if (o.isSelected(e)) {
|
|
206
|
+
o.setExpanded(e, !o.isExpanded(e));
|
|
207
|
+
return;
|
|
226
208
|
}
|
|
209
|
+
const t = a.children?.find((n) => n.type === "example");
|
|
210
|
+
return t ? (o.setSelected(t.id), o.setExpanded(t.id, !0)) : o.setSelected(e), i.push({
|
|
211
|
+
name: "example",
|
|
212
|
+
params: {
|
|
213
|
+
documentSlug: v("document", a)?.name,
|
|
214
|
+
pathEncoded: encodeURIComponent(a.path),
|
|
215
|
+
method: a.method,
|
|
216
|
+
exampleName: t?.name ?? "default"
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (a.type === "example") {
|
|
221
|
+
o.setSelected(e);
|
|
222
|
+
const t = v("operation", a);
|
|
223
|
+
return i.push({
|
|
224
|
+
name: "example",
|
|
225
|
+
params: {
|
|
226
|
+
documentSlug: v("document", a)?.name,
|
|
227
|
+
pathEncoded: encodeURIComponent(t?.path ?? ""),
|
|
228
|
+
method: t?.method,
|
|
229
|
+
exampleName: a.name
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (a.type === "text")
|
|
234
|
+
return i.push({
|
|
235
|
+
name: "document.overview",
|
|
236
|
+
params: {
|
|
237
|
+
documentSlug: v("document", a)?.name
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
o.setExpanded(e, !o.isExpanded(e));
|
|
241
|
+
}, ee = async () => {
|
|
242
|
+
if (!s.value)
|
|
243
|
+
return;
|
|
244
|
+
const e = s.value.workspace["x-scalar-active-tab"] ?? 0, a = s.value.workspace["x-scalar-tabs"]?.[e];
|
|
245
|
+
a && await i.replace(a.path);
|
|
246
|
+
}, K = (e) => {
|
|
247
|
+
e && s.value?.buildSidebar(e);
|
|
248
|
+
}, ae = (e) => {
|
|
249
|
+
const a = A.value?.["x-scalar-navigation"]?.name;
|
|
250
|
+
if (!a)
|
|
251
|
+
return;
|
|
252
|
+
const t = W({
|
|
253
|
+
document: a,
|
|
254
|
+
path: e.path,
|
|
255
|
+
method: e.method,
|
|
256
|
+
example: e.exampleKey
|
|
227
257
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
258
|
+
(!t || t.type !== "example") && (K(a), d.value && M(d.value));
|
|
259
|
+
}, te = p(() => s.value?.workspace?.["x-scalar-sidebar-width"] ?? Te), ne = (e) => s.value?.update("x-scalar-sidebar-width", e), C = u(!0), se = "x-scalar-tabs", oe = "x-scalar-active-tab", B = (e) => {
|
|
260
|
+
const a = l("method", e), t = l("pathEncoded", e), n = l("documentSlug", e), c = l("workspaceSlug", e);
|
|
261
|
+
return {
|
|
262
|
+
...xe({
|
|
263
|
+
workspace: c,
|
|
264
|
+
document: n,
|
|
265
|
+
path: t,
|
|
266
|
+
method: a,
|
|
267
|
+
getEntryByLocation: W
|
|
268
|
+
}),
|
|
269
|
+
path: d.value?.path ?? ""
|
|
270
|
+
};
|
|
271
|
+
}, V = p(() => s.value?.workspace[se] ?? [B(d.value)]), re = p(() => s.value?.workspace[oe] ?? 0), q = async (e) => {
|
|
272
|
+
const a = V.value[e];
|
|
273
|
+
if (!a) {
|
|
274
|
+
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const t = `${window.location.origin}${a.path}`;
|
|
278
|
+
try {
|
|
279
|
+
await navigator.clipboard.writeText(t);
|
|
280
|
+
} catch (n) {
|
|
281
|
+
console.error("Failed to copy URL to clipboard:", n);
|
|
282
|
+
}
|
|
283
|
+
}, ce = (e) => {
|
|
284
|
+
const a = l("workspaceSlug", e), t = l("documentSlug", e), n = l("namespace", e);
|
|
285
|
+
if (!n || !a)
|
|
286
|
+
return;
|
|
287
|
+
const c = f.value.find(
|
|
288
|
+
(r) => r.slug === a && r.namespace === n
|
|
289
|
+
);
|
|
290
|
+
if (c && !We(c.teamUid, g.value))
|
|
291
|
+
return E("local", "default");
|
|
292
|
+
if (x.value = n, I.value = a, b.value = t, L.value = l("method", e), O.value = l("pathEncoded", e), N.value = l("exampleName", e), e.path !== "" && ye.setCurrentPath(e.path), h(x.value, a) !== D.value?.id)
|
|
293
|
+
return Z(x.value, a);
|
|
294
|
+
t && t !== s.value?.workspace[we.workspace.activeDocument] && s?.value?.update("x-scalar-active-document", t), le(e), M(e);
|
|
295
|
+
}, le = (e) => {
|
|
296
|
+
const a = s.value?.workspace["x-scalar-tabs"] ?? [], t = s.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
|
|
297
|
+
!n || n.path === e.path || (a[t] = B(e));
|
|
298
|
+
}, M = (e) => {
|
|
299
|
+
const a = l("documentSlug", e);
|
|
300
|
+
if (!a) {
|
|
301
|
+
o.setSelected(null);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const t = W({
|
|
305
|
+
document: a,
|
|
306
|
+
path: l("pathEncoded", e),
|
|
307
|
+
method: l("method", e),
|
|
308
|
+
example: l("exampleName", e)
|
|
235
309
|
});
|
|
236
|
-
|
|
237
|
-
}, he = async () => {
|
|
238
|
-
if (!o.value)
|
|
239
|
-
return;
|
|
240
|
-
const e = o.value.workspace["x-scalar-active-tab"] ?? 0, a = o.value.workspace["x-scalar-tabs"]?.[e];
|
|
241
|
-
a && await u.value?.replace(a.path);
|
|
242
|
-
}, q = (e) => {
|
|
243
|
-
e && o.value?.buildSidebar(e);
|
|
244
|
-
}, we = (e) => {
|
|
245
|
-
const a = C.value?.["x-scalar-navigation"]?.name;
|
|
246
|
-
if (!a)
|
|
247
|
-
return;
|
|
248
|
-
const t = E({
|
|
249
|
-
document: a,
|
|
250
|
-
path: e.path,
|
|
251
|
-
method: e.method,
|
|
252
|
-
example: e.exampleKey
|
|
253
|
-
});
|
|
254
|
-
(!t || t.type !== "example") && (q(a), d.value && j(d.value));
|
|
255
|
-
}, ge = 288, xe = i(() => o.value?.workspace?.["x-scalar-sidebar-width"] ?? ge), ke = (e) => o.value?.update("x-scalar-sidebar-width", e), T = p(!0), be = "x-scalar-tabs", ye = "x-scalar-active-tab", B = (e) => {
|
|
256
|
-
const a = l("method", e), t = l("pathEncoded", e), n = l("documentSlug", e), c = l("workspaceSlug", e);
|
|
257
|
-
return {
|
|
258
|
-
...re({
|
|
259
|
-
workspace: c,
|
|
260
|
-
document: n,
|
|
261
|
-
path: t,
|
|
262
|
-
method: a,
|
|
263
|
-
getEntryByLocation: E
|
|
264
|
-
}),
|
|
265
|
-
path: d.value?.path ?? ""
|
|
310
|
+
t && (o.setSelected(t.id), o.setExpanded(t.id, !0));
|
|
266
311
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.error("Failed to copy URL to clipboard:", n);
|
|
278
|
-
}
|
|
279
|
-
}, Ee = (e) => {
|
|
280
|
-
const a = l("workspaceSlug", e), t = l("documentSlug", e), n = l("namespace", e);
|
|
281
|
-
if (!n || !a)
|
|
282
|
-
return;
|
|
283
|
-
const c = f.value.find(
|
|
284
|
-
(s) => s.slug === a && s.namespace === n
|
|
285
|
-
);
|
|
286
|
-
if (c && !ue(c.teamUid, R.value))
|
|
287
|
-
return S("local", "default");
|
|
288
|
-
if (g.value = n, W.value = a, b.value = t, P.value = l("method", e), _.value = l("pathEncoded", e), $.value = l("exampleName", e), e.path !== "" && se.setCurrentPath(e.path), h(g.value, a) !== A.value?.id)
|
|
289
|
-
return fe(g.value, a);
|
|
290
|
-
t && t !== o.value?.workspace[ae.workspace.activeDocument] && o?.value?.update("x-scalar-active-document", t), We(e), j(e);
|
|
291
|
-
}, We = (e) => {
|
|
292
|
-
const a = o.value?.workspace["x-scalar-tabs"] ?? [], t = o.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
|
|
293
|
-
!n || n.path === e.path || (a[t] = B(e));
|
|
294
|
-
}, j = (e) => {
|
|
295
|
-
const a = l("documentSlug", e);
|
|
296
|
-
if (!a) {
|
|
297
|
-
r.setSelected(null);
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
const t = E({
|
|
301
|
-
document: a,
|
|
302
|
-
path: l("pathEncoded", e),
|
|
303
|
-
method: l("method", e),
|
|
304
|
-
example: l("exampleName", e)
|
|
312
|
+
Se({
|
|
313
|
+
eventBus: w,
|
|
314
|
+
router: i,
|
|
315
|
+
store: s,
|
|
316
|
+
navigateToCurrentTab: ee,
|
|
317
|
+
rebuildSidebar: K,
|
|
318
|
+
onAfterExampleCreation: ae,
|
|
319
|
+
onSelectSidebarItem: F,
|
|
320
|
+
onCopyTabUrl: (e) => q(e),
|
|
321
|
+
onToggleSidebar: () => C.value = !C.value
|
|
305
322
|
});
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
store: o,
|
|
312
|
-
navigateToCurrentTab: he,
|
|
313
|
-
rebuildSidebar: q,
|
|
314
|
-
onAfterExampleCreation: we,
|
|
315
|
-
onSelectSidebarItem: V,
|
|
316
|
-
onCopyTabUrl: (e) => Y(e),
|
|
317
|
-
onToggleSidebar: () => T.value = !T.value
|
|
318
|
-
});
|
|
319
|
-
function He(e) {
|
|
320
|
-
return e && (u.value = e), {
|
|
323
|
+
const ie = p(() => {
|
|
324
|
+
const e = s.value?.workspace["x-scalar-color-mode"] ?? "system";
|
|
325
|
+
return e === "system" ? window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ?? !1 : e === "dark";
|
|
326
|
+
});
|
|
327
|
+
return {
|
|
321
328
|
/** Active workspace store */
|
|
322
|
-
store:
|
|
329
|
+
store: s,
|
|
323
330
|
sidebar: {
|
|
324
|
-
state:
|
|
325
|
-
width:
|
|
326
|
-
isOpen:
|
|
327
|
-
handleSelectItem:
|
|
328
|
-
handleSidebarWidthUpdate:
|
|
329
|
-
getEntryByLocation:
|
|
331
|
+
state: o,
|
|
332
|
+
width: te,
|
|
333
|
+
isOpen: C,
|
|
334
|
+
handleSelectItem: F,
|
|
335
|
+
handleSidebarWidthUpdate: ne,
|
|
336
|
+
getEntryByLocation: W
|
|
330
337
|
},
|
|
331
338
|
tabs: {
|
|
332
|
-
state:
|
|
333
|
-
activeTabIndex:
|
|
334
|
-
copyTabUrl:
|
|
339
|
+
state: V,
|
|
340
|
+
activeTabIndex: re,
|
|
341
|
+
copyTabUrl: q
|
|
335
342
|
},
|
|
336
343
|
workspace: {
|
|
337
|
-
create:
|
|
344
|
+
create: _,
|
|
338
345
|
workspaceList: f,
|
|
339
|
-
filteredWorkspaceList:
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
346
|
+
filteredWorkspaceList: S,
|
|
347
|
+
workspaceGroups: z,
|
|
348
|
+
activeWorkspace: D,
|
|
349
|
+
navigateToWorkspace: E,
|
|
350
|
+
isOpen: p(() => !!(I.value && !b.value))
|
|
343
351
|
},
|
|
344
|
-
eventBus:
|
|
345
|
-
router:
|
|
352
|
+
eventBus: w,
|
|
353
|
+
router: i,
|
|
346
354
|
currentRoute: d,
|
|
347
|
-
loading:
|
|
355
|
+
loading: y,
|
|
348
356
|
activeEntities: {
|
|
349
|
-
namespace:
|
|
350
|
-
workspaceSlug:
|
|
357
|
+
namespace: x,
|
|
358
|
+
workspaceSlug: I,
|
|
351
359
|
documentSlug: b,
|
|
352
|
-
path:
|
|
353
|
-
method:
|
|
354
|
-
exampleName:
|
|
355
|
-
teamUid:
|
|
360
|
+
path: O,
|
|
361
|
+
method: L,
|
|
362
|
+
exampleName: N,
|
|
363
|
+
teamUid: g
|
|
356
364
|
},
|
|
357
|
-
environment:
|
|
358
|
-
document:
|
|
365
|
+
environment: G,
|
|
366
|
+
document: A,
|
|
367
|
+
isDarkMode: ie
|
|
359
368
|
};
|
|
360
|
-
}
|
|
369
|
+
};
|
|
361
370
|
export {
|
|
362
|
-
He as
|
|
371
|
+
He as createAppState
|
|
363
372
|
};
|