@scalar/api-client 2.2.6 → 2.2.8

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 (58) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/components/AddressBar/AddressBar.vue.js +2 -2
  3. package/dist/components/AddressBar/AddressBar.vue2.js +1 -1
  4. package/dist/components/AddressBar/AddressBarServer.vue.js +18 -18
  5. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  6. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +108 -106
  7. package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +20 -20
  8. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts +1 -1
  9. package/dist/components/CommandPalette/TheCommandPalette.vue.js +2 -2
  10. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +12 -12
  11. package/dist/components/HttpMethod/HttpMethod.vue.js +2 -2
  12. package/dist/components/HttpMethod/HttpMethod.vue2.js +12 -12
  13. package/dist/components/HttpMethod/index.d.ts +0 -1
  14. package/dist/components/HttpMethod/index.d.ts.map +1 -1
  15. package/dist/components/HttpMethod/index.js +2 -4
  16. package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
  17. package/dist/components/ImportCollection/ImportCollectionModal.vue.js +119 -102
  18. package/dist/components/OpenApiClientButton.vue.d.ts +1 -0
  19. package/dist/components/OpenApiClientButton.vue.d.ts.map +1 -1
  20. package/dist/components/OpenApiClientButton.vue.js +2 -2
  21. package/dist/components/OpenApiClientButton.vue2.js +23 -17
  22. package/dist/components/Search/useSearch.d.ts.map +1 -1
  23. package/dist/components/Search/useSearch.js +45 -41
  24. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  25. package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
  26. package/dist/layouts/Modal/ApiClientModal.vue2.js +28 -23
  27. package/dist/libs/create-client.d.ts +1 -0
  28. package/dist/libs/create-client.d.ts.map +1 -1
  29. package/dist/libs/create-client.js +31 -30
  30. package/dist/libs/index.d.ts +1 -0
  31. package/dist/libs/index.d.ts.map +1 -1
  32. package/dist/libs/index.js +28 -24
  33. package/dist/libs/postman.d.ts +11 -0
  34. package/dist/libs/postman.d.ts.map +1 -0
  35. package/dist/libs/postman.js +39 -0
  36. package/dist/style.css +1 -1
  37. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
  38. package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +65 -62
  39. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
  40. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +1 -1
  41. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +82 -84
  42. package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
  43. package/dist/views/Request/RequestSection/RequestBody.vue.js +2 -2
  44. package/dist/views/Request/RequestSection/RequestBody.vue2.js +27 -24
  45. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  46. package/dist/views/Request/RequestSidebar.vue.js +4 -4
  47. package/dist/views/Request/RequestSidebar.vue2.js +32 -30
  48. package/dist/views/Request/RequestSubpageHeader.vue.d.ts.map +1 -1
  49. package/dist/views/Request/RequestSubpageHeader.vue.js +3 -3
  50. package/dist/views/Request/RequestSubpageHeader.vue2.js +34 -32
  51. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  52. package/dist/views/Request/components/WorkspaceDropdown.vue.js +1 -1
  53. package/dist/views/Request/libs/live-sync.d.ts.map +1 -1
  54. package/dist/views/Request/libs/live-sync.js +77 -78
  55. package/package.json +10 -9
  56. package/dist/components/HttpMethod/helpers.d.ts +0 -4
  57. package/dist/components/HttpMethod/helpers.d.ts.map +0 -1
  58. package/dist/components/HttpMethod/helpers.js +0 -5
@@ -1,26 +1,25 @@
1
- import { isHTTPMethod as D } from "../../../components/HttpMethod/helpers.js";
2
- import { collectionSchema as b, requestSchema as O, serverSchema as V, tagSchema as M, securitySchemeSchema as S, createExampleFromRequest as H } from "@scalar/oas-utils/entities/spec";
3
- import { schemaModel as R } from "@scalar/oas-utils/helpers";
4
- import { getNestedValue as Z } from "@scalar/object-utils/nested";
1
+ import { collectionSchema as b, requestSchema as O, serverSchema as V, tagSchema as M, securitySchemeSchema as S, createExampleFromRequest as D } from "@scalar/oas-utils/entities/spec";
2
+ import { isHttpMethod as H, schemaModel as R } from "@scalar/oas-utils/helpers";
3
+ import { getNestedValue as N } from "@scalar/object-utils/nested";
5
4
  import j from "microdiff";
6
5
  import { z as i } from "zod";
7
6
  const x = (e, s = []) => {
8
7
  const t = [];
9
8
  let a = !1;
10
- for (let n = 0; n < e.length; n++) {
9
+ for (let r = 0; r < e.length; r++) {
11
10
  if (a) {
12
11
  a = !1;
13
12
  continue;
14
13
  }
15
- const r = e[n], u = e[n + 1];
14
+ const n = e[r], u = e[r + 1];
16
15
  if (s.length)
17
- r.path = [...s, ...r.path], u && (u.path = [...s, ...u.path]);
18
- else if (r.path[0] !== "paths") {
19
- t.push(r);
16
+ n.path = [...s, ...n.path], u && (u.path = [...s, ...u.path]);
17
+ else if (n.path[0] !== "paths") {
18
+ t.push(n);
20
19
  continue;
21
20
  }
22
- if (r.type === "REMOVE" && (u == null ? void 0 : u.type) === "CREATE") {
23
- const [, l, p] = r.path, [, o, h] = u.path, c = ["paths", o];
21
+ if (n.type === "REMOVE" && (u == null ? void 0 : u.type) === "CREATE") {
22
+ const [, l, p] = n.path, [, o, h] = u.path, c = ["paths", o];
24
23
  if (l !== o && t.push({
25
24
  type: "CHANGE",
26
25
  path: ["paths", "path"],
@@ -32,20 +31,20 @@ const x = (e, s = []) => {
32
31
  oldValue: p,
33
32
  value: h
34
33
  }), c.push(h)), s.length === 0) {
35
- const y = j(r.oldValue, u.value);
34
+ const y = j(n.oldValue, u.value);
36
35
  if (y.length) {
37
- const f = x(y, c);
38
- t.push(...f);
36
+ const E = x(y, c);
37
+ t.push(...E);
39
38
  }
40
39
  }
41
40
  a = !0;
42
- } else r.type === "CREATE" && r.path.length > 3 && typeof r.path.at(-1) != "number" ? t.push({ ...r, type: "CHANGE", oldValue: void 0 }) : r.type === "REMOVE" && r.path.length > 3 && typeof r.path.at(-1) != "number" ? t.push({ ...r, type: "CHANGE", value: void 0 }) : t.push(r);
41
+ } else n.type === "CREATE" && n.path.length > 3 && typeof n.path.at(-1) != "number" ? t.push({ ...n, type: "CHANGE", oldValue: void 0 }) : n.type === "REMOVE" && n.path.length > 3 && typeof n.path.at(-1) != "number" ? t.push({ ...n, type: "CHANGE", value: void 0 }) : t.push(n);
43
42
  }
44
43
  return t;
45
44
  }, v = (e, s, t) => {
46
45
  for (const a of e) {
47
- const n = s[a];
48
- if (t(n)) return n;
46
+ const r = s[a];
47
+ if (t(r)) return r;
49
48
  }
50
49
  return null;
51
50
  }, d = (e) => e instanceof i.ZodOptional ? d(e.unwrap()) : e instanceof i.ZodDefault ? d(e._def.innerType) : e, G = (e, s) => {
@@ -75,18 +74,18 @@ const x = (e, s = []) => {
75
74
  }, m = (e, s) => {
76
75
  const t = G(e, s.path);
77
76
  if (!t) return null;
78
- const a = s.path.join("."), n = s.path.slice(0, -1).join(".");
77
+ const a = s.path.join("."), r = s.path.slice(0, -1).join(".");
79
78
  if (s.type === "REMOVE")
80
79
  return {
81
80
  path: a,
82
- pathMinusOne: n,
81
+ pathMinusOne: r,
83
82
  value: void 0
84
83
  };
85
- const r = R(s.value, t, !1);
86
- return r ? {
84
+ const n = R(s.value, t, !1);
85
+ return n ? {
87
86
  path: a,
88
- pathMinusOne: n,
89
- value: r
87
+ pathMinusOne: r,
88
+ value: n
90
89
  } : null;
91
90
  }, K = (e, { activeCollection: s }, { collectionMutators: t }) => {
92
91
  if (!s.value) return !1;
@@ -96,13 +95,13 @@ const x = (e, s = []) => {
96
95
  path: e.path
97
96
  });
98
97
  if (!a) return !1;
99
- const n = [
100
- ...Z(s.value, a.pathMinusOne)
98
+ const r = [
99
+ ...N(s.value, a.pathMinusOne)
101
100
  ];
102
- e.type === "CREATE" ? n.push(a.value) : e.type === "REMOVE" && n.pop(), t.edit(
101
+ e.type === "CREATE" ? r.push(a.value) : e.type === "REMOVE" && r.pop(), t.edit(
103
102
  s.value.uid,
104
103
  a.pathMinusOne,
105
- n
104
+ r
106
105
  );
107
106
  } else {
108
107
  const a = m(b, e);
@@ -114,90 +113,90 @@ const x = (e, s = []) => {
114
113
  );
115
114
  }
116
115
  return !0;
117
- }, T = (e, s) => {
118
- const { requests: t, requestExamples: a, requestExampleMutators: n } = s, r = t[e];
119
- r == null || r.examples.forEach((u) => {
120
- const l = H(
121
- r,
116
+ }, Z = (e, s) => {
117
+ const { requests: t, requestExamples: a, requestExampleMutators: r } = s, n = t[e];
118
+ n == null || n.examples.forEach((u) => {
119
+ const l = D(
120
+ n,
122
121
  a[u].name
123
122
  );
124
- l && n.set({
123
+ l && r.set({
125
124
  ...l,
126
125
  uid: u
127
126
  });
128
127
  });
129
128
  }, L = (e, { activeCollection: s }, t) => {
130
129
  if (!s.value) return !1;
131
- const { requests: a, requestMutators: n } = t, [, r, u, ...l] = e.path;
132
- if (r === "path" && e.type === "CHANGE")
130
+ const { requests: a, requestMutators: r } = t, [, n, u, ...l] = e.path;
131
+ if (n === "path" && e.type === "CHANGE")
133
132
  s.value.requests.forEach((p) => {
134
- a[p].path === e.oldValue && n.edit(p, "path", e.value);
133
+ a[p].path === e.oldValue && r.edit(p, "path", e.value);
135
134
  });
136
135
  else if (u === "method" && e.type === "CHANGE")
137
136
  s.value.requests.forEach((p) => {
138
- a[p].method === e.oldValue && a[p].path === r && n.edit(p, "method", e.value);
137
+ a[p].method === e.oldValue && a[p].path === n && r.edit(p, "method", e.value);
139
138
  });
140
139
  else if (e.type !== "CHANGE" && typeof l.at(-1) == "number") {
141
140
  const p = v(
142
141
  s.value.requests,
143
142
  a,
144
- (c) => c.path === r && c.method === u
143
+ (c) => c.path === n && c.method === u
145
144
  ), o = m(O, {
146
145
  ...e,
147
146
  path: e.path.slice(3)
148
147
  });
149
148
  if (!p || !o) return !1;
150
- const h = [...Z(p, o.pathMinusOne)];
151
- e.type === "CREATE" ? h.push(o.value) : e.type === "REMOVE" && h.pop(), n.edit(p.uid, o.pathMinusOne, h), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, t);
149
+ const h = [...N(p, o.pathMinusOne)];
150
+ e.type === "CREATE" ? h.push(o.value) : e.type === "REMOVE" && h.pop(), r.edit(p.uid, o.pathMinusOne, h), (e.path[3] === "parameters" || e.path[3] === "requestBody") && Z(p.uid, t);
152
151
  } else if (e.type === "CREATE") {
153
- const [[p, o]] = Object.entries(e.value), h = u ? e.value : o, c = u || p, y = V.array().parse(h.servers ?? []), { security: f, ...N } = h, g = {
154
- ...N,
155
- method: D(c) ? c : "get",
156
- path: r,
152
+ const [[p, o]] = Object.entries(e.value), h = u ? e.value : o, c = u || p, y = V.array().parse(h.servers ?? []), { security: E, ...T } = h, g = {
153
+ ...T,
154
+ method: H(c) ? c : "get",
155
+ path: n,
157
156
  parameters: h.parameters ?? [],
158
- servers: y.map((E) => E.uid)
157
+ servers: y.map((f) => f.uid)
159
158
  };
160
- f != null && f.length && (g.security = f.map((E) => {
161
- if (Object.keys(E).length) {
162
- const [A] = Object.keys(E);
159
+ E != null && E.length && (g.security = E.map((f) => {
160
+ if (Object.keys(f).length) {
161
+ const [A] = Object.keys(f);
163
162
  return {
164
- [A]: E[A]
163
+ [A]: f[A]
165
164
  };
166
- } else return E;
165
+ } else return f;
167
166
  }));
168
167
  const q = R(g, O, !1);
169
168
  if (!q) return !1;
170
- n.add(q, s.value.uid);
169
+ r.add(q, s.value.uid);
171
170
  } else if (e.type === "REMOVE") {
172
171
  const p = v(
173
172
  s.value.requests,
174
173
  a,
175
- (o) => o.path === r && o.method === u
174
+ (o) => o.path === n && o.method === u
176
175
  );
177
176
  if (!p) return !1;
178
- n.delete(p, s.value.uid);
177
+ r.delete(p, s.value.uid);
179
178
  } else if (e.type === "CHANGE") {
180
179
  const p = v(
181
180
  s.value.requests,
182
181
  a,
183
- (h) => h.path === r && h.method === u
182
+ (h) => h.path === n && h.method === u
184
183
  ), o = m(O, { ...e, path: l });
185
184
  if (!p || !o) return !1;
186
- n.edit(p.uid, o.path, o.value), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, t);
185
+ r.edit(p.uid, o.path, o.value), (e.path[3] === "parameters" || e.path[3] === "requestBody") && Z(p.uid, t);
187
186
  }
188
187
  return !0;
189
- }, W = (e, { activeCollection: s }, { servers: t, serverMutators: a }) => {
188
+ }, P = (e, { activeCollection: s }, { servers: t, serverMutators: a }) => {
190
189
  if (!s.value) return !1;
191
- const [, n, ...r] = e.path;
192
- if (r != null && r.length) {
193
- const u = s.value.servers[n], l = t[u], p = m(V, { ...e, path: r });
190
+ const [, r, ...n] = e.path;
191
+ if (n != null && n.length) {
192
+ const u = s.value.servers[r], l = t[u], p = m(V, { ...e, path: n });
194
193
  if (!l || !p) return !1;
195
- const h = e.type === "REMOVE" && r[r.length - 1] === "variables" ? {} : p.value;
194
+ const h = e.type === "REMOVE" && n[n.length - 1] === "variables" ? {} : p.value;
196
195
  a.edit(u, p.path, h);
197
196
  } else if (e.type === "REMOVE") {
198
- if (!s.value.servers[n]) return !1;
197
+ if (!s.value.servers[r]) return !1;
199
198
  a.delete(
200
- s.value.servers[n],
199
+ s.value.servers[r],
201
200
  s.value.uid
202
201
  );
203
202
  } else if (e.type === "CREATE") {
@@ -206,15 +205,15 @@ const x = (e, s = []) => {
206
205
  a.add(u, s.value.uid);
207
206
  }
208
207
  return !0;
209
- }, I = (e, { activeCollection: s }, { tags: t, tagMutators: a }) => {
208
+ }, W = (e, { activeCollection: s }, { tags: t, tagMutators: a }) => {
210
209
  if (!s.value) return !1;
211
- const [, n, ...r] = e.path;
212
- if (r != null && r.length) {
213
- const u = s.value.tags[n], l = t[u], p = m(M, { ...e, path: r });
210
+ const [, r, ...n] = e.path;
211
+ if (n != null && n.length) {
212
+ const u = s.value.tags[r], l = t[u], p = m(M, { ...e, path: n });
214
213
  if (!l || !p) return !1;
215
214
  a.edit(u, p.path, p.value);
216
215
  } else if (e.type === "REMOVE") {
217
- const u = s.value.tags[n], l = t[u];
216
+ const u = s.value.tags[r], l = t[u];
218
217
  if (!l) return !1;
219
218
  a.delete(l, s.value.uid);
220
219
  } else if (e.type === "CREATE") {
@@ -226,22 +225,22 @@ const x = (e, s = []) => {
226
225
  }, w = (e, s, t) => {
227
226
  const a = d(e);
228
227
  if (a instanceof i.ZodUnion || a instanceof i.ZodDiscriminatedUnion) {
229
- for (const n of a.options)
230
- if (n instanceof i.ZodObject && s in n.shape && n.shape[s] instanceof i.ZodLiteral && n.shape[s].value === t)
231
- return n;
228
+ for (const r of a.options)
229
+ if (r instanceof i.ZodObject && s in r.shape && r.shape[s] instanceof i.ZodLiteral && r.shape[s].value === t)
230
+ return r;
232
231
  }
233
232
  return null;
234
- }, J = (e, { activeCollection: s }, { securitySchemes: t, securitySchemeMutators: a }) => {
233
+ }, I = (e, { activeCollection: s }, { securitySchemes: t, securitySchemeMutators: a }) => {
235
234
  if (!s.value) return !1;
236
- const [, , n, ...r] = e.path, u = t[n] ?? v(
235
+ const [, , r, ...n] = e.path, u = t[r] ?? v(
237
236
  s.value.securitySchemes,
238
237
  t,
239
- (l) => l.nameKey === n
238
+ (l) => l.nameKey === r
240
239
  );
241
- if (r != null && r.length) {
240
+ if (n != null && n.length) {
242
241
  const l = w(S, "type", u == null ? void 0 : u.type);
243
242
  if (!l) return !1;
244
- const p = m(l, { ...e, path: r });
243
+ const p = m(l, { ...e, path: n });
245
244
  if (!p) return !1;
246
245
  const o = p.path;
247
246
  a.edit(u.uid, o, p.value);
@@ -259,9 +258,9 @@ export {
259
258
  v as findResource,
260
259
  K as mutateCollectionDiff,
261
260
  L as mutateRequestDiff,
262
- J as mutateSecuritySchemeDiff,
263
- W as mutateServerDiff,
264
- I as mutateTagDiff,
261
+ I as mutateSecuritySchemeDiff,
262
+ P as mutateServerDiff,
263
+ W as mutateTagDiff,
265
264
  w as narrowUnionSchema,
266
265
  m as parseDiff,
267
266
  G as traverseZodSchema
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.2.6",
21
+ "version": "2.2.8",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -159,20 +159,21 @@
159
159
  "whatwg-mimetype": "^4.0.0",
160
160
  "yaml": "^2.4.5",
161
161
  "zod": "^3.23.8",
162
- "@scalar/components": "0.13.1",
162
+ "@scalar/components": "0.13.2",
163
163
  "@scalar/draggable": "0.1.7",
164
164
  "@scalar/icons": "0.1.2",
165
- "@scalar/import": "0.2.2",
165
+ "@scalar/import": "0.2.3",
166
+ "@scalar/oas-utils": "0.2.85",
166
167
  "@scalar/object-utils": "1.1.12",
167
- "@scalar/oas-utils": "0.2.84",
168
168
  "@scalar/openapi-parser": "0.8.10",
169
169
  "@scalar/openapi-types": "0.1.5",
170
170
  "@scalar/themes": "0.9.54",
171
171
  "@scalar/types": "0.0.23",
172
- "@scalar/use-codemirror": "0.11.45",
172
+ "@scalar/use-codemirror": "0.11.46",
173
+ "@scalar/postman-to-openapi": "0.1.8",
173
174
  "@scalar/use-hooks": "0.1.7",
174
- "@scalar/use-tooltip": "1.0.4",
175
- "@scalar/use-toasts": "0.7.7"
175
+ "@scalar/use-toasts": "0.7.7",
176
+ "@scalar/use-tooltip": "1.0.4"
176
177
  },
177
178
  "devDependencies": {
178
179
  "@types/js-cookie": "^3.0.6",
@@ -189,8 +190,8 @@
189
190
  "vite": "^5.4.10",
190
191
  "vite-svg-loader": "^5.1.0",
191
192
  "vitest": "^1.6.0",
192
- "@scalar/galaxy": "0.2.16",
193
- "@scalar/build-tooling": "0.1.12"
193
+ "@scalar/build-tooling": "0.1.12",
194
+ "@scalar/galaxy": "0.2.16"
194
195
  },
195
196
  "scripts": {
196
197
  "build": "vite build && pnpm types:build && tsc-alias -p tsconfig.build.json",
@@ -1,4 +0,0 @@
1
- import { type RequestMethod } from '@scalar/oas-utils/entities/spec';
2
- /** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
3
- export declare const isHTTPMethod: (method: string) => method is RequestMethod;
4
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/HttpMethod/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,iCAAiC,CAAA;AAExC,yFAAyF;AACzF,eAAO,MAAM,YAAY,WAAY,MAAM,KAAG,MAAM,IAAI,aACN,CAAA"}
@@ -1,5 +0,0 @@
1
- import { requestMethods as o } from "@scalar/oas-utils/entities/spec";
2
- const s = (e) => o.includes(e);
3
- export {
4
- s as isHTTPMethod
5
- };