@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.
Files changed (103) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  3. package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
  4. package/dist/style.css +1 -1
  5. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +8 -0
  6. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  7. package/dist/v2/blocks/operation-block/OperationBlock.vue.js +33 -29
  8. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +6 -0
  9. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
  10. package/dist/v2/blocks/operation-block/components/Header.vue.js +2 -2
  11. package/dist/v2/blocks/operation-block/components/Header.vue2.js +46 -29
  12. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  13. package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.d.ts +15 -0
  14. package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.d.ts.map +1 -0
  15. package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.js +125 -0
  16. package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue2.js +4 -0
  17. package/dist/v2/components/sidebar/Sidebar.vue.d.ts +2 -2
  18. package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  19. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +2 -2
  20. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
  21. package/dist/v2/features/app/App.vue.d.ts +8 -0
  22. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  23. package/dist/v2/features/app/App.vue.js +95 -108
  24. package/dist/v2/features/app/app-state.d.ts +46 -16
  25. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  26. package/dist/v2/features/app/app-state.js +174 -161
  27. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +2 -2
  28. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  29. package/dist/v2/features/app/components/AppSidebar.vue.js +3 -3
  30. package/dist/v2/features/app/components/WebTopNav.vue.d.ts +3 -3
  31. package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +1 -1
  32. package/dist/v2/features/app/helpers/filter-workspaces.d.ts +49 -0
  33. package/dist/v2/features/app/helpers/filter-workspaces.d.ts.map +1 -0
  34. package/dist/v2/features/app/helpers/filter-workspaces.js +5 -0
  35. package/dist/v2/features/app/helpers/group-workspaces.d.ts +24 -0
  36. package/dist/v2/features/app/helpers/group-workspaces.d.ts.map +1 -0
  37. package/dist/v2/features/app/helpers/group-workspaces.js +23 -0
  38. package/dist/v2/features/app/hooks/use-document-watcher.js +8 -8
  39. package/dist/v2/features/collection/components/Environment.vue.d.ts.map +1 -1
  40. package/dist/v2/features/collection/components/Environment.vue.js +12 -11
  41. package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
  42. package/dist/v2/features/collection/components/Settings.vue.js +17 -25
  43. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +1 -1
  44. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
  45. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +115 -118
  46. package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.d.ts.map +1 -1
  47. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts +14 -4
  48. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts.map +1 -1
  49. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.js +5 -6
  50. package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.d.ts.map +1 -1
  51. package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts +16 -0
  52. package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -0
  53. package/dist/v2/features/command-palette/helpers/load-document-from-source.js +34 -0
  54. package/dist/v2/features/command-palette/index.d.ts +4 -0
  55. package/dist/v2/features/command-palette/index.d.ts.map +1 -0
  56. package/dist/v2/features/command-palette/index.js +8 -0
  57. package/dist/v2/features/environments/EnvironmentsList.vue.d.ts +4 -0
  58. package/dist/v2/features/environments/EnvironmentsList.vue.d.ts.map +1 -1
  59. package/dist/v2/features/environments/EnvironmentsList.vue.js +29 -27
  60. package/dist/v2/features/environments/components/Environment.vue.d.ts +1 -0
  61. package/dist/v2/features/environments/components/Environment.vue.d.ts.map +1 -1
  62. package/dist/v2/features/environments/components/Environment.vue.js +37 -24
  63. package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
  64. package/dist/v2/features/modal/Modal.vue.js +2 -2
  65. package/dist/v2/features/modal/Modal.vue2.js +39 -38
  66. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  67. package/dist/v2/features/operation/Operation.vue.js +35 -26
  68. package/dist/v2/workspace-events.d.ts.map +1 -1
  69. package/dist/v2/workspace-events.js +7 -0
  70. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  71. package/package.json +15 -15
  72. package/dist/v2/features/import-listener/ImportListener.vue.d.ts +0 -52
  73. package/dist/v2/features/import-listener/ImportListener.vue.d.ts.map +0 -1
  74. package/dist/v2/features/import-listener/ImportListener.vue.js +0 -91
  75. package/dist/v2/features/import-listener/ImportListener.vue2.js +0 -4
  76. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts +0 -7
  77. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts.map +0 -1
  78. package/dist/v2/features/import-listener/components/DropEventListener.vue.js +0 -81
  79. package/dist/v2/features/import-listener/components/DropEventListener.vue2.js +0 -4
  80. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts +0 -40
  81. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts.map +0 -1
  82. package/dist/v2/features/import-listener/components/ImportModal.vue.js +0 -170
  83. package/dist/v2/features/import-listener/components/ImportModal.vue3.js +0 -5
  84. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts +0 -29
  85. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts.map +0 -1
  86. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.js +0 -83
  87. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue2.js +0 -4
  88. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts +0 -8
  89. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts.map +0 -1
  90. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.js +0 -4
  91. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts +0 -15
  92. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts.map +0 -1
  93. package/dist/v2/features/import-listener/helpers/load-document-from-source.js +0 -28
  94. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts +0 -15
  95. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts.map +0 -1
  96. package/dist/v2/features/import-listener/helpers/wait-for-condition.js +0 -16
  97. package/dist/v2/features/import-listener/index.d.ts +0 -2
  98. package/dist/v2/features/import-listener/index.d.ts.map +0 -1
  99. package/dist/v2/features/import-listener/index.js +0 -4
  100. /package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.d.ts +0 -0
  101. /package/dist/v2/features/{import-listener → command-palette}/helpers/generate-unique-slug.js +0 -0
  102. /package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.d.ts +0 -0
  103. /package/dist/v2/features/{import-listener → command-palette}/helpers/import-document-to-workspace.js +0 -0
@@ -1,65 +1,66 @@
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, w = J({
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
- }), v = p(void 0), k = p(void 0), x = p(void 0), B = p(void 0), O = p(void 0), L = p(void 0), h = p(!1), l = E(null);
21
- Z(l, (e) => {
22
- e && e.afterEach((a) => ge(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 m = i(() => l.value?.currentRoute.value ?? null);
25
- function c(e, a) {
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 && Y(t) ? t : void 0 : decodeURIComponent(t);
29
+ return e === "method" ? t && J(t) ? t : void 0 : decodeURIComponent(t);
29
30
  }
30
- const W = E(null), I = p([]), o = E(null), T = i(() => o.value?.workspace.documents[x.value ?? ""] || null), se = i(() => ee(o.value, T.value)), { workspace: g } = await G(), f = (e, a) => `${e}/${a}`;
31
- I.value = await g.getAll().then(
32
- (e) => e.map(({ teamUid: a, namespace: t, slug: n, name: u }) => ({
33
- id: f(t, n),
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: u
38
+ label: c
38
39
  }))
39
40
  );
40
- const ce = async ({ namespace: e, slug: a }) => C({
41
+ const me = async ({ namespace: e, slug: a }) => N({
41
42
  plugins: [
42
- await Q({ workspaceId: f(e, a), debounceDelay: oe })
43
+ await ee({ workspaceId: h(e, a), debounceDelay: ie })
43
44
  ]
44
- }), ue = async (e, a) => {
45
- const t = await g.getItem({ namespace: e, slug: a });
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 ce({ namespace: e, slug: a });
51
- return n.loadWorkspace(t.workspace), W.value = { id: f(t.namespace, t.slug), label: t.name }, o.value = n, {
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
- }, le = async ({
56
+ }, ve = async ({
56
57
  name: e,
57
58
  teamUid: a,
58
59
  namespace: t,
59
60
  slug: n
60
61
  }) => {
61
- const u = C();
62
- await u.addDocument({
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 g.setItem(
80
+ const s = await y.setItem(
80
81
  { namespace: t, slug: n },
81
82
  {
82
83
  name: e,
83
84
  teamUid: a,
84
- workspace: u.exportWorkspace()
85
+ workspace: c.exportWorkspace()
85
86
  }
86
87
  );
87
- return I.value.push({
88
- id: f(s.namespace, s.slug),
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
- }, N = async (e, a) => {
95
- await l.value?.push({
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
- }, P = async ({
100
- key: e,
101
- name: a
100
+ }, F = async ({
101
+ teamUid: e,
102
+ namespace: a,
103
+ slug: t,
104
+ name: n
102
105
  }) => {
103
106
  o.value = null;
104
- const t = await M({
105
- defaultValue: e?.slug ?? a,
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 (s) => !await g.has({ namespace: e?.namespace ?? "local", slug: s }),
110
+ validation: async (w) => !await y.has({ namespace: a ?? "local", slug: w }),
108
111
  maxRetries: 100,
109
- transformation: te
112
+ transformation: oe
110
113
  });
111
- if (!t)
114
+ if (!c)
112
115
  return;
113
- const n = {
114
- teamUid: e?.teamUid,
115
- namespace: e?.namespace,
116
- slug: t,
117
- name: a
118
- }, u = await le(n);
119
- return await N(u.namespace, u.slug), u;
120
- }, ie = async (e, a) => {
121
- o.value = null, h.value = !0;
122
- const t = await ue(e, a);
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 u = t.workspace["x-scalar-active-tab"] ?? 0, s = t.workspace["x-scalar-tabs"], D = s?.[u];
125
- D && await l.value?.replace({
126
- path: D.path,
127
- query: m.value?.query ?? {}
128
- }), s && u >= s.length && w.emit("tabs:update:tabs", {
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
- }), s || w.emit("tabs:update:tabs", {
131
- "x-scalar-tabs": [U(m.value)],
133
+ }), m || k.emit("tabs:update:tabs", {
134
+ "x-scalar-tabs": [B(d.value)],
132
135
  "x-scalar-active-tab": 0
133
- }), h.value = !1;
136
+ }), x.value = !1;
134
137
  return;
135
138
  }
136
- const n = await P({
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
- key: { slug: "default" }
144
+ slug: "default"
139
145
  });
140
- if (h.value = !1, !n)
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
- }, _ = i(() => {
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 V(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(A);
149
- }), r = j(_), y = ({
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(A)), R = i(
155
- () => z({
156
- items: _.value,
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 = d("document", e), t = d("operation", e);
161
- return y({
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
- ), b = (e) => {
170
- const a = R.value.get(y(e));
171
- return a || R.value.get(
172
- y({
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
- }, $ = (e) => {
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), l.value?.push({
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), l.value?.push({
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: d("document", a)?.name,
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 = d("operation", a);
213
- return l.value?.push({
218
+ const t = v("operation", a);
219
+ return u.value?.push({
214
220
  name: "example",
215
221
  params: {
216
- documentSlug: d("document", a)?.name,
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 l.value?.push({
230
+ return u.value?.push({
225
231
  name: "document.overview",
226
232
  params: {
227
- documentSlug: d("document", a)?.name
233
+ documentSlug: v("document", a)?.name
228
234
  }
229
235
  });
230
236
  r.setExpanded(e, !r.isExpanded(e));
231
- }, pe = async () => {
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 l.value?.replace(a.path);
236
- }, F = (e) => {
241
+ a && await u.value?.replace(a.path);
242
+ }, q = (e) => {
237
243
  e && o.value?.buildSidebar(e);
238
- }, me = (e) => {
239
- const a = T.value?.["x-scalar-navigation"]?.name;
244
+ }, we = (e) => {
245
+ const a = C.value?.["x-scalar-navigation"]?.name;
240
246
  if (!a)
241
247
  return;
242
- const t = b({
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") && (F(a), m.value && H(m.value));
249
- }, 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) => {
250
- const a = c("method", e), t = c("pathEncoded", e), n = c("documentSlug", e), u = c("workspaceSlug", e);
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
- ...ae({
253
- workspace: u,
258
+ ...re({
259
+ workspace: c,
254
260
  document: n,
255
261
  path: t,
256
262
  method: a,
257
- getEntryByLocation: b
263
+ getEntryByLocation: E
258
264
  }),
259
- path: m.value?.path ?? ""
265
+ path: d.value?.path ?? ""
260
266
  };
261
- }, K = i(() => o.value?.workspace[he] ?? [U(m.value)]), xe = i(() => o.value?.workspace[we] ?? 0), q = async (e) => {
262
- const a = K.value[e];
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
- }, ge = (e) => {
274
- const a = c("workspaceSlug", e), t = c("documentSlug", e);
275
- if (v.value = c("namespace", e), k.value = a, x.value = t, B.value = c("method", e), O.value = c("pathEncoded", e), L.value = c("exampleName", e), !(!v.value || !a)) {
276
- if (e.path !== "" && ne.setCurrentPath(e.path), f(v.value, a) !== W.value?.id)
277
- return ie(v.value, a);
278
- t && t !== o.value?.workspace[X.workspace.activeDocument] && o?.value?.update("x-scalar-active-document", t), be(e), H(e);
279
- }
280
- }, be = (e) => {
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] = U(e));
283
- }, H = (e) => {
284
- const a = c("documentSlug", e);
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 = b({
300
+ const t = E({
290
301
  document: a,
291
- path: c("pathEncoded", e),
292
- method: c("method", e),
293
- example: c("exampleName", e)
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
- re({
298
- eventBus: w,
299
- router: l,
308
+ ce({
309
+ eventBus: k,
310
+ router: u,
300
311
  store: o,
301
- navigateToCurrentTab: pe,
302
- rebuildSidebar: F,
303
- onAfterExampleCreation: me,
304
- onSelectSidebarItem: $,
305
- onCopyTabUrl: (e) => q(e),
306
- onToggleSidebar: () => S.value = !S.value
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 _e(e) {
309
- return e && (l.value = 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: ve,
315
- isOpen: S,
316
- handleSelectItem: $,
317
- handleSidebarWidthUpdate: fe,
318
- getEntryByLocation: b
325
+ width: xe,
326
+ isOpen: T,
327
+ handleSelectItem: V,
328
+ handleSidebarWidthUpdate: ke,
329
+ getEntryByLocation: E
319
330
  },
320
331
  tabs: {
321
- state: K,
322
- activeTabIndex: xe,
323
- copyTabUrl: q
332
+ state: H,
333
+ activeTabIndex: Se,
334
+ copyTabUrl: Y
324
335
  },
325
336
  workspace: {
326
- create: P,
327
- workspaceList: I,
328
- activeWorkspace: W,
329
- navigateToWorkspace: N,
330
- isOpen: i(() => !!(k.value && !x.value))
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: w,
333
- router: l,
334
- currentRoute: m,
335
- loading: h,
344
+ eventBus: k,
345
+ router: u,
346
+ currentRoute: d,
347
+ loading: x,
336
348
  activeEntities: {
337
- namespace: v,
338
- workspaceSlug: k,
339
- documentSlug: x,
340
- path: O,
341
- method: B,
342
- exampleName: L
349
+ namespace: g,
350
+ workspaceSlug: W,
351
+ documentSlug: b,
352
+ path: _,
353
+ method: P,
354
+ exampleName: $,
355
+ teamUid: R
343
356
  },
344
- environment: se,
345
- document: T
357
+ environment: pe,
358
+ document: C
346
359
  };
347
360
  }
348
361
  export {
349
- _e as useAppState
362
+ He as useAppState
350
363
  };
@@ -1,4 +1,4 @@
1
- import { type ScalarListboxOption } from '@scalar/components';
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: ScalarListboxOption[];
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,mBAAmB,EACzB,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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= /* @__PURE__ */ p(o, [["__scopeId", "data-v-b574e7b1"]]);
3
+ import a from "../../../../_virtual/_plugin-vue_export-helper.js";
4
+ const m = /* @__PURE__ */ a(o, [["__scopeId", "data-v-6a79a4d6"]]);
5
5
  export {
6
- e as default
6
+ m as default
7
7
  };
@@ -1,4 +1,4 @@
1
- import type { ScalarListboxOption } from '@scalar/components';
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: ScalarListboxOption[];
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: ScalarListboxOption[];
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,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAO7D;;;;GAIG;;IAGD;;;OAGG;qBACc;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;IAC/B;;;OAGG;gBACS,mBAAmB,EAAE;;;;;IATjC;;;OAGG;qBACc;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;IAC/B;;;OAGG;gBACS,mBAAmB,EAAE;;;;;AAXnC,wBAuGC"}
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"}
@@ -0,0 +1,5 @@
1
+ const a = (r, t) => r.filter((e) => o(e.teamUid, t)), o = (r, t) => r === t || r === "local";
2
+ export {
3
+ o as canLoadWorkspace,
4
+ a as filterWorkspacesByTeam
5
+ };