typebox 1.0.35 → 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 (152) 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/engine/instantiate.d.mts +2 -1
  122. package/build/type/engine/instantiate.mjs +5 -1
  123. package/build/type/extends/array.d.mts +15 -2
  124. package/build/type/extends/array.mjs +16 -4
  125. package/build/type/extends/extends-left.d.mts +1 -1
  126. package/build/type/extends/extends-left.mjs +1 -1
  127. package/build/type/extends/literal.d.mts +2 -1
  128. package/build/type/extends/literal.mjs +4 -1
  129. package/build/type/script/mapping.d.mts +2 -0
  130. package/build/type/script/mapping.mjs +3 -0
  131. package/build/type/script/parser.d.mts +3 -1
  132. package/build/type/script/parser.mjs +2 -1
  133. package/build/type/types/_immutable.d.mts +16 -0
  134. package/build/type/types/_immutable.mjs +26 -0
  135. package/build/type/types/_readonly.d.mts +2 -2
  136. package/build/type/types/_readonly.mjs +3 -3
  137. package/build/type/types/_refine.mjs +1 -1
  138. package/build/type/types/array.d.mts +2 -1
  139. package/build/type/types/base.d.mts +1 -7
  140. package/build/type/types/base.mjs +12 -20
  141. package/build/type/types/index.d.mts +1 -0
  142. package/build/type/types/index.mjs +1 -0
  143. package/build/type/types/literal.d.mts +9 -0
  144. package/build/type/types/literal.mjs +22 -1
  145. package/build/type/types/static.d.mts +3 -2
  146. package/build/type/types/tuple.d.mts +2 -1
  147. package/build/typebox.d.mts +1 -0
  148. package/build/typebox.mjs +1 -0
  149. package/package.json +28 -28
  150. package/readme.md +1 -1
  151. package/build/schema/types/static.d.mts +0 -113
  152. /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,3 +1,4 @@
1
+ import { type TImmutable } from '../types/_immutable.mjs';
1
2
  import { type TOptional, TOptionalAdd, TOptionalRemove } from '../types/_optional.mjs';
2
3
  import { type TReadonly, TReadonlyAdd, TReadonlyRemove } from '../types/_readonly.mjs';
3
4
  import { type TSchema } from '../types/schema.mjs';
@@ -151,7 +152,7 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
151
152
  Action,
152
153
  Parameters
153
154
  ] extends ['Uppercase', [infer Type extends TSchema]] ? TUppercaseInstantiate<Context, State, Type> : TDeferred<Action, Parameters>);
154
- export type TInstantiateType<Context extends TProperties, State extends TState, Input extends TSchema, ModifierState extends [TSchema, ModifierAction, ModifierAction] = TModifierActions<Input, Input extends TReadonly<Input> ? 'add' : 'none', Input extends TOptional<Input> ? 'add' : 'none'>, Type extends TSchema = ModifierState[0], Instantiated extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TInstantiateType<Context, State, Type>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type)> = TApplyReadonly<ModifierState[1], TApplyOptional<ModifierState[2], Instantiated>>;
155
+ export type TInstantiateType<Context extends TProperties, State extends TState, Input extends TSchema, IsImmutable extends boolean = Input extends TImmutable ? true : false, ModifierState extends [TSchema, ModifierAction, ModifierAction] = TModifierActions<Input, Input extends TReadonly<Input> ? 'add' : 'none', Input extends TOptional<Input> ? 'add' : 'none'>, Type extends TSchema = ModifierState[0], Instantiated extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TInstantiateType<Context, State, Type>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithImmutable extends TSchema = IsImmutable extends true ? TImmutable<Instantiated> : Instantiated, WithModifiers extends TSchema = TApplyReadonly<ModifierState[1], TApplyOptional<ModifierState[2], WithImmutable>>> = WithModifiers;
155
156
  export declare function InstantiateType<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, input: Type): TInstantiateType<Context, State, Type>;
156
157
  /** Instantiates computed schematics using the given context and type. */
157
158
  export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, {
@@ -4,6 +4,7 @@ import { Guard } from '../../guard/index.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Modifiers
6
6
  // ------------------------------------------------------------------
7
+ import { IsImmutable, Immutable } from '../types/_immutable.mjs';
7
8
  import { IsOptional, OptionalAdd, OptionalRemove } from '../types/_optional.mjs';
8
9
  import { IsReadonly, ReadonlyAdd, ReadonlyRemove } from '../types/_readonly.mjs';
9
10
  // ------------------------------------------------------------------
@@ -139,6 +140,7 @@ function InstantiateDeferred(context, state, action, parameters, options) {
139
140
  Deferred(action, parameters, options));
140
141
  }
141
142
  export function InstantiateType(context, state, input) {
143
+ const isImmutable = IsImmutable(input);
142
144
  const modifierActions = ModifierActions(input, IsReadonly(input) ? 'add' : 'none', IsOptional(input) ? 'add' : 'none');
143
145
  const type = modifierActions[0];
144
146
  const instantiated = (IsRef(type) ? RefInstantiate(context, state, type.$ref) :
@@ -157,7 +159,9 @@ export function InstantiateType(context, state, input) {
157
159
  IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) :
158
160
  IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) :
159
161
  type);
160
- return ApplyReadonly(modifierActions[1], ApplyOptional(modifierActions[2], instantiated));
162
+ const withImmutable = isImmutable ? Immutable(instantiated) : instantiated;
163
+ const withModifiers = ApplyReadonly(modifierActions[1], ApplyOptional(modifierActions[2], withImmutable));
164
+ return withModifiers;
161
165
  }
162
166
  /** Instantiates computed schematics using the given context and type. */
163
167
  export function Instantiate(context, type) {
@@ -1,7 +1,20 @@
1
1
  import { type TSchema } from '../types/schema.mjs';
2
2
  import { type TProperties } from '../types/properties.mjs';
3
3
  import { type TArray } from '../types/array.mjs';
4
+ import { type TImmutable } from '../types/_immutable.mjs';
4
5
  import { type TExtendsRight } from './extends-right.mjs';
5
6
  import { type TExtendsLeft } from './extends-left.mjs';
6
- export type TExtendsArray<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TArray<infer Type extends TSchema> ? TExtendsLeft<Inferred, Left, Type> : TExtendsRight<Inferred, TArray<Left>, Right>);
7
- export declare function ExtendsArray<Inferred extends TProperties, Left extends TSchema, Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsArray<Inferred, Left, Right>;
7
+ import * as Result from './result.mjs';
8
+ type TExtendsImmutable<Left extends TSchema, Right extends TSchema, IsImmutableLeft extends boolean = Left extends TImmutable ? true : false, IsImmutableRight extends boolean = Right extends TImmutable ? true : false, Result extends boolean = [
9
+ IsImmutableLeft,
10
+ IsImmutableRight
11
+ ] extends [true, true] ? true : [
12
+ IsImmutableLeft,
13
+ IsImmutableRight
14
+ ] extends [false, true] ? true : [
15
+ IsImmutableLeft,
16
+ IsImmutableRight
17
+ ] extends [true, false] ? false : true> = Result;
18
+ export type TExtendsArray<Inferred extends TProperties, ArrayLeft extends TSchema, Left extends TSchema, Right extends TSchema> = (Right extends TArray<infer Type extends TSchema> ? TExtendsImmutable<ArrayLeft, Right> extends true ? TExtendsLeft<Inferred, Left, Type> : Result.TExtendsFalse : TExtendsRight<Inferred, ArrayLeft, Right>);
19
+ export declare function ExtendsArray<Inferred extends TProperties, ArrayLeft extends TSchema, Left extends TSchema, Right extends TSchema>(inferred: Inferred, arrayLeft: ArrayLeft, left: Left, right: Right): TExtendsArray<Inferred, ArrayLeft, Left, Right>;
20
+ export {};
@@ -1,9 +1,21 @@
1
1
  // deno-fmt-ignore-file
2
- import { Array, IsArray } from '../types/array.mjs';
2
+ import { IsArray } from '../types/array.mjs';
3
+ import { IsImmutable } from '../types/_immutable.mjs';
3
4
  import { ExtendsRight } from './extends-right.mjs';
4
5
  import { ExtendsLeft } from './extends-left.mjs';
5
- export function ExtendsArray(inferred, left, right) {
6
+ import * as Result from './result.mjs';
7
+ function ExtendsImmutable(left, right) {
8
+ const isImmutableLeft = IsImmutable(left);
9
+ const isImmutableRight = IsImmutable(right);
10
+ return (isImmutableLeft && isImmutableRight ? true :
11
+ !isImmutableLeft && isImmutableRight ? true :
12
+ isImmutableLeft && !isImmutableRight ? false :
13
+ true);
14
+ }
15
+ export function ExtendsArray(inferred, arrayLeft, left, right) {
6
16
  return (IsArray(right)
7
- ? ExtendsLeft(inferred, left, right.items)
8
- : ExtendsRight(inferred, Array(left), right));
17
+ ? ExtendsImmutable(arrayLeft, right)
18
+ ? ExtendsLeft(inferred, left, right.items)
19
+ : Result.ExtendsFalse()
20
+ : ExtendsRight(inferred, arrayLeft, right));
9
21
  }
@@ -51,5 +51,5 @@ import { type TProperties } from '../types/properties.mjs';
51
51
  import { type TUnion } from '../types/union.mjs';
52
52
  import { type TVoid } from '../types/void.mjs';
53
53
  import * as Result from './result.mjs';
54
- export type TExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TAny ? TExtendsAny<Inferred, Left, Right> : Left extends TArray<infer Type extends TSchema> ? TExtendsArray<Inferred, Type, Right> : Left extends TAsyncIterator<infer Type extends TSchema> ? TExtendsAsyncIterator<Inferred, Type, Right> : Left extends TBigInt ? TExtendsBigInt<Inferred, Left, Right> : Left extends TBoolean ? TExtendsBoolean<Inferred, Left, Right> : Left extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TExtendsConstructor<Inferred, Parameters, InstanceType, Right> : Left extends TEnum<infer Values extends TEnumValue[]> ? TExtendsEnum<Inferred, TEnum<Values>, Right> : Left extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TExtendsFunction<Inferred, Parameters, ReturnType, Right> : Left extends TInteger ? TExtendsInteger<Inferred, Left, Right> : Left extends TIntersect<infer Types extends TSchema[]> ? TExtendsIntersect<Inferred, Types, Right> : Left extends TIterator<infer Type extends TSchema> ? TExtendsIterator<Inferred, Type, Right> : Left extends TLiteral ? TExtendsLiteral<Inferred, Left, Right> : Left extends TNever ? TExtendsNever<Inferred, Left, Right> : Left extends TNull ? TExtendsNull<Inferred, Left, Right> : Left extends TNumber ? TExtendsNumber<Inferred, Left, Right> : Left extends TObject<infer Properties extends TProperties> ? TExtendsObject<Inferred, Properties, Right> : Left extends TPromise<infer Type extends TSchema> ? TExtendsPromise<Inferred, Type, Right> : Left extends TString ? TExtendsString<Inferred, Left, Right> : Left extends TSymbol ? TExtendsSymbol<Inferred, Left, Right> : Left extends TTemplateLiteral<infer Pattern extends string> ? TExtendsTemplateLiteral<Inferred, Pattern, Right> : Left extends TTuple<infer Types extends TSchema[]> ? TExtendsTuple<Inferred, Types, Right> : Left extends TUndefined ? TExtendsUndefined<Inferred, Left, Right> : Left extends TUnion<infer Types extends TSchema[]> ? TExtendsUnion<Inferred, Types, Right> : Left extends TUnknown ? TExtendsUnknown<Inferred, Left, Right> : Left extends TVoid ? TExtendsVoid<Inferred, Left, Right> : Result.TExtendsFalse);
54
+ export type TExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TAny ? TExtendsAny<Inferred, Left, Right> : Left extends TArray<infer Items extends TSchema> ? TExtendsArray<Inferred, Left, Items, Right> : Left extends TAsyncIterator<infer Type extends TSchema> ? TExtendsAsyncIterator<Inferred, Type, Right> : Left extends TBigInt ? TExtendsBigInt<Inferred, Left, Right> : Left extends TBoolean ? TExtendsBoolean<Inferred, Left, Right> : Left extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TExtendsConstructor<Inferred, Parameters, InstanceType, Right> : Left extends TEnum<infer Values extends TEnumValue[]> ? TExtendsEnum<Inferred, TEnum<Values>, Right> : Left extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TExtendsFunction<Inferred, Parameters, ReturnType, Right> : Left extends TInteger ? TExtendsInteger<Inferred, Left, Right> : Left extends TIntersect<infer Types extends TSchema[]> ? TExtendsIntersect<Inferred, Types, Right> : Left extends TIterator<infer Type extends TSchema> ? TExtendsIterator<Inferred, Type, Right> : Left extends TLiteral ? TExtendsLiteral<Inferred, Left, Right> : Left extends TNever ? TExtendsNever<Inferred, Left, Right> : Left extends TNull ? TExtendsNull<Inferred, Left, Right> : Left extends TNumber ? TExtendsNumber<Inferred, Left, Right> : Left extends TObject<infer Properties extends TProperties> ? TExtendsObject<Inferred, Properties, Right> : Left extends TPromise<infer Type extends TSchema> ? TExtendsPromise<Inferred, Type, Right> : Left extends TString ? TExtendsString<Inferred, Left, Right> : Left extends TSymbol ? TExtendsSymbol<Inferred, Left, Right> : Left extends TTemplateLiteral<infer Pattern extends string> ? TExtendsTemplateLiteral<Inferred, Pattern, Right> : Left extends TTuple<infer Types extends TSchema[]> ? TExtendsTuple<Inferred, Types, Right> : Left extends TUndefined ? TExtendsUndefined<Inferred, Left, Right> : Left extends TUnion<infer Types extends TSchema[]> ? TExtendsUnion<Inferred, Types, Right> : Left extends TUnknown ? TExtendsUnknown<Inferred, Left, Right> : Left extends TVoid ? TExtendsVoid<Inferred, Left, Right> : Result.TExtendsFalse);
55
55
  export declare function ExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsLeft<Inferred, Left, Right>;
@@ -55,7 +55,7 @@ import { IsVoid } from '../types/void.mjs';
55
55
  import * as Result from './result.mjs';
56
56
  export function ExtendsLeft(inferred, left, right) {
57
57
  return (IsAny(left) ? ExtendsAny(inferred, left, right) :
58
- IsArray(left) ? ExtendsArray(inferred, left.items, right) :
58
+ IsArray(left) ? ExtendsArray(inferred, left, left.items, right) :
59
59
  IsAsyncIterator(left) ? ExtendsAsyncIterator(inferred, left.iteratorItems, right) :
60
60
  IsBigInt(left) ? ExtendsBigInt(inferred, left, right) :
61
61
  IsBoolean(left) ? ExtendsBoolean(inferred, left, right) :
@@ -1,3 +1,4 @@
1
+ import { TUnreachable } from '../../system/unreachable/unreachable.mjs';
1
2
  import { type TSchema } from '../types/schema.mjs';
2
3
  import { type TProperties } from '../types/properties.mjs';
3
4
  import { type TLiteral, type TLiteralValue } from '../types/literal.mjs';
@@ -12,6 +13,6 @@ type TExtendsLiteralBigInt<Inferred extends TProperties, Left extends bigint, Ri
12
13
  type TExtendsLiteralBoolean<Inferred extends TProperties, Left extends boolean, Right extends TSchema> = (Right extends TLiteral<infer Value extends boolean> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TBoolean ? Result.TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
13
14
  type TExtendsLiteralNumber<Inferred extends TProperties, Left extends number, Right extends TSchema> = (Right extends TLiteral<infer Value extends number> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TNumber ? Result.TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
14
15
  type TExtendsLiteralString<Inferred extends TProperties, Left extends string, Right extends TSchema> = (Right extends TLiteral<infer Value extends string> ? TExtendsLiteralValue<Inferred, Left, Value> : Right extends TString ? Result.TExtendsTrue<Inferred> : TExtendsRight<Inferred, TLiteral<Left>, Right>);
15
- export type TExtendsLiteral<Inferred extends TProperties, Left extends TLiteral, Right extends TSchema> = (Left extends TLiteral<infer Value extends bigint> ? TExtendsLiteralBigInt<Inferred, Value, Right> : Left extends TLiteral<infer Value extends boolean> ? TExtendsLiteralBoolean<Inferred, Value, Right> : Left extends TLiteral<infer Value extends number> ? TExtendsLiteralNumber<Inferred, Value, Right> : Left extends TLiteral<infer Value extends string> ? TExtendsLiteralString<Inferred, Value, Right> : TExtendsRight<Inferred, Left, Right>);
16
+ export type TExtendsLiteral<Inferred extends TProperties, Left extends TLiteral, Right extends TSchema> = (Left extends TLiteral<infer Value extends bigint> ? TExtendsLiteralBigInt<Inferred, Value, Right> : Left extends TLiteral<infer Value extends boolean> ? TExtendsLiteralBoolean<Inferred, Value, Right> : Left extends TLiteral<infer Value extends number> ? TExtendsLiteralNumber<Inferred, Value, Right> : Left extends TLiteral<infer Value extends string> ? TExtendsLiteralString<Inferred, Value, Right> : TUnreachable);
16
17
  export declare function ExtendsLiteral<Inferred extends TProperties, Left extends TLiteral, Right extends TSchema>(inferred: TProperties, left: Left, right: Right): TExtendsLiteral<Inferred, Left, Right>;
17
18
  export {};
@@ -1,4 +1,5 @@
1
1
  // deno-fmt-ignore-file
2
+ import { Unreachable } from '../../system/unreachable/unreachable.mjs';
2
3
  import { Guard } from '../../guard/index.mjs';
3
4
  import { IsLiteral, Literal } from '../types/literal.mjs';
4
5
  import { IsBigInt } from '../types/bigint.mjs';
@@ -37,5 +38,7 @@ export function ExtendsLiteral(inferred, left, right) {
37
38
  Guard.IsBoolean(left.const) ? ExtendsLiteralBoolean(inferred, left.const, right) :
38
39
  Guard.IsNumber(left.const) ? ExtendsLiteralNumber(inferred, left.const, right) :
39
40
  Guard.IsString(left.const) ? ExtendsLiteralString(inferred, left.const, right) :
40
- ExtendsRight(inferred, left, right));
41
+ Unreachable() // ExtendsRight(inferred, left, right)
42
+ );
41
43
  }
44
+ // deno-coverage-ignore-stop
@@ -174,6 +174,8 @@ export type TExprTailMapping<Input extends [unknown, unknown, unknown] | []> = (
174
174
  export declare function ExprTailMapping(input: [unknown, unknown, unknown] | []): unknown;
175
175
  export type TExprMapping<Input extends [unknown, unknown]> = (Input extends [infer Left extends T.TSchema, infer Rest extends unknown[]] ? TExprBinaryMapping<Left, Rest> : []);
176
176
  export declare function ExprMapping(input: [unknown, unknown]): unknown;
177
+ export type TExprReadonlyMapping<Input extends [unknown, unknown]> = (Input extends ['readonly', infer Type extends T.TSchema] ? T.TImmutableAdd<Type> : never);
178
+ export declare function ExprReadonlyMapping(input: [unknown, unknown]): unknown;
177
179
  export type TExprPipeMapping<Input extends [unknown, unknown]> = (Input extends ['|', infer Type extends T.TSchema] ? Type : never);
178
180
  export declare function ExprPipeMapping(input: [unknown, unknown]): unknown;
179
181
  export type TGenericTypeMapping<Input extends [unknown, unknown, unknown]> = (Input extends [infer Arguments extends T.TParameter[], '=', infer Type extends T.TSchema] ? T.TGeneric<Arguments, Type> : never);
@@ -238,6 +238,9 @@ export function ExprMapping(input) {
238
238
  const [left, rest] = input;
239
239
  return ExprBinaryMapping(left, rest);
240
240
  }
241
+ export function ExprReadonlyMapping(input) {
242
+ return T.ImmutableAdd(input[1]);
243
+ }
241
244
  export function ExprPipeMapping(input) {
242
245
  return input[1];
243
246
  }
@@ -48,10 +48,11 @@ export type TExprTermTail<Input extends string> = ((Token.TConst<'&', Input> ext
48
48
  export type TExprTerm<Input extends string> = (TFactor<Input> extends [infer _0, infer Input extends string] ? (TExprTermTail<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprTermMapping<_0>, Input] : [];
49
49
  export type TExprTail<Input extends string> = ((Token.TConst<'|', Input> extends [infer _0, infer Input extends string] ? (TExprTerm<Input> extends [infer _1, infer Input extends string] ? (TExprTail<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExprTailMapping<_0>, Input] : [];
50
50
  export type TExpr<Input extends string> = (TExprTerm<Input> extends [infer _0, infer Input extends string] ? (TExprTail<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprMapping<_0>, Input] : [];
51
+ export type TExprReadonly<Input extends string> = (Token.TConst<'readonly', Input> extends [infer _0, infer Input extends string] ? (TExpr<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprReadonlyMapping<_0>, Input] : [];
51
52
  export type TExprPipe<Input extends string> = (Token.TConst<'|', Input> extends [infer _0, infer Input extends string] ? (TExpr<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprPipeMapping<_0>, Input] : [];
52
53
  export type TGenericType<Input extends string> = (TGenericParameters<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'=', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TGenericTypeMapping<_0>, Input] : [];
53
54
  export type TInferType<Input extends string> = ((Token.TConst<'infer', Input> extends [infer _0, infer Input extends string] ? (Token.TIdent<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'extends', Input> extends [infer _2, infer Input extends string] ? (TExpr<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'infer', Input> extends [infer _0, infer Input extends string] ? (Token.TIdent<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown] | [unknown, unknown], infer Input extends string] ? [S.TInferTypeMapping<_0>, Input] : [];
54
- export type TType<Input extends string> = (TInferType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TExprPipe<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TExpr<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TTypeMapping<_0>, Input] : [];
55
+ export type TType<Input extends string> = (TInferType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TExprPipe<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TExprReadonly<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TExpr<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TTypeMapping<_0>, Input] : [];
55
56
  export type TPropertyKeyNumber<Input extends string> = Token.TNumber<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TPropertyKeyNumberMapping<_0>, Input] : [];
56
57
  export type TPropertyKeyIdent<Input extends string> = Token.TIdent<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TPropertyKeyIdentMapping<_0>, Input] : [];
57
58
  export type TPropertyKeyQuoted<Input extends string> = Token.TString<['\'', '\"'], Input> extends [infer _0 extends string, infer Input extends string] ? [S.TPropertyKeyQuotedMapping<_0>, Input] : [];
@@ -176,6 +177,7 @@ export declare const ExprTermTail: (input: string) => [unknown, string] | [];
176
177
  export declare const ExprTerm: (input: string) => [unknown, string] | [];
177
178
  export declare const ExprTail: (input: string) => [unknown, string] | [];
178
179
  export declare const Expr: (input: string) => [unknown, string] | [];
180
+ export declare const ExprReadonly: (input: string) => [unknown, string] | [];
179
181
  export declare const ExprPipe: (input: string) => [unknown, string] | [];
180
182
  export declare const GenericType: (input: string) => [unknown, string] | [];
181
183
  export declare const InferType: (input: string) => [unknown, string] | [];
@@ -51,10 +51,11 @@ export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, i
51
51
  export const ExprTerm = (input) => If(If(Factor(input), ([_0, input]) => If(ExprTermTail(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprTermMapping(_0), input]);
52
52
  export const ExprTail = (input) => If(If(If(Token.Const('|', input), ([_0, input]) => If(ExprTerm(input), ([_1, input]) => If(ExprTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTailMapping(_0), input]);
53
53
  export const Expr = (input) => If(If(ExprTerm(input), ([_0, input]) => If(ExprTail(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprMapping(_0), input]);
54
+ export const ExprReadonly = (input) => If(If(Token.Const('readonly', input), ([_0, input]) => If(Expr(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprReadonlyMapping(_0), input]);
54
55
  export const ExprPipe = (input) => If(If(Token.Const('|', input), ([_0, input]) => If(Expr(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprPipeMapping(_0), input]);
55
56
  export const GenericType = (input) => If(If(GenericParameters(input), ([_0, input]) => If(Token.Const('=', input), ([_1, input]) => If(Type(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.GenericTypeMapping(_0), input]);
56
57
  export const InferType = (input) => If(If(If(Token.Const('infer', input), ([_0, input]) => If(Token.Ident(input), ([_1, input]) => If(Token.Const('extends', input), ([_2, input]) => If(Expr(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => If(If(Token.Const('infer', input), ([_0, input]) => If(Token.Ident(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.InferTypeMapping(_0), input]);
57
- export const Type = (input) => If(If(InferType(input), ([_0, input]) => [_0, input], () => If(ExprPipe(input), ([_0, input]) => [_0, input], () => If(Expr(input), ([_0, input]) => [_0, input], () => []))), ([_0, input]) => [S.TypeMapping(_0), input]);
58
+ export const Type = (input) => If(If(InferType(input), ([_0, input]) => [_0, input], () => If(ExprPipe(input), ([_0, input]) => [_0, input], () => If(ExprReadonly(input), ([_0, input]) => [_0, input], () => If(Expr(input), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.TypeMapping(_0), input]);
58
59
  export const PropertyKeyNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.PropertyKeyNumberMapping(_0), input]);
59
60
  export const PropertyKeyIdent = (input) => If(Token.Ident(input), ([_0, input]) => [S.PropertyKeyIdentMapping(_0), input]);
60
61
  export const PropertyKeyQuoted = (input) => If(Token.String(['\'', '\"'], input), ([_0, input]) => [S.PropertyKeyQuotedMapping(_0), input]);
@@ -0,0 +1,16 @@
1
+ import { type TSchema } from './schema.mjs';
2
+ /** Removes Immutable from the given type. */
3
+ export type TImmutableRemove<Type extends TSchema, Result extends TSchema = Type extends TImmutable<infer Type extends TSchema> ? Type : Type> = Result;
4
+ /** Removes Immutable from the given type. */
5
+ export declare function ImmutableRemove<Type extends TSchema>(type: Type): TImmutableRemove<Type>;
6
+ /** Adds Immutable to the given type. */
7
+ export type TImmutableAdd<Type extends TSchema = TSchema> = ('~immutable' extends keyof Type ? Type : TImmutable<Type>);
8
+ /** Adds Immutable to the given type. */
9
+ export declare function ImmutableAdd<Type extends TSchema>(type: Type): TImmutableAdd<Type>;
10
+ export type TImmutable<Type extends TSchema = TSchema> = (Type & {
11
+ '~immutable': true;
12
+ });
13
+ /** Applies an Immutable modifier to the given type. */
14
+ export declare function Immutable<Type extends TSchema>(type: Type): TImmutableAdd<Type>;
15
+ /** Returns true if the given value is a TImmutable */
16
+ export declare function IsImmutable(value: unknown): value is TImmutable<TSchema>;
@@ -0,0 +1,26 @@
1
+ // deno-fmt-ignore-file
2
+ import { Memory } from '../../system/memory/index.mjs';
3
+ import { Guard } from '../../guard/index.mjs';
4
+ import { IsSchema } from './schema.mjs';
5
+ /** Removes Immutable from the given type. */
6
+ export function ImmutableRemove(type) {
7
+ return Memory.Discard(type, ['~immutable']);
8
+ }
9
+ /** Adds Immutable to the given type. */
10
+ export function ImmutableAdd(type) {
11
+ return Memory.Update(type, { '~immutable': true }, {});
12
+ }
13
+ // ------------------------------------------------------------------
14
+ // Factory
15
+ // ------------------------------------------------------------------
16
+ /** Applies an Immutable modifier to the given type. */
17
+ export function Immutable(type) {
18
+ return ImmutableAdd(type);
19
+ }
20
+ // ------------------------------------------------------------------
21
+ // Guard
22
+ // ------------------------------------------------------------------
23
+ /** Returns true if the given value is a TImmutable */
24
+ export function IsImmutable(value) {
25
+ return IsSchema(value) && Guard.HasPropertyKey(value, '~immutable');
26
+ }
@@ -4,11 +4,11 @@ export type TReadonlyRemove<Type extends TSchema, Result extends TSchema = Type
4
4
  /** Removes Readaonly from the given type. */
5
5
  export declare function ReadonlyRemove<Type extends TSchema>(type: Type): TReadonlyRemove<Type>;
6
6
  /** Adds Readonly to the given type. */
7
- export type TReadonlyAdd<Type extends TSchema = TSchema> = ('readOnly' extends keyof Type ? Type : TReadonly<Type>);
7
+ export type TReadonlyAdd<Type extends TSchema = TSchema> = ('~readonly' extends keyof Type ? Type : TReadonly<Type>);
8
8
  /** Adds Readonly to the given type. */
9
9
  export declare function ReadonlyAdd<Type extends TSchema>(type: Type): TReadonlyAdd<Type>;
10
10
  export type TReadonly<Type extends TSchema = TSchema> = (Type & {
11
- readOnly: true;
11
+ '~readonly': true;
12
12
  });
13
13
  /** Applies an Readonly modifier to the given type. */
14
14
  export declare function Readonly<Type extends TSchema>(type: Type): TReadonlyAdd<Type>;
@@ -4,11 +4,11 @@ import { Guard } from '../../guard/index.mjs';
4
4
  import { IsSchema } from './schema.mjs';
5
5
  /** Removes Readaonly from the given type. */
6
6
  export function ReadonlyRemove(type) {
7
- return Memory.Discard(type, ['readOnly']);
7
+ return Memory.Discard(type, ['~readonly']);
8
8
  }
9
9
  /** Adds Readonly to the given type. */
10
10
  export function ReadonlyAdd(type) {
11
- return Memory.Update(type, {}, { 'readOnly': true });
11
+ return Memory.Update(type, { '~readonly': true }, {});
12
12
  }
13
13
  // ------------------------------------------------------------------
14
14
  // Factory
@@ -22,5 +22,5 @@ export function Readonly(type) {
22
22
  // ------------------------------------------------------------------
23
23
  /** Returns true if the given value is a TReadonly */
24
24
  export function IsReadonly(value) {
25
- return IsSchema(value) && Guard.HasPropertyKey(value, 'readOnly');
25
+ return IsSchema(value) && Guard.HasPropertyKey(value, '~readonly');
26
26
  }
@@ -5,7 +5,7 @@ import { IsSchema } from './schema.mjs';
5
5
  /** Applies a Refine check to the given type. */
6
6
  export function RefineAdd(type, refinement) {
7
7
  const refinements = IsRefine(type) ? [...type['~refine'], refinement] : [refinement];
8
- return Memory.Update(type, {}, { '~refine': refinements });
8
+ return Memory.Update(type, { '~refine': refinements }, {});
9
9
  }
10
10
  /** Applies a Refine check to the given type. */
11
11
  export function Refine(type, refine, message = 'error') {