@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.
- package/CHANGELOG.md +25 -0
- package/dist/components/AddressBar/AddressBar.vue.js +2 -2
- package/dist/components/AddressBar/AddressBar.vue2.js +1 -1
- package/dist/components/AddressBar/AddressBarServer.vue.js +18 -18
- package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +108 -106
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +20 -20
- package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts +1 -1
- package/dist/components/CommandPalette/TheCommandPalette.vue.js +2 -2
- package/dist/components/CommandPalette/TheCommandPalette.vue2.js +12 -12
- package/dist/components/HttpMethod/HttpMethod.vue.js +2 -2
- package/dist/components/HttpMethod/HttpMethod.vue2.js +12 -12
- package/dist/components/HttpMethod/index.d.ts +0 -1
- package/dist/components/HttpMethod/index.d.ts.map +1 -1
- package/dist/components/HttpMethod/index.js +2 -4
- package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
- package/dist/components/ImportCollection/ImportCollectionModal.vue.js +119 -102
- package/dist/components/OpenApiClientButton.vue.d.ts +1 -0
- package/dist/components/OpenApiClientButton.vue.d.ts.map +1 -1
- package/dist/components/OpenApiClientButton.vue.js +2 -2
- package/dist/components/OpenApiClientButton.vue2.js +23 -17
- package/dist/components/Search/useSearch.d.ts.map +1 -1
- package/dist/components/Search/useSearch.js +45 -41
- package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
- package/dist/layouts/Modal/ApiClientModal.vue2.js +28 -23
- package/dist/libs/create-client.d.ts +1 -0
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +31 -30
- package/dist/libs/index.d.ts +1 -0
- package/dist/libs/index.d.ts.map +1 -1
- package/dist/libs/index.js +28 -24
- package/dist/libs/postman.d.ts +11 -0
- package/dist/libs/postman.d.ts.map +1 -0
- package/dist/libs/postman.js +39 -0
- package/dist/style.css +1 -1
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +65 -62
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +82 -84
- package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestBody.vue.js +2 -2
- package/dist/views/Request/RequestSection/RequestBody.vue2.js +27 -24
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.js +4 -4
- package/dist/views/Request/RequestSidebar.vue2.js +32 -30
- package/dist/views/Request/RequestSubpageHeader.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSubpageHeader.vue.js +3 -3
- package/dist/views/Request/RequestSubpageHeader.vue2.js +34 -32
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/components/WorkspaceDropdown.vue.js +1 -1
- package/dist/views/Request/libs/live-sync.d.ts.map +1 -1
- package/dist/views/Request/libs/live-sync.js +77 -78
- package/package.json +10 -9
- package/dist/components/HttpMethod/helpers.d.ts +0 -4
- package/dist/components/HttpMethod/helpers.d.ts.map +0 -1
- package/dist/components/HttpMethod/helpers.js +0 -5
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
9
|
+
for (let r = 0; r < e.length; r++) {
|
|
11
10
|
if (a) {
|
|
12
11
|
a = !1;
|
|
13
12
|
continue;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
14
|
+
const n = e[r], u = e[r + 1];
|
|
16
15
|
if (s.length)
|
|
17
|
-
|
|
18
|
-
else if (
|
|
19
|
-
t.push(
|
|
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 (
|
|
23
|
-
const [, l, p] =
|
|
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(
|
|
34
|
+
const y = j(n.oldValue, u.value);
|
|
36
35
|
if (y.length) {
|
|
37
|
-
const
|
|
38
|
-
t.push(...
|
|
36
|
+
const E = x(y, c);
|
|
37
|
+
t.push(...E);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
a = !0;
|
|
42
|
-
} else
|
|
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
|
|
48
|
-
if (t(
|
|
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("."),
|
|
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:
|
|
81
|
+
pathMinusOne: r,
|
|
83
82
|
value: void 0
|
|
84
83
|
};
|
|
85
|
-
const
|
|
86
|
-
return
|
|
84
|
+
const n = R(s.value, t, !1);
|
|
85
|
+
return n ? {
|
|
87
86
|
path: a,
|
|
88
|
-
pathMinusOne:
|
|
89
|
-
value:
|
|
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
|
|
100
|
-
...
|
|
98
|
+
const r = [
|
|
99
|
+
...N(s.value, a.pathMinusOne)
|
|
101
100
|
];
|
|
102
|
-
e.type === "CREATE" ?
|
|
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
|
-
|
|
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
|
-
},
|
|
118
|
-
const { requests: t, requestExamples: a, requestExampleMutators:
|
|
119
|
-
|
|
120
|
-
const l =
|
|
121
|
-
|
|
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 &&
|
|
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:
|
|
132
|
-
if (
|
|
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 &&
|
|
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 ===
|
|
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 ===
|
|
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 = [...
|
|
151
|
-
e.type === "CREATE" ? h.push(o.value) : e.type === "REMOVE" && h.pop(),
|
|
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:
|
|
154
|
-
...
|
|
155
|
-
method:
|
|
156
|
-
path:
|
|
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((
|
|
157
|
+
servers: y.map((f) => f.uid)
|
|
159
158
|
};
|
|
160
|
-
|
|
161
|
-
if (Object.keys(
|
|
162
|
-
const [A] = Object.keys(
|
|
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]:
|
|
163
|
+
[A]: f[A]
|
|
165
164
|
};
|
|
166
|
-
} else return
|
|
165
|
+
} else return f;
|
|
167
166
|
}));
|
|
168
167
|
const q = R(g, O, !1);
|
|
169
168
|
if (!q) return !1;
|
|
170
|
-
|
|
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 ===
|
|
174
|
+
(o) => o.path === n && o.method === u
|
|
176
175
|
);
|
|
177
176
|
if (!p) return !1;
|
|
178
|
-
|
|
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 ===
|
|
182
|
+
(h) => h.path === n && h.method === u
|
|
184
183
|
), o = m(O, { ...e, path: l });
|
|
185
184
|
if (!p || !o) return !1;
|
|
186
|
-
|
|
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
|
-
},
|
|
188
|
+
}, P = (e, { activeCollection: s }, { servers: t, serverMutators: a }) => {
|
|
190
189
|
if (!s.value) return !1;
|
|
191
|
-
const [,
|
|
192
|
-
if (
|
|
193
|
-
const u = s.value.servers[
|
|
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" &&
|
|
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[
|
|
197
|
+
if (!s.value.servers[r]) return !1;
|
|
199
198
|
a.delete(
|
|
200
|
-
s.value.servers[
|
|
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
|
-
},
|
|
208
|
+
}, W = (e, { activeCollection: s }, { tags: t, tagMutators: a }) => {
|
|
210
209
|
if (!s.value) return !1;
|
|
211
|
-
const [,
|
|
212
|
-
if (
|
|
213
|
-
const u = s.value.tags[
|
|
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[
|
|
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
|
|
230
|
-
if (
|
|
231
|
-
return
|
|
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
|
-
},
|
|
233
|
+
}, I = (e, { activeCollection: s }, { securitySchemes: t, securitySchemeMutators: a }) => {
|
|
235
234
|
if (!s.value) return !1;
|
|
236
|
-
const [, ,
|
|
235
|
+
const [, , r, ...n] = e.path, u = t[r] ?? v(
|
|
237
236
|
s.value.securitySchemes,
|
|
238
237
|
t,
|
|
239
|
-
(l) => l.nameKey ===
|
|
238
|
+
(l) => l.nameKey === r
|
|
240
239
|
);
|
|
241
|
-
if (
|
|
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:
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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-
|
|
175
|
-
"@scalar/use-
|
|
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/
|
|
193
|
-
"@scalar/
|
|
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"}
|