@texaryn/core 0.8.0 → 0.9.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.
- package/CHANGELOG.md +58 -0
- package/dist/schema/port.d.ts +59 -11
- package/dist/schema/port.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @texaryn/core
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a53724c: Report two disagreeing applicable defaults rather than merging them
|
|
8
|
+
|
|
9
|
+
`AnnotationSet.default` is one value, so an adapter that merges before core sees
|
|
10
|
+
anything reported whichever declaration its merge kept. For
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
{
|
|
14
|
+
type: 'object',
|
|
15
|
+
allOf: [
|
|
16
|
+
{ properties: { x: { type: 'string', default: 'a' } } },
|
|
17
|
+
{ properties: { x: { type: 'string', default: 'b' } } },
|
|
18
|
+
],
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`@texaryn/schema-json` reported `'b'` and `@texaryn/schema-json-hyperjump`
|
|
23
|
+
reported `'a'`. Neither is wrong, which is why neither can be the answer: in
|
|
24
|
+
JSON Schema two `allOf` branches are conjunctive and neither is nearer.
|
|
25
|
+
|
|
26
|
+
`/x` now projects with no `default` at all, and the projection carries an
|
|
27
|
+
`ambiguous-default` diagnostic naming the two schema positions that disagreed.
|
|
28
|
+
That is the rule `ambiguous-projection-shape` already applies to a shape two
|
|
29
|
+
keyword families disagree about, one level down.
|
|
30
|
+
|
|
31
|
+
Scope is declarations that apply to every instance: a location's own, and those
|
|
32
|
+
reached through `allOf` and `$ref`. A declaration carried by `oneOf`, `anyOf`,
|
|
33
|
+
`if`/`then`/`else` or `dependentSchemas` competes with the base only while its
|
|
34
|
+
branch applies, so whether it disagrees is a state of the data rather than a
|
|
35
|
+
fact about the schema, and `SchemaProjection.diagnostics` carries the latter.
|
|
36
|
+
Those still collapse, tracked as #142.
|
|
37
|
+
|
|
38
|
+
**Behaviour change.** A caller reading `annotations.default` for such a location
|
|
39
|
+
used to get a value and now gets `undefined`. That value was one library's
|
|
40
|
+
traversal order, so relying on it was relying on the adapter rather than on the
|
|
41
|
+
schema, but it is a change and this is why the bump is `minor`, which is the
|
|
42
|
+
break bump under 0.x.
|
|
43
|
+
|
|
44
|
+
`ProjectionDiagnostic` gains an optional `sources`, the schema positions a
|
|
45
|
+
diagnostic is about, as JSON Pointers into the schema document with the root as
|
|
46
|
+
the empty string. A position reached through `$ref` is named by what it resolves
|
|
47
|
+
to. Both adapters report in that form, so a diagnostic means the same thing
|
|
48
|
+
whichever produced it.
|
|
49
|
+
|
|
50
|
+
`@texaryn/schema-json-hyperjump` implements the same rule and gains the same
|
|
51
|
+
break. It is unpublished, so it carries no version here. It also returns a
|
|
52
|
+
`diagnostics` array for the first time, carrying `ambiguous-default` and only
|
|
53
|
+
that code: it detects neither shape code, so an empty array from it is not a
|
|
54
|
+
claim that no schema in the projection was ambiguous.
|
|
55
|
+
|
|
56
|
+
`NodeProjection.itemAnnotations.default` is unchanged and still collapses. It
|
|
57
|
+
describes an array's item schema rather than being an instance location, so
|
|
58
|
+
there is no pointer an omission there could be reported at, and the element
|
|
59
|
+
locations the data provides each report their own conflict.
|
|
60
|
+
|
|
3
61
|
## 0.8.0
|
|
4
62
|
|
|
5
63
|
### Minor Changes
|
package/dist/schema/port.d.ts
CHANGED
|
@@ -8,17 +8,20 @@ export interface SchemaEvaluationPort {
|
|
|
8
8
|
export interface SchemaProjection {
|
|
9
9
|
nodes: Map<JsonPointer, NodeProjection>;
|
|
10
10
|
/**
|
|
11
|
-
* Every place the adapter could not choose
|
|
11
|
+
* Every place the adapter could not choose, and why.
|
|
12
12
|
*
|
|
13
|
-
* A pointer absent from `nodes` renders no field, and
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* make
|
|
13
|
+
* A pointer absent from `nodes` renders no field, and an annotation absent
|
|
14
|
+
* from a node states less than the schema does. Without this the caller
|
|
15
|
+
* cannot tell an intentional omission from a schema the adapter did not
|
|
16
|
+
* understand. That distinction is not cosmetic: a schema declaring a field
|
|
17
|
+
* the form silently never collects is the failure mode this exists to make
|
|
18
|
+
* visible.
|
|
18
19
|
*
|
|
19
|
-
* The rule the codes divide up: an explicit `type` is used, an
|
|
20
|
-
* structural shape is derived, and a schema that yields neither
|
|
21
|
-
* here.
|
|
20
|
+
* The rule the shape codes divide up: an explicit `type` is used, an
|
|
21
|
+
* unambiguous structural shape is derived, and a schema that yields neither
|
|
22
|
+
* is reported here. `ambiguous-default` is the same rule one level down, for
|
|
23
|
+
* a value rather than a shape. Nothing is guessed and nothing the schema
|
|
24
|
+
* declares disappears without a word.
|
|
22
25
|
*
|
|
23
26
|
* The boundary worth stating, because it is what keeps this channel worth
|
|
24
27
|
* reading: these describe schemas, not data.
|
|
@@ -38,11 +41,17 @@ export interface SchemaProjection {
|
|
|
38
41
|
*
|
|
39
42
|
* Optional, so an adapter that reports nothing stays valid, and empty rather
|
|
40
43
|
* than absent means "nothing to report".
|
|
44
|
+
*
|
|
45
|
+
* "Nothing to report" is per code rather than per adapter, and the
|
|
46
|
+
* conformance suite is what says which codes an adapter detects. An empty
|
|
47
|
+
* array is therefore not a claim that no code applies, only that none of the
|
|
48
|
+
* ones this adapter detects did.
|
|
41
49
|
*/
|
|
42
50
|
diagnostics?: readonly ProjectionDiagnostic[];
|
|
43
51
|
}
|
|
44
52
|
/**
|
|
45
|
-
* One reason a pointer
|
|
53
|
+
* One reason a pointer projects less than the schema declares: no node at all,
|
|
54
|
+
* or a node missing something the schema states.
|
|
46
55
|
*
|
|
47
56
|
* `code` is a stable identifier a caller can branch on; `message` is for a
|
|
48
57
|
* person reading a log and is not a contract.
|
|
@@ -51,6 +60,21 @@ export interface ProjectionDiagnostic {
|
|
|
51
60
|
pointer: JsonPointer;
|
|
52
61
|
code: ProjectionDiagnosticCode;
|
|
53
62
|
message: string;
|
|
63
|
+
/**
|
|
64
|
+
* The schema positions the diagnostic is about, as JSON Pointers into the
|
|
65
|
+
* schema document, with the root as the empty string. A position reached
|
|
66
|
+
* through `$ref` is named by what it resolves to rather than by the reference
|
|
67
|
+
* that pointed at it.
|
|
68
|
+
*
|
|
69
|
+
* Present where naming the positions is the useful half of the report, which
|
|
70
|
+
* is `ambiguous-default`: that two declarations disagree is far less
|
|
71
|
+
* actionable than which two. Optional because the other codes describe one
|
|
72
|
+
* schema position, already named by `pointer`.
|
|
73
|
+
*
|
|
74
|
+
* Order is not a contract. Which order an adapter walks its own applicators
|
|
75
|
+
* in is its own business; the set is what is being reported.
|
|
76
|
+
*/
|
|
77
|
+
sources?: readonly string[];
|
|
54
78
|
}
|
|
55
79
|
export type ProjectionDiagnosticCode =
|
|
56
80
|
/**
|
|
@@ -65,7 +89,22 @@ export type ProjectionDiagnosticCode =
|
|
|
65
89
|
* JSON Schema permits heterogeneous members, so `enum` says what the values
|
|
66
90
|
* are and not what type they have.
|
|
67
91
|
*/
|
|
68
|
-
| 'unresolved-projection-shape'
|
|
92
|
+
| 'unresolved-projection-shape'
|
|
93
|
+
/**
|
|
94
|
+
* Two or more `default` declarations apply to the location whatever the
|
|
95
|
+
* instance is, and they do not agree. `AnnotationSet.default` is omitted:
|
|
96
|
+
* one value is reported where the schema states one, and where it states two
|
|
97
|
+
* that disagree there is nothing to report but the disagreement.
|
|
98
|
+
*
|
|
99
|
+
* Unconditional is what makes this a fact about the schema. A location's own
|
|
100
|
+
* declaration and those reached from it through `allOf` and `$ref` all apply
|
|
101
|
+
* together, so no instance resolves them. Declarations that arrive through
|
|
102
|
+
* `oneOf`, `anyOf`, `if`/`then`/`else` or `dependentSchemas` are partitioned
|
|
103
|
+
* by the branch that carries them: they compete with each other within one
|
|
104
|
+
* branch, and a branch competing with the base is a state of the data, which
|
|
105
|
+
* this channel deliberately does not carry.
|
|
106
|
+
*/
|
|
107
|
+
| 'ambiguous-default';
|
|
69
108
|
export interface NodeProjection {
|
|
70
109
|
/**
|
|
71
110
|
* The shape a renderer should present, which is not an assertion about the
|
|
@@ -139,6 +178,15 @@ export interface AnnotationSet {
|
|
|
139
178
|
writeOnly?: boolean;
|
|
140
179
|
deprecated?: boolean;
|
|
141
180
|
examples?: unknown[];
|
|
181
|
+
/**
|
|
182
|
+
* The value the schema declares for a location that has none.
|
|
183
|
+
*
|
|
184
|
+
* Absent where two or more declarations apply unconditionally and disagree,
|
|
185
|
+
* with an `ambiguous-default` diagnostic in its place. A single value is
|
|
186
|
+
* reported where the schema states one; where it states two that disagree,
|
|
187
|
+
* reporting either would be a merge order presented as an answer, and the
|
|
188
|
+
* two adapters' merges do not even keep the same one.
|
|
189
|
+
*/
|
|
142
190
|
default?: unknown;
|
|
143
191
|
}
|
|
144
192
|
//# sourceMappingURL=port.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/schema/port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAElE,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAA;IAExC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAA;IAEvD,UAAU,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAA;CACjF;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IACvC
|
|
1
|
+
{"version":3,"file":"port.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