@sinclair/typebox 0.32.0-dev-22 → 0.32.0-dev-24

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 (100) hide show
  1. package/build/import/compiler/compiler.d.mts +3 -2
  2. package/build/import/compiler/compiler.mjs +3 -2
  3. package/build/import/errors/errors.d.mts +2 -1
  4. package/build/import/errors/errors.mjs +2 -1
  5. package/build/import/index.d.mts +1 -0
  6. package/build/import/index.mjs +1 -0
  7. package/build/import/system/system.d.mts +3 -2
  8. package/build/import/system/system.mjs +3 -2
  9. package/build/import/type/error/error.d.mts +4 -0
  10. package/build/import/type/error/error.mjs +6 -0
  11. package/build/import/type/error/index.d.mts +1 -0
  12. package/build/import/type/error/index.mjs +1 -0
  13. package/build/import/type/extends/extends-check.d.mts +2 -1
  14. package/build/import/type/extends/extends-check.mjs +2 -1
  15. package/build/import/type/guard/type.d.mts +2 -1
  16. package/build/import/type/guard/type.mjs +2 -1
  17. package/build/import/type/index.d.mts +1 -0
  18. package/build/import/type/index.mjs +1 -0
  19. package/build/import/type/record/record.d.mts +1 -1
  20. package/build/import/type/template-literal/finite.d.mts +2 -1
  21. package/build/import/type/template-literal/finite.mjs +2 -1
  22. package/build/import/type/template-literal/generate.d.mts +3 -2
  23. package/build/import/type/template-literal/generate.mjs +2 -1
  24. package/build/import/type/template-literal/parse.d.mts +2 -1
  25. package/build/import/type/template-literal/parse.mjs +2 -1
  26. package/build/import/type/template-literal/pattern.d.mts +2 -1
  27. package/build/import/type/template-literal/pattern.mjs +2 -1
  28. package/build/import/value/cast/cast.d.mts +5 -4
  29. package/build/import/value/cast/cast.mjs +5 -4
  30. package/build/import/value/check/check.d.mts +2 -1
  31. package/build/import/value/check/check.mjs +2 -1
  32. package/build/import/value/convert/convert.d.mts +2 -1
  33. package/build/import/value/convert/convert.mjs +2 -1
  34. package/build/import/value/create/create.d.mts +7 -6
  35. package/build/import/value/create/create.mjs +7 -6
  36. package/build/import/value/delta/delta.d.mts +3 -2
  37. package/build/import/value/delta/delta.mjs +3 -2
  38. package/build/import/value/deref/deref.d.mts +2 -1
  39. package/build/import/value/deref/deref.mjs +2 -1
  40. package/build/import/value/hash/hash.d.mts +2 -1
  41. package/build/import/value/hash/hash.mjs +2 -1
  42. package/build/import/value/mutate/mutate.d.mts +3 -2
  43. package/build/import/value/mutate/mutate.mjs +3 -2
  44. package/build/import/value/pointer/pointer.d.mts +3 -2
  45. package/build/import/value/pointer/pointer.mjs +3 -2
  46. package/build/import/value/transform/decode.d.mts +3 -2
  47. package/build/import/value/transform/decode.mjs +3 -2
  48. package/build/import/value/transform/encode.d.mts +3 -2
  49. package/build/import/value/transform/encode.mjs +3 -2
  50. package/build/require/compiler/compiler.d.ts +3 -2
  51. package/build/require/compiler/compiler.js +61 -60
  52. package/build/require/errors/errors.d.ts +2 -1
  53. package/build/require/errors/errors.js +34 -33
  54. package/build/require/index.d.ts +1 -0
  55. package/build/require/index.js +154 -152
  56. package/build/require/system/system.d.ts +3 -2
  57. package/build/require/system/system.js +3 -2
  58. package/build/require/type/error/error.d.ts +4 -0
  59. package/build/require/type/error/error.js +11 -0
  60. package/build/require/type/error/index.d.ts +1 -0
  61. package/build/require/type/error/index.js +18 -0
  62. package/build/require/type/extends/extends-check.d.ts +2 -1
  63. package/build/require/type/extends/extends-check.js +172 -171
  64. package/build/require/type/guard/type.d.ts +2 -1
  65. package/build/require/type/guard/type.js +2 -1
  66. package/build/require/type/index.d.ts +1 -0
  67. package/build/require/type/index.js +1 -0
  68. package/build/require/type/record/record.d.ts +1 -1
  69. package/build/require/type/template-literal/finite.d.ts +2 -1
  70. package/build/require/type/template-literal/finite.js +2 -1
  71. package/build/require/type/template-literal/generate.d.ts +3 -2
  72. package/build/require/type/template-literal/generate.js +2 -1
  73. package/build/require/type/template-literal/parse.d.ts +2 -1
  74. package/build/require/type/template-literal/parse.js +3 -2
  75. package/build/require/type/template-literal/pattern.d.ts +2 -1
  76. package/build/require/type/template-literal/pattern.js +2 -1
  77. package/build/require/value/cast/cast.d.ts +5 -4
  78. package/build/require/value/cast/cast.js +36 -35
  79. package/build/require/value/check/check.d.ts +2 -1
  80. package/build/require/value/check/check.js +24 -23
  81. package/build/require/value/convert/convert.d.ts +2 -1
  82. package/build/require/value/convert/convert.js +32 -31
  83. package/build/require/value/create/create.d.ts +7 -6
  84. package/build/require/value/create/create.js +7 -6
  85. package/build/require/value/delta/delta.d.ts +3 -2
  86. package/build/require/value/delta/delta.js +20 -19
  87. package/build/require/value/deref/deref.d.ts +2 -1
  88. package/build/require/value/deref/deref.js +2 -1
  89. package/build/require/value/hash/hash.d.ts +2 -1
  90. package/build/require/value/hash/hash.js +2 -1
  91. package/build/require/value/mutate/mutate.d.ts +3 -2
  92. package/build/require/value/mutate/mutate.js +3 -2
  93. package/build/require/value/pointer/pointer.d.ts +3 -2
  94. package/build/require/value/pointer/pointer.js +3 -2
  95. package/build/require/value/transform/decode.d.ts +3 -2
  96. package/build/require/value/transform/decode.js +19 -18
  97. package/build/require/value/transform/encode.d.ts +3 -2
  98. package/build/require/value/transform/encode.js +20 -19
  99. package/package.json +1 -1
  100. package/readme.md +117 -137
@@ -1,4 +1,5 @@
1
1
  import { ValueErrorIterator } from '../errors/index.mjs';
2
+ import { TypeBoxError } from '../type/error/index.mjs';
2
3
  import type { TSchema } from '../type/schema/index.mjs';
3
4
  import type { Static, StaticDecode, StaticEncode } from '../type/static/index.mjs';
4
5
  export type CheckFunction = (value: unknown) => boolean;
@@ -20,11 +21,11 @@ export declare class TypeCheck<T extends TSchema> {
20
21
  /** Encodes a value or throws if error */
21
22
  Encode(value: unknown): StaticEncode<T>;
22
23
  }
23
- export declare class TypeCompilerUnknownTypeError extends Error {
24
+ export declare class TypeCompilerUnknownTypeError extends TypeBoxError {
24
25
  readonly schema: TSchema;
25
26
  constructor(schema: TSchema);
26
27
  }
27
- export declare class TypeCompilerTypeGuardError extends Error {
28
+ export declare class TypeCompilerTypeGuardError extends TypeBoxError {
28
29
  readonly schema: TSchema;
29
30
  constructor(schema: TSchema);
30
31
  }
@@ -1,6 +1,7 @@
1
1
  import { TransformEncode, TransformDecode, HasTransform, TransformDecodeCheckError, TransformEncodeCheckError } from '../value/transform/index.mjs';
2
2
  import { Errors } from '../errors/index.mjs';
3
3
  import { TypeSystemPolicy } from '../system/index.mjs';
4
+ import { TypeBoxError } from '../type/error/index.mjs';
4
5
  import { Deref } from '../value/deref/index.mjs';
5
6
  import { Hash } from '../value/hash/index.mjs';
6
7
  import { Kind } from '../type/symbols/index.mjs';
@@ -142,14 +143,14 @@ var LiteralString;
142
143
  // ------------------------------------------------------------------
143
144
  // Errors
144
145
  // ------------------------------------------------------------------
145
- export class TypeCompilerUnknownTypeError extends Error {
146
+ export class TypeCompilerUnknownTypeError extends TypeBoxError {
146
147
  schema;
147
148
  constructor(schema) {
148
149
  super('Unknown type');
149
150
  this.schema = schema;
150
151
  }
151
152
  }
152
- export class TypeCompilerTypeGuardError extends Error {
153
+ export class TypeCompilerTypeGuardError extends TypeBoxError {
153
154
  schema;
154
155
  constructor(schema) {
155
156
  super('Preflight validation check failed to guard for the given schema');
@@ -1,3 +1,4 @@
1
+ import { TypeBoxError } from '../type/error/index.mjs';
1
2
  import type { TSchema } from '../type/schema/index.mjs';
2
3
  export declare enum ValueErrorType {
3
4
  ArrayContains = 0,
@@ -71,7 +72,7 @@ export interface ValueError {
71
72
  value: unknown;
72
73
  message: string;
73
74
  }
74
- export declare class ValueErrorsUnknownTypeError extends Error {
75
+ export declare class ValueErrorsUnknownTypeError extends TypeBoxError {
75
76
  readonly schema: TSchema;
76
77
  constructor(schema: TSchema);
77
78
  }
@@ -3,6 +3,7 @@ import { KeyOfPattern } from '../type/keyof/index.mjs';
3
3
  import { TypeRegistry, FormatRegistry } from '../type/registry/index.mjs';
4
4
  import { ExtendsUndefinedCheck } from '../type/extends/extends-undefined.mjs';
5
5
  import { GetErrorFunction } from './function.mjs';
6
+ import { TypeBoxError } from '../type/error/index.mjs';
6
7
  import { Deref } from '../value/deref/index.mjs';
7
8
  import { Hash } from '../value/hash/index.mjs';
8
9
  import { Kind } from '../type/symbols/index.mjs';
@@ -84,7 +85,7 @@ export var ValueErrorType;
84
85
  // ------------------------------------------------------------------
85
86
  // ValueErrors
86
87
  // ------------------------------------------------------------------
87
- export class ValueErrorsUnknownTypeError extends Error {
88
+ export class ValueErrorsUnknownTypeError extends TypeBoxError {
88
89
  schema;
89
90
  constructor(schema) {
90
91
  super('Unknown type');
@@ -3,6 +3,7 @@ export { PatternBoolean, PatternBooleanExact, PatternNumber, PatternNumberExact,
3
3
  export { TypeRegistry, FormatRegistry } from './type/registry/index.mjs';
4
4
  export { TypeGuard, ValueGuard } from './type/guard/index.mjs';
5
5
  export { CloneType, CloneRest } from './type/clone/type.mjs';
6
+ export { TypeBoxError } from './type/error/index.mjs';
6
7
  export { Any, type TAny } from './type/any/index.mjs';
7
8
  export { Array, type TArray, type ArrayOptions } from './type/array/index.mjs';
8
9
  export { AsyncIterator, type TAsyncIterator } from './type/async-iterator/index.mjs';
@@ -6,6 +6,7 @@ export { PatternBoolean, PatternBooleanExact, PatternNumber, PatternNumberExact,
6
6
  export { TypeRegistry, FormatRegistry } from './type/registry/index.mjs';
7
7
  export { TypeGuard, ValueGuard } from './type/guard/index.mjs';
8
8
  export { CloneType, CloneRest } from './type/clone/type.mjs';
9
+ export { TypeBoxError } from './type/error/index.mjs';
9
10
  // ------------------------------------------------------------------
10
11
  // Type
11
12
  // ------------------------------------------------------------------
@@ -1,7 +1,8 @@
1
- export declare class TypeSystemDuplicateTypeKind extends Error {
1
+ import { TypeBoxError } from '../type/error/index.mjs';
2
+ export declare class TypeSystemDuplicateTypeKind extends TypeBoxError {
2
3
  constructor(kind: string);
3
4
  }
4
- export declare class TypeSystemDuplicateFormat extends Error {
5
+ export declare class TypeSystemDuplicateFormat extends TypeBoxError {
5
6
  constructor(kind: string);
6
7
  }
7
8
  /** Creates user defined types and formats and provides overrides for value checking behaviours */
@@ -1,15 +1,16 @@
1
1
  import { TypeRegistry, FormatRegistry } from '../type/registry/index.mjs';
2
2
  import { Unsafe } from '../type/unsafe/index.mjs';
3
3
  import { Kind } from '../type/symbols/index.mjs';
4
+ import { TypeBoxError } from '../type/error/index.mjs';
4
5
  // ------------------------------------------------------------------
5
6
  // Errors
6
7
  // ------------------------------------------------------------------
7
- export class TypeSystemDuplicateTypeKind extends Error {
8
+ export class TypeSystemDuplicateTypeKind extends TypeBoxError {
8
9
  constructor(kind) {
9
10
  super(`Duplicate type kind '${kind}' detected`);
10
11
  }
11
12
  }
12
- export class TypeSystemDuplicateFormat extends Error {
13
+ export class TypeSystemDuplicateFormat extends TypeBoxError {
13
14
  constructor(kind) {
14
15
  super(`Duplicate string format '${kind}' detected`);
15
16
  }
@@ -0,0 +1,4 @@
1
+ /** The base Error type thrown for all TypeBox exceptions */
2
+ export declare class TypeBoxError extends Error {
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,6 @@
1
+ /** The base Error type thrown for all TypeBox exceptions */
2
+ export class TypeBoxError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ }
6
+ }
@@ -0,0 +1 @@
1
+ export * from './error.mjs';
@@ -0,0 +1 @@
1
+ export * from './error.mjs';
@@ -1,5 +1,6 @@
1
1
  import { type TSchema } from '../schema/index.mjs';
2
- export declare class ExtendsResolverError extends Error {
2
+ import { TypeBoxError } from '../error/index.mjs';
3
+ export declare class ExtendsResolverError extends TypeBoxError {
3
4
  }
4
5
  export declare enum ExtendsResult {
5
6
  Union = 0,
@@ -6,8 +6,9 @@ import { Unknown } from '../unknown/index.mjs';
6
6
  import { TemplateLiteralToUnion } from '../template-literal/index.mjs';
7
7
  import { PatternNumberExact, PatternStringExact } from '../patterns/index.mjs';
8
8
  import { Kind, Hint } from '../symbols/index.mjs';
9
+ import { TypeBoxError } from '../error/index.mjs';
9
10
  import { TypeGuard, ValueGuard } from '../guard/index.mjs';
10
- export class ExtendsResolverError extends Error {
11
+ export class ExtendsResolverError extends TypeBoxError {
11
12
  }
12
13
  export var ExtendsResult;
13
14
  (function (ExtendsResult) {
@@ -1,4 +1,5 @@
1
1
  import { Kind, Hint, TransformKind } from '../symbols/index.mjs';
2
+ import { TypeBoxError } from '../error/index.mjs';
2
3
  import { TransformOptions } from '../transform/index.mjs';
3
4
  import { TTemplateLiteral, TTemplateLiteralKind } from '../template-literal/index.mjs';
4
5
  import { TArray } from '../array/index.mjs';
@@ -35,7 +36,7 @@ import type { TUnsafe } from '../unsafe/index.mjs';
35
36
  import type { TVoid } from '../void/index.mjs';
36
37
  import type { TDate } from '../date/index.mjs';
37
38
  import type { TThis } from '../recursive/index.mjs';
38
- export declare class TypeGuardUnknownTypeError extends Error {
39
+ export declare class TypeGuardUnknownTypeError extends TypeBoxError {
39
40
  }
40
41
  /** Returns true if this value has a Readonly symbol */
41
42
  export declare function IsReadonly<T extends TSchema>(value: T): value is TReadonly<T>;
@@ -1,6 +1,7 @@
1
1
  import * as ValueGuard from './value.mjs';
2
2
  import { Kind, Hint, TransformKind, ReadonlyKind, OptionalKind } from '../symbols/index.mjs';
3
- export class TypeGuardUnknownTypeError extends Error {
3
+ import { TypeBoxError } from '../error/index.mjs';
4
+ export class TypeGuardUnknownTypeError extends TypeBoxError {
4
5
  }
5
6
  const KnownTypes = [
6
7
  'Any',
@@ -13,6 +13,7 @@ export * from './date/index.mjs';
13
13
  export * from './deref/index.mjs';
14
14
  export * from './discard/index.mjs';
15
15
  export * from './enum/index.mjs';
16
+ export * from './error/index.mjs';
16
17
  export * from './exclude/index.mjs';
17
18
  export * from './extends/index.mjs';
18
19
  export * from './extract/index.mjs';
@@ -13,6 +13,7 @@ export * from './date/index.mjs';
13
13
  export * from './deref/index.mjs';
14
14
  export * from './discard/index.mjs';
15
15
  export * from './enum/index.mjs';
16
+ export * from './error/index.mjs';
16
17
  export * from './exclude/index.mjs';
17
18
  export * from './extends/index.mjs';
18
19
  export * from './extract/index.mjs';
@@ -26,7 +26,7 @@ type TFromUnionKeyLiteralNumber<K extends TLiteral<number>, T extends TSchema> =
26
26
  [_ in K['const']]: T;
27
27
  };
28
28
  type TFromUnionKeyRest<K extends TSchema[], T extends TSchema> = K extends [infer L extends TSchema, ...infer R extends TSchema[]] ? (L extends TUnion<infer S> ? TFromUnionKeyRest<S, T> & TFromUnionKeyRest<R, T> : L extends TLiteral<string> ? TFromUnionKeyLiteralString<L, T> & TFromUnionKeyRest<R, T> : L extends TLiteral<number> ? TFromUnionKeyLiteralNumber<L, T> & TFromUnionKeyRest<R, T> : {}) : {};
29
- type TFromUnionKey<K extends TSchema[], T extends TSchema, P extends TProperties = TFromUnionKeyRest<K, T>> = (Ensure<TObject<P>>);
29
+ type TFromUnionKey<K extends TSchema[], T extends TSchema, P extends TProperties = TFromUnionKeyRest<K, T>> = (Ensure<TObject<Evaluate<P>>>);
30
30
  type TFromLiteralKey<K extends TLiteralValue, T extends TSchema> = (Ensure<TObject<{
31
31
  [_ in Assert<K, PropertyKey>]: T;
32
32
  }>>);
@@ -1,3 +1,4 @@
1
+ import { TypeBoxError } from '../error/index.mjs';
1
2
  import type { TTemplateLiteral, TTemplateLiteralKind } from './index.mjs';
2
3
  import type { TUnion } from '../union/index.mjs';
3
4
  import type { TString } from '../string/index.mjs';
@@ -7,7 +8,7 @@ import type { TInteger } from '../integer/index.mjs';
7
8
  import type { TBigInt } from '../bigint/index.mjs';
8
9
  import type { TLiteral } from '../literal/index.mjs';
9
10
  import type { Expression } from './parse.mjs';
10
- export declare class TemplateLiteralFiniteError extends Error {
11
+ export declare class TemplateLiteralFiniteError extends TypeBoxError {
11
12
  }
12
13
  type TFromTemplateLiteralKind<T> = T extends TTemplateLiteral<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TUnion<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TString ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TBoolean ? true : T extends TLiteral ? true : false;
13
14
  type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? TFromTemplateLiteralKind<L> extends false ? false : TFromTemplateLiteralKinds<R> : true;
@@ -1,8 +1,9 @@
1
1
  import { TemplateLiteralParseExact } from './parse.mjs';
2
+ import { TypeBoxError } from '../error/index.mjs';
2
3
  // ------------------------------------------------------------------
3
4
  // TemplateLiteralFiniteError
4
5
  // ------------------------------------------------------------------
5
- export class TemplateLiteralFiniteError extends Error {
6
+ export class TemplateLiteralFiniteError extends TypeBoxError {
6
7
  }
7
8
  // ------------------------------------------------------------------
8
9
  // IsTemplateLiteralFiniteCheck
@@ -1,17 +1,18 @@
1
1
  import { TIsTemplateLiteralFinite } from './finite.mjs';
2
+ import { TypeBoxError } from '../error/index.mjs';
2
3
  import type { Assert } from '../helpers/index.mjs';
3
4
  import type { TBoolean } from '../boolean/index.mjs';
4
5
  import type { TTemplateLiteral, TTemplateLiteralKind } from './index.mjs';
5
6
  import type { TLiteral, TLiteralValue } from '../literal/index.mjs';
6
7
  import type { Expression } from './parse.mjs';
7
8
  import type { TUnion } from '../union/index.mjs';
8
- export declare class TemplateLiteralGenerateError extends Error {
9
+ export declare class TemplateLiteralGenerateError extends TypeBoxError {
9
10
  }
10
11
  type TStringReduceUnary<L extends string, R extends string[], Acc extends string[] = []> = R extends [infer A extends string, ...infer B extends string[]] ? TStringReduceUnary<L, B, [...Acc, `${L}${A}`]> : Acc;
11
12
  type TStringReduceBinary<L extends string[], R extends string[], Acc extends string[] = []> = L extends [infer A extends string, ...infer B extends string[]] ? TStringReduceBinary<B, R, [...Acc, ...TStringReduceUnary<A, R>]> : Acc;
12
13
  type TStringReduceMany<T extends string[][]> = T extends [infer L extends string[], infer R extends string[], ...infer Rest extends string[][]] ? TStringReduceMany<[TStringReduceBinary<L, R>, ...Rest]> : T;
13
14
  type TStringReduce<T extends string[][], O = TStringReduceMany<T>> = 0 extends keyof O ? Assert<O[0], string[]> : [];
14
- type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [L['const'], ...TFromTemplateLiteralUnionKinds<R>] : [];
15
+ type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [`${L['const']}`, ...TFromTemplateLiteralUnionKinds<R>] : [];
15
16
  type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = []> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? (L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds<R, [...Acc, [S]]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<R, [...Acc, TFromTemplateLiteralUnionKinds<S>]> : L extends TBoolean ? TFromTemplateLiteralKinds<R, [...Acc, ['true', 'false']]> : Acc) : Acc;
16
17
  export declare function TemplateLiteralExpressionGenerate(expression: Expression): IterableIterator<string>;
17
18
  export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<S> extends infer R extends string[][] ? TStringReduce<R> : [] : []) : [];
@@ -1,9 +1,10 @@
1
1
  import { IsTemplateLiteralExpressionFinite } from './finite.mjs';
2
2
  import { TemplateLiteralParseExact } from './parse.mjs';
3
+ import { TypeBoxError } from '../error/index.mjs';
3
4
  // ------------------------------------------------------------------
4
5
  // TemplateLiteralGenerateError
5
6
  // ------------------------------------------------------------------
6
- export class TemplateLiteralGenerateError extends Error {
7
+ export class TemplateLiteralGenerateError extends TypeBoxError {
7
8
  }
8
9
  // ------------------------------------------------------------------
9
10
  // TemplateLiteralExpressionGenerate
@@ -1,4 +1,5 @@
1
- export declare class TemplateLiteralParserError extends Error {
1
+ import { TypeBoxError } from '../error/index.mjs';
2
+ export declare class TemplateLiteralParserError extends TypeBoxError {
2
3
  }
3
4
  export type Expression = ExpressionAnd | ExpressionOr | ExpressionConst;
4
5
  export type ExpressionConst = {
@@ -1,7 +1,8 @@
1
+ import { TypeBoxError } from '../error/index.mjs';
1
2
  // ------------------------------------------------------------------
2
3
  // TemplateLiteralParserError
3
4
  // ------------------------------------------------------------------
4
- export class TemplateLiteralParserError extends Error {
5
+ export class TemplateLiteralParserError extends TypeBoxError {
5
6
  }
6
7
  // prettier-ignore
7
8
  function IsNonEscaped(pattern, index, char) {
@@ -1,4 +1,5 @@
1
1
  import type { TTemplateLiteralKind } from './index.mjs';
2
- export declare class TemplateLiteralPatternError extends Error {
2
+ import { TypeBoxError } from '../error/index.mjs';
3
+ export declare class TemplateLiteralPatternError extends TypeBoxError {
3
4
  }
4
5
  export declare function TemplateLiteralPattern(kinds: TTemplateLiteralKind[]): string;
@@ -1,5 +1,6 @@
1
1
  import { PatternNumber, PatternString, PatternBoolean } from '../patterns/index.mjs';
2
2
  import { Kind } from '../symbols/index.mjs';
3
+ import { TypeBoxError } from '../error/index.mjs';
3
4
  // ------------------------------------------------------------------
4
5
  // TypeGuard
5
6
  // ------------------------------------------------------------------
@@ -8,7 +9,7 @@ import { IsTemplateLiteral, IsUnion, IsNumber, IsInteger, IsBigInt, IsString, Is
8
9
  // ------------------------------------------------------------------
9
10
  // TemplateLiteralPatternError
10
11
  // ------------------------------------------------------------------
11
- export class TemplateLiteralPatternError extends Error {
12
+ export class TemplateLiteralPatternError extends TypeBoxError {
12
13
  }
13
14
  // ------------------------------------------------------------------
14
15
  // TemplateLiteralPattern
@@ -1,19 +1,20 @@
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
1
2
  import type { TSchema } from '../../type/schema/index.mjs';
2
3
  import type { Static } from '../../type/static/index.mjs';
3
- export declare class ValueCastArrayUniqueItemsTypeError extends Error {
4
+ export declare class ValueCastArrayUniqueItemsTypeError extends TypeBoxError {
4
5
  readonly schema: TSchema;
5
6
  readonly value: unknown;
6
7
  constructor(schema: TSchema, value: unknown);
7
8
  }
8
- export declare class ValueCastNeverTypeError extends Error {
9
+ export declare class ValueCastNeverTypeError extends TypeBoxError {
9
10
  readonly schema: TSchema;
10
11
  constructor(schema: TSchema);
11
12
  }
12
- export declare class ValueCastRecursiveTypeError extends Error {
13
+ export declare class ValueCastRecursiveTypeError extends TypeBoxError {
13
14
  readonly schema: TSchema;
14
15
  constructor(schema: TSchema);
15
16
  }
16
- export declare class ValueCastUnknownTypeError extends Error {
17
+ export declare class ValueCastUnknownTypeError extends TypeBoxError {
17
18
  readonly schema: TSchema;
18
19
  constructor(schema: TSchema);
19
20
  }
@@ -1,4 +1,5 @@
1
1
  import { IsPlainObject, IsArray, IsString, IsNumber, IsNull } from '../guard/index.mjs';
2
+ import { TypeBoxError } from '../../type/error/index.mjs';
2
3
  import { Kind } from '../../type/symbols/index.mjs';
3
4
  import { Create } from '../create/index.mjs';
4
5
  import { Check } from '../check/index.mjs';
@@ -7,7 +8,7 @@ import { Deref } from '../deref/index.mjs';
7
8
  // ------------------------------------------------------------------
8
9
  // Errors
9
10
  // ------------------------------------------------------------------
10
- export class ValueCastArrayUniqueItemsTypeError extends Error {
11
+ export class ValueCastArrayUniqueItemsTypeError extends TypeBoxError {
11
12
  schema;
12
13
  value;
13
14
  constructor(schema, value) {
@@ -16,21 +17,21 @@ export class ValueCastArrayUniqueItemsTypeError extends Error {
16
17
  this.value = value;
17
18
  }
18
19
  }
19
- export class ValueCastNeverTypeError extends Error {
20
+ export class ValueCastNeverTypeError extends TypeBoxError {
20
21
  schema;
21
22
  constructor(schema) {
22
23
  super('Never types cannot be cast');
23
24
  this.schema = schema;
24
25
  }
25
26
  }
26
- export class ValueCastRecursiveTypeError extends Error {
27
+ export class ValueCastRecursiveTypeError extends TypeBoxError {
27
28
  schema;
28
29
  constructor(schema) {
29
30
  super('Cannot cast recursive schemas');
30
31
  this.schema = schema;
31
32
  }
32
33
  }
33
- export class ValueCastUnknownTypeError extends Error {
34
+ export class ValueCastUnknownTypeError extends TypeBoxError {
34
35
  schema;
35
36
  constructor(schema) {
36
37
  super('Unknown type');
@@ -1,6 +1,7 @@
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
1
2
  import type { TSchema } from '../../type/schema/index.mjs';
2
3
  import type { Static } from '../../type/static/index.mjs';
3
- export declare class ValueCheckUnknownTypeError extends Error {
4
+ export declare class ValueCheckUnknownTypeError extends TypeBoxError {
4
5
  readonly schema: TSchema;
5
6
  constructor(schema: TSchema);
6
7
  }
@@ -5,6 +5,7 @@ import { Kind } from '../../type/symbols/index.mjs';
5
5
  import { KeyOfPattern } from '../../type/keyof/index.mjs';
6
6
  import { ExtendsUndefinedCheck } from '../../type/extends/index.mjs';
7
7
  import { TypeRegistry, FormatRegistry } from '../../type/registry/index.mjs';
8
+ import { TypeBoxError } from '../../type/error/index.mjs';
8
9
  import { Never } from '../../type/never/index.mjs';
9
10
  // ------------------------------------------------------------------
10
11
  // ValueGuard
@@ -18,7 +19,7 @@ import { IsSchema } from '../../type/guard/type.mjs';
18
19
  // ------------------------------------------------------------------
19
20
  // Errors
20
21
  // ------------------------------------------------------------------
21
- export class ValueCheckUnknownTypeError extends Error {
22
+ export class ValueCheckUnknownTypeError extends TypeBoxError {
22
23
  schema;
23
24
  constructor(schema) {
24
25
  super(`Unknown type`);
@@ -1,5 +1,6 @@
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
1
2
  import type { TSchema } from '../../type/schema/index.mjs';
2
- export declare class ValueConvertUnknownTypeError extends Error {
3
+ export declare class ValueConvertUnknownTypeError extends TypeBoxError {
3
4
  readonly schema: TSchema;
4
5
  constructor(schema: TSchema);
5
6
  }
@@ -1,6 +1,7 @@
1
1
  import { Clone } from '../clone/index.mjs';
2
2
  import { Check } from '../check/index.mjs';
3
3
  import { Deref } from '../deref/index.mjs';
4
+ import { TypeBoxError } from '../../type/error/index.mjs';
4
5
  import { IsObject as IsObjectType } from '../../type/guard/type.mjs';
5
6
  import { Kind } from '../../type/symbols/index.mjs';
6
7
  import { Composite } from '../../type/composite/index.mjs';
@@ -12,7 +13,7 @@ import { IsArray, IsObject, IsDate, IsUndefined, IsString, IsNumber, IsBoolean,
12
13
  // ------------------------------------------------------------------
13
14
  // Errors
14
15
  // ------------------------------------------------------------------
15
- export class ValueConvertUnknownTypeError extends Error {
16
+ export class ValueConvertUnknownTypeError extends TypeBoxError {
16
17
  schema;
17
18
  constructor(schema) {
18
19
  super('Unknown type');
@@ -1,26 +1,27 @@
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
1
2
  import type { TSchema } from '../../type/schema/index.mjs';
2
3
  import type { Static } from '../../type/static/index.mjs';
3
- export declare class ValueCreateUnknownTypeError extends Error {
4
+ export declare class ValueCreateUnknownTypeError extends TypeBoxError {
4
5
  readonly schema: TSchema;
5
6
  constructor(schema: TSchema);
6
7
  }
7
- export declare class ValueCreateNeverTypeError extends Error {
8
+ export declare class ValueCreateNeverTypeError extends TypeBoxError {
8
9
  readonly schema: TSchema;
9
10
  constructor(schema: TSchema);
10
11
  }
11
- export declare class ValueCreateNotTypeError extends Error {
12
+ export declare class ValueCreateNotTypeError extends TypeBoxError {
12
13
  readonly schema: TSchema;
13
14
  constructor(schema: TSchema);
14
15
  }
15
- export declare class ValueCreateIntersectTypeError extends Error {
16
+ export declare class ValueCreateIntersectTypeError extends TypeBoxError {
16
17
  readonly schema: TSchema;
17
18
  constructor(schema: TSchema);
18
19
  }
19
- export declare class ValueCreateTempateLiteralTypeError extends Error {
20
+ export declare class ValueCreateTempateLiteralTypeError extends TypeBoxError {
20
21
  readonly schema: TSchema;
21
22
  constructor(schema: TSchema);
22
23
  }
23
- export declare class ValueCreateRecursiveInstantiationError extends Error {
24
+ export declare class ValueCreateRecursiveInstantiationError extends TypeBoxError {
24
25
  readonly schema: TSchema;
25
26
  readonly recursiveMaxDepth: number;
26
27
  constructor(schema: TSchema, recursiveMaxDepth: number);
@@ -5,45 +5,46 @@ import { TemplateLiteralGenerate, IsTemplateLiteralFinite } from '../../type/tem
5
5
  import { PatternStringExact, PatternNumberExact } from '../../type/patterns/index.mjs';
6
6
  import { TypeRegistry } from '../../type/registry/index.mjs';
7
7
  import { Kind } from '../../type/symbols/index.mjs';
8
+ import { TypeBoxError } from '../../type/error/index.mjs';
8
9
  // ------------------------------------------------------------------
9
10
  // Errors
10
11
  // ------------------------------------------------------------------
11
- export class ValueCreateUnknownTypeError extends Error {
12
+ export class ValueCreateUnknownTypeError extends TypeBoxError {
12
13
  schema;
13
14
  constructor(schema) {
14
15
  super('Unknown type');
15
16
  this.schema = schema;
16
17
  }
17
18
  }
18
- export class ValueCreateNeverTypeError extends Error {
19
+ export class ValueCreateNeverTypeError extends TypeBoxError {
19
20
  schema;
20
21
  constructor(schema) {
21
22
  super('Never types cannot be created');
22
23
  this.schema = schema;
23
24
  }
24
25
  }
25
- export class ValueCreateNotTypeError extends Error {
26
+ export class ValueCreateNotTypeError extends TypeBoxError {
26
27
  schema;
27
28
  constructor(schema) {
28
29
  super('Not types must have a default value');
29
30
  this.schema = schema;
30
31
  }
31
32
  }
32
- export class ValueCreateIntersectTypeError extends Error {
33
+ export class ValueCreateIntersectTypeError extends TypeBoxError {
33
34
  schema;
34
35
  constructor(schema) {
35
36
  super('Intersect produced invalid value. Consider using a default value.');
36
37
  this.schema = schema;
37
38
  }
38
39
  }
39
- export class ValueCreateTempateLiteralTypeError extends Error {
40
+ export class ValueCreateTempateLiteralTypeError extends TypeBoxError {
40
41
  schema;
41
42
  constructor(schema) {
42
43
  super('Can only create template literal values from patterns that produce finite sequences. Consider using a default value.');
43
44
  this.schema = schema;
44
45
  }
45
46
  }
46
- export class ValueCreateRecursiveInstantiationError extends Error {
47
+ export class ValueCreateRecursiveInstantiationError extends TypeBoxError {
47
48
  schema;
48
49
  recursiveMaxDepth;
49
50
  constructor(schema, recursiveMaxDepth) {
@@ -1,4 +1,5 @@
1
1
  import type { Static } from '../../type/static/index.mjs';
2
+ import { TypeBoxError } from '../../type/error/index.mjs';
2
3
  export type Insert = Static<typeof Insert>;
3
4
  export declare const Insert: import("../../type/object/object.mjs").TObject<{
4
5
  type: import("../../type/literal/literal.mjs").TLiteral<"insert">;
@@ -29,11 +30,11 @@ export declare const Edit: import("../../type/union/union-type.mjs").TUnion<[imp
29
30
  type: import("../../type/literal/literal.mjs").TLiteral<"delete">;
30
31
  path: import("../../type/string/string.mjs").TString;
31
32
  }>]>;
32
- export declare class ValueDeltaObjectWithSymbolKeyError extends Error {
33
+ export declare class ValueDeltaObjectWithSymbolKeyError extends TypeBoxError {
33
34
  readonly key: unknown;
34
35
  constructor(key: unknown);
35
36
  }
36
- export declare class ValueDeltaUnableToDiffUnknownValue extends Error {
37
+ export declare class ValueDeltaUnableToDiffUnknownValue extends TypeBoxError {
37
38
  readonly value: unknown;
38
39
  constructor(value: unknown);
39
40
  }
@@ -1,6 +1,7 @@
1
1
  import { IsPlainObject, IsArray, IsTypedArray, IsValueType, IsSymbol, IsUndefined } from '../guard/index.mjs';
2
2
  import { ValuePointer } from '../pointer/index.mjs';
3
3
  import { Clone } from '../clone/index.mjs';
4
+ import { TypeBoxError } from '../../type/error/index.mjs';
4
5
  import { Literal as CreateLiteral } from '../../type/literal/index.mjs';
5
6
  import { Object as CreateObject } from '../../type/object/index.mjs';
6
7
  import { String as CreateString } from '../../type/string/index.mjs';
@@ -24,14 +25,14 @@ export const Edit = CreateUnion([Insert, Update, Delete]);
24
25
  // ------------------------------------------------------------------
25
26
  // Errors
26
27
  // ------------------------------------------------------------------
27
- export class ValueDeltaObjectWithSymbolKeyError extends Error {
28
+ export class ValueDeltaObjectWithSymbolKeyError extends TypeBoxError {
28
29
  key;
29
30
  constructor(key) {
30
31
  super('Cannot diff objects with symbol keys');
31
32
  this.key = key;
32
33
  }
33
34
  }
34
- export class ValueDeltaUnableToDiffUnknownValue extends Error {
35
+ export class ValueDeltaUnableToDiffUnknownValue extends TypeBoxError {
35
36
  value;
36
37
  constructor(value) {
37
38
  super('Unable to create diff edits for unknown value');
@@ -1,7 +1,8 @@
1
1
  import type { TSchema } from '../../type/schema/index.mjs';
2
2
  import type { TRef } from '../../type/ref/index.mjs';
3
3
  import type { TThis } from '../../type/recursive/index.mjs';
4
- export declare class TypeDereferenceError extends Error {
4
+ import { TypeBoxError } from '../../type/error/index.mjs';
5
+ export declare class TypeDereferenceError extends TypeBoxError {
5
6
  readonly schema: TRef | TThis;
6
7
  constructor(schema: TRef | TThis);
7
8
  }
@@ -1,4 +1,5 @@
1
- export class TypeDereferenceError extends Error {
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
2
+ export class TypeDereferenceError extends TypeBoxError {
2
3
  schema;
3
4
  constructor(schema) {
4
5
  super(`Unable to dereference schema with $id '${schema.$id}'`);
@@ -1,4 +1,5 @@
1
- export declare class ValueHashError extends Error {
1
+ import { TypeBoxError } from '../../type/error/index.mjs';
2
+ export declare class ValueHashError extends TypeBoxError {
2
3
  readonly value: unknown;
3
4
  constructor(value: unknown);
4
5
  }