@texaryn/schema-json 0.6.2 → 0.7.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 CHANGED
@@ -1,5 +1,72 @@
1
1
  # @texaryn/schema-json
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - eae5f41: A recursive local `$ref` projects, validates and initializes, closing #119. The
8
+ projection expands it once past the data, marks the objects above what it
9
+ withheld with `recursion` or `budget` boundaries, and projects at most 16
10
+ objects and 512 nodes that exist because of the recursion, never cutting a
11
+ member of a location that holds data. Each `$ref` site resolves to one compiled
12
+ target per adapter, which bounds the cost of a large object behind one `$ref`:
13
+ 500 string fields project in 5 ms on an Apple M1 Max.
14
+
15
+ `createJsonSchemaAdapter` rejects a schema that applies itself at one instance
16
+ location with `SameLocationCycleError`, which names the position and the path.
17
+ That includes a self-application under an `if`, which constructed before and
18
+ validated only while its condition was false.
19
+
20
+ In Draft 7, `"$ref": "#"` resolves to the document root, so validation of a
21
+ recursive Draft 7 schema is correct, and the draft-07 metaschema renders the
22
+ root fields that reference the root. The fix pins an internal of
23
+ json-schema-library 11.6.2, so the dependency range is `~11.6.2`, and adapter
24
+ creation fails with an error naming that release if the internal changes.
25
+
26
+ A field behind a chain of `$ref`s, a reference to a definition that is itself a
27
+ `$ref`, now projects, where it was dropped with an `unresolved-projection-shape`
28
+ diagnostic. In Draft 7, the fields under a `oneOf` or `anyOf` wrapper around a
29
+ `$ref`, nested or not, stay projected once they hold data, where the subtree
30
+ disappeared.
31
+
32
+ Fields declared only under a branch the specification never evaluates (a `then`
33
+ or `else` without `if`, a `then` under `if: false`, an `else` under `if: true`)
34
+ are not projected unless a reference points into the branch or a schema inside
35
+ it declares an `$id`, `$anchor` or `$dynamicAnchor`. Validation runs on the
36
+ schema as written, so an error only such a branch declares attaches to no field,
37
+ and `validate` returns the same result before and after a projection.
38
+
39
+ A schema with no recursive position projects its nodes in the same order as
40
+ before, so `schema-defaults` writes the same keys in the same order. In Draft 7,
41
+ the siblings of a `$ref` take no part in schema identity, and every registry
42
+ entry json-schema-library files for its own location is pinned, so a projection
43
+ cannot replace a definition with a reduced copy that a later reference resolves
44
+ to. A `$ref` chain is followed only through sites that add nothing but
45
+ annotations, so a `type`, `format` or `enum` beside a 2019-09 or 2020-12 `$ref`
46
+ still applies. An `$anchor`, `$dynamicAnchor` or Draft 7 fragment `$id` inside
47
+ such a kept branch is a reference target, so a cycle through it is rejected and
48
+ recursion through it is bounded. An `$id` declared under both `$defs` and
49
+ `definitions` resolves as json-schema-library resolves it, a reference with a
50
+ malformed percent escape such as `#/properties/50%off` keeps its raw spelling,
51
+ and only an own property of the data counts as holding data, so a member named
52
+ `constructor` is absent at `{}`.
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies [eae5f41]
57
+ - @texaryn/core@0.13.0
58
+
59
+ ## 0.6.3
60
+
61
+ ### Patch Changes
62
+
63
+ - 609ad71: The README states when a schema's own `format` keywords are asserted: in
64
+ Draft 7, including a schema whose `$schema` is absent or unrecognized while the
65
+ fallback is `draft-07`, and never in 2019-09 or 2020-12, where declaring the
66
+ format-assertion vocabulary does not turn it on. The `format` keywords inside a
67
+ published metaschema reached through `$ref` are asserted in every dialect. No
68
+ code changes.
69
+
3
70
  ## 0.6.2
4
71
 
5
72
  ### Patch Changes
package/README.md CHANGED
@@ -49,7 +49,7 @@ The returned object implements `SchemaEvaluationPort` from `@texaryn/core`.
49
49
  | 2019-09 | Supported |
50
50
  | 2020-12 | Supported |
51
51
 
52
- Dialect support does not mean every keyword generates a form control or that Texaryn provides full specification compliance. See the [JSON Schema support guide](https://texaryn.github.io/texaryn/guides/json-schema-support/) for the capability matrix, projection limits and validation behavior, including disabled `format` assertions for 2020-12.
52
+ Dialect support does not mean every keyword generates a form control or that Texaryn provides full specification compliance. See the [JSON Schema support guide](https://texaryn.github.io/texaryn/guides/json-schema-support/) for the capability matrix, projection limits and validation behavior.
53
53
 
54
54
  The adapter detects the dialect from `$schema`. If `$schema` is absent or unrecognized, the adapter uses `draft-07` by default. You can override the fallback:
55
55
 
@@ -59,6 +59,8 @@ const adapter = await createJsonSchemaAdapter(schema, {
59
59
  })
60
60
  ```
61
61
 
62
+ The detected dialect alone decides whether the schema's own `format` keywords are asserted. Draft 7 asserts them, and so does a schema whose `$schema` is absent or unrecognized while the fallback is `draft-07`; 2019-09 and 2020-12 never do, even when the format-assertion vocabulary is declared, and the adapter has no option that changes that. The `format` keywords inside a published metaschema reached through `$ref` are asserted in every dialect.
63
+
62
64
  ## Projection
63
65
 
64
66
  `project(data)` turns the schema plus current instance data into a framework-neutral `SchemaProjection`.
@@ -82,7 +84,7 @@ The adapter currently handles the schema features required by Texaryn's runtime
82
84
  - objects and primitive fields
83
85
  - arrays
84
86
  - enums
85
- - local `$ref`
87
+ - local `$ref`, including recursive references
86
88
  - `if` / `then` / `else`
87
89
  - `oneOf`
88
90
  - `anyOf`
@@ -91,7 +93,21 @@ The adapter currently handles the schema features required by Texaryn's runtime
91
93
  - Draft 7 `dependencies`
92
94
  - annotations and field constraints
93
95
 
94
- Inactive conditional fields remain represented in the projection with `active: false`, allowing the runtime and renderer to preserve a deterministic UI structure across branch changes.
96
+ Inactive conditional fields remain represented in the projection with `active: false`, allowing the runtime and renderer to preserve a deterministic UI structure across branch changes. A branch the specification never evaluates (a `then` or `else` without `if`, a `then` under `if: false`, an `else` under `if: true`) contributes no fields unless a reference points into it or a schema inside it declares an `$id`, `$anchor` or `$dynamicAnchor`.
97
+
98
+ ## Recursive schemas
99
+
100
+ A local `$ref` may point back to a schema that contains it, such as `{ properties: { child: { $ref: '#' } } }` or a definition that refers to itself. The projection expands such a schema once past the data: below the last location that holds data, a path never applies the same schemas twice. At `{}` the example above projects `/child`, and once `/child` holds an object it projects `/child/child`. Each level the user fills exposes the next.
101
+
102
+ `boundaries` on an object's `NodeProjection` says why the projection withheld something beneath it: `recursion` when a descendant would repeat the object's schemas, `budget` when a fixed per-projection limit withheld members. The limits are 16 objects and 512 nodes, counted only over locations that exist because of the recursion, two or more levels below the data; they never cut a member of a location that holds data. A node the projection reached only by expanding the recursion carries `recursiveExpansion`, and `schema-defaults` initialization never writes there.
103
+
104
+ A schema that applies itself at one instance location without crossing into a property or item, such as `{ allOf: [{ $ref: '#' }] }`, makes the evaluator recurse without end, so `createJsonSchemaAdapter` rejects it with `SameLocationCycleError`. Its `positions` field lists the schema positions of each cycle, and the message names one of them and the path through the cycle. The check reads the schema, not the data: a cycle behind an `if` is rejected even while the `if` does not hold, except the branches the specification never evaluates. It is conservative for dynamic references, treating a `$dynamicRef` to a `$dynamicAnchor` as reaching every `$dynamicAnchor` of that name and a `$recursiveRef` as reaching every schema that declares `$recursiveAnchor: true`, so a schema whose dynamic references could close such a cycle is rejected even when no evaluation selects it.
105
+
106
+ The [JSON Schema support guide](https://texaryn.github.io/texaryn/guides/json-schema-support/#recursive-references) has the details, and ADR-007 records the decision.
107
+
108
+ ## json-schema-library version
109
+
110
+ The dependency range is `~11.6.2`. In Draft 7, json-schema-library 11.6.2 overwrites the registry entry that `"$ref": "#"` resolves through, so without a fix the reference reaches another node and validation is wrong. The adapter pins that entry to the document root, and every other entry the library files for its own location to the node compiled there, so a reduction during projection cannot replace a definition with a reduced copy. Because the fix depends on the library's internal registry, adapter creation throws an error naming json-schema-library 11.6.2 when the registry is shaped differently, or when a self-test on two probe schemas shows the fix no longer repairs validation. A new json-schema-library minor needs a Texaryn release that verifies the internal again.
95
111
 
96
112
  ## Validation
97
113
 
@@ -133,6 +149,7 @@ The result contains validation errors at that pointer or below it.
133
149
  ```ts
134
150
  import {
135
151
  createJsonSchemaAdapter,
152
+ SameLocationCycleError,
136
153
  type AdapterConfig,
137
154
  type Dialect,
138
155
  } from '@texaryn/schema-json'
@@ -164,6 +181,19 @@ The union of dialect identifiers the adapter recognizes:
164
181
  type Dialect = 'draft-07' | '2019-09' | '2020-12'
165
182
  ```
166
183
 
184
+ ### `SameLocationCycleError`
185
+
186
+ Thrown by `createJsonSchemaAdapter` for a schema that applies itself at one instance location. A host that loads authored schemas can tell a broken schema from a failed load with `instanceof`:
187
+
188
+ ```ts
189
+ try {
190
+ await createJsonSchemaAdapter(schema)
191
+ } catch (error) {
192
+ if (error instanceof SameLocationCycleError) console.log(error.positions, error.message)
193
+ else throw error
194
+ }
195
+ ```
196
+
167
197
  ## Architecture
168
198
 
169
199
  The adapter is deliberately separate from `@texaryn/core`:
package/dist/adapter.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type ProjectionLimits } from './projection.js';
1
2
  import type { AdapterConfig, JsonSchemaAdapter } from './types.js';
2
3
  export declare function createJsonSchemaAdapter(schema: unknown, config?: AdapterConfig): Promise<JsonSchemaAdapter>;
4
+ export declare function createAdapter(schema: unknown, config: AdapterConfig | undefined, limits: ProjectionLimits): Promise<JsonSchemaAdapter>;
3
5
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAElE,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CAoB5B"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIxF,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAElE,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CA8B5B"}
package/dist/adapter.js CHANGED
@@ -1,21 +1,38 @@
1
1
  import { compileSchema, } from 'json-schema-library';
2
2
  import { detectDialect } from './dialect.js';
3
3
  import { loadMetaschemas, referencedDialects } from './metaschemas/index.js';
4
- import { buildProjection } from './projection.js';
4
+ import { newProjectionCache } from './identity.js';
5
+ import { buildProjection, DEFAULT_LIMITS } from './projection.js';
6
+ import { withoutUnreachableBranches } from './normalize.js';
7
+ import { fixRootReference } from './root-reference.js';
8
+ import { buildSchemaGraph, rejectSameLocationCycles, cyclicPositions, markPositions } from './schema-graph.js';
5
9
  export async function createJsonSchemaAdapter(schema, config) {
10
+ return createAdapter(schema, config, DEFAULT_LIMITS);
11
+ }
12
+ export async function createAdapter(schema, config, limits) {
6
13
  const dialect = detectDialect(schema, {
7
14
  defaultDialect: config?.defaultDialect ?? 'draft-07',
8
15
  });
9
- const prepared = await prepareSchema(schema, dialect);
16
+ // json-schema-library carries no metaschema documents, so a schema referencing its own fails closed.
17
+ const referenced = referencedDialects(schema);
18
+ const remotes = referenced.length > 0 ? await loadMetaschemas(referenced) : undefined;
19
+ // json-schema-library evaluates some branches the specification never does, so only the projection drops them.
20
+ const document = withoutUnreachableBranches(schema);
21
+ const graph = buildSchemaGraph(document, dialect, remotes ?? []);
22
+ rejectSameLocationCycles(graph);
23
+ const marked = markPositions(graph, document, remotes ?? []);
24
+ const validated = await prepareSchema(schema, dialect, remotes);
25
+ const projected = await prepareSchema(marked.document, dialect, remotes && marked.remotes);
26
+ const cache = newProjectionCache(dialect, cyclicPositions(graph), marked.at);
10
27
  return {
11
28
  project(data) {
12
- return buildProjection(prepared, data);
29
+ return buildProjection(projected, data, cache, limits);
13
30
  },
14
31
  validate(data) {
15
- return runValidation(prepared, data);
32
+ return runValidation(validated, data);
16
33
  },
17
34
  validateAt(data, pointer) {
18
- return runValidationAt(prepared, data, pointer);
35
+ return runValidationAt(validated, data, pointer);
19
36
  },
20
37
  };
21
38
  }
@@ -27,24 +44,20 @@ function toDraftOption(dialect) {
27
44
  // compileSchema() is synchronous for schemas with only local $ref (Phase 1's scope); it is
28
45
  // wrapped in a Promise so the factory signature stays uniform with libraries whose
29
46
  // preparation step is genuinely async (e.g. hyperjump's annotate()).
30
- async function prepareSchema(schema, dialect) {
31
- // A schema may reference its dialect's metaschema to assert that it is
32
- // itself a valid schema. json-schema-library carries the draft definitions
33
- // but not the metaschema documents, and an unresolved reference fails
34
- // closed, so without these a valid schema is reported invalid.
35
- const referenced = referencedDialects(schema);
36
- const remotes = referenced.length > 0 ? await loadMetaschemas(referenced) : undefined;
47
+ async function prepareSchema(schema, dialect, remotes) {
37
48
  // json-schema-library asserts `format` in every dialect. Draft 7 permits that:
38
49
  // assertion is the conventional behaviour there and the specification only asks
39
50
  // that it can be disabled. From 2019-09 the default inverted, and `format` is an
40
51
  // annotation unless the format-assertion vocabulary is declared, so asserting it
41
52
  // is a deviation rather than a stricter setting.
42
53
  const formatAssertion = dialect === 'draft-07' ? undefined : false;
43
- return compileSchema(schema, {
54
+ const root = compileSchema(schema, {
44
55
  draft: toDraftOption(dialect),
45
56
  formatAssertion,
46
57
  remotes,
47
58
  });
59
+ fixRootReference(root, dialect);
60
+ return root;
48
61
  }
49
62
  // json-schema-library reports data pointers as "#"-prefixed URI fragments (e.g. "#/age");
50
63
  // ValidationError.instancePointer expects an RFC 6901 JSON Pointer (e.g. "/age").
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAKd,MAAM,qBAAqB,CAAA;AAQ5B,OAAO,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGjD,MA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ACvD,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IAE3C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,KAAK,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,CAC9F,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACvD,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type SchemaNode } from 'json-schema-library';
2
+ import type { Dialect } from './dialect.js';
3
+ export interface LocationInfo {
4
+ readonly key: string;
5
+ readonly cycle: boolean;
6
+ readonly cyclic: boolean;
7
+ readonly expanded: readonly SchemaNode[];
8
+ readonly dead: ReadonlySet<SchemaNode>;
9
+ readonly children: Map<string, readonly SchemaNode[]>;
10
+ items?: readonly SchemaNode[];
11
+ }
12
+ export interface ProjectionCache {
13
+ readonly dialect: Dialect;
14
+ readonly schemaAt: (position: string) => unknown;
15
+ readonly closure: Map<string, readonly string[]>;
16
+ readonly info: Map<string, LocationInfo>;
17
+ readonly cyclic: ReadonlySet<string>;
18
+ }
19
+ export declare function newProjectionCache(dialect: Dialect, cyclic: ReadonlySet<string>, schemaAt: (position: string) => unknown): ProjectionCache;
20
+ export declare function onlyPoints(node: SchemaNode): boolean;
21
+ export declare function positionOf(node: SchemaNode): string;
22
+ export declare function followRef(node: SchemaNode): SchemaNode | undefined;
23
+ export declare function locationInfo(declaring: readonly SchemaNode[], cache: ProjectionCache): LocationInfo;
24
+ export declare function childDeclaring(info: LocationInfo, key: string): readonly SchemaNode[];
25
+ export declare function itemDeclaring(info: LocationInfo): readonly SchemaNode[];
26
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["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,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CA6BlE;AA0CD,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,EAAE,KAAK,EAAE,eAAe,GAAG,YAAY,CAoEnG;AAmBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,UAAU,EAAE,CAMrF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,UAAU,EAAE,CAMvE"}
@@ -0,0 +1,280 @@
1
+ import { isSchemaNode, settings } from 'json-schema-library';
2
+ import { POSITION, escape } from './schema-graph.js';
3
+ export function newProjectionCache(dialect, cyclic, schemaAt) {
4
+ return { dialect, schemaAt, closure: new Map(), info: new Map(), cyclic };
5
+ }
6
+ const IN_PLACE_BRANCHES = ['if', 'then', 'else'];
7
+ const UNLOCATED_CHILDREN = [...IN_PLACE_BRANCHES, 'contains'];
8
+ const NON_APPLYING = new Set([
9
+ '$ref',
10
+ '$schema',
11
+ '$id',
12
+ '$anchor',
13
+ '$dynamicAnchor',
14
+ '$recursiveAnchor',
15
+ '$vocabulary',
16
+ '$comment',
17
+ '$defs',
18
+ 'definitions',
19
+ POSITION,
20
+ ]);
21
+ // Draft 7 ignores a $ref's siblings, and the library copies the annotations to merge onto the target.
22
+ export function onlyPoints(node) {
23
+ if (node.getDraftVersion() === 'draft-07')
24
+ return true;
25
+ return Object.keys(node.schema).every((keyword) => NON_APPLYING.has(keyword) || settings.PROPERTIES_TO_MERGE.includes(keyword));
26
+ }
27
+ function markerOf(node) {
28
+ const schema = node.schema;
29
+ const marker = typeof schema === 'object' && schema !== null && Object.hasOwn(schema, POSITION) ? schema[POSITION] : undefined;
30
+ return typeof marker === 'string' ? marker : undefined;
31
+ }
32
+ // A boolean carries no marker, nor does an if, then or else json-schema-library parses beside a draft-07 $ref.
33
+ // The library locates an if, then, else or contains by its parent's location plus the whole evaluation path, and reduceNode strips if, then and else.
34
+ function unmarkedPosition(node) {
35
+ const own = typeof node.schemaLocation === 'string' ? node.schemaLocation : '#';
36
+ const parent = node.parent;
37
+ if (!parent || parent === node)
38
+ return own;
39
+ const branch = UNLOCATED_CHILDREN.find((keyword) => parent[keyword] === node || node.evaluationPath === `${parent.evaluationPath}/${keyword}`);
40
+ if (branch)
41
+ return `${positionOf(parent)}/${branch}`;
42
+ const parentOwn = parent.schemaLocation;
43
+ if (typeof parentOwn === 'string' && (own === parentOwn || own.startsWith(`${parentOwn}/`))) {
44
+ const suffix = own.slice(parentOwn.length);
45
+ const keyword = suffix.split('/')[1] ?? '';
46
+ const key = memberKey(parent, keyword, node) ?? strippedMemberKey(parent, keyword, node, suffix);
47
+ return key === undefined ? `${positionOf(parent)}${suffix}` : `${positionOf(parent)}/${keyword}/${escape(key)}`;
48
+ }
49
+ return own;
50
+ }
51
+ const memberKeys = new WeakMap();
52
+ function keyIn(map, entries, node) {
53
+ let keys = memberKeys.get(map);
54
+ if (!keys) {
55
+ const index = new Map();
56
+ for (const [key, child] of entries())
57
+ if (isSchemaNode(child) && !index.has(child))
58
+ index.set(child, key);
59
+ memberKeys.set(map, index);
60
+ keys = index;
61
+ }
62
+ return keys.get(node);
63
+ }
64
+ function memberKey(parent, keyword, node) {
65
+ const map = keyword === 'properties' ? parent.properties
66
+ : keyword === '$defs' || keyword === 'definitions' ? parent.$defs
67
+ : keyword === 'dependencies' || keyword === 'dependentSchemas' ? parent.dependentSchemas
68
+ : undefined;
69
+ if (map)
70
+ return keyIn(map, () => Object.entries(map), node);
71
+ const patterns = parent.patternProperties;
72
+ if (keyword === 'patternProperties' && patterns) {
73
+ return keyIn(patterns, () => patterns.map(({ name, node: child }) => [name, child]), node);
74
+ }
75
+ return undefined;
76
+ }
77
+ const STRIPPED_MAPS = new Set(['$defs', 'definitions', 'dependencies', 'dependentSchemas', 'patternProperties']);
78
+ function strippedMemberKey(parent, keyword, node, suffix) {
79
+ if (!STRIPPED_MAPS.has(keyword) || !node.evaluationPath.startsWith(`${parent.evaluationPath}/${keyword}/`))
80
+ return undefined;
81
+ const spelled = suffix.slice(keyword.length + 2);
82
+ return keyword === 'definitions' ? decodeURIComponent(spelled).replace(/~1/g, '/').replace(/~0/g, '~') : spelled;
83
+ }
84
+ export function positionOf(node) {
85
+ return markerOf(node) ?? unmarkedPosition(node);
86
+ }
87
+ // resolveRef() compiles a fresh copy of the target on every call; one copy per
88
+ // static reference site and compiled document is enough.
89
+ const resolvedReferences = new WeakMap();
90
+ function resolveFresh(node) {
91
+ const next = node.resolveRef();
92
+ return isSchemaNode(next) ? next : undefined;
93
+ }
94
+ export function followRef(node) {
95
+ if (node.$ref === '') {
96
+ const root = node.context?.rootNode;
97
+ if (root)
98
+ return root;
99
+ }
100
+ const context = node.context;
101
+ const raw = node.schema;
102
+ const dynamic = typeof raw === 'object' && raw !== null && ('$dynamicRef' in raw || '$recursiveRef' in raw);
103
+ if (!context || dynamic)
104
+ return resolveFresh(node);
105
+ let cache = resolvedReferences.get(context);
106
+ if (!cache) {
107
+ cache = new Map();
108
+ resolvedReferences.set(context, cache);
109
+ }
110
+ // The target is compiled with these keywords of the referring node copied onto it.
111
+ const copied = JSON.stringify(Object.fromEntries(settings.PROPERTIES_TO_MERGE.filter((keyword) => raw?.[keyword] !== undefined).map((keyword) => [
112
+ keyword,
113
+ raw[keyword],
114
+ ])));
115
+ // A copy keeps the referring site's library location, which default sources read.
116
+ const key = `${positionOf(node)}|${String(node.schemaLocation)}|${node.$ref}|${copied}`;
117
+ if (cache.has(key))
118
+ return cache.get(key);
119
+ const resolved = resolveFresh(node);
120
+ cache.set(key, resolved);
121
+ return resolved;
122
+ }
123
+ // Read from the document rather than the node: a node reached through `$ref`
124
+ // carries the referring site's merged annotations.
125
+ function authoredSchema(node, cache) {
126
+ const marker = markerOf(node);
127
+ return (marker === undefined ? undefined : cache.schemaAt(marker)) ?? node.schema;
128
+ }
129
+ function closureOf(node, cache, stack) {
130
+ const position = positionOf(node);
131
+ const cached = cache.closure.get(position);
132
+ if (cached)
133
+ return cached;
134
+ if (stack.has(position))
135
+ return [];
136
+ stack.add(position);
137
+ const out = new Set();
138
+ const addAllOf = () => {
139
+ for (const branch of node.allOf ?? [])
140
+ for (const p of closureOf(branch, cache, stack))
141
+ out.add(p);
142
+ };
143
+ if (typeof node.$ref === 'string') {
144
+ if (cache.dialect !== 'draft-07') {
145
+ const raw = authoredSchema(node, cache);
146
+ if (typeof raw === 'object' && raw !== null && Object.keys(raw).some((keyword) => !NON_APPLYING.has(keyword))) {
147
+ out.add(position);
148
+ }
149
+ addAllOf();
150
+ }
151
+ const target = followRef(node);
152
+ if (target)
153
+ for (const p of closureOf(target, cache, stack))
154
+ out.add(p);
155
+ }
156
+ else {
157
+ out.add(position);
158
+ addAllOf();
159
+ }
160
+ stack.delete(position);
161
+ const result = [...out];
162
+ cache.closure.set(position, result);
163
+ return result;
164
+ }
165
+ // A member of a branch that never applies declares its location, but its references do not extend live identity.
166
+ const deadMembers = new WeakMap();
167
+ export function locationInfo(declaring, cache) {
168
+ const members = deadMembers.get(declaring);
169
+ const memoKey = declaring.map((node) => `${positionOf(node)}${members?.has(node) ? '|dead' : ''}`).sort().join('\n');
170
+ const cached = cache.info.get(memoKey);
171
+ if (cached)
172
+ return cached;
173
+ const identity = new Set();
174
+ for (const node of declaring) {
175
+ if (members?.has(node))
176
+ identity.add(positionOf(node));
177
+ else
178
+ for (const p of closureOf(node, cache, new Set()))
179
+ identity.add(p);
180
+ }
181
+ let cycle = false;
182
+ const expanded = [];
183
+ const deadNodes = new Set();
184
+ const seen = new Map();
185
+ const visitAll = (node, stack, dead = false) => {
186
+ const position = positionOf(node);
187
+ if (stack.has(position)) {
188
+ if (!dead)
189
+ cycle = true;
190
+ return;
191
+ }
192
+ const first = seen.get(position);
193
+ if (first && (dead || !deadNodes.has(first)))
194
+ return;
195
+ if (first)
196
+ deadNodes.delete(first);
197
+ else {
198
+ seen.set(position, node);
199
+ expanded.push(node);
200
+ if (dead)
201
+ deadNodes.add(node);
202
+ }
203
+ stack.add(position);
204
+ if (typeof node.$ref === 'string') {
205
+ const target = followRef(node);
206
+ if (target)
207
+ visitAll(target, stack, dead);
208
+ if (cache.dialect === 'draft-07') {
209
+ stack.delete(position);
210
+ return;
211
+ }
212
+ }
213
+ const raw = authoredSchema(node, cache);
214
+ const condition = typeof raw === 'object' && raw !== null && 'if' in raw ? raw.if : undefined;
215
+ for (const keyword of IN_PLACE_BRANCHES) {
216
+ const branch = node[keyword];
217
+ const never = (keyword === 'then' && (condition === undefined || condition === false)) ||
218
+ (keyword === 'else' && (condition === undefined || condition === true));
219
+ if (branch && isSchemaNode(branch))
220
+ visitAll(branch, stack, dead || never);
221
+ }
222
+ for (const branches of [node.allOf, node.anyOf, node.oneOf]) {
223
+ for (const branch of branches ?? [])
224
+ visitAll(branch, stack, dead);
225
+ }
226
+ for (const dependency of Object.values(node.dependentSchemas ?? {})) {
227
+ if (dependency && isSchemaNode(dependency))
228
+ visitAll(dependency, stack, dead);
229
+ }
230
+ stack.delete(position);
231
+ };
232
+ for (const node of declaring)
233
+ visitAll(node, new Set());
234
+ const info = {
235
+ key: [...identity].sort().join('\n'),
236
+ cycle,
237
+ cyclic: [...identity].some((position) => cache.cyclic.has(position)),
238
+ expanded,
239
+ dead: deadNodes,
240
+ children: new Map(),
241
+ };
242
+ cache.info.set(memoKey, info);
243
+ return info;
244
+ }
245
+ function declaredBelow(info, member) {
246
+ const found = [];
247
+ const dead = new Set();
248
+ const seen = new Set();
249
+ for (const node of info.expanded) {
250
+ const child = member(node);
251
+ if (!child)
252
+ continue;
253
+ const position = positionOf(child);
254
+ if (seen.has(position))
255
+ continue;
256
+ seen.add(position);
257
+ found.push(child);
258
+ if (info.dead.has(node))
259
+ dead.add(child);
260
+ }
261
+ if (dead.size > 0)
262
+ deadMembers.set(found, dead);
263
+ return found;
264
+ }
265
+ export function childDeclaring(info, key) {
266
+ const cached = info.children.get(key);
267
+ if (cached)
268
+ return cached;
269
+ const found = declaredBelow(info, (node) => node.properties?.[key]);
270
+ info.children.set(key, found);
271
+ return found;
272
+ }
273
+ export function itemDeclaring(info) {
274
+ info.items ??= declaredBelow(info, (node) => {
275
+ const items = node.items;
276
+ return items && isSchemaNode(items) ? items : undefined;
277
+ });
278
+ return info.items;
279
+ }
280
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,qBAAqB,CAAA;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAoBpD,MAAM,UAAU,kBAAkB,CAChC,OAAgB,EAChB,MAA2B,EAC3B,QAAuC;IAEvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,CAAA;AAC3E,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AACzD,MAAM,kBAAkB,GAAG,CAAC,GAAG,iBAAiB,EAAE,UAAU,CAAU,CAAA;AACtE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM;IACN,SAAS;IACT,KAAK;IACL,SAAS;IACT,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;IACb,UAAU;IACV,OAAO;IACP,aAAa;IACb,QAAQ;CACT,CAAC,CAAA;AAEF,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,IAAgB;IACzC,IAAI,IAAI,CAAC,eAAe,EAAE,KAAK,UAAU;QAAE,OAAO,IAAI,CAAA;IACtD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC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ChC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAClB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;QAAE,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC/C,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAkB,EAAE,GAAW;IAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACrC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IACzB,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAA2B,CAAC,CAAA;IAC7F,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC7B,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAkB;IAC9C,IAAI,CAAC,KAAK,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAA+B,CAAA;QAClD,OAAO,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IACzD,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAC,KAAK,CAAA;AACnB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { createJsonSchemaAdapter } from './adapter.js';
2
2
  export type { AdapterConfig } from './types.js';
3
3
  export type { Dialect } from './dialect.js';
4
+ export { SameLocationCycleError } from './schema-graph.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { createJsonSchemaAdapter } from './adapter.js';
2
+ export { SameLocationCycleError } from './schema-graph.js';
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAGtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Keeps a branch the specification never evaluates when a reference or an identifier could reach it. */
2
+ export declare function withoutUnreachableBranches(document: unknown): unknown;
3
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAyFA,yGAAyG;AACzG,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAmCrE"}