@flock/wirespec 0.16.4 → 0.16.6

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 (38) hide show
  1. package/clikt-clikt.mjs +1148 -1148
  2. package/colormath-root-colormath.mjs +418 -418
  3. package/kotlin-kotlin-stdlib.mjs +29 -29
  4. package/kotlin-kotlin-stdlib.mjs.map +1 -1
  5. package/kotlin-rgxgen.mjs +1766 -1766
  6. package/kotlinx-io-kotlinx-io-core.mjs +373 -373
  7. package/markdown.mjs +1829 -1829
  8. package/mordant-mordant.mjs +1582 -1582
  9. package/package.json +5 -1
  10. package/wirespec-fetch.mjs +3 -2
  11. package/wirespec-serialization.d.ts +3 -0
  12. package/wirespec-serialization.mjs +17 -0
  13. package/wirespec-src-compiler-core.mjs +2938 -6444
  14. package/wirespec-src-compiler-core.mjs.map +1 -1
  15. package/wirespec-src-compiler-emitters-java.mjs +1003 -0
  16. package/wirespec-src-compiler-emitters-java.mjs.map +1 -0
  17. package/wirespec-src-compiler-emitters-kotlin.mjs +844 -0
  18. package/wirespec-src-compiler-emitters-kotlin.mjs.map +1 -0
  19. package/wirespec-src-compiler-emitters-python.mjs +1004 -0
  20. package/wirespec-src-compiler-emitters-python.mjs.map +1 -0
  21. package/wirespec-src-compiler-emitters-typescript.mjs +958 -0
  22. package/wirespec-src-compiler-emitters-typescript.mjs.map +1 -0
  23. package/wirespec-src-compiler-emitters-wirespec.mjs +390 -0
  24. package/wirespec-src-compiler-emitters-wirespec.mjs.map +1 -0
  25. package/wirespec-src-compiler-lib.mjs +314 -314
  26. package/wirespec-src-compiler-lib.mjs.map +1 -1
  27. package/wirespec-src-converter-avro.mjs +292 -292
  28. package/wirespec-src-converter-avro.mjs.map +1 -1
  29. package/wirespec-src-converter-openapi.mjs +354 -354
  30. package/wirespec-src-converter-openapi.mjs.map +1 -1
  31. package/wirespec-src-plugin-arguments.mjs +331 -319
  32. package/wirespec-src-plugin-arguments.mjs.map +1 -1
  33. package/wirespec-src-plugin-cli.mjs +87 -121
  34. package/wirespec-src-plugin-cli.mjs.map +1 -1
  35. package/wirespec-src-plugin-npm.d.ts +6 -2
  36. package/wirespec-src-plugin-npm.mjs +46 -28
  37. package/wirespec-src-plugin-npm.mjs.map +1 -1
  38. package/wirespec-src-tools-generator.mjs +25 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flock/wirespec",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "main": "wirespec-src-plugin-npm.mjs",
5
5
  "types": "wirespec-src-plugin-npm.d.ts",
6
6
  "devDependencies": {
@@ -25,6 +25,10 @@
25
25
  "./fetch": {
26
26
  "types": "./wirespec-fetch.d.ts",
27
27
  "default": "./wirespec-fetch.mjs"
28
+ },
29
+ "./serialization": {
30
+ "types": "./wirespec-serialization.d.ts",
31
+ "default": "./wirespec-serialization.mjs"
28
32
  }
29
33
  },
30
34
  "repository": {
@@ -13,9 +13,10 @@ export async function wirespecFetch(req, handler) {
13
13
  return `${key}=${value}`;
14
14
  })
15
15
  .join('&');
16
- const url = `${req.path
16
+ const path = req.path
17
17
  .map(segment => encodeURIComponent(segment))
18
- .join('/')}${query ? `?${query}` : ''}`;
18
+ .join('/')
19
+ const url = `/${path}${query ? `?${query}` : ''}`;
19
20
  const init = {method: req.method, body, headers: {...req.headers, ...contentHeader}}
20
21
  const res = handler ? await handler(url, init) : await fetch(url, init)
21
22
  const contentType = res.headers.get('Content-Type');
@@ -0,0 +1,3 @@
1
+ export type Serialization = { serialize: <T>(typed: T) => string; deserialize: <T>(raw: string | undefined) => T }
2
+
3
+ export const wirespecSerialization: Serialization
@@ -0,0 +1,17 @@
1
+ export const wirespecSerialization = {
2
+ deserialize(raw) {
3
+ if (raw === undefined) {
4
+ return undefined;
5
+ }
6
+ if (raw.startsWith('{') && raw.endsWith('}')) return JSON.parse(raw);
7
+ if (raw.startsWith('[') && raw.endsWith(']')) return JSON.parse(raw);
8
+ return raw;
9
+ },
10
+ serialize(type) {
11
+ if (typeof type === 'string') {
12
+ return type;
13
+ }
14
+
15
+ return JSON.stringify(type);
16
+ },
17
+ };