@scalar/api-client 2.22.2 → 2.23.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/style.css +1 -1
  3. package/dist/v2/blocks/request-block/helpers/get-default-headers.d.ts.map +1 -1
  4. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +9 -9
  5. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  6. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
  7. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +100 -91
  8. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts +2 -0
  9. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
  10. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +2 -2
  11. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue2.js +43 -37
  12. package/dist/v2/components/layout/ValueEmitter.vue.d.ts +6 -2
  13. package/dist/v2/components/layout/ValueEmitter.vue.d.ts.map +1 -1
  14. package/dist/v2/components/layout/ValueEmitter.vue.js +10 -10
  15. package/dist/v2/components/server/ServerDropdown.vue.d.ts +2 -0
  16. package/dist/v2/components/server/ServerDropdown.vue.d.ts.map +1 -1
  17. package/dist/v2/components/server/ServerDropdown.vue.js +48 -42
  18. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  19. package/dist/v2/features/app/App.vue.js +117 -89
  20. package/dist/v2/features/app/app-state.d.ts +23 -12
  21. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  22. package/dist/v2/features/app/app-state.js +228 -196
  23. package/dist/v2/features/app/helpers/routes.d.ts +1 -1
  24. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  25. package/dist/v2/features/app/helpers/routes.js +33 -27
  26. package/dist/v2/features/import-listener/ImportListener.vue.d.ts +52 -0
  27. package/dist/v2/features/import-listener/ImportListener.vue.d.ts.map +1 -0
  28. package/dist/v2/features/import-listener/ImportListener.vue.js +91 -0
  29. package/dist/v2/features/import-listener/ImportListener.vue2.js +4 -0
  30. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts +7 -0
  31. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts.map +1 -0
  32. package/dist/v2/features/import-listener/components/DropEventListener.vue.js +81 -0
  33. package/dist/v2/features/import-listener/components/DropEventListener.vue2.js +4 -0
  34. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts +40 -0
  35. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts.map +1 -0
  36. package/dist/v2/features/import-listener/components/ImportModal.vue.js +170 -0
  37. package/dist/v2/features/import-listener/components/ImportModal.vue3.js +5 -0
  38. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts +29 -0
  39. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts.map +1 -0
  40. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.js +83 -0
  41. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue2.js +4 -0
  42. package/dist/v2/features/import-listener/helpers/generate-unique-slug.d.ts +16 -0
  43. package/dist/v2/features/import-listener/helpers/generate-unique-slug.d.ts.map +1 -0
  44. package/dist/v2/features/import-listener/helpers/generate-unique-slug.js +11 -0
  45. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts +8 -0
  46. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts.map +1 -0
  47. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.js +4 -0
  48. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.d.ts +30 -0
  49. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.d.ts.map +1 -0
  50. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.js +31 -0
  51. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts +15 -0
  52. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts.map +1 -0
  53. package/dist/v2/features/import-listener/helpers/load-document-from-source.js +28 -0
  54. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts +15 -0
  55. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts.map +1 -0
  56. package/dist/v2/features/import-listener/helpers/wait-for-condition.js +16 -0
  57. package/dist/v2/features/import-listener/index.d.ts +2 -0
  58. package/dist/v2/features/import-listener/index.d.ts.map +1 -0
  59. package/dist/v2/features/import-listener/index.js +4 -0
  60. package/dist/v2/features/operation/Operation.vue.js +1 -1
  61. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  62. package/package.json +16 -11
@@ -1,50 +1,63 @@
1
- import { isDefined as D } from "@scalar/helpers/array/is-defined";
2
- import { sortByOrder as $ } from "@scalar/helpers/array/sort-by-order";
3
- import { isHttpMethod as H } from "@scalar/helpers/http/is-http-method";
4
- import { createSidebarState as V, generateReverseIndex as Y } from "@scalar/sidebar";
5
- import { createWorkspaceStore as R } from "@scalar/workspace-store/client";
6
- import { createWorkspaceEventBus as j } from "@scalar/workspace-store/events";
7
- import { generateUniqueValue as q } from "@scalar/workspace-store/helpers/generate-unique-value";
8
- import { getParentEntry as p } from "@scalar/workspace-store/navigation";
9
- import { createWorkspaceStorePersistence as z } from "@scalar/workspace-store/persistence";
10
- import { persistencePlugin as J } from "@scalar/workspace-store/plugins/client";
11
- import { extensions as M } from "@scalar/workspace-store/schemas/extensions";
12
- import { shallowRef as g, computed as u, ref as l, watch as G } from "vue";
13
- import { getActiveEnvironment as Q } from "../../helpers/get-active-environment.js";
14
- import { getTabDetails as X } from "../../helpers/get-tab-details.js";
15
- import { slugify as Z } from "../../helpers/slugify.js";
16
- import { workspaceStorage as ee } from "../../helpers/storage.js";
17
- import { initializeAppEventHandlers as te } from "./app-events.js";
18
- const ae = 1e3, v = j({
1
+ import { isDefined as A } from "@scalar/helpers/array/is-defined";
2
+ import { sortByOrder as V } from "@scalar/helpers/array/sort-by-order";
3
+ import { isHttpMethod as Y } from "@scalar/helpers/http/is-http-method";
4
+ import { createSidebarState as j, generateReverseIndex as z } from "@scalar/sidebar";
5
+ import { createWorkspaceStore as C } from "@scalar/workspace-store/client";
6
+ import { createWorkspaceEventBus as J } from "@scalar/workspace-store/events";
7
+ import { generateUniqueValue as M } from "@scalar/workspace-store/helpers/generate-unique-value";
8
+ import { getParentEntry as d } from "@scalar/workspace-store/navigation";
9
+ import { createWorkspaceStorePersistence as G } from "@scalar/workspace-store/persistence";
10
+ import { persistencePlugin as Q } from "@scalar/workspace-store/plugins/client";
11
+ import { extensions as X } from "@scalar/workspace-store/schemas/extensions";
12
+ import { shallowRef as E, computed as i, ref as p, watch as Z } from "vue";
13
+ import { getActiveEnvironment as ee } from "../../helpers/get-active-environment.js";
14
+ import { getTabDetails as ae } from "../../helpers/get-tab-details.js";
15
+ import { slugify as te } from "../../helpers/slugify.js";
16
+ import { workspaceStorage as ne } from "../../helpers/storage.js";
17
+ import { initializeAppEventHandlers as re } from "./app-events.js";
18
+ const oe = 1e3, h = J({
19
19
  debug: !1
20
- }), x = l(void 0), f = l(void 0), A = l(void 0), C = l(void 0), U = l(void 0), m = l(!1), c = g(null);
21
- G(c, (e) => {
22
- e && e.afterEach((t) => he(t));
20
+ }), v = p(void 0), k = p(void 0), w = p(void 0), B = p(void 0), O = p(void 0), $ = p(void 0), f = p(!1), l = E(null);
21
+ Z(l, (e) => {
22
+ e && e.afterEach((a) => ge(a));
23
23
  });
24
- const d = u(() => c.value?.currentRoute.value ?? null);
25
- function s(e, t) {
26
- const a = t?.params[e];
27
- if (typeof a == "string")
28
- return e === "method" ? a && H(a) ? a : void 0 : decodeURIComponent(a);
24
+ const m = i(() => l.value?.currentRoute.value ?? null);
25
+ function c(e, a) {
26
+ const t = a?.params[e];
27
+ if (typeof t == "string")
28
+ return e === "method" ? t && Y(t) ? t : void 0 : decodeURIComponent(t);
29
29
  }
30
- const y = g(null), S = l([]), n = g(null), E = u(() => n.value?.workspace.documents[f.value ?? ""] || null), re = u(() => Q(n.value, E.value)), { workspace: h } = await z();
31
- S.value = await h.getAll().then((e) => e.map(({ id: t, name: a }) => ({ id: t, label: a })));
32
- const ne = async ({ workspaceId: e }) => R({
33
- plugins: [await J({ workspaceId: e, debounceDelay: ae })]
34
- }), oe = async (e) => {
35
- const t = await h.getItem(e);
30
+ const W = E(null), I = p([]), o = E(null), T = i(() => o.value?.workspace.documents[w.value ?? ""] || null), se = i(() => ee(o.value, T.value)), { workspace: x } = await G(), g = (e, a) => `${e}/${a}`;
31
+ I.value = await x.getAll().then(
32
+ (e) => e.map(({ teamUid: a, namespace: t, slug: n, name: u }) => ({
33
+ id: g(t, n),
34
+ teamUid: a,
35
+ namespace: t,
36
+ slug: n,
37
+ label: u
38
+ }))
39
+ );
40
+ const ce = async ({ namespace: e, slug: a }) => C({
41
+ plugins: [await Q({ workspaceId: `${e}-${a}`, debounceDelay: oe })]
42
+ }), ue = async (e, a) => {
43
+ const t = await x.getItem({ namespace: e, slug: a });
36
44
  if (!t)
37
45
  return {
38
46
  success: !1
39
47
  };
40
- const a = await ne({ workspaceId: e });
41
- return a.loadWorkspace(t.workspace), y.value = { id: e, label: t.name }, n.value = a, {
48
+ const n = await ce({ namespace: e, slug: a });
49
+ return n.loadWorkspace(t.workspace), W.value = { id: g(t.namespace, t.slug), label: t.name }, o.value = n, {
42
50
  success: !0,
43
- workspace: a.workspace
51
+ workspace: n.workspace
44
52
  };
45
- }, se = async ({ id: e, name: t }) => {
46
- const a = R();
47
- await a.addDocument({
53
+ }, le = async ({
54
+ name: e,
55
+ teamUid: a,
56
+ namespace: t,
57
+ slug: n
58
+ }) => {
59
+ const u = C();
60
+ await u.addDocument({
48
61
  name: "drafts",
49
62
  document: {
50
63
  openapi: "3.1.0",
@@ -60,257 +73,276 @@ const ne = async ({ workspaceId: e }) => R({
60
73
  "x-scalar-original-document-hash": "drafts",
61
74
  "x-scalar-icon": "interface-edit-tool-pencil"
62
75
  }
63
- }), await h.setItem(e, {
64
- name: t,
65
- workspace: a.exportWorkspace()
66
- }), S.value.push({ id: e, label: t });
67
- }, B = async (e) => {
68
- e && await c.value?.push({
76
+ });
77
+ const s = await x.setItem(
78
+ { namespace: t, slug: n },
79
+ {
80
+ name: e,
81
+ teamUid: a,
82
+ workspace: u.exportWorkspace()
83
+ }
84
+ );
85
+ return I.value.push({
86
+ id: g(s.namespace, s.slug),
87
+ teamUid: s.teamUid,
88
+ namespace: s.namespace,
89
+ slug: s.slug,
90
+ label: s.name
91
+ }), s;
92
+ }, L = async (e, a) => {
93
+ await l.value?.push({
69
94
  name: "workspace.environment",
70
- params: { workspaceSlug: e }
95
+ params: { namespace: e, workspaceSlug: a }
71
96
  });
72
- }, O = async ({
73
- id: e,
74
- name: t
97
+ }, N = async ({
98
+ key: e,
99
+ name: a
75
100
  }) => {
76
- n.value = null;
77
- const a = await q({
78
- defaultValue: e ?? t,
101
+ o.value = null;
102
+ const t = await M({
103
+ defaultValue: e?.slug ?? a,
79
104
  // Use the provided id if it exists, otherwise use the name
80
- validation: async (i) => !await h.has(i),
105
+ validation: async (s) => !await x.has({ namespace: e?.namespace ?? "local", slug: s }),
81
106
  maxRetries: 100,
82
- transformation: Z
107
+ transformation: te
83
108
  });
84
- if (!a)
109
+ if (!t)
85
110
  return;
86
- const o = { id: a, name: t };
87
- return await se(o), await B(a), o;
88
- }, ce = async (e) => {
89
- n.value = null, m.value = !0;
90
- const t = await oe(e);
111
+ const n = {
112
+ teamUid: e?.teamUid,
113
+ namespace: e?.namespace,
114
+ slug: t,
115
+ name: a
116
+ }, u = await le(n);
117
+ return await L(u.namespace, u.slug), u;
118
+ }, ie = async (e, a) => {
119
+ o.value = null, f.value = !0;
120
+ const t = await ue(e, a);
91
121
  if (t.success) {
92
- const o = t.workspace["x-scalar-active-tab"] ?? 0, i = t.workspace["x-scalar-tabs"], W = i?.[o];
93
- W && await c.value?.replace(W.path), i && o >= i.length && v.emit("tabs:update:tabs", {
122
+ const u = t.workspace["x-scalar-active-tab"] ?? 0, s = t.workspace["x-scalar-tabs"], D = s?.[u];
123
+ D && await l.value?.replace({
124
+ path: D.path,
125
+ query: m.value?.query ?? {}
126
+ }), s && u >= s.length && h.emit("tabs:update:tabs", {
94
127
  "x-scalar-active-tab": 0
95
- }), i || v.emit("tabs:update:tabs", {
96
- "x-scalar-tabs": [I(d.value)],
128
+ }), s || h.emit("tabs:update:tabs", {
129
+ "x-scalar-tabs": [U(m.value)],
97
130
  "x-scalar-active-tab": 0
98
- }), m.value = !1;
131
+ }), f.value = !1;
99
132
  return;
100
133
  }
101
- const a = await O({
134
+ const n = await N({
102
135
  name: "Default Workspace",
103
- id: "default"
136
+ key: { slug: "default" }
104
137
  });
105
- if (m.value = !1, !a)
138
+ if (f.value = !1, !n)
106
139
  return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
107
140
  r.reset();
108
- }, L = u(() => {
109
- const e = n.value;
141
+ }, P = i(() => {
142
+ const e = o.value;
110
143
  if (!e)
111
144
  return [];
112
- const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
113
- return $(Object.keys(e.workspace.documents), t, (a) => a).map((a) => e.workspace.documents[a]?.["x-scalar-navigation"]).filter(D);
114
- }), r = V(L), b = ({
145
+ const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
146
+ return V(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(A);
147
+ }), r = j(P), y = ({
115
148
  document: e,
116
- path: t,
117
- method: a,
118
- example: o
119
- }) => JSON.stringify([e, t, a, o].filter(D)), T = u(
120
- () => Y({
121
- items: L.value,
149
+ path: a,
150
+ method: t,
151
+ example: n
152
+ }) => JSON.stringify([e, a, t, n].filter(A)), R = i(
153
+ () => z({
154
+ items: P.value,
122
155
  nestedKey: "children",
123
156
  filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
124
157
  getId: (e) => {
125
- const t = p("document", e), a = p("operation", e);
126
- return b({
127
- document: t?.name ?? "",
128
- path: a?.path,
129
- method: a?.method,
158
+ const a = d("document", e), t = d("operation", e);
159
+ return y({
160
+ document: a?.name ?? "",
161
+ path: t?.path,
162
+ method: t?.method,
130
163
  example: e.type === "example" ? e.name : void 0
131
164
  });
132
165
  }
133
166
  })
134
- ), w = (e) => {
135
- const t = T.value.get(b(e));
136
- return t || T.value.get(
137
- b({
167
+ ), b = (e) => {
168
+ const a = R.value.get(y(e));
169
+ return a || R.value.get(
170
+ y({
138
171
  document: e.document,
139
172
  path: e.path,
140
173
  method: e.method
141
174
  })
142
175
  );
143
- }, N = (e) => {
144
- const t = r.getEntryById(e);
145
- if (!t) {
176
+ }, _ = (e) => {
177
+ const a = r.getEntryById(e);
178
+ if (!a) {
146
179
  console.warn(`Could not find sidebar entry with id ${e} to select`);
147
180
  return;
148
181
  }
149
- if (t.type === "document") {
182
+ if (a.type === "document") {
150
183
  if (r.selectedItem.value === e) {
151
184
  r.setExpanded(e, !r.isExpanded(e));
152
185
  return;
153
186
  }
154
- return r.setSelected(e), r.setExpanded(e, !0), c.value?.push({
187
+ return r.setSelected(e), r.setExpanded(e, !0), l.value?.push({
155
188
  name: "document.overview",
156
- params: { documentSlug: t.name }
189
+ params: { documentSlug: a.name }
157
190
  });
158
191
  }
159
- if (t.type === "operation") {
192
+ if (a.type === "operation") {
160
193
  if (r.isSelected(e)) {
161
194
  r.setExpanded(e, !r.isExpanded(e));
162
195
  return;
163
196
  }
164
- const a = t.children?.find((o) => o.type === "example");
165
- return a ? (r.setSelected(a.id), r.setExpanded(a.id, !0)) : r.setSelected(e), c.value?.push({
197
+ const t = a.children?.find((n) => n.type === "example");
198
+ return t ? (r.setSelected(t.id), r.setExpanded(t.id, !0)) : r.setSelected(e), l.value?.push({
166
199
  name: "example",
167
200
  params: {
168
- documentSlug: p("document", t)?.name,
169
- pathEncoded: encodeURIComponent(t.path),
170
- method: t.method,
171
- exampleName: a?.name ?? "default"
201
+ documentSlug: d("document", a)?.name,
202
+ pathEncoded: encodeURIComponent(a.path),
203
+ method: a.method,
204
+ exampleName: t?.name ?? "default"
172
205
  }
173
206
  });
174
207
  }
175
- if (t.type === "example") {
208
+ if (a.type === "example") {
176
209
  r.setSelected(e);
177
- const a = p("operation", t);
178
- return c.value?.push({
210
+ const t = d("operation", a);
211
+ return l.value?.push({
179
212
  name: "example",
180
213
  params: {
181
- documentSlug: p("document", t)?.name,
182
- pathEncoded: encodeURIComponent(a?.path ?? ""),
183
- method: a?.method,
184
- exampleName: t.name
214
+ documentSlug: d("document", a)?.name,
215
+ pathEncoded: encodeURIComponent(t?.path ?? ""),
216
+ method: t?.method,
217
+ exampleName: a.name
185
218
  }
186
219
  });
187
220
  }
188
- if (t.type === "text")
189
- return c.value?.push({
221
+ if (a.type === "text")
222
+ return l.value?.push({
190
223
  name: "document.overview",
191
224
  params: {
192
- documentSlug: p("document", t)?.name
225
+ documentSlug: d("document", a)?.name
193
226
  }
194
227
  });
195
228
  r.setExpanded(e, !r.isExpanded(e));
196
- }, ue = async () => {
197
- if (!n.value)
229
+ }, pe = async () => {
230
+ if (!o.value)
198
231
  return;
199
- const e = n.value.workspace["x-scalar-active-tab"] ?? 0, t = n.value.workspace["x-scalar-tabs"]?.[e];
200
- t && await c.value?.replace(t.path);
201
- }, P = (e) => {
202
- e && n.value?.buildSidebar(e);
203
- }, ie = (e) => {
204
- const t = E.value?.["x-scalar-navigation"]?.name;
205
- if (!t)
232
+ const e = o.value.workspace["x-scalar-active-tab"] ?? 0, a = o.value.workspace["x-scalar-tabs"]?.[e];
233
+ a && await l.value?.replace(a.path);
234
+ }, F = (e) => {
235
+ e && o.value?.buildSidebar(e);
236
+ }, me = (e) => {
237
+ const a = T.value?.["x-scalar-navigation"]?.name;
238
+ if (!a)
206
239
  return;
207
- const a = w({
208
- document: t,
240
+ const t = b({
241
+ document: a,
209
242
  path: e.path,
210
243
  method: e.method,
211
244
  example: e.exampleKey
212
245
  });
213
- (!a || a.type !== "example") && (P(t), d.value && K(d.value));
214
- }, le = 288, pe = u(() => n.value?.workspace?.["x-scalar-sidebar-width"] ?? le), de = (e) => n.value?.update("x-scalar-sidebar-width", e), k = l(!0), me = "x-scalar-tabs", ve = "x-scalar-active-tab", I = (e) => {
215
- const t = s("method", e), a = s("pathEncoded", e), o = s("documentSlug", e), i = s("workspaceSlug", e);
246
+ (!t || t.type !== "example") && (F(a), m.value && H(m.value));
247
+ }, de = 288, ve = i(() => o.value?.workspace?.["x-scalar-sidebar-width"] ?? de), fe = (e) => o.value?.update("x-scalar-sidebar-width", e), S = p(!0), he = "x-scalar-tabs", we = "x-scalar-active-tab", U = (e) => {
248
+ const a = c("method", e), t = c("pathEncoded", e), n = c("documentSlug", e), u = c("workspaceSlug", e);
216
249
  return {
217
- ...X({
218
- workspace: i,
219
- document: o,
220
- path: a,
221
- method: t,
222
- getEntryByLocation: w
250
+ ...ae({
251
+ workspace: u,
252
+ document: n,
253
+ path: t,
254
+ method: a,
255
+ getEntryByLocation: b
223
256
  }),
224
- path: d.value?.path ?? ""
257
+ path: m.value?.path ?? ""
225
258
  };
226
- }, _ = u(() => n.value?.workspace[me] ?? [I(d.value)]), fe = u(() => n.value?.workspace[ve] ?? 0), F = async (e) => {
227
- const t = _.value[e];
228
- if (!t) {
259
+ }, K = i(() => o.value?.workspace[he] ?? [U(m.value)]), xe = i(() => o.value?.workspace[we] ?? 0), q = async (e) => {
260
+ const a = K.value[e];
261
+ if (!a) {
229
262
  console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
230
263
  return;
231
264
  }
232
- const a = `${window.location.origin}${t.path}`;
265
+ const t = `${window.location.origin}${a.path}`;
233
266
  try {
234
- await navigator.clipboard.writeText(a);
235
- } catch (o) {
236
- console.error("Failed to copy URL to clipboard:", o);
267
+ await navigator.clipboard.writeText(t);
268
+ } catch (n) {
269
+ console.error("Failed to copy URL to clipboard:", n);
237
270
  }
238
- }, he = (e) => {
239
- const t = s("workspaceSlug", e), a = s("documentSlug", e);
240
- if (x.value = t, f.value = a, A.value = s("method", e), C.value = s("pathEncoded", e), U.value = s("exampleName", e), !!t) {
241
- if (e.path !== "" && ee.setCurrentPath(e.path), t !== y.value?.id)
242
- return ce(t);
243
- if (a && a !== n.value?.workspace[M.workspace.activeDocument])
244
- return n?.value?.update("x-scalar-active-document", a);
245
- we(e), K(e);
271
+ }, ge = (e) => {
272
+ const a = c("workspaceSlug", e), t = c("documentSlug", e);
273
+ if (v.value = c("namespace", e), k.value = a, w.value = t, B.value = c("method", e), O.value = c("pathEncoded", e), $.value = c("exampleName", e), !(!v.value || !a)) {
274
+ if (e.path !== "" && ne.setCurrentPath(e.path), g(v.value, a) !== W.value?.id)
275
+ return ie(v.value, a);
276
+ t && t !== o.value?.workspace[X.workspace.activeDocument] && o?.value?.update("x-scalar-active-document", t), be(e), H(e);
246
277
  }
247
- }, we = (e) => {
248
- const t = n.value?.workspace["x-scalar-tabs"] ?? [], a = n.value?.workspace["x-scalar-active-tab"] ?? 0, o = t[a];
249
- !o || o.path === e.path || (t[a] = I(e));
250
- }, K = (e) => {
251
- const t = s("documentSlug", e);
252
- if (!t) {
278
+ }, be = (e) => {
279
+ const a = o.value?.workspace["x-scalar-tabs"] ?? [], t = o.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
280
+ !n || n.path === e.path || (a[t] = U(e));
281
+ }, H = (e) => {
282
+ const a = c("documentSlug", e);
283
+ if (!a) {
253
284
  r.setSelected(null);
254
285
  return;
255
286
  }
256
- const a = w({
257
- document: t,
258
- path: s("pathEncoded", e),
259
- method: s("method", e),
260
- example: s("exampleName", e)
287
+ const t = b({
288
+ document: a,
289
+ path: c("pathEncoded", e),
290
+ method: c("method", e),
291
+ example: c("exampleName", e)
261
292
  });
262
- a && (r.setSelected(a.id), r.setExpanded(a.id, !0));
293
+ t && (r.setSelected(t.id), r.setExpanded(t.id, !0));
263
294
  };
264
- te({
265
- eventBus: v,
266
- router: c,
267
- store: n,
268
- navigateToCurrentTab: ue,
269
- rebuildSidebar: P,
270
- onAfterExampleCreation: ie,
271
- onSelectSidebarItem: N,
272
- onCopyTabUrl: (e) => F(e),
273
- onToggleSidebar: () => k.value = !k.value
295
+ re({
296
+ eventBus: h,
297
+ router: l,
298
+ store: o,
299
+ navigateToCurrentTab: pe,
300
+ rebuildSidebar: F,
301
+ onAfterExampleCreation: me,
302
+ onSelectSidebarItem: _,
303
+ onCopyTabUrl: (e) => q(e),
304
+ onToggleSidebar: () => S.value = !S.value
274
305
  });
275
- function Le(e) {
276
- return e && (c.value = e), {
306
+ function Pe(e) {
307
+ return e && (l.value = e), {
277
308
  /** Active workspace store */
278
- store: n,
309
+ store: o,
279
310
  sidebar: {
280
311
  state: r,
281
- width: pe,
282
- isOpen: k,
283
- handleSelectItem: N,
284
- handleSidebarWidthUpdate: de,
285
- getEntryByLocation: w
312
+ width: ve,
313
+ isOpen: S,
314
+ handleSelectItem: _,
315
+ handleSidebarWidthUpdate: fe,
316
+ getEntryByLocation: b
286
317
  },
287
318
  tabs: {
288
- state: _,
289
- activeTabIndex: fe,
290
- copyTabUrl: F
319
+ state: K,
320
+ activeTabIndex: xe,
321
+ copyTabUrl: q
291
322
  },
292
323
  workspace: {
293
- create: O,
294
- workspaceList: S,
295
- activeWorkspace: y,
296
- setId: B,
297
- isOpen: u(() => !!(x.value && !f.value))
324
+ create: N,
325
+ workspaceList: I,
326
+ activeWorkspace: W,
327
+ navigateToWorkspace: L,
328
+ isOpen: i(() => !!(k.value && !w.value))
298
329
  },
299
- eventBus: v,
300
- router: c,
301
- currentRoute: d,
302
- loading: m,
330
+ eventBus: h,
331
+ router: l,
332
+ currentRoute: m,
333
+ loading: f,
303
334
  activeEntities: {
304
- workspaceSlug: x,
305
- documentSlug: f,
306
- path: C,
307
- method: A,
308
- exampleName: U
335
+ namespace: v,
336
+ workspaceSlug: k,
337
+ documentSlug: w,
338
+ path: O,
339
+ method: B,
340
+ exampleName: $
309
341
  },
310
- environment: re,
311
- document: E
342
+ environment: se,
343
+ document: T
312
344
  };
313
345
  }
314
346
  export {
315
- Le as useAppState
347
+ Pe as useAppState
316
348
  };
@@ -32,7 +32,7 @@ export type CollectionProps = RouteProps & ({
32
32
  collectionType: 'workspace';
33
33
  document: null;
34
34
  });
35
- export type ScalarClientAppRouteParams = 'workspaceSlug' | 'documentSlug' | 'pathEncoded' | 'method' | 'exampleName';
35
+ export type ScalarClientAppRouteParams = 'namespace' | 'workspaceSlug' | 'documentSlug' | 'pathEncoded' | 'method' | 'exampleName';
36
36
  /** Routes for the API client app and web, the same as modal + workspace routes */
37
37
  export declare const ROUTES: ({
38
38
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAGlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kEAAkE,CAAA;AAU7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,WAAW,CA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