@texaryn/schema-json 0.8.1 → 0.8.3
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 +14 -0
- package/README.md +2 -2
- package/THIRD-PARTY-NOTICES.md +3 -2
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +0 -2
- package/dist/adapter.js.map +1 -1
- package/dist/bare-maps.d.ts +1 -1
- package/dist/bare-maps.d.ts.map +1 -1
- package/dist/bare-maps.js.map +1 -1
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js.map +1 -1
- package/dist/metaschemas/2019-09.d.ts +1 -1
- package/dist/metaschemas/2019-09.d.ts.map +1 -1
- package/dist/metaschemas/2020-12.d.ts +1 -1
- package/dist/metaschemas/2020-12.d.ts.map +1 -1
- package/dist/metaschemas/draft-07.d.ts +1 -1
- package/dist/metaschemas/draft-07.d.ts.map +1 -1
- package/dist/metaschemas/index.d.ts +1 -1
- package/dist/metaschemas/index.d.ts.map +1 -1
- package/dist/projection-validation-coherence.d.ts +1 -1
- package/dist/projection-validation-coherence.d.ts.map +1 -1
- package/dist/projection-validation-coherence.js.map +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js.map +1 -1
- package/dist/submission-projection.d.ts +1 -1
- package/dist/submission-projection.d.ts.map +1 -1
- package/dist/submission-projection.js +19 -3
- package/dist/submission-projection.js.map +1 -1
- package/dist/vendor/json-schema-library/index.mjs +1 -1
- package/dist/vendor/json-schema-library/index.mjs.map +1 -1
- package/dist/vendor/json-schema-library/rolldown-runtime-D9-fqq9M.mjs +1 -0
- package/package.json +4 -4
- package/dist/root-reference.d.ts +0 -4
- package/dist/root-reference.d.ts.map +0 -1
- package/dist/root-reference.js +0 -86
- package/dist/root-reference.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);export{e as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@texaryn/schema-json",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "JSON Schema evaluation and validation adapter for Texaryn",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"json-schema",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@sagold/json-pointer": "^7.2.1",
|
|
47
|
+
"@texaryn/json-schema-library": "^11.6.6",
|
|
47
48
|
"fast-copy": "^4.0.4",
|
|
48
49
|
"fast-deep-equal": "^3.1.3",
|
|
49
|
-
"json-schema-library": "11.6.2",
|
|
50
|
-
"uri-js": "^4.4.1",
|
|
51
50
|
"valid-url": "^1.0.9",
|
|
52
|
-
"@texaryn/core": "^0.
|
|
51
|
+
"@texaryn/core": "^0.15.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
54
|
+
"@sinclair/typebox": "^0.34.52",
|
|
55
55
|
"tsx": "^4.23.12",
|
|
56
56
|
"vitest": "^3.0.0"
|
|
57
57
|
},
|
package/dist/root-reference.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root-reference.d.ts","sourceRoot":"","sources":["../src/root-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAuF3C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAIzE"}
|
package/dist/root-reference.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { compileSchema, isSchemaNode } from './vendor/json-schema-library/index.mjs';
|
|
2
|
-
const TESTED = 'json-schema-library 11.6.2';
|
|
3
|
-
function registryOf(root) {
|
|
4
|
-
const context = root.context;
|
|
5
|
-
if (typeof context !== 'object' || context === null)
|
|
6
|
-
fail('the compiled root has no "context"');
|
|
7
|
-
const { refs, rootNode } = context;
|
|
8
|
-
if (rootNode !== root)
|
|
9
|
-
fail('"context.rootNode" is not the compiled root');
|
|
10
|
-
if (typeof refs !== 'object' || refs === null || Object.getPrototypeOf(refs) !== Object.prototype) {
|
|
11
|
-
fail('"context.refs" is not a plain object');
|
|
12
|
-
}
|
|
13
|
-
return refs;
|
|
14
|
-
}
|
|
15
|
-
// "$ref": "#" normalises to the root's base URI without its fragment, empty for an anonymous root.
|
|
16
|
-
function rootKey(root) {
|
|
17
|
-
const id = root.$id;
|
|
18
|
-
if (id === undefined)
|
|
19
|
-
return '';
|
|
20
|
-
if (typeof id !== 'string')
|
|
21
|
-
fail('the compiled root has a non-string "$id"');
|
|
22
|
-
return id.replace(/#.*$/, '');
|
|
23
|
-
}
|
|
24
|
-
function fail(reason) {
|
|
25
|
-
throw new Error(`@texaryn/schema-json: json-schema-library's reference registry is not shaped as in ${TESTED} ` +
|
|
26
|
-
`(${reason}). The Draft 7 adapter keeps each registry entry compiled for its own location ` +
|
|
27
|
-
`fixed, because that release overwrites entries during reductions and a "$ref" then resolves ` +
|
|
28
|
-
`to a reduced copy; without the fix Draft 7 validation is wrong, so the adapter refuses to start.`);
|
|
29
|
-
}
|
|
30
|
-
function pin(refs, key, node) {
|
|
31
|
-
Object.defineProperty(refs, key, { get: () => node, set: () => { }, enumerable: true, configurable: true });
|
|
32
|
-
}
|
|
33
|
-
function pinRegistry(root) {
|
|
34
|
-
const refs = registryOf(root);
|
|
35
|
-
const key = rootKey(root);
|
|
36
|
-
const descriptor = Object.getOwnPropertyDescriptor(refs, key);
|
|
37
|
-
if (!descriptor)
|
|
38
|
-
fail(`no entry for the root key ${JSON.stringify(key)}`);
|
|
39
|
-
if (!('value' in descriptor) || !descriptor.writable || !descriptor.configurable) {
|
|
40
|
-
fail(`the entry for ${JSON.stringify(key)} is not a writable data property`);
|
|
41
|
-
}
|
|
42
|
-
if (!isSchemaNode(descriptor.value))
|
|
43
|
-
fail(`the entry for ${JSON.stringify(key)} is not a schema node`);
|
|
44
|
-
pin(refs, key, root);
|
|
45
|
-
// The parser also files a node under its path from an ancestor, and compiling that location later corrects it.
|
|
46
|
-
for (const [other, node] of Object.entries(refs)) {
|
|
47
|
-
if (isSchemaNode(node) && other === `${key}${node.evaluationPath}`)
|
|
48
|
-
pin(refs, other, node);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let verified = false;
|
|
52
|
-
// A release that keeps the registry's shape but changes what the pin repairs must also fail closed.
|
|
53
|
-
function selfTest() {
|
|
54
|
-
if (verified)
|
|
55
|
-
return;
|
|
56
|
-
const anonymous = compileSchema({ type: 'object', properties: { name: { type: 'string' }, child: { $ref: '#' } } }, { draft: 'draft-07' });
|
|
57
|
-
const child = anonymous.properties?.child;
|
|
58
|
-
if (child?.$ref !== '')
|
|
59
|
-
fail('"$ref": "#" no longer normalises to the empty key');
|
|
60
|
-
pinRegistry(anonymous);
|
|
61
|
-
anonymous.reduceNode({});
|
|
62
|
-
if (anonymous.validate({ child: 'text' }).valid)
|
|
63
|
-
fail('an anonymous "#" does not resolve to the root');
|
|
64
|
-
if (!anonymous.validate({ child: {} }).valid)
|
|
65
|
-
fail('an anonymous "#" rejects a valid instance');
|
|
66
|
-
const identified = compileSchema({
|
|
67
|
-
$id: 'https://texaryn.invalid/probe',
|
|
68
|
-
type: 'object',
|
|
69
|
-
properties: { x: { type: 'number' }, child: { $ref: '#' } },
|
|
70
|
-
if: { required: ['x'] },
|
|
71
|
-
then: { required: ['y'] },
|
|
72
|
-
}, { draft: 'draft-07' });
|
|
73
|
-
pinRegistry(identified);
|
|
74
|
-
identified.reduceNode({});
|
|
75
|
-
if (identified.validate({ child: { x: 1 } }).valid)
|
|
76
|
-
fail('an identified "#" does not resolve to the root');
|
|
77
|
-
verified = true;
|
|
78
|
-
}
|
|
79
|
-
// Draft 7 only: the 2019-09 and 2020-12 parsers register an entry once and never overwrite it.
|
|
80
|
-
export function fixRootReference(root, dialect) {
|
|
81
|
-
if (dialect !== 'draft-07')
|
|
82
|
-
return;
|
|
83
|
-
selfTest();
|
|
84
|
-
pinRegistry(root);
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=root-reference.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root-reference.js","sourceRoot":"","sources":["../src/root-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAmB,MAAM,qBAAqB,CAAA;AAGlF,MAAM,MAAM,GAAG,4BAA4B,CAAA;AAI3C,SAAS,UAAU,CAAC,IAAgB;IAClC,MAAM,OAAO,GAAI,IAAyC,CAAC,OAAO,CAAA;IAClE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,IAAI,CAAC,oCAAoC,CAAC,CAAA;IAC/F,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAiD,CAAA;IAC5E,IAAI,QAAQ,KAAK,IAAI;QAAE,IAAI,CAAC,6CAA6C,CAAC,CAAA;IAC1E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;QAClG,IAAI,CAAC,sCAAsC,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,IAAgB,CAAA;AACzB,CAAC;AAED,mGAAmG;AACnG,SAAS,OAAO,CAAC,IAAgB;IAC/B,MAAM,EAAE,GAAI,IAA0B,CAAC,GAAG,CAAA;IAC1C,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAC/B,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,IAAI,CAAC,0CAA0C,CAAC,CAAA;IAC5E,OAAO,EAAE,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