@scalar/api-client 2.0.20 → 2.0.21
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestBody.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/RequestSection/RequestBody.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"RequestBody.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/RequestSection/RequestBody.vue"],"names":[],"mappings":";WAucS,MAAM;WACN,MAAM;eACF,GAAG,EAAE;;WAFT,MAAM;WACN,MAAM;eACF,GAAG,EAAE;;AAqxBlB,wBAMG;AAOH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC5D,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC"}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { useWorkspace as
|
|
8
|
-
import { ScalarListbox as
|
|
1
|
+
import { defineComponent as G, ref as T, computed as _, watch as N, openBlock as r, createBlock as f, withCtx as u, createTextVNode as V, toDisplayString as k, createElementBlock as v, Fragment as j, createVNode as d, unref as i, createElementVNode as y, nextTick as H } from "vue";
|
|
2
|
+
import K from "../../../components/CodeInput/CodeInput.vue.js";
|
|
3
|
+
import Q from "../../../components/DataTable/DataTable.vue.js";
|
|
4
|
+
import Z from "../../../components/DataTable/DataTableHeader.vue.js";
|
|
5
|
+
import D from "../../../components/DataTable/DataTableRow.vue.js";
|
|
6
|
+
import I from "../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
|
|
7
|
+
import { useWorkspace as ee } from "../../../store/workspace.js";
|
|
8
|
+
import { ScalarListbox as te, ScalarButton as F, ScalarIcon as q } from "@scalar/components";
|
|
9
9
|
import { createRequestExampleParameter as S } from "@scalar/oas-utils/entities/workspace/spec";
|
|
10
10
|
import L from "./RequestTable.vue.js";
|
|
11
11
|
import { useFileDialog as W } from "../../../hooks/useFileDialog.js";
|
|
12
|
-
const
|
|
12
|
+
const ae = {
|
|
13
13
|
key: 0,
|
|
14
14
|
class: "text-c-3 flex min-h-14 w-full items-center justify-center rounded border border-dashed text-center text-base"
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
],
|
|
15
|
+
}, oe = /* @__PURE__ */ y("span", null, "No Body", -1), le = [
|
|
16
|
+
oe
|
|
17
|
+
], ne = {
|
|
18
18
|
key: 0,
|
|
19
19
|
class: "text-c-3 flex min-h-10 w-full items-center justify-center p-2 text-sm"
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
],
|
|
20
|
+
}, re = /* @__PURE__ */ y("span", null, "No Body", -1), ue = [
|
|
21
|
+
re
|
|
22
|
+
], ie = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "flex items-center justify-center p-1.5 overflow-hidden"
|
|
25
|
-
}, se = { class: "text-c-2 text-xs w-full border rounded p-1 max-w-full overflow-hidden whitespace-nowrap" },
|
|
25
|
+
}, se = { class: "text-c-2 text-xs w-full border rounded p-1 max-w-full overflow-hidden whitespace-nowrap" }, de = /* @__PURE__ */ y("span", null, "Upload File", -1), De = /* @__PURE__ */ G({
|
|
26
26
|
__name: "RequestBody",
|
|
27
27
|
props: {
|
|
28
28
|
title: {},
|
|
29
29
|
body: {},
|
|
30
30
|
formData: {}
|
|
31
31
|
},
|
|
32
|
-
setup(
|
|
33
|
-
const
|
|
32
|
+
setup(ce) {
|
|
33
|
+
const A = {
|
|
34
34
|
multipartForm: "Multipart Form",
|
|
35
35
|
formUrlEncoded: "Form URL Encoded",
|
|
36
36
|
binaryFile: "Binary File",
|
|
@@ -40,39 +40,39 @@ const te = {
|
|
|
40
40
|
edn: "EDN",
|
|
41
41
|
other: "Other",
|
|
42
42
|
none: "None"
|
|
43
|
-
}, { activeRequest: m, activeExample: t, requestExampleMutators:
|
|
43
|
+
}, { activeRequest: m, activeExample: t, requestExampleMutators: s } = ee(), n = T("none"), b = T(null), M = {
|
|
44
44
|
json: "json",
|
|
45
45
|
xml: "xml",
|
|
46
46
|
yaml: "yaml",
|
|
47
47
|
edn: "edn",
|
|
48
48
|
other: "html"
|
|
49
|
-
},
|
|
49
|
+
}, O = _(() => {
|
|
50
50
|
const e = n.value;
|
|
51
|
-
return
|
|
51
|
+
return M[e] ?? "plaintext";
|
|
52
52
|
});
|
|
53
|
-
function
|
|
53
|
+
function R() {
|
|
54
54
|
console.log("deleteRow");
|
|
55
55
|
}
|
|
56
|
-
const U = (e,
|
|
56
|
+
const U = (e, a, o) => {
|
|
57
57
|
if (!m.value || !t.value) return;
|
|
58
58
|
const c = p.value;
|
|
59
59
|
if (c.length > e) {
|
|
60
60
|
const l = [...c];
|
|
61
|
-
l[e] = { ...l[e], [
|
|
61
|
+
l[e] = { ...l[e], [a]: o }, (l[e].key !== "" || l[e].value !== "") && (l[e].enabled = !0), l[e].key === "" && l[e].value === "" && l.splice(e, 1), s.edit(
|
|
62
62
|
t.value.uid,
|
|
63
63
|
"body.formData.value",
|
|
64
64
|
l
|
|
65
65
|
);
|
|
66
66
|
} else {
|
|
67
|
-
const l = [S({ [
|
|
68
|
-
|
|
67
|
+
const l = [S({ [a]: o })];
|
|
68
|
+
s.edit(
|
|
69
69
|
t.value.uid,
|
|
70
70
|
"body.formData.value",
|
|
71
71
|
l
|
|
72
|
-
),
|
|
73
|
-
var
|
|
72
|
+
), H(() => {
|
|
73
|
+
var C;
|
|
74
74
|
if (!b.value) return;
|
|
75
|
-
(
|
|
75
|
+
(C = b.value.querySelectorAll("input")[a === "key" ? 0 : 1]) == null || C.focus();
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
}, p = _(
|
|
@@ -81,35 +81,42 @@ const te = {
|
|
|
81
81
|
return ((e = t.value) == null ? void 0 : e.body.formData.value) ?? [];
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
|
-
function
|
|
84
|
+
function z() {
|
|
85
85
|
p.value.length === 0 && x();
|
|
86
86
|
}
|
|
87
87
|
const x = () => {
|
|
88
88
|
if (!m.value || !t.value) return;
|
|
89
89
|
const e = S({
|
|
90
90
|
enabled: !1
|
|
91
|
-
}),
|
|
92
|
-
|
|
91
|
+
}), a = [...p.value, e];
|
|
92
|
+
s.edit(
|
|
93
93
|
t.value.uid,
|
|
94
94
|
"body.formData.value",
|
|
95
|
-
|
|
95
|
+
a
|
|
96
96
|
);
|
|
97
97
|
}, $ = (e) => {
|
|
98
|
-
!m.value || !t.value ||
|
|
98
|
+
!m.value || !t.value || s.edit(
|
|
99
99
|
t.value.uid,
|
|
100
100
|
"body.raw.value",
|
|
101
101
|
e
|
|
102
102
|
);
|
|
103
|
+
}, J = (e) => {
|
|
104
|
+
let a = "raw";
|
|
105
|
+
e === "multipartForm" || e === "formUrlEncoded" ? a = "formData" : e === "binaryFile" ? a = "binary" : a = "raw", s.edit(
|
|
106
|
+
t.value.uid,
|
|
107
|
+
"body.activeBody",
|
|
108
|
+
a
|
|
109
|
+
);
|
|
103
110
|
}, B = async (e) => {
|
|
104
|
-
const { open:
|
|
105
|
-
onChange: async (
|
|
106
|
-
const c =
|
|
111
|
+
const { open: a } = W({
|
|
112
|
+
onChange: async (o) => {
|
|
113
|
+
const c = o == null ? void 0 : o[0];
|
|
107
114
|
if (c && m.value && t.value) {
|
|
108
115
|
const h = [...p.value];
|
|
109
116
|
h[e] = {
|
|
110
117
|
...h[e],
|
|
111
118
|
file: c
|
|
112
|
-
},
|
|
119
|
+
}, s.edit(
|
|
113
120
|
t.value.uid,
|
|
114
121
|
"body.formData.value",
|
|
115
122
|
h
|
|
@@ -119,31 +126,31 @@ const te = {
|
|
|
119
126
|
multiple: !1,
|
|
120
127
|
accept: "*/*"
|
|
121
128
|
});
|
|
122
|
-
|
|
129
|
+
a();
|
|
123
130
|
};
|
|
124
|
-
function
|
|
125
|
-
!m.value || !t.value ||
|
|
131
|
+
function X() {
|
|
132
|
+
!m.value || !t.value || s.edit(t.value.uid, "body.binary", void 0);
|
|
126
133
|
}
|
|
127
|
-
function
|
|
134
|
+
function E(e) {
|
|
128
135
|
if (!m.value || !t.value) return;
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
...
|
|
136
|
+
const o = [...p.value];
|
|
137
|
+
o[e] = {
|
|
138
|
+
...o[e],
|
|
132
139
|
file: void 0
|
|
133
|
-
},
|
|
140
|
+
}, s.edit(
|
|
134
141
|
t.value.uid,
|
|
135
142
|
"body.formData.value",
|
|
136
|
-
|
|
143
|
+
o
|
|
137
144
|
);
|
|
138
145
|
}
|
|
139
|
-
function
|
|
146
|
+
function Y() {
|
|
140
147
|
const { open: e } = W({
|
|
141
|
-
onChange: async (
|
|
142
|
-
const
|
|
143
|
-
|
|
148
|
+
onChange: async (a) => {
|
|
149
|
+
const o = a == null ? void 0 : a[0];
|
|
150
|
+
o && m.value && t.value && s.edit(
|
|
144
151
|
t.value.uid,
|
|
145
152
|
"body.binary",
|
|
146
|
-
|
|
153
|
+
o
|
|
147
154
|
);
|
|
148
155
|
},
|
|
149
156
|
multiple: !1,
|
|
@@ -151,20 +158,20 @@ const te = {
|
|
|
151
158
|
});
|
|
152
159
|
e();
|
|
153
160
|
}
|
|
154
|
-
const
|
|
155
|
-
([e,
|
|
161
|
+
const P = Object.entries(A).map(
|
|
162
|
+
([e, a]) => ({
|
|
156
163
|
id: e,
|
|
157
|
-
label:
|
|
164
|
+
label: a,
|
|
158
165
|
value: e
|
|
159
166
|
})
|
|
160
167
|
), g = _({
|
|
161
|
-
get: () =>
|
|
168
|
+
get: () => P.find((e) => e.id === n.value),
|
|
162
169
|
set: (e) => {
|
|
163
170
|
e != null && e.id && (n.value = e.id);
|
|
164
171
|
}
|
|
165
|
-
}),
|
|
166
|
-
return
|
|
167
|
-
|
|
172
|
+
}), w = _(() => t.value ? t.value.body.formData && t.value.body.formData.value.length > 0 ? "multipartForm" : t.value.body.raw && t.value.body.raw.value.trim() !== "" ? t.value.body.raw.encoding : n.value : "none");
|
|
173
|
+
return w.value !== "none" && (n.value = w.value), N(
|
|
174
|
+
w,
|
|
168
175
|
(e) => {
|
|
169
176
|
e && (n.value = e);
|
|
170
177
|
},
|
|
@@ -172,42 +179,42 @@ const te = {
|
|
|
172
179
|
), N(
|
|
173
180
|
n,
|
|
174
181
|
(e) => {
|
|
175
|
-
(e === "multipartForm" || e === "formUrlEncoded") &&
|
|
182
|
+
(e === "multipartForm" || e === "formUrlEncoded") && z(), J(e);
|
|
176
183
|
},
|
|
177
184
|
{ immediate: !0 }
|
|
178
|
-
), (e,
|
|
185
|
+
), (e, a) => (r(), f(I, null, {
|
|
179
186
|
title: u(() => [
|
|
180
|
-
V(
|
|
187
|
+
V(k(e.title), 1)
|
|
181
188
|
]),
|
|
182
189
|
default: u(() => [
|
|
183
|
-
e.body && e.body.length === 0 && e.formData && e.formData.length === 0 ? (r(), v("div",
|
|
190
|
+
e.body && e.body.length === 0 && e.formData && e.formData.length === 0 ? (r(), v("div", ae, le)) : e.formData && e.formData.length > 0 ? (r(), v(j, { key: 1 }, [], 64)) : (r(), f(Q, {
|
|
184
191
|
key: 2,
|
|
185
192
|
columns: [""]
|
|
186
193
|
}, {
|
|
187
194
|
default: u(() => [
|
|
188
|
-
|
|
195
|
+
d(D, null, {
|
|
189
196
|
default: u(() => [
|
|
190
|
-
|
|
197
|
+
d(Z, { class: "relative col-span-full flex h-8 cursor-pointer items-center px-[2.25px] py-[2.25px]" }, {
|
|
191
198
|
default: u(() => [
|
|
192
|
-
i(
|
|
199
|
+
d(i(te), {
|
|
193
200
|
modelValue: g.value,
|
|
194
|
-
"onUpdate:modelValue":
|
|
201
|
+
"onUpdate:modelValue": a[0] || (a[0] = (o) => g.value = o),
|
|
195
202
|
class: "text-xxs w-full",
|
|
196
203
|
fullWidth: "",
|
|
197
|
-
options:
|
|
204
|
+
options: i(P),
|
|
198
205
|
teleport: ""
|
|
199
206
|
}, {
|
|
200
207
|
default: u(() => [
|
|
201
|
-
i(
|
|
208
|
+
d(i(F), {
|
|
202
209
|
class: "flex gap-1.5 h-auto px-1.5 text-c-2 font-normal hover:text-c-1",
|
|
203
210
|
fullWidth: "",
|
|
204
211
|
variant: "ghost"
|
|
205
212
|
}, {
|
|
206
213
|
default: u(() => {
|
|
207
|
-
var
|
|
214
|
+
var o;
|
|
208
215
|
return [
|
|
209
|
-
y("span", null,
|
|
210
|
-
i(
|
|
216
|
+
y("span", null, k((o = g.value) == null ? void 0 : o.label), 1),
|
|
217
|
+
d(i(q), {
|
|
211
218
|
class: "stroke-[1]",
|
|
212
219
|
icon: "ChevronDown",
|
|
213
220
|
size: "xs"
|
|
@@ -225,34 +232,34 @@ const te = {
|
|
|
225
232
|
]),
|
|
226
233
|
_: 1
|
|
227
234
|
}),
|
|
228
|
-
|
|
235
|
+
d(D, null, {
|
|
229
236
|
default: u(() => {
|
|
230
|
-
var
|
|
237
|
+
var o, c, l;
|
|
231
238
|
return [
|
|
232
|
-
n.value === "none" ? (r(), v("div",
|
|
233
|
-
(
|
|
234
|
-
y("span", se,
|
|
235
|
-
i(
|
|
239
|
+
n.value === "none" ? (r(), v("div", ne, ue)) : n.value === "binaryFile" ? (r(), v("div", ie, [
|
|
240
|
+
(o = i(t)) != null && o.body.binary ? (r(), v(j, { key: 0 }, [
|
|
241
|
+
y("span", se, k((c = i(t)) == null ? void 0 : c.body.binary.name), 1),
|
|
242
|
+
d(i(F), {
|
|
236
243
|
class: "bg-b-2 hover:bg-b-3 border-0 text-c-2 ml-1",
|
|
237
244
|
size: "sm",
|
|
238
245
|
variant: "outlined",
|
|
239
|
-
onClick:
|
|
246
|
+
onClick: X
|
|
240
247
|
}, {
|
|
241
248
|
default: u(() => [
|
|
242
249
|
V(" Delete ")
|
|
243
250
|
]),
|
|
244
251
|
_: 1
|
|
245
252
|
})
|
|
246
|
-
], 64)) : (r(), f(
|
|
253
|
+
], 64)) : (r(), f(i(F), {
|
|
247
254
|
key: 1,
|
|
248
255
|
class: "bg-b-2 hover:bg-b-3 border-0 text-c-2",
|
|
249
256
|
size: "sm",
|
|
250
257
|
variant: "outlined",
|
|
251
|
-
onClick:
|
|
258
|
+
onClick: Y
|
|
252
259
|
}, {
|
|
253
260
|
default: u(() => [
|
|
254
|
-
|
|
255
|
-
i(
|
|
261
|
+
de,
|
|
262
|
+
d(i(q), {
|
|
256
263
|
class: "ml-1 stroke-[2.5]",
|
|
257
264
|
icon: "UploadSimple",
|
|
258
265
|
size: "xs"
|
|
@@ -269,8 +276,8 @@ const te = {
|
|
|
269
276
|
items: p.value,
|
|
270
277
|
showUploadButton: "",
|
|
271
278
|
onAddRow: x,
|
|
272
|
-
onDeleteRow:
|
|
273
|
-
onRemoveFile:
|
|
279
|
+
onDeleteRow: R,
|
|
280
|
+
onRemoveFile: E,
|
|
274
281
|
onUpdateRow: U,
|
|
275
282
|
onUploadFile: B
|
|
276
283
|
}, null, 8, ["items"])) : n.value == "formUrlEncoded" ? (r(), f(L, {
|
|
@@ -282,24 +289,24 @@ const te = {
|
|
|
282
289
|
items: p.value,
|
|
283
290
|
showUploadButton: "",
|
|
284
291
|
onAddRow: x,
|
|
285
|
-
onDeleteRow:
|
|
286
|
-
onRemoveFile:
|
|
292
|
+
onDeleteRow: R,
|
|
293
|
+
onRemoveFile: E,
|
|
287
294
|
onUpdateRow: U,
|
|
288
295
|
onUploadFile: B
|
|
289
|
-
}, null, 8, ["items"])) : (r(), f(
|
|
296
|
+
}, null, 8, ["items"])) : (r(), f(K, {
|
|
290
297
|
key: 4,
|
|
291
298
|
content: "",
|
|
292
|
-
language:
|
|
299
|
+
language: O.value,
|
|
293
300
|
lineNumbers: "",
|
|
294
301
|
lint: "",
|
|
295
|
-
modelValue: ((l =
|
|
302
|
+
modelValue: ((l = i(t)) == null ? void 0 : l.body.raw.value) ?? "",
|
|
296
303
|
"onUpdate:modelValue": $
|
|
297
304
|
}, null, 8, ["language", "modelValue"]))
|
|
298
305
|
];
|
|
299
306
|
}),
|
|
300
307
|
_: 1
|
|
301
308
|
}),
|
|
302
|
-
|
|
309
|
+
d(D)
|
|
303
310
|
]),
|
|
304
311
|
_: 1
|
|
305
312
|
}))
|
|
@@ -309,5 +316,5 @@ const te = {
|
|
|
309
316
|
}
|
|
310
317
|
});
|
|
311
318
|
export {
|
|
312
|
-
|
|
319
|
+
De as default
|
|
313
320
|
};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.0.
|
|
21
|
+
"version": "2.0.21",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
@@ -115,10 +115,10 @@
|
|
|
115
115
|
"vue-router": "^4.3.0",
|
|
116
116
|
"zod": "^3.22.4",
|
|
117
117
|
"@scalar/components": "0.12.14",
|
|
118
|
+
"@scalar/object-utils": "1.1.4",
|
|
118
119
|
"@scalar/draggable": "0.1.3",
|
|
119
120
|
"@scalar/oas-utils": "0.2.13",
|
|
120
121
|
"@scalar/themes": "0.9.13",
|
|
121
|
-
"@scalar/object-utils": "1.1.4",
|
|
122
122
|
"@scalar/use-codemirror": "0.11.6",
|
|
123
123
|
"@scalar/use-toasts": "0.7.4",
|
|
124
124
|
"@scalar/use-tooltip": "1.0.2"
|