@scalar/api-client 2.1.26 → 2.1.27

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 (59) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  3. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +149 -89
  4. package/dist/components/ImportCollection/ImportNowButton.vue.d.ts.map +1 -1
  5. package/dist/components/ImportCollection/ImportNowButton.vue.js +7 -9
  6. package/dist/layouts/App/create-api-client-app.d.ts +77 -20
  7. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  8. package/dist/layouts/App/create-api-client-app.js +14 -12
  9. package/dist/layouts/Modal/create-api-client-modal.d.ts +154 -40
  10. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  11. package/dist/layouts/Modal/create-api-client-modal.js +23 -26
  12. package/dist/layouts/Web/create-api-client-web.d.ts +77 -20
  13. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  14. package/dist/layouts/Web/create-api-client-web.js +12 -10
  15. package/dist/libs/create-client.d.ts +77 -20
  16. package/dist/libs/create-client.d.ts.map +1 -1
  17. package/dist/libs/create-client.js +60 -58
  18. package/dist/store/collections.d.ts +34 -4
  19. package/dist/store/collections.d.ts.map +1 -1
  20. package/dist/store/import-spec.d.ts +43 -4
  21. package/dist/store/import-spec.d.ts.map +1 -1
  22. package/dist/store/import-spec.js +60 -36
  23. package/dist/store/requests.d.ts +4 -1
  24. package/dist/store/requests.d.ts.map +1 -1
  25. package/dist/store/requests.js +76 -76
  26. package/dist/store/security-schemes.d.ts +2 -2
  27. package/dist/store/security-schemes.d.ts.map +1 -1
  28. package/dist/store/security-schemes.js +35 -37
  29. package/dist/store/servers.d.ts +10 -10
  30. package/dist/store/servers.d.ts.map +1 -1
  31. package/dist/store/store.d.ts +154 -40
  32. package/dist/store/store.d.ts.map +1 -1
  33. package/dist/store/store.js +27 -27
  34. package/dist/style.css +1 -1
  35. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  36. package/dist/views/Request/Request.vue.js +1 -1
  37. package/dist/views/Request/Request.vue2.js +39 -38
  38. package/dist/views/Request/RequestSection/RequestAuth/DeleteRequestAuthModal.vue.d.ts.map +1 -1
  39. package/dist/views/Request/RequestSection/RequestAuth/DeleteRequestAuthModal.vue.js +12 -12
  40. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  41. package/dist/views/Request/RequestSidebar.vue.js +4 -4
  42. package/dist/views/Request/RequestSidebar.vue2.js +107 -102
  43. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  44. package/dist/views/Request/RequestSidebarItem.vue.js +1 -1
  45. package/dist/views/Request/RequestSidebarItem.vue2.js +165 -135
  46. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts +3 -1
  47. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  48. package/dist/views/Request/RequestSidebarItemMenu.vue.js +4 -4
  49. package/dist/views/Request/RequestSidebarItemMenu.vue2.js +96 -71
  50. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  51. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts +9 -0
  52. package/dist/views/Request/hooks/useOpenApiWatcher.d.ts.map +1 -0
  53. package/dist/views/Request/hooks/useOpenApiWatcher.js +86 -0
  54. package/dist/views/Request/libs/live-sync.d.ts +59 -0
  55. package/dist/views/Request/libs/live-sync.d.ts.map +1 -0
  56. package/dist/views/Request/libs/live-sync.js +289 -0
  57. package/dist/views/Request/types/sidebar-item.d.ts +2 -0
  58. package/dist/views/Request/types/sidebar-item.d.ts.map +1 -1
  59. package/package.json +10 -8
@@ -0,0 +1,289 @@
1
+ import { isHTTPMethod as D } from "../../../components/HttpMethod/helpers.js";
2
+ import { collectionSchema as b, requestSchema as O, serverSchema as V, tagSchema as M, oasOauthFlowSchema as H, securitySchemeSchema as S, createExampleFromRequest as j } from "@scalar/oas-utils/entities/spec";
3
+ import { schemaModel as R } from "@scalar/oas-utils/helpers";
4
+ import { getNestedValue as N } from "@scalar/object-utils/nested";
5
+ import G from "microdiff";
6
+ import { z as i } from "zod";
7
+ const x = (e, r = []) => {
8
+ const t = [];
9
+ let s = !1;
10
+ for (let u = 0; u < e.length; u++) {
11
+ if (s) {
12
+ s = !1;
13
+ continue;
14
+ }
15
+ const a = e[u], n = e[u + 1];
16
+ if (r.length)
17
+ a.path = [...r, ...a.path], n && (n.path = [...r, ...n.path]);
18
+ else if (a.path[0] !== "paths") {
19
+ t.push(a);
20
+ continue;
21
+ }
22
+ if (a.type === "REMOVE" && (n == null ? void 0 : n.type) === "CREATE") {
23
+ const [, h, p] = a.path, [, o, l] = n.path, c = ["paths", o];
24
+ if (h !== o && t.push({
25
+ type: "CHANGE",
26
+ path: ["paths", "path"],
27
+ oldValue: h,
28
+ value: o
29
+ }), p && l && p !== l && (t.push({
30
+ type: "CHANGE",
31
+ path: ["paths", o, "method"],
32
+ oldValue: p,
33
+ value: l
34
+ }), c.push(l)), r.length === 0) {
35
+ const m = G(a.oldValue, n.value);
36
+ if (m.length) {
37
+ const E = x(m, c);
38
+ t.push(...E);
39
+ }
40
+ }
41
+ s = !0;
42
+ } else a.type === "CREATE" && a.path.length > 3 && typeof a.path.at(-1) != "number" ? t.push({ ...a, type: "CHANGE", oldValue: void 0 }) : a.type === "REMOVE" && a.path.length > 3 && typeof a.path.at(-1) != "number" ? t.push({ ...a, type: "CHANGE", value: void 0 }) : t.push(a);
43
+ }
44
+ return t;
45
+ }, v = (e, r, t) => {
46
+ for (const s of e) {
47
+ const u = r[s];
48
+ if (t(u)) return u;
49
+ }
50
+ return null;
51
+ }, y = (e) => e instanceof i.ZodOptional ? y(e.unwrap()) : e instanceof i.ZodDefault ? y(e._def.innerType) : e, C = (e, r) => {
52
+ let t = e;
53
+ for (const s of r) {
54
+ if (t = y(t), t instanceof i.ZodAny)
55
+ return t;
56
+ if (t instanceof i.ZodObject && typeof s == "string" && s in t.shape)
57
+ t = t.shape[s];
58
+ else if (t instanceof i.ZodArray)
59
+ if (typeof s == "number")
60
+ t = t.element;
61
+ else if (typeof s == "string")
62
+ if (t = t.element, t instanceof i.ZodObject && s in t.shape)
63
+ t = t.shape[s];
64
+ else
65
+ return null;
66
+ else
67
+ return null;
68
+ else if (t instanceof i.ZodRecord)
69
+ t = t.valueSchema;
70
+ else
71
+ return null;
72
+ t = y(t);
73
+ }
74
+ return t;
75
+ }, f = (e, r) => {
76
+ const t = C(e, r.path);
77
+ if (!t) return null;
78
+ const s = r.path.join("."), u = r.path.slice(0, -1).join(".");
79
+ if (r.type === "REMOVE")
80
+ return {
81
+ path: s,
82
+ pathMinusOne: u,
83
+ value: void 0
84
+ };
85
+ const a = R(r.value, t, !1);
86
+ return a ? {
87
+ path: s,
88
+ pathMinusOne: u,
89
+ value: a
90
+ } : null;
91
+ }, K = (e, { activeCollection: r, collectionMutators: t }) => {
92
+ if (!r.value) return !1;
93
+ if (typeof e.path[e.path.length - 1] == "number" && (e.type === "CREATE" || e.type === "REMOVE")) {
94
+ const s = f(b, {
95
+ ...e,
96
+ path: e.path
97
+ });
98
+ if (!s) return !1;
99
+ const u = [
100
+ ...N(r.value, s.pathMinusOne)
101
+ ];
102
+ e.type === "CREATE" ? u.push(s.value) : e.type === "REMOVE" && u.pop(), t.edit(
103
+ r.value.uid,
104
+ s.pathMinusOne,
105
+ u
106
+ );
107
+ } else {
108
+ const s = f(b, e);
109
+ if (!s) return !1;
110
+ t.edit(
111
+ r.value.uid,
112
+ s.path,
113
+ s.value
114
+ );
115
+ }
116
+ return !0;
117
+ }, T = (e, r) => {
118
+ const { requests: t, requestExamples: s, requestExampleMutators: u } = r, a = t[e];
119
+ a == null || a.examples.forEach((n) => {
120
+ const h = j(
121
+ a,
122
+ s[n].name
123
+ );
124
+ h && u.set({
125
+ ...h,
126
+ uid: n
127
+ });
128
+ });
129
+ }, L = (e, r) => {
130
+ const { activeCollection: t, requests: s, requestMutators: u } = r;
131
+ if (!t.value) return !1;
132
+ const [, a, n, ...h] = e.path;
133
+ if (a === "path" && e.type === "CHANGE")
134
+ t.value.requests.forEach((p) => {
135
+ s[p].path === e.oldValue && u.edit(p, "path", e.value);
136
+ });
137
+ else if (n === "method" && e.type === "CHANGE")
138
+ t.value.requests.forEach((p) => {
139
+ s[p].method === e.oldValue && s[p].path === a && u.edit(p, "method", e.value);
140
+ });
141
+ else if (e.type !== "CHANGE" && typeof h.at(-1) == "number") {
142
+ const p = v(
143
+ t.value.requests,
144
+ s,
145
+ (c) => c.path === a && c.method === n
146
+ ), o = f(O, {
147
+ ...e,
148
+ path: e.path.slice(3)
149
+ });
150
+ if (!p || !o) return !1;
151
+ const l = [...N(p, o.pathMinusOne)];
152
+ e.type === "CREATE" ? l.push(o.value) : e.type === "REMOVE" && l.pop(), u.edit(p.uid, o.pathMinusOne, l), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, r);
153
+ } else if (e.type === "CREATE") {
154
+ const [[p, o]] = Object.entries(e.value), l = n ? e.value : o, c = n || p, m = V.array().parse(l.servers ?? []), { security: E, ...Z } = l, g = {
155
+ ...Z,
156
+ method: D(c) ? c : "get",
157
+ path: a,
158
+ parameters: l.parameters ?? [],
159
+ servers: m.map((d) => d.uid)
160
+ };
161
+ E != null && E.length && (g.security = E.map((d) => {
162
+ if (Object.keys(d).length) {
163
+ const [q] = Object.keys(d);
164
+ return {
165
+ [q]: d[q]
166
+ };
167
+ } else return d;
168
+ }));
169
+ const A = R(g, O, !1);
170
+ if (!A) return !1;
171
+ u.add(A, t.value.uid);
172
+ } else if (e.type === "REMOVE") {
173
+ const p = v(
174
+ t.value.requests,
175
+ s,
176
+ (o) => o.path === a && o.method === n
177
+ );
178
+ if (!p) return !1;
179
+ u.delete(p, t.value.uid);
180
+ } else if (e.type === "CHANGE") {
181
+ const p = v(
182
+ t.value.requests,
183
+ s,
184
+ (l) => l.path === a && l.method === n
185
+ ), o = f(O, { ...e, path: h });
186
+ if (!p || !o) return !1;
187
+ u.edit(p.uid, o.path, o.value), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, r);
188
+ }
189
+ return !0;
190
+ }, W = (e, { activeCollection: r, servers: t, serverMutators: s }) => {
191
+ if (!r.value) return !1;
192
+ const [, u, ...a] = e.path;
193
+ if (a != null && a.length) {
194
+ const n = r.value.servers[u], h = t[n], p = f(V, { ...e, path: a });
195
+ if (!h || !p) return !1;
196
+ const l = e.type === "REMOVE" && a[a.length - 1] === "variables" ? {} : p.value;
197
+ s.edit(n, p.path, l);
198
+ } else if (e.type === "REMOVE") {
199
+ if (!r.value.servers[u]) return !1;
200
+ s.delete(
201
+ r.value.servers[u],
202
+ r.value.uid
203
+ );
204
+ } else if (e.type === "CREATE") {
205
+ const n = R(e.value, V, !1);
206
+ if (!n) return !1;
207
+ s.add(n, r.value.uid);
208
+ }
209
+ return !0;
210
+ }, I = (e, { activeCollection: r, tags: t, tagMutators: s }) => {
211
+ if (!r.value) return !1;
212
+ const [, u, ...a] = e.path;
213
+ if (a != null && a.length) {
214
+ const n = r.value.tags[u], h = t[n], p = f(M, { ...e, path: a });
215
+ if (!h || !p) return !1;
216
+ s.edit(n, p.path, p.value);
217
+ } else if (e.type === "REMOVE") {
218
+ const n = r.value.tags[u], h = t[n];
219
+ if (!h) return !1;
220
+ s.delete(h, r.value.uid);
221
+ } else if (e.type === "CREATE") {
222
+ const n = R(e.value, M, !1);
223
+ if (!n) return !1;
224
+ s.add(n, r.value.uid);
225
+ }
226
+ return !0;
227
+ }, w = (e, r, t) => {
228
+ const s = y(e);
229
+ if (s instanceof i.ZodUnion || s instanceof i.ZodDiscriminatedUnion) {
230
+ for (const u of s.options)
231
+ if (u instanceof i.ZodObject && r in u.shape && u.shape[r] instanceof i.ZodLiteral && u.shape[r].value === t)
232
+ return u;
233
+ }
234
+ return null;
235
+ }, J = (e, { activeCollection: r, securitySchemes: t, securitySchemeMutators: s }) => {
236
+ var h;
237
+ if (!r.value) return !1;
238
+ const [, , u, ...a] = e.path, n = t[u] ?? v(
239
+ r.value.securitySchemes,
240
+ t,
241
+ (p) => p.nameKey === u
242
+ );
243
+ if (a != null && a.length) {
244
+ if (!n) return !1;
245
+ const { schema: p, _path: o } = a[0] === "flows" && n.type === "oauth2" ? {
246
+ schema: w(
247
+ H,
248
+ "type",
249
+ (h = n == null ? void 0 : n.flow) == null ? void 0 : h.type
250
+ ),
251
+ _path: a.slice(2)
252
+ } : {
253
+ schema: w(
254
+ S,
255
+ "type",
256
+ n == null ? void 0 : n.type
257
+ ),
258
+ _path: a
259
+ };
260
+ if (o[0] === "scopes" && n.type === "oauth2") {
261
+ const m = { ...n.flow.scopes };
262
+ return e.type === "CREATE" || e.type === "CHANGE" ? m[o[1]] = e.value : delete m[o[1]], s.edit(n.uid, "flow.scopes", m), !0;
263
+ }
264
+ if (!p) return !1;
265
+ const l = f(p, { ...e, path: o });
266
+ if (!l) return !1;
267
+ const c = a[0] === "flows" ? ["flow", ...o].join(".") : l.path;
268
+ s.edit(n.uid, c, l.value);
269
+ } else if (e.type === "REMOVE") {
270
+ if (!n) return !1;
271
+ s.delete(n.uid);
272
+ } else e.type === "CREATE" && s.add(
273
+ S.parse(e.value),
274
+ r.value.uid
275
+ );
276
+ return !0;
277
+ };
278
+ export {
279
+ x as combineRenameDiffs,
280
+ v as findResource,
281
+ K as mutateCollectionDiff,
282
+ L as mutateRequestDiff,
283
+ J as mutateSecuritySchemeDiff,
284
+ W as mutateServerDiff,
285
+ I as mutateTagDiff,
286
+ w as narrowUnionSchema,
287
+ f as parseDiff,
288
+ C as traverseZodSchema
289
+ };
@@ -10,6 +10,8 @@ export type SidebarItem = {
10
10
  icon?: string;
11
11
  edit: (name: string, icon?: string) => void;
12
12
  delete: () => void;
13
+ documentUrl?: string;
14
+ watchForChanges?: boolean;
13
15
  };
14
16
  export type SidebarMenuItem = {
15
17
  /** The resource which we are opening the menu for */
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-item.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/types/sidebar-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,aAAa,EACb,GAAG,EACJ,MAAM,iCAAiC,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,UAAU,GAAG,GAAG,GAAG,OAAO,GAAG,cAAc,CAAA;IACnD,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,8CAA8C;IAC9C,IAAI,EAAE,OAAO,CAAA;CACd,CAAA"}
1
+ {"version":3,"file":"sidebar-item.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/types/sidebar-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,aAAa,EACb,GAAG,EACJ,MAAM,iCAAiC,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,UAAU,GAAG,GAAG,GAAG,OAAO,GAAG,cAAc,CAAA;IACnD,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,8CAA8C;IAC9C,IAAI,EAAE,OAAO,CAAA;CACd,CAAA"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.1.26",
21
+ "version": "2.1.27",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -143,6 +143,7 @@
143
143
  "cva": "1.0.0-beta.1",
144
144
  "fuse.js": "^7.0.0",
145
145
  "js-cookie": "^3.0.5",
146
+ "microdiff": "^1.4.0",
146
147
  "nanoid": "^5.0.7",
147
148
  "pretty-bytes": "^6.1.1",
148
149
  "pretty-ms": "^8.0.0",
@@ -152,18 +153,18 @@
152
153
  "whatwg-mimetype": "^4.0.0",
153
154
  "yaml": "^2.4.5",
154
155
  "zod": "^3.23.8",
155
- "@scalar/components": "0.12.55",
156
+ "@scalar/components": "0.12.56",
156
157
  "@scalar/draggable": "0.1.6",
157
158
  "@scalar/icons": "0.1.1",
158
- "@scalar/oas-utils": "0.2.58",
159
+ "@scalar/oas-utils": "0.2.59",
160
+ "@scalar/object-utils": "1.1.10",
159
161
  "@scalar/openapi-parser": "0.8.7",
160
162
  "@scalar/openapi-types": "0.1.3",
161
- "@scalar/object-utils": "1.1.10",
162
- "@scalar/themes": "0.9.39",
163
- "@scalar/use-codemirror": "0.11.22",
163
+ "@scalar/themes": "0.9.40",
164
164
  "@scalar/types": "0.0.16",
165
- "@scalar/use-toasts": "0.7.7",
166
- "@scalar/use-tooltip": "1.0.3"
165
+ "@scalar/use-codemirror": "0.11.23",
166
+ "@scalar/use-tooltip": "1.0.3",
167
+ "@scalar/use-toasts": "0.7.7"
167
168
  },
168
169
  "devDependencies": {
169
170
  "@types/js-cookie": "^3.0.6",
@@ -180,6 +181,7 @@
180
181
  "vite": "^5.2.10",
181
182
  "vite-svg-loader": "^5.1.0",
182
183
  "vitest": "^1.6.0",
184
+ "@scalar/galaxy": "0.2.12",
183
185
  "@scalar/build-tooling": "0.1.11"
184
186
  },
185
187
  "scripts": {