@sinclair/typebox 0.32.0-dev-13 → 0.32.0-dev-15
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 +10 -10
- package/build/import/index.mjs +3 -3
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +13 -0
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +14 -0
- package/build/import/type/exclude/exclude.d.mts +4 -1
- package/build/import/type/exclude/exclude.mjs +10 -4
- package/build/import/type/exclude/index.d.mts +1 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extends/extends-from-mapped-key.d.mts +17 -0
- package/build/import/type/extends/extends-from-mapped-key.mjs +21 -0
- package/build/import/type/extends/extends-from-mapped-result.d.mts +13 -0
- package/build/import/type/extends/extends-from-mapped-result.mjs +14 -0
- package/build/import/type/extends/extends.d.mts +4 -4
- package/build/import/type/extends/extends.mjs +4 -4
- package/build/import/type/extends/index.d.mts +2 -2
- package/build/import/type/extends/index.mjs +2 -2
- package/build/import/type/extract/extract-from-mapped-result.d.mts +13 -0
- package/build/import/type/extract/extract-from-mapped-result.mjs +14 -0
- package/build/import/type/extract/extract.d.mts +3 -0
- package/build/import/type/extract/extract.mjs +9 -3
- package/build/import/type/extract/index.d.mts +1 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/guard/type.d.mts +47 -46
- package/build/import/type/guard/type.mjs +294 -293
- package/build/import/type/indexed/index.d.mts +1 -1
- package/build/import/type/indexed/index.mjs +1 -1
- package/build/import/type/indexed/{indexed-mapped-result.d.mts → indexed-from-mapped-key.d.mts} +6 -6
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +18 -0
- package/build/import/type/indexed/indexed-result.d.mts +2 -2
- package/build/import/type/indexed/indexed-result.mjs +3 -2
- package/build/import/type/indexed/indexed.d.mts +2 -2
- package/build/import/type/indexed/indexed.mjs +4 -4
- package/build/import/type/intrinsic/capitalize.mjs +1 -2
- package/build/import/type/intrinsic/index.d.mts +1 -1
- package/build/import/type/intrinsic/index.mjs +1 -1
- package/build/import/type/intrinsic/{intrinsic-mapped-result.d.mts → intrinsic-from-mapped-key.d.mts} +6 -5
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +21 -0
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -6
- package/build/import/type/intrinsic/intrinsic.mjs +8 -8
- package/build/import/type/intrinsic/lowercase.mjs +1 -2
- package/build/import/type/intrinsic/uncapitalize.mjs +1 -2
- package/build/import/type/intrinsic/uppercase.mjs +1 -2
- package/build/import/type/keyof/index.d.mts +1 -0
- package/build/import/type/keyof/index.mjs +1 -0
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +13 -0
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +14 -0
- package/build/import/type/keyof/keyof.d.mts +3 -0
- package/build/import/type/keyof/keyof.mjs +9 -2
- package/build/import/type/mapped/mapped.d.mts +9 -6
- package/build/import/type/mapped/mapped.mjs +11 -4
- package/build/import/type/omit/index.d.mts +1 -1
- package/build/import/type/omit/index.mjs +1 -1
- package/build/import/type/omit/omit-from-mapped-key.d.mts +15 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +20 -0
- package/build/import/type/omit/omit.d.mts +2 -2
- package/build/import/type/omit/omit.mjs +2 -2
- package/build/import/type/partial/index.d.mts +1 -0
- package/build/import/type/partial/index.mjs +1 -0
- package/build/import/type/partial/partial-from-mapped-result.d.mts +13 -0
- package/build/import/type/partial/partial-from-mapped-result.mjs +14 -0
- package/build/import/type/partial/partial.d.mts +5 -2
- package/build/import/type/partial/partial.mjs +11 -5
- package/build/import/type/pick/index.d.mts +1 -1
- package/build/import/type/pick/index.mjs +1 -1
- package/build/import/type/pick/pick-from-mapped-key.d.mts +15 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +20 -0
- package/build/import/type/pick/pick.d.mts +2 -2
- package/build/import/type/pick/pick.mjs +2 -2
- package/build/import/type/required/index.d.mts +1 -0
- package/build/import/type/required/index.mjs +1 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +13 -0
- package/build/import/type/required/required-from-mapped-result.mjs +14 -0
- package/build/import/type/required/required.d.mts +5 -2
- package/build/import/type/required/required.mjs +11 -5
- package/build/import/type/type/json.d.mts +21 -16
- package/build/import/type/type/json.mjs +3 -3
- package/build/require/index.d.ts +10 -10
- package/build/require/index.js +5 -3
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +13 -0
- package/build/require/type/exclude/exclude-from-mapped-result.js +18 -0
- package/build/require/type/exclude/exclude.d.ts +4 -1
- package/build/require/type/exclude/exclude.js +9 -4
- package/build/require/type/exclude/index.d.ts +1 -0
- package/build/require/type/exclude/index.js +1 -0
- package/build/require/type/extends/extends-from-mapped-key.d.ts +17 -0
- package/build/require/type/extends/extends-from-mapped-key.js +25 -0
- package/build/require/type/extends/extends-from-mapped-result.d.ts +13 -0
- package/build/require/type/extends/extends-from-mapped-result.js +18 -0
- package/build/require/type/extends/extends.d.ts +4 -4
- package/build/require/type/extends/extends.js +4 -4
- package/build/require/type/extends/index.d.ts +2 -2
- package/build/require/type/extends/index.js +2 -2
- package/build/require/type/extract/extract-from-mapped-result.d.ts +13 -0
- package/build/require/type/extract/extract-from-mapped-result.js +18 -0
- package/build/require/type/extract/extract.d.ts +3 -0
- package/build/require/type/extract/extract.js +8 -2
- package/build/require/type/extract/index.d.ts +1 -0
- package/build/require/type/extract/index.js +1 -0
- package/build/require/type/guard/type.d.ts +47 -46
- package/build/require/type/guard/type.js +252 -250
- package/build/require/type/indexed/index.d.ts +1 -1
- package/build/require/type/indexed/index.js +1 -1
- package/build/require/type/indexed/{indexed-mapped-result.d.ts → indexed-from-mapped-key.d.ts} +6 -6
- package/build/require/type/indexed/indexed-from-mapped-key.js +22 -0
- package/build/require/type/indexed/indexed-result.d.ts +2 -2
- package/build/require/type/indexed/indexed-result.js +11 -10
- package/build/require/type/indexed/indexed.d.ts +2 -2
- package/build/require/type/indexed/indexed.js +4 -4
- package/build/require/type/intrinsic/capitalize.js +1 -2
- package/build/require/type/intrinsic/index.d.ts +1 -1
- package/build/require/type/intrinsic/index.js +1 -1
- package/build/require/type/intrinsic/{intrinsic-mapped-result.d.ts → intrinsic-from-mapped-key.d.ts} +6 -5
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +25 -0
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -6
- package/build/require/type/intrinsic/intrinsic.js +8 -8
- package/build/require/type/intrinsic/lowercase.js +1 -2
- package/build/require/type/intrinsic/uncapitalize.js +1 -2
- package/build/require/type/intrinsic/uppercase.js +1 -2
- package/build/require/type/keyof/index.d.ts +1 -0
- package/build/require/type/keyof/index.js +1 -0
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +13 -0
- package/build/require/type/keyof/keyof-from-mapped-result.js +18 -0
- package/build/require/type/keyof/keyof.d.ts +3 -0
- package/build/require/type/keyof/keyof.js +9 -2
- package/build/require/type/mapped/mapped.d.ts +9 -6
- package/build/require/type/mapped/mapped.js +24 -17
- package/build/require/type/omit/index.d.ts +1 -1
- package/build/require/type/omit/index.js +1 -1
- package/build/require/type/omit/omit-from-mapped-key.d.ts +15 -0
- package/build/require/type/omit/omit-from-mapped-key.js +24 -0
- package/build/require/type/omit/omit.d.ts +2 -2
- package/build/require/type/omit/omit.js +2 -2
- package/build/require/type/partial/index.d.ts +1 -0
- package/build/require/type/partial/index.js +1 -0
- package/build/require/type/partial/partial-from-mapped-result.d.ts +13 -0
- package/build/require/type/partial/partial-from-mapped-result.js +18 -0
- package/build/require/type/partial/partial.d.ts +5 -2
- package/build/require/type/partial/partial.js +10 -5
- package/build/require/type/pick/index.d.ts +1 -1
- package/build/require/type/pick/index.js +1 -1
- package/build/require/type/pick/pick-from-mapped-key.d.ts +15 -0
- package/build/require/type/pick/pick-from-mapped-key.js +24 -0
- package/build/require/type/pick/pick.d.ts +2 -2
- package/build/require/type/pick/pick.js +2 -2
- package/build/require/type/required/index.d.ts +1 -0
- package/build/require/type/required/index.js +1 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +13 -0
- package/build/require/type/required/required-from-mapped-result.js +18 -0
- package/build/require/type/required/required.d.ts +5 -2
- package/build/require/type/required/required.js +10 -5
- package/build/require/type/type/json.d.ts +21 -16
- package/build/require/type/type/json.js +3 -3
- package/package.json +1 -1
- package/readme.md +79 -91
- package/build/import/type/extends/extends-mapped-result-from-result.d.mts +0 -13
- package/build/import/type/extends/extends-mapped-result-from-result.mjs +0 -14
- package/build/import/type/extends/extends-mapped-result.d.mts +0 -17
- package/build/import/type/extends/extends-mapped-result.mjs +0 -21
- package/build/import/type/indexed/indexed-mapped-result.mjs +0 -18
- package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +0 -21
- package/build/import/type/omit/omit-mapped-result.d.mts +0 -15
- package/build/import/type/omit/omit-mapped-result.mjs +0 -20
- package/build/import/type/pick/pick-mapped-result.d.mts +0 -15
- package/build/import/type/pick/pick-mapped-result.mjs +0 -20
- package/build/require/type/extends/extends-mapped-result-from-result.d.ts +0 -13
- package/build/require/type/extends/extends-mapped-result-from-result.js +0 -18
- package/build/require/type/extends/extends-mapped-result.d.ts +0 -17
- package/build/require/type/extends/extends-mapped-result.js +0 -25
- package/build/require/type/indexed/indexed-mapped-result.js +0 -22
- package/build/require/type/intrinsic/intrinsic-mapped-result.js +0 -25
- package/build/require/type/omit/omit-mapped-result.d.ts +0 -15
- package/build/require/type/omit/omit-mapped-result.js +0 -24
- package/build/require/type/pick/pick-mapped-result.d.ts +0 -15
- package/build/require/type/pick/pick-mapped-result.js +0 -24
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
|
+
import type { TProperties } from '../object/index.mjs';
|
|
3
|
+
import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
|
|
4
|
+
import { type TPick } from './pick.mjs';
|
|
5
|
+
type FromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
6
|
+
[_ in K]: TPick<T, [K]>;
|
|
7
|
+
};
|
|
8
|
+
declare function FromPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K, options: SchemaOptions): FromPropertyKey<T, K>;
|
|
9
|
+
type FromPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? FromPropertyKey<T, LK> & FromPropertyKeys<T, RK> : {});
|
|
10
|
+
declare function FromPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): FromPropertyKeys<T, K>;
|
|
11
|
+
type FromMappedKey<T extends TSchema, K extends TMappedKey> = (FromPropertyKeys<T, K['keys']>);
|
|
12
|
+
declare function FromMappedKey<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): FromMappedKey<T, K>;
|
|
13
|
+
export type TPickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
|
|
14
|
+
export declare function PickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MappedResult } from '../mapped/index.mjs';
|
|
2
|
+
import { Pick } from './pick.mjs';
|
|
3
|
+
function FromPropertyKey(T, K, options) {
|
|
4
|
+
return {
|
|
5
|
+
[K]: Pick(T, [K], options)
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function FromPropertyKeys(T, K, options) {
|
|
9
|
+
const [LK, ...RK] = K;
|
|
10
|
+
return (K.length > 0
|
|
11
|
+
? { ...FromPropertyKey(T, LK, options), ...FromPropertyKeys(T, RK, options) }
|
|
12
|
+
: {});
|
|
13
|
+
}
|
|
14
|
+
function FromMappedKey(T, K, options) {
|
|
15
|
+
return FromPropertyKeys(T, K.keys, options);
|
|
16
|
+
}
|
|
17
|
+
export function PickFromMappedKey(T, K, options) {
|
|
18
|
+
const P = FromMappedKey(T, K, options);
|
|
19
|
+
return MappedResult(P);
|
|
20
|
+
}
|
|
@@ -6,7 +6,7 @@ import { type TUnion } from '../union/index.mjs';
|
|
|
6
6
|
import { type TObject, type TProperties } from '../object/index.mjs';
|
|
7
7
|
import { type TIndexPropertyKeys } from '../indexed/index.mjs';
|
|
8
8
|
import { TMappedKey } from '../mapped/index.mjs';
|
|
9
|
-
import { type
|
|
9
|
+
import { type TPickFromMappedKey } from './pick-from-mapped-key.mjs';
|
|
10
10
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<L, K>, ...FromIntersect<R, K>] : [];
|
|
11
11
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
|
|
12
12
|
type FromUnion<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<L, K>, ...FromUnion<R, K>] : [];
|
|
@@ -16,7 +16,7 @@ declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(
|
|
|
16
16
|
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<{}>;
|
|
17
17
|
export declare function PickResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): PickResolve<T, K>;
|
|
18
18
|
export type TPick<T extends TSchema, K extends PropertyKey[]> = PickResolve<T, K>;
|
|
19
|
-
export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
19
|
+
export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
|
|
20
20
|
export declare function Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
21
21
|
export declare function Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
22
22
|
export {};
|
|
@@ -5,7 +5,7 @@ import { IndexPropertyKeys } from '../indexed/index.mjs';
|
|
|
5
5
|
import { Discard } from '../discard/index.mjs';
|
|
6
6
|
import { TransformKind } from '../symbols/index.mjs';
|
|
7
7
|
import { CloneType } from '../clone/type.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { PickFromMappedKey } from './pick-from-mapped-key.mjs';
|
|
9
9
|
import { TMappedKey as IsMappedKeyType, TIntersect as IsIntersectType, TUnion as IsUnionType, TObject as IsObjectType, TSchema as IsSchemaType, } from '../guard/type.mjs';
|
|
10
10
|
function FromIntersect(T, K) {
|
|
11
11
|
return T.map((T) => PickResolve(T, K));
|
|
@@ -26,7 +26,7 @@ export function PickResolve(T, K) {
|
|
|
26
26
|
}
|
|
27
27
|
export function Pick(T, K, options = {}) {
|
|
28
28
|
if (IsMappedKeyType(K)) {
|
|
29
|
-
return
|
|
29
|
+
return PickFromMappedKey(T, K, options);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
const I = IsSchemaType(K) ? IndexPropertyKeys(K) : K;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SchemaOptions } from '../schema/index.mjs';
|
|
2
|
+
import type { TProperties } from '../object/index.mjs';
|
|
3
|
+
import { type TMappedResult } from '../mapped/index.mjs';
|
|
4
|
+
import { type TRequired } from './required.mjs';
|
|
5
|
+
type FromProperties<K extends TProperties> = ({
|
|
6
|
+
[K2 in keyof K]: TRequired<K[K2]>;
|
|
7
|
+
});
|
|
8
|
+
declare function FromProperties<K extends TProperties>(K: K, options: SchemaOptions): FromProperties<K>;
|
|
9
|
+
type FromMappedResult<K extends TMappedResult> = (FromProperties<K['properties']>);
|
|
10
|
+
declare function FromMappedResult<K extends TMappedResult>(K: K, options: SchemaOptions): FromMappedResult<K>;
|
|
11
|
+
export type TRequiredFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
|
|
12
|
+
export declare function RequiredFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MappedResult } from '../mapped/index.mjs';
|
|
2
|
+
import { Required } from './required.mjs';
|
|
3
|
+
function FromProperties(K, options) {
|
|
4
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
5
|
+
return { ...Acc, [K2]: Required(K[K2], options) };
|
|
6
|
+
}, {});
|
|
7
|
+
}
|
|
8
|
+
function FromMappedResult(K, options) {
|
|
9
|
+
return FromProperties(K.properties, options);
|
|
10
|
+
}
|
|
11
|
+
export function RequiredFromMappedResult(T, options) {
|
|
12
|
+
const P = FromMappedResult(T, options);
|
|
13
|
+
return MappedResult(P);
|
|
14
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
2
|
import type { Evaluate } from '../helpers/index.mjs';
|
|
3
|
+
import type { TMappedResult } from '../mapped/index.mjs';
|
|
3
4
|
import { type TReadonlyOptional } from '../readonly-optional/index.mjs';
|
|
4
5
|
import { type TOptional } from '../optional/index.mjs';
|
|
5
6
|
import { type TReadonly } from '../readonly/index.mjs';
|
|
@@ -7,6 +8,7 @@ import { type TRecursive } from '../recursive/index.mjs';
|
|
|
7
8
|
import { type TIntersect } from '../intersect/index.mjs';
|
|
8
9
|
import { type TUnion } from '../union/index.mjs';
|
|
9
10
|
import { type TObject, type TProperties } from '../object/index.mjs';
|
|
11
|
+
import { type TRequiredFromMappedResult } from './required-from-mapped-result.mjs';
|
|
10
12
|
type FromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromIntersect<R>] : []);
|
|
11
13
|
declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
|
|
12
14
|
type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromUnion<R>] : []);
|
|
@@ -15,8 +17,9 @@ type FromProperties<T extends TProperties> = Evaluate<{
|
|
|
15
17
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
16
18
|
}>;
|
|
17
19
|
declare function FromProperties<T extends TProperties>(T: T): TProperties;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
type RequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<RequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S>> : T extends TUnion<infer S> ? TUnion<FromUnion<S>> : T extends TObject<infer S> ? TObject<FromProperties<S>> : TObject<{}>);
|
|
21
|
+
declare function RequiredResolve<T extends TSchema>(T: T): RequiredResolve<T>;
|
|
20
22
|
export type TRequired<T extends TSchema> = RequiredResolve<T>;
|
|
23
|
+
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
21
24
|
export declare function Required<T extends TSchema>(T: T, options?: SchemaOptions): TRequired<T>;
|
|
22
25
|
export {};
|
|
@@ -4,7 +4,8 @@ import { Object } from '../object/index.mjs';
|
|
|
4
4
|
import { OptionalKind, TransformKind } from '../symbols/index.mjs';
|
|
5
5
|
import { CloneType } from '../clone/type.mjs';
|
|
6
6
|
import { Discard } from '../discard/index.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { RequiredFromMappedResult } from './required-from-mapped-result.mjs';
|
|
8
|
+
import { TMappedResult as IsMappedResultType, TIntersect as IsIntersectType, TUnion as IsUnionType, TObject as IsObjectType } from '../guard/type.mjs';
|
|
8
9
|
function FromIntersect(T) {
|
|
9
10
|
const [L, ...R] = T;
|
|
10
11
|
return (T.length > 0
|
|
@@ -22,14 +23,19 @@ function FromProperties(T) {
|
|
|
22
23
|
return { ...Acc, [K]: Discard(T[K], [OptionalKind]) };
|
|
23
24
|
}, {});
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
function RequiredResolve(T) {
|
|
26
27
|
return (IsIntersectType(T) ? Intersect(FromIntersect(T.allOf)) :
|
|
27
28
|
IsUnionType(T) ? Union(FromUnion(T.anyOf)) :
|
|
28
29
|
IsObjectType(T) ? Object(FromProperties(T.properties)) :
|
|
29
30
|
Object({}));
|
|
30
31
|
}
|
|
31
32
|
export function Required(T, options = {}) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (IsMappedResultType(T)) {
|
|
34
|
+
return RequiredFromMappedResult(T, options);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const D = Discard(T, [TransformKind, '$id', 'required']);
|
|
38
|
+
const R = CloneType(RequiredResolve(T), options);
|
|
39
|
+
return { ...D, ...R };
|
|
40
|
+
}
|
|
35
41
|
}
|
|
@@ -5,14 +5,14 @@ import { type TComposite } from '../composite/index.mjs';
|
|
|
5
5
|
import { type TConst } from '../const/index.mjs';
|
|
6
6
|
import { type TDeref } from '../deref/index.mjs';
|
|
7
7
|
import { type TEnum, type TEnumKey, type TEnumValue } from '../enum/index.mjs';
|
|
8
|
-
import { type TExclude } from '../exclude/index.mjs';
|
|
9
|
-
import { type TExtends, type
|
|
10
|
-
import { type TExtract } from '../extract/index.mjs';
|
|
11
|
-
import { TIndex, type TIndexPropertyKeys, type
|
|
8
|
+
import { type TExclude, type TExcludeFromMappedResult } from '../exclude/index.mjs';
|
|
9
|
+
import { type TExtends, type TExtendsFromMappedKey, type TExtendsFromMappedResult } from '../extends/index.mjs';
|
|
10
|
+
import { type TExtract, type TExtractFromMappedResult } from '../extract/index.mjs';
|
|
11
|
+
import { TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from '../indexed/index.mjs';
|
|
12
12
|
import { type IntegerOptions, type TInteger } from '../integer/index.mjs';
|
|
13
13
|
import { type IntersectOptions, type IntersectResolve } from '../intersect/index.mjs';
|
|
14
14
|
import { type TCapitalize, type TUncapitalize, type TLowercase, type TUppercase } from '../intrinsic/index.mjs';
|
|
15
|
-
import { type TKeyOf } from '../keyof/index.mjs';
|
|
15
|
+
import { type TKeyOf, type TKeyOfFromMappedResult } from '../keyof/index.mjs';
|
|
16
16
|
import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
|
|
17
17
|
import { type TMappedFunction, type TMapped, type TMappedResult } from '../mapped/index.mjs';
|
|
18
18
|
import { type TNever } from '../never/index.mjs';
|
|
@@ -21,16 +21,16 @@ import { type TNull } from '../null/index.mjs';
|
|
|
21
21
|
import { type TMappedKey } from '../mapped/index.mjs';
|
|
22
22
|
import { type TNumber, type NumberOptions } from '../number/index.mjs';
|
|
23
23
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index.mjs';
|
|
24
|
-
import { type TOmit, type
|
|
24
|
+
import { type TOmit, type TOmitFromMappedKey } from '../omit/index.mjs';
|
|
25
25
|
import { type TOptional } from '../optional/index.mjs';
|
|
26
|
-
import { type TPartial } from '../partial/index.mjs';
|
|
27
|
-
import { type TPick, type
|
|
26
|
+
import { type TPartial, type TPartialFromMappedResult } from '../partial/index.mjs';
|
|
27
|
+
import { type TPick, type TPickFromMappedKey } from '../pick/index.mjs';
|
|
28
28
|
import { type TReadonly } from '../readonly/index.mjs';
|
|
29
29
|
import { type TReadonlyOptional } from '../readonly-optional/index.mjs';
|
|
30
30
|
import { type RecordResolve } from '../record/index.mjs';
|
|
31
31
|
import { type TRecursive, type TThis } from '../recursive/index.mjs';
|
|
32
32
|
import { type TRef } from '../ref/index.mjs';
|
|
33
|
-
import { type TRequired } from '../required/index.mjs';
|
|
33
|
+
import { type TRequired, type TRequiredFromMappedResult } from '../required/index.mjs';
|
|
34
34
|
import { type TRest } from '../rest/index.mjs';
|
|
35
35
|
import { type TSchema, type SchemaOptions } from '../schema/index.mjs';
|
|
36
36
|
import { type TString, type StringOptions } from '../string/index.mjs';
|
|
@@ -53,16 +53,19 @@ export declare class JsonTypeBuilder {
|
|
|
53
53
|
Const<T>(value: T, options?: SchemaOptions): TConst<T>;
|
|
54
54
|
Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
|
|
55
55
|
Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>;
|
|
56
|
-
|
|
57
|
-
Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsMappedResult<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>;
|
|
56
|
+
Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
59
57
|
Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
58
|
+
Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
59
|
+
Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedKey<L, R, T, F>;
|
|
60
|
+
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>;
|
|
61
|
+
Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
|
|
60
62
|
Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
|
|
61
|
-
Index<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
63
|
+
Index<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedKey<T, K>;
|
|
62
64
|
Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
|
|
63
65
|
Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
64
66
|
Integer(options?: IntegerOptions): TInteger;
|
|
65
67
|
Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): IntersectResolve<T>;
|
|
68
|
+
KeyOf<T extends TMappedResult>(schema: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
|
|
66
69
|
KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>;
|
|
67
70
|
Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>;
|
|
68
71
|
Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TLowercase<T>;
|
|
@@ -73,18 +76,20 @@ export declare class JsonTypeBuilder {
|
|
|
73
76
|
Null(options?: SchemaOptions): TNull;
|
|
74
77
|
Number(options?: NumberOptions): TNumber;
|
|
75
78
|
Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
|
|
76
|
-
Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
79
|
+
Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
|
|
77
80
|
Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
78
81
|
Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
|
|
82
|
+
Partial<T extends TMappedResult>(T: T, options?: ObjectOptions): TPartialFromMappedResult<T>;
|
|
79
83
|
Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
|
|
80
|
-
Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
84
|
+
Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
|
|
81
85
|
Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
82
86
|
Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
83
87
|
Record<K extends TSchema, T extends TSchema>(key: K, schema: T, options?: ObjectOptions): RecordResolve<K, T>;
|
|
84
88
|
Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
|
|
85
89
|
Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>;
|
|
86
90
|
Ref<T extends TSchema>($ref: string, options?: SchemaOptions): TRef<T>;
|
|
87
|
-
Required<T extends
|
|
91
|
+
Required<T extends TMappedResult>(T: T, options?: ObjectOptions): TRequiredFromMappedResult<T>;
|
|
92
|
+
Required<T extends TSchema>(schema: T, options?: ObjectOptions): TRequired<T>;
|
|
88
93
|
Rest<T extends TSchema>(schema: T): TRest<T>;
|
|
89
94
|
String(options?: StringOptions): TString;
|
|
90
95
|
TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TemplateLiteralSyntax<T>;
|
|
@@ -76,12 +76,12 @@ export class JsonTypeBuilder {
|
|
|
76
76
|
Enum(item, options = {}) {
|
|
77
77
|
return Enum(item, options);
|
|
78
78
|
}
|
|
79
|
-
Extends(L, R, T, F, options = {}) {
|
|
80
|
-
return Extends(L, R, T, F, options);
|
|
81
|
-
}
|
|
82
79
|
Exclude(unionType, excludedMembers, options = {}) {
|
|
83
80
|
return Exclude(unionType, excludedMembers, options);
|
|
84
81
|
}
|
|
82
|
+
Extends(L, R, T, F, options = {}) {
|
|
83
|
+
return Extends(L, R, T, F, options);
|
|
84
|
+
}
|
|
85
85
|
Extract(type, union, options = {}) {
|
|
86
86
|
return Extract(type, union, options);
|
|
87
87
|
}
|
package/build/require/index.d.ts
CHANGED
|
@@ -16,18 +16,18 @@ export { ConstructorParameters, type TConstructorParameters } from './type/const
|
|
|
16
16
|
export { Date, type TDate, type DateOptions } from './type/date/index';
|
|
17
17
|
export { Deref, type TDeref } from './type/deref/index';
|
|
18
18
|
export { Enum, type TEnum } from './type/enum/index';
|
|
19
|
-
export { Exclude, type TExclude } from './type/exclude/index';
|
|
20
|
-
export { Extends, type TExtends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './type/extends/index';
|
|
21
|
-
export { Extract, type TExtract } from './type/extract/index';
|
|
19
|
+
export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/exclude/index';
|
|
20
|
+
export { Extends, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './type/extends/index';
|
|
21
|
+
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index';
|
|
22
22
|
export { Function, type TFunction } from './type/function/index';
|
|
23
23
|
export { Increment, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index';
|
|
24
|
-
export { Index, IndexPropertyKeys,
|
|
24
|
+
export { Index, IndexPropertyKeys, IndexFromMappedKey, type TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from './type/indexed/index';
|
|
25
25
|
export { InstanceType, type TInstanceType } from './type/instance-type/index';
|
|
26
26
|
export { Integer, type TInteger, type IntegerOptions } from './type/integer/index';
|
|
27
27
|
export { Intersect, type TIntersect, type IntersectOptions } from './type/intersect/index';
|
|
28
28
|
export { Iterator, type TIterator } from './type/iterator/index';
|
|
29
|
-
export { Intrinsic, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index';
|
|
30
|
-
export { KeyOf, type TKeyOf, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index';
|
|
29
|
+
export { Intrinsic, IntrinsicFromMappedKey, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index';
|
|
30
|
+
export { KeyOf, type TKeyOf, type KeyOfFromMappedResult, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index';
|
|
31
31
|
export { Literal, type TLiteral } from './type/literal/index';
|
|
32
32
|
export { Mapped, MappedKey, MappedResult, type TMapped, type TMappedKey, type TMappedResult, type TMappedFunction } from './type/mapped/index';
|
|
33
33
|
export { Never, type TNever } from './type/never/index';
|
|
@@ -35,11 +35,11 @@ export { Not, type TNot } from './type/not/index';
|
|
|
35
35
|
export { Null, type TNull } from './type/null/index';
|
|
36
36
|
export { Number, type TNumber, type NumberOptions } from './type/number/index';
|
|
37
37
|
export { Object, type TObject, type TProperties, type ObjectOptions } from './type/object/index';
|
|
38
|
-
export { Omit, type TOmit, type
|
|
38
|
+
export { Omit, type TOmit, type TOmitFromMappedKey } from './type/omit/index';
|
|
39
39
|
export { Optional, type TOptional } from './type/optional/index';
|
|
40
40
|
export { Parameters, type TParameters } from './type/parameters/index';
|
|
41
|
-
export { Partial, type TPartial } from './type/partial/index';
|
|
42
|
-
export { Pick, type TPick, type
|
|
41
|
+
export { Partial, PartialFromMappedResult, type TPartial, type TPartialFromMappedResult } from './type/partial/index';
|
|
42
|
+
export { Pick, type TPick, type TPickFromMappedKey } from './type/pick/index';
|
|
43
43
|
export { Promise, type TPromise } from './type/promise/index';
|
|
44
44
|
export { Readonly, type TReadonly } from './type/readonly/index';
|
|
45
45
|
export { ReadonlyOptional, type TReadonlyOptional } from './type/readonly-optional/index';
|
|
@@ -47,7 +47,7 @@ export { Record, type TRecord } from './type/record/index';
|
|
|
47
47
|
export { Recursive, type TRecursive, type TThis } from './type/recursive/index';
|
|
48
48
|
export { Ref, type TRef } from './type/ref/index';
|
|
49
49
|
export { RegExp, type TRegExp } from './type/regexp/index';
|
|
50
|
-
export { Required, type TRequired } from './type/required/index';
|
|
50
|
+
export { Required, type TRequired, type TRequiredFromMappedResult } from './type/required/index';
|
|
51
51
|
export { Rest, type TRest } from './type/rest/index';
|
|
52
52
|
export { ReturnType, type TReturnType } from './type/return-type/index';
|
|
53
53
|
export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from './type/schema/index';
|
package/build/require/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.TemplateLiteralGenerate = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.IsTemplateLiteralFinite = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.Readonly = exports.Promise = exports.Pick = exports.Partial = exports.Parameters = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfPropertyKeys = exports.KeyOf = void 0;
|
|
3
|
+
exports.Uncapitalize = exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedKey = exports.IndexPropertyKeys = exports.Index = exports.Increment = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
|
|
4
|
+
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.TemplateLiteralGenerate = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.IsTemplateLiteralFinite = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = void 0;
|
|
5
5
|
var index_1 = require("./type/symbols/index");
|
|
6
6
|
Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return index_1.Kind; } });
|
|
7
7
|
Object.defineProperty(exports, "Hint", { enumerable: true, get: function () { return index_1.Hint; } });
|
|
@@ -66,7 +66,7 @@ Object.defineProperty(exports, "Increment", { enumerable: true, get: function ()
|
|
|
66
66
|
var index_23 = require("./type/indexed/index");
|
|
67
67
|
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return index_23.Index; } });
|
|
68
68
|
Object.defineProperty(exports, "IndexPropertyKeys", { enumerable: true, get: function () { return index_23.IndexPropertyKeys; } });
|
|
69
|
-
Object.defineProperty(exports, "
|
|
69
|
+
Object.defineProperty(exports, "IndexFromMappedKey", { enumerable: true, get: function () { return index_23.IndexFromMappedKey; } });
|
|
70
70
|
var index_24 = require("./type/instance-type/index");
|
|
71
71
|
Object.defineProperty(exports, "InstanceType", { enumerable: true, get: function () { return index_24.InstanceType; } });
|
|
72
72
|
var index_25 = require("./type/integer/index");
|
|
@@ -77,6 +77,7 @@ var index_27 = require("./type/iterator/index");
|
|
|
77
77
|
Object.defineProperty(exports, "Iterator", { enumerable: true, get: function () { return index_27.Iterator; } });
|
|
78
78
|
var index_28 = require("./type/intrinsic/index");
|
|
79
79
|
Object.defineProperty(exports, "Intrinsic", { enumerable: true, get: function () { return index_28.Intrinsic; } });
|
|
80
|
+
Object.defineProperty(exports, "IntrinsicFromMappedKey", { enumerable: true, get: function () { return index_28.IntrinsicFromMappedKey; } });
|
|
80
81
|
Object.defineProperty(exports, "Capitalize", { enumerable: true, get: function () { return index_28.Capitalize; } });
|
|
81
82
|
Object.defineProperty(exports, "Lowercase", { enumerable: true, get: function () { return index_28.Lowercase; } });
|
|
82
83
|
Object.defineProperty(exports, "Uncapitalize", { enumerable: true, get: function () { return index_28.Uncapitalize; } });
|
|
@@ -109,6 +110,7 @@ var index_39 = require("./type/parameters/index");
|
|
|
109
110
|
Object.defineProperty(exports, "Parameters", { enumerable: true, get: function () { return index_39.Parameters; } });
|
|
110
111
|
var index_40 = require("./type/partial/index");
|
|
111
112
|
Object.defineProperty(exports, "Partial", { enumerable: true, get: function () { return index_40.Partial; } });
|
|
113
|
+
Object.defineProperty(exports, "PartialFromMappedResult", { enumerable: true, get: function () { return index_40.PartialFromMappedResult; } });
|
|
112
114
|
var index_41 = require("./type/pick/index");
|
|
113
115
|
Object.defineProperty(exports, "Pick", { enumerable: true, get: function () { return index_41.Pick; } });
|
|
114
116
|
var index_42 = require("./type/promise/index");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { TProperties } from '../object/index';
|
|
3
|
+
import { type TMappedResult } from '../mapped/index';
|
|
4
|
+
import { type TExclude } from './exclude';
|
|
5
|
+
type FromProperties<K extends TProperties, U extends TSchema> = ({
|
|
6
|
+
[K2 in keyof K]: TExclude<K[K2], U>;
|
|
7
|
+
});
|
|
8
|
+
declare function FromProperties<K extends TProperties, U extends TSchema>(K: K, U: U, options: SchemaOptions): FromProperties<K, U>;
|
|
9
|
+
type FromMappedResult<K extends TMappedResult, U extends TSchema> = (FromProperties<K['properties'], U>);
|
|
10
|
+
declare function FromMappedResult<K extends TMappedResult, U extends TSchema>(K: K, U: U, options: SchemaOptions): FromMappedResult<K, U>;
|
|
11
|
+
export type TExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>> = (TMappedResult<P>);
|
|
12
|
+
export declare function ExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>>(T: T, U: U, options: SchemaOptions): TMappedResult<P>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExcludeFromMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const exclude_1 = require("./exclude");
|
|
6
|
+
function FromProperties(K, U, options) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
8
|
+
return { ...Acc, [K2]: (0, exclude_1.Exclude)(K[K2], U, options) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromMappedResult(K, U, options) {
|
|
12
|
+
return FromProperties(K.properties, U, options);
|
|
13
|
+
}
|
|
14
|
+
function ExcludeFromMappedResult(T, U, options) {
|
|
15
|
+
const P = FromMappedResult(T, U, options);
|
|
16
|
+
return (0, index_1.MappedResult)(P);
|
|
17
|
+
}
|
|
18
|
+
exports.ExcludeFromMappedResult = ExcludeFromMappedResult;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { UnionToTuple, AssertRest, AssertType, Assert } from '../helpers/index';
|
|
3
|
+
import type { TMappedResult } from '../mapped/index';
|
|
3
4
|
import { type TTemplateLiteral } from '../template-literal/index';
|
|
4
5
|
import { type TUnion } from '../union/index';
|
|
5
6
|
import { type TNever } from '../never/index';
|
|
6
7
|
import { type TLiteral } from '../literal/index';
|
|
7
8
|
import { type Static } from '../static/index';
|
|
8
9
|
import { UnionResolve } from '../union/index';
|
|
10
|
+
import { type TExcludeFromMappedResult } from './exclude-from-mapped-result';
|
|
9
11
|
type ExcludeTemplateLiteralResult<T extends string> = UnionResolve<AssertRest<UnionToTuple<{
|
|
10
12
|
[K in T]: TLiteral<K>;
|
|
11
13
|
}[T]>>>;
|
|
@@ -14,7 +16,8 @@ type ExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTu
|
|
|
14
16
|
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
|
|
15
17
|
}[number]>> extends infer R extends TSchema[] ? UnionResolve<R> : never;
|
|
16
18
|
type ExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? ExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? ExcludeArray<S, U> : T extends U ? TNever : T;
|
|
17
|
-
|
|
19
|
+
declare function ExcludeResolve<L extends TSchema, R extends TSchema>(L: L, R: R): ExcludeResolve<L, R>;
|
|
18
20
|
export type TExclude<T extends TSchema, U extends TSchema> = ExcludeResolve<T, U>;
|
|
21
|
+
export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
|
|
19
22
|
export declare function Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
|
|
20
23
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Exclude =
|
|
3
|
+
exports.Exclude = void 0;
|
|
4
4
|
const index_1 = require("../template-literal/index");
|
|
5
5
|
const index_2 = require("../union/index");
|
|
6
6
|
const index_3 = require("../never/index");
|
|
7
7
|
const index_4 = require("../extends/index");
|
|
8
8
|
const type_1 = require("../clone/type");
|
|
9
|
+
const exclude_from_mapped_result_1 = require("./exclude-from-mapped-result");
|
|
9
10
|
const type_2 = require("../guard/type");
|
|
10
11
|
function ExcludeResolve(L, R) {
|
|
11
12
|
return ((0, type_2.TTemplateLiteral)(L) ? ExcludeResolve((0, index_1.TemplateLiteralToUnion)(L), R) :
|
|
@@ -17,9 +18,13 @@ function ExcludeResolve(L, R) {
|
|
|
17
18
|
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? (0, index_3.Never)() :
|
|
18
19
|
L);
|
|
19
20
|
}
|
|
20
|
-
exports.ExcludeResolve = ExcludeResolve;
|
|
21
21
|
function Exclude(unionType, excludedMembers, options = {}) {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if ((0, type_2.TMappedResult)(unionType)) {
|
|
23
|
+
return (0, exclude_from_mapped_result_1.ExcludeFromMappedResult)(unionType, excludedMembers, options);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const E = ExcludeResolve(unionType, excludedMembers);
|
|
27
|
+
return (0, type_1.CloneType)(E, options);
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
exports.Exclude = Exclude;
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./exclude-from-mapped-result"), exports);
|
|
17
18
|
__exportStar(require("./exclude"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { TProperties } from '../object/index';
|
|
3
|
+
import type { Assert } from '../helpers/index';
|
|
4
|
+
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
5
|
+
import { TLiteral, TLiteralValue } from '../literal/index';
|
|
6
|
+
import { type TExtends } from './extends';
|
|
7
|
+
type FromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
|
|
8
|
+
[_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
|
|
9
|
+
};
|
|
10
|
+
declare function FromPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromPropertyKey<K, U, L, R>;
|
|
11
|
+
type FromPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? FromPropertyKey<LK, U, L, R> & FromPropertyKeys<RK, U, L, R> : {});
|
|
12
|
+
declare function FromPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema>(K: [...K], U: U, L: L, R: R, options: SchemaOptions): FromPropertyKeys<K, U, L, R>;
|
|
13
|
+
type FromMappedKey<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (FromPropertyKeys<K['keys'], U, L, R>);
|
|
14
|
+
declare function FromMappedKey<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromMappedKey<K, U, L, R>;
|
|
15
|
+
export type TExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedKey<T, U, L, R>> = (TMappedResult<P>);
|
|
16
|
+
export declare function ExtendsFromMappedKey<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedKey<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendsFromMappedKey = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const index_2 = require("../literal/index");
|
|
6
|
+
const extends_1 = require("./extends");
|
|
7
|
+
function FromPropertyKey(K, U, L, R, options) {
|
|
8
|
+
return {
|
|
9
|
+
[K]: (0, extends_1.Extends)((0, index_2.Literal)(K), U, L, R, options)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function FromPropertyKeys(K, U, L, R, options) {
|
|
13
|
+
const [LK, ...RK] = K;
|
|
14
|
+
return (K.length > 0
|
|
15
|
+
? { ...FromPropertyKey(LK, U, L, R, options), ...FromPropertyKeys(RK, U, L, R, options) }
|
|
16
|
+
: {});
|
|
17
|
+
}
|
|
18
|
+
function FromMappedKey(K, U, L, R, options) {
|
|
19
|
+
return FromPropertyKeys(K.keys, U, L, R, options);
|
|
20
|
+
}
|
|
21
|
+
function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
22
|
+
const P = FromMappedKey(T, U, L, R, options);
|
|
23
|
+
return (0, index_1.MappedResult)(P);
|
|
24
|
+
}
|
|
25
|
+
exports.ExtendsFromMappedKey = ExtendsFromMappedKey;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { TProperties } from '../object/index';
|
|
3
|
+
import { type TMappedResult } from '../mapped/index';
|
|
4
|
+
import { type TExtends } from './extends';
|
|
5
|
+
type FromProperties<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema> = ({
|
|
6
|
+
[K2 in keyof K]: TExtends<K[K2], U, L, R>;
|
|
7
|
+
});
|
|
8
|
+
declare function FromProperties<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromProperties<K, U, L, R>;
|
|
9
|
+
type FromMappedResult<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema> = (FromProperties<K['properties'], U, L, R>);
|
|
10
|
+
declare function FromMappedResult<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R, options: SchemaOptions): FromMappedResult<K, U, L, R>;
|
|
11
|
+
export type TExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedResult<T, U, L, R>> = (TMappedResult<P>);
|
|
12
|
+
export declare function ExtendsFromMappedResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = FromMappedResult<T, U, L, R>>(T: T, U: U, L: L, R: R, options: SchemaOptions): TMappedResult<P>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendsFromMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const extends_1 = require("./extends");
|
|
6
|
+
function FromProperties(K, U, L, R, options) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
8
|
+
return { ...Acc, [K2]: (0, extends_1.Extends)(K[K2], U, L, R, options) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromMappedResult(K, U, L, R, options) {
|
|
12
|
+
return FromProperties(K.properties, U, L, R, options);
|
|
13
|
+
}
|
|
14
|
+
function ExtendsFromMappedResult(T, U, L, R, options) {
|
|
15
|
+
const P = FromMappedResult(T, U, L, R, options);
|
|
16
|
+
return (0, index_1.MappedResult)(P);
|
|
17
|
+
}
|
|
18
|
+
exports.ExtendsFromMappedResult = ExtendsFromMappedResult;
|
|
@@ -3,12 +3,12 @@ import type { Static } from '../static/index';
|
|
|
3
3
|
import { type TUnion } from '../union/index';
|
|
4
4
|
import { TMappedKey, TMappedResult } from '../mapped/index';
|
|
5
5
|
import { UnionToTuple } from '../helpers/index';
|
|
6
|
-
import { type
|
|
7
|
-
import { type
|
|
6
|
+
import { type TExtendsFromMappedKey } from './extends-from-mapped-key';
|
|
7
|
+
import { type TExtendsFromMappedResult } from './extends-from-mapped-result';
|
|
8
8
|
type ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema> = ((Static<L> extends Static<R> ? T : U) extends infer O extends TSchema ? UnionToTuple<O> extends [infer X extends TSchema, infer Y extends TSchema] ? TUnion<[X, Y]> : O : never);
|
|
9
9
|
declare function ExtendsResolve<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(left: L, right: R, trueType: T, falseType: U): ExtendsResolve<L, R, T, U>;
|
|
10
10
|
export type TExtends<L extends TSchema, R extends TSchema, T extends TSchema, F extends TSchema> = ExtendsResolve<L, R, T, F>;
|
|
11
|
-
export declare function Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions):
|
|
12
|
-
export declare function Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions):
|
|
11
|
+
export declare function Extends<L extends TMappedResult, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedResult<L, R, T, F>;
|
|
12
|
+
export declare function Extends<L extends TMappedKey, R extends TSchema, T extends TSchema, F extends TSchema>(L: L, R: R, T: T, F: F, options?: SchemaOptions): TExtendsFromMappedKey<L, R, T, F>;
|
|
13
13
|
export declare function 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>;
|
|
14
14
|
export {};
|
|
@@ -5,8 +5,8 @@ const type_1 = require("../guard/type");
|
|
|
5
5
|
const index_1 = require("../union/index");
|
|
6
6
|
const extends_check_1 = require("./extends-check");
|
|
7
7
|
const type_2 = require("../clone/type");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const extends_from_mapped_key_1 = require("./extends-from-mapped-key");
|
|
9
|
+
const extends_from_mapped_result_1 = require("./extends-from-mapped-result");
|
|
10
10
|
function ExtendsResolve(left, right, trueType, falseType) {
|
|
11
11
|
const R = (0, extends_check_1.ExtendsCheck)(left, right);
|
|
12
12
|
return (R === extends_check_1.ExtendsResult.Union ? (0, index_1.Union)([trueType, falseType]) :
|
|
@@ -14,8 +14,8 @@ function ExtendsResolve(left, right, trueType, falseType) {
|
|
|
14
14
|
falseType);
|
|
15
15
|
}
|
|
16
16
|
function Extends(L, R, T, F, options = {}) {
|
|
17
|
-
return ((0, type_1.TMappedResult)(L) ? (0,
|
|
18
|
-
(0, type_1.TMappedKey)(L) ? (0, type_2.CloneType)((0,
|
|
17
|
+
return ((0, type_1.TMappedResult)(L) ? (0, extends_from_mapped_result_1.ExtendsFromMappedResult)(L, R, T, F, options) :
|
|
18
|
+
(0, type_1.TMappedKey)(L) ? (0, type_2.CloneType)((0, extends_from_mapped_key_1.ExtendsFromMappedKey)(L, R, T, F, options)) :
|
|
19
19
|
(0, type_2.CloneType)(ExtendsResolve(L, R, T, F), options));
|
|
20
20
|
}
|
|
21
21
|
exports.Extends = Extends;
|