@flock/wirespec 0.18.1-RC.2 → 0.18.4

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 (44) hide show
  1. package/clikt-clikt-mordant.mjs +79 -79
  2. package/clikt-clikt.mjs +1265 -1265
  3. package/clikt-clikt.mjs.map +1 -1
  4. package/colormath-root-colormath.mjs +433 -433
  5. package/kotlin-kotlin-stdlib.mjs +29 -23
  6. package/kotlin-kotlin-stdlib.mjs.map +1 -1
  7. package/kotlin-openapi-bindings.mjs +5407 -5405
  8. package/kotlin-openapi-bindings.mjs.map +1 -1
  9. package/kotlin-rgxgen.mjs +1760 -1760
  10. package/kotlinx-io-kotlinx-io-core.mjs +404 -404
  11. package/kotlinx-serialization-kotlinx-serialization-core.mjs +1701 -1701
  12. package/kotlinx-serialization-kotlinx-serialization-json.mjs +1320 -1319
  13. package/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
  14. package/mordant-mordant.mjs +1198 -1198
  15. package/package.json +1 -1
  16. package/wirespec-fetch.mjs +13 -19
  17. package/wirespec-src-compiler-core.mjs +193 -206
  18. package/wirespec-src-compiler-core.mjs.map +1 -1
  19. package/wirespec-src-compiler-emitters-java.mjs +718 -784
  20. package/wirespec-src-compiler-emitters-java.mjs.map +1 -1
  21. package/wirespec-src-compiler-emitters-kotlin.mjs +357 -464
  22. package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -1
  23. package/wirespec-src-compiler-emitters-python.mjs +628 -757
  24. package/wirespec-src-compiler-emitters-python.mjs.map +1 -1
  25. package/wirespec-src-compiler-emitters-rust.mjs +1582 -1708
  26. package/wirespec-src-compiler-emitters-rust.mjs.map +1 -1
  27. package/wirespec-src-compiler-emitters-scala.mjs +680 -635
  28. package/wirespec-src-compiler-emitters-scala.mjs.map +1 -1
  29. package/wirespec-src-compiler-emitters-typescript.mjs +627 -610
  30. package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -1
  31. package/wirespec-src-compiler-emitters-wirespec.mjs +40 -40
  32. package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -1
  33. package/wirespec-src-compiler-ir.mjs +5428 -6057
  34. package/wirespec-src-compiler-ir.mjs.map +1 -1
  35. package/wirespec-src-compiler-lib.mjs +279 -279
  36. package/wirespec-src-converter-avro.mjs +559 -559
  37. package/wirespec-src-converter-avro.mjs.map +1 -1
  38. package/wirespec-src-converter-openapi.mjs +802 -404
  39. package/wirespec-src-converter-openapi.mjs.map +1 -1
  40. package/wirespec-src-plugin-arguments.mjs +144 -144
  41. package/wirespec-src-plugin-cli.mjs +87 -87
  42. package/wirespec-src-plugin-npm.mjs +44 -25
  43. package/wirespec-src-plugin-npm.mjs.map +1 -1
  44. package/wirespec-src-tools-generator.mjs +13 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flock/wirespec",
3
- "version": "0.18.1-RC.2",
3
+ "version": "0.18.4",
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
  }