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,5 +1,5 @@
1
1
  import * as Engine from './engine/index.mjs';
2
- import { type XSchemaLike } from './types/index.mjs';
2
+ import { type XSchema } from './types/index.mjs';
3
3
  export type CheckFunction = (value: unknown) => boolean;
4
4
  export interface EvaluateResult {
5
5
  IsEvaluated: boolean;
@@ -13,11 +13,11 @@ export declare class BuildResult {
13
13
  private readonly functions;
14
14
  private readonly call;
15
15
  private readonly useUnevaluated;
16
- constructor(context: Record<PropertyKey, XSchemaLike>, schema: XSchemaLike, external: Engine.TExternal, functions: string[], call: string, useUnevaluated: boolean);
16
+ constructor(context: Record<PropertyKey, XSchema>, schema: XSchema, external: Engine.TExternal, functions: string[], call: string, useUnevaluated: boolean);
17
17
  /** Returns the Context used for this build */
18
- Context(): Record<PropertyKey, XSchemaLike>;
18
+ Context(): Record<PropertyKey, XSchema>;
19
19
  /** Returns the Schema used for this build */
20
- Schema(): XSchemaLike;
20
+ Schema(): XSchema;
21
21
  /** Returns true if this build requires a Unevaluated context */
22
22
  UseUnevaluated(): boolean;
23
23
  /** Returns external variables */
@@ -30,6 +30,6 @@ export declare class BuildResult {
30
30
  Evaluate(): EvaluateResult;
31
31
  }
32
32
  /** Builds a schema into a optimized runtime validator */
33
- export declare function Build(schema: XSchemaLike): BuildResult;
33
+ export declare function Build(schema: XSchema): BuildResult;
34
34
  /** Builds a schema into a optimized runtime validator */
35
- export declare function Build(context: Record<PropertyKey, XSchemaLike>, schema: XSchemaLike): BuildResult;
35
+ export declare function Build(context: Record<PropertyKey, XSchema>, schema: XSchema): BuildResult;
@@ -1,5 +1,5 @@
1
- import { XSchemaLike } from './types/index.mjs';
1
+ import { XSchema } from './types/index.mjs';
2
2
  /** Checks a value against the provided schema */
3
- export declare function Check(schema: XSchemaLike, value: unknown): boolean;
3
+ export declare function Check(schema: XSchema, value: unknown): boolean;
4
4
  /** Checks a value against the provided schema */
5
- export declare function Check(context: Record<PropertyKey, XSchemaLike>, schema: XSchemaLike, value: unknown): boolean;
5
+ export declare function Check(context: Record<PropertyKey, XSchema>, schema: XSchema, value: unknown): boolean;
@@ -1,4 +1,4 @@
1
1
  import * as S from '../types/index.mjs';
2
- export declare function Rebase(baseUri: string, schema: S.XSchema): string;
2
+ export declare function Rebase(baseUri: string, schema: S.XSchemaObject): string;
3
3
  /** Deferences a schema with the given Ref */
4
4
  export declare function Deref(schema: object, ref: S.XRef): unknown | undefined;
@@ -35,7 +35,7 @@ function Select(schema, baseUri, $ref) {
35
35
  }
36
36
  if (IsHashPointer($ref)) {
37
37
  const target = Pointer.Get(schema, $ref.slice(1));
38
- if (S.IsSchemaLike(target))
38
+ if (S.IsSchema(target))
39
39
  return target;
40
40
  }
41
41
  return undefined;
@@ -55,7 +55,7 @@ function FromObject(schema, baseUrl, ref) {
55
55
  // ----------------------------------------------------------------
56
56
  const rebase = Rebase(baseUrl, schema);
57
57
  const target = Select(schema, rebase, ref.$ref);
58
- if (S.IsSchemaLike(target))
58
+ if (S.IsSchema(target))
59
59
  return target;
60
60
  // Keep searching ...
61
61
  return Object.values(schema).reduce((result, subschema) => result || FromValue(subschema, rebase, ref), undefined);
@@ -2,15 +2,15 @@ import * as S from '../types/index.mjs';
2
2
  import type { TValidationError } from '../../error/index.mjs';
3
3
  export declare function HasUnevaluated(context: Record<PropertyKey, unknown>, schema: unknown): boolean;
4
4
  export declare class BaseContext {
5
- protected readonly context: Record<PropertyKey, S.XSchemaLike>;
6
- protected readonly schema: S.XSchemaLike;
7
- constructor(context: Record<PropertyKey, S.XSchemaLike>, schema: S.XSchemaLike);
5
+ protected readonly context: Record<PropertyKey, S.XSchema>;
6
+ protected readonly schema: S.XSchema;
7
+ constructor(context: Record<PropertyKey, S.XSchema>, schema: S.XSchema);
8
8
  GetContext(): Record<PropertyKey, object | boolean>;
9
9
  GetSchema(): object | boolean;
10
10
  }
11
11
  export declare class BuildContext extends BaseContext {
12
12
  private readonly hasUnevaluated;
13
- constructor(context: Record<PropertyKey, S.XSchemaLike>, schema: S.XSchemaLike, hasUnevaluated: boolean);
13
+ constructor(context: Record<PropertyKey, S.XSchema>, schema: S.XSchema, hasUnevaluated: boolean);
14
14
  UseUnevaluated(): boolean;
15
15
  AddIndex(index: string): string;
16
16
  AddKey(key: string): string;
@@ -20,7 +20,7 @@ export declare class BuildContext extends BaseContext {
20
20
  export declare class CheckContext extends BaseContext {
21
21
  private readonly indices;
22
22
  private readonly keys;
23
- constructor(context: Record<PropertyKey, S.XSchemaLike>, schema: S.XSchemaLike);
23
+ constructor(context: Record<PropertyKey, S.XSchema>, schema: S.XSchema);
24
24
  AddIndex(index: number): true;
25
25
  AddKey(key: string): true;
26
26
  GetIndices(): Set<number>;
@@ -31,12 +31,12 @@ export declare class CheckContext extends BaseContext {
31
31
  export type ErrorContextCallback = (error: TValidationError) => unknown;
32
32
  export declare class ErrorContext extends CheckContext {
33
33
  private readonly callback;
34
- constructor(context: Record<PropertyKey, S.XSchemaLike>, schema: S.XSchemaLike, callback: ErrorContextCallback);
34
+ constructor(context: Record<PropertyKey, S.XSchema>, schema: S.XSchema, callback: ErrorContextCallback);
35
35
  AddError(error: TValidationError): false;
36
36
  }
37
37
  export declare class AccumulatedErrorContext extends ErrorContext {
38
38
  private readonly errors;
39
- constructor(context: Record<PropertyKey, S.XSchemaLike>, schema: S.XSchemaLike);
39
+ constructor(context: Record<PropertyKey, S.XSchema>, schema: S.XSchema);
40
40
  AddError(error: TValidationError): false;
41
41
  GetErrors(): TValidationError[];
42
42
  }
@@ -2,4 +2,4 @@ import * as S from '../types/index.mjs';
2
2
  import { BuildContext } from './_context.mjs';
3
3
  export declare function ResetFunctions(): void;
4
4
  export declare function GetFunctions(): string[];
5
- export declare function CreateFunction(context: BuildContext, schema: S.XSchemaLike, value: string): string;
5
+ export declare function CreateFunction(context: BuildContext, schema: S.XSchema, value: string): string;
@@ -1,3 +1,3 @@
1
1
  import * as S from '../types/index.mjs';
2
2
  import { BuildContext } from './_context.mjs';
3
- export declare function Reducer(context: BuildContext, schemas: S.XSchemaLike[], value: string, check: string): string;
3
+ export declare function Reducer(context: BuildContext, schemas: S.XSchema[], value: string, check: string): string;
@@ -18,7 +18,7 @@ function Resolve(context, schema) {
18
18
  }
19
19
  // inline referential schema
20
20
  const dereferenced = Deref(schemaRoot, { $ref: schema.$ref });
21
- return S.IsSchemaLike(dereferenced) ? dereferenced : false;
21
+ return S.IsSchema(dereferenced) ? dereferenced : false;
22
22
  }
23
23
  // ------------------------------------------------------------------
24
24
  // Build
@@ -32,12 +32,12 @@ export function BuildRef(context, schema, value) {
32
32
  // ------------------------------------------------------------------
33
33
  export function CheckRef(context, schema, value) {
34
34
  const target = Resolve(context, schema);
35
- return (S.IsSchemaLike(target) && CheckSchema(context, target, value));
35
+ return (S.IsSchema(target) && CheckSchema(context, target, value));
36
36
  }
37
37
  // ------------------------------------------------------------------
38
38
  // Error
39
39
  // ------------------------------------------------------------------
40
40
  export function ErrorRef(context, schemaPath, instancePath, schema, value) {
41
41
  const target = Resolve(context, schema);
42
- return (S.IsSchemaLike(target) && ErrorSchema(context, '#', instancePath, target, value));
42
+ return (S.IsSchema(target) && ErrorSchema(context, '#', instancePath, target, value));
43
43
  }
@@ -1,5 +1,5 @@
1
1
  import * as S from '../types/index.mjs';
2
2
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildSchema(context: BuildContext, schema: S.XSchemaLike, value: string): string;
4
- export declare function CheckSchema(context: CheckContext, schema: S.XSchemaLike, value: unknown): boolean;
5
- export declare function ErrorSchema(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XSchemaLike, value: unknown): boolean;
3
+ export declare function BuildSchema(context: BuildContext, schema: S.XSchema, value: string): string;
4
+ export declare function CheckSchema(context: CheckContext, schema: S.XSchema, value: unknown): boolean;
5
+ export declare function ErrorSchema(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XSchema, value: unknown): boolean;
@@ -58,7 +58,7 @@ function HasObjectType(schema) {
58
58
  return HasTypeName(schema, 'object');
59
59
  }
60
60
  function HasObjectKeywords(schema) {
61
- return S.IsSchema(schema) && (S.IsAdditionalProperties(schema) ||
61
+ return S.IsSchemaObject(schema) && (S.IsAdditionalProperties(schema) ||
62
62
  S.IsDependencies(schema) ||
63
63
  S.IsDependentRequired(schema) ||
64
64
  S.IsDependentSchemas(schema) ||
@@ -77,7 +77,7 @@ function HasArrayType(schema) {
77
77
  return HasTypeName(schema, 'array');
78
78
  }
79
79
  function HasArrayKeywords(schema) {
80
- return S.IsSchema(schema) && (S.IsAdditionalItems(schema) ||
80
+ return S.IsSchemaObject(schema) && (S.IsAdditionalItems(schema) ||
81
81
  S.IsItems(schema) ||
82
82
  S.IsContains(schema) ||
83
83
  S.IsMaxContains(schema) ||
@@ -95,7 +95,7 @@ function HasStringType(schema) {
95
95
  return HasTypeName(schema, 'string');
96
96
  }
97
97
  function HasStringKeywords(schema) {
98
- return S.IsSchema(schema) && (S.IsMinLength(schema) ||
98
+ return S.IsSchemaObject(schema) && (S.IsMinLength(schema) ||
99
99
  S.IsMaxLength(schema) ||
100
100
  S.IsFormat(schema) ||
101
101
  S.IsPattern(schema));
@@ -107,7 +107,7 @@ function HasNumberType(schema) {
107
107
  return HasTypeName(schema, 'number') || HasTypeName(schema, 'bigint');
108
108
  }
109
109
  function HasNumberKeywords(schema) {
110
- return S.IsSchema(schema) && (S.IsMinimum(schema) ||
110
+ return S.IsSchemaObject(schema) && (S.IsMinimum(schema) ||
111
111
  S.IsMaximum(schema) ||
112
112
  S.IsExclusiveMaximum(schema) ||
113
113
  S.IsExclusiveMinimum(schema) ||
@@ -1,6 +1,6 @@
1
1
  import { type TLocalizedValidationError } from '../error/index.mjs';
2
- import { type XSchemaLike } from './types/index.mjs';
2
+ import { type XSchema } from './types/index.mjs';
3
3
  /** Checks a value and returns validation errors */
4
- export declare function Errors(schema: XSchemaLike, value: unknown): [boolean, TLocalizedValidationError[]];
4
+ export declare function Errors(schema: XSchema, value: unknown): [boolean, TLocalizedValidationError[]];
5
5
  /** Checks a value and returns validation errors */
6
- export declare function Errors(context: Record<PropertyKey, XSchemaLike>, schema: XSchemaLike, value: unknown): [boolean, TLocalizedValidationError[]];
6
+ export declare function Errors(context: Record<PropertyKey, XSchema>, schema: XSchema, value: unknown): [boolean, TLocalizedValidationError[]];
@@ -1,4 +1,5 @@
1
1
  export * from './engine/index.mjs';
2
+ export * from './static/index.mjs';
2
3
  export * from './types/index.mjs';
3
4
  export * from './build.mjs';
4
5
  export * from './check.mjs';
@@ -1,4 +1,5 @@
1
1
  export * from './engine/index.mjs';
2
+ export * from './static/index.mjs';
2
3
  export * from './types/index.mjs';
3
4
  export * from './build.mjs';
4
5
  export * from './check.mjs';
@@ -0,0 +1,7 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticAdditionalProperties<Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
4
+ [key: string]: unknown;
5
+ } : Schema extends false ? {} : {
6
+ [key: string]: XStaticSchema<Schema>;
7
+ })> = Result;
@@ -0,0 +1,3 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticAllOf<Schemas extends XSchema[], Result extends unknown = unknown> = (Schemas extends readonly [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAllOf<Right, Result & XStaticSchema<Left>> : Result);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticAnyOf<Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticAnyOf<Right, XStaticSchema<Left> | Result> : Result);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1 @@
1
+ export type XStaticConst<Value extends unknown> = Value;
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1 @@
1
+ export type XStaticEnum<Values extends unknown[], Result extends unknown = never> = (Values extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XStaticEnum<Right, Left | Result> : Result);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1 @@
1
+ export type { XStatic } from './static.mjs';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ type TFromUnsized<Schema extends XSchema> = (XStaticSchema<Schema>[]);
4
+ type TFromSized<Schema extends XSchema[], Result extends unknown[] = []> = (Schema extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? TFromSized<Right, [...Result, XStaticSchema<Left>]> : Result);
5
+ export type XStaticItems<Schemas extends XSchema[] | XSchema, Result extends unknown = (Schemas extends XSchema[] ? TFromSized<[...Schemas]> : Schemas extends XSchema ? TFromUnsized<Schemas> : never)> = Result;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticOneOf<Schemas extends XSchema[], Result extends unknown = never> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticOneOf<Right, XStaticSchema<Left> | Result> : Result);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticPatternProperties<Properties extends Record<PropertyKey, XSchema> = Record<PropertyKey, XSchema>, InferredProperties extends Record<PropertyKey, unknown> = {
4
+ [Key in keyof Properties]: XStaticSchema<Properties[Key]>;
5
+ }, EvaluatedProperties extends unknown = {
6
+ [key: string]: InferredProperties[keyof InferredProperties];
7
+ }> = EvaluatedProperties;
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticPrefixItems<Schemas extends XSchema[], Result extends unknown[] = []> = (Schemas extends [infer Left extends XSchema, ...infer Right extends XSchema[]] ? XStaticPrefixItems<Right, [...Result, XStaticSchema<Left>]> : Result);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ import type { TIsReadonly } from './~readonly.mjs';
4
+ type TReadonlyOptionalProperties<Properties extends Record<PropertyKey, XSchema>> = {
5
+ readonly [Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? Key : never]?: XStaticSchema<Properties[Key]>;
6
+ };
7
+ type TOptionalProperties<Properties extends Record<PropertyKey, XSchema>> = {
8
+ [Key in keyof Properties as TIsReadonly<Properties[Key]> extends true ? never : Key]?: XStaticSchema<Properties[Key]>;
9
+ };
10
+ export type XStaticProperties<Properties extends Record<PropertyKey, XSchema>, ReadonlyOptional extends Record<PropertyKey, unknown> = TReadonlyOptionalProperties<Properties>, Optional extends Record<PropertyKey, unknown> = TOptionalProperties<Properties>, Result extends Record<PropertyKey, unknown> = ReadonlyOptional & Optional> = Result;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XProperties } from '../types/properties.mjs';
3
+ import type { TIsReadonly } from './~readonly.mjs';
4
+ import type { XStaticSchema } from './schema.mjs';
5
+ type TResolveProperties<Schema extends XSchema, Result extends Record<PropertyKey, XSchema> = (Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? Properties : {})> = Result;
6
+ type TFromKey<Properties extends Record<PropertyKey, XSchema>, Key extends string, Readonly extends boolean = Key extends keyof Properties ? TIsReadonly<Properties[Key]> : false, Value extends unknown = Key extends keyof Properties ? XStaticSchema<Properties[Key]> : unknown, Result extends Record<PropertyKey, unknown> = (Readonly extends true ? {
7
+ readonly [_ in Key]: Value;
8
+ } : {
9
+ [_ in Key]: Value;
10
+ })> = Result;
11
+ type TFromKeys<Properties extends Record<PropertyKey, XSchema>, Keys extends string[], Result extends Record<PropertyKey, unknown> = {}> = (Keys extends [infer Left extends string, ...infer Right extends string[]] ? TFromKeys<Properties, Right, Result & TFromKey<Properties, Left>> : Result);
12
+ export type XStaticRequired<Schema extends XSchema, Keys extends string[], Properties extends Record<PropertyKey, XSchema> = TResolveProperties<Schema>, Result extends Record<PropertyKey, unknown> = TFromKeys<Properties, Keys>> = Result;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { XAdditionalProperties } from '../types/additionalProperties.mjs';
2
+ import type { XAnyOf } from '../types/anyOf.mjs';
3
+ import type { XAllOf } from '../types/allOf.mjs';
4
+ import type { XConst } from '../types/const.mjs';
5
+ import type { XEnum } from '../types/enum.mjs';
6
+ import type { XItems } from '../types/items.mjs';
7
+ import type { XOneOf } from '../types/oneOf.mjs';
8
+ import type { XPatternProperties } from '../types/patternProperties.mjs';
9
+ import type { XPrefixItems } from '../types/prefixItems.mjs';
10
+ import type { XProperties } from '../types/properties.mjs';
11
+ import type { XRequired } from '../types/required.mjs';
12
+ import type { XSchema } from '../types/schema.mjs';
13
+ import type { XType } from '../types/type.mjs';
14
+ import type { XUnevaluatedProperties } from '../types/unevaluatedProperties.mjs';
15
+ import type { XStaticAdditionalProperties } from './additionalProperties.mjs';
16
+ import type { XStaticAllOf } from './allOf.mjs';
17
+ import type { XStaticAnyOf } from './anyOf.mjs';
18
+ import type { XStaticConst } from './const.mjs';
19
+ import type { XStaticEnum } from './enum.mjs';
20
+ import type { XStaticItems } from './items.mjs';
21
+ import type { XStaticOneOf } from './oneOf.mjs';
22
+ import type { XStaticPatternProperties } from './patternProperties.mjs';
23
+ import type { XStaticPrefixItems } from './prefixItems.mjs';
24
+ import type { XStaticProperties } from './properties.mjs';
25
+ import type { XStaticRequired } from './required.mjs';
26
+ import type { XStaticType } from './type.mjs';
27
+ import type { XStaticUnevaluatedProperties } from './unevaluatedProperties.mjs';
28
+ type TFromKeywords<Schema, Result extends unknown[] = [
29
+ Schema extends XAdditionalProperties<infer Type extends XSchema> ? XStaticAdditionalProperties<Type> : unknown,
30
+ Schema extends XAllOf<infer Types extends XSchema[]> ? XStaticAllOf<Types> : unknown,
31
+ Schema extends XAnyOf<infer Types extends XSchema[]> ? XStaticAnyOf<Types> : unknown,
32
+ Schema extends XConst<infer Value extends unknown> ? XStaticConst<Value> : unknown,
33
+ Schema extends XEnum<infer Values extends unknown[]> ? XStaticEnum<Values> : unknown,
34
+ Schema extends XItems<infer Types extends XSchema[] | XSchema> ? XStaticItems<Types> : unknown,
35
+ Schema extends XOneOf<infer Types extends XSchema[]> ? XStaticOneOf<Types> : unknown,
36
+ Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticPatternProperties<Properties> : unknown,
37
+ Schema extends XPrefixItems<infer Types extends XSchema[]> ? XStaticPrefixItems<Types> : unknown,
38
+ Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticProperties<Properties> : unknown,
39
+ Schema extends XRequired<infer Keys extends string[]> ? XStaticRequired<Schema, Keys> : unknown,
40
+ Schema extends XType<infer TypeName extends string[] | string> ? XStaticType<TypeName> : unknown,
41
+ Schema extends XUnevaluatedProperties<infer Type extends XSchema> ? XStaticUnevaluatedProperties<Type> : unknown
42
+ ]> = Result;
43
+ type TKeywordsIntersected<Schemas extends unknown[], Result extends unknown = unknown> = (Schemas extends [infer Left extends unknown, ...infer Right extends unknown[]] ? TKeywordsIntersected<Right, Result & Left> : Result);
44
+ type TKeywordsEvaluated<Schema extends unknown, Result extends unknown = Schema extends object ? {
45
+ [Key in keyof Schema]: Schema[Key];
46
+ } : Schema> = Result;
47
+ export type XStaticSchema<Schema extends XSchema, Keywords extends unknown[] = TFromKeywords<Schema>, Intersected extends unknown = TKeywordsIntersected<Keywords>, Evaluated extends unknown = TKeywordsEvaluated<Intersected>> = Evaluated;
48
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ import type { XMutable } from './~mutable.mjs';
4
+ /** Statically infers a JSON Schema */
5
+ export type XStatic<Value extends unknown, Schema extends XSchema = Value extends XSchema ? Value : {}, Mutable extends XSchema = XMutable<Schema>, Result extends unknown = XStaticSchema<Mutable>> = Result;
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,4 @@
1
+ type TFromTypeNames<TypeNames extends string[], Result extends unknown = never> = (TypeNames extends readonly [infer Left extends string, ...infer Right extends string[]] ? TFromTypeNames<Right, Result | TFromTypeName<Left>> : Result);
2
+ type TFromTypeName<TypeName extends string> = (TypeName extends 'array' ? {} : TypeName extends 'bigint' ? bigint : TypeName extends 'boolean' ? boolean : TypeName extends 'integer' ? number : TypeName extends 'object' ? object : TypeName extends 'null' ? null : TypeName extends 'number' ? number : TypeName extends 'string' ? string : TypeName extends 'symbol' ? symbol : TypeName extends 'undefined' ? undefined : unknown);
3
+ export type XStaticType<TypeName extends string[] | string> = (TypeName extends string[] ? TFromTypeNames<TypeName> : TypeName extends string ? TFromTypeName<TypeName> : unknown);
4
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ import type { XStaticSchema } from './schema.mjs';
3
+ export type XStaticUnevaluatedProperties<Schema extends XSchema, Result extends Record<PropertyKey, unknown> = (Schema extends true ? {
4
+ [key: string]: unknown;
5
+ } : Schema extends false ? {} : {
6
+ [key: string]: XStaticSchema<Schema>;
7
+ })> = Result;
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,7 @@
1
+ type TFromTuple<Value extends readonly unknown[]> = (Value extends [infer Left, ...infer Right extends unknown[]] ? [XMutable<Left>, ...TFromTuple<Right>] : []);
2
+ type TFromArray<Value extends unknown, Result extends unknown[] = XMutable<Value>[]> = Result;
3
+ type TFromObject<Value extends object, Result extends Record<PropertyKey, unknown> = {
4
+ -readonly [K in keyof Value]: XMutable<Value[K]>;
5
+ }> = Result;
6
+ export type XMutable<Value extends unknown> = (Value extends readonly [...infer Schemas extends unknown[]] ? TFromTuple<Schemas> : Value extends readonly (infer Schema)[] ? TFromArray<Schema> : Value extends object ? TFromObject<Value> : Value);
7
+ export {};
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { XSchema } from '../types/schema.mjs';
2
+ export type TIsReadonly<Schema extends XSchema> = (Schema extends {
3
+ readOnly: true;
4
+ } ? true : Schema extends {
5
+ '~readonly': true;
6
+ } ? true : false);
@@ -0,0 +1,2 @@
1
+ // deno-fmt-ignore-file
2
+ export {};
@@ -1,4 +1,4 @@
1
- import type { XSchema } from './schema.mjs';
1
+ import type { XSchemaObject } from './schema.mjs';
2
2
  export interface XGuardInterface<Value extends unknown = unknown> {
3
3
  check(value: unknown): value is Value;
4
4
  errors(value: unknown): object[];
@@ -7,4 +7,4 @@ export interface XGuard<Value extends unknown = unknown> {
7
7
  '~guard': XGuardInterface<Value>;
8
8
  }
9
9
  export declare function IsGuardInterface(value: unknown): value is XGuardInterface;
10
- export declare function IsGuard(value: XSchema): value is XGuard;
10
+ export declare function IsGuard(value: XSchemaObject): value is XGuard;
@@ -1,4 +1,4 @@
1
- import type { XSchema } from './schema.mjs';
1
+ import type { XSchemaObject } from './schema.mjs';
2
2
  export interface XRefinement {
3
3
  refine: (value: unknown) => boolean;
4
4
  message: string;
@@ -10,4 +10,4 @@ export interface XRefine<Refinements extends XRefinement[] = XRefinement[]> {
10
10
  * Returns true if the schema contains an '~refine` keyword
11
11
  * @specification None
12
12
  */
13
- export declare function IsRefine(value: XSchema): value is XRefine;
13
+ export declare function IsRefine(value: XSchemaObject): value is XRefine;
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from '../types/schema.mjs';
2
- export interface XAdditionalItems<AdditionalItems extends XSchemaLike = XSchemaLike> {
1
+ import { type XSchemaObject, type XSchema } from '../types/schema.mjs';
2
+ export interface XAdditionalItems<AdditionalItems extends XSchema = XSchema> {
3
3
  additionalItems: AdditionalItems;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid additionalItems property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsAdditionalItems(schema: XSchema): schema is XAdditionalItems;
9
+ export declare function IsAdditionalItems(schema: XSchemaObject): schema is XAdditionalItems;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
- import { IsSchemaLike } from '../types/schema.mjs';
3
+ import { IsSchema } from '../types/schema.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Guard
6
6
  // ------------------------------------------------------------------
@@ -10,5 +10,5 @@ import { IsSchemaLike } from '../types/schema.mjs';
10
10
  */
11
11
  export function IsAdditionalItems(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'additionalItems')
13
- && IsSchemaLike(schema.additionalItems);
13
+ && IsSchema(schema.additionalItems);
14
14
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XAdditionalProperties<AdditionalProperties extends XSchemaLike = XSchemaLike> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XAdditionalProperties<AdditionalProperties extends XSchema = XSchema> {
3
3
  additionalProperties: AdditionalProperties;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid additionalProperties property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsAdditionalProperties(schema: XSchema): schema is XAdditionalProperties;
9
+ export declare function IsAdditionalProperties(schema: XSchemaObject): schema is XAdditionalProperties;
@@ -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 IsAdditionalProperties(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'additionalProperties')
13
- && IsSchemaLike(schema.additionalProperties);
13
+ && IsSchema(schema.additionalProperties);
14
14
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XAllOf<AllOf extends XSchemaLike[] = XSchemaLike[]> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XAllOf<AllOf extends XSchema[] = XSchema[]> {
3
3
  allOf: AllOf;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid allOf property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsAllOf(schema: XSchema): schema is XAllOf;
9
+ export declare function IsAllOf(schema: XSchemaObject): schema is XAllOf;
@@ -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 IsAllOf(schema) {
12
12
  return Guard.HasPropertyKey(schema, 'allOf')
13
13
  && Guard.IsArray(schema.allOf)
14
- && schema.allOf.every(value => IsSchemaLike(value));
14
+ && schema.allOf.every(value => IsSchema(value));
15
15
  }
@@ -1,9 +1,9 @@
1
- import { type XSchema, type XSchemaLike } from './schema.mjs';
2
- export interface XAnyOf<AnyOf extends XSchemaLike[] = XSchemaLike[]> {
1
+ import { type XSchemaObject, type XSchema } from './schema.mjs';
2
+ export interface XAnyOf<AnyOf extends XSchema[] = XSchema[]> {
3
3
  anyOf: AnyOf;
4
4
  }
5
5
  /**
6
6
  * Returns true if the schema contains a valid anyOf property
7
7
  * @specification Json Schema 7
8
8
  */
9
- export declare function IsAnyOf(schema: XSchema): schema is XAnyOf;
9
+ export declare function IsAnyOf(schema: XSchemaObject): schema is XAnyOf;