@sinclair/typebox 0.32.0-dev-11 → 0.32.0-dev-12
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/build/import/compiler/compiler.mjs +3 -3
- package/build/import/errors/errors.mjs +3 -3
- package/build/import/index.d.mts +3 -3
- package/build/import/index.mjs +2 -2
- package/build/import/type/composite/composite.d.mts +2 -2
- package/build/import/type/composite/composite.mjs +2 -2
- package/build/import/type/extends/extends-mapped-result.d.mts +13 -0
- package/build/import/type/extends/extends-mapped-result.mjs +14 -0
- package/build/import/type/extends/extends-mapped.d.mts +17 -0
- package/build/import/type/extends/extends-mapped.mjs +21 -0
- package/build/import/type/extends/extends.d.mts +8 -2
- package/build/import/type/extends/extends.mjs +7 -3
- package/build/import/type/extends/index.d.mts +2 -0
- package/build/import/type/extends/index.mjs +2 -0
- package/build/import/type/guard/type.d.mts +5 -1
- package/build/import/type/guard/type.mjs +18 -2
- package/build/import/type/indexed/index.d.mts +2 -1
- package/build/import/type/indexed/index.mjs +2 -1
- package/build/import/type/indexed/indexed-mapped.d.mts +16 -0
- package/build/import/type/indexed/indexed-mapped.mjs +18 -0
- package/build/import/type/indexed/{indexed-key.d.mts → indexed-property-keys.d.mts} +3 -3
- package/build/import/type/indexed/{indexed-key.mjs → indexed-property-keys.mjs} +2 -2
- package/build/import/type/indexed/indexed-type.d.mts +2 -2
- package/build/import/type/indexed/indexed-type.mjs +1 -1
- package/build/import/type/indexed/indexed.d.mts +7 -4
- package/build/import/type/indexed/indexed.mjs +7 -6
- package/build/import/type/keyof/index.d.mts +1 -2
- package/build/import/type/keyof/index.mjs +1 -2
- package/build/import/type/keyof/{keyof-string.d.mts → keyof-property-keys.d.mts} +4 -4
- package/build/import/type/keyof/{keyof-string.mjs → keyof-property-keys.mjs} +4 -4
- package/build/import/type/keyof/keyof.d.mts +12 -4
- package/build/import/type/keyof/keyof.mjs +14 -3
- package/build/import/type/mapped/mapped.d.mts +41 -15
- package/build/import/type/mapped/mapped.mjs +75 -11
- package/build/import/type/omit/omit.d.mts +2 -2
- package/build/import/type/omit/omit.mjs +2 -2
- package/build/import/type/pick/pick.d.mts +2 -2
- package/build/import/type/pick/pick.mjs +2 -2
- package/build/import/type/record/record.mjs +3 -3
- package/build/import/type/type/json.d.mts +13 -6
- package/build/import/type/type/json.mjs +6 -2
- package/build/import/value/check/check.mjs +3 -3
- package/build/import/value/clean/clean.mjs +2 -2
- package/build/import/value/transform/decode.mjs +5 -5
- package/build/import/value/transform/encode.mjs +5 -5
- package/build/require/compiler/compiler.js +2 -2
- package/build/require/errors/errors.js +2 -2
- package/build/require/index.d.ts +3 -3
- package/build/require/index.js +7 -7
- package/build/require/type/composite/composite.d.ts +2 -2
- package/build/require/type/composite/composite.js +1 -1
- package/build/require/type/extends/extends-mapped-result.d.ts +13 -0
- package/build/require/type/extends/extends-mapped-result.js +18 -0
- package/build/require/type/extends/extends-mapped.d.ts +17 -0
- package/build/require/type/extends/extends-mapped.js +25 -0
- package/build/require/type/extends/extends.d.ts +8 -2
- package/build/require/type/extends/extends.js +8 -5
- package/build/require/type/extends/index.d.ts +2 -0
- package/build/require/type/extends/index.js +2 -0
- package/build/require/type/guard/type.d.ts +5 -1
- package/build/require/type/guard/type.js +53 -34
- package/build/require/type/indexed/index.d.ts +2 -1
- package/build/require/type/indexed/index.js +2 -1
- package/build/require/type/indexed/indexed-mapped.d.ts +16 -0
- package/build/require/type/indexed/indexed-mapped.js +22 -0
- package/build/require/type/indexed/{indexed-key.d.ts → indexed-property-keys.d.ts} +3 -3
- package/build/require/type/indexed/{indexed-key.js → indexed-property-keys.js} +4 -4
- package/build/require/type/indexed/indexed-type.d.ts +2 -2
- package/build/require/type/indexed/indexed-type.js +3 -3
- package/build/require/type/indexed/indexed.d.ts +7 -4
- package/build/require/type/indexed/indexed.js +7 -6
- package/build/require/type/keyof/index.d.ts +1 -2
- package/build/require/type/keyof/index.js +1 -2
- package/build/require/type/keyof/{keyof-string.d.ts → keyof-property-keys.d.ts} +4 -4
- package/build/require/type/keyof/{keyof-string.js → keyof-property-keys.js} +7 -7
- package/build/require/type/keyof/keyof.d.ts +12 -4
- package/build/require/type/keyof/keyof.js +14 -3
- package/build/require/type/mapped/mapped.d.ts +41 -15
- package/build/require/type/mapped/mapped.js +80 -12
- package/build/require/type/omit/omit.d.ts +2 -2
- package/build/require/type/omit/omit.js +1 -1
- package/build/require/type/pick/pick.d.ts +2 -2
- package/build/require/type/pick/pick.js +1 -1
- package/build/require/type/record/record.js +2 -2
- package/build/require/type/type/json.d.ts +13 -6
- package/build/require/type/type/json.js +54 -50
- package/build/require/value/check/check.js +2 -2
- package/build/require/value/clean/clean.js +15 -15
- package/build/require/value/transform/decode.js +3 -3
- package/build/require/value/transform/encode.js +3 -3
- package/package.json +1 -1
- package/build/import/type/keyof/keyof-type.d.mts +0 -11
- package/build/import/type/keyof/keyof-type.mjs +0 -15
- package/build/require/type/keyof/keyof-type.d.ts +0 -11
- package/build/require/type/keyof/keyof-type.js +0 -19
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
|
-
import type { Evaluate } from '../helpers/index';
|
|
3
|
-
import
|
|
4
|
-
import { type TObject, type TProperties } from '../object/index';
|
|
5
|
-
import { IndexedKeyResolve } from '../indexed/indexed-key';
|
|
2
|
+
import type { Ensure, Evaluate } from '../helpers/index';
|
|
3
|
+
import { IndexedPropertyKeys } from '../indexed/index';
|
|
6
4
|
import { Kind } from '../symbols/index';
|
|
5
|
+
import { type TArray } from '../array/index';
|
|
6
|
+
import { type TAsyncIterator } from '../async-iterator/index';
|
|
7
|
+
import { type TConstructor } from '../constructor/index';
|
|
8
|
+
import { type TFunction } from '../function/index';
|
|
9
|
+
import { type TIntersect } from '../intersect/index';
|
|
10
|
+
import { type TIterator } from '../iterator/index';
|
|
11
|
+
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
12
|
+
import { type TNever } from '../never/index';
|
|
13
|
+
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
14
|
+
import { type TOptional } from '../optional/index';
|
|
15
|
+
import { type TPromise } from '../promise/index';
|
|
16
|
+
import { type TReadonly } from '../readonly/index';
|
|
17
|
+
import { type TUnion } from '../union/index';
|
|
7
18
|
export interface TMappedKey<T extends PropertyKey[] = PropertyKey[]> extends TSchema {
|
|
8
19
|
[Kind]: 'MappedKey';
|
|
9
20
|
static: T[number];
|
|
10
|
-
|
|
21
|
+
keys: T;
|
|
11
22
|
}
|
|
23
|
+
export declare function MappedKey<T extends PropertyKey[]>(T: [...T]): TMappedKey<T>;
|
|
12
24
|
export type MappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
type FromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromMappedPropertyKey<K, P[K]> : TNever);
|
|
26
|
+
declare function FromMappedResult<K extends PropertyKey, P extends TProperties>(K: K, P: P): FromMappedResult<K, P>;
|
|
27
|
+
type FromMappedKey<K extends PropertyKey, _ extends PropertyKey[]> = (K extends TLiteralValue ? TLiteral<K> : TLiteral<'never'>);
|
|
28
|
+
declare function FromMappedKey<K extends PropertyKey, P extends PropertyKey[]>(K: K, _: [...P]): TLiteral<TLiteralValue>;
|
|
29
|
+
type FromRest<K extends PropertyKey, T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromMappedPropertyKey<K, L>, ...FromRest<K, R>] : [];
|
|
30
|
+
declare function FromRest<K extends PropertyKey, T extends TSchema[]>(K: K, T: [...T]): FromRest<K, T>;
|
|
31
|
+
type FromProperties<K extends PropertyKey, T extends TProperties, R extends TProperties = Evaluate<{
|
|
32
|
+
[K2 in keyof T]: FromMappedPropertyKey<K, T[K2]>;
|
|
33
|
+
}>> = R;
|
|
34
|
+
declare function FromProperties<K extends PropertyKey, T extends TProperties>(K: K, T: T): FromProperties<K, T>;
|
|
35
|
+
export type FromMappedPropertyKey<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromMappedPropertyKey<K, S>> : T extends TOptional<infer S> ? TOptional<FromMappedPropertyKey<K, S>> : T extends TMappedResult<infer P> ? FromMappedResult<K, P> : T extends TMappedKey<infer S> ? FromMappedKey<K, S> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<FromRest<K, S>, FromMappedPropertyKey<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<FromRest<K, S>, FromMappedPropertyKey<K, R>> : T extends TAsyncIterator<infer S> ? TAsyncIterator<FromMappedPropertyKey<K, S>> : T extends TIterator<infer S> ? TIterator<FromMappedPropertyKey<K, S>> : T extends TIntersect<infer S> ? TIntersect<FromRest<K, S>> : T extends TUnion<infer S> ? TUnion<FromRest<K, S>> : T extends TObject<infer S> ? TObject<FromProperties<K, S>> : T extends TArray<infer S> ? TArray<FromMappedPropertyKey<K, S>> : T extends TPromise<infer S> ? TPromise<FromMappedPropertyKey<K, S>> : T);
|
|
36
|
+
export declare function FromMappedPropertyKey<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromMappedPropertyKey<K, T>;
|
|
37
|
+
export type FromMappedPropertyKeys<K extends PropertyKey[], T extends TSchema> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
|
|
38
|
+
[_ in L]: FromMappedPropertyKey<L, T>;
|
|
39
|
+
} & FromMappedPropertyKeys<R, T> : {});
|
|
40
|
+
export declare function FromMappedPropertyKeys<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T): FromMappedPropertyKeys<K, T>;
|
|
41
|
+
export interface TMappedResult<T extends TProperties = TProperties> extends TSchema {
|
|
19
42
|
[Kind]: 'MappedResult';
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
properties: T;
|
|
44
|
+
static: unknown;
|
|
22
45
|
}
|
|
23
|
-
export declare function
|
|
24
|
-
export
|
|
46
|
+
export declare function MappedResult<T extends TProperties>(properties: T): TMappedResult<T>;
|
|
47
|
+
export type TMapped<K extends PropertyKey[], F extends MappedFunction<K>, R extends TProperties = Evaluate<FromMappedPropertyKeys<K, ReturnType<F>>>> = Ensure<TObject<R>>;
|
|
48
|
+
export declare function Mapped<K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>, F extends MappedFunction<I> = MappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;
|
|
49
|
+
export declare function Mapped<K extends PropertyKey[], F extends MappedFunction<K> = MappedFunction<K>, R extends TMapped<K, F> = TMapped<K, F>>(key: [...K], map: F, options?: ObjectOptions): R;
|
|
50
|
+
export {};
|
|
@@ -1,18 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Mapped = void 0;
|
|
4
|
-
const index_1 = require("../
|
|
5
|
-
const index_2 = require("../literal/index");
|
|
6
|
-
const indexed_key_1 = require("../indexed/indexed-key");
|
|
3
|
+
exports.Mapped = exports.MappedResult = exports.FromMappedPropertyKeys = exports.FromMappedPropertyKey = exports.MappedKey = void 0;
|
|
4
|
+
const index_1 = require("../indexed/index");
|
|
7
5
|
const type_1 = require("../guard/type");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const index_2 = require("../symbols/index");
|
|
7
|
+
const type_2 = require("../clone/type");
|
|
8
|
+
const index_3 = require("../discard/index");
|
|
9
|
+
const index_4 = require("../array/index");
|
|
10
|
+
const index_5 = require("../async-iterator/index");
|
|
11
|
+
const index_6 = require("../constructor/index");
|
|
12
|
+
const index_7 = require("../function/index");
|
|
13
|
+
const index_8 = require("../intersect/index");
|
|
14
|
+
const index_9 = require("../iterator/index");
|
|
15
|
+
const index_10 = require("../literal/index");
|
|
16
|
+
const index_11 = require("../never/index");
|
|
17
|
+
const index_12 = require("../object/index");
|
|
18
|
+
const index_13 = require("../optional/index");
|
|
19
|
+
const index_14 = require("../promise/index");
|
|
20
|
+
const index_15 = require("../readonly/index");
|
|
21
|
+
const index_16 = require("../union/index");
|
|
22
|
+
const type_3 = require("../guard/type");
|
|
23
|
+
function MappedKey(T) {
|
|
24
|
+
return {
|
|
25
|
+
[index_2.Kind]: 'MappedKey',
|
|
26
|
+
keys: T
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.MappedKey = MappedKey;
|
|
30
|
+
function FromMappedResult(K, P) {
|
|
31
|
+
return (K in P
|
|
32
|
+
? FromMappedPropertyKey(K, P[K])
|
|
33
|
+
: (0, index_11.Never)());
|
|
34
|
+
}
|
|
35
|
+
function FromMappedKey(K, _) {
|
|
36
|
+
return (0, index_10.Literal)(K);
|
|
37
|
+
}
|
|
38
|
+
function FromRest(K, T) {
|
|
39
|
+
const [L, ...R] = T;
|
|
40
|
+
return (T.length > 0
|
|
41
|
+
? [FromMappedPropertyKey(K, L), ...FromRest(K, R)]
|
|
42
|
+
: []);
|
|
43
|
+
}
|
|
44
|
+
function FromProperties(K, T) {
|
|
45
|
+
return globalThis.Object.getOwnPropertyNames(T).reduce((Acc, K2) => {
|
|
46
|
+
return { ...Acc, [K2]: FromMappedPropertyKey(K, T[K2]) };
|
|
15
47
|
}, {});
|
|
16
|
-
|
|
48
|
+
}
|
|
49
|
+
function FromMappedPropertyKey(K, T) {
|
|
50
|
+
return ((0, type_3.TOptional)(T) ? (0, index_13.Optional)(FromMappedPropertyKey(K, (0, index_3.Discard)(T, [index_2.OptionalKind]))) :
|
|
51
|
+
(0, type_3.TReadonly)(T) ? (0, index_15.Readonly)(FromMappedPropertyKey(K, (0, index_3.Discard)(T, [index_2.ReadonlyKind]))) :
|
|
52
|
+
(0, type_3.TMappedResult)(T) ? FromMappedResult(K, T.properties) :
|
|
53
|
+
(0, type_3.TMappedKey)(T) ? FromMappedKey(K, T.keys) :
|
|
54
|
+
(0, type_3.TConstructor)(T) ? (0, index_6.Constructor)(FromRest(K, T.parameters), FromMappedPropertyKey(K, T.returns)) :
|
|
55
|
+
(0, type_3.TFunction)(T) ? (0, index_7.Function)(FromRest(K, T.parameters), FromMappedPropertyKey(K, T.returns)) :
|
|
56
|
+
(0, type_3.TAsyncIterator)(T) ? (0, index_5.AsyncIterator)(FromMappedPropertyKey(K, T.items)) :
|
|
57
|
+
(0, type_3.TIterator)(T) ? (0, index_9.Iterator)(FromMappedPropertyKey(K, T.items)) :
|
|
58
|
+
(0, type_3.TIntersect)(T) ? (0, index_8.Intersect)(FromRest(K, T.allOf)) :
|
|
59
|
+
(0, type_3.TUnion)(T) ? (0, index_16.Union)(FromRest(K, T.anyOf)) :
|
|
60
|
+
(0, type_3.TObject)(T) ? (0, index_12.Object)(FromProperties(K, T.properties)) :
|
|
61
|
+
(0, type_3.TArray)(T) ? (0, index_4.Array)(FromMappedPropertyKey(K, T.items)) :
|
|
62
|
+
(0, type_3.TPromise)(T) ? (0, index_14.Promise)(FromMappedPropertyKey(K, T.item)) :
|
|
63
|
+
T);
|
|
64
|
+
}
|
|
65
|
+
exports.FromMappedPropertyKey = FromMappedPropertyKey;
|
|
66
|
+
function FromMappedPropertyKeys(K, T) {
|
|
67
|
+
const [L, ...R] = K;
|
|
68
|
+
return (K.length > 0
|
|
69
|
+
? { [L]: FromMappedPropertyKey(L, T), ...FromMappedPropertyKeys(R, T) }
|
|
70
|
+
: {});
|
|
71
|
+
}
|
|
72
|
+
exports.FromMappedPropertyKeys = FromMappedPropertyKeys;
|
|
73
|
+
function MappedResult(properties) {
|
|
74
|
+
return {
|
|
75
|
+
[index_2.Kind]: 'MappedResult',
|
|
76
|
+
properties
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
exports.MappedResult = MappedResult;
|
|
80
|
+
function Mapped(key, map, options = {}) {
|
|
81
|
+
const K = (0, type_1.TSchema)(key) ? (0, index_1.IndexedPropertyKeys)(key) : key;
|
|
82
|
+
const RT = map({ [index_2.Kind]: 'MappedKey', keys: K });
|
|
83
|
+
const R = FromMappedPropertyKeys(K, RT);
|
|
84
|
+
return (0, type_2.CloneType)((0, index_12.Object)(R), options);
|
|
17
85
|
}
|
|
18
86
|
exports.Mapped = Mapped;
|
|
@@ -4,7 +4,7 @@ import { type TRecursive } from '../recursive/index';
|
|
|
4
4
|
import { type TIntersect } from '../intersect/index';
|
|
5
5
|
import { type TUnion } from '../union/index';
|
|
6
6
|
import { type TObject, type TProperties } from '../object/index';
|
|
7
|
-
import {
|
|
7
|
+
import { IndexedPropertyKeys } from '../indexed/index';
|
|
8
8
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromIntersect<R, K>] : [];
|
|
9
9
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
|
|
10
10
|
type FromUnion<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromUnion<R, K>] : [];
|
|
@@ -14,6 +14,6 @@ declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(
|
|
|
14
14
|
export type OmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<OmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
|
|
15
15
|
export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): OmitResolve<T, K>;
|
|
16
16
|
export type TOmit<T extends TSchema, K extends PropertyKey[]> = OmitResolve<T, K>;
|
|
17
|
-
export declare function Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] =
|
|
17
|
+
export declare function Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
18
18
|
export declare function Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
|
|
19
19
|
export {};
|
|
@@ -32,7 +32,7 @@ function OmitResolve(T, K) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.OmitResolve = OmitResolve;
|
|
34
34
|
function Omit(T, K, options = {}) {
|
|
35
|
-
const I = (0, type_2.TSchema)(K) ? (0, index_4.
|
|
35
|
+
const I = (0, type_2.TSchema)(K) ? (0, index_4.IndexedPropertyKeys)(K) : K;
|
|
36
36
|
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);
|
|
37
37
|
const R = (0, type_1.CloneType)(OmitResolve(T, I), options);
|
|
38
38
|
return { ...D, ...R };
|
|
@@ -4,7 +4,7 @@ import { type TRecursive } from '../recursive/index';
|
|
|
4
4
|
import { type TIntersect } from '../intersect/index';
|
|
5
5
|
import { type TUnion } from '../union/index';
|
|
6
6
|
import { type TObject, type TProperties } from '../object/index';
|
|
7
|
-
import {
|
|
7
|
+
import { IndexedPropertyKeys } from '../indexed/index';
|
|
8
8
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<L, K>, ...FromIntersect<R, K>] : [];
|
|
9
9
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
|
|
10
10
|
type FromUnion<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<L, K>, ...FromUnion<R, K>] : [];
|
|
@@ -14,6 +14,6 @@ declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(
|
|
|
14
14
|
export type PickResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<PickResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
|
|
15
15
|
export declare function PickResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): PickResolve<T, K>;
|
|
16
16
|
export type TPick<T extends TSchema, K extends PropertyKey[]> = PickResolve<T, K>;
|
|
17
|
-
export declare function Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] =
|
|
17
|
+
export declare function Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
18
18
|
export declare function Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
19
19
|
export {};
|
|
@@ -28,7 +28,7 @@ function PickResolve(T, K) {
|
|
|
28
28
|
}
|
|
29
29
|
exports.PickResolve = PickResolve;
|
|
30
30
|
function Pick(T, K, options = {}) {
|
|
31
|
-
const I = (0, type_2.TSchema)(K) ? (0, index_4.
|
|
31
|
+
const I = (0, type_2.TSchema)(K) ? (0, index_4.IndexedPropertyKeys)(K) : K;
|
|
32
32
|
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);
|
|
33
33
|
const R = (0, type_1.CloneType)(PickResolve(T, I), options);
|
|
34
34
|
return { ...D, ...R };
|
|
@@ -21,11 +21,11 @@ function FromKeys(keys, T) {
|
|
|
21
21
|
function FromTemplateLiteralKey(K, T) {
|
|
22
22
|
const expression = (0, index_4.TemplateLiteralParseExact)(K.pattern);
|
|
23
23
|
return ((0, index_4.IsTemplateLiteralFinite)(expression)
|
|
24
|
-
? FromKeys((0, index_6.
|
|
24
|
+
? FromKeys((0, index_6.IndexedPropertyKeys)(K), T)
|
|
25
25
|
: FromPattern(K.pattern, T));
|
|
26
26
|
}
|
|
27
27
|
function FromUnionKey(K, T) {
|
|
28
|
-
return FromKeys((0, index_6.
|
|
28
|
+
return FromKeys((0, index_6.IndexedPropertyKeys)((0, index_3.Union)(K)), T);
|
|
29
29
|
}
|
|
30
30
|
function FromLiteralKey(K, T) {
|
|
31
31
|
return FromKeys([K.toString()], T);
|
|
@@ -6,17 +6,19 @@ import { type TConst } from '../const/index';
|
|
|
6
6
|
import { type TDeref } from '../deref/index';
|
|
7
7
|
import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index';
|
|
8
8
|
import { type TExclude } from '../exclude/index';
|
|
9
|
-
import { type TExtends } from '../extends/index';
|
|
9
|
+
import { type TExtends, type MappedExtends, type MappedResultExtends } from '../extends/index';
|
|
10
10
|
import { type TExtract } from '../extract/index';
|
|
11
|
-
import { TIndex, type
|
|
11
|
+
import { TIndex, type IndexedPropertyKeys, type TMappedIndex } from '../indexed/index';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index';
|
|
13
13
|
import { type IntersectOptions, type IntersectResolve } from '../intersect/index';
|
|
14
14
|
import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index';
|
|
15
15
|
import { type TKeyOf } from '../keyof/index';
|
|
16
16
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
17
|
+
import { type MappedFunction, type TMapped, type TMappedResult } from '../mapped/index';
|
|
17
18
|
import { type TNever } from '../never/index';
|
|
18
19
|
import { type TNot } from '../not/index';
|
|
19
20
|
import { type TNull } from '../null/index';
|
|
21
|
+
import { type TMappedKey } from '../mapped/index';
|
|
20
22
|
import { type TNumber, type NumberOptions } from '../number/index';
|
|
21
23
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
22
24
|
import { type TOmit } from '../omit/index';
|
|
@@ -51,25 +53,30 @@ export declare class JsonTypeBuilder {
|
|
|
51
53
|
Const<T>(value: T, options?: SchemaOptions): TConst<T>;
|
|
52
54
|
Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
|
|
53
55
|
Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
54
|
-
Extends<L extends
|
|
56
|
+
Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): MappedResultExtends<L, R, T, F>;
|
|
57
|
+
Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): MappedExtends<L, R, T, F>;
|
|
58
|
+
Extends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtends<L, R, T, F>;
|
|
55
59
|
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
56
60
|
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
57
|
-
Index<T extends TSchema, K extends
|
|
61
|
+
Index<T extends TSchema, K extends TMappedKey>(T: T, K: K): TMappedIndex<T, K>;
|
|
62
|
+
Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
|
|
58
63
|
Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
59
64
|
Integer(options?: IntegerOptions): TInteger;
|
|
60
65
|
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): IntersectResolve<T>;
|
|
61
66
|
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
62
67
|
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
63
68
|
Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TLowercase<T>;
|
|
69
|
+
Mapped<K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>, F extends MappedFunction<I> = MappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;
|
|
70
|
+
Mapped<K extends PropertyKey[], F extends MappedFunction<K> = MappedFunction<K>, R extends TMapped<K, F> = TMapped<K, F>>(key: [...K], map: F, options?: ObjectOptions): R;
|
|
64
71
|
Never(options?: SchemaOptions): TNever;
|
|
65
72
|
Not<T extends TSchema>(schema: T, options?: SchemaOptions): TNot<T>;
|
|
66
73
|
Null(options?: SchemaOptions): TNull;
|
|
67
74
|
Number(options?: NumberOptions): TNumber;
|
|
68
75
|
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
69
|
-
Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] =
|
|
76
|
+
Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
70
77
|
Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
|
|
71
78
|
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
72
|
-
Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] =
|
|
79
|
+
Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = IndexedPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
73
80
|
Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
74
81
|
Record<K extends TSchema, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): RecordResolve<K, T>;
|
|
75
82
|
Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
|
|
@@ -17,42 +17,43 @@ const index_13 = require("../intersect/index");
|
|
|
17
17
|
const index_14 = require("../intrinsic/index");
|
|
18
18
|
const index_15 = require("../keyof/index");
|
|
19
19
|
const index_16 = require("../literal/index");
|
|
20
|
-
const index_17 = require("../
|
|
21
|
-
const index_18 = require("../
|
|
22
|
-
const index_19 = require("../
|
|
23
|
-
const index_20 = require("../
|
|
24
|
-
const index_21 = require("../
|
|
25
|
-
const index_22 = require("../
|
|
26
|
-
const index_23 = require("../
|
|
27
|
-
const index_24 = require("../
|
|
28
|
-
const index_25 = require("../
|
|
29
|
-
const index_26 = require("../
|
|
30
|
-
const index_27 = require("../readonly
|
|
31
|
-
const index_28 = require("../
|
|
32
|
-
const index_29 = require("../
|
|
33
|
-
const index_30 = require("../
|
|
34
|
-
const index_31 = require("../
|
|
35
|
-
const index_32 = require("../
|
|
36
|
-
const index_33 = require("../
|
|
37
|
-
const index_34 = require("../
|
|
38
|
-
const index_35 = require("../
|
|
39
|
-
const index_36 = require("../
|
|
40
|
-
const index_37 = require("../
|
|
41
|
-
const index_38 = require("../
|
|
42
|
-
const index_39 = require("../
|
|
43
|
-
const index_40 = require("../
|
|
20
|
+
const index_17 = require("../mapped/index");
|
|
21
|
+
const index_18 = require("../never/index");
|
|
22
|
+
const index_19 = require("../not/index");
|
|
23
|
+
const index_20 = require("../null/index");
|
|
24
|
+
const index_21 = require("../number/index");
|
|
25
|
+
const index_22 = require("../object/index");
|
|
26
|
+
const index_23 = require("../omit/index");
|
|
27
|
+
const index_24 = require("../optional/index");
|
|
28
|
+
const index_25 = require("../partial/index");
|
|
29
|
+
const index_26 = require("../pick/index");
|
|
30
|
+
const index_27 = require("../readonly/index");
|
|
31
|
+
const index_28 = require("../readonly-optional/index");
|
|
32
|
+
const index_29 = require("../record/index");
|
|
33
|
+
const index_30 = require("../recursive/index");
|
|
34
|
+
const index_31 = require("../ref/index");
|
|
35
|
+
const index_32 = require("../required/index");
|
|
36
|
+
const index_33 = require("../rest/index");
|
|
37
|
+
const index_34 = require("../strict/index");
|
|
38
|
+
const index_35 = require("../string/index");
|
|
39
|
+
const index_36 = require("../template-literal/index");
|
|
40
|
+
const index_37 = require("../transform/index");
|
|
41
|
+
const index_38 = require("../tuple/index");
|
|
42
|
+
const index_39 = require("../union/index");
|
|
43
|
+
const index_40 = require("../unknown/index");
|
|
44
|
+
const index_41 = require("../unsafe/index");
|
|
44
45
|
class JsonTypeBuilder {
|
|
45
46
|
Strict(schema) {
|
|
46
|
-
return (0,
|
|
47
|
+
return (0, index_34.Strict)(schema);
|
|
47
48
|
}
|
|
48
49
|
ReadonlyOptional(schema) {
|
|
49
|
-
return (0,
|
|
50
|
+
return (0, index_28.ReadonlyOptional)(schema);
|
|
50
51
|
}
|
|
51
52
|
Readonly(schema) {
|
|
52
|
-
return (0,
|
|
53
|
+
return (0, index_27.Readonly)(schema);
|
|
53
54
|
}
|
|
54
55
|
Optional(schema) {
|
|
55
|
-
return (0,
|
|
56
|
+
return (0, index_24.Optional)(schema);
|
|
56
57
|
}
|
|
57
58
|
Any(options = {}) {
|
|
58
59
|
return (0, index_1.Any)(options);
|
|
@@ -78,8 +79,8 @@ class JsonTypeBuilder {
|
|
|
78
79
|
Enum(item, options = {}) {
|
|
79
80
|
return (0, index_7.Enum)(item, options);
|
|
80
81
|
}
|
|
81
|
-
Extends(
|
|
82
|
-
return (0, index_9.Extends)(
|
|
82
|
+
Extends(L, R, T, F, options = {}) {
|
|
83
|
+
return (0, index_9.Extends)(L, R, T, F, options);
|
|
83
84
|
}
|
|
84
85
|
Exclude(unionType, excludedMembers, options = {}) {
|
|
85
86
|
return (0, index_8.Exclude)(unionType, excludedMembers, options);
|
|
@@ -105,68 +106,71 @@ class JsonTypeBuilder {
|
|
|
105
106
|
Lowercase(schema, options = {}) {
|
|
106
107
|
return (0, index_14.Lowercase)(schema, options);
|
|
107
108
|
}
|
|
109
|
+
Mapped(key, map, options = {}) {
|
|
110
|
+
return (0, index_17.Mapped)(key, map, options);
|
|
111
|
+
}
|
|
108
112
|
Never(options = {}) {
|
|
109
|
-
return (0,
|
|
113
|
+
return (0, index_18.Never)(options);
|
|
110
114
|
}
|
|
111
115
|
Not(schema, options) {
|
|
112
|
-
return (0,
|
|
116
|
+
return (0, index_19.Not)(schema, options);
|
|
113
117
|
}
|
|
114
118
|
Null(options = {}) {
|
|
115
|
-
return (0,
|
|
119
|
+
return (0, index_20.Null)(options);
|
|
116
120
|
}
|
|
117
121
|
Number(options = {}) {
|
|
118
|
-
return (0,
|
|
122
|
+
return (0, index_21.Number)(options);
|
|
119
123
|
}
|
|
120
124
|
Object(properties, options = {}) {
|
|
121
|
-
return (0,
|
|
125
|
+
return (0, index_22.Object)(properties, options);
|
|
122
126
|
}
|
|
123
127
|
Omit(schema, unresolved, options = {}) {
|
|
124
|
-
return (0,
|
|
128
|
+
return (0, index_23.Omit)(schema, unresolved, options);
|
|
125
129
|
}
|
|
126
130
|
Partial(schema, options = {}) {
|
|
127
|
-
return (0,
|
|
131
|
+
return (0, index_25.Partial)(schema, options);
|
|
128
132
|
}
|
|
129
133
|
Pick(schema, unresolved, options = {}) {
|
|
130
|
-
return (0,
|
|
134
|
+
return (0, index_26.Pick)(schema, unresolved, options);
|
|
131
135
|
}
|
|
132
136
|
Record(key, schema, options = {}) {
|
|
133
|
-
return (0,
|
|
137
|
+
return (0, index_29.Record)(key, schema);
|
|
134
138
|
}
|
|
135
139
|
Recursive(callback, options = {}) {
|
|
136
|
-
return (0,
|
|
140
|
+
return (0, index_30.Recursive)(callback, options);
|
|
137
141
|
}
|
|
138
142
|
Ref(unresolved, options = {}) {
|
|
139
|
-
return (0,
|
|
143
|
+
return (0, index_31.Ref)(unresolved, options);
|
|
140
144
|
}
|
|
141
145
|
Required(schema, options = {}) {
|
|
142
|
-
return (0,
|
|
146
|
+
return (0, index_32.Required)(schema, options);
|
|
143
147
|
}
|
|
144
148
|
Rest(schema) {
|
|
145
|
-
return (0,
|
|
149
|
+
return (0, index_33.Rest)(schema);
|
|
146
150
|
}
|
|
147
151
|
String(options = {}) {
|
|
148
|
-
return (0,
|
|
152
|
+
return (0, index_35.String)(options);
|
|
149
153
|
}
|
|
150
154
|
TemplateLiteral(unresolved, options = {}) {
|
|
151
|
-
return (0,
|
|
155
|
+
return (0, index_36.TemplateLiteral)(unresolved, options);
|
|
152
156
|
}
|
|
153
157
|
Transform(schema) {
|
|
154
|
-
return (0,
|
|
158
|
+
return (0, index_37.Transform)(schema);
|
|
155
159
|
}
|
|
156
160
|
Tuple(items, options = {}) {
|
|
157
|
-
return (0,
|
|
161
|
+
return (0, index_38.Tuple)(items, options);
|
|
158
162
|
}
|
|
159
163
|
Uncapitalize(schema, options = {}) {
|
|
160
164
|
return (0, index_14.Uncapitalize)(schema, options);
|
|
161
165
|
}
|
|
162
166
|
Union(schemas, options = {}) {
|
|
163
|
-
return (0,
|
|
167
|
+
return (0, index_39.Union)(schemas, options);
|
|
164
168
|
}
|
|
165
169
|
Unknown(options = {}) {
|
|
166
|
-
return (0,
|
|
170
|
+
return (0, index_40.Unknown)(options);
|
|
167
171
|
}
|
|
168
172
|
Unsafe(options = {}) {
|
|
169
|
-
return (0,
|
|
173
|
+
return (0, index_41.Unsafe)(options);
|
|
170
174
|
}
|
|
171
175
|
Uppercase(schema, options = {}) {
|
|
172
176
|
return (0, index_14.Uppercase)(schema, options);
|
|
@@ -142,12 +142,12 @@ function TInteger(schema, references, value) {
|
|
|
142
142
|
function TIntersect(schema, references, value) {
|
|
143
143
|
const check1 = schema.allOf.every((schema) => Visit(schema, references, value));
|
|
144
144
|
if (schema.unevaluatedProperties === false) {
|
|
145
|
-
const keyPattern = new RegExp((0, index_6.
|
|
145
|
+
const keyPattern = new RegExp((0, index_6.KeyOfPattern)(schema));
|
|
146
146
|
const check2 = Object.getOwnPropertyNames(value).every((key) => keyPattern.test(key));
|
|
147
147
|
return check1 && check2;
|
|
148
148
|
}
|
|
149
149
|
else if ((0, type_1.TSchema)(schema.unevaluatedProperties)) {
|
|
150
|
-
const keyCheck = new RegExp((0, index_6.
|
|
150
|
+
const keyCheck = new RegExp((0, index_6.KeyOfPattern)(schema));
|
|
151
151
|
const check2 = Object.getOwnPropertyNames(value).every((key) => keyCheck.test(key) || Visit(schema.unevaluatedProperties, references, value[key]));
|
|
152
152
|
return check1 && check2;
|
|
153
153
|
}
|
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Clean = void 0;
|
|
4
4
|
const index_1 = require("../guard/index");
|
|
5
5
|
const type_1 = require("../../type/guard/type");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const index_2 = require("../../type/keyof/index");
|
|
7
|
+
const index_3 = require("../check/index");
|
|
8
|
+
const index_4 = require("../clone/index");
|
|
9
|
+
const index_5 = require("../deref/index");
|
|
10
|
+
const index_6 = require("../../type/symbols/index");
|
|
11
11
|
function IsSchema(schema) {
|
|
12
12
|
return (0, type_1.TSchema)(schema);
|
|
13
13
|
}
|
|
14
14
|
function IsCheckable(schema) {
|
|
15
|
-
return (0, type_1.TSchema)(schema) && schema[
|
|
15
|
+
return (0, type_1.TSchema)(schema) && schema[index_6.Kind] !== 'Unsafe';
|
|
16
16
|
}
|
|
17
17
|
function TArray(schema, references, value) {
|
|
18
18
|
if (!(0, index_1.IsArray)(value))
|
|
@@ -21,15 +21,15 @@ function TArray(schema, references, value) {
|
|
|
21
21
|
}
|
|
22
22
|
function TIntersect(schema, references, value) {
|
|
23
23
|
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
24
|
-
const intersections = schema.allOf.map((schema) => Visit(schema, references, (0,
|
|
24
|
+
const intersections = schema.allOf.map((schema) => Visit(schema, references, (0, index_4.Clone)(value)));
|
|
25
25
|
const composite = intersections.reduce((acc, value) => ((0, index_1.IsObject)(value) ? { ...acc, ...value } : value), {});
|
|
26
26
|
if (!(0, index_1.IsObject)(value) || !(0, index_1.IsObject)(composite) || !IsSchema(unevaluatedProperties))
|
|
27
27
|
return composite;
|
|
28
|
-
const knownkeys = (0,
|
|
28
|
+
const knownkeys = (0, index_2.KeyOfPropertyKeys)(schema);
|
|
29
29
|
for (const key of Object.getOwnPropertyNames(value)) {
|
|
30
30
|
if (knownkeys.includes(key))
|
|
31
31
|
continue;
|
|
32
|
-
if ((0,
|
|
32
|
+
if ((0, index_3.Check)(unevaluatedProperties, references, value[key])) {
|
|
33
33
|
composite[key] = Visit(unevaluatedProperties, references, value[key]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -44,7 +44,7 @@ function TObject(schema, references, value) {
|
|
|
44
44
|
value[key] = Visit(schema.properties[key], references, value[key]);
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
if (IsSchema(additionalProperties) && (0,
|
|
47
|
+
if (IsSchema(additionalProperties) && (0, index_3.Check)(additionalProperties, references, value[key])) {
|
|
48
48
|
value[key] = Visit(additionalProperties, references, value[key]);
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
@@ -64,7 +64,7 @@ function TRecord(schema, references, value) {
|
|
|
64
64
|
value[key] = Visit(propertySchema, references, value[key]);
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
-
if (IsSchema(additionalProperties) && (0,
|
|
67
|
+
if (IsSchema(additionalProperties) && (0, index_3.Check)(additionalProperties, references, value[key])) {
|
|
68
68
|
value[key] = Visit(additionalProperties, references, value[key]);
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
@@ -73,10 +73,10 @@ function TRecord(schema, references, value) {
|
|
|
73
73
|
return value;
|
|
74
74
|
}
|
|
75
75
|
function TRef(schema, references, value) {
|
|
76
|
-
return Visit((0,
|
|
76
|
+
return Visit((0, index_5.Deref)(schema, references), references, value);
|
|
77
77
|
}
|
|
78
78
|
function TThis(schema, references, value) {
|
|
79
|
-
return Visit((0,
|
|
79
|
+
return Visit((0, index_5.Deref)(schema, references), references, value);
|
|
80
80
|
}
|
|
81
81
|
function TTuple(schema, references, value) {
|
|
82
82
|
if (!(0, index_1.IsArray)(value))
|
|
@@ -93,7 +93,7 @@ function TTuple(schema, references, value) {
|
|
|
93
93
|
}
|
|
94
94
|
function TUnion(schema, references, value) {
|
|
95
95
|
for (const inner of schema.anyOf) {
|
|
96
|
-
if (IsCheckable(inner) && (0,
|
|
96
|
+
if (IsCheckable(inner) && (0, index_3.Check)(inner, value)) {
|
|
97
97
|
return Visit(inner, references, value);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -102,7 +102,7 @@ function TUnion(schema, references, value) {
|
|
|
102
102
|
function Visit(schema, references, value) {
|
|
103
103
|
const references_ = (0, index_1.IsString)(schema.$id) ? [...references, schema] : references;
|
|
104
104
|
const schema_ = schema;
|
|
105
|
-
switch (schema_[
|
|
105
|
+
switch (schema_[index_6.Kind]) {
|
|
106
106
|
case 'Array':
|
|
107
107
|
return TArray(schema_, references_, value);
|
|
108
108
|
case 'Intersect':
|
|
@@ -41,10 +41,10 @@ function TArray(schema, references, value) {
|
|
|
41
41
|
function TIntersect(schema, references, value) {
|
|
42
42
|
if (!(0, index_2.IsPlainObject)(value) || (0, index_2.IsValueType)(value))
|
|
43
43
|
return Default(schema, value);
|
|
44
|
-
const knownKeys = (0, index_3.
|
|
44
|
+
const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
|
|
45
45
|
const knownProperties = knownKeys.reduce((value, key) => {
|
|
46
46
|
return (key in value)
|
|
47
|
-
? { ...value, [key]: Visit((0, index_4.
|
|
47
|
+
? { ...value, [key]: Visit((0, index_4.IndexedType)(schema, [key]), references, value[key]) }
|
|
48
48
|
: value;
|
|
49
49
|
}, value);
|
|
50
50
|
if (!(0, type_1.TTransform)(schema.unevaluatedProperties)) {
|
|
@@ -65,7 +65,7 @@ function TNot(schema, references, value) {
|
|
|
65
65
|
function TObject(schema, references, value) {
|
|
66
66
|
if (!(0, index_2.IsPlainObject)(value))
|
|
67
67
|
return Default(schema, value);
|
|
68
|
-
const knownKeys = (0, index_3.
|
|
68
|
+
const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
|
|
69
69
|
const knownProperties = knownKeys.reduce((value, key) => {
|
|
70
70
|
return (key in value)
|
|
71
71
|
? { ...value, [key]: Visit(schema.properties[key], references, value[key]) }
|
|
@@ -43,10 +43,10 @@ function TIntersect(schema, references, value) {
|
|
|
43
43
|
const defaulted = Default(schema, value);
|
|
44
44
|
if (!(0, index_2.IsPlainObject)(value) || (0, index_2.IsValueType)(value))
|
|
45
45
|
return defaulted;
|
|
46
|
-
const knownKeys = (0, index_3.
|
|
46
|
+
const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
|
|
47
47
|
const knownProperties = knownKeys.reduce((value, key) => {
|
|
48
48
|
return key in defaulted
|
|
49
|
-
? { ...value, [key]: Visit((0, index_4.
|
|
49
|
+
? { ...value, [key]: Visit((0, index_4.IndexedType)(schema, [key]), references, value[key]) }
|
|
50
50
|
: value;
|
|
51
51
|
}, defaulted);
|
|
52
52
|
if (!(0, type_1.TTransform)(schema.unevaluatedProperties)) {
|
|
@@ -67,7 +67,7 @@ function TObject(schema, references, value) {
|
|
|
67
67
|
const defaulted = Default(schema, value);
|
|
68
68
|
if (!(0, index_2.IsPlainObject)(value))
|
|
69
69
|
return defaulted;
|
|
70
|
-
const knownKeys = (0, index_3.
|
|
70
|
+
const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
|
|
71
71
|
const knownProperties = knownKeys.reduce((value, key) => {
|
|
72
72
|
return key in value
|
|
73
73
|
? { ...value, [key]: Visit(schema.properties[key], references, value[key]) }
|