@amritk/adapters 0.6.3 → 0.6.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.
- package/README.md +3 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -180,7 +180,7 @@ avroToJsonSchema(avro, { encoding: 'avro-json' })
|
|
|
180
180
|
|
|
181
181
|
The `default` column is not a stylistic choice. Avro has **no optional fields** — every declared field is present in the encoding, and a `default` is only consulted during schema resolution, when reading data written against a *different* schema. So `'avro-json'` marks every field required, because that is what is on the wire, while `'json'` treats a defaulted field as optional, because that is the shape application code deals with.
|
|
182
182
|
|
|
183
|
-
The default **value** is translated too, not just copied, because Avro writes it in neither encoding exactly. Avro states a union's default as a *bare* value of the union's **first** branch, so under `'avro-json'` it is wrapped to match the branch tagging the data uses (`null` stays bare, in both the `"null"` and `{"type": "null"}` spellings). Under `'json'` a byte default is in the wrong alphabet — Avro writes it latin-1, the idiomatic shape is base64 — so it is dropped rather than mistranslated. Both rules apply at any depth: a union nested inside a record, array, or map default is tagged the same way, and a byte value anywhere inside a default drops the whole thing, since a half-translated default is worse than none. This matters more than a stray annotation would, because `@amritk/
|
|
183
|
+
The default **value** is translated too, not just copied, because Avro writes it in neither encoding exactly. Avro states a union's default as a *bare* value of the union's **first** branch, so under `'avro-json'` it is wrapped to match the branch tagging the data uses (`null` stays bare, in both the `"null"` and `{"type": "null"}` spellings). Under `'json'` a byte default is in the wrong alphabet — Avro writes it latin-1, the idiomatic shape is base64 — so it is dropped rather than mistranslated. Both rules apply at any depth: a union nested inside a record, array, or map default is tagged the same way, and a byte value anywhere inside a default drops the whole thing, since a half-translated default is worse than none. This matters more than a stray annotation would, because `@amritk/parsers` coerces with `default`.
|
|
184
184
|
|
|
185
185
|
#### What deliberately does not get refined
|
|
186
186
|
|
|
@@ -234,7 +234,7 @@ string literal in generated output); an unsafe name is ignored.
|
|
|
234
234
|
|
|
235
235
|
Both schema→type paths honour the brand identically:
|
|
236
236
|
|
|
237
|
-
- the **code generators** (`@amritk/
|
|
237
|
+
- the **code generators** (`@amritk/parsers` etc.) emit it into `.d.ts`;
|
|
238
238
|
- the type-level [`FromSchema`](../runtime-validators) reads it too, so anything
|
|
239
239
|
typed from a live schema literal — most notably `@amritk/api` route
|
|
240
240
|
`params` / `query` / `body` — carries the brand into your handler. Declaring a
|
|
@@ -291,7 +291,7 @@ So: want a generated `Date`? Author `Schema.DateFromSelf`. Want a string that Ef
|
|
|
291
291
|
## Related packages
|
|
292
292
|
|
|
293
293
|
- [`@amritk/mjst`](../cli) — CLI that ingests these formats via `--input <format>`
|
|
294
|
-
- [`@amritk/
|
|
294
|
+
- [`@amritk/parsers`](../parsers) · [`@amritk/generate-markdown`](../generate-markdown) · [`@amritk/generate-examples`](../generate-examples) — the generators these adapters feed
|
|
295
295
|
- [`@amritk/helpers`](../helpers) — defines the shared `x-mjst` extension
|
|
296
296
|
|
|
297
297
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amritk/adapters",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Convert schemas from external libraries (TypeBox, Zod, Avro, ...) into JSON Schema for mjst.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,10 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"json-schema-typed": "^8.0.1",
|
|
47
|
-
"@amritk/helpers": "^0.
|
|
47
|
+
"@amritk/helpers": "^0.23.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@amritk/
|
|
50
|
+
"@amritk/parsers": "^0.2.0",
|
|
51
|
+
"@amritk/runtime-validators": "^0.15.0"
|
|
51
52
|
},
|
|
52
53
|
"exports": {
|
|
53
54
|
"./package.json": "./package.json",
|