@scalar/api-client 2.23.4 → 2.25.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 +57 -0
- package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +8 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +33 -29
- 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 +46 -29
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.d.ts +15 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.js +125 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue2.js +4 -0
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +2 -2
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +2 -2
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.d.ts +8 -0
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +95 -108
- package/dist/v2/features/app/app-state.d.ts +46 -16
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +174 -161
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts +2 -2
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +3 -3
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts +3 -3
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/filter-workspaces.d.ts +49 -0
- package/dist/v2/features/app/helpers/filter-workspaces.d.ts.map +1 -0
- package/dist/v2/features/app/helpers/filter-workspaces.js +5 -0
- package/dist/v2/features/app/helpers/group-workspaces.d.ts +24 -0
- package/dist/v2/features/app/helpers/group-workspaces.d.ts.map +1 -0
- package/dist/v2/features/app/helpers/group-workspaces.js +23 -0
- package/dist/v2/features/app/hooks/use-document-watcher.js +8 -8
- package/dist/v2/features/collection/components/Environment.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Environment.vue.js +12 -11
- package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.js +17 -25
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +115 -118
- package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts +14 -4
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.js +5 -6
- package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts +16 -0
- package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/load-document-from-source.js +34 -0
- package/dist/v2/features/command-palette/index.d.ts +4 -0
- package/dist/v2/features/command-palette/index.d.ts.map +1 -0
- package/dist/v2/features/command-palette/index.js +8 -0
- package/dist/v2/features/environments/EnvironmentsList.vue.d.ts +4 -0
- package/dist/v2/features/environments/EnvironmentsList.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/EnvironmentsList.vue.js +29 -27
- package/dist/v2/features/environments/components/Environment.vue.d.ts +1 -0
- package/dist/v2/features/environments/components/Environment.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/Environment.vue.js +37 -24
- 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 +39 -38
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +35 -26
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +7 -0
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +15 -15
- package/dist/v2/features/import-listener/ImportListener.vue.d.ts +0 -52
- package/dist/v2/features/import-listener/ImportListener.vue.d.ts.map +0 -1
- package/dist/v2/features/import-listener/ImportListener.vue.js +0 -91
- package/dist/v2/features/import-listener/ImportListener.vue2.js +0 -4
- package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts +0 -7
- package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts.map +0 -1
- package/dist/v2/features/import-listener/components/DropEventListener.vue.js +0 -81
- package/dist/v2/features/import-listener/components/DropEventListener.vue2.js +0 -4
- package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts +0 -40
- package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts.map +0 -1
- package/dist/v2/features/import-listener/components/ImportModal.vue.js +0 -170
- package/dist/v2/features/import-listener/components/ImportModal.vue3.js +0 -5
- package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts +0 -29
- package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts.map +0 -1
- package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.js +0 -83
- package/dist/v2/features/import-listener/components/WorkspaceSelector.vue2.js +0 -4
- package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts +0 -8
- package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts.map +0 -1
- package/dist/v2/features/import-listener/helpers/get-url-query-parameter.js +0 -4
- package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts +0 -15
- package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts.map +0 -1
- package/dist/v2/features/import-listener/helpers/load-document-from-source.js +0 -28
- package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts +0 -15
- package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts.map +0 -1
- package/dist/v2/features/import-listener/helpers/wait-for-condition.js +0 -16
- package/dist/v2/features/import-listener/index.d.ts +0 -2
- package/dist/v2/features/import-listener/index.d.ts.map +0 -1
- package/dist/v2/features/import-listener/index.js +0 -4
- /package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.d.ts +0 -0
- /package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.js +0 -0
- /package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.d.ts +0 -0
- /package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.js +0 -0
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { sortByOrder as
|
|
3
|
-
import { isHttpMethod as
|
|
4
|
-
import { createSidebarState as
|
|
5
|
-
import { createWorkspaceStore as
|
|
6
|
-
import { createWorkspaceEventBus as
|
|
7
|
-
import { generateUniqueValue as
|
|
8
|
-
import { getParentEntry as
|
|
9
|
-
import { createWorkspaceStorePersistence as
|
|
10
|
-
import { persistencePlugin as
|
|
11
|
-
import { extensions as
|
|
12
|
-
import { shallowRef as
|
|
13
|
-
import { getActiveEnvironment as
|
|
14
|
-
import { getTabDetails as
|
|
15
|
-
import { slugify as
|
|
16
|
-
import { workspaceStorage as
|
|
17
|
-
import { initializeAppEventHandlers as
|
|
18
|
-
|
|
1
|
+
import { isDefined as O } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { sortByOrder as z } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { isHttpMethod as J } from "@scalar/helpers/http/is-http-method";
|
|
4
|
+
import { createSidebarState as M, generateReverseIndex as G } from "@scalar/sidebar";
|
|
5
|
+
import { createWorkspaceStore as N } from "@scalar/workspace-store/client";
|
|
6
|
+
import { createWorkspaceEventBus as Q } from "@scalar/workspace-store/events";
|
|
7
|
+
import { generateUniqueValue as X } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
8
|
+
import { getParentEntry as v } from "@scalar/workspace-store/navigation";
|
|
9
|
+
import { createWorkspaceStorePersistence as Z } from "@scalar/workspace-store/persistence";
|
|
10
|
+
import { persistencePlugin as ee } from "@scalar/workspace-store/plugins/client";
|
|
11
|
+
import { extensions as ae } from "@scalar/workspace-store/schemas/extensions";
|
|
12
|
+
import { shallowRef as D, computed as i, ref as p, watch as te } from "vue";
|
|
13
|
+
import { getActiveEnvironment as ne } from "../../helpers/get-active-environment.js";
|
|
14
|
+
import { getTabDetails as re } from "../../helpers/get-tab-details.js";
|
|
15
|
+
import { slugify as oe } from "../../helpers/slugify.js";
|
|
16
|
+
import { workspaceStorage as se } from "../../helpers/storage.js";
|
|
17
|
+
import { initializeAppEventHandlers as ce } from "./app-events.js";
|
|
18
|
+
import { filterWorkspacesByTeam as le, canLoadWorkspace as ue } from "./helpers/filter-workspaces.js";
|
|
19
|
+
const ie = 1e3, k = Q({
|
|
19
20
|
debug: !1
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
e && e.afterEach((a) =>
|
|
21
|
+
}), R = p("local"), g = p(void 0), W = p(void 0), b = p(void 0), P = p(void 0), _ = p(void 0), $ = p(void 0), x = p(!1), u = D(null);
|
|
22
|
+
te(u, (e) => {
|
|
23
|
+
e && e.afterEach((a) => Ee(a));
|
|
23
24
|
});
|
|
24
|
-
const
|
|
25
|
-
function
|
|
25
|
+
const d = i(() => u.value?.currentRoute.value ?? null);
|
|
26
|
+
function l(e, a) {
|
|
26
27
|
const t = a?.params[e];
|
|
27
28
|
if (typeof t == "string")
|
|
28
|
-
return e === "method" ? t &&
|
|
29
|
+
return e === "method" ? t && J(t) ? t : void 0 : decodeURIComponent(t);
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
(e) => e.map(({ teamUid: a, namespace: t, slug: n, name:
|
|
33
|
-
id:
|
|
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),
|
|
34
35
|
teamUid: a,
|
|
35
36
|
namespace: t,
|
|
36
37
|
slug: n,
|
|
37
|
-
label:
|
|
38
|
+
label: c
|
|
38
39
|
}))
|
|
39
40
|
);
|
|
40
|
-
const
|
|
41
|
+
const me = async ({ namespace: e, slug: a }) => N({
|
|
41
42
|
plugins: [
|
|
42
|
-
await
|
|
43
|
+
await ee({ workspaceId: h(e, a), debounceDelay: ie })
|
|
43
44
|
]
|
|
44
|
-
}),
|
|
45
|
-
const t = await
|
|
45
|
+
}), de = async (e, a) => {
|
|
46
|
+
const t = await y.getItem({ namespace: e, slug: a });
|
|
46
47
|
if (!t)
|
|
47
48
|
return {
|
|
48
49
|
success: !1
|
|
49
50
|
};
|
|
50
|
-
const n = await
|
|
51
|
-
return n.loadWorkspace(t.workspace),
|
|
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, {
|
|
52
53
|
success: !0,
|
|
53
54
|
workspace: n.workspace
|
|
54
55
|
};
|
|
55
|
-
},
|
|
56
|
+
}, ve = async ({
|
|
56
57
|
name: e,
|
|
57
58
|
teamUid: a,
|
|
58
59
|
namespace: t,
|
|
59
60
|
slug: n
|
|
60
61
|
}) => {
|
|
61
|
-
const
|
|
62
|
-
await
|
|
62
|
+
const c = N();
|
|
63
|
+
await c.addDocument({
|
|
63
64
|
name: "drafts",
|
|
64
65
|
document: {
|
|
65
66
|
openapi: "3.1.0",
|
|
@@ -76,89 +77,94 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
76
77
|
"x-scalar-icon": "interface-edit-tool-pencil"
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
|
-
const s = await
|
|
80
|
+
const s = await y.setItem(
|
|
80
81
|
{ namespace: t, slug: n },
|
|
81
82
|
{
|
|
82
83
|
name: e,
|
|
83
84
|
teamUid: a,
|
|
84
|
-
workspace:
|
|
85
|
+
workspace: c.exportWorkspace()
|
|
85
86
|
}
|
|
86
87
|
);
|
|
87
|
-
return
|
|
88
|
-
id:
|
|
88
|
+
return f.value.push({
|
|
89
|
+
id: h(s.namespace, s.slug),
|
|
89
90
|
teamUid: s.teamUid,
|
|
90
91
|
namespace: s.namespace,
|
|
91
92
|
slug: s.slug,
|
|
92
93
|
label: s.name
|
|
93
94
|
}), s;
|
|
94
|
-
},
|
|
95
|
-
await
|
|
95
|
+
}, S = async (e, a) => {
|
|
96
|
+
await u.value?.push({
|
|
96
97
|
name: "workspace.environment",
|
|
97
98
|
params: { namespace: e, workspaceSlug: a }
|
|
98
99
|
});
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
}, F = async ({
|
|
101
|
+
teamUid: e,
|
|
102
|
+
namespace: a,
|
|
103
|
+
slug: t,
|
|
104
|
+
name: n
|
|
102
105
|
}) => {
|
|
103
106
|
o.value = null;
|
|
104
|
-
const
|
|
105
|
-
defaultValue:
|
|
107
|
+
const c = await X({
|
|
108
|
+
defaultValue: t ?? n,
|
|
106
109
|
// Use the provided id if it exists, otherwise use the name
|
|
107
|
-
validation: async (
|
|
110
|
+
validation: async (w) => !await y.has({ namespace: a ?? "local", slug: w }),
|
|
108
111
|
maxRetries: 100,
|
|
109
|
-
transformation:
|
|
112
|
+
transformation: oe
|
|
110
113
|
});
|
|
111
|
-
if (!
|
|
114
|
+
if (!c)
|
|
112
115
|
return;
|
|
113
|
-
const
|
|
114
|
-
teamUid: e
|
|
115
|
-
namespace:
|
|
116
|
-
slug:
|
|
117
|
-
name:
|
|
118
|
-
}
|
|
119
|
-
return await
|
|
120
|
-
},
|
|
121
|
-
o.value = null,
|
|
122
|
-
const t = await
|
|
116
|
+
const m = await ve({
|
|
117
|
+
teamUid: e,
|
|
118
|
+
namespace: a,
|
|
119
|
+
slug: c,
|
|
120
|
+
name: n
|
|
121
|
+
});
|
|
122
|
+
return await S(m.namespace, m.slug), m;
|
|
123
|
+
}, fe = async (e, a) => {
|
|
124
|
+
o.value = null, x.value = !0;
|
|
125
|
+
const t = await de(e, a);
|
|
123
126
|
if (t.success) {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
path:
|
|
127
|
-
query:
|
|
128
|
-
}),
|
|
127
|
+
const s = t.workspace["x-scalar-active-tab"] ?? 0, m = t.workspace["x-scalar-tabs"], w = m?.[s];
|
|
128
|
+
w && await u.value?.replace({
|
|
129
|
+
path: w.path,
|
|
130
|
+
query: d.value?.query ?? {}
|
|
131
|
+
}), m && s >= m.length && k.emit("tabs:update:tabs", {
|
|
129
132
|
"x-scalar-active-tab": 0
|
|
130
|
-
}),
|
|
131
|
-
"x-scalar-tabs": [
|
|
133
|
+
}), m || k.emit("tabs:update:tabs", {
|
|
134
|
+
"x-scalar-tabs": [B(d.value)],
|
|
132
135
|
"x-scalar-active-tab": 0
|
|
133
|
-
}),
|
|
136
|
+
}), x.value = !1;
|
|
134
137
|
return;
|
|
135
138
|
}
|
|
136
|
-
const n =
|
|
139
|
+
const n = U.value.find((s) => s.teamUid === "local" && s.slug === "default") ?? U.value[0];
|
|
140
|
+
if (n)
|
|
141
|
+
return S(n.namespace, n.slug);
|
|
142
|
+
const c = await F({
|
|
137
143
|
name: "Default Workspace",
|
|
138
|
-
|
|
144
|
+
slug: "default"
|
|
139
145
|
});
|
|
140
|
-
if (
|
|
146
|
+
if (x.value = !1, !c)
|
|
141
147
|
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
142
148
|
r.reset();
|
|
143
|
-
},
|
|
149
|
+
}, K = i(() => {
|
|
144
150
|
const e = o.value;
|
|
145
151
|
if (!e)
|
|
146
152
|
return [];
|
|
147
153
|
const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
148
|
-
return
|
|
149
|
-
}), r =
|
|
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 = ({
|
|
150
156
|
document: e,
|
|
151
157
|
path: a,
|
|
152
158
|
method: t,
|
|
153
159
|
example: n
|
|
154
|
-
}) => JSON.stringify([e, a, t, n].filter(
|
|
155
|
-
() =>
|
|
156
|
-
items:
|
|
160
|
+
}) => JSON.stringify([e, a, t, n].filter(O)), L = i(
|
|
161
|
+
() => G({
|
|
162
|
+
items: K.value,
|
|
157
163
|
nestedKey: "children",
|
|
158
164
|
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
159
165
|
getId: (e) => {
|
|
160
|
-
const a =
|
|
161
|
-
return
|
|
166
|
+
const a = v("document", e), t = v("operation", e);
|
|
167
|
+
return I({
|
|
162
168
|
document: a?.name ?? "",
|
|
163
169
|
path: t?.path,
|
|
164
170
|
method: t?.method,
|
|
@@ -166,16 +172,16 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
166
172
|
});
|
|
167
173
|
}
|
|
168
174
|
})
|
|
169
|
-
),
|
|
170
|
-
const a =
|
|
171
|
-
return a ||
|
|
172
|
-
|
|
175
|
+
), E = (e) => {
|
|
176
|
+
const a = L.value.get(I(e));
|
|
177
|
+
return a || L.value.get(
|
|
178
|
+
I({
|
|
173
179
|
document: e.document,
|
|
174
180
|
path: e.path,
|
|
175
181
|
method: e.method
|
|
176
182
|
})
|
|
177
183
|
);
|
|
178
|
-
},
|
|
184
|
+
}, V = (e) => {
|
|
179
185
|
const a = r.getEntryById(e);
|
|
180
186
|
if (!a) {
|
|
181
187
|
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
@@ -186,7 +192,7 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
186
192
|
r.setExpanded(e, !r.isExpanded(e));
|
|
187
193
|
return;
|
|
188
194
|
}
|
|
189
|
-
return r.setSelected(e), r.setExpanded(e, !0),
|
|
195
|
+
return r.setSelected(e), r.setExpanded(e, !0), u.value?.push({
|
|
190
196
|
name: "document.overview",
|
|
191
197
|
params: { documentSlug: a.name }
|
|
192
198
|
});
|
|
@@ -197,10 +203,10 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
197
203
|
return;
|
|
198
204
|
}
|
|
199
205
|
const t = a.children?.find((n) => n.type === "example");
|
|
200
|
-
return t ? (r.setSelected(t.id), r.setExpanded(t.id, !0)) : r.setSelected(e),
|
|
206
|
+
return t ? (r.setSelected(t.id), r.setExpanded(t.id, !0)) : r.setSelected(e), u.value?.push({
|
|
201
207
|
name: "example",
|
|
202
208
|
params: {
|
|
203
|
-
documentSlug:
|
|
209
|
+
documentSlug: v("document", a)?.name,
|
|
204
210
|
pathEncoded: encodeURIComponent(a.path),
|
|
205
211
|
method: a.method,
|
|
206
212
|
exampleName: t?.name ?? "default"
|
|
@@ -209,11 +215,11 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
209
215
|
}
|
|
210
216
|
if (a.type === "example") {
|
|
211
217
|
r.setSelected(e);
|
|
212
|
-
const t =
|
|
213
|
-
return
|
|
218
|
+
const t = v("operation", a);
|
|
219
|
+
return u.value?.push({
|
|
214
220
|
name: "example",
|
|
215
221
|
params: {
|
|
216
|
-
documentSlug:
|
|
222
|
+
documentSlug: v("document", a)?.name,
|
|
217
223
|
pathEncoded: encodeURIComponent(t?.path ?? ""),
|
|
218
224
|
method: t?.method,
|
|
219
225
|
exampleName: a.name
|
|
@@ -221,45 +227,45 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
221
227
|
});
|
|
222
228
|
}
|
|
223
229
|
if (a.type === "text")
|
|
224
|
-
return
|
|
230
|
+
return u.value?.push({
|
|
225
231
|
name: "document.overview",
|
|
226
232
|
params: {
|
|
227
|
-
documentSlug:
|
|
233
|
+
documentSlug: v("document", a)?.name
|
|
228
234
|
}
|
|
229
235
|
});
|
|
230
236
|
r.setExpanded(e, !r.isExpanded(e));
|
|
231
|
-
},
|
|
237
|
+
}, he = async () => {
|
|
232
238
|
if (!o.value)
|
|
233
239
|
return;
|
|
234
240
|
const e = o.value.workspace["x-scalar-active-tab"] ?? 0, a = o.value.workspace["x-scalar-tabs"]?.[e];
|
|
235
|
-
a && await
|
|
236
|
-
},
|
|
241
|
+
a && await u.value?.replace(a.path);
|
|
242
|
+
}, q = (e) => {
|
|
237
243
|
e && o.value?.buildSidebar(e);
|
|
238
|
-
},
|
|
239
|
-
const a =
|
|
244
|
+
}, we = (e) => {
|
|
245
|
+
const a = C.value?.["x-scalar-navigation"]?.name;
|
|
240
246
|
if (!a)
|
|
241
247
|
return;
|
|
242
|
-
const t =
|
|
248
|
+
const t = E({
|
|
243
249
|
document: a,
|
|
244
250
|
path: e.path,
|
|
245
251
|
method: e.method,
|
|
246
252
|
example: e.exampleKey
|
|
247
253
|
});
|
|
248
|
-
(!t || t.type !== "example") && (
|
|
249
|
-
},
|
|
250
|
-
const a =
|
|
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);
|
|
251
257
|
return {
|
|
252
|
-
...
|
|
253
|
-
workspace:
|
|
258
|
+
...re({
|
|
259
|
+
workspace: c,
|
|
254
260
|
document: n,
|
|
255
261
|
path: t,
|
|
256
262
|
method: a,
|
|
257
|
-
getEntryByLocation:
|
|
263
|
+
getEntryByLocation: E
|
|
258
264
|
}),
|
|
259
|
-
path:
|
|
265
|
+
path: d.value?.path ?? ""
|
|
260
266
|
};
|
|
261
|
-
},
|
|
262
|
-
const a =
|
|
267
|
+
}, H = i(() => o.value?.workspace[be] ?? [B(d.value)]), Se = i(() => o.value?.workspace[ye] ?? 0), Y = async (e) => {
|
|
268
|
+
const a = H.value[e];
|
|
263
269
|
if (!a) {
|
|
264
270
|
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
265
271
|
return;
|
|
@@ -270,81 +276,88 @@ const ce = async ({ namespace: e, slug: a }) => C({
|
|
|
270
276
|
} catch (n) {
|
|
271
277
|
console.error("Failed to copy URL to clipboard:", n);
|
|
272
278
|
}
|
|
273
|
-
},
|
|
274
|
-
const a =
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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) => {
|
|
281
292
|
const a = o.value?.workspace["x-scalar-tabs"] ?? [], t = o.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
|
|
282
|
-
!n || n.path === e.path || (a[t] =
|
|
283
|
-
},
|
|
284
|
-
const a =
|
|
293
|
+
!n || n.path === e.path || (a[t] = B(e));
|
|
294
|
+
}, j = (e) => {
|
|
295
|
+
const a = l("documentSlug", e);
|
|
285
296
|
if (!a) {
|
|
286
297
|
r.setSelected(null);
|
|
287
298
|
return;
|
|
288
299
|
}
|
|
289
|
-
const t =
|
|
300
|
+
const t = E({
|
|
290
301
|
document: a,
|
|
291
|
-
path:
|
|
292
|
-
method:
|
|
293
|
-
example:
|
|
302
|
+
path: l("pathEncoded", e),
|
|
303
|
+
method: l("method", e),
|
|
304
|
+
example: l("exampleName", e)
|
|
294
305
|
});
|
|
295
306
|
t && (r.setSelected(t.id), r.setExpanded(t.id, !0));
|
|
296
307
|
};
|
|
297
|
-
|
|
298
|
-
eventBus:
|
|
299
|
-
router:
|
|
308
|
+
ce({
|
|
309
|
+
eventBus: k,
|
|
310
|
+
router: u,
|
|
300
311
|
store: o,
|
|
301
|
-
navigateToCurrentTab:
|
|
302
|
-
rebuildSidebar:
|
|
303
|
-
onAfterExampleCreation:
|
|
304
|
-
onSelectSidebarItem:
|
|
305
|
-
onCopyTabUrl: (e) =>
|
|
306
|
-
onToggleSidebar: () =>
|
|
312
|
+
navigateToCurrentTab: he,
|
|
313
|
+
rebuildSidebar: q,
|
|
314
|
+
onAfterExampleCreation: we,
|
|
315
|
+
onSelectSidebarItem: V,
|
|
316
|
+
onCopyTabUrl: (e) => Y(e),
|
|
317
|
+
onToggleSidebar: () => T.value = !T.value
|
|
307
318
|
});
|
|
308
|
-
function
|
|
309
|
-
return e && (
|
|
319
|
+
function He(e) {
|
|
320
|
+
return e && (u.value = e), {
|
|
310
321
|
/** Active workspace store */
|
|
311
322
|
store: o,
|
|
312
323
|
sidebar: {
|
|
313
324
|
state: r,
|
|
314
|
-
width:
|
|
315
|
-
isOpen:
|
|
316
|
-
handleSelectItem:
|
|
317
|
-
handleSidebarWidthUpdate:
|
|
318
|
-
getEntryByLocation:
|
|
325
|
+
width: xe,
|
|
326
|
+
isOpen: T,
|
|
327
|
+
handleSelectItem: V,
|
|
328
|
+
handleSidebarWidthUpdate: ke,
|
|
329
|
+
getEntryByLocation: E
|
|
319
330
|
},
|
|
320
331
|
tabs: {
|
|
321
|
-
state:
|
|
322
|
-
activeTabIndex:
|
|
323
|
-
copyTabUrl:
|
|
332
|
+
state: H,
|
|
333
|
+
activeTabIndex: Se,
|
|
334
|
+
copyTabUrl: Y
|
|
324
335
|
},
|
|
325
336
|
workspace: {
|
|
326
|
-
create:
|
|
327
|
-
workspaceList:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
337
|
+
create: F,
|
|
338
|
+
workspaceList: f,
|
|
339
|
+
filteredWorkspaceList: U,
|
|
340
|
+
activeWorkspace: A,
|
|
341
|
+
navigateToWorkspace: S,
|
|
342
|
+
isOpen: i(() => !!(W.value && !b.value))
|
|
331
343
|
},
|
|
332
|
-
eventBus:
|
|
333
|
-
router:
|
|
334
|
-
currentRoute:
|
|
335
|
-
loading:
|
|
344
|
+
eventBus: k,
|
|
345
|
+
router: u,
|
|
346
|
+
currentRoute: d,
|
|
347
|
+
loading: x,
|
|
336
348
|
activeEntities: {
|
|
337
|
-
namespace:
|
|
338
|
-
workspaceSlug:
|
|
339
|
-
documentSlug:
|
|
340
|
-
path:
|
|
341
|
-
method:
|
|
342
|
-
exampleName:
|
|
349
|
+
namespace: g,
|
|
350
|
+
workspaceSlug: W,
|
|
351
|
+
documentSlug: b,
|
|
352
|
+
path: _,
|
|
353
|
+
method: P,
|
|
354
|
+
exampleName: $,
|
|
355
|
+
teamUid: R
|
|
343
356
|
},
|
|
344
|
-
environment:
|
|
345
|
-
document:
|
|
357
|
+
environment: pe,
|
|
358
|
+
document: C
|
|
346
359
|
};
|
|
347
360
|
}
|
|
348
361
|
export {
|
|
349
|
-
|
|
362
|
+
He as useAppState
|
|
350
363
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type WorkspaceGroup } from '@scalar/components';
|
|
2
2
|
import type { SidebarState } from '@scalar/sidebar';
|
|
3
3
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
4
4
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
@@ -29,7 +29,7 @@ type __VLS_Props = {
|
|
|
29
29
|
* The list of all available workspaces.
|
|
30
30
|
* Used to render options for workspace switching and selection.
|
|
31
31
|
*/
|
|
32
|
-
workspaces:
|
|
32
|
+
workspaces: WorkspaceGroup[];
|
|
33
33
|
/**
|
|
34
34
|
* The workspace event bus for handling workspace-level events.
|
|
35
35
|
* Used for triggering and responding to workspace changes and actions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"AAkeA,OAAO,EAML,KAAK,
|
|
1
|
+
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"AAkeA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAA;AAO3B,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,cAAc,EAAE,CAAA;IAC5B;;;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;AAqfF,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
|
-
import
|
|
4
|
-
const
|
|
3
|
+
import a from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const m = /* @__PURE__ */ a(o, [["__scopeId", "data-v-6a79a4d6"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
m as default
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkspaceGroup } from '@scalar/components';
|
|
2
2
|
/**
|
|
3
3
|
* The top nav on the web
|
|
4
4
|
*
|
|
@@ -16,7 +16,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
16
16
|
* The list of all available workspaces.
|
|
17
17
|
* Used to render options for workspace switching and selection.
|
|
18
18
|
*/
|
|
19
|
-
workspaces:
|
|
19
|
+
workspaces: WorkspaceGroup[];
|
|
20
20
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
21
|
"create:workspace": () => any;
|
|
22
22
|
"select:workspace": (id?: string | undefined) => any;
|
|
@@ -32,7 +32,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
32
32
|
* The list of all available workspaces.
|
|
33
33
|
* Used to render options for workspace switching and selection.
|
|
34
34
|
*/
|
|
35
|
-
workspaces:
|
|
35
|
+
workspaces: WorkspaceGroup[];
|
|
36
36
|
}> & Readonly<{
|
|
37
37
|
"onCreate:workspace"?: (() => any) | undefined;
|
|
38
38
|
"onSelect:workspace"?: ((id?: string | undefined) => any) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebTopNav.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/WebTopNav.vue"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"WebTopNav.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/WebTopNav.vue"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAOxD;;;;GAIG;;IAGD;;;OAGG;qBACc;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;IAC/B;;;OAGG;gBACS,cAAc,EAAE;;;;;IAT5B;;;OAGG;qBACc;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;IAC/B;;;OAGG;gBACS,cAAc,EAAE;;;;;AAX9B,wBAuGC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters workspaces to show only those accessible to the current team.
|
|
3
|
+
*
|
|
4
|
+
* A workspace is accessible if:
|
|
5
|
+
* - Its teamUid matches the current team, OR
|
|
6
|
+
* - Its teamUid is 'local' (local workspaces are always accessible)
|
|
7
|
+
*
|
|
8
|
+
* @param workspaces - Array of workspaces to filter
|
|
9
|
+
* @param currentTeamUid - The currently active team identifier
|
|
10
|
+
* @returns Filtered array of workspaces accessible to the current team
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const workspaces = [
|
|
15
|
+
* { id: '1', teamUid: 'local', name: 'Local' },
|
|
16
|
+
* { id: '2', teamUid: 'team-a', name: 'Team A' },
|
|
17
|
+
* { id: '3', teamUid: 'team-b', name: 'Team B' },
|
|
18
|
+
* ]
|
|
19
|
+
*
|
|
20
|
+
* filterWorkspacesByTeam(workspaces, 'team-a')
|
|
21
|
+
* // => [{ id: '1', teamUid: 'local' }, { id: '2', teamUid: 'team-a' }]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const filterWorkspacesByTeam: <T extends {
|
|
25
|
+
teamUid: string;
|
|
26
|
+
}>(workspaces: T[], currentTeamUid: string) => T[];
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a workspace can be loaded by the current team.
|
|
29
|
+
*
|
|
30
|
+
* A workspace can be loaded if:
|
|
31
|
+
* - Its teamUid matches the current team, OR
|
|
32
|
+
* - Its teamUid is 'local' (local workspaces are always accessible)
|
|
33
|
+
*
|
|
34
|
+
* This is used during route changes to prevent users from accessing
|
|
35
|
+
* workspaces that do not belong to their active team.
|
|
36
|
+
*
|
|
37
|
+
* @param workspaceTeamUid - The team identifier of the workspace to check
|
|
38
|
+
* @param currentTeamUid - The currently active team identifier
|
|
39
|
+
* @returns true if the workspace can be loaded, false otherwise
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* canLoadWorkspace('team-a', 'team-a') // => true
|
|
44
|
+
* canLoadWorkspace('local', 'team-a') // => true
|
|
45
|
+
* canLoadWorkspace('team-b', 'team-a') // => false
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const canLoadWorkspace: (workspaceTeamUid: string, currentTeamUid: string) => boolean;
|
|
49
|
+
//# sourceMappingURL=filter-workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-workspaces.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/filter-workspaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,YAAY,CAAC,EAAE,EAAE,gBAAgB,MAAM,KAAG,CAAC,EAEhH,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB,GAAI,kBAAkB,MAAM,EAAE,gBAAgB,MAAM,KAAG,OAEnF,CAAA"}
|