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