typebox 1.2.18 → 1.3.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.
Files changed (152) hide show
  1. package/build/compile/validator.d.mts +2 -7
  2. package/build/compile/validator.mjs +6 -36
  3. package/build/error/errors.d.mts +1 -7
  4. package/build/guard/emit.d.mts +0 -4
  5. package/build/guard/emit.mjs +0 -8
  6. package/build/guard/guard.d.mts +0 -4
  7. package/build/guard/guard.mjs +0 -8
  8. package/build/schema/engine/index.d.mts +0 -1
  9. package/build/schema/engine/index.mjs +0 -1
  10. package/build/schema/engine/schema.mjs +0 -5
  11. package/build/schema/engine/type.mjs +14 -18
  12. package/build/schema/types/index.d.mts +0 -1
  13. package/build/schema/types/index.mjs +0 -1
  14. package/build/system/locale/ar_001.mjs +0 -1
  15. package/build/system/locale/bn_BD.mjs +0 -1
  16. package/build/system/locale/cs_CZ.mjs +0 -1
  17. package/build/system/locale/de_DE.mjs +0 -1
  18. package/build/system/locale/el_GR.mjs +0 -1
  19. package/build/system/locale/en_US.mjs +0 -1
  20. package/build/system/locale/es_419.mjs +0 -1
  21. package/build/system/locale/es_AR.mjs +0 -1
  22. package/build/system/locale/es_ES.mjs +0 -1
  23. package/build/system/locale/es_MX.mjs +0 -1
  24. package/build/system/locale/fa_IR.mjs +0 -1
  25. package/build/system/locale/fil_PH.mjs +0 -1
  26. package/build/system/locale/fr_CA.mjs +0 -1
  27. package/build/system/locale/fr_FR.mjs +0 -1
  28. package/build/system/locale/ha_NG.mjs +0 -1
  29. package/build/system/locale/hi_IN.mjs +0 -1
  30. package/build/system/locale/hu_HU.mjs +0 -1
  31. package/build/system/locale/id_ID.mjs +0 -1
  32. package/build/system/locale/it_IT.mjs +0 -1
  33. package/build/system/locale/ja_JP.mjs +0 -1
  34. package/build/system/locale/ko_KR.mjs +0 -1
  35. package/build/system/locale/ms_MY.mjs +0 -1
  36. package/build/system/locale/nl_NL.mjs +0 -1
  37. package/build/system/locale/pl_PL.mjs +0 -1
  38. package/build/system/locale/pt_BR.mjs +0 -1
  39. package/build/system/locale/pt_PT.mjs +0 -1
  40. package/build/system/locale/ro_RO.mjs +0 -1
  41. package/build/system/locale/ru_RU.mjs +0 -1
  42. package/build/system/locale/sv_SE.mjs +0 -1
  43. package/build/system/locale/sw_TZ.mjs +0 -1
  44. package/build/system/locale/th_TH.mjs +0 -1
  45. package/build/system/locale/tr_TR.mjs +0 -1
  46. package/build/system/locale/uk_UA.mjs +0 -1
  47. package/build/system/locale/ur_PK.mjs +0 -1
  48. package/build/system/locale/vi_VN.mjs +0 -1
  49. package/build/system/locale/yo_NG.mjs +0 -1
  50. package/build/system/locale/zh_Hans.mjs +0 -1
  51. package/build/system/locale/zh_Hant.mjs +0 -1
  52. package/build/system/memory/clone.d.mts +2 -3
  53. package/build/system/memory/clone.mjs +72 -26
  54. package/build/type/action/index.d.mts +0 -1
  55. package/build/type/action/index.mjs +0 -1
  56. package/build/type/action/readonly_object.d.mts +0 -5
  57. package/build/type/action/readonly_object.mjs +0 -5
  58. package/build/type/action/with.d.mts +0 -10
  59. package/build/type/action/with.mjs +0 -8
  60. package/build/type/engine/cyclic/check.d.mts +1 -4
  61. package/build/type/engine/cyclic/check.mjs +9 -15
  62. package/build/type/engine/cyclic/dependencies.d.mts +1 -4
  63. package/build/type/engine/cyclic/dependencies.mjs +9 -15
  64. package/build/type/engine/cyclic/extends.d.mts +1 -4
  65. package/build/type/engine/cyclic/extends.mjs +8 -14
  66. package/build/type/engine/index.d.mts +0 -1
  67. package/build/type/engine/index.mjs +0 -1
  68. package/build/type/engine/indexed/instantiate.d.mts +1 -1
  69. package/build/type/engine/indexed/instantiate.mjs +4 -2
  70. package/build/type/engine/instantiate.d.mts +7 -12
  71. package/build/type/engine/instantiate.mjs +60 -66
  72. package/build/type/engine/keyof/instantiate.d.mts +1 -1
  73. package/build/type/engine/keyof/instantiate.mjs +4 -1
  74. package/build/type/engine/this/expand_this.d.mts +1 -4
  75. package/build/type/engine/this/expand_this.mjs +7 -13
  76. package/build/type/extends/extends_left.d.mts +1 -7
  77. package/build/type/extends/extends_left.mjs +23 -32
  78. package/build/type/script/mapping.d.mts +0 -12
  79. package/build/type/script/mapping.mjs +21 -25
  80. package/build/type/types/_refine.d.mts +0 -2
  81. package/build/type/types/_refine.mjs +1 -2
  82. package/build/type/types/index.d.mts +0 -4
  83. package/build/type/types/index.mjs +0 -4
  84. package/build/type/types/static.d.mts +1 -5
  85. package/build/typebox.d.mts +2 -7
  86. package/build/typebox.mjs +2 -7
  87. package/build/value/clean/from_type.mjs +8 -10
  88. package/build/value/clone/clone.mjs +1 -86
  89. package/build/value/convert/from_type.mjs +19 -21
  90. package/build/value/create/from_type.mjs +23 -31
  91. package/build/value/default/from_type.mjs +8 -10
  92. package/build/value/index.d.mts +0 -1
  93. package/build/value/index.mjs +0 -1
  94. package/build/value/repair/from_type.mjs +2 -12
  95. package/build/value/value.d.mts +0 -1
  96. package/build/value/value.mjs +0 -1
  97. package/package.json +1 -1
  98. package/readme.md +1 -1
  99. package/build/schema/engine/_guard.d.mts +0 -6
  100. package/build/schema/engine/_guard.mjs +0 -26
  101. package/build/schema/types/_guard.d.mts +0 -10
  102. package/build/schema/types/_guard.mjs +0 -16
  103. package/build/type/action/awaited.d.mts +0 -15
  104. package/build/type/action/awaited.mjs +0 -15
  105. package/build/type/engine/awaited/index.d.mts +0 -1
  106. package/build/type/engine/awaited/index.mjs +0 -1
  107. package/build/type/engine/awaited/instantiate.d.mts +0 -11
  108. package/build/type/engine/awaited/instantiate.mjs +0 -20
  109. package/build/type/extends/async_iterator.d.mts +0 -7
  110. package/build/type/extends/async_iterator.mjs +0 -9
  111. package/build/type/extends/iterator.d.mts +0 -7
  112. package/build/type/extends/iterator.mjs +0 -9
  113. package/build/type/extends/promise.d.mts +0 -7
  114. package/build/type/extends/promise.mjs +0 -9
  115. package/build/type/types/async_iterator.d.mts +0 -20
  116. package/build/type/types/async_iterator.mjs +0 -28
  117. package/build/type/types/base.d.mts +0 -50
  118. package/build/type/types/base.mjs +0 -84
  119. package/build/type/types/iterator.d.mts +0 -20
  120. package/build/type/types/iterator.mjs +0 -28
  121. package/build/type/types/promise.d.mts +0 -21
  122. package/build/type/types/promise.mjs +0 -29
  123. package/build/value/clean/from_base.d.mts +0 -2
  124. package/build/value/clean/from_base.mjs +0 -4
  125. package/build/value/convert/from_base.d.mts +0 -2
  126. package/build/value/convert/from_base.mjs +0 -4
  127. package/build/value/create/from_async_iterator.d.mts +0 -2
  128. package/build/value/create/from_async_iterator.mjs +0 -5
  129. package/build/value/create/from_base.d.mts +0 -2
  130. package/build/value/create/from_base.mjs +0 -4
  131. package/build/value/create/from_iterator.d.mts +0 -2
  132. package/build/value/create/from_iterator.mjs +0 -5
  133. package/build/value/create/from_promise.d.mts +0 -2
  134. package/build/value/create/from_promise.mjs +0 -5
  135. package/build/value/default/from_base.d.mts +0 -2
  136. package/build/value/default/from_base.mjs +0 -5
  137. package/build/value/mutate/error.d.mts +0 -3
  138. package/build/value/mutate/error.mjs +0 -6
  139. package/build/value/mutate/from_array.d.mts +0 -2
  140. package/build/value/mutate/from_array.mjs +0 -16
  141. package/build/value/mutate/from_object.d.mts +0 -2
  142. package/build/value/mutate/from_object.mjs +0 -40
  143. package/build/value/mutate/from_unknown.d.mts +0 -2
  144. package/build/value/mutate/from_unknown.mjs +0 -7
  145. package/build/value/mutate/from_value.d.mts +0 -2
  146. package/build/value/mutate/from_value.mjs +0 -12
  147. package/build/value/mutate/index.d.mts +0 -1
  148. package/build/value/mutate/index.mjs +0 -1
  149. package/build/value/mutate/mutate.d.mts +0 -11
  150. package/build/value/mutate/mutate.mjs +0 -41
  151. package/build/value/repair/from_base.d.mts +0 -2
  152. package/build/value/repair/from_base.mjs +0 -8
@@ -1,8 +1,6 @@
1
1
  import type { StaticCodec, TCodec } from './_codec.mjs';
2
2
  import type { StaticAny, TAny } from './any.mjs';
3
3
  import type { StaticArray, TArray } from './array.mjs';
4
- import type { StaticAsyncIterator, TAsyncIterator } from './async_iterator.mjs';
5
- import type { StaticBase, Base } from './base.mjs';
6
4
  import type { StaticBigInt, TBigInt } from './bigint.mjs';
7
5
  import type { StaticBoolean, TBoolean } from './boolean.mjs';
8
6
  import type { StaticConstructor, TConstructor } from './constructor.mjs';
@@ -12,13 +10,11 @@ import type { StaticFunction, TFunction } from './function.mjs';
12
10
  import type { StaticInteger, TInteger } from './integer.mjs';
13
11
  import type { StaticDependent, TDependent } from './dependent.mjs';
14
12
  import type { StaticIntersect, TIntersect } from './intersect.mjs';
15
- import type { StaticIterator, TIterator } from './iterator.mjs';
16
13
  import type { StaticLiteral, TLiteral, TLiteralValue } from './literal.mjs';
17
14
  import type { StaticNever, TNever } from './never.mjs';
18
15
  import type { StaticNull, TNull } from './null.mjs';
19
16
  import type { StaticNumber, TNumber } from './number.mjs';
20
17
  import type { StaticObject, TObject } from './object.mjs';
21
- import type { StaticPromise, TPromise } from './promise.mjs';
22
18
  import type { TProperties } from './properties.mjs';
23
19
  import type { StaticRecord, TRecord } from './record.mjs';
24
20
  import type { StaticRef, TRef } from './ref.mjs';
@@ -38,7 +34,7 @@ export type StaticEvaluate<T> = {
38
34
  [K in keyof T]: T[K];
39
35
  } & {};
40
36
  export type StaticDirection = 'Encode' | 'Decode';
41
- export type StaticType<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema> = (Type extends TCodec<infer Type extends TSchema, infer Decoded extends unknown> ? StaticCodec<Stack, Direction, Context, This, Type, Decoded> : Type extends TAny ? StaticAny : Type extends TArray<infer Items extends TSchema> ? StaticArray<Stack, Direction, Context, This, Type, Items> : Type extends TAsyncIterator<infer Type extends TSchema> ? StaticAsyncIterator<Stack, Direction, Context, This, Type> : Type extends Base<infer Value extends unknown> ? StaticBase<Value> : Type extends TBigInt ? StaticBigInt : Type extends TBoolean ? StaticBoolean : Type extends TConstructor<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticConstructor<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TEnum<infer Values extends TEnumValue[]> ? StaticEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticFunction<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? StaticDependent<Stack, Direction, Context, This, If, Then, Else> : Type extends TInteger ? StaticInteger : Type extends TIntersect<infer Types extends TSchema[]> ? StaticIntersect<Stack, Direction, Context, This, Types> : Type extends TIterator<infer Types extends TSchema> ? StaticIterator<Stack, Direction, Context, This, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? StaticLiteral<Value> : Type extends TNever ? StaticNever : Type extends TNull ? StaticNull : Type extends TNumber ? StaticNumber : Type extends TObject<infer Properties extends TProperties> ? StaticObject<Stack, Direction, Context, This, Properties> : Type extends TPromise<infer Type extends TSchema> ? StaticPromise<Stack, Direction, Context, This, Type> : Type extends TRecord<infer Key extends string, infer Value extends TSchema> ? StaticRecord<Stack, Direction, Context, This, Key, Value> : Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? StaticCyclic<Stack, Direction, Context, This, Defs, Ref> : Type extends TRef<infer Ref extends string> ? StaticRef<Stack, Direction, Context, This, Ref> : Type extends TString ? StaticString : Type extends TSymbol ? StaticSymbol : Type extends TTemplateLiteral<infer Pattern extends string> ? StaticTemplateLiteral<Pattern> : Type extends TThis ? StaticThis<Stack, Direction, Context, This> : Type extends TTuple<infer Items extends TSchema[]> ? StaticTuple<Stack, Direction, Context, This, Type, Items> : Type extends TUndefined ? StaticUndefined : Type extends TUnion<infer Types extends TSchema[]> ? StaticUnion<Stack, Direction, Context, This, Types> : Type extends TUnknown ? StaticUnknown : Type extends TUnsafe<infer Type extends unknown> ? StaticUnsafe<Type> : Type extends TVoid ? StaticVoid : XStatic<Type>);
37
+ export type StaticType<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema> = (Type extends TCodec<infer Type extends TSchema, infer Decoded extends unknown> ? StaticCodec<Stack, Direction, Context, This, Type, Decoded> : Type extends TAny ? StaticAny : Type extends TArray<infer Items extends TSchema> ? StaticArray<Stack, Direction, Context, This, Type, Items> : Type extends TBigInt ? StaticBigInt : Type extends TBoolean ? StaticBoolean : Type extends TConstructor<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticConstructor<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TEnum<infer Values extends TEnumValue[]> ? StaticEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticFunction<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? StaticDependent<Stack, Direction, Context, This, If, Then, Else> : Type extends TInteger ? StaticInteger : Type extends TIntersect<infer Types extends TSchema[]> ? StaticIntersect<Stack, Direction, Context, This, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? StaticLiteral<Value> : Type extends TNever ? StaticNever : Type extends TNull ? StaticNull : Type extends TNumber ? StaticNumber : Type extends TObject<infer Properties extends TProperties> ? StaticObject<Stack, Direction, Context, This, Properties> : Type extends TRecord<infer Key extends string, infer Value extends TSchema> ? StaticRecord<Stack, Direction, Context, This, Key, Value> : Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? StaticCyclic<Stack, Direction, Context, This, Defs, Ref> : Type extends TRef<infer Ref extends string> ? StaticRef<Stack, Direction, Context, This, Ref> : Type extends TString ? StaticString : Type extends TSymbol ? StaticSymbol : Type extends TTemplateLiteral<infer Pattern extends string> ? StaticTemplateLiteral<Pattern> : Type extends TThis ? StaticThis<Stack, Direction, Context, This> : Type extends TTuple<infer Items extends TSchema[]> ? StaticTuple<Stack, Direction, Context, This, Type, Items> : Type extends TUndefined ? StaticUndefined : Type extends TUnion<infer Types extends TSchema[]> ? StaticUnion<Stack, Direction, Context, This, Types> : Type extends TUnknown ? StaticUnknown : Type extends TUnsafe<infer Type extends unknown> ? StaticUnsafe<Type> : Type extends TVoid ? StaticVoid : XStatic<Type>);
42
38
  /** Infers a static type from a TypeBox type using Parse logic. */
43
39
  export type StaticParse<Type extends TSchema, Context extends TProperties = {}, Result extends unknown = StaticType<[], 'Encode', Context, {}, Type>> = Result;
44
40
  /** Infers a static type from a TypeBox type using Decode logic. */
@@ -1,7 +1,6 @@
1
1
  export { Instantiate, type TInstantiate } from './type/engine/instantiate.mjs';
2
2
  export { Extends, ExtendsResult, type TExtends } from './type/extends/index.mjs';
3
3
  export { Script, type TScript } from './type/script/index.mjs';
4
- export { Awaited, type TAwaited, type TAwaitedDeferred } from './type/action/awaited.mjs';
5
4
  export { Capitalize, type TCapitalize, type TCapitalizeDeferred } from './type/action/capitalize.mjs';
6
5
  export { Conditional, type TConditional, type TConditionalDeferred } from './type/action/conditional.mjs';
7
6
  export { ConstructorParameters, type TConstructorParameters, type TConstructorParametersDeferred } from './type/action/constructor_parameters.mjs';
@@ -20,12 +19,12 @@ export { Omit, type TOmit, type TOmitDeferred } from './type/action/omit.mjs';
20
19
  export { Parameters, type TParameters, type TParametersDeferred } from './type/action/parameters.mjs';
21
20
  export { Partial, type TPartial, type TPartialDeferred } from './type/action/partial.mjs';
22
21
  export { Pick, type TPick, type TPickDeferred } from './type/action/pick.mjs';
23
- export { ReadonlyObject, ReadonlyType, type TReadonlyObject, type TReadonlyObjectDeferred } from './type/action/readonly_object.mjs';
22
+ export { ReadonlyObject, type TReadonlyObject, type TReadonlyObjectDeferred } from './type/action/readonly_object.mjs';
24
23
  export { Required, type TRequired, type TRequiredDeferred } from './type/action/required.mjs';
25
24
  export { ReturnType, type TReturnType, type TReturnTypeDeferred } from './type/action/return_type.mjs';
26
25
  export { type TUncapitalize, type TUncapitalizeDeferred, Uncapitalize } from './type/action/uncapitalize.mjs';
27
26
  export { type TUppercase, type TUppercaseDeferred, Uppercase } from './type/action/uppercase.mjs';
28
- export { Options, type TOptions, type TWith, With } from './type/action/with.mjs';
27
+ export { type TWith, With } from './type/action/with.mjs';
29
28
  export { Codec, Decode, DecodeBuilder, Encode, EncodeBuilder, IsCodec, type TCodec } from './type/types/_codec.mjs';
30
29
  export { Immutable, IsImmutable, type TImmutable } from './type/types/_immutable.mjs';
31
30
  export { IsOptional, Optional, type TOptional } from './type/types/_optional.mjs';
@@ -33,8 +32,6 @@ export { IsReadonly, Readonly, type TReadonly } from './type/types/_readonly.mjs
33
32
  export { IsRefine, Refine, type TRefine, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement } from './type/types/_refine.mjs';
34
33
  export { Any, IsAny, type TAny } from './type/types/any.mjs';
35
34
  export { Array, IsArray, type TArray } from './type/types/array.mjs';
36
- export { AsyncIterator, IsAsyncIterator, type TAsyncIterator } from './type/types/async_iterator.mjs';
37
- export { Base, IsBase } from './type/types/base.mjs';
38
35
  export { BigInt, IsBigInt, type TBigInt } from './type/types/bigint.mjs';
39
36
  export { Boolean, IsBoolean, type TBoolean } from './type/types/boolean.mjs';
40
37
  export { Call, IsCall, type TCall } from './type/types/call.mjs';
@@ -48,14 +45,12 @@ export { Dependent, IsDependent, type TDependent } from './type/types/dependent.
48
45
  export { Infer, IsInfer, type TInfer } from './type/types/infer.mjs';
49
46
  export { Integer, IsInteger, type TInteger } from './type/types/integer.mjs';
50
47
  export { Intersect, IsIntersect, type TIntersect } from './type/types/intersect.mjs';
51
- export { IsIterator, Iterator, type TIterator } from './type/types/iterator.mjs';
52
48
  export { IsLiteral, Literal, type TLiteral, type TLiteralValue } from './type/types/literal.mjs';
53
49
  export { IsNever, Never, type TNever } from './type/types/never.mjs';
54
50
  export { IsNull, Null, type TNull } from './type/types/null.mjs';
55
51
  export { IsNumber, Number, type TNumber } from './type/types/number.mjs';
56
52
  export { IsObject, Object, type TObject } from './type/types/object.mjs';
57
53
  export { IsParameter, Parameter, type TParameter } from './type/types/parameter.mjs';
58
- export { IsPromise, Promise, type TPromise } from './type/types/promise.mjs';
59
54
  export { type TProperties, type TRequiredArray } from './type/types/properties.mjs';
60
55
  export { IsRecord, Record, RecordKey, RecordPattern, RecordValue, type TRecord, type TRecordKey, type TRecordPattern, type TRecordValue } from './type/types/record.mjs';
61
56
  export { IsRef, Ref, type TRef } from './type/types/ref.mjs';
package/build/typebox.mjs CHANGED
@@ -13,7 +13,6 @@ export { Script } from './type/script/index.mjs';
13
13
  // ------------------------------------------------------------------
14
14
  // Actions
15
15
  // ------------------------------------------------------------------
16
- export { Awaited } from './type/action/awaited.mjs';
17
16
  export { Capitalize } from './type/action/capitalize.mjs';
18
17
  export { Conditional } from './type/action/conditional.mjs';
19
18
  export { ConstructorParameters } from './type/action/constructor_parameters.mjs';
@@ -32,12 +31,12 @@ export { Omit } from './type/action/omit.mjs';
32
31
  export { Parameters } from './type/action/parameters.mjs';
33
32
  export { Partial } from './type/action/partial.mjs';
34
33
  export { Pick } from './type/action/pick.mjs';
35
- export { ReadonlyObject, ReadonlyType } from './type/action/readonly_object.mjs';
34
+ export { ReadonlyObject } from './type/action/readonly_object.mjs';
36
35
  export { Required } from './type/action/required.mjs';
37
36
  export { ReturnType } from './type/action/return_type.mjs';
38
37
  export { Uncapitalize } from './type/action/uncapitalize.mjs';
39
38
  export { Uppercase } from './type/action/uppercase.mjs';
40
- export { Options, With } from './type/action/with.mjs';
39
+ export { With } from './type/action/with.mjs';
41
40
  // ------------------------------------------------------------------
42
41
  // Extension
43
42
  // ------------------------------------------------------------------
@@ -51,8 +50,6 @@ export { IsRefine, Refine } from './type/types/_refine.mjs';
51
50
  // ------------------------------------------------------------------
52
51
  export { Any, IsAny } from './type/types/any.mjs';
53
52
  export { Array, IsArray } from './type/types/array.mjs';
54
- export { AsyncIterator, IsAsyncIterator } from './type/types/async_iterator.mjs';
55
- export { Base, IsBase } from './type/types/base.mjs';
56
53
  export { BigInt, IsBigInt } from './type/types/bigint.mjs';
57
54
  export { Boolean, IsBoolean } from './type/types/boolean.mjs';
58
55
  export { Call, IsCall } from './type/types/call.mjs';
@@ -66,14 +63,12 @@ export { Dependent, IsDependent } from './type/types/dependent.mjs';
66
63
  export { Infer, IsInfer } from './type/types/infer.mjs';
67
64
  export { Integer, IsInteger } from './type/types/integer.mjs';
68
65
  export { Intersect, IsIntersect } from './type/types/intersect.mjs';
69
- export { IsIterator, Iterator } from './type/types/iterator.mjs';
70
66
  export { IsLiteral, Literal } from './type/types/literal.mjs';
71
67
  export { IsNever, Never } from './type/types/never.mjs';
72
68
  export { IsNull, Null } from './type/types/null.mjs';
73
69
  export { IsNumber, Number } from './type/types/number.mjs';
74
70
  export { IsObject, Object } from './type/types/object.mjs';
75
71
  export { IsParameter, Parameter } from './type/types/parameter.mjs';
76
- export { IsPromise, Promise } from './type/types/promise.mjs';
77
72
  export { IsRecord, Record, RecordKey, RecordPattern, RecordValue } from './type/types/record.mjs';
78
73
  export { IsRef, Ref } from './type/types/ref.mjs';
79
74
  export { IsRest, Rest } from './type/types/rest.mjs';
@@ -1,7 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import * as T from '../../type/index.mjs';
3
3
  import { FromArray } from './from_array.mjs';
4
- import { FromBase } from './from_base.mjs';
5
4
  import { FromCyclic } from './from_cyclic.mjs';
6
5
  import { FromIntersect } from './from_intersect.mjs';
7
6
  import { FromObject } from './from_object.mjs';
@@ -11,13 +10,12 @@ import { FromTuple } from './from_tuple.mjs';
11
10
  import { FromUnion } from './from_union.mjs';
12
11
  export function FromType(context, type, value) {
13
12
  return (T.IsArray(type) ? FromArray(context, type, value) :
14
- T.IsBase(type) ? FromBase(context, type, value) :
15
- T.IsCyclic(type) ? FromCyclic(context, type, value) :
16
- T.IsIntersect(type) ? FromIntersect(context, type, value) :
17
- T.IsObject(type) ? FromObject(context, type, value) :
18
- T.IsRecord(type) ? FromRecord(context, type, value) :
19
- T.IsRef(type) ? FromRef(context, type, value) :
20
- T.IsTuple(type) ? FromTuple(context, type, value) :
21
- T.IsUnion(type) ? FromUnion(context, type, value) :
22
- value);
13
+ T.IsCyclic(type) ? FromCyclic(context, type, value) :
14
+ T.IsIntersect(type) ? FromIntersect(context, type, value) :
15
+ T.IsObject(type) ? FromObject(context, type, value) :
16
+ T.IsRecord(type) ? FromRecord(context, type, value) :
17
+ T.IsRef(type) ? FromRef(context, type, value) :
18
+ T.IsTuple(type) ? FromTuple(context, type, value) :
19
+ T.IsUnion(type) ? FromUnion(context, type, value) :
20
+ value);
23
21
  }
@@ -1,86 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard, GlobalsGuard } from '../../guard/index.mjs';
3
2
  import { Clone as SystemClone } from '../../system/memory/clone.mjs';
4
3
  // ------------------------------------------------------------------
5
- // ClassInstance
6
- //
7
- // TypeBox does not support cloning arbitrary class instances. It treats
8
- // class instances as atomic values, similar to number, boolean, and
9
- // string. In the future, an implementation could detect the presence of
10
- // a .clone() method, but no formal specification for this behavior
11
- // exists, so we don't.
12
- //
13
- // ------------------------------------------------------------------
14
- function FromClassInstance(value) {
15
- return value; // atomic
16
- }
17
- // ------------------------------------------------------------------
18
- // TypeInstance
19
- //
20
- // TypeBox types have non-enumerable properties that should be
21
- // retained on Clone. We need to use a SystemClone for this
22
- // to ensure the non-enumerable properties are preserved.
23
- // ------------------------------------------------------------------
24
- function IsTypeInstance(value) {
25
- return Guard.HasPropertyKey(value, '~kind');
26
- }
27
- function FromTypeInstance(value) {
28
- return SystemClone(value);
29
- }
30
- // ------------------------------------------------------------------
31
- // ObjectInstance
32
- // ------------------------------------------------------------------
33
- function FromObjectInstance(value) {
34
- const result = {};
35
- for (const key of Guard.Keys(value)) {
36
- if (Guard.IsUnsafePropertyKey(key))
37
- continue; // (ignore: prototype-pollution)
38
- result[key] = Clone(value[key]);
39
- }
40
- for (const key of Guard.Symbols(value)) {
41
- result[key] = Clone(value[key]);
42
- }
43
- return result;
44
- }
45
- // ------------------------------------------------------------------
46
- // Object
47
- // ------------------------------------------------------------------
48
- function FromObject(value) {
49
- return (Guard.IsClassInstance(value) ? FromClassInstance(value) :
50
- IsTypeInstance(value) ? FromTypeInstance(value) :
51
- FromObjectInstance(value));
52
- }
53
- // ------------------------------------------------------------------
54
- // Array
55
- // ------------------------------------------------------------------
56
- function FromArray(value) {
57
- return value.map((element) => Clone(element));
58
- }
59
- // ------------------------------------------------------------------
60
- // TypeArray
61
- // ------------------------------------------------------------------
62
- function FromTypedArray(value) {
63
- return value.slice();
64
- }
65
- // ------------------------------------------------------------------
66
- // Map
67
- // ------------------------------------------------------------------
68
- function FromMap(value) {
69
- return new Map(Clone([...value.entries()]));
70
- }
71
- // ------------------------------------------------------------------
72
- // Set
73
- // ------------------------------------------------------------------
74
- function FromSet(value) {
75
- return new Set(Clone([...value.values()]));
76
- }
77
- // ------------------------------------------------------------------
78
- // Value
79
- // ------------------------------------------------------------------
80
- function FromValue(value) {
81
- return value;
82
- }
83
- // ------------------------------------------------------------------
84
4
  // Clone
85
5
  // ------------------------------------------------------------------
86
6
  /**
@@ -88,10 +8,5 @@ function FromValue(value) {
88
8
  * but also supports deep cloning instances of Map, Set and TypeArray.
89
9
  */
90
10
  export function Clone(value) {
91
- return (GlobalsGuard.IsTypeArray(value) ? FromTypedArray(value) :
92
- GlobalsGuard.IsMap(value) ? FromMap(value) :
93
- GlobalsGuard.IsSet(value) ? FromSet(value) :
94
- Guard.IsArray(value) ? FromArray(value) :
95
- Guard.IsObject(value) ? FromObject(value) :
96
- FromValue(value));
11
+ return SystemClone(value);
97
12
  }
@@ -1,7 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import * as Type from '../../type/index.mjs';
3
3
  import { FromArray } from './from_array.mjs';
4
- import { FromBase } from './from_base.mjs';
5
4
  import { FromBigInt } from './from_bigint.mjs';
6
5
  import { FromBoolean } from './from_boolean.mjs';
7
6
  import { FromCyclic } from './from_cyclic.mjs';
@@ -22,24 +21,23 @@ import { FromUnion } from './from_union.mjs';
22
21
  import { FromVoid } from './from_void.mjs';
23
22
  export function FromType(context, type, value) {
24
23
  return (Type.IsArray(type) ? FromArray(context, type, value) :
25
- Type.IsBase(type) ? FromBase(context, type, value) :
26
- Type.IsBigInt(type) ? FromBigInt(context, type, value) :
27
- Type.IsBoolean(type) ? FromBoolean(context, type, value) :
28
- Type.IsCyclic(type) ? FromCyclic(context, type, value) :
29
- Type.IsEnum(type) ? FromEnum(context, type, value) :
30
- Type.IsInteger(type) ? FromInteger(context, type, value) :
31
- Type.IsIntersect(type) ? FromIntersect(context, type, value) :
32
- Type.IsLiteral(type) ? FromLiteral(context, type, value) :
33
- Type.IsNull(type) ? FromNull(context, type, value) :
34
- Type.IsNumber(type) ? FromNumber(context, type, value) :
35
- Type.IsObject(type) ? FromObject(context, type, value) :
36
- Type.IsRecord(type) ? FromRecord(context, type, value) :
37
- Type.IsRef(type) ? FromRef(context, type, value) :
38
- Type.IsString(type) ? FromString(context, type, value) :
39
- Type.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type, value) :
40
- Type.IsTuple(type) ? FromTuple(context, type, value) :
41
- Type.IsUndefined(type) ? FromUndefined(context, type, value) :
42
- Type.IsUnion(type) ? FromUnion(context, type, value) :
43
- Type.IsVoid(type) ? FromVoid(context, type, value) :
44
- value);
24
+ Type.IsBigInt(type) ? FromBigInt(context, type, value) :
25
+ Type.IsBoolean(type) ? FromBoolean(context, type, value) :
26
+ Type.IsCyclic(type) ? FromCyclic(context, type, value) :
27
+ Type.IsEnum(type) ? FromEnum(context, type, value) :
28
+ Type.IsInteger(type) ? FromInteger(context, type, value) :
29
+ Type.IsIntersect(type) ? FromIntersect(context, type, value) :
30
+ Type.IsLiteral(type) ? FromLiteral(context, type, value) :
31
+ Type.IsNull(type) ? FromNull(context, type, value) :
32
+ Type.IsNumber(type) ? FromNumber(context, type, value) :
33
+ Type.IsObject(type) ? FromObject(context, type, value) :
34
+ Type.IsRecord(type) ? FromRecord(context, type, value) :
35
+ Type.IsRef(type) ? FromRef(context, type, value) :
36
+ Type.IsString(type) ? FromString(context, type, value) :
37
+ Type.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type, value) :
38
+ Type.IsTuple(type) ? FromTuple(context, type, value) :
39
+ Type.IsUndefined(type) ? FromUndefined(context, type, value) :
40
+ Type.IsUnion(type) ? FromUnion(context, type, value) :
41
+ Type.IsVoid(type) ? FromVoid(context, type, value) :
42
+ value);
45
43
  }
@@ -3,8 +3,6 @@ import * as T from '../../type/index.mjs';
3
3
  import * as S from '../../schema/types/index.mjs';
4
4
  import { FromDefault } from './from_default.mjs';
5
5
  import { FromArray } from './from_array.mjs';
6
- import { FromAsyncIterator } from './from_async_iterator.mjs';
7
- import { FromBase } from './from_base.mjs';
8
6
  import { FromBigInt } from './from_bigint.mjs';
9
7
  import { FromBoolean } from './from_boolean.mjs';
10
8
  import { FromConstructor } from './from_constructor.mjs';
@@ -13,13 +11,11 @@ import { FromEnum } from './from_enum.mjs';
13
11
  import { FromFunction } from './from_function.mjs';
14
12
  import { FromInteger } from './from_integer.mjs';
15
13
  import { FromIntersect } from './from_intersect.mjs';
16
- import { FromIterator } from './from_iterator.mjs';
17
14
  import { FromLiteral } from './from_literal.mjs';
18
15
  import { FromNever } from './from_never.mjs';
19
16
  import { FromNull } from './from_null.mjs';
20
17
  import { FromNumber } from './from_number.mjs';
21
18
  import { FromObject } from './from_object.mjs';
22
- import { FromPromise } from './from_promise.mjs';
23
19
  import { FromRecord } from './from_record.mjs';
24
20
  import { FromRef } from './from_ref.mjs';
25
21
  import { FromString } from './from_string.mjs';
@@ -39,31 +35,27 @@ export function FromType(context, type) {
39
35
  // Types
40
36
  // -----------------------------------------------------
41
37
  T.IsArray(type) ? FromArray(context, type) :
42
- T.IsAsyncIterator(type) ? FromAsyncIterator(context, type) :
43
- T.IsBase(type) ? FromBase(context, type) :
44
- T.IsBigInt(type) ? FromBigInt(context, type) :
45
- T.IsBoolean(type) ? FromBoolean(context, type) :
46
- T.IsConstructor(type) ? FromConstructor(context, type) :
47
- T.IsCyclic(type) ? FromCyclic(context, type) :
48
- T.IsEnum(type) ? FromEnum(context, type) :
49
- T.IsFunction(type) ? FromFunction(context, type) :
50
- T.IsInteger(type) ? FromInteger(context, type) :
51
- T.IsIntersect(type) ? FromIntersect(context, type) :
52
- T.IsIterator(type) ? FromIterator(context, type) :
53
- T.IsLiteral(type) ? FromLiteral(context, type) :
54
- T.IsNever(type) ? FromNever(context, type) :
55
- T.IsNull(type) ? FromNull(context, type) :
56
- T.IsNumber(type) ? FromNumber(context, type) :
57
- T.IsObject(type) ? FromObject(context, type) :
58
- T.IsPromise(type) ? FromPromise(context, type) :
59
- T.IsRecord(type) ? FromRecord(context, type) :
60
- T.IsRef(type) ? FromRef(context, type) :
61
- T.IsString(type) ? FromString(context, type) :
62
- T.IsSymbol(type) ? FromSymbol(context, type) :
63
- T.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type) :
64
- T.IsTuple(type) ? FromTuple(context, type) :
65
- T.IsUndefined(type) ? FromUndefined(context, type) :
66
- T.IsUnion(type) ? FromUnion(context, type) :
67
- T.IsVoid(type) ? FromVoid(context, type) :
68
- undefined);
38
+ T.IsBigInt(type) ? FromBigInt(context, type) :
39
+ T.IsBoolean(type) ? FromBoolean(context, type) :
40
+ T.IsConstructor(type) ? FromConstructor(context, type) :
41
+ T.IsCyclic(type) ? FromCyclic(context, type) :
42
+ T.IsEnum(type) ? FromEnum(context, type) :
43
+ T.IsFunction(type) ? FromFunction(context, type) :
44
+ T.IsInteger(type) ? FromInteger(context, type) :
45
+ T.IsIntersect(type) ? FromIntersect(context, type) :
46
+ T.IsLiteral(type) ? FromLiteral(context, type) :
47
+ T.IsNever(type) ? FromNever(context, type) :
48
+ T.IsNull(type) ? FromNull(context, type) :
49
+ T.IsNumber(type) ? FromNumber(context, type) :
50
+ T.IsObject(type) ? FromObject(context, type) :
51
+ T.IsRecord(type) ? FromRecord(context, type) :
52
+ T.IsRef(type) ? FromRef(context, type) :
53
+ T.IsString(type) ? FromString(context, type) :
54
+ T.IsSymbol(type) ? FromSymbol(context, type) :
55
+ T.IsTemplateLiteral(type) ? FromTemplateLiteral(context, type) :
56
+ T.IsTuple(type) ? FromTuple(context, type) :
57
+ T.IsUndefined(type) ? FromUndefined(context, type) :
58
+ T.IsUnion(type) ? FromUnion(context, type) :
59
+ T.IsVoid(type) ? FromVoid(context, type) :
60
+ undefined);
69
61
  }
@@ -3,7 +3,6 @@
3
3
  import { IsDefault } from '../../schema/index.mjs';
4
4
  import * as T from '../../type/index.mjs';
5
5
  import { FromArray } from './from_array.mjs';
6
- import { FromBase } from './from_base.mjs';
7
6
  import { FromCyclic } from './from_cyclic.mjs';
8
7
  import { FromDefault } from './from_default.mjs';
9
8
  import { FromIntersect } from './from_intersect.mjs';
@@ -15,13 +14,12 @@ import { FromUnion } from './from_union.mjs';
15
14
  export function FromType(context, type, value) {
16
15
  const defaulted = IsDefault(type) ? FromDefault(type, value) : value;
17
16
  return (T.IsArray(type) ? FromArray(context, type, defaulted) :
18
- T.IsBase(type) ? FromBase(context, type, defaulted) :
19
- T.IsCyclic(type) ? FromCyclic(context, type, defaulted) :
20
- T.IsIntersect(type) ? FromIntersect(context, type, defaulted) :
21
- T.IsObject(type) ? FromObject(context, type, defaulted) :
22
- T.IsRecord(type) ? FromRecord(context, type, defaulted) :
23
- T.IsRef(type) ? FromRef(context, type, defaulted) :
24
- T.IsTuple(type) ? FromTuple(context, type, defaulted) :
25
- T.IsUnion(type) ? FromUnion(context, type, defaulted) :
26
- defaulted);
17
+ T.IsCyclic(type) ? FromCyclic(context, type, defaulted) :
18
+ T.IsIntersect(type) ? FromIntersect(context, type, defaulted) :
19
+ T.IsObject(type) ? FromObject(context, type, defaulted) :
20
+ T.IsRecord(type) ? FromRecord(context, type, defaulted) :
21
+ T.IsRef(type) ? FromRef(context, type, defaulted) :
22
+ T.IsTuple(type) ? FromTuple(context, type, defaulted) :
23
+ T.IsUnion(type) ? FromUnion(context, type, defaulted) :
24
+ defaulted);
27
25
  }
@@ -9,7 +9,6 @@ export * from './errors/index.mjs';
9
9
  export * from './default/index.mjs';
10
10
  export * from './equal/index.mjs';
11
11
  export * from './hash/index.mjs';
12
- export * from './mutate/index.mjs';
13
12
  export * from './parse/index.mjs';
14
13
  export * from './delta/index.mjs';
15
14
  export * from './pipeline/index.mjs';
@@ -12,7 +12,6 @@ export * from './errors/index.mjs';
12
12
  export * from './default/index.mjs';
13
13
  export * from './equal/index.mjs';
14
14
  export * from './hash/index.mjs';
15
- export * from './mutate/index.mjs';
16
15
  export * from './parse/index.mjs';
17
16
  export * from './delta/index.mjs';
18
17
  export * from './pipeline/index.mjs';
@@ -4,7 +4,6 @@ import * as T from '../../type/index.mjs';
4
4
  import { Check } from '../check/index.mjs';
5
5
  import { Create } from '../create/index.mjs';
6
6
  import { FromArray } from './from_array.mjs';
7
- import { FromBase } from './from_base.mjs';
8
7
  import { FromEnum } from './from_enum.mjs';
9
8
  import { FromIntersect } from './from_intersect.mjs';
10
9
  import { FromObject } from './from_object.mjs';
@@ -33,12 +32,9 @@ function AssertRepairableValue(context, type, value) {
33
32
  // AssertRepairableType
34
33
  // ------------------------------------------------------------------
35
34
  function AssertRepairableType(context, type, value) {
36
- const unsupported = T.IsAsyncIterator(type)
37
- || T.IsIterator(type)
38
- || T.IsConstructor(type)
35
+ const unsupported = T.IsConstructor(type)
39
36
  || T.IsFunction(type)
40
- || T.IsNever(type)
41
- || T.IsPromise(type);
37
+ || T.IsNever(type);
42
38
  if (unsupported) {
43
39
  throw new RepairError(context, type, value, 'Type is not repairable');
44
40
  }
@@ -64,12 +60,6 @@ function FinalizeRepair(context, type, repaired) {
64
60
  // FromType
65
61
  // ------------------------------------------------------------------
66
62
  export function FromType(context, type, value) {
67
- // Base Repair
68
- if (T.IsBase(type)) {
69
- const repaired = FromBase(context, type, value);
70
- return FinalizeRepair(context, type, repaired);
71
- }
72
- // Schema Repair
73
63
  AssertRepairableValue(context, type, value);
74
64
  AssertRepairableType(context, type, value);
75
65
  const repaired = (T.IsArray(type) ? FromArray(context, type, value) :
@@ -9,7 +9,6 @@ export { Default } from './default/index.mjs';
9
9
  export { Equal } from './equal/index.mjs';
10
10
  export { Errors } from './errors/index.mjs';
11
11
  export { Hash } from './hash/index.mjs';
12
- export { Mutate, type TMutable } from './mutate/index.mjs';
13
12
  export { Parse } from './parse/index.mjs';
14
13
  export { Diff, Patch } from './delta/index.mjs';
15
14
  export { Pointer } from './pointer/index.mjs';
@@ -9,7 +9,6 @@ export { Default } from './default/index.mjs';
9
9
  export { Equal } from './equal/index.mjs';
10
10
  export { Errors } from './errors/index.mjs';
11
11
  export { Hash } from './hash/index.mjs';
12
- export { Mutate } from './mutate/index.mjs';
13
12
  export { Parse } from './parse/index.mjs';
14
13
  export { Diff, Patch } from './delta/index.mjs';
15
14
  export { Pointer } from './pointer/index.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.2.18",
4
+ "version": "1.3.0",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
package/readme.md CHANGED
@@ -111,7 +111,7 @@ type User = Type.Static<typeof User> // type User = {
111
111
 
112
112
  ## Script
113
113
 
114
- [Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdAGUAxlGBgYACjwC5eAJS9G3VWvXdqdOADkAhiFQBnMHpGpKIiADsj8ALJ6YACzgBeREWFiJ0gAaUcHCEaHAAaqgiMNAATO5wAN5wZABccNYAriDEqFAANHBIaZnZuXAAvoHBROGR0VAAzPEAogBuegA2GU6oADwRUbFwAGSJcABexVk5UBUAfFUh6AP1ACwt7V09-XXQTaNJAO5TpbPlC35KygAiqGjWACao1vD6hiZmFla28En2xq5yvF+KhvOJJFIknIBI4XBUCn4gosahFYKgyPEElUgpAjMAYMAbGkVtBVnlseloCBOsTdo1yUEghlWrTBlAYlVKkElnAAOKoHCoGBQJCYimtXIE8xGWlosgAbQAugzGcBHsBpScZkrOcjQrDcsBOmLGXADMRgM8YKy1iqgg9gBgMBkjKgbaS7XATJEMh09FB3VBVrruTV-kZXB4saaAOYCwzCop8+NCkWe6kwQ00uAG8SdXWXLT0ABKGReoHQxdQGA6dUJ1ko4ecAjA2DQsEtRgEccFiZbbclnYEEo70oE+NQIC7rYg7YJxhbEDxBJs-dng4XZEbALXc6HPYTIt3G67I6lC4nU+PHYX1ipnWv867W6bj-3Kb7M73C7PGovmavL8TwEZk303bcIzArsMyzDooIEB0nRdUEgJvZ8IObVCnwEGC8zgrCh3NS0Xngl8dwIhdcKNfCBzQgRvREX1-VIos4CEGAnA1OAAElrAwXJnnMShnWsKJ6zgKBnieKApHeZw0hBYQOKlXolggDAcwBOYFESKo5O7D8j1-aV5QABkVRdl3rAQtyCfSD1TJBh0HEzzIEO8oGpODbLgezDKc4zjDMizQJ8-SqIfRDnVdGy9J3CK4KIq1Yrs+Kejw+i0EYv0oFi8ogA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdACpejbuImTu1OnAByAQxCoAzmAUBjVJQB2S1eq1wAsgpgALOAG9KcOKjKRYcDRB0r4ANVQaY0AExwALyIRAIA8sQAVj4wABRWcGQAXKGCcgCuIMSoUHEAlAA0cEip-KgCmdm5BXAAvvm29o7Q8K7uXrHQAMzBaRUAogBuCgA2GWaoceUCAJI6MLkqsXEA2t6+AcUzkTG+CXAAXmVhVTl5+fX5ALr5jXYOTm1uHnAbflAALH0zw2MTi2mYXmiygy326y6UG62zCuxWiQA7id0llzrUGrdGnUZPQACKoNA6AAmqAW8n0ak02nar28sAcPzh0QRTUgKmAMGAblSpgsAne0E+hSaOmgIDGvLM5gFUJhTQyQyl-MFUH8lAalFp8AA4qgcKgYFAkEzBPD9jY7ENclytCoURUAIJQKAKJBxemLMhFJrAEnAO0OgTO13umZnGp3DWNbUmSZQYBjU0Vc3xS1wJTEYBkmDKmWq4VNYnADAYDLLPOyzZfEV2NQ+DKjBRQSsF6Nal7wYyqSwhHYsi1NADm+uURtKcD1BvHtbgEtBidGytyi-bogAShkFqB0OvUBhRrFuTpKN2VDKwNg0LBsyoBCPp8aBJeINeuaoBNab3aBJzUCA7xfN9b2fCAOS5NxnyvG0QLIU8eyg18YI-B8xyfIDkLvL9bQ-P8AMQ4CPzFKAJVGAjMIEOCzwvaCbxQ0dDXQ2j3ywmCfzwwDmJAxVyLou8qIQjC+IEecVzGXiWIEYtS3LCohMkgTzwkkDRITcT5JAzNswWZSP0UmikOE1TF10u96w0Rtm1MyjcTgABlGAzADOB5gwXIyS0Sgyx0XxjzgKAyVJPJlHPIMHKcjQAB5CDQCAMBMHsAD5LnTEKZVQxikE-NjVFWAAGa5QPA48bLsNL7wY8dsu-XKCoEYjSNKucEIyqrsIDWrCp4uCyoQ4zxOkstlia8r+rIrScxGvr4xM8zLKgGy6iAA) | [Challenges](test/typescript/readme.md)
114
+ [Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdAGUAxlGBgYACjwC5eAJS9G3VWvXdqdOADkAhiFQBnMHpGpKIiADsj8ALJ6YACzgBeREWFiJ0gAaUcHCEaHAAaqgiMNAATO5wAN5wZABccNYAriDEqFAANHBIaZnZuXAAvoHBROGR0VAAzPEAogBuegA2GU6oADwRUbFwAGSJcABexVk5UBUAfFUh6AP1ACwt7V09-XXQTaNJAO5TpbPlC35KygAiqGjWACao1vD6hiZmFla28En2xq5yvF+KhvOJJFIknIBI4XBUCn4gosahFYKgyPEElUgpAjMAYMAbGkVtBVnlseloCBOsTdo1yUEghlWrTBlAYlVKkElnAAOKoHCoGBQJCYimtXIE8xGWlosgAbQAugzGcBHsBpScZkrOcjQrDcsBOmLGXADMRgM8YKy1iqgg9gBgMBkjKgbaS7XATJEMh09FB3VBVrruTV-kZXB4saaAOYCwzCop8+NCkWe6kwQ00uAG8SdXWXLT0ABKGReoHQxdQGA6dUJ1ko4ecAjA2DQsEtRgEccFiZbbclnYEEo70oE+NQIC7rYg7YJxhbEDxBJs-dng4XZEbALXc6HPYTIt3G67I6lC4nU+PHYX1ipnWv867W6bj-3Kb7M73C7PGovmavL8TwEZk303bcIzArsMyzDooIEB0nRdUEgJvZ8IObVCnwEGC8zgrCh3NS0Xngl8dwIhdcKNfCBzQgRvREX1-VIos4CEGAnA1OAAElrAwXJnnMShnWsKJ6zgKBnieKApHeZw0hBYQOKlXolggDAcwBOYFESKo5O7D8j1-aV5QABkVRdl3rAQtyCfSD1TJBh0HEzzIEO8oGpODbLgezDKc4zjDMizQJ8-SqIfRDnVdGy9J3CK4KIq1Yrs+Kejw+i0EYv0oFi8ogA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdACpejbuImTu1OnAByAQxCoAzmAUBjVJQB2S1eq1wAsgpgALOAG9KcOKjKRYcDRB0r4ANVQaY0AExwALyIRAIA8sQAVj4wABRWcGQAXKGCcgCuIMSoUHEAlAA0cEip-KgCmdm5BXAAvvm29o7Q8K7uXrHQAMzBaRUAogBuCgA2GWaoceUCAJI6MLkqsXEA2t6+AcUzkTG+CXAAXmVhVTl5+fX5ALr5jXYOTm1uHnAbflAALH0zw2MTi2mYXmiygy326y6UG62zCuxWiQA7id0llzrUGrdGnUZPQACKoNA6AAmqAW8n0ak02nar28sAcPzh0QRTUgKmAMGAblSpgsAne0E+hSaOmgIDGvLM5gFUJhTQyQyl-MFUH8lAalFp8AA4qgcKgYFAkEzBPD9jY7ENclytCoURUAIJQKAKJBxemLMhFJrAEnAO0OgTO13umZnGp3DWNbUmSZQYBjU0Vc3xS1wJTEYBkmDKmWq4VNYnADAYDLLPOyzZfEV2NQ+DKjBRQSsF6Nal7wYyqSwhHYsi1NADm+uURtKcD1BvHtbgEtBidGytyi-bogAShkFqB0OvUBhRrFuTpKN2VDKwNg0LBsyoBCPp8aBJeINeuaoBNab3aBJzUCA7xfN9b2fCAOS5NxnyvG0QLIU8eyg18YI-B8xyfIDkLvL9bQ-P8AMQ4CPzFKAJVGAjMIEOCzwvaCbxQ0dDXQ2j3ywmCfzwwDmJAxVyLou8qIQjC+IEecVzGXiWIEYtS3LCohMkgTzwkkDRITcT5JAzNswWZSP0UmikOE1TF10u96w0Rtm1MyjcTgABlGAzADOB5gwXIyS0Sgyx0XxjzgKAyVJPJlHPIMHKcjQAB5CDQCAMBMHsAD5LnTEKZVQxikE-NjVFWAAGa5QPA48bLsNL7wY8dsu-XKCoEYjSNKucEIyqrsIDWrCp4uCyoQ4zxOkstlia8r+rIrScxGvr4xM8zLKgGy6iAA) | [Challenge](test/typescript/readme.md)
115
115
 
116
116
  TypeBox includes a syntax engine that can transform TypeScript declarations into JSON Schema. The engine is a full syntactic frontend to Type.* and supports many advanced type-level constructs such as Conditional, Mapped, Indexed, Infer, Generics, Distributed types and more. This feature is implemented symmetrically at runtime and statically via TypeScript Template Literal types.
117
117
 
@@ -1,6 +0,0 @@
1
- import * as Schema from '../types/index.mjs';
2
- import { Stack } from './_stack.mjs';
3
- import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
4
- export declare function BuildGuard(_stack: Stack, _context: BuildContext, schema: Schema.XGuard, value: string): string;
5
- export declare function CheckGuard(_stack: Stack, _context: CheckContext, schema: Schema.XGuard, value: unknown): boolean;
6
- export declare function ErrorGuard(_stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XGuard, value: unknown): boolean;
@@ -1,26 +0,0 @@
1
- // deno-fmt-ignore-file
2
- import * as Externals from './_externals.mjs';
3
- import { EmitGuard as E } from '../../guard/index.mjs';
4
- // ------------------------------------------------------------------
5
- // Build
6
- // ------------------------------------------------------------------
7
- export function BuildGuard(_stack, _context, schema, value) {
8
- return E.Call(E.Member(E.Member(Externals.CreateVariable(schema), '~guard'), 'check'), [value]);
9
- }
10
- // ------------------------------------------------------------------
11
- // Check
12
- // ------------------------------------------------------------------
13
- export function CheckGuard(_stack, _context, schema, value) {
14
- return schema['~guard'].check(value);
15
- }
16
- // ------------------------------------------------------------------
17
- // Error
18
- // ------------------------------------------------------------------
19
- export function ErrorGuard(_stack, context, schemaPath, instancePath, schema, value) {
20
- return schema['~guard'].check(value) || context.AddError({
21
- keyword: '~guard',
22
- schemaPath,
23
- instancePath,
24
- params: { errors: schema['~guard'].errors(value) },
25
- });
26
- }
@@ -1,10 +0,0 @@
1
- import type { XSchemaObject } from './schema.mjs';
2
- export interface XGuardInterface<Value extends unknown = unknown> {
3
- check(value: unknown): value is Value;
4
- errors(value: unknown): object[];
5
- }
6
- export interface XGuard<Value extends unknown = unknown> {
7
- '~guard': XGuardInterface<Value>;
8
- }
9
- export declare function IsGuardInterface(value: unknown): value is XGuardInterface;
10
- export declare function IsGuard(value: XSchemaObject): value is XGuard;
@@ -1,16 +0,0 @@
1
- // deno-fmt-ignore-file
2
- import { Guard } from '../../guard/index.mjs';
3
- // ------------------------------------------------------------------
4
- // Guard
5
- // ------------------------------------------------------------------
6
- export function IsGuardInterface(value) {
7
- return Guard.IsObject(value)
8
- && Guard.HasPropertyKey(value, 'check')
9
- && Guard.HasPropertyKey(value, 'errors')
10
- && Guard.IsFunction(value.check)
11
- && Guard.IsFunction(value.errors);
12
- }
13
- export function IsGuard(value) {
14
- return Guard.HasPropertyKey(value, '~guard')
15
- && IsGuardInterface(value['~guard']);
16
- }
@@ -1,15 +0,0 @@
1
- import { type TSchema, type TSchemaOptions } from '../types/schema.mjs';
2
- import { type TDeferred } from '../types/deferred.mjs';
3
- import { type TAwaitedAction } from '../engine/awaited/instantiate.mjs';
4
- /** Creates a deferred Awaited action. */
5
- export type TAwaitedDeferred<Type extends TSchema> = (TDeferred<'Awaited', [Type]>);
6
- /** Creates a deferred Awaited action. */
7
- export declare function AwaitedDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TAwaitedDeferred<Type>;
8
- /** Applies an Awaited action to a type. */
9
- export type TAwaited<Type extends TSchema> = (TAwaitedAction<Type>);
10
- /**
11
- * Applies an Awaited action to a type.
12
- *
13
- * @deprecated This action is being removed in the next version of TypeBox.
14
- */
15
- export declare function Awaited<Type extends TSchema>(type: Type, options?: TSchemaOptions): TAwaited<Type>;