@sinclair/typebox 0.30.0-dev-1 → 0.30.0-dev-2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.30.0-dev-1",
3
+ "version": "0.30.0-dev-2",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/value/cast.d.ts CHANGED
@@ -24,8 +24,7 @@ export declare class ValueCastDereferenceError extends Error {
24
24
  readonly schema: Types.TRef | Types.TThis;
25
25
  constructor(schema: Types.TRef | Types.TThis);
26
26
  }
27
- export declare function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): any;
28
- /** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
27
+ /** Casts a value into a given type and references. The return value will retain as much information of the original value as possible. */
29
28
  export declare function Cast<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): Types.Static<T>;
30
29
  /** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
31
30
  export declare function Cast<T extends Types.TSchema>(schema: T, value: unknown): Types.Static<T>;
package/value/cast.js CHANGED
@@ -27,7 +27,7 @@ THE SOFTWARE.
27
27
 
28
28
  ---------------------------------------------------------------------------*/
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Cast = exports.Visit = exports.ValueCastDereferenceError = exports.ValueCastUnknownTypeError = exports.ValueCastRecursiveTypeError = exports.ValueCastNeverTypeError = exports.ValueCastArrayUniqueItemsTypeError = exports.ValueCastReferenceTypeError = void 0;
30
+ exports.Cast = exports.ValueCastDereferenceError = exports.ValueCastUnknownTypeError = exports.ValueCastRecursiveTypeError = exports.ValueCastNeverTypeError = exports.ValueCastArrayUniqueItemsTypeError = exports.ValueCastReferenceTypeError = void 0;
31
31
  const Types = require("../typebox");
32
32
  const ValueCreate = require("./create");
33
33
  const ValueCheck = require("./check");
@@ -359,7 +359,6 @@ function Visit(schema, references, value) {
359
359
  return TKind(schema_, references_, value);
360
360
  }
361
361
  }
362
- exports.Visit = Visit;
363
362
  /** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
364
363
  function Cast(...args) {
365
364
  return args.length === 3 ? Visit(args[0], args[1], args[2]) : Visit(args[0], [], args[1]);
@@ -7,8 +7,7 @@ export declare class ValueConvertDereferenceError extends Error {
7
7
  readonly schema: Types.TRef | Types.TThis;
8
8
  constructor(schema: Types.TRef | Types.TThis);
9
9
  }
10
- export declare function Visit(schema: Types.TSchema, references: Types.TSchema[], value: any): unknown;
11
- /** Converts any type mismatched values to their target type if a conversion is possible. */
10
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
12
11
  export declare function Convert<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): unknown;
13
- /** Converts any type mismatched values to their target type if a conversion is possible. */
12
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
14
13
  export declare function Convert<T extends Types.TSchema>(schema: T, value: unknown): unknown;
package/value/convert.js CHANGED
@@ -27,7 +27,7 @@ THE SOFTWARE.
27
27
 
28
28
  ---------------------------------------------------------------------------*/
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Convert = exports.Visit = exports.ValueConvertDereferenceError = exports.ValueConvertUnknownTypeError = void 0;
30
+ exports.Convert = exports.ValueConvertDereferenceError = exports.ValueConvertUnknownTypeError = void 0;
31
31
  const Types = require("../typebox");
32
32
  const ValueClone = require("./clone");
33
33
  const ValueCheck = require("./check");
@@ -351,8 +351,7 @@ function Visit(schema, references, value) {
351
351
  return TUserDefined(schema_, references_, value);
352
352
  }
353
353
  }
354
- exports.Visit = Visit;
355
- /** Converts any type mismatched values to their target type if a conversion is possible. */
354
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possible. */
356
355
  function Convert(...args) {
357
356
  return args.length === 3 ? Visit(args[0], args[1], args[2]) : Visit(args[0], [], args[1]);
358
357
  }
package/value/create.d.ts CHANGED
@@ -28,9 +28,7 @@ export declare class ValueCreateRecursiveInstantiationError extends Error {
28
28
  readonly recursiveMaxDepth: number;
29
29
  constructor(schema: Types.TSchema, recursiveMaxDepth: number);
30
30
  }
31
- /** Creates a value from the given schema. If the schema specifies a default value, then that value is returned. */
32
- export declare function Visit(schema: Types.TSchema, references: Types.TSchema[]): unknown;
33
- /** Creates a value from the given schema */
31
+ /** Creates a value from the given schema and references */
34
32
  export declare function Create<T extends Types.TSchema>(schema: T, references: Types.TSchema[]): Types.Static<T>;
35
33
  /** Creates a value from the given schema */
36
- export declare function Create<T extends Types.TSchema>(schema: T, value: unknown): Types.Static<T>;
34
+ export declare function Create<T extends Types.TSchema>(schema: T): Types.Static<T>;
package/value/create.js CHANGED
@@ -27,7 +27,7 @@ THE SOFTWARE.
27
27
 
28
28
  ---------------------------------------------------------------------------*/
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Create = exports.Visit = exports.ValueCreateRecursiveInstantiationError = exports.ValueCreateDereferenceError = exports.ValueCreateTempateLiteralTypeError = exports.ValueCreateIntersectTypeError = exports.ValueCreateNotTypeError = exports.ValueCreateNeverTypeError = exports.ValueCreateUnknownTypeError = void 0;
30
+ exports.Create = exports.ValueCreateRecursiveInstantiationError = exports.ValueCreateDereferenceError = exports.ValueCreateTempateLiteralTypeError = exports.ValueCreateIntersectTypeError = exports.ValueCreateNotTypeError = exports.ValueCreateNeverTypeError = exports.ValueCreateUnknownTypeError = void 0;
31
31
  const Types = require("../typebox");
32
32
  const ValueCheck = require("./check");
33
33
  const ValueGuard = require("./guard");
@@ -431,7 +431,6 @@ function TKind(schema, references) {
431
431
  throw new Error('ValueCreate: User defined types must specify a default value');
432
432
  }
433
433
  }
434
- /** Creates a value from the given schema. If the schema specifies a default value, then that value is returned. */
435
434
  function Visit(schema, references) {
436
435
  const references_ = ValueGuard.IsString(schema.$id) ? [...references, schema] : references;
437
436
  const schema_ = schema;
@@ -502,7 +501,6 @@ function Visit(schema, references) {
502
501
  return TKind(schema_, references_);
503
502
  }
504
503
  }
505
- exports.Visit = Visit;
506
504
  // --------------------------------------------------------------------------
507
505
  // State
508
506
  // --------------------------------------------------------------------------
package/value/mutate.d.ts CHANGED
@@ -7,5 +7,5 @@ export declare class ValueMutateInvalidRootMutationError extends Error {
7
7
  export type Mutable = {
8
8
  [key: string]: unknown;
9
9
  } | unknown[];
10
- /** Performs a deep mutable value assignment while retaining internal references. */
10
+ /** Performs a deep mutable value assignment while retaining internal references */
11
11
  export declare function Mutate(current: Mutable, next: Mutable): void;
package/value/mutate.js CHANGED
@@ -118,7 +118,7 @@ function IsMismatchedValue(current, next) {
118
118
  // --------------------------------------------------------------------------
119
119
  // Mutate
120
120
  // --------------------------------------------------------------------------
121
- /** Performs a deep mutable value assignment while retaining internal references. */
121
+ /** Performs a deep mutable value assignment while retaining internal references */
122
122
  function Mutate(current, next) {
123
123
  if (IsNonMutableValue(current) || IsNonMutableValue(next))
124
124
  throw new ValueMutateInvalidRootMutationError();
package/value/value.d.ts CHANGED
@@ -8,17 +8,17 @@ export declare namespace Value {
8
8
  function Cast<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): Types.Static<T>;
9
9
  /** Casts a value into a given type. The return value will retain as much information of the original value as possible. */
10
10
  function Cast<T extends Types.TSchema>(schema: T, value: unknown): Types.Static<T>;
11
- /** Creates a value from the given type */
11
+ /** Creates a value from the given type and references */
12
12
  function Create<T extends Types.TSchema>(schema: T, references: Types.TSchema[]): Types.Static<T>;
13
13
  /** Creates a value from the given type */
14
14
  function Create<T extends Types.TSchema>(schema: T): Types.Static<T>;
15
- /** Returns true if the value matches the given type. */
15
+ /** Returns true if the value matches the given type and references */
16
16
  function Check<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): value is Types.Static<T>;
17
- /** Returns true if the value matches the given type. */
17
+ /** Returns true if the value matches the given type */
18
18
  function Check<T extends Types.TSchema>(schema: T, value: unknown): value is Types.Static<T>;
19
- /** Converts any type mismatched values to their target type if a conversion is possible. */
19
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possible */
20
20
  function Convert<T extends Types.TSchema>(schema: T, references: Types.TSchema[], value: unknown): unknown;
21
- /** Converts any type mismatched values to their target type if a conversion is possible. */
21
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possibl. */
22
22
  function Convert<T extends Types.TSchema>(schema: T, value: unknown): unknown;
23
23
  /** Returns a structural clone of the given value */
24
24
  function Clone<T>(value: T): T;
package/value/value.js CHANGED
@@ -51,12 +51,12 @@ var Value;
51
51
  return ValueCreate.Create.apply(ValueCreate, args);
52
52
  }
53
53
  Value.Create = Create;
54
- /** Returns true if the value matches the given type. */
54
+ /** Returns true if the value matches the given type */
55
55
  function Check(...args) {
56
56
  return ValueCheck.Check.apply(ValueCheck, args);
57
57
  }
58
58
  Value.Check = Check;
59
- /** Converts any type mismatched values to their target type if a conversion is possible. */
59
+ /** Converts any type mismatched values to their target type if a reasonable conversion is possible */
60
60
  function Convert(...args) {
61
61
  return ValueConvert.Convert.apply(ValueConvert, args);
62
62
  }