@depup/typebox 1.3.9-depup.0 → 1.3.14-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/format/date.d.mts +1 -1
- package/build/format/date.mjs +1 -1
- package/build/format/date_time.d.mts +2 -2
- package/build/format/date_time.mjs +3 -3
- package/build/format/email.d.mts +1 -1
- package/build/format/email.mjs +2 -2
- package/build/format/hostname.mjs +2 -10
- package/build/format/idn_email.d.mts +1 -1
- package/build/format/idn_email.mjs +3 -3
- package/build/format/idn_hostname.d.mts +1 -0
- package/build/format/idn_hostname.mjs +3 -11
- package/build/format/idna/format/bidi.d.mts +3 -0
- package/build/format/idna/format/bidi.mjs +98 -0
- package/build/format/idna/format/puny.d.mts +3 -0
- package/build/format/idna/format/puny.mjs +144 -0
- package/build/format/idna/hostname.d.mts +1 -0
- package/build/format/idna/hostname.mjs +16 -0
- package/build/format/idna/idn-hostname.d.mts +1 -0
- package/build/format/idna/idn-hostname.mjs +23 -0
- package/build/format/idna/index.d.mts +2 -0
- package/build/format/idna/index.mjs +2 -0
- package/build/format/idna/label/ascii.d.mts +1 -0
- package/build/format/idna/label/ascii.mjs +9 -0
- package/build/format/idna/label/puny.d.mts +1 -0
- package/build/format/idna/label/puny.mjs +28 -0
- package/build/format/idna/label/unicode.d.mts +1 -0
- package/build/format/idna/label/unicode.mjs +106 -0
- package/build/format/idna/pattern/pattern.d.mts +30 -0
- package/build/format/idna/pattern/pattern.mjs +70 -0
- package/build/format/ipv4.d.mts +0 -1
- package/build/format/ipv4.mjs +2 -32
- package/build/format/ipv6.mjs +2 -61
- package/build/format/iri.d.mts +2 -2
- package/build/format/iri.mjs +26 -8
- package/build/format/iri_reference.d.mts +2 -2
- package/build/format/iri_reference.mjs +9 -55
- package/build/format/regex.d.mts +1 -2
- package/build/format/regex.mjs +2 -6
- package/build/format/time.d.mts +2 -2
- package/build/format/time.mjs +19 -14
- package/build/format/uri.d.mts +1 -1
- package/build/format/uri.mjs +3 -130
- package/build/format/uri_reference.d.mts +1 -1
- package/build/format/uri_reference.mjs +2 -3
- package/build/format/uri_template.d.mts +2 -3
- package/build/format/uri_template.mjs +4 -5
- package/build/format/url.d.mts +3 -3
- package/build/format/url.mjs +4 -5
- package/build/guard/guard.mjs +2 -2
- package/build/guard/string.d.mts +2 -2
- package/build/guard/string.mjs +7 -7
- package/build/schema/engine/_regexp.d.mts +2 -0
- package/build/schema/engine/_regexp.mjs +4 -0
- package/build/schema/engine/_stack.mjs +1 -1
- package/build/schema/engine/additionalProperties.mjs +4 -3
- package/build/schema/engine/pattern.mjs +3 -2
- package/build/schema/engine/patternProperties.mjs +4 -3
- package/build/schema/engine/schema.mjs +13 -4
- package/build/schema/resolve/ref.d.mts +1 -0
- package/build/schema/resolve/ref.mjs +13 -3
- package/build/schema/types/index.d.mts +0 -2
- package/build/schema/types/index.mjs +0 -2
- package/build/system/memory/clone.mjs +14 -11
- package/build/system/memory/discard.mjs +6 -5
- package/build/system/settings/settings.d.mts +9 -0
- package/build/system/settings/settings.mjs +2 -0
- package/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/build/type/engine/call/instantiate.mjs +34 -4
- package/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/build/type/engine/evaluate/broaden.mjs +20 -26
- package/build/type/engine/evaluate/compare.d.mts +6 -10
- package/build/type/engine/evaluate/compare.mjs +9 -13
- package/build/type/engine/evaluate/composite.d.mts +7 -4
- package/build/type/engine/evaluate/composite.mjs +12 -19
- package/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/build/type/engine/evaluate/distribute.mjs +8 -20
- package/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/build/type/engine/evaluate/flatten.mjs +3 -4
- package/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/build/type/engine/evaluate/narrow.mjs +26 -6
- package/build/type/engine/exclude/operation.mjs +3 -4
- package/build/type/engine/extract/operation.d.mts +1 -1
- package/build/type/engine/extract/operation.mjs +3 -4
- package/build/type/engine/priority/priority.d.mts +2 -2
- package/build/type/engine/priority/priority.mjs +3 -4
- package/build/type/script/parser.mjs +8 -1
- package/changes.json +1 -1
- package/package.json +3 -3
- package/readme.md +66 -62
- package/build/format/_idna.d.mts +0 -2
- package/build/format/_idna.mjs +0 -246
- package/build/format/_puny.d.mts +0 -1
- package/build/format/_puny.mjs +0 -77
- package/build/schema/types/contentEncoding.d.mts +0 -9
- package/build/schema/types/contentEncoding.mjs +0 -13
- package/build/schema/types/contentMediaType.d.mts +0 -9
- package/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
|
-
import { IsUnknown } from '../../types/unknown.mjs';
|
|
4
3
|
import { Extends, ExtendsResult } from "../../extends/index.mjs";
|
|
5
4
|
// ------------------------------------------------------------------
|
|
6
5
|
// TCompare
|
|
7
6
|
// ------------------------------------------------------------------
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
7
|
+
export const CompareResultEqual = 0; // 'equal'
|
|
8
|
+
export const CompareResultDisjoint = 1; // 'disjoint'
|
|
9
|
+
export const CompareResultLeftInside = 2; // 'left-inside'
|
|
10
|
+
export const CompareResultRightInside = 3; // 'right-inside'
|
|
12
11
|
/** Compares left and right types and determines their set relationship. */
|
|
13
12
|
export function Compare(left, right) {
|
|
14
|
-
const extendsCheck = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ExtendsResult.IsExtendsTrueLike(extendsCheck[0]) && ExtendsResult.IsExtendsFalse(extendsCheck[1]) ? ResultLeftInside :
|
|
20
|
-
ExtendsResult.IsExtendsFalse(extendsCheck[0]) && ExtendsResult.IsExtendsTrueLike(extendsCheck[1]) ? ResultRightInside :
|
|
21
|
-
ResultDisjoint);
|
|
13
|
+
const extendsCheck = [Extends({}, left, right), Extends({}, right, left)];
|
|
14
|
+
return (ExtendsResult.IsExtendsTrueLike(extendsCheck[0]) && ExtendsResult.IsExtendsTrueLike(extendsCheck[1]) ? CompareResultEqual :
|
|
15
|
+
ExtendsResult.IsExtendsTrueLike(extendsCheck[0]) && ExtendsResult.IsExtendsFalse(extendsCheck[1]) ? CompareResultLeftInside :
|
|
16
|
+
ExtendsResult.IsExtendsFalse(extendsCheck[0]) && ExtendsResult.IsExtendsTrueLike(extendsCheck[1]) ? CompareResultRightInside :
|
|
17
|
+
CompareResultDisjoint);
|
|
22
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type TUnreachable } from '../../../system/unreachable/index.mjs';
|
|
2
1
|
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
3
2
|
import { type TOptional } from '../../types/_optional.mjs';
|
|
4
3
|
import { type TSchema } from '../../types/schema.mjs';
|
|
@@ -12,6 +11,10 @@ import { type TRemoveReadonly } from '../../action/_remove_readonly.mjs';
|
|
|
12
11
|
import { type TRemoveOptional } from '../../action/_remove_optional.mjs';
|
|
13
12
|
import { type TTupleElementsToProperties } from '../tuple/to_object.mjs';
|
|
14
13
|
import { type TEvaluateIntersect } from './evaluate.mjs';
|
|
14
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
15
|
+
export type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
|
|
16
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
17
|
+
export declare function CanComposite<Type extends TSchema>(type: Type): TCanComposite<Type>;
|
|
15
18
|
type TIsReadonlyProperty<Left extends TSchema, Right extends TSchema> = (Left extends TReadonly<Left> ? Right extends TReadonly<Right> ? true : false : false);
|
|
16
19
|
type TIsOptionalProperty<Left extends TSchema, Right extends TSchema> = (Left extends TOptional<Left> ? Right extends TOptional<Right> ? true : false : false);
|
|
17
20
|
type TCompositeProperty<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = TIsReadonlyProperty<Left, Right>, IsOptional extends boolean = TIsOptionalProperty<Left, Right>, Evaluated extends TSchema = TEvaluateIntersect<[Left, Right]>, Property extends TSchema = TRemoveReadonly<TRemoveOptional<Evaluated>>> = ([
|
|
@@ -25,10 +28,10 @@ type TCompositeProperty<Left extends TSchema, Right extends TSchema, IsReadonly
|
|
|
25
28
|
IsOptional
|
|
26
29
|
] extends [false, true] ? TAddOptional<Property> : Property);
|
|
27
30
|
type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TCompositeProperty<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
|
|
28
|
-
type TCompositeProperties<Left extends TProperties, Right extends TProperties, Result extends TProperties = {
|
|
29
|
-
[Key in
|
|
31
|
+
type TCompositeProperties<Left extends TProperties, Right extends TProperties, Keys extends PropertyKey = keyof (Left & Right), Result extends TProperties = {
|
|
32
|
+
[Key in Keys]: TCompositePropertyKey<Left, Right, Key>;
|
|
30
33
|
}> = Result;
|
|
31
|
-
type TGetProperties<Type extends TSchema, Result extends TProperties = (Type extends TObject<infer Properties extends TProperties> ? Properties : Type extends TTuple<infer Types extends TSchema[]> ? TTupleElementsToProperties<Types> :
|
|
34
|
+
type TGetProperties<Type extends TSchema, Result extends TProperties = (Type extends TObject<infer Properties extends TProperties> ? Properties : Type extends TTuple<infer Types extends TSchema[]> ? TTupleElementsToProperties<Types> : {})> = Result;
|
|
32
35
|
export type TComposite<Left extends TSchema, Right extends TSchema, LeftProperties extends TProperties = TGetProperties<Left>, RightProperties extends TProperties = TGetProperties<Right>, Properties extends TProperties = TCompositeProperties<LeftProperties, RightProperties>, Result extends TSchema = TObject<Properties>> = Result;
|
|
33
36
|
export declare function Composite<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TComposite<Left, Right>;
|
|
34
37
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
|
-
import { Unreachable } from '../../../system/unreachable/index.mjs';
|
|
4
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
5
4
|
import { IsReadonly } from '../../types/_readonly.mjs';
|
|
6
5
|
import { IsOptional } from '../../types/_optional.mjs';
|
|
@@ -13,6 +12,10 @@ import { RemoveReadonly } from '../../action/_remove_readonly.mjs';
|
|
|
13
12
|
import { RemoveOptional } from '../../action/_remove_optional.mjs';
|
|
14
13
|
import { TupleElementsToProperties } from '../tuple/to_object.mjs';
|
|
15
14
|
import { EvaluateIntersect } from './evaluate.mjs';
|
|
15
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
16
|
+
export function CanComposite(type) {
|
|
17
|
+
return (IsObject(type) || IsTuple(type));
|
|
18
|
+
}
|
|
16
19
|
function IsReadonlyProperty(left, right) {
|
|
17
20
|
return (IsReadonly(left) ? IsReadonly(right) ? true : false : false);
|
|
18
21
|
}
|
|
@@ -32,36 +35,26 @@ function CompositeProperty(left, right) {
|
|
|
32
35
|
}
|
|
33
36
|
function CompositePropertyKey(left, right, key) {
|
|
34
37
|
return (key in left
|
|
35
|
-
? key in right
|
|
36
|
-
|
|
37
|
-
: left[key]
|
|
38
|
-
: key in right
|
|
39
|
-
? right[key]
|
|
40
|
-
: Never());
|
|
38
|
+
? key in right ? CompositeProperty(left[key], right[key]) : left[key]
|
|
39
|
+
: key in right ? right[key] : Never());
|
|
41
40
|
}
|
|
42
41
|
function CompositeProperties(left, right) {
|
|
43
|
-
const keys = new Set([...Guard.Keys(
|
|
44
|
-
|
|
42
|
+
const keys = new Set([...Guard.Keys(left), ...Guard.Keys(right)]);
|
|
43
|
+
const result = [...keys].reduce((result, key) => {
|
|
45
44
|
return { ...result, [key]: CompositePropertyKey(left, right, key) };
|
|
46
45
|
}, {});
|
|
46
|
+
return result;
|
|
47
47
|
}
|
|
48
|
-
// ------------------------------------------------------------------
|
|
49
|
-
// deno-coverage-ignore-start - symmetric unreachable | internal
|
|
50
|
-
//
|
|
51
|
-
// Composite is called by Distribute which provisions the type as
|
|
52
|
-
// either TObject ot TTuple. Fall-through unreachable.
|
|
53
|
-
//
|
|
54
|
-
// ------------------------------------------------------------------
|
|
55
48
|
function GetProperties(type) {
|
|
56
49
|
const result = (IsObject(type) ? type.properties :
|
|
57
50
|
IsTuple(type) ? TupleElementsToProperties(type.items) :
|
|
58
|
-
|
|
59
|
-
);
|
|
51
|
+
{});
|
|
60
52
|
return result;
|
|
61
53
|
}
|
|
62
54
|
export function Composite(left, right) {
|
|
63
55
|
const leftProperties = GetProperties(left);
|
|
64
56
|
const rightProperties = GetProperties(right);
|
|
65
57
|
const properties = CompositeProperties(leftProperties, rightProperties);
|
|
66
|
-
|
|
58
|
+
const result = Object(properties);
|
|
59
|
+
return result;
|
|
67
60
|
}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
-
import { type TProperties } from '../../types/properties.mjs';
|
|
3
2
|
import { type TUnion } from '../../types/union.mjs';
|
|
4
|
-
import { type TObject } from '../../types/object.mjs';
|
|
5
|
-
import { type TTuple } from '../../types/tuple.mjs';
|
|
6
|
-
import { type TComposite } from './composite.mjs';
|
|
7
3
|
import { type TNarrow } from './narrow.mjs';
|
|
8
|
-
import { type TEvaluateType } from './evaluate.mjs';
|
|
9
4
|
import { type TEvaluateIntersect } from './evaluate.mjs';
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
type TDistributeOperation<Left extends TSchema, Right extends TSchema, EvaluatedLeft extends TSchema = TEvaluateType<Left>, EvaluatedRight extends TSchema = TEvaluateType<Right>,
|
|
13
|
-
|
|
14
|
-
] extends [true] ? TEvaluateIntersect<[EvaluatedLeft, EvaluatedRight]> : [
|
|
15
|
-
IsObjectLeft,
|
|
16
|
-
IsObjectRight
|
|
17
|
-
] extends [true, true] ? TComposite<EvaluatedLeft, EvaluatedRight> : [
|
|
18
|
-
IsObjectLeft,
|
|
19
|
-
IsObjectRight
|
|
20
|
-
] extends [true, false] ? EvaluatedLeft : [
|
|
21
|
-
IsObjectLeft,
|
|
22
|
-
IsObjectRight
|
|
23
|
-
] extends [false, true] ? EvaluatedRight : TNarrow<EvaluatedLeft, EvaluatedRight>)> = Result;
|
|
24
|
-
type TDistributeType<Type extends TSchema, Distribution extends TSchema[], Result extends TSchema[] = []> = (Distribution extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDistributeType<Type, Right, [...Result, TDistributeOperation<Type, Left>]> : Result extends [] ? [Type] : Result);
|
|
5
|
+
import { type TEvaluateType } from './evaluate.mjs';
|
|
6
|
+
type TShouldEvaluate<Left extends TSchema, Right extends TSchema, IsUnionLeft extends boolean = Left extends TUnion ? true : false, IsUnionRight extends boolean = Right extends TUnion ? true : false, Result extends boolean = IsUnionLeft extends true ? true : IsUnionRight extends true ? true : false> = Result;
|
|
7
|
+
type TDistributeOperation<Left extends TSchema, Right extends TSchema, EvaluatedLeft extends TSchema = TEvaluateType<Left>, EvaluatedRight extends TSchema = TEvaluateType<Right>, ShouldEvaluate extends boolean = TShouldEvaluate<EvaluatedLeft, EvaluatedRight>, Result extends TSchema = [ShouldEvaluate] extends [true] ? TEvaluateIntersect<[EvaluatedLeft, EvaluatedRight]> : TNarrow<EvaluatedLeft, EvaluatedRight>> = Result;
|
|
8
|
+
type TDistributeType<Type extends TSchema, Distribution extends TSchema[], Result extends TSchema[] = []> = (Distribution extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDistributeType<Type, Right, [...Result, TDistributeOperation<Left, Type>]> : Result extends [] ? [Type] : Result);
|
|
25
9
|
type TDistributeUnion<Types extends TSchema[], Distribution extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDistributeUnion<Right, Distribution, [...Result, ...TDistribute<[Left], Distribution>]> : Result);
|
|
26
10
|
export type TDistribute<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TUnion<infer UnionTypes extends TSchema[]> ? TDistribute<Right, TDistributeUnion<UnionTypes, Result>> : TDistribute<Right, TDistributeType<Left, Result>> : Result);
|
|
27
11
|
export declare function Distribute<Types extends TSchema[]>(types: [...Types], result?: TSchema[]): TDistribute<Types>;
|
|
@@ -2,36 +2,24 @@
|
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
4
4
|
import { IsUnion } from '../../types/union.mjs';
|
|
5
|
-
import { IsObject } from '../../types/object.mjs';
|
|
6
|
-
import { IsTuple } from '../../types/tuple.mjs';
|
|
7
|
-
import { Composite } from './composite.mjs';
|
|
8
5
|
import { Narrow } from './narrow.mjs';
|
|
9
|
-
import { EvaluateType } from './evaluate.mjs';
|
|
10
6
|
import { EvaluateIntersect } from './evaluate.mjs';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function IsUnionOperand(left, right) {
|
|
15
|
-
const isUnionLeft = IsUnion(left);
|
|
16
|
-
const isUnionRight = IsUnion(right);
|
|
17
|
-
const result = isUnionLeft || isUnionRight;
|
|
7
|
+
import { EvaluateType } from './evaluate.mjs';
|
|
8
|
+
function ShouldEvaluate(left, right) {
|
|
9
|
+
const result = IsUnion(left) || IsUnion(right);
|
|
18
10
|
return result;
|
|
19
11
|
}
|
|
20
12
|
function DistributeOperation(left, right) {
|
|
21
13
|
const evaluatedLeft = EvaluateType(left);
|
|
22
14
|
const evaluatedRight = EvaluateType(right);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isObjectLeft && IsObjectRight ? Composite(evaluatedLeft, evaluatedRight) :
|
|
28
|
-
isObjectLeft && !IsObjectRight ? evaluatedLeft :
|
|
29
|
-
!isObjectLeft && IsObjectRight ? evaluatedRight :
|
|
30
|
-
Narrow(evaluatedLeft, evaluatedRight));
|
|
15
|
+
const shouldEvaluate = ShouldEvaluate(evaluatedLeft, evaluatedRight);
|
|
16
|
+
const result = shouldEvaluate
|
|
17
|
+
? EvaluateIntersect([evaluatedLeft, evaluatedRight])
|
|
18
|
+
: Narrow(evaluatedLeft, evaluatedRight);
|
|
31
19
|
return result;
|
|
32
20
|
}
|
|
33
21
|
function DistributeType(type, types, result = []) {
|
|
34
|
-
return Guard.ShiftLeft(types, (left, right) => DistributeType(type, right, [...result, DistributeOperation(
|
|
22
|
+
return Guard.ShiftLeft(types, (left, right) => DistributeType(type, right, [...result, DistributeOperation(left, type)]), () => Guard.IsEqual(result.length, 0)
|
|
35
23
|
? [type]
|
|
36
24
|
: result);
|
|
37
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TDependent } from '../../types/dependent.mjs';
|
|
3
3
|
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
4
|
-
import { type TLiteral } from '../../types/literal.mjs';
|
|
5
4
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
5
|
+
import { type TLiteral } from '../../types/literal.mjs';
|
|
6
6
|
import { type TNever } from '../../types/never.mjs';
|
|
7
7
|
import { type TTemplateLiteral } from '../../types/template_literal.mjs';
|
|
8
8
|
import { type TUnion } from '../../types/union.mjs';
|
|
@@ -10,11 +10,11 @@ import { type TDistribute } from './distribute.mjs';
|
|
|
10
10
|
import { type TBroaden } from './broaden.mjs';
|
|
11
11
|
import { type TExcludeOperation } from '../exclude/operation.mjs';
|
|
12
12
|
import { type TTemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
13
|
-
export type TEvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema,
|
|
13
|
+
export type TEvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema, Intersected extends TSchema = TEvaluateIntersect<[If, Then]>, Excluded extends TSchema = TExcludeOperation<Else, If>, Result extends TSchema = TEvaluateUnion<[Intersected, Excluded]>> = Result;
|
|
14
14
|
export declare function EvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema>(if_: If, then_: Then, else_: Else): TEvaluateDependent<If, Then, Else>;
|
|
15
15
|
export type TEvaluateEnum<Values extends TEnumValue[], Result extends TSchema[] = []> = (Values extends [infer Left extends TEnumValue, ...infer Right extends TEnumValue[]] ? TEvaluateEnum<Right, [...Result, TLiteral<Left>]> : TEvaluateUnion<Result>);
|
|
16
|
-
export declare function EvaluateEnum<Values extends TEnumValue[]>(values: [...Values]): TEvaluateEnum<Values>;
|
|
17
|
-
export type TEvaluateIntersect<Types extends TSchema[], Distribution extends TSchema[] = TDistribute<Types>, Broadend extends TSchema[] = TBroaden<Distribution>, Result extends TSchema =
|
|
16
|
+
export declare function EvaluateEnum<Values extends TEnumValue[]>(values: [...Values], result?: TSchema[]): TEvaluateEnum<Values>;
|
|
17
|
+
export type TEvaluateIntersect<Types extends TSchema[], Distribution extends TSchema[] = TDistribute<Types>, Broadend extends TSchema[] = TBroaden<Distribution>, Result extends TSchema = TEvaluateUnion<Broadend>> = Result;
|
|
18
18
|
export declare function EvaluateIntersect<Types extends TSchema[]>(types: [...Types]): TEvaluateIntersect<Types>;
|
|
19
19
|
export type TEvaluateTemplateLiteral<Pattern extends string, Evaluated extends TSchema = TTemplateLiteralDecode<Pattern>, Result extends TSchema = TEvaluateType<Evaluated>> = Result;
|
|
20
20
|
export declare function EvaluateTemplateLiteral<Pattern extends string>(pattern: Pattern): TEvaluateTemplateLiteral<Pattern>;
|
|
@@ -2,29 +2,31 @@
|
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { IsDependent } from '../../types/dependent.mjs';
|
|
4
4
|
import { IsEnum } from '../../types/enum.mjs';
|
|
5
|
+
import { IsIntersect } from '../../types/intersect.mjs';
|
|
5
6
|
import { Literal } from '../../types/literal.mjs';
|
|
6
|
-
import { IsIntersect, Intersect } from '../../types/intersect.mjs';
|
|
7
7
|
import { Never } from '../../types/never.mjs';
|
|
8
8
|
import { IsTemplateLiteral } from '../../types/template_literal.mjs';
|
|
9
9
|
import { Union, IsUnion } from '../../types/union.mjs';
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
// Infrastructure
|
|
12
|
+
// ------------------------------------------------------------------
|
|
10
13
|
import { Distribute } from './distribute.mjs';
|
|
11
14
|
import { Broaden } from './broaden.mjs';
|
|
12
15
|
import { ExcludeOperation } from '../exclude/operation.mjs';
|
|
13
16
|
import { TemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
14
17
|
export function EvaluateDependent(if_, then_, else_) {
|
|
15
|
-
const
|
|
18
|
+
const intersected = EvaluateIntersect([if_, then_]);
|
|
16
19
|
const excluded = ExcludeOperation(else_, if_);
|
|
17
|
-
const result = EvaluateUnion([
|
|
20
|
+
const result = EvaluateUnion([intersected, excluded]);
|
|
18
21
|
return result;
|
|
19
22
|
}
|
|
20
|
-
export function EvaluateEnum(values) {
|
|
21
|
-
|
|
22
|
-
return EvaluateUnion(result);
|
|
23
|
+
export function EvaluateEnum(values, result = []) {
|
|
24
|
+
return Guard.ShiftLeft(values, (left, right) => EvaluateEnum(right, [...result, Literal(left)]), () => EvaluateUnion(result));
|
|
23
25
|
}
|
|
24
26
|
export function EvaluateIntersect(types) {
|
|
25
27
|
const distribution = Distribute(types);
|
|
26
28
|
const broadend = Broaden(distribution);
|
|
27
|
-
const result =
|
|
29
|
+
const result = EvaluateUnion(broadend);
|
|
28
30
|
return result;
|
|
29
31
|
}
|
|
30
32
|
export function EvaluateTemplateLiteral(pattern) {
|
|
@@ -38,12 +40,13 @@ export function EvaluateUnion(types) {
|
|
|
38
40
|
return result;
|
|
39
41
|
}
|
|
40
42
|
export function EvaluateType(type) {
|
|
41
|
-
|
|
43
|
+
const result = (IsDependent(type) ? EvaluateDependent(type.if, type.then, type.else) :
|
|
42
44
|
IsEnum(type) ? EvaluateEnum(type.enum) :
|
|
43
45
|
IsIntersect(type) ? EvaluateIntersect(type.allOf) :
|
|
44
46
|
IsTemplateLiteral(type) ? EvaluateTemplateLiteral(type.pattern) :
|
|
45
47
|
IsUnion(type) ? EvaluateUnion(type.anyOf) :
|
|
46
48
|
type);
|
|
49
|
+
return result;
|
|
47
50
|
}
|
|
48
51
|
export function EvaluateUnionFast(types) {
|
|
49
52
|
const result = (Guard.IsEqual(types.length, 1) ? types[0] :
|
|
@@ -2,5 +2,5 @@ import { type TSchema } from '../../types/schema.mjs';
|
|
|
2
2
|
import { type TUnion } from '../../types/union.mjs';
|
|
3
3
|
type TFlattenType<Type extends TSchema, Result extends TSchema[] = Type extends TUnion<infer Types extends TSchema[]> ? TFlatten<Types> : [Type]> = Result;
|
|
4
4
|
export type TFlatten<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFlatten<Right, [...Result, ...TFlattenType<Left>]> : Result);
|
|
5
|
-
export declare function Flatten<Types extends TSchema[]>(types: [...Types]): TFlatten<Types>;
|
|
5
|
+
export declare function Flatten<Types extends TSchema[]>(types: [...Types], result?: TSchema[]): TFlatten<Types>;
|
|
6
6
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
2
3
|
import { IsUnion } from '../../types/union.mjs';
|
|
3
4
|
function FlattenType(type) {
|
|
4
5
|
const result = IsUnion(type) ? Flatten(type.anyOf) : [type];
|
|
5
6
|
return result;
|
|
6
7
|
}
|
|
7
|
-
export function Flatten(types) {
|
|
8
|
-
return
|
|
9
|
-
return [...result, ...FlattenType(type)];
|
|
10
|
-
}, []);
|
|
8
|
+
export function Flatten(types, result = []) {
|
|
9
|
+
return Guard.ShiftLeft(types, (left, right) => Flatten(right, [...result, ...FlattenType(left)]), () => result);
|
|
11
10
|
}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TAny } from '../../types/any.mjs';
|
|
2
3
|
import { type TNever } from '../../types/never.mjs';
|
|
3
|
-
import { type
|
|
4
|
-
|
|
4
|
+
import { type TUnknown } from '../../types/unknown.mjs';
|
|
5
|
+
import { type TCompare, type TCompareResult, CompareResultLeftInside, CompareResultRightInside, CompareResultEqual } from './compare.mjs';
|
|
6
|
+
import { type TComposite, type TCanComposite } from './composite.mjs';
|
|
7
|
+
type TNarrowCompareRule<Left extends TSchema, Right extends TSchema, Result extends TCompareResult = TCompare<Left, Right>> = (Result extends typeof CompareResultLeftInside ? Left : Result extends typeof CompareResultRightInside ? Right : Result extends typeof CompareResultEqual ? Right : TNever);
|
|
8
|
+
type TNarrowCompositeRule<Left extends TSchema, Right extends TSchema, CanCompositeLeft extends boolean = TCanComposite<Left>, CanCompositeRight extends boolean = TCanComposite<Right>> = ([
|
|
9
|
+
CanCompositeLeft,
|
|
10
|
+
CanCompositeRight
|
|
11
|
+
] extends [true, true] ? TComposite<Left, Right> : [
|
|
12
|
+
CanCompositeLeft,
|
|
13
|
+
CanCompositeRight
|
|
14
|
+
] extends [true, false] ? Left : [
|
|
15
|
+
CanCompositeLeft,
|
|
16
|
+
CanCompositeRight
|
|
17
|
+
] extends [false, true] ? Right : TNarrowCompareRule<Left, Right>);
|
|
18
|
+
export type TNarrow<Left extends TSchema, Right extends TSchema> = (Left extends TNever ? TNever : Left extends TAny ? TAny : Left extends TUnknown ? Right : Right extends TNever ? TNever : Right extends TAny ? TAny : Right extends TUnknown ? Left : TNarrowCompositeRule<Left, Right>);
|
|
5
19
|
export declare function Narrow<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TNarrow<Left, Right>;
|
|
20
|
+
export {};
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { IsAny } from '../../types/any.mjs';
|
|
4
|
+
import { Never, IsNever } from '../../types/never.mjs';
|
|
5
|
+
import { IsUnknown } from '../../types/unknown.mjs';
|
|
6
|
+
import { Compare, CompareResultLeftInside, CompareResultRightInside, CompareResultEqual } from './compare.mjs';
|
|
7
|
+
import { Composite, CanComposite } from './composite.mjs';
|
|
8
|
+
function NarrowCompareRule(left, right) {
|
|
6
9
|
const result = Compare(left, right);
|
|
7
|
-
return (Guard.IsEqual(result,
|
|
8
|
-
Guard.IsEqual(result,
|
|
9
|
-
Guard.IsEqual(result,
|
|
10
|
+
return (Guard.IsEqual(result, CompareResultLeftInside) ? left :
|
|
11
|
+
Guard.IsEqual(result, CompareResultRightInside) ? right :
|
|
12
|
+
Guard.IsEqual(result, CompareResultEqual) ? right :
|
|
10
13
|
Never());
|
|
11
14
|
}
|
|
15
|
+
function NarrowCompositeRule(left, right) {
|
|
16
|
+
const canCompositeLeft = CanComposite(left);
|
|
17
|
+
const canCompositeRight = CanComposite(right);
|
|
18
|
+
return (canCompositeLeft && canCompositeRight ? Composite(left, right) :
|
|
19
|
+
canCompositeLeft && !canCompositeRight ? left :
|
|
20
|
+
!canCompositeLeft && canCompositeRight ? right :
|
|
21
|
+
NarrowCompareRule(left, right));
|
|
22
|
+
}
|
|
23
|
+
export function Narrow(left, right) {
|
|
24
|
+
return (IsNever(left) ? left :
|
|
25
|
+
IsAny(left) ? left :
|
|
26
|
+
IsUnknown(left) ? right :
|
|
27
|
+
IsNever(right) ? right :
|
|
28
|
+
IsAny(right) ? right :
|
|
29
|
+
IsUnknown(right) ? left :
|
|
30
|
+
NarrowCompositeRule(left, right));
|
|
31
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
3
4
|
import { IsUnion } from '../../types/union.mjs';
|
|
4
5
|
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
5
6
|
import { EvaluateType } from '../evaluate/evaluate.mjs';
|
|
@@ -9,10 +10,8 @@ function ExcludeType(left, right) {
|
|
|
9
10
|
const result = ExtendsResult.IsExtendsTrueLike(check) ? [] : [left];
|
|
10
11
|
return result;
|
|
11
12
|
}
|
|
12
|
-
function ExcludeUnion(
|
|
13
|
-
return
|
|
14
|
-
return [...result, ...ExcludeType(head, right)];
|
|
15
|
-
}, []);
|
|
13
|
+
function ExcludeUnion(left, right, result = []) {
|
|
14
|
+
return Guard.ShiftLeft(left, (head, tail) => ExcludeUnion(tail, right, [...result, ...ExcludeType(head, right)]), () => result);
|
|
16
15
|
}
|
|
17
16
|
export function ExcludeOperation(left, right) {
|
|
18
17
|
const evaluated = EvaluateType(left);
|
|
@@ -4,7 +4,7 @@ import { type TExtends, ExtendsResult } from '../../extends/index.mjs';
|
|
|
4
4
|
import { type TEvaluateType } from '../evaluate/evaluate.mjs';
|
|
5
5
|
import { type TEvaluateUnion } from '../evaluate/evaluate.mjs';
|
|
6
6
|
type TExtractType<Left extends TSchema, Right extends TSchema, Check extends ExtendsResult.TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends ExtendsResult.TExtendsTrueLike ? [Left] : []> = Result;
|
|
7
|
-
type TExtractUnion<
|
|
7
|
+
type TExtractUnion<Left extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtractUnion<Tail, Right, [...Result, ...TExtractType<Head, Right>]> : Result);
|
|
8
8
|
export type TExtractOperation<Left extends TSchema, Right extends TSchema, Evaluated extends TSchema = TEvaluateType<Left>, Canonical extends TSchema[] = Evaluated extends TUnion<infer Types extends TSchema[]> ? Types : [Evaluated], Remaining extends TSchema[] = TExtractUnion<Canonical, Right>, Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
9
9
|
export declare function ExtractOperation<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TExtractOperation<Left, Right>;
|
|
10
10
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
|
+
import { Guard } from '../../../guard/index.mjs';
|
|
3
4
|
import { IsUnion } from '../../types/union.mjs';
|
|
4
5
|
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
5
6
|
import { EvaluateType } from '../evaluate/evaluate.mjs';
|
|
@@ -9,10 +10,8 @@ function ExtractType(left, right) {
|
|
|
9
10
|
const result = ExtendsResult.IsExtendsTrueLike(check) ? [left] : [];
|
|
10
11
|
return result;
|
|
11
12
|
}
|
|
12
|
-
function ExtractUnion(
|
|
13
|
-
return
|
|
14
|
-
return [...result, ...ExtractType(head, right)];
|
|
15
|
-
}, []);
|
|
13
|
+
function ExtractUnion(left, right, result = []) {
|
|
14
|
+
return Guard.ShiftLeft(left, (head, tail) => ExtractUnion(tail, right, [...result, ...ExtractType(head, right)]), () => result);
|
|
16
15
|
}
|
|
17
16
|
export function ExtractOperation(left, right) {
|
|
18
17
|
const evaluated = EvaluateType(left);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
-
import { type TCompare, type TCompareResult } from '../evaluate/compare.mjs';
|
|
3
|
-
type TComparer<Left extends TSchema, Right extends TSchema, CompareResult extends TCompareResult = TCompare<Left, Right>, Result extends 0 | 1 = (CompareResult extends
|
|
2
|
+
import { type TCompare, type TCompareResult, CompareResultRightInside, CompareResultDisjoint } from '../evaluate/compare.mjs';
|
|
3
|
+
type TComparer<Left extends TSchema, Right extends TSchema, CompareResult extends TCompareResult = TCompare<Left, Right>, Result extends 0 | 1 = (CompareResult extends typeof CompareResultRightInside ? 1 : CompareResult extends typeof CompareResultDisjoint ? 1 : 0)> = Result;
|
|
4
4
|
type TInsert<Type extends TSchema, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TComparer<Type, Left> extends 1 ? TInsert<Type, Right, [...Result, Left]> : [...Result, Type, ...Types] : [...Result, Type]);
|
|
5
5
|
type TSort<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TSort<Right, TInsert<Left, Result>> : Result);
|
|
6
6
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
-
import { Compare } from '../evaluate/compare.mjs';
|
|
3
|
+
import { Compare, CompareResultRightInside, CompareResultDisjoint } from '../evaluate/compare.mjs';
|
|
4
4
|
function Comparer(left, right) {
|
|
5
5
|
const compareResult = Compare(left, right);
|
|
6
|
-
|
|
7
|
-
Guard.IsEqual(compareResult,
|
|
6
|
+
return (Guard.IsEqual(compareResult, CompareResultRightInside) ? 1 :
|
|
7
|
+
Guard.IsEqual(compareResult, CompareResultDisjoint) ? 1 :
|
|
8
8
|
0);
|
|
9
|
-
return result;
|
|
10
9
|
}
|
|
11
10
|
function Insert(type, types, result = []) {
|
|
12
11
|
return Guard.ShiftLeft(types, (left, right) => Guard.IsEqual(Comparer(type, left), 1)
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// deno-lint-ignore-file
|
|
3
|
-
//
|
|
3
|
+
// ------------------------------------------------------------------
|
|
4
|
+
//
|
|
5
|
+
// This module was auto-generated by TypeBox's parser compiler
|
|
6
|
+
// infrastructure (ParseBox). The source grammar is located at:
|
|
7
|
+
//
|
|
8
|
+
// Source: ./design/syntax/syntax.ts
|
|
9
|
+
//
|
|
10
|
+
// ------------------------------------------------------------------
|
|
4
11
|
import * as S from './mapping.mjs';
|
|
5
12
|
import * as Token from './token/index.mjs';
|
|
6
13
|
const If = (result, left, right = () => []) => result.length === 2 ? left(result) : right();
|
package/changes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/typebox",
|
|
3
3
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript (with updated dependencies)",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.14-depup.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typebox",
|
|
7
7
|
"depup",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"changes": {},
|
|
95
95
|
"depsUpdated": 0,
|
|
96
96
|
"originalPackage": "typebox",
|
|
97
|
-
"originalVersion": "1.3.
|
|
98
|
-
"processedAt": "2026-08-
|
|
97
|
+
"originalVersion": "1.3.14",
|
|
98
|
+
"processedAt": "2026-08-16T00:27:33.089Z",
|
|
99
99
|
"smokeTest": "passed"
|
|
100
100
|
}
|
|
101
101
|
}
|