@texaryn/core 0.9.0 → 0.11.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 +116 -0
- package/dist/commands/handler.d.ts +13 -0
- package/dist/commands/handler.d.ts.map +1 -1
- package/dist/commands/handler.js +22 -4
- package/dist/commands/handler.js.map +1 -1
- package/dist/commands/types.d.ts +16 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/initialization/index.d.ts +4 -0
- package/dist/initialization/index.d.ts.map +1 -0
- package/dist/initialization/index.js +3 -0
- package/dist/initialization/index.js.map +1 -0
- package/dist/initialization/kernel.d.ts +133 -0
- package/dist/initialization/kernel.d.ts.map +1 -0
- package/dist/initialization/kernel.js +223 -0
- package/dist/initialization/kernel.js.map +1 -0
- package/dist/initialization/view.d.ts +16 -0
- package/dist/initialization/view.d.ts.map +1 -0
- package/dist/initialization/view.js +40 -0
- package/dist/initialization/view.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +116 -4
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +62 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/schema/port.d.ts +45 -6
- package/dist/schema/port.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/runtime/types.d.ts
CHANGED
|
@@ -4,11 +4,53 @@ import type { UIHints } from '../hints/types.js';
|
|
|
4
4
|
import type { Command } from '../commands/types.js';
|
|
5
5
|
import type { SubmissionState } from '../ir/runtime-state.js';
|
|
6
6
|
import type { NodeId, MaybePromise, ValidationError, VisibleError } from '../types.js';
|
|
7
|
+
import type { DefaultConflict, DefaultRefusal } from '../initialization/index.js';
|
|
8
|
+
/** Which initialization policy consumes the schema's `default` annotations. */
|
|
9
|
+
export type InitializationPolicy = 'none' | 'schema-defaults';
|
|
10
|
+
/**
|
|
11
|
+
* What one run of ADR-003's initialization pass did, without the data, which
|
|
12
|
+
* the runtime publishes on `data` like any other.
|
|
13
|
+
*
|
|
14
|
+
* A discarded run reports only that it was discarded. Carrying the conflicts
|
|
15
|
+
* and refusals of the run that produced them would say a run found them and
|
|
16
|
+
* then say nothing was written, and the two readings are not the same claim.
|
|
17
|
+
*/
|
|
18
|
+
export type InitializationReport = {
|
|
19
|
+
readonly outcome: 'initialized';
|
|
20
|
+
/** Locations left absent because their applicable declarations disagreed. */
|
|
21
|
+
readonly conflicts: readonly DefaultConflict[];
|
|
22
|
+
/** Locations left absent because filling would have meant guessing or destroying. */
|
|
23
|
+
readonly refusals: readonly DefaultRefusal[];
|
|
24
|
+
readonly passes: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly outcome: 'budget-exhausted';
|
|
27
|
+
readonly passes: number;
|
|
28
|
+
};
|
|
7
29
|
export interface FormRuntimeOptions {
|
|
8
30
|
initialData?: unknown;
|
|
9
31
|
hints?: UIHints;
|
|
10
32
|
onSubmit?: (data: unknown) => MaybePromise<void>;
|
|
11
33
|
validationDebounceMs?: number;
|
|
34
|
+
/**
|
|
35
|
+
* ADR-003. `'none'`, the default, materialises nothing: given `{}` the
|
|
36
|
+
* runtime's data stays `{}`.
|
|
37
|
+
*
|
|
38
|
+
* `'schema-defaults'` fills every reachable location the schema declares a
|
|
39
|
+
* default for and the data leaves absent. A location is filled when it
|
|
40
|
+
* becomes reachable, so this runs at construction, on `Reset`, and after any
|
|
41
|
+
* edit that can change what is reachable: activating a `oneOf` branch by
|
|
42
|
+
* setting its discriminator fills that branch's own defaults. It never
|
|
43
|
+
* overwrites, so `false`, `0`, `''` and `null` are values and are left alone.
|
|
44
|
+
*
|
|
45
|
+
* What the run wrote is the baseline at construction and on `Reset`, and is
|
|
46
|
+
* not between them: a location seeded by an edit differs from
|
|
47
|
+
* `state.initialData`, which is what `modified` reports.
|
|
48
|
+
*
|
|
49
|
+
* Omitting `initialData` is not the same as passing `{}`. The first states
|
|
50
|
+
* nothing about the root, so a root-level `default` applies to it; the second
|
|
51
|
+
* is a root the caller supplied, and nothing is written over it.
|
|
52
|
+
*/
|
|
53
|
+
initialization?: InitializationPolicy;
|
|
12
54
|
}
|
|
13
55
|
export interface NodeState {
|
|
14
56
|
readonly value: Store<unknown>;
|
|
@@ -25,6 +67,26 @@ export interface FormRuntime {
|
|
|
25
67
|
readonly data: Store<unknown>;
|
|
26
68
|
readonly submission: Store<SubmissionState>;
|
|
27
69
|
readonly visibleErrors: Store<VisibleError[]>;
|
|
70
|
+
/**
|
|
71
|
+
* The last initialization run, or `undefined` where no policy is configured.
|
|
72
|
+
*
|
|
73
|
+
* `dispatch` returns void and is typically called from an event handler, so a
|
|
74
|
+
* run that exhausts its budget reports here rather than throwing into the
|
|
75
|
+
* host's render. What that discards depends on the moment: a `Reset`
|
|
76
|
+
* establishes a baseline, so it is refused whole and nothing lands, while an
|
|
77
|
+
* ordinary edit establishes none, so the edit lands and only the seeding is
|
|
78
|
+
* dropped. `createFormRuntime` throws instead, because a caller can decline a
|
|
79
|
+
* runtime it never received.
|
|
80
|
+
*
|
|
81
|
+
* A new report is published on every data-mutating dispatch under the policy,
|
|
82
|
+
* including one where the pass wrote nothing, because each dispatch is a run
|
|
83
|
+
* and what a run finds changes as the user types. Anything subscribed here
|
|
84
|
+
* therefore updates per edit.
|
|
85
|
+
*
|
|
86
|
+
* It is not the projection's diagnostics channel, which describes a schema
|
|
87
|
+
* rather than one run over data.
|
|
88
|
+
*/
|
|
89
|
+
readonly initialization: Store<InitializationReport | undefined>;
|
|
28
90
|
dispatch(command: Command): void;
|
|
29
91
|
getNodeState(nodeId: NodeId): NodeState | undefined;
|
|
30
92
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.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AA;IAC3C,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAA;IAC7C;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAA;IAChE,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAChC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;IACnD,OAAO,IAAI,IAAI,CAAA;CAChB"}
|
package/dist/schema/port.d.ts
CHANGED
|
@@ -26,12 +26,23 @@ export interface SchemaProjection {
|
|
|
26
26
|
* The boundary worth stating, because it is what keeps this channel worth
|
|
27
27
|
* reading: these describe schemas, not data.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* a
|
|
34
|
-
*
|
|
29
|
+
* Two cases are therefore not reported here, and only two.
|
|
30
|
+
*
|
|
31
|
+
* A `oneOf` or `anyOf` whose branches the current value does not match, where
|
|
32
|
+
* some branch would have rendered for a value that did. That same schema
|
|
33
|
+
* projects a shape for such a value, whether the value is acceptable is
|
|
34
|
+
* validation's subject, and a form's data fails to match for most of the time
|
|
35
|
+
* someone is filling it in, so reporting it would mean a diagnostic that
|
|
36
|
+
* flaps on every keystroke.
|
|
37
|
+
*
|
|
38
|
+
* A disagreement between `default` declarations that a conditional branch
|
|
39
|
+
* carries, which holds exactly while that branch is selected and so flaps for
|
|
40
|
+
* the same reason. It is reported on `NodeProjection.defaultConflict`, which
|
|
41
|
+
* describes this projection rather than the schema and which also carries the
|
|
42
|
+
* unconditional case, so a consumer acting on a location reads one place.
|
|
43
|
+
* `ambiguous-default` here is the subset that holds whatever the instance is:
|
|
44
|
+
* a contradiction in the schema wherever it is used, which is worth telling
|
|
45
|
+
* whoever wrote it.
|
|
35
46
|
*
|
|
36
47
|
* Everything else about a composition is reported, including a branch that
|
|
37
48
|
* the value does match and that still supplies no shape, and a composition
|
|
@@ -142,6 +153,34 @@ export interface NodeProjection {
|
|
|
142
153
|
* adapter that does not select provisionally keeps its current behaviour.
|
|
143
154
|
*/
|
|
144
155
|
provisional?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Schema positions whose `default` declarations apply to this node for the
|
|
158
|
+
* instance as it stands, and disagree. Present exactly where
|
|
159
|
+
* `AnnotationSet.default` was omitted for that reason, and absent otherwise.
|
|
160
|
+
*
|
|
161
|
+
* This is the per-instance half of what `ambiguous-default` reports.
|
|
162
|
+
* `SchemaProjection.diagnostics` describes the schema, so it carries only the
|
|
163
|
+
* disagreements that hold whatever the instance is: a location's own
|
|
164
|
+
* declaration against those reached through `allOf` and `$ref`. A declaration
|
|
165
|
+
* carried by `oneOf`, `anyOf`, `if`/`then`/`else` or `dependentSchemas`
|
|
166
|
+
* competes only while its branch applies, so whether it disagrees is a state
|
|
167
|
+
* of the data and belongs here, beside `active` and `provisional`, which flap
|
|
168
|
+
* with the data for the same reason.
|
|
169
|
+
*
|
|
170
|
+
* Every conflict appears here, conditional or not, so a consumer deciding
|
|
171
|
+
* what to do about a location reads one place. The diagnostic stays for the
|
|
172
|
+
* unconditional case because a contradiction that holds for every instance is
|
|
173
|
+
* worth reporting to whoever wrote the schema.
|
|
174
|
+
*
|
|
175
|
+
* **A provisionally selected branch's declarations compete**, though JSON
|
|
176
|
+
* Schema says the branch does not apply. The projection exposes that branch so
|
|
177
|
+
* the user can complete it and a policy may fill from it, so a disagreement
|
|
178
|
+
* has to be visible wherever the fill would happen. Applicability here is
|
|
179
|
+
* therefore exposure, matching `active || provisional`, rather than validity.
|
|
180
|
+
*
|
|
181
|
+
* Order is not a contract; the set is.
|
|
182
|
+
*/
|
|
183
|
+
defaultConflict?: readonly string[];
|
|
145
184
|
annotations: AnnotationSet;
|
|
146
185
|
/**
|
|
147
186
|
* Annotations of an array's item template, for arrays only.
|
|
@@ -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.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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