@flock/wirespec 0.18.0-RC.1 → 0.18.1-RC.3
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/arrow-arrow-atomic.mjs +12 -12
- package/arrow-arrow-core.mjs +152 -158
- package/arrow-arrow-core.mjs.map +1 -1
- package/clikt-clikt-mordant.mjs +80 -80
- package/clikt-clikt.mjs +1442 -1442
- package/clikt-clikt.mjs.map +1 -1
- package/colormath-root-colormath.mjs +439 -439
- package/kotlin-kotlin-stdlib.mjs +1072 -1136
- package/kotlin-kotlin-stdlib.mjs.map +1 -1
- package/kotlin-openapi-bindings.mjs +4857 -4857
- package/kotlin-rgxgen.mjs +1793 -1793
- package/kotlinx-io-kotlinx-io-core.mjs +415 -415
- package/kotlinx-serialization-kotlinx-serialization-core.mjs +1752 -1752
- package/kotlinx-serialization-kotlinx-serialization-json.mjs +1348 -1356
- package/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
- package/mordant-mordant.mjs +1303 -1311
- package/mordant-mordant.mjs.map +1 -1
- package/package.json +1 -1
- package/wirespec-fetch.mjs +13 -19
- package/wirespec-src-compiler-core.mjs +1526 -1526
- package/wirespec-src-compiler-emitters-java.mjs +477 -451
- package/wirespec-src-compiler-emitters-java.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-kotlin.mjs +458 -453
- package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-python.mjs +419 -418
- package/wirespec-src-compiler-emitters-python.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-rust.mjs +939 -725
- package/wirespec-src-compiler-emitters-rust.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-scala.mjs +225 -233
- package/wirespec-src-compiler-emitters-scala.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-typescript.mjs +524 -555
- package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -1
- package/wirespec-src-compiler-emitters-wirespec.mjs +81 -81
- package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -1
- package/wirespec-src-compiler-ir.mjs +3738 -3708
- package/wirespec-src-compiler-ir.mjs.map +1 -1
- package/wirespec-src-compiler-lib.mjs +418 -418
- package/wirespec-src-converter-avro.mjs +506 -506
- package/wirespec-src-converter-openapi.mjs +684 -684
- package/wirespec-src-plugin-arguments.mjs +181 -181
- package/wirespec-src-plugin-cli.mjs +106 -106
- package/wirespec-src-plugin-npm.mjs +36 -36
- package/wirespec-src-tools-generator.mjs +34 -34
package/package.json
CHANGED
package/wirespec-fetch.mjs
CHANGED
|
@@ -34,34 +34,28 @@ export async function wirespecFetch(req, handler) {
|
|
|
34
34
|
|
|
35
35
|
export async function wirespecFetchIr(req, handler) {
|
|
36
36
|
const contentHeader = req.body ? { 'Content-Type': 'application/json' } : {};
|
|
37
|
-
const body = req.body !== undefined ? req.body : undefined;
|
|
38
37
|
const query = Object.entries(req.queries)
|
|
39
|
-
.filter(([
|
|
40
|
-
.flatMap(([key,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return parsedValue.map((item) => `${key}=${item}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return `${key}=${value}`;
|
|
48
|
-
})
|
|
38
|
+
.filter(([, value]) => value !== undefined)
|
|
39
|
+
.flatMap(([key, values]) =>
|
|
40
|
+
Array.isArray(values)
|
|
41
|
+
? values.map((v) => `${encodeURIComponent(key)}=${encodeURIComponent(v)}`)
|
|
42
|
+
: [`${encodeURIComponent(key)}=${encodeURIComponent(values)}`])
|
|
49
43
|
.join('&');
|
|
50
44
|
const path = req.path
|
|
51
45
|
.map(segment => encodeURIComponent(segment))
|
|
52
46
|
.join('/')
|
|
53
47
|
const url = `/${path}${query ? `?${query}` : ''}`;
|
|
54
|
-
const init = {method: req.method, body, headers: {...req.headers, ...contentHeader}}
|
|
48
|
+
const init = {method: req.method, body: req.body, headers: {...req.headers, ...contentHeader}}
|
|
55
49
|
const res = handler ? await handler(url, init) : await fetch(url, init)
|
|
56
|
-
const
|
|
57
|
-
|
|
50
|
+
const headers = [...res.headers.entries()]
|
|
51
|
+
.reduce((acc, [key, value]) => ({...acc, [key]: [value]}), {});
|
|
52
|
+
const hasBody = ![204, 205, 304].includes(res.status);
|
|
53
|
+
const buf = hasBody ? await res.arrayBuffer() : undefined;
|
|
54
|
+
const body = buf && buf.byteLength > 0 ? new Uint8Array(buf) : undefined;
|
|
58
55
|
return {
|
|
59
56
|
statusCode: res.status,
|
|
60
|
-
headers
|
|
61
|
-
|
|
62
|
-
'Content-Type': [contentType],
|
|
63
|
-
},
|
|
64
|
-
body: contentLength !== '0' && contentType ? await res.text() : undefined,
|
|
57
|
+
headers,
|
|
58
|
+
body,
|
|
65
59
|
};
|
|
66
60
|
|
|
67
61
|
}
|