@sinclair/typebox 0.32.0-dev-21 → 0.32.0-dev-23
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/index.d.mts +2 -2
- package/build/import/type/awaited/awaited.d.mts +4 -6
- package/build/import/type/awaited/awaited.mjs +3 -3
- package/build/import/type/composite/composite.d.mts +8 -8
- package/build/import/type/const/const.d.mts +4 -7
- package/build/import/type/constructor/constructor.d.mts +4 -4
- package/build/import/type/deref/deref.d.mts +2 -2
- package/build/import/type/deref/deref.mjs +26 -36
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
- package/build/import/type/exclude/exclude.d.mts +7 -8
- package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
- package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
- package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
- package/build/import/type/extends/extends.d.mts +2 -3
- package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
- package/build/import/type/extract/extract.d.mts +8 -8
- package/build/import/type/function/function.d.mts +1 -1
- package/build/import/type/helpers/helpers.d.mts +1 -1
- package/build/import/type/index.d.mts +0 -1
- package/build/import/type/index.mjs +0 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
- package/build/import/type/indexed/indexed-property-keys.d.mts +4 -7
- package/build/import/type/indexed/indexed.d.mts +13 -23
- package/build/import/type/indexed/indexed.mjs +13 -13
- package/build/import/type/intersect/intersect-create.mjs +0 -1
- package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
- package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
- package/build/import/type/intersect/intersect-type.d.mts +2 -2
- package/build/import/type/intersect/intersect.mjs +1 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
- package/build/import/type/intrinsic/intrinsic.mjs +5 -3
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
- package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
- package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
- package/build/import/type/keyof/keyof.d.mts +7 -8
- package/build/import/type/keyof/keyof.mjs +8 -6
- package/build/import/type/mapped/mapped.d.mts +9 -13
- package/build/import/type/mapped/mapped.mjs +9 -9
- package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
- package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
- package/build/import/type/omit/omit.d.mts +6 -9
- package/build/import/type/omit/omit.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +16 -16
- package/build/import/type/operators/operators.mjs +21 -25
- package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
- package/build/import/type/optional/optional.d.mts +3 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
- package/build/import/type/partial/partial.d.mts +4 -7
- package/build/import/type/partial/partial.mjs +6 -7
- package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
- package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
- package/build/import/type/pick/pick.d.mts +4 -4
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
- package/build/import/type/readonly/readonly.d.mts +3 -7
- package/build/import/type/record/record.d.mts +13 -19
- package/build/import/type/record/record.mjs +0 -1
- package/build/import/type/ref/ref.mjs +3 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
- package/build/import/type/required/required.d.mts +5 -9
- package/build/import/type/required/required.mjs +6 -7
- package/build/import/type/rest/rest.d.mts +3 -3
- package/build/import/type/static/static.d.mts +1 -1
- package/build/import/type/template-literal/finite.d.mts +3 -3
- package/build/import/type/template-literal/generate.d.mts +7 -8
- package/build/import/type/template-literal/syntax.d.mts +2 -2
- package/build/import/type/template-literal/syntax.mjs +2 -2
- package/build/import/type/transform/transform.mjs +0 -1
- package/build/import/type/tuple/tuple.d.mts +1 -2
- package/build/import/type/union/union-evaluated.d.mts +6 -10
- package/build/import/type/union/union-evaluated.mjs +7 -2
- package/build/require/index.d.ts +2 -2
- package/build/require/type/awaited/awaited.d.ts +4 -6
- package/build/require/type/awaited/awaited.js +3 -3
- package/build/require/type/composite/composite.d.ts +8 -8
- package/build/require/type/const/const.d.ts +4 -7
- package/build/require/type/constructor/constructor.d.ts +4 -4
- package/build/require/type/deref/deref.d.ts +2 -2
- package/build/require/type/deref/deref.js +25 -35
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
- package/build/require/type/exclude/exclude.d.ts +7 -8
- package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
- package/build/require/type/extends/extends-from-mapped-key.js +3 -3
- package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
- package/build/require/type/extends/extends.d.ts +2 -3
- package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
- package/build/require/type/extract/extract.d.ts +8 -8
- package/build/require/type/function/function.d.ts +1 -1
- package/build/require/type/helpers/helpers.d.ts +1 -1
- package/build/require/type/index.d.ts +0 -1
- package/build/require/type/index.js +0 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
- package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
- package/build/require/type/indexed/indexed-property-keys.d.ts +4 -7
- package/build/require/type/indexed/indexed.d.ts +13 -23
- package/build/require/type/indexed/indexed.js +13 -13
- package/build/require/type/intersect/intersect-create.js +0 -1
- package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
- package/build/require/type/intersect/intersect-evaluated.js +9 -4
- package/build/require/type/intersect/intersect-type.d.ts +2 -2
- package/build/require/type/intersect/intersect.js +0 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
- package/build/require/type/intrinsic/intrinsic.js +5 -3
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
- package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
- package/build/require/type/keyof/keyof-property-keys.js +12 -9
- package/build/require/type/keyof/keyof.d.ts +7 -8
- package/build/require/type/keyof/keyof.js +8 -6
- package/build/require/type/mapped/mapped.d.ts +9 -13
- package/build/require/type/mapped/mapped.js +9 -9
- package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
- package/build/require/type/omit/omit-from-mapped-key.js +3 -3
- package/build/require/type/omit/omit.d.ts +6 -9
- package/build/require/type/omit/omit.js +0 -1
- package/build/require/type/operators/operators.d.ts +16 -16
- package/build/require/type/operators/operators.js +21 -25
- package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
- package/build/require/type/optional/optional.d.ts +3 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
- package/build/require/type/partial/partial.d.ts +4 -7
- package/build/require/type/partial/partial.js +6 -7
- package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
- package/build/require/type/pick/pick-from-mapped-key.js +3 -3
- package/build/require/type/pick/pick.d.ts +4 -4
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
- package/build/require/type/readonly/readonly.d.ts +3 -7
- package/build/require/type/record/record.d.ts +13 -19
- package/build/require/type/record/record.js +0 -1
- package/build/require/type/ref/ref.js +3 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
- package/build/require/type/required/required.d.ts +5 -9
- package/build/require/type/required/required.js +6 -7
- package/build/require/type/rest/rest.d.ts +3 -3
- package/build/require/type/static/static.d.ts +1 -1
- package/build/require/type/template-literal/finite.d.ts +3 -3
- package/build/require/type/template-literal/generate.d.ts +7 -8
- package/build/require/type/template-literal/syntax.d.ts +2 -2
- package/build/require/type/template-literal/syntax.js +1 -1
- package/build/require/type/transform/transform.js +0 -1
- package/build/require/type/tuple/tuple.d.ts +1 -2
- package/build/require/type/union/union-evaluated.d.ts +6 -10
- package/build/require/type/union/union-evaluated.js +7 -2
- package/package.json +1 -1
- package/build/import/type/modifiers/index.d.mts +0 -1
- package/build/import/type/modifiers/index.mjs +0 -1
- package/build/import/type/modifiers/modifiers.d.mts +0 -18
- package/build/import/type/modifiers/modifiers.mjs +0 -50
- package/build/require/type/modifiers/index.d.ts +0 -1
- package/build/require/type/modifiers/index.js +0 -18
- package/build/require/type/modifiers/modifiers.d.ts +0 -18
- package/build/require/type/modifiers/modifiers.js +0 -56
|
@@ -4,13 +4,10 @@ import { type TInteger } from '../integer/index';
|
|
|
4
4
|
import { type TNumber } from '../number/index';
|
|
5
5
|
import { type TSchema } from '../schema/index';
|
|
6
6
|
import { type TUnion } from '../union/index';
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
type FromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
|
|
12
|
-
declare function FromLiteral<T extends TLiteralValue>(T: T): FromLiteral<T>;
|
|
13
|
-
export type TIndexPropertyKeys<T extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T> : T extends TUnion<infer S> ? FromUnion<S> : T extends TLiteral<infer S> ? FromLiteral<S> : T extends TNumber ? ['[number]'] : T extends TInteger ? ['[number]'] : [
|
|
7
|
+
type TFromTemplateLiteral<T extends TTemplateLiteral, R extends string[] = TTemplateLiteralGenerate<T>> = (R);
|
|
8
|
+
type TFromUnion<T extends TSchema[], Acc extends string[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...TIndexPropertyKeys<L>, ...Acc]> : Acc);
|
|
9
|
+
type TFromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
|
|
10
|
+
export type TIndexPropertyKeys<T extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T> : T extends TUnion<infer S> ? TFromUnion<S> : T extends TLiteral<infer S> ? TFromLiteral<S> : T extends TNumber ? ['[number]'] : T extends TInteger ? ['[number]'] : [
|
|
14
11
|
]);
|
|
15
12
|
/** Returns a tuple of PropertyKeys derived from the given TSchema */
|
|
16
13
|
export declare function IndexPropertyKeys<T extends TSchema>(T: T): TIndexPropertyKeys<T>;
|
|
@@ -8,32 +8,22 @@ import { type TMappedKey } from '../mapped/index';
|
|
|
8
8
|
import { type TUnion } from '../union/index';
|
|
9
9
|
import { type TTuple } from '../tuple/index';
|
|
10
10
|
import { type TArray } from '../array/index';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { type TIntersectEvaluated } from '../intersect/index';
|
|
12
|
+
import { type TUnionEvaluated } from '../union/index';
|
|
13
13
|
import { type TIndexPropertyKeys } from './indexed-property-keys';
|
|
14
14
|
import { type TIndexFromMappedKey } from './indexed-from-mapped-key';
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
type
|
|
20
|
-
|
|
21
|
-
type
|
|
22
|
-
declare function FromUnionRest<T extends TSchema[]>(T: [...T], S?: [...T]): FromUnionRest<T>;
|
|
23
|
-
type FromUnion<T extends TSchema[], K extends PropertyKey> = (UnionEvaluated<FromUnionRest<FromRest<T, K>>>);
|
|
24
|
-
declare function FromUnion<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromUnion<T, K>;
|
|
25
|
-
type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? UnionEvaluated<T> : TNever);
|
|
26
|
-
declare function FromTuple<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromTuple<T, K>;
|
|
27
|
-
type FromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
|
|
28
|
-
declare function FromArray<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromArray<T, K>;
|
|
15
|
+
type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TFromKey<L, K>, TSchema>]> : Acc);
|
|
16
|
+
type TFromIntersectRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? TFromIntersectRest<R, [...Acc]> : TFromIntersectRest<R, [...Acc, L]> : Acc);
|
|
17
|
+
type TFromIntersect<T extends TSchema[], K extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<T, K>>>);
|
|
18
|
+
type TFromUnionRest<T extends TSchema[], Acc extends TSchema[] = T> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [] : TFromUnionRest<R, Acc> : Acc);
|
|
19
|
+
type TFromUnion<T extends TSchema[], K extends PropertyKey> = (TUnionEvaluated<TFromUnionRest<TFromRest<T, K>>>);
|
|
20
|
+
type TFromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? TUnionEvaluated<T> : TNever);
|
|
21
|
+
type TFromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
|
|
29
22
|
type AssertPropertyKey<T> = Assert<T, string | number>;
|
|
30
|
-
type
|
|
31
|
-
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
-
type FromKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? [FromKey<T, L>, ...FromKeys<T, R>] : []);
|
|
35
|
-
declare function FromKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromKeys<T, K>;
|
|
36
|
-
type FromSchema<T extends TSchema, K extends PropertyKey[]> = (UnionEvaluated<FromKeys<T, K>>);
|
|
23
|
+
type TFromProperty<T extends TProperties, K extends PropertyKey> = (K extends keyof T ? T[K] : `${AssertPropertyKey<K>}` extends `${AssertPropertyKey<keyof T>}` ? T[AssertPropertyKey<K>] : TNever);
|
|
24
|
+
type TFromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TFromKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
|
|
25
|
+
type TFromKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TFromKeys<T, R, [...Acc, Assert<TFromKey<T, L>, TSchema>]> : Acc);
|
|
26
|
+
type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TFromKeys<T, K>>);
|
|
37
27
|
declare function FromSchema<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromSchema<T, K>;
|
|
38
28
|
export type TIndex<T extends TSchema, K extends PropertyKey[]> = (FromSchema<T, K>);
|
|
39
29
|
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
@@ -14,33 +14,33 @@ const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
|
|
|
14
14
|
// prettier-ignore
|
|
15
15
|
const type_2 = require("../guard/type");
|
|
16
16
|
// prettier-ignore
|
|
17
|
-
function FromRest(T, K) {
|
|
17
|
+
function FromRest(T, K, Acc = []) {
|
|
18
18
|
const [L, ...R] = T;
|
|
19
19
|
return (T.length > 0
|
|
20
|
-
?
|
|
21
|
-
:
|
|
20
|
+
? FromRest(R, K, [...Acc, FromKey(L, K)])
|
|
21
|
+
: Acc);
|
|
22
22
|
}
|
|
23
23
|
// prettier-ignore
|
|
24
|
-
function FromIntersectRest(T) {
|
|
24
|
+
function FromIntersectRest(T, Acc = []) {
|
|
25
25
|
const [L, ...R] = T;
|
|
26
26
|
return (T.length > 0
|
|
27
27
|
? (0, type_2.IsNever)(L)
|
|
28
|
-
?
|
|
29
|
-
: [
|
|
30
|
-
:
|
|
28
|
+
? FromIntersectRest(R, [...Acc])
|
|
29
|
+
: FromIntersectRest(R, [...Acc, L])
|
|
30
|
+
: Acc);
|
|
31
31
|
}
|
|
32
32
|
// prettier-ignore
|
|
33
33
|
function FromIntersect(T, K) {
|
|
34
34
|
return ((0, index_2.IntersectEvaluated)(FromIntersectRest(FromRest(T, K))));
|
|
35
35
|
}
|
|
36
36
|
// prettier-ignore
|
|
37
|
-
function FromUnionRest(T,
|
|
37
|
+
function FromUnionRest(T, Acc = T) {
|
|
38
38
|
const [L, ...R] = T;
|
|
39
39
|
return (T.length > 0
|
|
40
40
|
? (0, type_2.IsNever)(L)
|
|
41
41
|
? []
|
|
42
|
-
: FromUnionRest(R,
|
|
43
|
-
:
|
|
42
|
+
: FromUnionRest(R, Acc)
|
|
43
|
+
: Acc);
|
|
44
44
|
}
|
|
45
45
|
// prettier-ignore
|
|
46
46
|
function FromUnion(T, K) {
|
|
@@ -74,11 +74,11 @@ function FromKey(T, K) {
|
|
|
74
74
|
(0, index_1.Never)());
|
|
75
75
|
}
|
|
76
76
|
// prettier-ignore
|
|
77
|
-
function FromKeys(T, K) {
|
|
77
|
+
function FromKeys(T, K, Acc = []) {
|
|
78
78
|
const [L, ...R] = K;
|
|
79
79
|
return (K.length > 0
|
|
80
|
-
?
|
|
81
|
-
:
|
|
80
|
+
? FromKeys(T, R, [...Acc, FromKey(T, L)])
|
|
81
|
+
: Acc);
|
|
82
82
|
}
|
|
83
83
|
// prettier-ignore
|
|
84
84
|
function FromSchema(T, K) {
|
|
@@ -7,7 +7,6 @@ const type_1 = require("../clone/type");
|
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
|
-
// prettier-ignore
|
|
11
10
|
const type_2 = require("../guard/type");
|
|
12
11
|
// ------------------------------------------------------------------
|
|
13
12
|
// IntersectCreate
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
2
|
import { type TNever } from '../never/index';
|
|
3
3
|
import { type TOptional } from '../optional/index';
|
|
4
4
|
import type { TReadonly } from '../readonly/index';
|
|
5
5
|
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
|
|
12
|
-
type ResolveIntersect<T extends TSchema[]> = (IsIntersectOptional<T> extends true ? TOptional<TIntersect<RemoveOptionalFromRest<T>>> : TIntersect<RemoveOptionalFromRest<T>>);
|
|
13
|
-
declare function ResolveIntersect<T extends TSchema[]>(T: [...T], options: SchemaOptions): ResolveIntersect<T>;
|
|
14
|
-
export type IntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveIntersect<T>);
|
|
6
|
+
type TIsIntersectOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? TIsIntersectOptional<R> : false : true);
|
|
7
|
+
type TRemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<TRemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromType<S> : T);
|
|
8
|
+
type TRemoveOptionalFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest<R, [...Acc, TRemoveOptionalFromType<S>]> : TRemoveOptionalFromRest<R, [...Acc, L]> : Acc);
|
|
9
|
+
type TResolveIntersect<T extends TSchema[]> = (TIsIntersectOptional<T> extends true ? TOptional<TIntersect<TRemoveOptionalFromRest<T>>> : TIntersect<TRemoveOptionalFromRest<T>>);
|
|
10
|
+
export type TIntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TResolveIntersect<T>);
|
|
15
11
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
16
|
-
export declare function IntersectEvaluated<T extends TSchema[], R =
|
|
12
|
+
export declare function IntersectEvaluated<T extends TSchema[], R = TIntersectEvaluated<T>>(T: [...T], options?: IntersectOptions): R;
|
|
17
13
|
export {};
|
|
@@ -23,14 +23,19 @@ function IsIntersectOptional(T) {
|
|
|
23
23
|
: true);
|
|
24
24
|
}
|
|
25
25
|
// prettier-ignore
|
|
26
|
-
function RemoveOptionalFromRest(T) {
|
|
27
|
-
return (T.map(T => RemoveOptionalFromType(T)));
|
|
28
|
-
}
|
|
29
|
-
// prettier-ignore
|
|
30
26
|
function RemoveOptionalFromType(T) {
|
|
31
27
|
return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
|
|
32
28
|
}
|
|
33
29
|
// prettier-ignore
|
|
30
|
+
function RemoveOptionalFromRest(T, Acc = []) {
|
|
31
|
+
const [L, ...R] = T;
|
|
32
|
+
return (T.length > 0
|
|
33
|
+
? (0, type_2.IsOptional)(L)
|
|
34
|
+
? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
|
|
35
|
+
: RemoveOptionalFromRest(R, [...Acc, L])
|
|
36
|
+
: Acc);
|
|
37
|
+
}
|
|
38
|
+
// prettier-ignore
|
|
34
39
|
function ResolveIntersect(T, options) {
|
|
35
40
|
return (IsIntersectOptional(T)
|
|
36
41
|
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options))
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import { Kind } from '../symbols/index';
|
|
4
|
-
type
|
|
4
|
+
type TIntersectStatic<T extends TSchema[], P extends unknown[], Acc extends unknown = unknown> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TIntersectStatic<R, P, Acc & Static<L, P>> : Acc;
|
|
5
5
|
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
6
6
|
export interface IntersectOptions extends SchemaOptions {
|
|
7
7
|
unevaluatedProperties?: TUnevaluatedProperties;
|
|
8
8
|
}
|
|
9
9
|
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
10
10
|
[Kind]: 'Intersect';
|
|
11
|
-
static:
|
|
11
|
+
static: TIntersectStatic<T, this['params']>;
|
|
12
12
|
type?: 'object';
|
|
13
13
|
allOf: [...T];
|
|
14
14
|
}
|
|
@@ -8,7 +8,6 @@ const intersect_create_1 = require("./intersect-create");
|
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
9
|
// TypeGuard
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
|
-
// prettier-ignore
|
|
12
11
|
const type_2 = require("../guard/type");
|
|
13
12
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
14
13
|
function Intersect(T, options = {}) {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
|
+
import { Assert } from '../helpers/index';
|
|
3
4
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
4
5
|
import { type TIntrinsic, type IntrinsicMode } from './intrinsic';
|
|
5
6
|
import { TLiteral, TLiteralValue } from '../literal/index';
|
|
6
|
-
type
|
|
7
|
-
[_ in K]: TIntrinsic<TLiteral<
|
|
7
|
+
type TMappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode> = {
|
|
8
|
+
[_ in K]: TIntrinsic<TLiteral<Assert<K, TLiteralValue>>, M>;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode>(T: K, M: M, options: SchemaOptions): MappedIntrinsicProperties<K, M>;
|
|
14
|
-
export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
|
|
15
|
-
export declare function IntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>>(T: K, M: M, options: SchemaOptions): TMappedResult<P>;
|
|
10
|
+
type TMappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedIntrinsicPropertyKeys<R, M, Acc & TMappedIntrinsicPropertyKey<L, M>> : Acc);
|
|
11
|
+
type TMappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode> = (TMappedIntrinsicPropertyKeys<K['keys'], M>);
|
|
12
|
+
export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = TMappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
|
|
13
|
+
export declare function IntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = TMappedIntrinsicProperties<K, M>>(T: K, M: M, options: SchemaOptions): TMappedResult<P>;
|
|
16
14
|
export {};
|
|
@@ -12,11 +12,11 @@ function MappedIntrinsicPropertyKey(K, M, options) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
15
|
+
function MappedIntrinsicPropertyKeys(K, M, options, Acc = {}) {
|
|
16
16
|
const [L, ...R] = K;
|
|
17
17
|
return (K.length > 0
|
|
18
|
-
?
|
|
19
|
-
:
|
|
18
|
+
? MappedIntrinsicPropertyKeys(R, M, options, { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) })
|
|
19
|
+
: Acc);
|
|
20
20
|
}
|
|
21
21
|
// prettier-ignore
|
|
22
22
|
function MappedIntrinsicProperties(T, M, options) {
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import { type TTemplateLiteral, type TTemplateLiteralKind } from '../template-literal/index';
|
|
3
3
|
import { type TIntrinsicFromMappedKey } from './intrinsic-from-mapped-key';
|
|
4
|
-
import { type TLiteral
|
|
4
|
+
import { type TLiteral } from '../literal/index';
|
|
5
5
|
import { type TUnion } from '../union/index';
|
|
6
6
|
import { type TMappedKey } from '../mapped/index';
|
|
7
7
|
export type IntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
declare function
|
|
12
|
-
type
|
|
13
|
-
declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], mode: M): FromRest<T, M>;
|
|
14
|
-
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<FromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<FromLiteralValue<S, M>> : T;
|
|
8
|
+
type TFromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? [TIntrinsic<L, M>, ...TFromTemplateLiteral<R, M>] : T : T;
|
|
9
|
+
type TFromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T);
|
|
10
|
+
type FromRest<T extends TSchema[], M extends IntrinsicMode, Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromRest<R, M, [...Acc, TIntrinsic<L, M>]> : Acc;
|
|
11
|
+
declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], M: M, Acc?: TSchema[]): FromRest<T, M>;
|
|
12
|
+
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<TFromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<TFromLiteralValue<S, M>> : T;
|
|
15
13
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
16
14
|
export declare function Intrinsic<T extends TMappedKey, M extends IntrinsicMode>(schema: T, mode: M, options?: SchemaOptions): TIntrinsicFromMappedKey<T, M>;
|
|
17
15
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
@@ -9,7 +9,6 @@ const index_3 = require("../union/index");
|
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// TypeGuard
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
// prettier-ignore
|
|
13
12
|
const type_1 = require("../guard/type");
|
|
14
13
|
// ------------------------------------------------------------------
|
|
15
14
|
// Apply
|
|
@@ -49,9 +48,12 @@ function FromLiteralValue(value, mode) {
|
|
|
49
48
|
mode === 'Lowercase' ? ApplyLowercase(value) :
|
|
50
49
|
value) : value.toString());
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
// prettier-ignore
|
|
52
|
+
function FromRest(T, M, Acc = []) {
|
|
53
53
|
const [L, ...R] = T;
|
|
54
|
-
return (T.length > 0
|
|
54
|
+
return (T.length > 0
|
|
55
|
+
? FromRest(R, M, [...Acc, Intrinsic(L, M)])
|
|
56
|
+
: Acc);
|
|
55
57
|
}
|
|
56
58
|
/** Applies an intrinsic string manipulation to the given type. */
|
|
57
59
|
function Intrinsic(schema, mode, options = {}) {
|
|
@@ -2,12 +2,10 @@ import type { SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TKeyOf } from './keyof';
|
|
5
|
-
type
|
|
5
|
+
type TFromProperties<K extends TProperties> = ({
|
|
6
6
|
[K2 in keyof K]: TKeyOf<K[K2]>;
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
declare function
|
|
11
|
-
export type TKeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
|
|
12
|
-
export declare function KeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
|
|
8
|
+
type TFromMappedResult<K extends TMappedResult> = (TFromProperties<K['properties']>);
|
|
9
|
+
export type TKeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
|
|
10
|
+
export declare function KeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
|
|
13
11
|
export {};
|
|
@@ -7,24 +7,20 @@ import type { TTuple } from '../tuple/index';
|
|
|
7
7
|
import type { TArray } from '../array/index';
|
|
8
8
|
import type { TObject, TProperties } from '../object/index';
|
|
9
9
|
import { OperatorUnionMany, OperatorIntersectMany } from '../operators/index';
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type FromUnion<T extends TSchema[], C extends PropertyKey[][] = FromRest<T>> = (OperatorIntersectMany<C>);
|
|
10
|
+
type TFromRest<T extends TSchema[], Acc extends PropertyKey[][] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TKeyOfPropertyKeys<L>]> : Acc);
|
|
11
|
+
type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = OperatorUnionMany<C>> = R;
|
|
12
|
+
declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
|
|
13
|
+
type FromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = OperatorIntersectMany<C>> = R;
|
|
15
14
|
declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
type FromArray<_ extends TSchema> = ([
|
|
15
|
+
type TFromTuple<T extends TSchema[], I extends string = ZeroString, Acc extends PropertyKey[] = []> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, Increment<I>, [...Acc, I]> : Acc;
|
|
16
|
+
type TFromArray<_ extends TSchema> = ([
|
|
19
17
|
'[number]'
|
|
20
18
|
]);
|
|
21
|
-
|
|
22
|
-
type
|
|
23
|
-
declare function FromProperties<T extends TProperties>(T: T): FromProperties<T>;
|
|
24
|
-
export type KeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? KeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? FromIntersect<S> : T extends TUnion<infer S> ? FromUnion<S> : T extends TTuple<infer S> ? FromTuple<S> : T extends TArray<infer S> ? FromArray<S> : T extends TObject<infer S> ? FromProperties<S> : [
|
|
19
|
+
type TFromProperties<T extends TProperties> = (UnionToTuple<keyof T>);
|
|
20
|
+
export type TKeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? TKeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? FromIntersect<S> : T extends TUnion<infer S> ? FromUnion<S> : T extends TTuple<infer S> ? TFromTuple<S> : T extends TArray<infer S> ? TFromArray<S> : T extends TObject<infer S> ? TFromProperties<S> : [
|
|
25
21
|
]);
|
|
26
22
|
/** Returns a tuple of PropertyKeys derived from the given TSchema. */
|
|
27
|
-
export declare function KeyOfPropertyKeys<T extends TSchema>(T: T):
|
|
23
|
+
export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): TKeyOfPropertyKeys<T>;
|
|
28
24
|
/** Returns a regular expression pattern derived from the given TSchema */
|
|
29
25
|
export declare function KeyOfPattern(schema: TSchema): string;
|
|
30
26
|
export {};
|
|
@@ -10,27 +10,30 @@ const index_2 = require("../operators/index");
|
|
|
10
10
|
// prettier-ignore
|
|
11
11
|
const type_1 = require("../guard/type");
|
|
12
12
|
// prettier-ignore
|
|
13
|
-
function FromRest(T) {
|
|
13
|
+
function FromRest(T, Acc = []) {
|
|
14
14
|
const [L, ...R] = T;
|
|
15
15
|
return (T.length > 0
|
|
16
|
-
?
|
|
17
|
-
:
|
|
16
|
+
? FromRest(R, [...Acc, KeyOfPropertyKeys(L)])
|
|
17
|
+
: Acc);
|
|
18
18
|
}
|
|
19
19
|
// prettier-ignore
|
|
20
|
-
function FromIntersect(T
|
|
21
|
-
|
|
20
|
+
function FromIntersect(T) {
|
|
21
|
+
const C = FromRest(T);
|
|
22
|
+
const R = (0, index_2.OperatorUnionMany)(C);
|
|
23
|
+
return R;
|
|
22
24
|
}
|
|
23
25
|
// prettier-ignore
|
|
24
26
|
function FromUnion(T) {
|
|
25
27
|
const C = FromRest(T);
|
|
26
|
-
|
|
28
|
+
const R = (0, index_2.OperatorIntersectMany)(C);
|
|
29
|
+
return R;
|
|
27
30
|
}
|
|
28
31
|
// prettier-ignore
|
|
29
|
-
function FromTuple(T, I = '0') {
|
|
32
|
+
function FromTuple(T, I = '0', Acc = []) {
|
|
30
33
|
const [_, ...R] = T;
|
|
31
34
|
return (T.length > 0
|
|
32
|
-
?
|
|
33
|
-
:
|
|
35
|
+
? FromTuple(R, (0, index_1.Increment)(I), [...Acc, I])
|
|
36
|
+
: Acc);
|
|
34
37
|
}
|
|
35
38
|
// prettier-ignore
|
|
36
39
|
function FromArray(_) {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
|
-
import type { Ensure } from '../helpers/index';
|
|
2
|
+
import type { Assert, Ensure } from '../helpers/index';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index';
|
|
4
|
-
import
|
|
4
|
+
import type { SchemaOptions } from '../schema/index';
|
|
5
|
+
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
5
6
|
import { type TNumber } from '../number/index';
|
|
6
|
-
import { type
|
|
7
|
-
import {
|
|
8
|
-
import { UnionEvaluated } from '../union/index';
|
|
7
|
+
import { type TKeyOfPropertyKeys } from './keyof-property-keys';
|
|
8
|
+
import { type TUnionEvaluated } from '../union/index';
|
|
9
9
|
import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result';
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
export type TKeyOf<T extends TSchema> = (Ensure<UnionEvaluated<FromLiterals<KeyOfPropertyKeys<T>>>>);
|
|
10
|
+
type TFromPropertyKeys<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TFromPropertyKeys<R, [...Acc, TNumber]> : TFromPropertyKeys<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
|
|
11
|
+
export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TFromPropertyKeys<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
|
|
13
12
|
/** `[Json]` Creates a KeyOf type */
|
|
14
13
|
export declare function KeyOf<T extends TMappedResult>(T: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
|
|
15
14
|
/** `[Json]` Creates a KeyOf type */
|
|
@@ -14,13 +14,13 @@ const keyof_from_mapped_result_1 = require("./keyof-from-mapped-result");
|
|
|
14
14
|
// prettier-ignore
|
|
15
15
|
const type_2 = require("../guard/type");
|
|
16
16
|
// prettier-ignore
|
|
17
|
-
function
|
|
17
|
+
function FromPropertyKeys(T, Acc = []) {
|
|
18
18
|
const [L, ...R] = T;
|
|
19
19
|
return (T.length > 0
|
|
20
20
|
? L === '[number]'
|
|
21
|
-
? [(0, index_2.Number)()
|
|
22
|
-
: [(0, index_1.Literal)(L)
|
|
23
|
-
:
|
|
21
|
+
? FromPropertyKeys(R, [...Acc, (0, index_2.Number)()])
|
|
22
|
+
: FromPropertyKeys(R, [...Acc, (0, index_1.Literal)(L)])
|
|
23
|
+
: Acc);
|
|
24
24
|
}
|
|
25
25
|
/** `[Json]` Creates a KeyOf type */
|
|
26
26
|
function KeyOf(T, options = {}) {
|
|
@@ -28,8 +28,10 @@ function KeyOf(T, options = {}) {
|
|
|
28
28
|
return (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(T, options);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
const K = (0,
|
|
32
|
-
|
|
31
|
+
const K = (0, keyof_property_keys_1.KeyOfPropertyKeys)(T);
|
|
32
|
+
const S = FromPropertyKeys(K);
|
|
33
|
+
const U = (0, index_3.UnionEvaluated)(S);
|
|
34
|
+
return (0, type_1.CloneType)(U, options);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
exports.KeyOf = KeyOf;
|
|
@@ -16,26 +16,22 @@ import { type TTuple } from '../tuple/index';
|
|
|
16
16
|
import { type TUnion } from '../union/index';
|
|
17
17
|
import { type TMappedResult } from './mapped-result';
|
|
18
18
|
import type { TMappedKey } from './mapped-key';
|
|
19
|
-
type
|
|
20
|
-
|
|
21
|
-
type MappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]> = (P extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
|
|
19
|
+
type TFromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> : TMappedResult<P>);
|
|
20
|
+
type TMappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[], Acc extends TProperties = {}> = (P extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedKeyToMappedResultProperties<K, R, Acc & {
|
|
22
21
|
[_ in L]: TLiteral<Assert<L, TLiteralValue>>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type
|
|
26
|
-
declare function FromMappedKey<K extends PropertyKey, P extends PropertyKey[]>(K: K, P: [...P]): FromMappedResult<K, MappedKeyToMappedResultProperties<K, P>>;
|
|
27
|
-
type FromRest<K extends PropertyKey, T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromSchemaType<K, L>, ...FromRest<K, R>] : [];
|
|
28
|
-
declare function FromRest<K extends PropertyKey, T extends TSchema[]>(K: K, T: [...T]): FromRest<K, T>;
|
|
22
|
+
}> : Acc);
|
|
23
|
+
type TFromMappedKey<K extends PropertyKey, P extends PropertyKey[], R extends TProperties = TMappedKeyToMappedResultProperties<K, P>> = (TFromMappedResult<K, R>);
|
|
24
|
+
type TFromRest<K extends PropertyKey, T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<K, R, [...Acc, FromSchemaType<K, L>]> : Acc);
|
|
29
25
|
type FromProperties<K extends PropertyKey, T extends TProperties, R extends TProperties = Evaluate<{
|
|
30
26
|
[K2 in keyof T]: FromSchemaType<K, T[K2]>;
|
|
31
27
|
}>> = R;
|
|
32
28
|
declare function FromProperties<K extends PropertyKey, T extends TProperties>(K: K, T: T): FromProperties<K, T>;
|
|
33
|
-
type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P> ?
|
|
29
|
+
type FromSchemaType<K extends PropertyKey, T extends TSchema> = (T extends TReadonly<infer S> ? TReadonly<FromSchemaType<K, S>> : T extends TOptional<infer S> ? TOptional<FromSchemaType<K, S>> : T extends TMappedResult<infer P> ? TFromMappedResult<K, P> : T extends TMappedKey<infer P> ? TFromMappedKey<K, P> : T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<K, S>, FromSchemaType<K, R>> : T extends TAsyncIterator<infer S> ? TAsyncIterator<FromSchemaType<K, S>> : T extends TIterator<infer S> ? TIterator<FromSchemaType<K, S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<K, S>> : T extends TUnion<infer S> ? TUnion<TFromRest<K, S>> : T extends TTuple<infer S> ? TTuple<TFromRest<K, S>> : T extends TObject<infer S> ? TObject<FromProperties<K, S>> : T extends TArray<infer S> ? TArray<FromSchemaType<K, S>> : T extends TPromise<infer S> ? TPromise<FromSchemaType<K, S>> : T);
|
|
34
30
|
declare function FromSchemaType<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromSchemaType<K, T>;
|
|
35
|
-
type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
|
|
31
|
+
type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? FromMappedFunctionReturnType<R, T, Acc & {
|
|
36
32
|
[_ in L]: FromSchemaType<L, T>;
|
|
37
|
-
}
|
|
38
|
-
declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T): FromMappedFunctionReturnType<K, T>;
|
|
33
|
+
}> : Acc);
|
|
34
|
+
declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): FromMappedFunctionReturnType<K, T>;
|
|
39
35
|
export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
|
|
40
36
|
export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<FromMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
|
|
41
37
|
/** `[Json]` Creates a Mapped object type */
|
|
@@ -34,11 +34,11 @@ function FromMappedResult(K, P) {
|
|
|
34
34
|
: (0, mapped_result_1.MappedResult)(P));
|
|
35
35
|
}
|
|
36
36
|
// prettier-ignore
|
|
37
|
-
function MappedKeyToMappedResultProperties(K, P) {
|
|
37
|
+
function MappedKeyToMappedResultProperties(K, P, Acc = {}) {
|
|
38
38
|
const [L, ...R] = P;
|
|
39
39
|
return (P.length > 0
|
|
40
|
-
? { [L]: (0, index_10.Literal)(L)
|
|
41
|
-
:
|
|
40
|
+
? MappedKeyToMappedResultProperties(K, R, { ...Acc, [L]: (0, index_10.Literal)(L) })
|
|
41
|
+
: Acc);
|
|
42
42
|
}
|
|
43
43
|
// prettier-ignore
|
|
44
44
|
function FromMappedKey(K, P) {
|
|
@@ -46,11 +46,11 @@ function FromMappedKey(K, P) {
|
|
|
46
46
|
return FromMappedResult(K, R);
|
|
47
47
|
}
|
|
48
48
|
// prettier-ignore
|
|
49
|
-
function FromRest(K, T) {
|
|
49
|
+
function FromRest(K, T, Acc = []) {
|
|
50
50
|
const [L, ...R] = T;
|
|
51
51
|
return (T.length > 0
|
|
52
|
-
?
|
|
53
|
-
:
|
|
52
|
+
? FromRest(K, R, [...Acc, FromSchemaType(K, L)])
|
|
53
|
+
: Acc);
|
|
54
54
|
}
|
|
55
55
|
// prettier-ignore
|
|
56
56
|
function FromProperties(K, T) {
|
|
@@ -81,11 +81,11 @@ function FromSchemaType(K, T) {
|
|
|
81
81
|
T);
|
|
82
82
|
}
|
|
83
83
|
// prettier-ignore
|
|
84
|
-
function FromMappedFunctionReturnType(K, T) {
|
|
84
|
+
function FromMappedFunctionReturnType(K, T, Acc = {}) {
|
|
85
85
|
const [L, ...R] = K;
|
|
86
86
|
return (K.length > 0
|
|
87
|
-
? { [L]: FromSchemaType(L, T)
|
|
88
|
-
:
|
|
87
|
+
? FromMappedFunctionReturnType(R, T, { ...Acc, [L]: FromSchemaType(L, T) })
|
|
88
|
+
: Acc);
|
|
89
89
|
}
|
|
90
90
|
/** `[Json]` Creates a Mapped object type */
|
|
91
91
|
function Mapped(key, map, options = {}) {
|
|
@@ -2,14 +2,11 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
4
4
|
import { type TOmit } from './omit';
|
|
5
|
-
type
|
|
5
|
+
type TFromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
6
6
|
[_ in K]: TOmit<T, [K]>;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
declare function FromMappedKey<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): FromMappedKey<T, K>;
|
|
13
|
-
export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
|
|
14
|
-
export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
|
|
8
|
+
type TFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? TFromPropertyKeys<T, RK, Acc & TFromPropertyKey<T, LK>> : Acc);
|
|
9
|
+
type TFromMappedKey<T extends TSchema, K extends TMappedKey> = (TFromPropertyKeys<T, K['keys']>);
|
|
10
|
+
export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>> = (TMappedResult<P>);
|
|
11
|
+
export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
|
|
15
12
|
export {};
|