typebox 1.0.36 → 1.0.37

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 (126) hide show
  1. package/build/schema/build.d.mts +6 -6
  2. package/build/schema/check.d.mts +3 -3
  3. package/build/schema/deref/deref.d.mts +1 -1
  4. package/build/schema/deref/deref.mjs +2 -2
  5. package/build/schema/engine/_context.d.mts +7 -7
  6. package/build/schema/engine/_functions.d.mts +1 -1
  7. package/build/schema/engine/_reducer.d.mts +1 -1
  8. package/build/schema/engine/ref.mjs +3 -3
  9. package/build/schema/engine/schema.d.mts +3 -3
  10. package/build/schema/engine/schema.mjs +4 -4
  11. package/build/schema/errors.d.mts +3 -3
  12. package/build/schema/schema.d.mts +1 -0
  13. package/build/schema/schema.mjs +1 -0
  14. package/build/schema/static/additionalProperties.d.mts +7 -0
  15. package/build/schema/static/allOf.d.mts +3 -0
  16. package/build/schema/static/allOf.mjs +2 -0
  17. package/build/schema/static/anyOf.d.mts +3 -0
  18. package/build/schema/static/anyOf.mjs +2 -0
  19. package/build/schema/static/const.d.mts +1 -0
  20. package/build/schema/static/const.mjs +2 -0
  21. package/build/schema/static/enum.d.mts +1 -0
  22. package/build/schema/static/enum.mjs +2 -0
  23. package/build/schema/static/index.d.mts +1 -0
  24. package/build/schema/static/index.mjs +1 -0
  25. package/build/schema/static/items.d.mts +6 -0
  26. package/build/schema/static/items.mjs +2 -0
  27. package/build/schema/static/oneOf.d.mts +3 -0
  28. package/build/schema/static/oneOf.mjs +2 -0
  29. package/build/schema/static/patternProperties.d.mts +7 -0
  30. package/build/schema/static/patternProperties.mjs +2 -0
  31. package/build/schema/static/prefixItems.d.mts +3 -0
  32. package/build/schema/static/prefixItems.mjs +2 -0
  33. package/build/schema/static/properties.d.mts +11 -0
  34. package/build/schema/static/properties.mjs +2 -0
  35. package/build/schema/static/required.d.mts +13 -0
  36. package/build/schema/static/required.mjs +2 -0
  37. package/build/schema/static/schema.d.mts +48 -0
  38. package/build/schema/static/schema.mjs +2 -0
  39. package/build/schema/static/static.d.mts +5 -0
  40. package/build/schema/static/static.mjs +2 -0
  41. package/build/schema/static/type.d.mts +4 -0
  42. package/build/schema/static/type.mjs +2 -0
  43. package/build/schema/static/unevaluatedProperties.d.mts +7 -0
  44. package/build/schema/static/unevaluatedProperties.mjs +2 -0
  45. package/build/schema/static/~mutable.d.mts +7 -0
  46. package/build/schema/static/~mutable.mjs +2 -0
  47. package/build/schema/static/~readonly.d.mts +6 -0
  48. package/build/schema/static/~readonly.mjs +2 -0
  49. package/build/schema/types/_guard.d.mts +2 -2
  50. package/build/schema/types/_refine.d.mts +2 -2
  51. package/build/schema/types/additionalItems.d.mts +3 -3
  52. package/build/schema/types/additionalItems.mjs +2 -2
  53. package/build/schema/types/additionalProperties.d.mts +3 -3
  54. package/build/schema/types/additionalProperties.mjs +2 -2
  55. package/build/schema/types/allOf.d.mts +3 -3
  56. package/build/schema/types/allOf.mjs +2 -2
  57. package/build/schema/types/anyOf.d.mts +3 -3
  58. package/build/schema/types/anyOf.mjs +2 -2
  59. package/build/schema/types/const.d.mts +2 -2
  60. package/build/schema/types/contains.d.mts +3 -3
  61. package/build/schema/types/contains.mjs +2 -2
  62. package/build/schema/types/contentEncoding.d.mts +2 -2
  63. package/build/schema/types/contentMediaType.d.mts +2 -2
  64. package/build/schema/types/default.d.mts +2 -2
  65. package/build/schema/types/defs.d.mts +3 -3
  66. package/build/schema/types/defs.mjs +2 -2
  67. package/build/schema/types/dependencies.d.mts +2 -2
  68. package/build/schema/types/dependencies.mjs +2 -2
  69. package/build/schema/types/dependentRequired.d.mts +2 -2
  70. package/build/schema/types/dependentSchemas.d.mts +3 -3
  71. package/build/schema/types/dependentSchemas.mjs +2 -2
  72. package/build/schema/types/else.d.mts +3 -3
  73. package/build/schema/types/else.mjs +2 -2
  74. package/build/schema/types/enum.d.mts +2 -2
  75. package/build/schema/types/exclusiveMaximum.d.mts +2 -2
  76. package/build/schema/types/exclusiveMinimum.d.mts +2 -2
  77. package/build/schema/types/format.d.mts +2 -2
  78. package/build/schema/types/id.d.mts +2 -2
  79. package/build/schema/types/if.d.mts +3 -3
  80. package/build/schema/types/if.mjs +2 -2
  81. package/build/schema/types/index.d.mts +0 -1
  82. package/build/schema/types/index.mjs +0 -1
  83. package/build/schema/types/items.d.mts +7 -7
  84. package/build/schema/types/items.mjs +3 -3
  85. package/build/schema/types/maxContains.d.mts +2 -2
  86. package/build/schema/types/maxItems.d.mts +2 -2
  87. package/build/schema/types/maxLength.d.mts +2 -2
  88. package/build/schema/types/maxProperties.d.mts +2 -2
  89. package/build/schema/types/maximum.d.mts +2 -2
  90. package/build/schema/types/minContains.d.mts +2 -2
  91. package/build/schema/types/minItems.d.mts +2 -2
  92. package/build/schema/types/minLength.d.mts +2 -2
  93. package/build/schema/types/minProperties.d.mts +2 -2
  94. package/build/schema/types/minimum.d.mts +2 -2
  95. package/build/schema/types/multipleOf.d.mts +2 -2
  96. package/build/schema/types/not.d.mts +3 -3
  97. package/build/schema/types/not.mjs +2 -2
  98. package/build/schema/types/oneOf.d.mts +3 -3
  99. package/build/schema/types/oneOf.mjs +2 -2
  100. package/build/schema/types/pattern.d.mts +2 -2
  101. package/build/schema/types/patternProperties.d.mts +3 -3
  102. package/build/schema/types/patternProperties.mjs +2 -2
  103. package/build/schema/types/prefixItems.d.mts +3 -3
  104. package/build/schema/types/prefixItems.mjs +2 -2
  105. package/build/schema/types/properties.d.mts +3 -3
  106. package/build/schema/types/properties.mjs +2 -2
  107. package/build/schema/types/propertyNames.d.mts +3 -3
  108. package/build/schema/types/propertyNames.mjs +2 -2
  109. package/build/schema/types/ref.d.mts +2 -2
  110. package/build/schema/types/required.d.mts +2 -2
  111. package/build/schema/types/schema.d.mts +4 -4
  112. package/build/schema/types/schema.mjs +3 -3
  113. package/build/schema/types/then.d.mts +3 -3
  114. package/build/schema/types/then.mjs +2 -2
  115. package/build/schema/types/type.d.mts +2 -2
  116. package/build/schema/types/unevaluatedItems.d.mts +4 -4
  117. package/build/schema/types/unevaluatedItems.mjs +2 -2
  118. package/build/schema/types/unevaluatedProperties.d.mts +3 -3
  119. package/build/schema/types/unevaluatedProperties.mjs +2 -2
  120. package/build/schema/types/uniqueItems.d.mts +2 -2
  121. package/build/type/types/base.d.mts +1 -7
  122. package/build/type/types/base.mjs +1 -15
  123. package/build/type/types/static.d.mts +3 -2
  124. package/package.json +27 -27
  125. package/build/schema/types/static.d.mts +0 -113
  126. /package/build/schema/{types/static.mjs → static/additionalProperties.mjs} +0 -0
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -11,5 +11,5 @@ import { IsSchemaLike } from './schema.mjs';
11
11
  export function IsPatternProperties(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'patternProperties')
13
13
  && Guard.IsObject(schema.patternProperties)
14
- && Object.values(schema.patternProperties).every(value => IsSchemaLike(value));
14
+ && Object.values(schema.patternProperties).every(value => IsSchema(value));
15
15
  }
@@ -1,8 +1,8 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XPrefixItems<PrefixItems extends XSchemaLike[] = XSchemaLike[]> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XPrefixItems<PrefixItems extends XSchema[] = XSchema[]> {
3
3
  prefixItems: PrefixItems;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid prefixItems property
7
7
  */
8
- export declare function IsPrefixItems(schema: XSchema): schema is XPrefixItems;
8
+ export declare function IsPrefixItems(schema: XSchemaObject): schema is XPrefixItems;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -10,5 +10,5 @@ import { IsSchemaLike } from './schema.mjs';
10
10
  export function IsPrefixItems(schema) {
11
11
  return Guard.HasPropertyKey(schema, 'prefixItems')
12
12
  && Guard.IsArray(schema.prefixItems)
13
- && schema.prefixItems.every(schema => IsSchemaLike(schema));
13
+ && schema.prefixItems.every(schema => IsSchema(schema));
14
14
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XProperties<Properties extends Record<PropertyKey, XSchemaLike> = Record<PropertyKey, XSchemaLike>> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XProperties<Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>> {
3
3
  properties: Properties;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid properties property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsProperties(schema: XSchema): schema is XProperties;
9
+ export declare function IsProperties(schema: XSchemaObject): schema is XProperties;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -11,5 +11,5 @@ import { IsSchemaLike } from './schema.mjs';
11
11
  export function IsProperties(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'properties')
13
13
  && Guard.IsObject(schema.properties)
14
- && Object.values(schema.properties).every(value => IsSchemaLike(value));
14
+ && Object.values(schema.properties).every(value => IsSchema(value));
15
15
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XPropertyNames<PropertyNames extends XSchemaLike = XSchemaLike> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XPropertyNames<PropertyNames extends XSchema = XSchema> {
3
3
  propertyNames: PropertyNames;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid propertyNames property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsPropertyNames(schema: XSchema): schema is XPropertyNames;
9
+ export declare function IsPropertyNames(schema: XSchemaObject): schema is XPropertyNames;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -11,5 +11,5 @@ import { IsSchemaLike } from './schema.mjs';
11
11
  export function IsPropertyNames(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'propertyNames')
13
13
  && (Guard.IsObject(schema.propertyNames)
14
- || IsSchemaLike(schema.propertyNames));
14
+ || IsSchema(schema.propertyNames));
15
15
  }
@@ -1,4 +1,4 @@
1
- import { type XSchema } from './schema.mjs';
1
+ import { type XSchemaObject } from './schema.mjs';
2
2
  export interface XRef<Ref extends string = string> {
3
3
  $ref: Ref;
4
4
  }
@@ -6,4 +6,4 @@ export interface XRef<Ref extends string = string> {
6
6
  * Returns true if the schema contains a valid $ref property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsRef(schema: XSchema): schema is XRef;
9
+ export declare function IsRef(schema: XSchemaObject): schema is XRef;
@@ -1,4 +1,4 @@
1
- import { type XSchema } from './schema.mjs';
1
+ import { type XSchemaObject } from './schema.mjs';
2
2
  export interface XRequired<Required extends string[] = string[]> {
3
3
  required: Required;
4
4
  }
@@ -6,4 +6,4 @@ export interface XRequired<Required extends string[] = string[]> {
6
6
  * Returns true if the schema contains a valid required property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsRequired(schema: XSchema): schema is XRequired;
9
+ export declare function IsRequired(schema: XSchemaObject): schema is XRequired;
@@ -1,9 +1,9 @@
1
- export type XSchema = object;
1
+ export type XSchemaObject = object;
2
2
  /** Returns true if this value is object like */
3
- export declare function IsSchema(value: unknown): value is XSchema;
3
+ export declare function IsSchemaObject(value: unknown): value is XSchemaObject;
4
4
  export type XSchemaBoolean = boolean;
5
5
  /** Returns true if this value is a boolean */
6
6
  export declare function IsBooleanSchema(value: unknown): value is XSchemaBoolean;
7
- export type XSchemaLike = XSchema | XSchemaBoolean;
7
+ export type XSchema = XSchemaObject | XSchemaBoolean;
8
8
  /** Returns true if this value is schema like */
9
- export declare function IsSchemaLike(value: unknown): value is XSchemaLike;
9
+ export declare function IsSchema(value: unknown): value is XSchema;
@@ -1,7 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
3
  /** Returns true if this value is object like */
4
- export function IsSchema(value) {
4
+ export function IsSchemaObject(value) {
5
5
  return Guard.IsObject(value) && !Guard.IsArray(value);
6
6
  }
7
7
  /** Returns true if this value is a boolean */
@@ -9,6 +9,6 @@ export function IsBooleanSchema(value) {
9
9
  return Guard.IsBoolean(value);
10
10
  }
11
11
  /** Returns true if this value is schema like */
12
- export function IsSchemaLike(value) {
13
- return IsSchema(value) || IsBooleanSchema(value);
12
+ export function IsSchema(value) {
13
+ return IsSchemaObject(value) || IsBooleanSchema(value);
14
14
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XThen<Then extends XSchemaLike = XSchemaLike> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XThen<Then extends XSchema = XSchema> {
3
3
  then: Then;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid then property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsThen(schema: XSchema): schema is XThen;
9
+ export declare function IsThen(schema: XSchemaObject): schema is XThen;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -10,5 +10,5 @@ import { IsSchemaLike } from './schema.mjs';
10
10
  */
11
11
  export function IsThen(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'then')
13
- && IsSchemaLike(schema.then);
13
+ && IsSchema(schema.then);
14
14
  }
@@ -1,4 +1,4 @@
1
- import { type XSchema } from './schema.mjs';
1
+ import { type XSchemaObject } from './schema.mjs';
2
2
  export interface XType<Type extends string | string[] = string | string[]> {
3
3
  type: Type;
4
4
  }
@@ -6,4 +6,4 @@ export interface XType<Type extends string | string[] = string | string[]> {
6
6
  * Returns true if the schema contains a valid type property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsType(schema: XSchema): schema is XType;
9
+ export declare function IsType(schema: XSchemaObject): schema is XType;
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XUnevaluatedItems<unevaluatedItems extends XSchemaLike = XSchemaLike> {
3
- unevaluatedItems: XSchemaLike;
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XUnevaluatedItems<unevaluatedItems extends XSchema = XSchema> {
3
+ unevaluatedItems: XSchema;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid unevaluatedItems property
7
7
  * @specification Json Schema 2019-09
8
8
  */
9
- export declare function IsUnevaluatedItems(schema: XSchema): schema is XUnevaluatedItems;
9
+ export declare function IsUnevaluatedItems(schema: XSchemaObject): schema is XUnevaluatedItems;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -10,5 +10,5 @@ import { IsSchemaLike } from './schema.mjs';
10
10
  */
11
11
  export function IsUnevaluatedItems(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'unevaluatedItems')
13
- && IsSchemaLike(schema.unevaluatedItems);
13
+ && IsSchema(schema.unevaluatedItems);
14
14
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XUnevaluatedProperties<UnevaluatedProperties extends XSchemaLike = XSchemaLike> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XUnevaluatedProperties<UnevaluatedProperties extends XSchema = XSchema> {
3
3
  unevaluatedProperties: UnevaluatedProperties;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid unevaluatedProperties property
7
7
  * @specification Json Schema 2019-09
8
8
  */
9
- export declare function IsUnevaluatedProperties(schema: XSchema): schema is XUnevaluatedProperties;
9
+ export declare function IsUnevaluatedProperties(schema: XSchemaObject): schema is XUnevaluatedProperties;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from './schema.mjs';
3
+ import { IsSchema } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -10,5 +10,5 @@ import { IsSchemaLike } from './schema.mjs';
10
10
  */
11
11
  export function IsUnevaluatedProperties(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'unevaluatedProperties')
13
- && IsSchemaLike(schema.unevaluatedProperties);
13
+ && IsSchema(schema.unevaluatedProperties);
14
14
  }
@@ -1,4 +1,4 @@
1
- import { type XSchema } from './schema.mjs';
1
+ import { type XSchemaObject } from './schema.mjs';
2
2
  export interface XUniqueItems<UniqueItems extends boolean = boolean> {
3
3
  uniqueItems: UniqueItems;
4
4
  }
@@ -6,4 +6,4 @@ export interface XUniqueItems<UniqueItems extends boolean = boolean> {
6
6
  * Returns true if the schema contains a valid uniqueItems property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsUniqueItems(schema: XSchema): schema is XUniqueItems;
9
+ export declare function IsUniqueItems(schema: XSchemaObject): schema is XUniqueItems;
@@ -1,12 +1,6 @@
1
1
  import { type TSchema } from './schema.mjs';
2
2
  import { type XGuard, type XGuardInterface } from '../../schema/types/index.mjs';
3
- export declare class NotImplemented extends Error {
4
- readonly cause: {
5
- type: Base;
6
- method: string;
7
- };
8
- constructor(type: Base, method: string);
9
- }
3
+ export type StaticBase<Value extends unknown> = Value;
10
4
  /** Base class for creating extension types. */
11
5
  export declare class Base<Value extends unknown = unknown> implements TSchema, XGuard<Value> {
12
6
  readonly '~kind': 'Base';
@@ -2,20 +2,6 @@
2
2
  import { Settings } from '../../system/settings/index.mjs';
3
3
  import { IsKind } from './schema.mjs';
4
4
  // ------------------------------------------------------------------
5
- // NotImplemented
6
- // ------------------------------------------------------------------
7
- export class NotImplemented extends Error {
8
- constructor(type, method) {
9
- super(`Base type does not implement the '${method}' function`);
10
- Object.defineProperty(this, 'cause', {
11
- value: { type, method },
12
- writable: false,
13
- configurable: false,
14
- enumerable: false
15
- });
16
- }
17
- }
18
- // ------------------------------------------------------------------
19
5
  // Type.Base<...>
20
6
  // ------------------------------------------------------------------
21
7
  /** Base class for creating extension types. */
@@ -60,7 +46,7 @@ export class Base {
60
46
  }
61
47
  /** Creates a new instance of this type */
62
48
  Create() {
63
- throw new NotImplemented(this, 'Create');
49
+ throw new Error('Create not implemented');
64
50
  }
65
51
  }
66
52
  // ------------------------------------------------------------------
@@ -2,6 +2,7 @@ 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
4
  import type { StaticAsyncIterator, TAsyncIterator } from './async-iterator.mjs';
5
+ import type { StaticBase, Base } from './base.mjs';
5
6
  import type { StaticBigInt, TBigInt } from './bigint.mjs';
6
7
  import type { StaticBoolean, TBoolean } from './boolean.mjs';
7
8
  import type { StaticConstructor, TConstructor } from './constructor.mjs';
@@ -31,12 +32,12 @@ import type { StaticUnion, TUnion } from './union.mjs';
31
32
  import type { StaticUnknown, TUnknown } from './unknown.mjs';
32
33
  import type { StaticUnsafe, TUnsafe } from './unsafe.mjs';
33
34
  import type { StaticVoid, TVoid } from './void.mjs';
34
- import type { XStatic } from '../../schema/types/static.mjs';
35
+ import type { XStatic } from '../../schema/static/static.mjs';
35
36
  export type StaticEvaluate<T> = {
36
37
  [K in keyof T]: T[K];
37
38
  } & {};
38
39
  export type StaticDirection = 'Encode' | 'Decode';
39
- 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 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 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>);
40
+ 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 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>);
40
41
  /** Infers a static type from a TypeBox type using Parse logic. */
41
42
  export type StaticParse<Type extends TSchema, Context extends TProperties = {}> = StaticType<[], 'Decode', Context, {}, Type>;
42
43
  /** Infers a static type from a TypeBox type using Decode logic. */
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.0.36",
4
+ "version": "1.0.37",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
@@ -16,38 +16,38 @@
16
16
  "types": "./build/index.d.mts",
17
17
  "module": "./build/index.mjs",
18
18
  "exports": {
19
- "./guard": {
20
- "import": "./build/guard/index.mjs",
21
- "default": "./build/guard/index.mjs"
19
+ "./error": {
20
+ "import": "./build/error/index.mjs",
21
+ "default": "./build/error/index.mjs"
22
22
  },
23
23
  "./schema": {
24
24
  "import": "./build/schema/index.mjs",
25
25
  "default": "./build/schema/index.mjs"
26
26
  },
27
- "./value": {
28
- "import": "./build/value/index.mjs",
29
- "default": "./build/value/index.mjs"
30
- },
31
27
  "./format": {
32
28
  "import": "./build/format/index.mjs",
33
29
  "default": "./build/format/index.mjs"
34
30
  },
31
+ "./compile": {
32
+ "import": "./build/compile/index.mjs",
33
+ "default": "./build/compile/index.mjs"
34
+ },
35
+ "./guard": {
36
+ "import": "./build/guard/index.mjs",
37
+ "default": "./build/guard/index.mjs"
38
+ },
39
+ "./value": {
40
+ "import": "./build/value/index.mjs",
41
+ "default": "./build/value/index.mjs"
42
+ },
35
43
  "./type": {
36
44
  "import": "./build/type/index.mjs",
37
45
  "default": "./build/type/index.mjs"
38
46
  },
39
- "./error": {
40
- "import": "./build/error/index.mjs",
41
- "default": "./build/error/index.mjs"
42
- },
43
47
  "./system": {
44
48
  "import": "./build/system/index.mjs",
45
49
  "default": "./build/system/index.mjs"
46
50
  },
47
- "./compile": {
48
- "import": "./build/compile/index.mjs",
49
- "default": "./build/compile/index.mjs"
50
- },
51
51
  ".": {
52
52
  "import": "./build/index.mjs",
53
53
  "default": "./build/index.mjs"
@@ -55,30 +55,30 @@
55
55
  },
56
56
  "typesVersions": {
57
57
  "*": {
58
- "guard": [
59
- "./build/guard/index.d.mts"
58
+ "error": [
59
+ "./build/error/index.d.mts"
60
60
  ],
61
61
  "schema": [
62
62
  "./build/schema/index.d.mts"
63
63
  ],
64
- "value": [
65
- "./build/value/index.d.mts"
66
- ],
67
64
  "format": [
68
65
  "./build/format/index.d.mts"
69
66
  ],
67
+ "compile": [
68
+ "./build/compile/index.d.mts"
69
+ ],
70
+ "guard": [
71
+ "./build/guard/index.d.mts"
72
+ ],
73
+ "value": [
74
+ "./build/value/index.d.mts"
75
+ ],
70
76
  "type": [
71
77
  "./build/type/index.d.mts"
72
78
  ],
73
- "error": [
74
- "./build/error/index.d.mts"
75
- ],
76
79
  "system": [
77
80
  "./build/system/index.d.mts"
78
81
  ],
79
- "compile": [
80
- "./build/compile/index.d.mts"
81
- ],
82
82
  ".": [
83
83
  "./build/index.d.mts"
84
84
  ]
@@ -1,113 +0,0 @@
1
- import type { XGuard } from './_guard.mjs';
2
- import type { XSchemaLike } from './schema.mjs';
3
- import type { XAdditionalProperties } from './additionalProperties.mjs';
4
- import type { XAnyOf } from './anyOf.mjs';
5
- import type { XAllOf } from './allOf.mjs';
6
- import type { XConst } from './const.mjs';
7
- import type { XEnum } from './enum.mjs';
8
- import type { XItems } from './items.mjs';
9
- import type { XOneOf } from './oneOf.mjs';
10
- import type { XPatternProperties } from './patternProperties.mjs';
11
- import type { XPrefixItems } from './prefixItems.mjs';
12
- import type { XProperties } from './properties.mjs';
13
- import type { XRequired } from './required.mjs';
14
- export type XStaticBase<Value extends unknown> = Value;
15
- type XStaticAdditionalProperties<Schema extends XSchemaLike, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
16
- [key: string]: unknown;
17
- } : Schema extends false ? {} : {
18
- [key: string]: XStaticType<Schema>;
19
- })> = Result;
20
- type XStaticAllOf<Schemas extends XSchemaLike[], Result extends unknown = unknown> = Schemas extends [infer Left extends XSchemaLike, ...infer Right extends XSchemaLike[]] ? XStaticAllOf<Right, XStaticType<Left> & Result> : Result;
21
- type XStaticAnyOf<Schemas extends XSchemaLike[], Result extends unknown = never> = Schemas extends [infer Left extends XSchemaLike, ...infer Right extends XSchemaLike[]] ? XStaticAnyOf<Right, XStaticType<Left> | Result> : Result;
22
- type XStaticConst<Value extends unknown> = Value;
23
- type XStaticEnum<Values extends unknown[], Result extends unknown = never> = Values extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XStaticEnum<Right, Left | Result> : Result;
24
- type XStaticItemsUnsized<Schema extends XSchemaLike> = XStaticType<Schema>[];
25
- type XStaticItemsSized<Schema extends XSchemaLike[], Result extends unknown[] = []> = Schema extends [infer Left extends XSchemaLike, ...infer Right extends XSchemaLike[]] ? XStaticItemsSized<Right, [...Result, XStaticType<Left>]> : Result;
26
- type XStaticItems<Schemas extends XSchemaLike[] | XSchemaLike, Result extends unknown = (Schemas extends XSchemaLike[] ? XStaticItemsSized<[...Schemas]> : Schemas extends XSchemaLike ? XStaticItemsUnsized<Schemas> : never)> = Result;
27
- type XStaticOneOf<Schemas extends XSchemaLike[], Result extends unknown = never> = Schemas extends [infer Left extends XSchemaLike, ...infer Right extends XSchemaLike[]] ? XStaticOneOf<Right, XStaticType<Left> | Result> : Result;
28
- type XStaticPatternProperties<Properties extends Record<PropertyKey, XSchemaLike> = Record<PropertyKey, XSchemaLike>, InferredProperties extends Record<PropertyKey, unknown> = {
29
- [Key in keyof Properties]: XStaticType<Properties[Key]>;
30
- }, EvaluatedProperties extends unknown = {
31
- [key: string]: InferredProperties[keyof InferredProperties];
32
- }> = EvaluatedProperties;
33
- type XStaticPrefixItems<Schemas extends XSchemaLike[], Result extends unknown[] = []> = Schemas extends [infer Left extends XSchemaLike, ...infer Right extends XSchemaLike[]] ? XStaticPrefixItems<Right, [...Result, XStaticType<Left>]> : Result;
34
- type XStaticProperties<Properties extends Record<PropertyKey, XSchemaLike>, Readonly extends Record<PropertyKey, unknown> = {
35
- readonly [Key in keyof Properties as Properties[Key] extends {
36
- readOnly: true;
37
- } ? Key : never]?: XStaticType<Properties[Key]>;
38
- }, Standard extends Record<PropertyKey, unknown> = {
39
- [Key in keyof Properties as Properties[Key] extends {
40
- readOnly: true;
41
- } ? never : Key]?: XStaticType<Properties[Key]>;
42
- }, Result extends Record<PropertyKey, unknown> = Readonly & Standard> = Result;
43
- type RequiredSelectProperty<Properties extends Record<PropertyKey, XSchemaLike>, Key extends string, Result extends Record<PropertyKey, unknown> = (Key extends keyof Properties ? Properties[Key] extends {
44
- readOnly: true;
45
- } ? {
46
- readonly [_ in Key]: XStaticType<Properties[Key]>;
47
- } : {
48
- [_ in Key]: XStaticType<Properties[Key]>;
49
- } : {
50
- [_ in Key]: unknown;
51
- })> = Result;
52
- type RequiredSelectProperties<Properties extends Record<PropertyKey, XSchemaLike>, Keys extends string[], Result extends Record<PropertyKey, unknown> = {}> = Keys extends [infer Left extends string, ...infer Right extends string[]] ? RequiredSelectProperties<Properties, Right, Result & RequiredSelectProperty<Properties, Left>> : Result;
53
- type RequiredGetProperties<Schema extends XSchemaLike, Result extends Record<PropertyKey, unknown> = (Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchemaLike>> ? Properties : {})> = Result;
54
- type XStaticRequired<Schema extends XSchemaLike, Keys extends string[], Properties extends Record<PropertyKey, XSchemaLike> = RequiredGetProperties<Schema>, Result extends Record<PropertyKey, unknown> = RequiredSelectProperties<Properties, Keys>> = Result;
55
- type XStaticKeywords<Schema, Result extends unknown[] = [
56
- Schema extends XAdditionalProperties<infer Type extends XSchemaLike> ? XStaticAdditionalProperties<Type> : unknown,
57
- Schema extends XAllOf<infer Types extends XSchemaLike[]> ? XStaticAllOf<Types> : unknown,
58
- Schema extends XAnyOf<infer Types extends XSchemaLike[]> ? XStaticAnyOf<Types> : unknown,
59
- Schema extends XConst<infer Value extends unknown> ? XStaticConst<Value> : unknown,
60
- Schema extends XEnum<infer Values extends unknown[]> ? XStaticEnum<Values> : unknown,
61
- Schema extends XItems<infer Types extends XSchemaLike[] | XSchemaLike> ? XStaticItems<Types> : unknown,
62
- Schema extends XOneOf<infer Types extends XSchemaLike[]> ? XStaticOneOf<Types> : unknown,
63
- Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchemaLike>> ? XStaticPatternProperties<Properties> : unknown,
64
- Schema extends XPrefixItems<infer Types extends XSchemaLike[]> ? XStaticPrefixItems<Types> : unknown,
65
- Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchemaLike>> ? XStaticProperties<Properties> : unknown,
66
- Schema extends XRequired<infer Keys extends string[]> ? XStaticRequired<Schema, Keys> : unknown,
67
- Schema extends {
68
- type: 'array';
69
- } ? {} : unknown,
70
- Schema extends {
71
- type: 'bigint';
72
- } ? bigint : unknown,
73
- Schema extends {
74
- type: 'boolean';
75
- } ? boolean : unknown,
76
- Schema extends {
77
- type: 'integer';
78
- } ? number : unknown,
79
- Schema extends {
80
- type: 'object';
81
- } ? object : unknown,
82
- Schema extends {
83
- type: 'null';
84
- } ? null : unknown,
85
- Schema extends {
86
- type: 'number';
87
- } ? number : unknown,
88
- Schema extends {
89
- type: 'string';
90
- } ? string : unknown,
91
- Schema extends {
92
- type: 'symbol';
93
- } ? symbol : unknown,
94
- Schema extends {
95
- type: 'undefined';
96
- } ? undefined : unknown
97
- ]> = Result;
98
- type XStaticKeywordIntersect<Schemas extends unknown[], Result extends unknown = unknown> = (Schemas extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XStaticKeywordIntersect<Right, Result & Left> : Result);
99
- type XStaticEvaluate<Schema extends unknown, Result extends unknown = Schema extends object ? {
100
- [Key in keyof Schema]: Schema[Key];
101
- } : Schema> = Result;
102
- type XStaticJsonSchema<Schema extends unknown, Keywords extends unknown[] = XStaticKeywords<Schema>, Intersect extends unknown = XStaticKeywordIntersect<Keywords>, Result extends unknown = XStaticEvaluate<Intersect>> = Result;
103
- /** Statically infers a JSON Schema or Validator */
104
- export type XStaticType<Schema extends XSchemaLike, Result extends unknown = (Schema extends XGuard<infer Value> ? Value : XStaticJsonSchema<Schema>)> = Result;
105
- type XStaticMutableTuple<Schemas extends readonly unknown[]> = (Schemas extends [infer Left, ...infer Right extends unknown[]] ? [XStaticMutable<Left>, ...XStaticMutableTuple<Right>] : []);
106
- type XStaticMutableArray<Schema extends unknown, Result extends unknown[] = XStaticMutable<Schema>[]> = Result;
107
- type XStaticMutableObject<Schema extends object, Result extends Record<PropertyKey, unknown> = {
108
- -readonly [K in keyof Schema]: XStaticMutable<Schema[K]>;
109
- }> = Result;
110
- type XStaticMutable<Schema> = (Schema extends XGuard ? Schema : Schema extends readonly [...infer Schemas extends unknown[]] ? XStaticMutableTuple<Schemas> : Schema extends readonly (infer Schema)[] ? XStaticMutableArray<Schema> : Schema extends object ? XStaticMutableObject<Schema> : Schema);
111
- /** Statically infers a JSON Schema */
112
- export type XStatic<Schema extends XSchemaLike, Mutable extends XSchemaLike = XStaticMutable<Schema>, Result extends unknown = XStaticType<Mutable>> = Result;
113
- export {};