@maroonedog/luq 2.2.0 → 2.3.1
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/README.md +47 -602
- package/dist/builder/compile-declarations.d.ts +7 -1
- package/dist/builder/compile-declarations.js +18 -8
- package/dist/builder/compile-declarations.mjs +18 -8
- package/dist/builder/create-builder.js +2 -3
- package/dist/builder/create-builder.mjs +2 -3
- package/dist/builder/create-field-builder.js +13 -1
- package/dist/builder/create-field-builder.mjs +13 -1
- package/dist/builder/declared-calls-store.d.ts +9 -0
- package/dist/builder/declared-calls-store.js +19 -0
- package/dist/builder/declared-calls-store.mjs +15 -0
- package/dist/builder/field-declared-calls.types.d.ts +6 -0
- package/dist/builder/field-declared-calls.types.js +2 -0
- package/dist/builder/field-declared-calls.types.mjs +1 -0
- package/dist/builder/field-entry.types.d.ts +9 -3
- package/dist/builder/field-options.types.d.ts +26 -0
- package/dist/chain/bundle-paths.types.d.ts +9 -12
- package/dist/chain/chain-node-store.d.ts +5 -0
- package/dist/chain/chain-node-store.js +15 -0
- package/dist/chain/chain-node-store.mjs +11 -0
- package/dist/chain/collect-field-rules.d.ts +13 -2
- package/dist/chain/collect-field-rules.js +10 -3
- package/dist/chain/collect-field-rules.mjs +10 -3
- package/dist/chain/create-chain-node.d.ts +10 -0
- package/dist/chain/create-chain-node.js +19 -9
- package/dist/chain/create-chain-node.mjs +19 -9
- package/dist/chain/create-field-slots.js +9 -1
- package/dist/chain/create-field-slots.mjs +9 -1
- package/dist/chain/declaration-recorder.port.d.ts +31 -0
- package/dist/chain/declaration-recorder.port.js +17 -0
- package/dist/chain/declaration-recorder.port.mjs +13 -0
- package/dist/chain/declared-call.types.d.ts +15 -0
- package/dist/chain/declared-call.types.js +2 -0
- package/dist/chain/declared-call.types.mjs +1 -0
- package/dist/chain/index.d.ts +3 -1
- package/dist/chain/slot-type-guard.d.ts +10 -0
- package/dist/chain/slot-type-guard.js +37 -0
- package/dist/chain/slot-type-guard.mjs +34 -0
- package/dist/compile/compile-array-node.js +1 -0
- package/dist/compile/compile-array-node.mjs +1 -0
- package/dist/compile/compile-field.d.ts +1 -0
- package/dist/compile/compile-field.js +8 -6
- package/dist/compile/compile-field.mjs +8 -6
- package/dist/compile/compile-schema.js +4 -0
- package/dist/compile/compile-schema.mjs +4 -0
- package/dist/compile/group-array-fields.d.ts +1 -0
- package/dist/compile/split-rules-by-kind.js +10 -14
- package/dist/compile/split-rules-by-kind.mjs +10 -14
- package/dist/compile/validation-plan.types.d.ts +19 -6
- package/dist/core/type-erasure.d.ts +36 -30
- package/dist/core/type-erasure.js +36 -30
- package/dist/core/type-erasure.mjs +36 -30
- package/dist/json-schema/build-from-schema.js +8 -1
- package/dist/json-schema/build-from-schema.mjs +8 -1
- package/dist/json-schema/create-structural-context.js +3 -0
- package/dist/json-schema/create-structural-context.mjs +3 -0
- package/dist/json-schema/declare-additional-properties.d.ts +7 -7
- package/dist/json-schema/declare-additional-properties.js +7 -7
- package/dist/json-schema/declare-additional-properties.mjs +7 -7
- package/dist/json-schema/declare-object-keywords.js +4 -4
- package/dist/json-schema/declare-object-keywords.mjs +4 -4
- package/dist/json-schema/follow-json-pointer.d.ts +7 -6
- package/dist/json-schema/follow-json-pointer.js +24 -24
- package/dist/json-schema/follow-json-pointer.mjs +24 -24
- package/dist/json-schema/ref-resolution-error.js +3 -3
- package/dist/json-schema/ref-resolution-error.mjs +3 -3
- package/dist/json-schema/schema-registry.js +12 -11
- package/dist/json-schema/schema-registry.mjs +12 -11
- package/dist/json-schema/uri-reference.js +12 -12
- package/dist/json-schema/uri-reference.mjs +12 -12
- package/dist/path/create-value-writer.js +12 -12
- package/dist/path/create-value-writer.mjs +12 -12
- package/dist/path/reserved-segment.d.ts +16 -16
- package/dist/path/reserved-segment.js +17 -21
- package/dist/path/reserved-segment.mjs +17 -21
- package/dist/plugins/index.generated.js +2 -2
- package/dist/plugins/index.generated.mjs +2 -2
- package/dist/plugins/manifest.generated.js +2 -2
- package/dist/plugins/manifest.generated.mjs +2 -2
- package/dist/plugins/object/object.d.ts +6 -0
- package/dist/plugins/object/object.js +9 -11
- package/dist/plugins/object/object.mjs +10 -12
- package/dist/plugins/object-additional-properties/select-additional-keys.d.ts +8 -8
- package/dist/plugins/object-additional-properties/select-additional-keys.js +16 -16
- package/dist/plugins/object-additional-properties/select-additional-keys.mjs +16 -16
- package/dist/plugins/stitch/stitch.d.ts +10 -14
- package/dist/plugins/stitch-with/stitch-with.d.ts +1 -1
- package/dist/plugins/stitch-with/stitch-with.js +22 -24
- package/dist/plugins/stitch-with/stitch-with.mjs +22 -24
- package/dist/plugins/string-min/string-min.js +6 -8
- package/dist/plugins/string-min/string-min.mjs +6 -8
- package/dist/presets/presets.d.ts +10 -11
- package/dist/presets/presets.js +22 -23
- package/dist/presets/presets.mjs +22 -23
- package/dist/runtime/create-field-validator.js +4 -6
- package/dist/runtime/create-field-validator.mjs +4 -6
- package/dist/runtime/create-validator.js +11 -11
- package/dist/runtime/create-validator.mjs +11 -11
- package/dist/runtime/output-writer.js +5 -1
- package/dist/runtime/output-writer.mjs +5 -1
- package/dist/runtime/run-array-node.js +6 -6
- package/dist/runtime/run-array-node.mjs +6 -6
- package/dist/runtime/run-field.js +18 -19
- package/dist/runtime/run-field.mjs +18 -19
- package/dist/standard-schema/assemble-json-schema.d.ts +4 -0
- package/dist/standard-schema/assemble-json-schema.js +95 -0
- package/dist/standard-schema/assemble-json-schema.mjs +92 -0
- package/dist/standard-schema/declaration-recorder.d.ts +6 -0
- package/dist/standard-schema/declaration-recorder.js +30 -0
- package/dist/standard-schema/declaration-recorder.mjs +27 -0
- package/dist/standard-schema/declarations-unavailable-error.d.ts +4 -0
- package/dist/standard-schema/declarations-unavailable-error.js +32 -0
- package/dist/standard-schema/declarations-unavailable-error.mjs +28 -0
- package/dist/standard-schema/emit-field-schema.d.ts +9 -0
- package/dist/standard-schema/emit-field-schema.js +68 -0
- package/dist/standard-schema/emit-field-schema.mjs +65 -0
- package/dist/standard-schema/index.d.ts +5 -0
- package/dist/standard-schema/index.js +9 -1
- package/dist/standard-schema/index.mjs +4 -0
- package/dist/standard-schema/json-schema-target.d.ts +6 -0
- package/dist/standard-schema/json-schema-target.js +44 -0
- package/dist/standard-schema/json-schema-target.mjs +39 -0
- package/dist/standard-schema/plugin-keyword-map.d.ts +3 -0
- package/dist/standard-schema/plugin-keyword-map.js +93 -0
- package/dist/standard-schema/plugin-keyword-map.mjs +90 -0
- package/dist/standard-schema/split-issue-path.d.ts +6 -4
- package/dist/standard-schema/split-issue-path.js +15 -13
- package/dist/standard-schema/split-issue-path.mjs +15 -13
- package/dist/standard-schema/standard-schema.types.d.ts +8 -7
- package/dist/standard-schema/standard-schema.types.js +6 -6
- package/dist/standard-schema/standard-schema.types.mjs +6 -6
- package/dist/standard-schema/to-standard-json-schema.d.ts +19 -0
- package/dist/standard-schema/to-standard-json-schema.js +36 -0
- package/dist/standard-schema/to-standard-json-schema.mjs +33 -0
- package/dist/standard-schema/to-standard-schema.d.ts +16 -15
- package/dist/standard-schema/to-standard-schema.js +15 -22
- package/dist/standard-schema/to-standard-schema.mjs +15 -22
- package/dist/standard-schema/unrepresentable-rule-error.d.ts +15 -0
- package/dist/standard-schema/unrepresentable-rule-error.js +43 -0
- package/dist/standard-schema/unrepresentable-rule-error.mjs +38 -0
- package/dist/types/index.d.ts +12 -12
- package/dist/types/index.js +7 -7
- package/dist/types/index.mjs +7 -7
- package/package.json +1 -1
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSchemaRegistry = createSchemaRegistry;
|
|
4
4
|
// ===========================================================================
|
|
5
|
-
// L8 src/json-schema/schema-registry.ts —
|
|
5
|
+
// L8 src/json-schema/schema-registry.ts — which URI names which schema.
|
|
6
6
|
//
|
|
7
|
-
// Draft-07 §8.2
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// Draft-07 §8.2 gives `$id` two jobs: a URI that names a location re-bases
|
|
8
|
+
// what follows, and the `#name` form gives a **location-independent name**.
|
|
9
|
+
// Both are the same index — this URI is that node — which is this file's whole
|
|
10
|
+
// responsibility. Walking a pointer is about location, and lives elsewhere.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// *
|
|
16
|
-
// *
|
|
17
|
-
//
|
|
12
|
+
// External documents are **only what the caller passed in**; nothing is
|
|
13
|
+
// fetched. Taking a map rather than a loader function is what makes all three
|
|
14
|
+
// of these true at once:
|
|
15
|
+
// * a URI written in a schema can never make this process open a socket,
|
|
16
|
+
// * conversion stays synchronous, so it works under CSP,
|
|
17
|
+
// * everything that could possibly be read is visible in the caller's code.
|
|
18
|
+
// An async loader gives up all three.
|
|
18
19
|
// ===========================================================================
|
|
19
20
|
const draft07_types_1 = require("./draft07.types");
|
|
20
21
|
const types_1 = require("../types");
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// ===========================================================================
|
|
2
|
-
// L8 src/json-schema/schema-registry.ts —
|
|
2
|
+
// L8 src/json-schema/schema-registry.ts — which URI names which schema.
|
|
3
3
|
//
|
|
4
|
-
// Draft-07 §8.2
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Draft-07 §8.2 gives `$id` two jobs: a URI that names a location re-bases
|
|
5
|
+
// what follows, and the `#name` form gives a **location-independent name**.
|
|
6
|
+
// Both are the same index — this URI is that node — which is this file's whole
|
|
7
|
+
// responsibility. Walking a pointer is about location, and lives elsewhere.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// *
|
|
13
|
-
// *
|
|
14
|
-
//
|
|
9
|
+
// External documents are **only what the caller passed in**; nothing is
|
|
10
|
+
// fetched. Taking a map rather than a loader function is what makes all three
|
|
11
|
+
// of these true at once:
|
|
12
|
+
// * a URI written in a schema can never make this process open a socket,
|
|
13
|
+
// * conversion stays synchronous, so it works under CSP,
|
|
14
|
+
// * everything that could possibly be read is visible in the caller's code.
|
|
15
|
+
// An async loader gives up all three.
|
|
15
16
|
// ===========================================================================
|
|
16
17
|
import { isDraft07Schema, isSchemaObject } from "./draft07.types.mjs";
|
|
17
18
|
import { isArray, isPlainObject } from "../types/index.mjs";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ===========================================================================
|
|
3
|
-
// L8 src/json-schema/uri-reference.ts —
|
|
3
|
+
// L8 src/json-schema/uri-reference.ts — the URI arithmetic of `$id`/`$ref`.
|
|
4
4
|
//
|
|
5
|
-
// Draft-07 §8.2
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// Draft-07 §8.2 makes `$id` establish a base URI that `$ref` resolves
|
|
6
|
+
// against. A `$ref` is therefore a **URI reference** and not a pointer within
|
|
7
|
+
// a document: the same string points somewhere else depending on which `$id`
|
|
8
|
+
// it was written under.
|
|
8
9
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// eval
|
|
10
|
+
// Resolution is delegated to the WHATWG URL. Rewriting RFC 3986 §5.3 by hand
|
|
11
|
+
// goes wrong on percent-encoding, dot segments and scheme-relative
|
|
12
|
+
// (`//host/x`) every time — and URL is a standard global in both browsers and
|
|
13
|
+
// Node, needing neither eval nor new Function.
|
|
13
14
|
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// このプロセスがソケットを開くことは無い。
|
|
15
|
+
// **Nothing here touches the network.** This is string arithmetic; how a
|
|
16
|
+
// resolved URI is actually obtained is the caller's responsibility. A URI
|
|
17
|
+
// written in a schema never causes this process to open a socket.
|
|
18
18
|
// ===========================================================================
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.splitUri = splitUri;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// ===========================================================================
|
|
2
|
-
// L8 src/json-schema/uri-reference.ts —
|
|
2
|
+
// L8 src/json-schema/uri-reference.ts — the URI arithmetic of `$id`/`$ref`.
|
|
3
3
|
//
|
|
4
|
-
// Draft-07 §8.2
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// Draft-07 §8.2 makes `$id` establish a base URI that `$ref` resolves
|
|
5
|
+
// against. A `$ref` is therefore a **URI reference** and not a pointer within
|
|
6
|
+
// a document: the same string points somewhere else depending on which `$id`
|
|
7
|
+
// it was written under.
|
|
7
8
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// eval
|
|
9
|
+
// Resolution is delegated to the WHATWG URL. Rewriting RFC 3986 §5.3 by hand
|
|
10
|
+
// goes wrong on percent-encoding, dot segments and scheme-relative
|
|
11
|
+
// (`//host/x`) every time — and URL is a standard global in both browsers and
|
|
12
|
+
// Node, needing neither eval nor new Function.
|
|
12
13
|
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// このプロセスがソケットを開くことは無い。
|
|
14
|
+
// **Nothing here touches the network.** This is string arithmetic; how a
|
|
15
|
+
// resolved URI is actually obtained is the caller's responsibility. A URI
|
|
16
|
+
// written in a schema never causes this process to open a socket.
|
|
17
17
|
// ===========================================================================
|
|
18
18
|
export function splitUri(uri) {
|
|
19
19
|
const hash = uri.indexOf("#");
|
|
@@ -36,19 +36,19 @@ function writeInto(container, keys, depth, value) {
|
|
|
36
36
|
* numeric key here is a Record key.
|
|
37
37
|
*/
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Places a key as an own property. **Never with the assignment operator.**
|
|
40
40
|
*
|
|
41
|
-
* `copy[key] = value`
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* `copy[key] = value` on "__proto__" invokes the accessor on
|
|
42
|
+
* Object.prototype: instead of creating an own property it swaps the
|
|
43
|
+
* prototype. defineProperty ignores accessors and defines the own property, so
|
|
44
|
+
* a property actually named "__proto__" can be held safely.
|
|
45
45
|
*
|
|
46
|
-
* "constructor"
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* "constructor" and "prototype" are data properties, so assignment would only
|
|
47
|
+
* make own properties of them — but branching per key is how the branch gets
|
|
48
|
+
* written wrong, so everything goes through this one path.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* This is what makes writing safe, and therefore what makes refusing these
|
|
51
|
+
* names in the path grammar unnecessary. See reserved-segment.ts.
|
|
52
52
|
*/
|
|
53
53
|
function putOwnProperty(target, key, value) {
|
|
54
54
|
Object.defineProperty(target, key, {
|
|
@@ -72,8 +72,8 @@ function copyWith(container, key, value) {
|
|
|
72
72
|
copy[index] = value;
|
|
73
73
|
return copy;
|
|
74
74
|
}
|
|
75
|
-
//
|
|
76
|
-
//
|
|
75
|
+
// Spread copies own enumerable properties with CreateDataProperty, so no
|
|
76
|
+
// setter runs here. Only assignment is dangerous.
|
|
77
77
|
const copy = { ...container };
|
|
78
78
|
putOwnProperty(copy, key, value);
|
|
79
79
|
return copy;
|
|
@@ -33,19 +33,19 @@ function writeInto(container, keys, depth, value) {
|
|
|
33
33
|
* numeric key here is a Record key.
|
|
34
34
|
*/
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Places a key as an own property. **Never with the assignment operator.**
|
|
37
37
|
*
|
|
38
|
-
* `copy[key] = value`
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* `copy[key] = value` on "__proto__" invokes the accessor on
|
|
39
|
+
* Object.prototype: instead of creating an own property it swaps the
|
|
40
|
+
* prototype. defineProperty ignores accessors and defines the own property, so
|
|
41
|
+
* a property actually named "__proto__" can be held safely.
|
|
42
42
|
*
|
|
43
|
-
* "constructor"
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* "constructor" and "prototype" are data properties, so assignment would only
|
|
44
|
+
* make own properties of them — but branching per key is how the branch gets
|
|
45
|
+
* written wrong, so everything goes through this one path.
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* This is what makes writing safe, and therefore what makes refusing these
|
|
48
|
+
* names in the path grammar unnecessary. See reserved-segment.ts.
|
|
49
49
|
*/
|
|
50
50
|
function putOwnProperty(target, key, value) {
|
|
51
51
|
Object.defineProperty(target, key, {
|
|
@@ -69,8 +69,8 @@ function copyWith(container, key, value) {
|
|
|
69
69
|
copy[index] = value;
|
|
70
70
|
return copy;
|
|
71
71
|
}
|
|
72
|
-
//
|
|
73
|
-
//
|
|
72
|
+
// Spread copies own enumerable properties with CreateDataProperty, so no
|
|
73
|
+
// setter runs here. Only assignment is dangerous.
|
|
74
74
|
const copy = { ...container };
|
|
75
75
|
putOwnProperty(copy, key, value);
|
|
76
76
|
return copy;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `Object.prototype
|
|
2
|
+
* Keys that share a name with something on `Object.prototype`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* **This is no longer a deny list.** Refusing these in a declared path was
|
|
5
|
+
* over-broad: only writing is dangerous, and of the three only "__proto__"
|
|
6
|
+
* really is.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* reading own properties only, checked with hasOwnProperty.call, so the
|
|
9
|
+
* prototype chain is never walked to begin with
|
|
10
|
+
* writing `target[key] = value` on "__proto__" invokes the ACCESSOR on
|
|
11
|
+
* Object.prototype: it creates no own property and swaps the
|
|
12
|
+
* prototype instead. "constructor" and "prototype" are data
|
|
13
|
+
* properties, so assigning them only makes an own property and
|
|
14
|
+
* pollutes nothing
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `{ "properties": { "__proto__": ... } }`
|
|
18
|
-
* ようになった (JSON-Schema-Test-Suite の properties.json が要求している)。
|
|
16
|
+
* Writing through defineProperty instead of assignment closes that route.
|
|
17
|
+
* Refusing by name became unnecessary, which is what allows a schema like
|
|
18
|
+
* `{ "properties": { "__proto__": ... } }` to be validated at all.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* The list stays. Tests use it to name the keys they check Object.prototype
|
|
21
|
+
* against.
|
|
22
22
|
*/
|
|
23
23
|
export declare const RESERVED_SEGMENTS: readonly string[];
|
|
24
24
|
/** Thrown at BUILD time for every malformed or unsafe path. A declared rule
|
|
@@ -14,26 +14,26 @@ exports.PathSyntaxError = exports.RESERVED_SEGMENTS = void 0;
|
|
|
14
14
|
exports.isReservedSegment = isReservedSegment;
|
|
15
15
|
exports.assertDeclarableKey = assertDeclarableKey;
|
|
16
16
|
/**
|
|
17
|
-
* `Object.prototype
|
|
17
|
+
* Keys that share a name with something on `Object.prototype`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* **This is no longer a deny list.** Refusing these in a declared path was
|
|
20
|
+
* over-broad: only writing is dangerous, and of the three only "__proto__"
|
|
21
|
+
* really is.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* reading own properties only, checked with hasOwnProperty.call, so the
|
|
24
|
+
* prototype chain is never walked to begin with
|
|
25
|
+
* writing `target[key] = value` on "__proto__" invokes the ACCESSOR on
|
|
26
|
+
* Object.prototype: it creates no own property and swaps the
|
|
27
|
+
* prototype instead. "constructor" and "prototype" are data
|
|
28
|
+
* properties, so assigning them only makes an own property and
|
|
29
|
+
* pollutes nothing
|
|
29
30
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `{ "properties": { "__proto__": ... } }`
|
|
33
|
-
* ようになった (JSON-Schema-Test-Suite の properties.json が要求している)。
|
|
31
|
+
* Writing through defineProperty instead of assignment closes that route.
|
|
32
|
+
* Refusing by name became unnecessary, which is what allows a schema like
|
|
33
|
+
* `{ "properties": { "__proto__": ... } }` to be validated at all.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* The list stays. Tests use it to name the keys they check Object.prototype
|
|
36
|
+
* against.
|
|
37
37
|
*/
|
|
38
38
|
exports.RESERVED_SEGMENTS = Object.freeze([
|
|
39
39
|
"__proto__",
|
|
@@ -80,9 +80,5 @@ function assertDeclarableKey(key, source) {
|
|
|
80
80
|
throw new PathSyntaxError(source, `the key ${JSON.stringify(key)} contains a bracket; "[*]" is the only ` +
|
|
81
81
|
"bracket form and it must trail a key");
|
|
82
82
|
}
|
|
83
|
-
//
|
|
84
|
-
// コメントに書いてある。要約すると、危険なのは書き込みだけで、その書き込みは
|
|
85
|
-
// create-value-writer.ts が defineProperty に移したので安全になった。
|
|
86
|
-
// 名前で拒否する必要が無くなり、JSON Schema が "__proto__" というキーを
|
|
87
|
-
// 持つオブジェクトを検証できるようになった。
|
|
83
|
+
// Reserved segments are deliberately NOT refused here. See RESERVED_SEGMENTS.
|
|
88
84
|
}
|
|
@@ -9,26 +9,26 @@
|
|
|
9
9
|
// dependent for no gain.
|
|
10
10
|
// ===========================================================================
|
|
11
11
|
/**
|
|
12
|
-
* `Object.prototype
|
|
12
|
+
* Keys that share a name with something on `Object.prototype`.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* **This is no longer a deny list.** Refusing these in a declared path was
|
|
15
|
+
* over-broad: only writing is dangerous, and of the three only "__proto__"
|
|
16
|
+
* really is.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* reading own properties only, checked with hasOwnProperty.call, so the
|
|
19
|
+
* prototype chain is never walked to begin with
|
|
20
|
+
* writing `target[key] = value` on "__proto__" invokes the ACCESSOR on
|
|
21
|
+
* Object.prototype: it creates no own property and swaps the
|
|
22
|
+
* prototype instead. "constructor" and "prototype" are data
|
|
23
|
+
* properties, so assigning them only makes an own property and
|
|
24
|
+
* pollutes nothing
|
|
24
25
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* `{ "properties": { "__proto__": ... } }`
|
|
28
|
-
* ようになった (JSON-Schema-Test-Suite の properties.json が要求している)。
|
|
26
|
+
* Writing through defineProperty instead of assignment closes that route.
|
|
27
|
+
* Refusing by name became unnecessary, which is what allows a schema like
|
|
28
|
+
* `{ "properties": { "__proto__": ... } }` to be validated at all.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* The list stays. Tests use it to name the keys they check Object.prototype
|
|
31
|
+
* against.
|
|
32
32
|
*/
|
|
33
33
|
export const RESERVED_SEGMENTS = Object.freeze([
|
|
34
34
|
"__proto__",
|
|
@@ -74,9 +74,5 @@ export function assertDeclarableKey(key, source) {
|
|
|
74
74
|
throw new PathSyntaxError(source, `the key ${JSON.stringify(key)} contains a bracket; "[*]" is the only ` +
|
|
75
75
|
"bracket form and it must trail a key");
|
|
76
76
|
}
|
|
77
|
-
//
|
|
78
|
-
// コメントに書いてある。要約すると、危険なのは書き込みだけで、その書き込みは
|
|
79
|
-
// create-value-writer.ts が defineProperty に移したので安全になった。
|
|
80
|
-
// 名前で拒否する必要が無くなり、JSON Schema が "__proto__" というキーを
|
|
81
|
-
// 持つオブジェクトを検証できるようになった。
|
|
77
|
+
// Reserved segments are deliberately NOT refused here. See RESERVED_SEGMENTS.
|
|
82
78
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// GENERATED FILE -
|
|
3
|
-
//
|
|
2
|
+
// GENERATED FILE - do not edit by hand.
|
|
3
|
+
// Generated by scripts/catalog/build-plugin-catalog.ts out of the plugin directory structure.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.stringDatetimePlugin = exports.stringDatePlugin = exports.stringContentMediaTypePlugin = exports.stringContentEncodingPlugin = exports.stringBase64Plugin = exports.stringAlphanumericPlugin = exports.stitchWithPlugin = exports.stitchPlugin = exports.skipPlugin = exports.requiredIfPlugin = exports.requiredPlugin = exports.readOnlyPlugin = exports.orFailPlugin = exports.optionalIfPlugin = exports.optionalPlugin = exports.oneOfPlugin = exports.objectRecursivelyPlugin = exports.objectPropertyNamesPlugin = exports.objectPatternPropertiesPlugin = exports.objectMinPropertiesPlugin = exports.objectMaxPropertiesPlugin = exports.objectDependentSchemasPlugin = exports.objectDependentRequiredPlugin = exports.objectAdditionalPropertiesSchemaPlugin = exports.objectAdditionalPropertiesPlugin = exports.objectPlugin = exports.numberRangePlugin = exports.numberPositivePlugin = exports.numberNegativePlugin = exports.numberMultipleOfPlugin = exports.numberMinPlugin = exports.numberMaxPlugin = exports.numberIntegerPlugin = exports.numberFinitePlugin = exports.nullablePlugin = exports.literalPlugin = exports.jsonSchemaFullFeaturePlugin = exports.jsonSchemaPlugin = exports.fromContextPlugin = exports.customPlugin = exports.conditionalSchemaPlugin = exports.compareFieldPlugin = exports.booleanTruthyPlugin = exports.booleanFalsyPlugin = exports.arrayUniquePlugin = exports.arrayMinLengthPlugin = exports.arrayMaxLengthPlugin = exports.arrayIncludesPlugin = exports.arrayEachPlugin = exports.arrayContainsPlugin = void 0;
|
|
6
6
|
exports.writeOnlyPlugin = exports.validateIfPlugin = exports.uuidPlugin = exports.unionGuardPlugin = exports.tupleBuilderPlugin = exports.transformPlugin = exports.stringUrlPlugin = exports.stringUriTemplatePlugin = exports.stringUriReferencePlugin = exports.stringTimePlugin = exports.stringStartsWithPlugin = exports.stringRelativeJsonPointerPlugin = exports.stringRegexPlugin = exports.stringPatternPlugin = exports.stringMinPlugin = exports.stringMaxPlugin = exports.stringJsonPointerPlugin = exports.stringIriReferencePlugin = exports.stringIriPlugin = exports.stringIpv6Plugin = exports.stringIpv4Plugin = exports.stringIdnHostnamePlugin = exports.stringIdnEmailPlugin = exports.stringHostnamePlugin = exports.stringExactLengthPlugin = exports.stringEndsWithPlugin = exports.stringEmailPlugin = exports.stringDurationPlugin = void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// GENERATED FILE -
|
|
2
|
-
//
|
|
1
|
+
// GENERATED FILE - do not edit by hand.
|
|
2
|
+
// Generated by scripts/catalog/build-plugin-catalog.ts out of the plugin directory structure.
|
|
3
3
|
export { arrayContainsPlugin } from "./array-contains/index.mjs";
|
|
4
4
|
export { arrayEachPlugin } from "./array-each/index.mjs";
|
|
5
5
|
export { arrayIncludesPlugin } from "./array-includes/index.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// GENERATED FILE -
|
|
3
|
-
//
|
|
2
|
+
// GENERATED FILE - do not edit by hand.
|
|
3
|
+
// Generated by scripts/catalog/build-plugin-catalog.ts out of the plugin directory structure.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.PLUGIN_MANIFEST = void 0;
|
|
6
6
|
exports.PLUGIN_MANIFEST = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// GENERATED FILE -
|
|
2
|
-
//
|
|
1
|
+
// GENERATED FILE - do not edit by hand.
|
|
2
|
+
// Generated by scripts/catalog/build-plugin-catalog.ts out of the plugin directory structure.
|
|
3
3
|
export const PLUGIN_MANIFEST = [
|
|
4
4
|
{ directoryName: "array-contains", subpathName: "arrayContains", tier: "isolated", entryFile: "src/plugins/array-contains/index.ts", exportedSymbols: ["arrayContainsPlugin"] },
|
|
5
5
|
{ directoryName: "array-each", subpathName: "arrayEach", tier: "isolated", entryFile: "src/plugins/array-each/index.ts", exportedSymbols: ["arrayEachPlugin"] },
|
|
@@ -2,6 +2,12 @@ import type { Unchanged } from "../../plugin-kit/marker.types";
|
|
|
2
2
|
export interface ObjectTypeContext {
|
|
3
3
|
readonly actual: string;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Entering `b.object` already checks this, under the code
|
|
7
|
+
* `objectType`. Drop the `.use(objectPlugin)` and the `.object()` call: the
|
|
8
|
+
* field goes on rejecting arrays, `null` and primitives, and only the issue's
|
|
9
|
+
* code and message change.
|
|
10
|
+
*/
|
|
5
11
|
export declare const objectPlugin: import("../../plugin-kit/plugin-definition").PluginDefinition<"object", "object", readonly ["object"], {
|
|
6
12
|
args: readonly [];
|
|
7
13
|
out: Unchanged;
|
|
@@ -4,14 +4,12 @@ exports.objectPlugin = void 0;
|
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const create_rule_1 = require("../../plugin-kit/create-rule");
|
|
6
6
|
const plugin_definition_1 = require("../../plugin-kit/plugin-definition");
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return typeof value;
|
|
14
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Entering `b.object` already checks this, under the code
|
|
9
|
+
* `objectType`. Drop the `.use(objectPlugin)` and the `.object()` call: the
|
|
10
|
+
* field goes on rejecting arrays, `null` and primitives, and only the issue's
|
|
11
|
+
* code and message change.
|
|
12
|
+
*/
|
|
15
13
|
exports.objectPlugin = (0, plugin_definition_1.definePlugin)()({
|
|
16
14
|
name: "object",
|
|
17
15
|
method: "object",
|
|
@@ -20,9 +18,9 @@ exports.objectPlugin = (0, plugin_definition_1.definePlugin)()({
|
|
|
20
18
|
code: ctx.code,
|
|
21
19
|
messageFactory: ctx.messageFactory,
|
|
22
20
|
severity: ctx.severity,
|
|
23
|
-
run: (
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
run: () => types_1.PASS,
|
|
22
|
+
// Unreachable while run() never fails, and kept so the shape of the rule
|
|
23
|
+
// stays a rule rather than becoming a special case for the engine.
|
|
26
24
|
describe: (detail) => `Value must be an object, but got ${String(detail.actual)}`,
|
|
27
25
|
buildMessageContext: (detail) => ({ actual: String(detail.actual) }),
|
|
28
26
|
}),
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { PASS
|
|
1
|
+
import { PASS } from "../../types/index.mjs";
|
|
2
2
|
import { check } from "../../plugin-kit/create-rule.mjs";
|
|
3
3
|
import { definePlugin } from "../../plugin-kit/plugin-definition.mjs";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return typeof value;
|
|
11
|
-
}
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Entering `b.object` already checks this, under the code
|
|
6
|
+
* `objectType`. Drop the `.use(objectPlugin)` and the `.object()` call: the
|
|
7
|
+
* field goes on rejecting arrays, `null` and primitives, and only the issue's
|
|
8
|
+
* code and message change.
|
|
9
|
+
*/
|
|
12
10
|
export const objectPlugin = /*#__PURE__*/ definePlugin()({
|
|
13
11
|
name: "object",
|
|
14
12
|
method: "object",
|
|
@@ -17,9 +15,9 @@ export const objectPlugin = /*#__PURE__*/ definePlugin()({
|
|
|
17
15
|
code: ctx.code,
|
|
18
16
|
messageFactory: ctx.messageFactory,
|
|
19
17
|
severity: ctx.severity,
|
|
20
|
-
run: (
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
run: () => PASS,
|
|
19
|
+
// Unreachable while run() never fails, and kept so the shape of the rule
|
|
20
|
+
// stays a rule rather than becoming a special case for the engine.
|
|
23
21
|
describe: (detail) => `Value must be an object, but got ${String(detail.actual)}`,
|
|
24
22
|
buildMessageContext: (detail) => ({ actual: String(detail.actual) }),
|
|
25
23
|
}),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Patterns are compiled once, at build time, matching the design where
|
|
3
|
+
* validation only runs what was already assembled. Compiling per key would
|
|
4
|
+
* cost O(keys × patterns) compilations on every call.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A broken pattern is ignored rather than fatal. Draft-07 asks for ECMA-262
|
|
7
|
+
* regular expressions and real documents arrive with dialect differences;
|
|
8
|
+
* having that one pattern match nothing beats refusing the whole build.
|
|
9
9
|
*/
|
|
10
10
|
export declare function compilePatterns(patterns: readonly string[] | undefined): readonly RegExp[];
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Returns the keys matched by neither a declared name nor any pattern,
|
|
13
|
+
* preserving the input's enumeration order so issue output stays stable.
|
|
14
14
|
*/
|
|
15
15
|
export declare function selectAdditionalKeys(value: Readonly<Record<string, unknown>>, known: ReadonlySet<string>, patterns: readonly RegExp[]): readonly string[];
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
// ===========================================================================
|
|
3
3
|
// L7 src/plugins/object-additional-properties/select-additional-keys.ts
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Which keys count as "additional". Used by both the boolean form and the
|
|
6
|
+
// schema form.
|
|
6
7
|
//
|
|
7
|
-
// Draft-07 §6.5.4
|
|
8
|
-
// patternProperties
|
|
9
|
-
// `{"patternProperties":{"^v":{}},"additionalProperties":false}`
|
|
10
|
-
// {"vroom":2}
|
|
11
|
-
// "patternProperties are not additional properties" がそれを突く)。
|
|
8
|
+
// Draft-07 §6.5.4 defines them as the keys matched by neither `properties`
|
|
9
|
+
// nor `patternProperties`. Miss the patterns and
|
|
10
|
+
// `{"patternProperties":{"^v":{}},"additionalProperties":false}` wrongly
|
|
11
|
+
// rejects {"vroom":2}.
|
|
12
12
|
// ===========================================================================
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.compilePatterns = compilePatterns;
|
|
15
15
|
exports.selectAdditionalKeys = selectAdditionalKeys;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Patterns are compiled once, at build time, matching the design where
|
|
18
|
+
* validation only runs what was already assembled. Compiling per key would
|
|
19
|
+
* cost O(keys × patterns) compilations on every call.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* A broken pattern is ignored rather than fatal. Draft-07 asks for ECMA-262
|
|
22
|
+
* regular expressions and real documents arrive with dialect differences;
|
|
23
|
+
* having that one pattern match nothing beats refusing the whole build.
|
|
24
24
|
*/
|
|
25
25
|
function compilePatterns(patterns) {
|
|
26
26
|
if (patterns === undefined || patterns.length === 0)
|
|
@@ -32,19 +32,19 @@ function compilePatterns(patterns) {
|
|
|
32
32
|
}
|
|
33
33
|
catch {
|
|
34
34
|
try {
|
|
35
|
-
// "u"
|
|
35
|
+
// Some real patterns fail only under "u". Try again without it.
|
|
36
36
|
compiled.push(new RegExp(pattern));
|
|
37
37
|
}
|
|
38
38
|
catch {
|
|
39
|
-
//
|
|
39
|
+
// Failing both ways, treat this pattern as matching nothing.
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return Object.freeze(compiled);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Returns the keys matched by neither a declared name nor any pattern,
|
|
47
|
+
* preserving the input's enumeration order so issue output stays stable.
|
|
48
48
|
*/
|
|
49
49
|
function selectAdditionalKeys(value, known, patterns) {
|
|
50
50
|
return Object.keys(value).filter((key) => !known.has(key) && !patterns.some((pattern) => pattern.test(key)));
|