@amritk/adapters 0.6.4 → 0.6.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 (2) hide show
  1. package/README.md +4 -4
  2. package/package.json +3 -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/parsers` coerces with `default`.
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/validation` coerces with `default`.
184
184
 
185
185
  #### What deliberately does not get refined
186
186
 
@@ -195,7 +195,7 @@ Two mappings look like omissions and are not:
195
195
 
196
196
  ## The `x-mjst` extension
197
197
 
198
- JSON Schema's core vocabulary has no keyword for a runtime `Date`, a `bigint`, or a nominal brand. mjst carries those as a vendor extension, `x-mjst`, that the generators read to emit the right TypeScript type and runtime check:
198
+ JSON Schema's core vocabulary has no keyword for a runtime `Date`, a `bigint`, or a nominal brand. mjst carries those as a vendor extension, `x-mjst`, that the generators read to emit the right TypeScript type and runtime check. The same object carries documentation settings for [`@amritk/generate-markdown`](../generate-markdown#the-x-mjst-keyword) (`hidden`, and everything under `markdown`), which the generators ignore:
199
199
 
200
200
  | `x-mjst` hint | Generated handling |
201
201
  |:---|:---|
@@ -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/parsers` etc.) emit it into `.d.ts`;
237
+ - the **code generators** (`@amritk/validation` 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/parsers`](../parsers) · [`@amritk/generate-markdown`](../generate-markdown) · [`@amritk/generate-examples`](../generate-examples) — the generators these adapters feed
294
+ - [`@amritk/validation`](../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.4",
3
+ "version": "0.6.6",
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,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "json-schema-typed": "^8.0.1",
47
- "@amritk/helpers": "^0.23.0"
47
+ "@amritk/helpers": "^0.23.2"
48
48
  },
49
49
  "devDependencies": {
50
- "@amritk/parsers": "^0.2.0",
50
+ "@amritk/validation": "^0.3.1",
51
51
  "@amritk/runtime-validators": "^0.15.0"
52
52
  },
53
53
  "exports": {