@sinclair/typebox 0.32.8 → 0.32.9
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 +3 -2
- package/build/import/index.mjs +12 -2
- package/build/import/type/composite/composite.d.mts +16 -11
- package/build/import/type/composite/composite.mjs +36 -9
- package/build/import/type/helpers/helpers.d.mts +2 -2
- package/build/import/type/keyof/keyof-property-keys.d.mts +5 -7
- package/build/import/type/sets/set.d.mts +12 -8
- package/build/import/type/sets/set.mjs +14 -4
- package/build/import/type/type/json.d.mts +1 -1
- package/build/import/type/type/json.mjs +2 -2
- package/build/require/index.d.ts +3 -2
- package/build/require/index.js +178 -160
- package/build/require/type/composite/composite.d.ts +16 -11
- package/build/require/type/composite/composite.js +37 -10
- package/build/require/type/helpers/helpers.d.ts +2 -2
- package/build/require/type/keyof/keyof-property-keys.d.ts +5 -7
- package/build/require/type/sets/set.d.ts +12 -8
- package/build/require/type/sets/set.js +14 -4
- package/build/require/type/type/json.d.ts +1 -1
- package/build/require/type/type/json.js +2 -2
- package/package.json +1 -1
- package/readme.md +2 -2
package/build/import/index.d.mts
CHANGED
|
@@ -4,6 +4,8 @@ export { TypeRegistry, FormatRegistry } from './type/registry/index.mjs';
|
|
|
4
4
|
export { TypeGuard, ValueGuard } from './type/guard/index.mjs';
|
|
5
5
|
export { CloneType, CloneRest } from './type/clone/type.mjs';
|
|
6
6
|
export { TypeBoxError } from './type/error/index.mjs';
|
|
7
|
+
export { SetComplement, SetDistinct, SetIncludes, SetIntersect, SetIntersectMany, SetIsSubset, SetUnion, SetUnionMany, type TSetComplement, type TSetDistinct, type TSetIncludes, type TSetIntersect, type TSetIntersectMany, type TSetIsSubset, type TSetUnion, type TSetUnionMany, } from './type/sets/index.mjs';
|
|
8
|
+
export { Increment, type TIncrement, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index.mjs';
|
|
7
9
|
export { Any, type TAny } from './type/any/index.mjs';
|
|
8
10
|
export { Array, type TArray, type ArrayOptions } from './type/array/index.mjs';
|
|
9
11
|
export { AsyncIterator, type TAsyncIterator } from './type/async-iterator/index.mjs';
|
|
@@ -21,7 +23,6 @@ export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/ex
|
|
|
21
23
|
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index.mjs';
|
|
22
24
|
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index.mjs';
|
|
23
25
|
export { Function, type TFunction } from './type/function/index.mjs';
|
|
24
|
-
export { Increment, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index.mjs';
|
|
25
26
|
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index.mjs';
|
|
26
27
|
export { InstanceType, type TInstanceType } from './type/instance-type/index.mjs';
|
|
27
28
|
export { Integer, type TInteger, type IntegerOptions } from './type/integer/index.mjs';
|
|
@@ -55,7 +56,7 @@ export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from '.
|
|
|
55
56
|
export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, type TDecodeRest, type TDecodeProperties } from './type/static/index.mjs';
|
|
56
57
|
export { Strict } from './type/strict/index.mjs';
|
|
57
58
|
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index.mjs';
|
|
58
|
-
export { Symbol, type TSymbol, type TSymbolValue
|
|
59
|
+
export { Symbol, type TSymbol, type TSymbolValue } from './type/symbol/index.mjs';
|
|
59
60
|
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TIsTemplateLiteralFinite, } from './type/template-literal/index.mjs';
|
|
60
61
|
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index.mjs';
|
|
61
62
|
export { Tuple, type TTuple } from './type/tuple/index.mjs';
|
package/build/import/index.mjs
CHANGED
|
@@ -6,9 +6,20 @@ export { PatternBoolean, PatternBooleanExact, PatternNumber, PatternNumberExact,
|
|
|
6
6
|
export { TypeRegistry, FormatRegistry } from './type/registry/index.mjs';
|
|
7
7
|
export { TypeGuard, ValueGuard } from './type/guard/index.mjs';
|
|
8
8
|
export { CloneType, CloneRest } from './type/clone/type.mjs';
|
|
9
|
+
// ------------------------------------------------------------------
|
|
10
|
+
// Error
|
|
11
|
+
// ------------------------------------------------------------------
|
|
9
12
|
export { TypeBoxError } from './type/error/index.mjs';
|
|
10
13
|
// ------------------------------------------------------------------
|
|
11
|
-
//
|
|
14
|
+
// Sets
|
|
15
|
+
// ------------------------------------------------------------------
|
|
16
|
+
export { SetComplement, SetDistinct, SetIncludes, SetIntersect, SetIntersectMany, SetIsSubset, SetUnion, SetUnionMany, } from './type/sets/index.mjs';
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
// Helpers
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
export { Increment } from './type/helpers/index.mjs';
|
|
21
|
+
// ------------------------------------------------------------------
|
|
22
|
+
// Types
|
|
12
23
|
// ------------------------------------------------------------------
|
|
13
24
|
export { Any } from './type/any/index.mjs';
|
|
14
25
|
export { Array } from './type/array/index.mjs';
|
|
@@ -27,7 +38,6 @@ export { Exclude } from './type/exclude/index.mjs';
|
|
|
27
38
|
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './type/extends/index.mjs';
|
|
28
39
|
export { Extract } from './type/extract/index.mjs';
|
|
29
40
|
export { Function } from './type/function/index.mjs';
|
|
30
|
-
export { Increment } from './type/helpers/index.mjs';
|
|
31
41
|
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, } from './type/indexed/index.mjs';
|
|
32
42
|
export { InstanceType } from './type/instance-type/index.mjs';
|
|
33
43
|
export { Integer } from './type/integer/index.mjs';
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
+
import type { Evaluate } from '../helpers/index.mjs';
|
|
3
|
+
import { type TIntersectEvaluated } from '../intersect/index.mjs';
|
|
4
|
+
import { type TIndexFromPropertyKeys } from '../indexed/index.mjs';
|
|
5
|
+
import { type TKeyOfPropertyKeys } from '../keyof/index.mjs';
|
|
6
|
+
import { type TNever } from '../never/index.mjs';
|
|
2
7
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function Composite<T extends
|
|
8
|
+
import { TSetDistinct } from '../sets/index.mjs';
|
|
9
|
+
type TCompositeKeys<T extends TSchema[], Acc extends PropertyKey[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TCompositeKeys<R, TSetDistinct<[...Acc, ...TKeyOfPropertyKeys<L>]>> : Acc);
|
|
10
|
+
type TFilterNever<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? Acc : TFilterNever<R, [...Acc, L]> : Acc);
|
|
11
|
+
type TCompositeProperty<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TCompositeProperty<R, K, TFilterNever<[...Acc, ...TIndexFromPropertyKeys<L, [K]>]>> : Acc);
|
|
12
|
+
type TCompositeProperties<T extends TSchema[], K extends PropertyKey[], Acc = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TCompositeProperties<T, R, Acc & {
|
|
13
|
+
[_ in L]: TIntersectEvaluated<TCompositeProperty<T, L>>;
|
|
14
|
+
}> : Acc);
|
|
15
|
+
type TCompositeEvaluate<T extends TSchema[], K extends PropertyKey[] = TCompositeKeys<T>, P extends TProperties = Evaluate<TCompositeProperties<T, K>>, R extends TObject = TObject<P>> = R;
|
|
16
|
+
export type TComposite<T extends TSchema[]> = TCompositeEvaluate<T>;
|
|
17
|
+
export declare function Composite<T extends TSchema[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
|
|
13
18
|
export {};
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Index } from '../indexed/index.mjs';
|
|
1
|
+
import { IntersectEvaluated } from '../intersect/index.mjs';
|
|
2
|
+
import { IndexFromPropertyKeys } from '../indexed/index.mjs';
|
|
4
3
|
import { KeyOfPropertyKeys } from '../keyof/index.mjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { Object } from '../object/index.mjs';
|
|
5
|
+
import { SetDistinct } from '../sets/index.mjs';
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
// TypeGuard
|
|
8
|
+
// ------------------------------------------------------------------
|
|
9
|
+
import { IsNever } from '../guard/type.mjs';
|
|
10
|
+
// prettier-ignore
|
|
11
|
+
function CompositeKeys(T) {
|
|
12
|
+
return T.reduce((Acc, L) => {
|
|
13
|
+
return SetDistinct([...Acc, ...KeyOfPropertyKeys(L)]);
|
|
14
|
+
}, []);
|
|
15
|
+
}
|
|
16
|
+
// prettier-ignore
|
|
17
|
+
function FilterNever(T) {
|
|
18
|
+
return T.filter(L => !IsNever(L));
|
|
19
|
+
}
|
|
20
|
+
// prettier-ignore
|
|
21
|
+
function CompositeProperty(T, K) {
|
|
22
|
+
return T.reduce((Acc, L) => {
|
|
23
|
+
return FilterNever([...Acc, ...IndexFromPropertyKeys(L, [K])]);
|
|
24
|
+
}, []);
|
|
25
|
+
}
|
|
26
|
+
// prettier-ignore
|
|
27
|
+
function CompositeProperties(T, K) {
|
|
28
|
+
return K.reduce((Acc, L) => {
|
|
29
|
+
return { ...Acc, [L]: IntersectEvaluated(CompositeProperty(T, L)) };
|
|
30
|
+
}, {});
|
|
31
|
+
}
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
export function Composite(T, options = {}) {
|
|
34
|
+
const K = CompositeKeys(T);
|
|
35
|
+
const P = CompositeProperties(T, K);
|
|
36
|
+
const R = Object(P, options);
|
|
37
|
+
return R;
|
|
11
38
|
}
|
|
@@ -33,9 +33,9 @@ type IncrementBase = {
|
|
|
33
33
|
type IncrementTake<T extends keyof IncrementBase> = IncrementBase[T];
|
|
34
34
|
type IncrementStep<T extends string> = T extends IncrementBase['m'] ? IncrementBase['t'] : T extends `${infer L extends keyof IncrementBase}${infer R}` ? L extends IncrementBase['m'] ? `${IncrementTake<L>}${IncrementStep<R>}` : `${IncrementTake<L>}${R}` : never;
|
|
35
35
|
type IncrementReverse<T extends string> = T extends `${infer L}${infer R}` ? `${IncrementReverse<R>}${L}` : T;
|
|
36
|
-
export type
|
|
36
|
+
export type TIncrement<T extends string> = IncrementReverse<IncrementStep<IncrementReverse<T>>>;
|
|
37
37
|
/** Increments the given string value + 1 */
|
|
38
|
-
export declare function Increment<T extends string>(T: T):
|
|
38
|
+
export declare function Increment<T extends string>(T: T): TIncrement<T>;
|
|
39
39
|
export type AssertProperties<T> = T extends TProperties ? T : TProperties;
|
|
40
40
|
export type AssertRest<T, E extends TSchema[] = TSchema[]> = T extends E ? T : [];
|
|
41
41
|
export type AssertType<T, E extends TSchema = TSchema> = T extends E ? T : TNever;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index.mjs';
|
|
2
|
-
import { type ZeroString, type UnionToTuple,
|
|
2
|
+
import { type ZeroString, type UnionToTuple, type TIncrement } from '../helpers/index.mjs';
|
|
3
3
|
import type { TRecursive } from '../recursive/index.mjs';
|
|
4
4
|
import type { TIntersect } from '../intersect/index.mjs';
|
|
5
5
|
import type { TUnion } from '../union/index.mjs';
|
|
@@ -8,16 +8,14 @@ import type { TArray } from '../array/index.mjs';
|
|
|
8
8
|
import type { TObject, TProperties } from '../object/index.mjs';
|
|
9
9
|
import { type TSetUnionMany, type TSetIntersectMany } from '../sets/index.mjs';
|
|
10
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
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
|
|
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;
|
|
11
|
+
type TFromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetUnionMany<C>> = R;
|
|
12
|
+
type TFromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetIntersectMany<C>> = R;
|
|
13
|
+
type TFromTuple<T extends TSchema[], I extends string = ZeroString, Acc extends PropertyKey[] = []> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, TIncrement<I>, [...Acc, I]> : Acc;
|
|
16
14
|
type TFromArray<_ extends TSchema> = ([
|
|
17
15
|
'[number]'
|
|
18
16
|
]);
|
|
19
17
|
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> ?
|
|
18
|
+
export type TKeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? TKeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? TFromIntersect<S> : T extends TUnion<infer S> ? TFromUnion<S> : T extends TTuple<infer S> ? TFromTuple<S> : T extends TArray<infer S> ? TFromArray<S> : T extends TObject<infer S> ? TFromProperties<S> : [
|
|
21
19
|
]);
|
|
22
20
|
/** Returns a tuple of PropertyKeys derived from the given TSchema. */
|
|
23
21
|
export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): TKeyOfPropertyKeys<T>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
export type TSetIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TSetIncludes<R, S> : false);
|
|
2
|
-
/** Returns true if element
|
|
2
|
+
/** Returns true if element right is in the set of left */
|
|
3
3
|
export declare function SetIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TSetIncludes<T, S>;
|
|
4
|
-
export type
|
|
5
|
-
/** Returns true if
|
|
6
|
-
export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]):
|
|
4
|
+
export type TSetIsSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIsSubset<R, S> : false : true);
|
|
5
|
+
/** Returns true if left is a subset of right */
|
|
6
|
+
export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIsSubset<T, S>;
|
|
7
7
|
export type TSetDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<Acc, L> extends false ? TSetDistinct<R, [...Acc, L]> : TSetDistinct<R, [...Acc]> : Acc;
|
|
8
8
|
/** Returns a distinct set of elements */
|
|
9
9
|
export declare function SetDistinct<T extends PropertyKey[]>(T: [...T]): TSetDistinct<T>;
|
|
10
|
-
export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [
|
|
10
|
+
export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [...Acc, L]> : TSetIntersect<R, S, [...Acc]> : Acc);
|
|
11
11
|
/** Returns the Intersect of the given sets */
|
|
12
12
|
export declare function SetIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIntersect<T, S>;
|
|
13
|
-
export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[]
|
|
13
|
+
export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[]> = ([
|
|
14
|
+
...T,
|
|
15
|
+
...S
|
|
16
|
+
]);
|
|
14
17
|
/** Returns the Union of the given sets */
|
|
15
18
|
export declare function SetUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetUnion<T, S>;
|
|
16
19
|
export type TSetComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetComplement<R, S, [...Acc]> : TSetComplement<R, S, [...Acc, L]> : Acc);
|
|
17
20
|
/** Returns the Complement by omitting elements in T that are in S */
|
|
18
21
|
export declare function SetComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetComplement<T, S>;
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
type TSetIntersectManyResolve<T extends PropertyKey[][], Acc extends PropertyKey[]> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectManyResolve<R, TSetIntersect<Acc, L>> : Acc);
|
|
23
|
+
export type TSetIntersectMany<T extends PropertyKey[][]> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectManyResolve<R, L> : []);
|
|
21
24
|
export declare function SetIntersectMany<T extends PropertyKey[][]>(T: [...T]): TSetIntersectMany<T>;
|
|
22
25
|
export type TSetUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetUnionMany<R, TSetUnion<Acc, L>> : Acc);
|
|
23
26
|
/** Returns the Union of multiple sets */
|
|
24
27
|
export declare function SetUnionMany<T extends PropertyKey[][]>(T: [...T]): TSetUnionMany<T>;
|
|
28
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/** Returns true if element
|
|
1
|
+
/** Returns true if element right is in the set of left */
|
|
2
2
|
// prettier-ignore
|
|
3
3
|
export function SetIncludes(T, S) {
|
|
4
4
|
return T.includes(S);
|
|
5
5
|
}
|
|
6
|
-
/** Returns true if
|
|
6
|
+
/** Returns true if left is a subset of right */
|
|
7
7
|
export function SetIsSubset(T, S) {
|
|
8
8
|
return T.every((L) => SetIncludes(S, L));
|
|
9
9
|
}
|
|
@@ -24,10 +24,20 @@ export function SetUnion(T, S) {
|
|
|
24
24
|
export function SetComplement(T, S) {
|
|
25
25
|
return T.filter(L => !S.includes(L));
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
// prettier-ignore
|
|
28
|
+
function SetIntersectManyResolve(T, Init) {
|
|
29
|
+
return T.reduce((Acc, L) => {
|
|
30
|
+
return SetIntersect(Acc, L);
|
|
31
|
+
}, Init);
|
|
32
|
+
}
|
|
28
33
|
// prettier-ignore
|
|
29
34
|
export function SetIntersectMany(T) {
|
|
30
|
-
return (T.length === 1
|
|
35
|
+
return (T.length === 1
|
|
36
|
+
? T[0]
|
|
37
|
+
// Use left to initialize the accumulator for resolve
|
|
38
|
+
: T.length > 1
|
|
39
|
+
? SetIntersectManyResolve(T.slice(1), T[0])
|
|
40
|
+
: []);
|
|
31
41
|
}
|
|
32
42
|
/** Returns the Union of multiple sets */
|
|
33
43
|
export function SetUnionMany(T) {
|
|
@@ -71,7 +71,7 @@ export declare class JsonTypeBuilder {
|
|
|
71
71
|
/** `[Json]` Intrinsic function to Capitalize LiteralString types */
|
|
72
72
|
Capitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TCapitalize<T>;
|
|
73
73
|
/** `[Json]` Creates a Composite object type */
|
|
74
|
-
Composite<T extends
|
|
74
|
+
Composite<T extends TSchema[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
|
|
75
75
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
76
76
|
Const</* const (not supported in 4.0) */ T>(value: T, options?: SchemaOptions): TConst<T>;
|
|
77
77
|
/** `[Json]` Creates a dereferenced type */
|
|
@@ -83,8 +83,8 @@ export class JsonTypeBuilder {
|
|
|
83
83
|
return Capitalize(schema, options);
|
|
84
84
|
}
|
|
85
85
|
/** `[Json]` Creates a Composite object type */
|
|
86
|
-
Composite(
|
|
87
|
-
return Composite(
|
|
86
|
+
Composite(schemas, options) {
|
|
87
|
+
return Composite(schemas, options); // (error) TS 5.4.0-dev - review TComposite implementation
|
|
88
88
|
}
|
|
89
89
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
90
90
|
Const(value, options = {}) {
|
package/build/require/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { TypeRegistry, FormatRegistry } from './type/registry/index';
|
|
|
4
4
|
export { TypeGuard, ValueGuard } from './type/guard/index';
|
|
5
5
|
export { CloneType, CloneRest } from './type/clone/type';
|
|
6
6
|
export { TypeBoxError } from './type/error/index';
|
|
7
|
+
export { SetComplement, SetDistinct, SetIncludes, SetIntersect, SetIntersectMany, SetIsSubset, SetUnion, SetUnionMany, type TSetComplement, type TSetDistinct, type TSetIncludes, type TSetIntersect, type TSetIntersectMany, type TSetIsSubset, type TSetUnion, type TSetUnionMany, } from './type/sets/index';
|
|
8
|
+
export { Increment, type TIncrement, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index';
|
|
7
9
|
export { Any, type TAny } from './type/any/index';
|
|
8
10
|
export { Array, type TArray, type ArrayOptions } from './type/array/index';
|
|
9
11
|
export { AsyncIterator, type TAsyncIterator } from './type/async-iterator/index';
|
|
@@ -21,7 +23,6 @@ export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/ex
|
|
|
21
23
|
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index';
|
|
22
24
|
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index';
|
|
23
25
|
export { Function, type TFunction } from './type/function/index';
|
|
24
|
-
export { Increment, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index';
|
|
25
26
|
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index';
|
|
26
27
|
export { InstanceType, type TInstanceType } from './type/instance-type/index';
|
|
27
28
|
export { Integer, type TInteger, type IntegerOptions } from './type/integer/index';
|
|
@@ -55,7 +56,7 @@ export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from '.
|
|
|
55
56
|
export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, type TDecodeRest, type TDecodeProperties } from './type/static/index';
|
|
56
57
|
export { Strict } from './type/strict/index';
|
|
57
58
|
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index';
|
|
58
|
-
export { Symbol, type TSymbol, type TSymbolValue
|
|
59
|
+
export { Symbol, type TSymbol, type TSymbolValue } from './type/symbol/index';
|
|
59
60
|
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TIsTemplateLiteralFinite, } from './type/template-literal/index';
|
|
60
61
|
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index';
|
|
61
62
|
export { Tuple, type TTuple } from './type/tuple/index';
|
package/build/require/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = void 0;
|
|
4
|
+
exports.IndexFromPropertyKeys = exports.IndexPropertyKeys = exports.Index = 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.Increment = exports.SetUnionMany = exports.SetUnion = exports.SetIsSubset = exports.SetIntersectMany = exports.SetIntersect = exports.SetIncludes = exports.SetDistinct = exports.SetComplement = exports.TypeBoxError = 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;
|
|
5
|
+
exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedFunctionReturnType = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfFromMappedResult = exports.KeyOfPropertyKeysToRest = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedResult = exports.IndexFromMappedKey = exports.IndexFromPropertyKey = void 0;
|
|
6
|
+
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.IsTemplateLiteralExpressionFinite = exports.TemplateLiteralExpressionGenerate = exports.IsTemplateLiteralFinite = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralGenerate = exports.TemplateLiteralSyntax = exports.TemplateLiteral = void 0;
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// Infrastructure
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -29,167 +29,185 @@ Object.defineProperty(exports, "ValueGuard", { enumerable: true, get: function (
|
|
|
29
29
|
var type_1 = require("./type/clone/type");
|
|
30
30
|
Object.defineProperty(exports, "CloneType", { enumerable: true, get: function () { return type_1.CloneType; } });
|
|
31
31
|
Object.defineProperty(exports, "CloneRest", { enumerable: true, get: function () { return type_1.CloneRest; } });
|
|
32
|
+
// ------------------------------------------------------------------
|
|
33
|
+
// Error
|
|
34
|
+
// ------------------------------------------------------------------
|
|
32
35
|
var index_5 = require("./type/error/index");
|
|
33
36
|
Object.defineProperty(exports, "TypeBoxError", { enumerable: true, get: function () { return index_5.TypeBoxError; } });
|
|
34
37
|
// ------------------------------------------------------------------
|
|
35
|
-
//
|
|
38
|
+
// Sets
|
|
39
|
+
// ------------------------------------------------------------------
|
|
40
|
+
var index_6 = require("./type/sets/index");
|
|
41
|
+
Object.defineProperty(exports, "SetComplement", { enumerable: true, get: function () { return index_6.SetComplement; } });
|
|
42
|
+
Object.defineProperty(exports, "SetDistinct", { enumerable: true, get: function () { return index_6.SetDistinct; } });
|
|
43
|
+
Object.defineProperty(exports, "SetIncludes", { enumerable: true, get: function () { return index_6.SetIncludes; } });
|
|
44
|
+
Object.defineProperty(exports, "SetIntersect", { enumerable: true, get: function () { return index_6.SetIntersect; } });
|
|
45
|
+
Object.defineProperty(exports, "SetIntersectMany", { enumerable: true, get: function () { return index_6.SetIntersectMany; } });
|
|
46
|
+
Object.defineProperty(exports, "SetIsSubset", { enumerable: true, get: function () { return index_6.SetIsSubset; } });
|
|
47
|
+
Object.defineProperty(exports, "SetUnion", { enumerable: true, get: function () { return index_6.SetUnion; } });
|
|
48
|
+
Object.defineProperty(exports, "SetUnionMany", { enumerable: true, get: function () { return index_6.SetUnionMany; } });
|
|
49
|
+
// ------------------------------------------------------------------
|
|
50
|
+
// Helpers
|
|
51
|
+
// ------------------------------------------------------------------
|
|
52
|
+
var index_7 = require("./type/helpers/index");
|
|
53
|
+
Object.defineProperty(exports, "Increment", { enumerable: true, get: function () { return index_7.Increment; } });
|
|
54
|
+
// ------------------------------------------------------------------
|
|
55
|
+
// Types
|
|
36
56
|
// ------------------------------------------------------------------
|
|
37
|
-
var
|
|
38
|
-
Object.defineProperty(exports, "Any", { enumerable: true, get: function () { return
|
|
39
|
-
var
|
|
40
|
-
Object.defineProperty(exports, "Array", { enumerable: true, get: function () { return
|
|
41
|
-
var
|
|
42
|
-
Object.defineProperty(exports, "AsyncIterator", { enumerable: true, get: function () { return
|
|
43
|
-
var
|
|
44
|
-
Object.defineProperty(exports, "Awaited", { enumerable: true, get: function () { return
|
|
45
|
-
var
|
|
46
|
-
Object.defineProperty(exports, "BigInt", { enumerable: true, get: function () { return
|
|
47
|
-
var
|
|
48
|
-
Object.defineProperty(exports, "Boolean", { enumerable: true, get: function () { return
|
|
49
|
-
var
|
|
50
|
-
Object.defineProperty(exports, "Composite", { enumerable: true, get: function () { return
|
|
51
|
-
var
|
|
52
|
-
Object.defineProperty(exports, "Const", { enumerable: true, get: function () { return
|
|
53
|
-
var
|
|
54
|
-
Object.defineProperty(exports, "Constructor", { enumerable: true, get: function () { return
|
|
55
|
-
var
|
|
56
|
-
Object.defineProperty(exports, "ConstructorParameters", { enumerable: true, get: function () { return
|
|
57
|
-
var
|
|
58
|
-
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return
|
|
59
|
-
var
|
|
60
|
-
Object.defineProperty(exports, "Deref", { enumerable: true, get: function () { return
|
|
61
|
-
var
|
|
62
|
-
Object.defineProperty(exports, "Enum", { enumerable: true, get: function () { return
|
|
63
|
-
var
|
|
64
|
-
Object.defineProperty(exports, "Exclude", { enumerable: true, get: function () { return
|
|
65
|
-
var
|
|
66
|
-
Object.defineProperty(exports, "Extends", { enumerable: true, get: function () { return
|
|
67
|
-
Object.defineProperty(exports, "ExtendsCheck", { enumerable: true, get: function () { return
|
|
68
|
-
Object.defineProperty(exports, "ExtendsResult", { enumerable: true, get: function () { return
|
|
69
|
-
Object.defineProperty(exports, "ExtendsUndefinedCheck", { enumerable: true, get: function () { return
|
|
70
|
-
var
|
|
71
|
-
Object.defineProperty(exports, "Extract", { enumerable: true, get: function () { return
|
|
72
|
-
var
|
|
73
|
-
Object.defineProperty(exports, "Function", { enumerable: true, get: function () { return
|
|
74
|
-
var
|
|
75
|
-
Object.defineProperty(exports, "
|
|
76
|
-
|
|
77
|
-
Object.defineProperty(exports, "
|
|
78
|
-
Object.defineProperty(exports, "
|
|
79
|
-
Object.defineProperty(exports, "
|
|
80
|
-
Object.defineProperty(exports, "
|
|
81
|
-
|
|
82
|
-
Object.defineProperty(exports, "
|
|
83
|
-
var
|
|
84
|
-
Object.defineProperty(exports, "
|
|
85
|
-
var
|
|
86
|
-
Object.defineProperty(exports, "
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Object.defineProperty(exports, "
|
|
90
|
-
var
|
|
91
|
-
Object.defineProperty(exports, "
|
|
92
|
-
|
|
93
|
-
Object.defineProperty(exports, "
|
|
94
|
-
Object.defineProperty(exports, "
|
|
95
|
-
Object.defineProperty(exports, "
|
|
96
|
-
Object.defineProperty(exports, "
|
|
97
|
-
|
|
98
|
-
Object.defineProperty(exports, "
|
|
99
|
-
|
|
100
|
-
Object.defineProperty(exports, "
|
|
101
|
-
Object.defineProperty(exports, "
|
|
102
|
-
Object.defineProperty(exports, "
|
|
103
|
-
|
|
104
|
-
Object.defineProperty(exports, "
|
|
105
|
-
var
|
|
106
|
-
Object.defineProperty(exports, "
|
|
107
|
-
|
|
108
|
-
Object.defineProperty(exports, "
|
|
109
|
-
Object.defineProperty(exports, "
|
|
110
|
-
|
|
111
|
-
Object.defineProperty(exports, "
|
|
112
|
-
var
|
|
113
|
-
Object.defineProperty(exports, "
|
|
114
|
-
var
|
|
115
|
-
Object.defineProperty(exports, "
|
|
116
|
-
var
|
|
117
|
-
Object.defineProperty(exports, "
|
|
118
|
-
var
|
|
119
|
-
Object.defineProperty(exports, "
|
|
120
|
-
var
|
|
121
|
-
Object.defineProperty(exports, "
|
|
122
|
-
var
|
|
123
|
-
Object.defineProperty(exports, "
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Object.defineProperty(exports, "
|
|
127
|
-
var
|
|
128
|
-
Object.defineProperty(exports, "
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Object.defineProperty(exports, "
|
|
132
|
-
var
|
|
133
|
-
Object.defineProperty(exports, "
|
|
134
|
-
var
|
|
135
|
-
Object.defineProperty(exports, "
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Object.defineProperty(exports, "
|
|
139
|
-
var
|
|
140
|
-
Object.defineProperty(exports, "
|
|
141
|
-
var
|
|
142
|
-
Object.defineProperty(exports, "
|
|
143
|
-
var
|
|
144
|
-
Object.defineProperty(exports, "
|
|
145
|
-
var
|
|
146
|
-
Object.defineProperty(exports, "
|
|
147
|
-
var
|
|
148
|
-
Object.defineProperty(exports, "
|
|
149
|
-
var
|
|
150
|
-
Object.defineProperty(exports, "
|
|
151
|
-
var
|
|
152
|
-
Object.defineProperty(exports, "
|
|
153
|
-
var
|
|
154
|
-
Object.defineProperty(exports, "
|
|
155
|
-
var
|
|
156
|
-
Object.defineProperty(exports, "
|
|
157
|
-
var
|
|
158
|
-
Object.defineProperty(exports, "
|
|
159
|
-
var
|
|
160
|
-
Object.defineProperty(exports, "
|
|
161
|
-
|
|
162
|
-
Object.defineProperty(exports, "
|
|
163
|
-
Object.defineProperty(exports, "
|
|
164
|
-
Object.defineProperty(exports, "
|
|
165
|
-
Object.defineProperty(exports, "
|
|
166
|
-
Object.defineProperty(exports, "
|
|
167
|
-
Object.defineProperty(exports, "
|
|
168
|
-
|
|
169
|
-
Object.defineProperty(exports, "
|
|
170
|
-
|
|
171
|
-
Object.defineProperty(exports, "
|
|
172
|
-
|
|
173
|
-
Object.defineProperty(exports, "
|
|
174
|
-
var
|
|
175
|
-
Object.defineProperty(exports, "
|
|
176
|
-
var
|
|
177
|
-
Object.defineProperty(exports, "
|
|
178
|
-
var
|
|
179
|
-
Object.defineProperty(exports, "
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Object.defineProperty(exports, "
|
|
183
|
-
var
|
|
184
|
-
Object.defineProperty(exports, "
|
|
185
|
-
var
|
|
186
|
-
Object.defineProperty(exports, "
|
|
187
|
-
var index_64 = require("./type/void/index");
|
|
188
|
-
Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return index_64.Void; } });
|
|
57
|
+
var index_8 = require("./type/any/index");
|
|
58
|
+
Object.defineProperty(exports, "Any", { enumerable: true, get: function () { return index_8.Any; } });
|
|
59
|
+
var index_9 = require("./type/array/index");
|
|
60
|
+
Object.defineProperty(exports, "Array", { enumerable: true, get: function () { return index_9.Array; } });
|
|
61
|
+
var index_10 = require("./type/async-iterator/index");
|
|
62
|
+
Object.defineProperty(exports, "AsyncIterator", { enumerable: true, get: function () { return index_10.AsyncIterator; } });
|
|
63
|
+
var index_11 = require("./type/awaited/index");
|
|
64
|
+
Object.defineProperty(exports, "Awaited", { enumerable: true, get: function () { return index_11.Awaited; } });
|
|
65
|
+
var index_12 = require("./type/bigint/index");
|
|
66
|
+
Object.defineProperty(exports, "BigInt", { enumerable: true, get: function () { return index_12.BigInt; } });
|
|
67
|
+
var index_13 = require("./type/boolean/index");
|
|
68
|
+
Object.defineProperty(exports, "Boolean", { enumerable: true, get: function () { return index_13.Boolean; } });
|
|
69
|
+
var index_14 = require("./type/composite/index");
|
|
70
|
+
Object.defineProperty(exports, "Composite", { enumerable: true, get: function () { return index_14.Composite; } });
|
|
71
|
+
var index_15 = require("./type/const/index");
|
|
72
|
+
Object.defineProperty(exports, "Const", { enumerable: true, get: function () { return index_15.Const; } });
|
|
73
|
+
var index_16 = require("./type/constructor/index");
|
|
74
|
+
Object.defineProperty(exports, "Constructor", { enumerable: true, get: function () { return index_16.Constructor; } });
|
|
75
|
+
var index_17 = require("./type/constructor-parameters/index");
|
|
76
|
+
Object.defineProperty(exports, "ConstructorParameters", { enumerable: true, get: function () { return index_17.ConstructorParameters; } });
|
|
77
|
+
var index_18 = require("./type/date/index");
|
|
78
|
+
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return index_18.Date; } });
|
|
79
|
+
var index_19 = require("./type/deref/index");
|
|
80
|
+
Object.defineProperty(exports, "Deref", { enumerable: true, get: function () { return index_19.Deref; } });
|
|
81
|
+
var index_20 = require("./type/enum/index");
|
|
82
|
+
Object.defineProperty(exports, "Enum", { enumerable: true, get: function () { return index_20.Enum; } });
|
|
83
|
+
var index_21 = require("./type/exclude/index");
|
|
84
|
+
Object.defineProperty(exports, "Exclude", { enumerable: true, get: function () { return index_21.Exclude; } });
|
|
85
|
+
var index_22 = require("./type/extends/index");
|
|
86
|
+
Object.defineProperty(exports, "Extends", { enumerable: true, get: function () { return index_22.Extends; } });
|
|
87
|
+
Object.defineProperty(exports, "ExtendsCheck", { enumerable: true, get: function () { return index_22.ExtendsCheck; } });
|
|
88
|
+
Object.defineProperty(exports, "ExtendsResult", { enumerable: true, get: function () { return index_22.ExtendsResult; } });
|
|
89
|
+
Object.defineProperty(exports, "ExtendsUndefinedCheck", { enumerable: true, get: function () { return index_22.ExtendsUndefinedCheck; } });
|
|
90
|
+
var index_23 = require("./type/extract/index");
|
|
91
|
+
Object.defineProperty(exports, "Extract", { enumerable: true, get: function () { return index_23.Extract; } });
|
|
92
|
+
var index_24 = require("./type/function/index");
|
|
93
|
+
Object.defineProperty(exports, "Function", { enumerable: true, get: function () { return index_24.Function; } });
|
|
94
|
+
var index_25 = require("./type/indexed/index");
|
|
95
|
+
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return index_25.Index; } });
|
|
96
|
+
Object.defineProperty(exports, "IndexPropertyKeys", { enumerable: true, get: function () { return index_25.IndexPropertyKeys; } });
|
|
97
|
+
Object.defineProperty(exports, "IndexFromPropertyKeys", { enumerable: true, get: function () { return index_25.IndexFromPropertyKeys; } });
|
|
98
|
+
Object.defineProperty(exports, "IndexFromPropertyKey", { enumerable: true, get: function () { return index_25.IndexFromPropertyKey; } });
|
|
99
|
+
Object.defineProperty(exports, "IndexFromMappedKey", { enumerable: true, get: function () { return index_25.IndexFromMappedKey; } });
|
|
100
|
+
Object.defineProperty(exports, "IndexFromMappedResult", { enumerable: true, get: function () { return index_25.IndexFromMappedResult; } });
|
|
101
|
+
var index_26 = require("./type/instance-type/index");
|
|
102
|
+
Object.defineProperty(exports, "InstanceType", { enumerable: true, get: function () { return index_26.InstanceType; } });
|
|
103
|
+
var index_27 = require("./type/integer/index");
|
|
104
|
+
Object.defineProperty(exports, "Integer", { enumerable: true, get: function () { return index_27.Integer; } });
|
|
105
|
+
var index_28 = require("./type/intersect/index");
|
|
106
|
+
Object.defineProperty(exports, "Intersect", { enumerable: true, get: function () { return index_28.Intersect; } });
|
|
107
|
+
Object.defineProperty(exports, "IntersectEvaluated", { enumerable: true, get: function () { return index_28.IntersectEvaluated; } });
|
|
108
|
+
var index_29 = require("./type/iterator/index");
|
|
109
|
+
Object.defineProperty(exports, "Iterator", { enumerable: true, get: function () { return index_29.Iterator; } });
|
|
110
|
+
var index_30 = require("./type/intrinsic/index");
|
|
111
|
+
Object.defineProperty(exports, "Intrinsic", { enumerable: true, get: function () { return index_30.Intrinsic; } });
|
|
112
|
+
Object.defineProperty(exports, "IntrinsicFromMappedKey", { enumerable: true, get: function () { return index_30.IntrinsicFromMappedKey; } });
|
|
113
|
+
Object.defineProperty(exports, "Capitalize", { enumerable: true, get: function () { return index_30.Capitalize; } });
|
|
114
|
+
Object.defineProperty(exports, "Lowercase", { enumerable: true, get: function () { return index_30.Lowercase; } });
|
|
115
|
+
Object.defineProperty(exports, "Uncapitalize", { enumerable: true, get: function () { return index_30.Uncapitalize; } });
|
|
116
|
+
Object.defineProperty(exports, "Uppercase", { enumerable: true, get: function () { return index_30.Uppercase; } });
|
|
117
|
+
var index_31 = require("./type/keyof/index");
|
|
118
|
+
Object.defineProperty(exports, "KeyOf", { enumerable: true, get: function () { return index_31.KeyOf; } });
|
|
119
|
+
Object.defineProperty(exports, "KeyOfPropertyKeys", { enumerable: true, get: function () { return index_31.KeyOfPropertyKeys; } });
|
|
120
|
+
Object.defineProperty(exports, "KeyOfPropertyKeysToRest", { enumerable: true, get: function () { return index_31.KeyOfPropertyKeysToRest; } });
|
|
121
|
+
Object.defineProperty(exports, "KeyOfFromMappedResult", { enumerable: true, get: function () { return index_31.KeyOfFromMappedResult; } });
|
|
122
|
+
Object.defineProperty(exports, "KeyOfPattern", { enumerable: true, get: function () { return index_31.KeyOfPattern; } });
|
|
123
|
+
var index_32 = require("./type/literal/index");
|
|
124
|
+
Object.defineProperty(exports, "Literal", { enumerable: true, get: function () { return index_32.Literal; } });
|
|
125
|
+
var index_33 = require("./type/mapped/index");
|
|
126
|
+
Object.defineProperty(exports, "Mapped", { enumerable: true, get: function () { return index_33.Mapped; } });
|
|
127
|
+
Object.defineProperty(exports, "MappedKey", { enumerable: true, get: function () { return index_33.MappedKey; } });
|
|
128
|
+
Object.defineProperty(exports, "MappedResult", { enumerable: true, get: function () { return index_33.MappedResult; } });
|
|
129
|
+
Object.defineProperty(exports, "MappedFunctionReturnType", { enumerable: true, get: function () { return index_33.MappedFunctionReturnType; } });
|
|
130
|
+
var index_34 = require("./type/never/index");
|
|
131
|
+
Object.defineProperty(exports, "Never", { enumerable: true, get: function () { return index_34.Never; } });
|
|
132
|
+
var index_35 = require("./type/not/index");
|
|
133
|
+
Object.defineProperty(exports, "Not", { enumerable: true, get: function () { return index_35.Not; } });
|
|
134
|
+
var index_36 = require("./type/null/index");
|
|
135
|
+
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return index_36.Null; } });
|
|
136
|
+
var index_37 = require("./type/number/index");
|
|
137
|
+
Object.defineProperty(exports, "Number", { enumerable: true, get: function () { return index_37.Number; } });
|
|
138
|
+
var index_38 = require("./type/object/index");
|
|
139
|
+
Object.defineProperty(exports, "Object", { enumerable: true, get: function () { return index_38.Object; } });
|
|
140
|
+
var index_39 = require("./type/omit/index");
|
|
141
|
+
Object.defineProperty(exports, "Omit", { enumerable: true, get: function () { return index_39.Omit; } });
|
|
142
|
+
var index_40 = require("./type/optional/index");
|
|
143
|
+
Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return index_40.Optional; } });
|
|
144
|
+
Object.defineProperty(exports, "OptionalFromMappedResult", { enumerable: true, get: function () { return index_40.OptionalFromMappedResult; } });
|
|
145
|
+
var index_41 = require("./type/parameters/index");
|
|
146
|
+
Object.defineProperty(exports, "Parameters", { enumerable: true, get: function () { return index_41.Parameters; } });
|
|
147
|
+
var index_42 = require("./type/partial/index");
|
|
148
|
+
Object.defineProperty(exports, "Partial", { enumerable: true, get: function () { return index_42.Partial; } });
|
|
149
|
+
Object.defineProperty(exports, "PartialFromMappedResult", { enumerable: true, get: function () { return index_42.PartialFromMappedResult; } });
|
|
150
|
+
var index_43 = require("./type/pick/index");
|
|
151
|
+
Object.defineProperty(exports, "Pick", { enumerable: true, get: function () { return index_43.Pick; } });
|
|
152
|
+
var index_44 = require("./type/promise/index");
|
|
153
|
+
Object.defineProperty(exports, "Promise", { enumerable: true, get: function () { return index_44.Promise; } });
|
|
154
|
+
var index_45 = require("./type/readonly/index");
|
|
155
|
+
Object.defineProperty(exports, "Readonly", { enumerable: true, get: function () { return index_45.Readonly; } });
|
|
156
|
+
Object.defineProperty(exports, "ReadonlyFromMappedResult", { enumerable: true, get: function () { return index_45.ReadonlyFromMappedResult; } });
|
|
157
|
+
var index_46 = require("./type/readonly-optional/index");
|
|
158
|
+
Object.defineProperty(exports, "ReadonlyOptional", { enumerable: true, get: function () { return index_46.ReadonlyOptional; } });
|
|
159
|
+
var index_47 = require("./type/record/index");
|
|
160
|
+
Object.defineProperty(exports, "Record", { enumerable: true, get: function () { return index_47.Record; } });
|
|
161
|
+
var index_48 = require("./type/recursive/index");
|
|
162
|
+
Object.defineProperty(exports, "Recursive", { enumerable: true, get: function () { return index_48.Recursive; } });
|
|
163
|
+
var index_49 = require("./type/ref/index");
|
|
164
|
+
Object.defineProperty(exports, "Ref", { enumerable: true, get: function () { return index_49.Ref; } });
|
|
165
|
+
var index_50 = require("./type/regexp/index");
|
|
166
|
+
Object.defineProperty(exports, "RegExp", { enumerable: true, get: function () { return index_50.RegExp; } });
|
|
167
|
+
var index_51 = require("./type/required/index");
|
|
168
|
+
Object.defineProperty(exports, "Required", { enumerable: true, get: function () { return index_51.Required; } });
|
|
169
|
+
var index_52 = require("./type/rest/index");
|
|
170
|
+
Object.defineProperty(exports, "Rest", { enumerable: true, get: function () { return index_52.Rest; } });
|
|
171
|
+
var index_53 = require("./type/return-type/index");
|
|
172
|
+
Object.defineProperty(exports, "ReturnType", { enumerable: true, get: function () { return index_53.ReturnType; } });
|
|
173
|
+
var index_54 = require("./type/strict/index");
|
|
174
|
+
Object.defineProperty(exports, "Strict", { enumerable: true, get: function () { return index_54.Strict; } });
|
|
175
|
+
var index_55 = require("./type/string/index");
|
|
176
|
+
Object.defineProperty(exports, "String", { enumerable: true, get: function () { return index_55.String; } });
|
|
177
|
+
var index_56 = require("./type/symbol/index");
|
|
178
|
+
Object.defineProperty(exports, "Symbol", { enumerable: true, get: function () { return index_56.Symbol; } });
|
|
179
|
+
var index_57 = require("./type/template-literal/index");
|
|
180
|
+
Object.defineProperty(exports, "TemplateLiteral", { enumerable: true, get: function () { return index_57.TemplateLiteral; } });
|
|
181
|
+
Object.defineProperty(exports, "TemplateLiteralSyntax", { enumerable: true, get: function () { return index_57.TemplateLiteralSyntax; } });
|
|
182
|
+
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralGenerate; } });
|
|
183
|
+
Object.defineProperty(exports, "TemplateLiteralParse", { enumerable: true, get: function () { return index_57.TemplateLiteralParse; } });
|
|
184
|
+
Object.defineProperty(exports, "TemplateLiteralParseExact", { enumerable: true, get: function () { return index_57.TemplateLiteralParseExact; } });
|
|
185
|
+
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralFinite; } });
|
|
186
|
+
Object.defineProperty(exports, "TemplateLiteralExpressionGenerate", { enumerable: true, get: function () { return index_57.TemplateLiteralExpressionGenerate; } });
|
|
187
|
+
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_57.IsTemplateLiteralExpressionFinite; } });
|
|
188
|
+
var index_58 = require("./type/transform/index");
|
|
189
|
+
Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return index_58.Transform; } });
|
|
190
|
+
Object.defineProperty(exports, "TransformDecodeBuilder", { enumerable: true, get: function () { return index_58.TransformDecodeBuilder; } });
|
|
191
|
+
Object.defineProperty(exports, "TransformEncodeBuilder", { enumerable: true, get: function () { return index_58.TransformEncodeBuilder; } });
|
|
192
|
+
var index_59 = require("./type/tuple/index");
|
|
193
|
+
Object.defineProperty(exports, "Tuple", { enumerable: true, get: function () { return index_59.Tuple; } });
|
|
194
|
+
var index_60 = require("./type/uint8array/index");
|
|
195
|
+
Object.defineProperty(exports, "Uint8Array", { enumerable: true, get: function () { return index_60.Uint8Array; } });
|
|
196
|
+
var index_61 = require("./type/undefined/index");
|
|
197
|
+
Object.defineProperty(exports, "Undefined", { enumerable: true, get: function () { return index_61.Undefined; } });
|
|
198
|
+
var index_62 = require("./type/union/index");
|
|
199
|
+
Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return index_62.Union; } });
|
|
200
|
+
Object.defineProperty(exports, "UnionEvaluated", { enumerable: true, get: function () { return index_62.UnionEvaluated; } });
|
|
201
|
+
var index_63 = require("./type/unknown/index");
|
|
202
|
+
Object.defineProperty(exports, "Unknown", { enumerable: true, get: function () { return index_63.Unknown; } });
|
|
203
|
+
var index_64 = require("./type/unsafe/index");
|
|
204
|
+
Object.defineProperty(exports, "Unsafe", { enumerable: true, get: function () { return index_64.Unsafe; } });
|
|
205
|
+
var index_65 = require("./type/void/index");
|
|
206
|
+
Object.defineProperty(exports, "Void", { enumerable: true, get: function () { return index_65.Void; } });
|
|
189
207
|
// ------------------------------------------------------------------
|
|
190
208
|
// Namespace
|
|
191
209
|
// ------------------------------------------------------------------
|
|
192
|
-
var
|
|
193
|
-
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return
|
|
194
|
-
Object.defineProperty(exports, "JsonTypeBuilder", { enumerable: true, get: function () { return
|
|
195
|
-
Object.defineProperty(exports, "JavaScriptTypeBuilder", { enumerable: true, get: function () { return
|
|
210
|
+
var index_66 = require("./type/type/index");
|
|
211
|
+
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return index_66.Type; } });
|
|
212
|
+
Object.defineProperty(exports, "JsonTypeBuilder", { enumerable: true, get: function () { return index_66.JsonTypeBuilder; } });
|
|
213
|
+
Object.defineProperty(exports, "JavaScriptTypeBuilder", { enumerable: true, get: function () { return index_66.JavaScriptTypeBuilder; } });
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
|
+
import type { Evaluate } from '../helpers/index';
|
|
3
|
+
import { type TIntersectEvaluated } from '../intersect/index';
|
|
4
|
+
import { type TIndexFromPropertyKeys } from '../indexed/index';
|
|
5
|
+
import { type TKeyOfPropertyKeys } from '../keyof/index';
|
|
6
|
+
import { type TNever } from '../never/index';
|
|
2
7
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function Composite<T extends
|
|
8
|
+
import { TSetDistinct } from '../sets/index';
|
|
9
|
+
type TCompositeKeys<T extends TSchema[], Acc extends PropertyKey[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TCompositeKeys<R, TSetDistinct<[...Acc, ...TKeyOfPropertyKeys<L>]>> : Acc);
|
|
10
|
+
type TFilterNever<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? Acc : TFilterNever<R, [...Acc, L]> : Acc);
|
|
11
|
+
type TCompositeProperty<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TCompositeProperty<R, K, TFilterNever<[...Acc, ...TIndexFromPropertyKeys<L, [K]>]>> : Acc);
|
|
12
|
+
type TCompositeProperties<T extends TSchema[], K extends PropertyKey[], Acc = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TCompositeProperties<T, R, Acc & {
|
|
13
|
+
[_ in L]: TIntersectEvaluated<TCompositeProperty<T, L>>;
|
|
14
|
+
}> : Acc);
|
|
15
|
+
type TCompositeEvaluate<T extends TSchema[], K extends PropertyKey[] = TCompositeKeys<T>, P extends TProperties = Evaluate<TCompositeProperties<T, K>>, R extends TObject = TObject<P>> = R;
|
|
16
|
+
export type TComposite<T extends TSchema[]> = TCompositeEvaluate<T>;
|
|
17
|
+
export declare function Composite<T extends TSchema[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
|
|
13
18
|
export {};
|
|
@@ -2,15 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Composite = void 0;
|
|
5
|
-
const index_1 = require("../
|
|
6
|
-
const index_2 = require("../
|
|
7
|
-
const index_3 = require("../
|
|
8
|
-
const index_4 = require("../
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const index_1 = require("../intersect/index");
|
|
6
|
+
const index_2 = require("../indexed/index");
|
|
7
|
+
const index_3 = require("../keyof/index");
|
|
8
|
+
const index_4 = require("../object/index");
|
|
9
|
+
const index_5 = require("../sets/index");
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
// TypeGuard
|
|
12
|
+
// ------------------------------------------------------------------
|
|
13
|
+
const type_1 = require("../guard/type");
|
|
14
|
+
// prettier-ignore
|
|
15
|
+
function CompositeKeys(T) {
|
|
16
|
+
return T.reduce((Acc, L) => {
|
|
17
|
+
return (0, index_5.SetDistinct)([...Acc, ...(0, index_3.KeyOfPropertyKeys)(L)]);
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
20
|
+
// prettier-ignore
|
|
21
|
+
function FilterNever(T) {
|
|
22
|
+
return T.filter(L => !(0, type_1.IsNever)(L));
|
|
23
|
+
}
|
|
24
|
+
// prettier-ignore
|
|
25
|
+
function CompositeProperty(T, K) {
|
|
26
|
+
return T.reduce((Acc, L) => {
|
|
27
|
+
return FilterNever([...Acc, ...(0, index_2.IndexFromPropertyKeys)(L, [K])]);
|
|
28
|
+
}, []);
|
|
29
|
+
}
|
|
30
|
+
// prettier-ignore
|
|
31
|
+
function CompositeProperties(T, K) {
|
|
32
|
+
return K.reduce((Acc, L) => {
|
|
33
|
+
return { ...Acc, [L]: (0, index_1.IntersectEvaluated)(CompositeProperty(T, L)) };
|
|
34
|
+
}, {});
|
|
35
|
+
}
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
function Composite(T, options = {}) {
|
|
38
|
+
const K = CompositeKeys(T);
|
|
39
|
+
const P = CompositeProperties(T, K);
|
|
40
|
+
const R = (0, index_4.Object)(P, options);
|
|
41
|
+
return R;
|
|
15
42
|
}
|
|
16
43
|
exports.Composite = Composite;
|
|
@@ -33,9 +33,9 @@ type IncrementBase = {
|
|
|
33
33
|
type IncrementTake<T extends keyof IncrementBase> = IncrementBase[T];
|
|
34
34
|
type IncrementStep<T extends string> = T extends IncrementBase['m'] ? IncrementBase['t'] : T extends `${infer L extends keyof IncrementBase}${infer R}` ? L extends IncrementBase['m'] ? `${IncrementTake<L>}${IncrementStep<R>}` : `${IncrementTake<L>}${R}` : never;
|
|
35
35
|
type IncrementReverse<T extends string> = T extends `${infer L}${infer R}` ? `${IncrementReverse<R>}${L}` : T;
|
|
36
|
-
export type
|
|
36
|
+
export type TIncrement<T extends string> = IncrementReverse<IncrementStep<IncrementReverse<T>>>;
|
|
37
37
|
/** Increments the given string value + 1 */
|
|
38
|
-
export declare function Increment<T extends string>(T: T):
|
|
38
|
+
export declare function Increment<T extends string>(T: T): TIncrement<T>;
|
|
39
39
|
export type AssertProperties<T> = T extends TProperties ? T : TProperties;
|
|
40
40
|
export type AssertRest<T, E extends TSchema[] = TSchema[]> = T extends E ? T : [];
|
|
41
41
|
export type AssertType<T, E extends TSchema = TSchema> = T extends E ? T : TNever;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
|
-
import { type ZeroString, type UnionToTuple,
|
|
2
|
+
import { type ZeroString, type UnionToTuple, type TIncrement } from '../helpers/index';
|
|
3
3
|
import type { TRecursive } from '../recursive/index';
|
|
4
4
|
import type { TIntersect } from '../intersect/index';
|
|
5
5
|
import type { TUnion } from '../union/index';
|
|
@@ -8,16 +8,14 @@ import type { TArray } from '../array/index';
|
|
|
8
8
|
import type { TObject, TProperties } from '../object/index';
|
|
9
9
|
import { type TSetUnionMany, type TSetIntersectMany } from '../sets/index';
|
|
10
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
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
declare function FromUnion<T extends TSchema[]>(T: [...T]): FromUnion<T>;
|
|
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;
|
|
11
|
+
type TFromIntersect<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetUnionMany<C>> = R;
|
|
12
|
+
type TFromUnion<T extends TSchema[], C extends PropertyKey[][] = TFromRest<T>, R extends PropertyKey[] = TSetIntersectMany<C>> = R;
|
|
13
|
+
type TFromTuple<T extends TSchema[], I extends string = ZeroString, Acc extends PropertyKey[] = []> = T extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, TIncrement<I>, [...Acc, I]> : Acc;
|
|
16
14
|
type TFromArray<_ extends TSchema> = ([
|
|
17
15
|
'[number]'
|
|
18
16
|
]);
|
|
19
17
|
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> ?
|
|
18
|
+
export type TKeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? TKeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? TFromIntersect<S> : T extends TUnion<infer S> ? TFromUnion<S> : T extends TTuple<infer S> ? TFromTuple<S> : T extends TArray<infer S> ? TFromArray<S> : T extends TObject<infer S> ? TFromProperties<S> : [
|
|
21
19
|
]);
|
|
22
20
|
/** Returns a tuple of PropertyKeys derived from the given TSchema. */
|
|
23
21
|
export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): TKeyOfPropertyKeys<T>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
export type TSetIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TSetIncludes<R, S> : false);
|
|
2
|
-
/** Returns true if element
|
|
2
|
+
/** Returns true if element right is in the set of left */
|
|
3
3
|
export declare function SetIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TSetIncludes<T, S>;
|
|
4
|
-
export type
|
|
5
|
-
/** Returns true if
|
|
6
|
-
export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]):
|
|
4
|
+
export type TSetIsSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIsSubset<R, S> : false : true);
|
|
5
|
+
/** Returns true if left is a subset of right */
|
|
6
|
+
export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIsSubset<T, S>;
|
|
7
7
|
export type TSetDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<Acc, L> extends false ? TSetDistinct<R, [...Acc, L]> : TSetDistinct<R, [...Acc]> : Acc;
|
|
8
8
|
/** Returns a distinct set of elements */
|
|
9
9
|
export declare function SetDistinct<T extends PropertyKey[]>(T: [...T]): TSetDistinct<T>;
|
|
10
|
-
export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [
|
|
10
|
+
export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [...Acc, L]> : TSetIntersect<R, S, [...Acc]> : Acc);
|
|
11
11
|
/** Returns the Intersect of the given sets */
|
|
12
12
|
export declare function SetIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIntersect<T, S>;
|
|
13
|
-
export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[]
|
|
13
|
+
export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[]> = ([
|
|
14
|
+
...T,
|
|
15
|
+
...S
|
|
16
|
+
]);
|
|
14
17
|
/** Returns the Union of the given sets */
|
|
15
18
|
export declare function SetUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetUnion<T, S>;
|
|
16
19
|
export type TSetComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetComplement<R, S, [...Acc]> : TSetComplement<R, S, [...Acc, L]> : Acc);
|
|
17
20
|
/** Returns the Complement by omitting elements in T that are in S */
|
|
18
21
|
export declare function SetComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetComplement<T, S>;
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
type TSetIntersectManyResolve<T extends PropertyKey[][], Acc extends PropertyKey[]> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectManyResolve<R, TSetIntersect<Acc, L>> : Acc);
|
|
23
|
+
export type TSetIntersectMany<T extends PropertyKey[][]> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectManyResolve<R, L> : []);
|
|
21
24
|
export declare function SetIntersectMany<T extends PropertyKey[][]>(T: [...T]): TSetIntersectMany<T>;
|
|
22
25
|
export type TSetUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetUnionMany<R, TSetUnion<Acc, L>> : Acc);
|
|
23
26
|
/** Returns the Union of multiple sets */
|
|
24
27
|
export declare function SetUnionMany<T extends PropertyKey[][]>(T: [...T]): TSetUnionMany<T>;
|
|
28
|
+
export {};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.SetUnionMany = exports.SetIntersectMany = exports.SetComplement = exports.SetUnion = exports.SetIntersect = exports.SetDistinct = exports.SetIsSubset = exports.SetIncludes = void 0;
|
|
5
|
-
/** Returns true if element
|
|
5
|
+
/** Returns true if element right is in the set of left */
|
|
6
6
|
// prettier-ignore
|
|
7
7
|
function SetIncludes(T, S) {
|
|
8
8
|
return T.includes(S);
|
|
9
9
|
}
|
|
10
10
|
exports.SetIncludes = SetIncludes;
|
|
11
|
-
/** Returns true if
|
|
11
|
+
/** Returns true if left is a subset of right */
|
|
12
12
|
function SetIsSubset(T, S) {
|
|
13
13
|
return T.every((L) => SetIncludes(S, L));
|
|
14
14
|
}
|
|
@@ -34,10 +34,20 @@ function SetComplement(T, S) {
|
|
|
34
34
|
return T.filter(L => !S.includes(L));
|
|
35
35
|
}
|
|
36
36
|
exports.SetComplement = SetComplement;
|
|
37
|
-
|
|
37
|
+
// prettier-ignore
|
|
38
|
+
function SetIntersectManyResolve(T, Init) {
|
|
39
|
+
return T.reduce((Acc, L) => {
|
|
40
|
+
return SetIntersect(Acc, L);
|
|
41
|
+
}, Init);
|
|
42
|
+
}
|
|
38
43
|
// prettier-ignore
|
|
39
44
|
function SetIntersectMany(T) {
|
|
40
|
-
return (T.length === 1
|
|
45
|
+
return (T.length === 1
|
|
46
|
+
? T[0]
|
|
47
|
+
// Use left to initialize the accumulator for resolve
|
|
48
|
+
: T.length > 1
|
|
49
|
+
? SetIntersectManyResolve(T.slice(1), T[0])
|
|
50
|
+
: []);
|
|
41
51
|
}
|
|
42
52
|
exports.SetIntersectMany = SetIntersectMany;
|
|
43
53
|
/** Returns the Union of multiple sets */
|
|
@@ -71,7 +71,7 @@ export declare class JsonTypeBuilder {
|
|
|
71
71
|
/** `[Json]` Intrinsic function to Capitalize LiteralString types */
|
|
72
72
|
Capitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TCapitalize<T>;
|
|
73
73
|
/** `[Json]` Creates a Composite object type */
|
|
74
|
-
Composite<T extends
|
|
74
|
+
Composite<T extends TSchema[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
|
|
75
75
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
76
76
|
Const</* const (not supported in 4.0) */ T>(value: T, options?: SchemaOptions): TConst<T>;
|
|
77
77
|
/** `[Json]` Creates a dereferenced type */
|
|
@@ -87,8 +87,8 @@ class JsonTypeBuilder {
|
|
|
87
87
|
return (0, index_14.Capitalize)(schema, options);
|
|
88
88
|
}
|
|
89
89
|
/** `[Json]` Creates a Composite object type */
|
|
90
|
-
Composite(
|
|
91
|
-
return (0, index_4.Composite)(
|
|
90
|
+
Composite(schemas, options) {
|
|
91
|
+
return (0, index_4.Composite)(schemas, options); // (error) TS 5.4.0-dev - review TComposite implementation
|
|
92
92
|
}
|
|
93
93
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
94
94
|
Const(value, options = {}) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -53,7 +53,7 @@ type T = Static<typeof T> // type T = {
|
|
|
53
53
|
|
|
54
54
|
TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
|
|
55
55
|
|
|
56
|
-
This library is designed to
|
|
56
|
+
This library is designed to allow Json Schema to compose with the same flexibility as TypeScript's programmable type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
|
|
57
57
|
|
|
58
58
|
License MIT
|
|
59
59
|
|
|
@@ -1814,4 +1814,4 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
|
|
|
1814
1814
|
|
|
1815
1815
|
## Contribute
|
|
1816
1816
|
|
|
1817
|
-
TypeBox is open to community contribution. Please ensure you submit an open issue before submitting your pull request. The TypeBox project
|
|
1817
|
+
TypeBox is open to community contribution. Please ensure you submit an open issue before submitting your pull request. The TypeBox project prefers open community discussion before accepting new features.
|