@alexify/metaschema 3.0.0 → 3.2.0

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 (47) hide show
  1. package/CHANGELOG.md +312 -1
  2. package/README.md +463 -17
  3. package/SECURITY.md +26 -7
  4. package/index.d.ts +338 -3
  5. package/package.json +42 -5
  6. package/src/codec.js +161 -73
  7. package/src/compile/code.js +1 -1
  8. package/src/compile/emit.js +60 -7
  9. package/src/compile/index.d.ts +6 -0
  10. package/src/compile/index.js +14 -3
  11. package/src/context.js +8 -9
  12. package/src/errors.js +18 -1
  13. package/src/formats/index.d.ts +19 -0
  14. package/src/formats/index.js +146 -0
  15. package/src/generators/fromjsonschema.js +517 -0
  16. package/src/generators/index.d.ts +19 -2
  17. package/src/generators/index.js +16 -10
  18. package/src/generators/jsonschema.js +2 -0
  19. package/src/issues.js +37 -20
  20. package/src/lint.js +12 -3
  21. package/src/locales/en.js +11 -2
  22. package/src/locales/uk.js +10 -2
  23. package/src/metadata.js +3 -2
  24. package/src/model/data.js +122 -0
  25. package/src/model/diff.js +439 -0
  26. package/src/model/index.d.ts +68 -0
  27. package/src/model/index.js +45 -0
  28. package/src/model/infer.js +483 -0
  29. package/src/model/merge.js +255 -0
  30. package/src/model/pattern.js +322 -0
  31. package/src/model/restore.js +226 -0
  32. package/src/model/sample.js +398 -0
  33. package/src/model.js +13 -1
  34. package/src/preprocessor.js +5 -1
  35. package/src/prototypes/collections.js +4 -3
  36. package/src/prototypes/scalars.js +4 -4
  37. package/src/prototypes/schema.js +6 -5
  38. package/src/prototypes/union.js +2 -2
  39. package/src/result.js +6 -0
  40. package/src/rules.js +53 -4
  41. package/src/schema.js +28 -7
  42. package/src/snapshot.js +111 -0
  43. package/src/stream/index.d.ts +68 -0
  44. package/src/stream/index.js +247 -0
  45. package/src/struct.js +64 -18
  46. package/src/types.js +14 -1
  47. package/src/util.js +18 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,315 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.2.0] - 2026-10-12
11
+
12
+ 3.2 takes a schema to the records around it. The new `@alexify/metaschema/stream` subpath runs
13
+ a schema over a sequence of records, lazily and in order, as generators and as a
14
+ `TransformStream`; `infer` in the model subpath reads a definition out of the values that
15
+ exist, the reverse of `sample`; and the two performance candidates the review of 3.0 left were
16
+ measured and done: independent async validators are in flight together, and the passes of
17
+ `parse` allocate nothing per container they visit. The review of the release before its tag
18
+ added the `format` rule of strings with the `@alexify/metaschema/formats` subpath, fixed a value
19
+ parsed from JSON that could throw out of `check`, made the ReDoS note true, and closed two
20
+ unhandled rejections. Nothing breaks; the changes in behaviour (the order of the issues of an
21
+ async check with a sync validator after an unrelated promise, a pattern no longer run past
22
+ `length.max`, the message of `unexpected` capped at ten keys) are listed under Changed.
23
+
24
+ ### Added
25
+
26
+ - **The `format` rule of strings and the `@alexify/metaschema/formats` subpath.**
27
+ `{ type: 'string', format: 'email' }` is a rule beside `length` and `pattern`: the core knows
28
+ the rule and keeps an empty table (`FORMATS`), and `register()` of the subpath fills it with
29
+ `uuid`, `email`, `date-time`, `date`, `time`, `ipv4`, `ipv6`, `uri` and `hostname` (the
30
+ expressions of ajv-formats' fast mode, linear and anchored, with the date and time ranges
31
+ checked and the leap second as RFC 3339 has it) and with the program's own
32
+ (`register({ phone: { test, examples, infer } })`), once per name, process-wide; a name the
33
+ table lacks is `ERR_INVALID_RULE` with the hint when the schema is built, an entry that is
34
+ not a format `ERR_INVALID_FORMAT`, a name registered again with another test
35
+ `ERR_FORMAT_REGISTERED`. A failed test is the new `format` issue (`params.format`, rendered
36
+ by both locales); the rule runs after the pattern, under the bound of `length.max`, and the
37
+ JIT reaches the test through its scope. `toJSONSchema` writes `format` (the built-in names
38
+ are JSON Schema's; the strict profile drops it, a `$jsonSchema` has none) and
39
+ `fromJSONSchema` reads a registered one back; `sample` draws one of the format's examples;
40
+ `infer` writes the first registered format every string of a place passes (`formats: false`
41
+ turns it off; `hostname`, which every word passes, is never inferred); `merge` refuses two
42
+ formats and `diff` classifies one as a pattern. A rule, not a type: a type named `email`
43
+ would make `{ email: 'string', name: 'string' }` read as a shorthand. The subpath is 1.3 KB
44
+ min+gzip on top of the core, gated at 2 KB; the typings add `FormatDefinition`, the issue
45
+ code and the two error codes.
46
+ - **`compiled(target)` in the `@alexify/metaschema/compile` subpath**: whether a schema (every
47
+ entity of a model) runs generated code now, in place of the internal symbol the guide pointed
48
+ at.
49
+ - **`result.toJSON()`**: `JSON.stringify(result)` writes `{ valid, issues }` (the verdict was a
50
+ getter and was left out); `util.inspect(model)` prints the snapshot, as a schema prints its
51
+ definition.
52
+ - **`sideEffects: false` in package.json**: nothing registers on import, so a bundler may drop
53
+ a subpath a program imports and never calls.
54
+ - **`tests/unit/graph.test.js`**: the module graph of `src/` has no cycles (CLAUDE.md drew it
55
+ by hand and said nothing checked it).
56
+ - **`infer(samples, options)` in the `@alexify/metaschema/model` subpath, the reverse of
57
+ `sample`.** A definition (or a `Schema`, with `as: 'schema'`) that accepts every sample
58
+ given, to bootstrap a model from the documents that exist: one pass summarizes the kinds of
59
+ every place, the records of a place fuse into one struct with optional keys (absent or
60
+ `undefined`) and nullable keys (`null` beside a type), arrays fuse their elements, values of
61
+ several kinds are a `union` with the record last, whole numbers are `integer`, a string of
62
+ few recurring values an `enum`, records whose keys are not names (or many sparse keys of one
63
+ kind) a dictionary `{ object: { string: T } }`, `Set`, `Map`, `Date` and bigint their types,
64
+ and what no type describes `any`; no bounds, patterns, references or tuples. Every key of the
65
+ data is a key of the definition (`__proto__` through `define`, a struct wrapped as
66
+ `{ schema }` where its first key would read otherwise, the root under its `kind`). The
67
+ samples are input: a sample nested deeper than `maxDepth` (128) is `ERR_INFER_DEPTH` with its
68
+ index and place, and the definition is checked against every sample before it is returned
69
+ (`ERR_INFER_MISMATCH`, with `error.index`, names the id field a stored kind adds over a field
70
+ of that name, or a bug). `register()` installs `Schema.infer`; the typings add
71
+ `InferOptions` (`as`, `name`, `kind`, `enum`, `integer`, `map`, `maxDepth`) and the two codes.
72
+ - **The `@alexify/metaschema/stream` subpath: a schema over a sequence of records.**
73
+ `checkEach(schema, records, options)` and `parseEach` run `check` or `parse` on every record
74
+ of an iterable, lazily, and yield `{ index, record, result }` in the order of the records;
75
+ `checkEachAsync` and `parseEachAsync` do the same over a sync or async iterable with the
76
+ async methods, keeping `options.concurrency` records in flight (one by default), still in
77
+ order, and observing the promises in flight when the iteration ends early; `maxInvalid` ends
78
+ an iteration after that many invalid records. `transform(schema, options)` is a
79
+ `TransformStream` (a global since Node.js 18, and in browsers) that passes every valid record
80
+ on as its parsed value (or as it is with `mode: 'check'`), hands an invalid one to
81
+ `onInvalid(record, result, index)`, or ends the stream with a `TypeError` of the new runtime
82
+ code `ERR_INVALID_RECORD` (with `index`, `record` and `result` on it). `register()` installs
83
+ the five as methods of `Schema`. The subpath is 1.0 KB min+gzip on top of the core, gated at
84
+ 1.5 KB; the typings add `EachOptions`, `ParseEachOptions`, `EachAsyncOptions`,
85
+ `TransformOptions` and `RecordEntry<T, R>` (`T` the type of the records of the source:
86
+ `checkEach<T>(schema, records: Iterable<T>)` and its kin).
87
+ - **Bench scenarios for the async path and for `strip`** (`pnpm bench`): `checkAsync` with
88
+ sync, resolved and event-loop-bound validators, `parseAsync` with an async decoder, and
89
+ `parse` under `unknown: 'strip'` over a nested value and a list of 100 records, each on both
90
+ backends, through a `benchAsync` twin of the harness (one `await` per call).
91
+
92
+ ### Changed
93
+
94
+ - **Independent async validators are in flight together.** `checkAsync` and `parseAsync` set a
95
+ validator aside uncalled only when a promise is pending under its path (the `validate` of a
96
+ struct whose field is still being checked, the schema's own); every other validator runs
97
+ where `check` runs it, during the walk, and the promises are awaited together after it, so
98
+ the latency of a check is the longest of the waits rather than their sum (`pnpm bench`:
99
+ four independent validators awaiting `setImmediate` went from 18 K to 66 K checks a second,
100
+ 32 records with one each from 2.2 K to 45 K, four awaiting `setTimeout(1)` from 190 to
101
+ 845; the sync validators and the resolved promises are unchanged). What
102
+ changes besides the latency: a synchronous validator met after an unrelated promise runs
103
+ during the walk, so the issues of the walk come first, in walk order, and the promises after
104
+ them, in field order; under a low `maxErrors`, and in a branch of a plain union that fails, a
105
+ validator may be called whose result is dropped, as in `check`. The issues recorded are the
106
+ same, on both backends.
107
+ - **A `pattern` is never run over a string longer than `length.max`.** The ReDoS note promised
108
+ that the bound keeps a backtracking expression fast, but every rule of a field ran: a string
109
+ past the bound got its length issue and then the pattern (2.5 s for `^(a+)+$` on 27
110
+ characters). Both backends skip the pattern on such a string (twice the bound in UTF-16
111
+ units with `unicode: true`), which is reported for its length alone: one issue where there
112
+ were two. A field without `length.max` is unchanged. A `format` is run under the same bound.
113
+ - **The message of `unexpected` lists the first ten keys** and says how many more; `params.keys`
114
+ keeps them all. The unexpected keys are one issue, so `maxErrors` never bounded the message,
115
+ and a value with a million keys the schema does not have rendered a million of them.
116
+ - **The gate of the `./model` subpath is 12 KB** (was 10): `infer` costs 2.3 KB min+gzip and
117
+ the subpath measures 11.7 KB (12.0 KB with the formats); the subpath is tooling, not the
118
+ validation path, as for the move from 8.5 to 10 KB in 3.1. **The core gate is 17.75 KB**
119
+ (was 17.5): the `format` rule, its issue and the fixes of the review measure 17.7 KB
120
+ together, and a gate the next fix cannot fit under is no gate, as in 3.1.
121
+
122
+ ### Performance
123
+
124
+ - **The passes of `parse` and `serialize` allocate nothing per container they visit.** The
125
+ walkers of `codec.js` kept a state object per struct, list, dictionary or tuple whose bits a
126
+ pass wanted (`{ context, key, value, clone, put, out, pending }`), even where nothing
127
+ changed; the output under construction and the parts still decoding are locals of the walker
128
+ now, written through two small helpers. `pnpm bench`: `parse` of 100 records under
129
+ `unknown: 'strip'` from 61 K to 71 K a second on the closures and from 81 K to 100 K on the
130
+ JIT, a nested struct under `strip` from 1.9 M to 2.2 M on the JIT, defaults and a decoder
131
+ about 5% faster on both; the rest within the run-to-run band.
132
+
133
+ ### Fixed
134
+
135
+ - **A value parsed from JSON could throw out of `check`.** A built-in was recognised by the
136
+ name of its constructor alone, and `{ "constructor": { "name": "Map" } }` as the value of a
137
+ `map`, `set` or `date` field was iterated, or asked for `getTime`, and threw a `TypeError`
138
+ out of `check`, `parse`, a union branch and both backends, where the contract is that
139
+ nothing in the value makes the check throw. The name is still tested first, then the shape
140
+ (an iterator for a `Map` or a `Set`, `getTime` for a `Date`), which JSON cannot fake; such a
141
+ value is a type issue. Since 2.0.
142
+ - **A walk that threw out of `checkAsync` or `parseAsync` left its promises unhandled.** A
143
+ getter of the value that throws (or, before the fix above, a crafted value) ended the call
144
+ with that error while the promise a validator had returned before it rejected with no
145
+ handler. The walk of an async check releases what it queued on the way out.
146
+ - **A queued record of the async stream pair could reject unhandled.** With a window of
147
+ records in flight, a later record whose parse threw while an earlier one still waited for
148
+ its validator fired `unhandledRejection` before its turn, then rejected the iteration all
149
+ the same; the promise is observed when it is queued.
150
+ - **Keys of untrusted input are shortened in every message.** The place of an `infer` error
151
+ (a key of a sample), of a `fromJSON` error (a key of a snapshot) and of a `fromJSONSchema`
152
+ error (a property name in the pointer) went into the message whole; they are truncated to
153
+ 100 characters as a key of a value under check is. A snapshot index named `__proto__` is
154
+ written as a key instead of vanishing, and the `validate` method of a schema reports a
155
+ thrown `null` as an exception instead of throwing on it.
156
+ - **A failed branch of a plain union observed none of the promises it dropped.** A validator
157
+ of the branch that returned a promise was set aside, and when the branch failed on a later
158
+ field the entry was cut from the list without a handler, so its rejection was an
159
+ `unhandledRejection` while the value went on to match the next branch. Both backends now
160
+ release such entries (`release` in `issues.js`, reached by the generated code through the
161
+ scope), as the trial of `parse` and a `settle` stopped by `maxErrors` already did.
162
+ - **An object with no key that starts with a letter is a struct.** `Schema.from({})`,
163
+ `{ _id: 'string' }` and a nested `{ a: {} }` threw a bare `TypeError` from the preprocessor
164
+ (the first key is the first one that starts with a letter, and there was none); they are
165
+ structs of those keys, or of none.
166
+ - **A nested struct may have a field named `required`.** `{ a: { required: 'boolean' } }`
167
+ gave the field `a` the `required` of its nested definition (`'boolean'`), which showed in
168
+ `toJSON()` and in the snapshot; the key and the parsers decide, as everywhere else.
169
+ - **`fromJSONSchema` wraps a nested struct whose first letter-led key reads as a type.** A
170
+ nested object with the properties `_id` and `string` came back bare and was read as a
171
+ `string` field; one with no properties came back as `{}` and could not be built. The rule
172
+ the generator asks (`readsAsStruct` in `types.js`) follows the preprocessor's `firstKey`
173
+ now, and the model subpath shares it.
174
+
175
+ - **`CheckContext` declares `renamed`.** The context has carried the slot (whether the check
176
+ read a field from one of its aliases) since 3.1, and the migration guide says the type declares
177
+ every slot; `tests/types/index.test-d.ts` pins it now.
178
+
179
+ ### Tooling
180
+
181
+ - **A cross-library benchmark, charted.** `pnpm bench:compare` replaces `pnpm bench
182
+ --compare-libs` (`bench/libs.js` is gone): metaschema on both backends beside Metarhia's
183
+ metaschema 2.2.2, zod, Valibot, ArkType, Effect Schema, TypeBox (1.x, `Compile` and `Value`),
184
+ Ajv, Yup, Joi and Superstruct, one adapter per library, each pair in a fresh process that
185
+ checks the verdicts before it times anything, median of five one-second samples. The
186
+ scenarios are the moltar object in its four modes, every issue of an invalid value, building
187
+ a schema and a cold start; `pnpm size:compare` bundles the same schema per library and checks
188
+ the bundle; `bench/releases.js` measures every release since Metarhia's 2.2.2 with one
189
+ harness. `pnpm bench:report` turns the results into SVG charts for the README and the tables
190
+ of the README and `docs/guide/benchmarks.md`; the docs render the same models as interactive
191
+ charts. The libraries are devDependencies (`@sinclair/typebox` 0.34 gave way to `typebox`
192
+ 1.x).
193
+ - **A feature matrix of twenty alternatives.** `docs/guide/comparison.md` and the README compare
194
+ metaschema with TypeScript-first validators, JSON Schema tools, IDLs and Mongoose in one
195
+ table, every cell checked against the source of the published package; `pnpm docs:comparison`
196
+ renders it from `docs/comparison.json`.
197
+ - **Docs.** New pages: Benchmarks, Compared with alternatives and Architecture (mermaid diagrams
198
+ of the pipeline); the home page and the Why page were rewritten around "fast, zero-dependency";
199
+ the package description says so too.
200
+
201
+ ## [3.1.0] - 2026-10-11
202
+
203
+ 3.1 makes the model data. `model.toJSON()` writes a snapshot of a model, the contract other
204
+ programs read it through, and the new `@alexify/metaschema/model` subpath builds on it:
205
+ `fromJSON` restores a model from a snapshot, `diff` and `compatibility` compare two versions by
206
+ the rules of schema evolution, `sample` draws a value a schema accepts, and `merge` unifies two
207
+ schemas. A field may carry `aliases`, read by `check` and renamed by `parse`, and
208
+ `fromJSONSchema` of the generators reads a JSON Schema document back into a definition. Nothing
209
+ breaks: the core, the generators and the compile subpath keep their 3.0 behaviour, with the
210
+ fixes listed below.
211
+
212
+ ### Added
213
+
214
+ - **The snapshot.** `model.toJSON()` (what `JSON.stringify(model)` writes) is the model as
215
+ data, format 1: the entities in dependency order with their metadata, fields (each
216
+ `{ type, required, ...sorted keys }`), indexes and relations, and the types the entities use;
217
+ a function is `{ $function: true }` wherever it stands, a bigint and a Date are tagged, a
218
+ RegExp is its source. `tests/fixtures/snapshot.json` pins the format.
219
+ - **`aliases` on a field.** `check` reads a field from an alias the value carries when it has
220
+ nothing under the field's own key, reporting under the key it found the value under; `parse`
221
+ fills no default over it and writes the value under the field's own key, in the place of the
222
+ alias, and only after a check that read an alias (a value without one comes back as it is,
223
+ the same reference); `serialize` never reads an alias. The JIT emits the same lookup. An
224
+ alias is a key of the struct (not a field, a calculated field or another alias:
225
+ `ERR_INVALID_DEFINITION`); the generators and `Infer` name the field's own key only.
226
+ - **`@alexify/metaschema/model`**, a subpath of 9.5 KB min+gzip on top of the core:
227
+ `fromJSON(snapshot, options)` restores a model from its snapshot (placeholders for the
228
+ functions, listed by path in `model.placeholders`; the real custom types through
229
+ `options.types`; an isolated registry unless `options.registry` says otherwise, and a shared
230
+ one refuses a placeholder type). A snapshot is untrusted input: what does not read (a
231
+ bigint, a date, a pattern, an entity without a kind, a nesting deeper than 128 levels, an
232
+ index named like a field, a `custom` key that would override the kind metadata) is
233
+ `ERR_INVALID_SNAPSHOT` with the entity and the field, and a key of the snapshot is defined,
234
+ never assigned, so `__proto__` is a field. `diff(prev, next)` lists the changes between two
235
+ models or snapshots as `{ kind, op, entity, name, from, to, detail }` (a field renamed
236
+ through its aliases is `renamed`, a removed `deprecated` field carries `detail.deprecated`);
237
+ `compatibility(changes)` classifies them as `full`, `backward`, `forward` or `none` by the
238
+ rules of the Confluent Schema Registry (the table is in the Model evolution guide), and
239
+ `compatibilityOf(change)` is the class of one change;
240
+ `sample(schema, { seed, locale, references, maxDepth })` is a value the schema accepts, the
241
+ same for a seed, drawn from the definition and verified field by field (a pattern from the
242
+ subset of alternatives, groups, classes, escapes, control escapes and quantifiers, the
243
+ letters of `.` and `\p{L}` those of the locale of the call; a custom type through
244
+ `metadata.sample`; a union draws another branch when one cannot be satisfied; `maxDepth` 0
245
+ to 32), with `ERR_UNSATISFIABLE`, `ERR_SAMPLE_PATTERN` and `ERR_SAMPLE_TYPE` for what cannot
246
+ be drawn, each naming the seed (`error.seed`): a repetition over 10000, a pattern whose
247
+ minimal length exceeds `length.max` (found before a string is built), groups nested deeper
248
+ than 64; `merge(a, b, { name, metadata })` is the schema both schemas describe,
249
+ by unification, with `ERR_MERGE_CONFLICT` for what no value can satisfy, located like a
250
+ definition error (`error.field`, the message ending `in "Name.address.city"`; an alias that
251
+ is a field of the other schema is a conflict too); `register()` installs `Model.fromJSON`,
252
+ `Model.diff`, `Model.compatibility`, `Model.compatibilityOf`, `Schema.merge` and
253
+ `schema.sample`.
254
+ - **`fromJSONSchema(document, { name, as, references, unsupported })`** of the generators
255
+ subpath: a definition (or a Schema) from the subset of JSON Schema a validation schema is
256
+ made of, the other direction of `toJSONSchema` (types and type lists, properties and
257
+ required, enum and const, items, tuples and uniqueItems, anyOf/oneOf with OpenAPI's
258
+ discriminator, `$ref` into the definitions, the rules, null, the annotations, the root's
259
+ `additionalProperties` as the unknown-keys policy); a keyword outside the subset is
260
+ `ERR_UNSUPPORTED_SCHEMA` with its place as a JSON pointer, and so are a `$ref` that is not
261
+ `#` or `#/…` over own keys, a bad escape in one, a nesting deeper than 128 levels, a
262
+ pattern that does not compile under the `u` flag and an unknown name in a type list;
263
+ `onUnsupported(reason, pointer)` tells what `unsupported: 'ignore'` dropped. A `$ref` is
264
+ converted once per pointer and shared where it is inlined, so a diamond of definitions is
265
+ linear. `register()` adds `Schema.fromJSONSchema`. The subpath is 7.1 KB on top of the core
266
+ now.
267
+ - The types `ModelSnapshot`, `EntitySnapshot`, `FieldSnapshot`, `FieldsSnapshot`,
268
+ `FunctionSnapshot`, `TypeSnapshot`, `RestoreOptions`, `RestoredModel`, `SchemaChange`,
269
+ `ChangeKind`, `ChangeOp`, `Compatibility`, `SampleOptions`, `SampleHook`, `TypeMetadata`
270
+ (the `sample` hook of a custom type), `MergeOptions` and `FromJSONSchemaOptions`;
271
+ `aliases` on `FieldType`; the codes `ERR_INVALID_SNAPSHOT`, `ERR_UNSATISFIABLE`,
272
+ `ERR_SAMPLE_PATTERN`, `ERR_SAMPLE_TYPE`, `ERR_MERGE_CONFLICT` and `ERR_UNSUPPORTED_SCHEMA`.
273
+ - A `dead-aliases` warning for `aliases` anywhere but on a field of a struct (an element, a
274
+ branch, a schema of one type), where nothing reads them.
275
+
276
+ ### Changed
277
+
278
+ - Two fields of a struct with one key (`{ a: 'string', 'a?': 'number' }`, or a calculated
279
+ field and a field of one name) are `ERR_INVALID_DEFINITION` ("is a field or an alias
280
+ already"); the second silently replaced the first before.
281
+ - `aliases` is a key the struct reads: `{ type: 'string', aliases: 'old' }` is
282
+ `ERR_INVALID_DEFINITION` where it was an `unknown-option` warning, and a custom type does not
283
+ see an option of that name.
284
+ - `JSON.stringify(model)` writes the snapshot; it wrote the `Model` instance's own enumerable
285
+ properties before.
286
+ - A function of a subpath given something other than what it takes (`toJSONSchema`,
287
+ `toTypeScript`, `compile`, `sample`, `merge`, `compatibility`, `fromJSONSchema`) throws a
288
+ `TypeError` with `code: 'ERR_INVALID_TARGET'` (the `RuntimeErrorCode` of `ERR_ASYNC_VALIDATOR`);
289
+ the message is the same, and `fromJSONSchema` of a non-object document, which was
290
+ `ERR_INVALID_OPTIONS`, is that error too.
291
+
292
+ ### Fixed
293
+
294
+ - A `many` reference re-parsed from its built field (a projection copies its parent's fields
295
+ that way, and the long form `{ type: 'Address', many: 'Address' }` reads the same) came back
296
+ with both ends and validated as a single reference.
297
+ - The name of a named tuple element (`[{ x: 'number' }]`) was an `unknown-option` warning.
298
+ - A `validate` given on a `schema` field (`{ type: 'schema', schema, validate }`) was replaced
299
+ by the one of the definition it holds; the field's own wins now, as its `parse` and
300
+ `serialize` did.
301
+
302
+ ### Tooling
303
+
304
+ - `pnpm size` has a fourth row and gate, `--max-gzip-model`; the CI gates are 17.5 KB per
305
+ core entry, 7.5 KB for `./generators`, 4.25 KB for `./compile` and 10 KB for `./model` (the
306
+ core, the compile and the model gates moved from 17 KB, 4 KB and 8.5 KB during the review
307
+ of 3.1: the first two had 14 and 15 bytes of headroom left, the third did not hold the
308
+ hardening of the subpath).
309
+ - The bench has a sparse-struct scenario and two alias scenarios of `parse`, and
310
+ `bench/baseline.json` is re-saved after the review.
311
+ - The coverage job runs under `shell: bash`, so the c8 thresholds fail CI through the pipe
312
+ into `tee`; before, the job took the status of `tee`.
313
+ - New suites: `snapshot`, `aliases`, `evolution`, `sample`, `fromjsonschema` and `merge`, on
314
+ all three backends; the bundle test bundles the model subpath with the core.
315
+ - New guides: Model evolution (`diff`, `compatibility`, `aliases`, `deprecated`, the rules
316
+ table), Sample values; the snapshot and `fromJSON` in Domain Models, the import in JSON
317
+ Schema, merging in Schema Syntax.
318
+
10
319
  ## [3.0.0] - 2026-10-11
11
320
 
12
321
  3.0 moves the generators of JSON Schema and TypeScript from the core entry to the
@@ -965,7 +1274,9 @@ published.
965
1274
 
966
1275
  ### [metaschema 0.x][upstream-0.x] - First generation of metaschema
967
1276
 
968
- [unreleased]: https://github.com/Alexis-Technologies/metaschema/compare/v3.0.0...HEAD
1277
+ [unreleased]: https://github.com/Alexis-Technologies/metaschema/compare/v3.2.0...HEAD
1278
+ [3.2.0]: https://github.com/Alexis-Technologies/metaschema/compare/v3.1.0...v3.2.0
1279
+ [3.1.0]: https://github.com/Alexis-Technologies/metaschema/compare/v3.0.0...v3.1.0
969
1280
  [3.0.0]: https://github.com/Alexis-Technologies/metaschema/compare/v2.0.0...v3.0.0
970
1281
  [2.0.0]: https://github.com/Alexis-Technologies/metaschema/compare/v1.0.0...v2.0.0
971
1282
  [1.0.0]: https://github.com/Alexis-Technologies/metaschema/releases/tag/v1.0.0