@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.
Files changed (43) hide show
  1. package/arrow-arrow-atomic.mjs +12 -12
  2. package/arrow-arrow-core.mjs +152 -158
  3. package/arrow-arrow-core.mjs.map +1 -1
  4. package/clikt-clikt-mordant.mjs +80 -80
  5. package/clikt-clikt.mjs +1442 -1442
  6. package/clikt-clikt.mjs.map +1 -1
  7. package/colormath-root-colormath.mjs +439 -439
  8. package/kotlin-kotlin-stdlib.mjs +1072 -1136
  9. package/kotlin-kotlin-stdlib.mjs.map +1 -1
  10. package/kotlin-openapi-bindings.mjs +4857 -4857
  11. package/kotlin-rgxgen.mjs +1793 -1793
  12. package/kotlinx-io-kotlinx-io-core.mjs +415 -415
  13. package/kotlinx-serialization-kotlinx-serialization-core.mjs +1752 -1752
  14. package/kotlinx-serialization-kotlinx-serialization-json.mjs +1348 -1356
  15. package/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  16. package/mordant-mordant.mjs +1303 -1311
  17. package/mordant-mordant.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/wirespec-fetch.mjs +13 -19
  20. package/wirespec-src-compiler-core.mjs +1526 -1526
  21. package/wirespec-src-compiler-emitters-java.mjs +477 -451
  22. package/wirespec-src-compiler-emitters-java.mjs.map +1 -1
  23. package/wirespec-src-compiler-emitters-kotlin.mjs +458 -453
  24. package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -1
  25. package/wirespec-src-compiler-emitters-python.mjs +419 -418
  26. package/wirespec-src-compiler-emitters-python.mjs.map +1 -1
  27. package/wirespec-src-compiler-emitters-rust.mjs +939 -725
  28. package/wirespec-src-compiler-emitters-rust.mjs.map +1 -1
  29. package/wirespec-src-compiler-emitters-scala.mjs +225 -233
  30. package/wirespec-src-compiler-emitters-scala.mjs.map +1 -1
  31. package/wirespec-src-compiler-emitters-typescript.mjs +524 -555
  32. package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -1
  33. package/wirespec-src-compiler-emitters-wirespec.mjs +81 -81
  34. package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -1
  35. package/wirespec-src-compiler-ir.mjs +3738 -3708
  36. package/wirespec-src-compiler-ir.mjs.map +1 -1
  37. package/wirespec-src-compiler-lib.mjs +418 -418
  38. package/wirespec-src-converter-avro.mjs +506 -506
  39. package/wirespec-src-converter-openapi.mjs +684 -684
  40. package/wirespec-src-plugin-arguments.mjs +181 -181
  41. package/wirespec-src-plugin-cli.mjs +106 -106
  42. package/wirespec-src-plugin-npm.mjs +36 -36
  43. package/wirespec-src-tools-generator.mjs +34 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flock/wirespec",
3
- "version": "0.18.0-RC.1",
3
+ "version": "0.18.1-RC.3",
4
4
  "main": "wirespec-src-plugin-npm.mjs",
5
5
  "types": "wirespec-src-plugin-npm.d.mts",
6
6
  "devDependencies": {
@@ -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(([_, value]) => value !== undefined)
40
- .flatMap(([key, value]) => {
41
- if (value && typeof value === 'string' && value.startsWith('[') && value.endsWith(']')) {
42
- const parsedValue = JSON.parse(value);
43
- if (Array.isArray(parsedValue)) {
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 contentType = res.headers.get('Content-Type');
57
- const contentLength = res.headers.get('Content-Length');
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
- ...[...res.headers.entries()].reduce((acc, [key, value]) => ({...acc, [key]: [value]}), {}),
62
- 'Content-Type': [contentType],
63
- },
64
- body: contentLength !== '0' && contentType ? await res.text() : undefined,
57
+ headers,
58
+ body,
65
59
  };
66
60
 
67
61
  }