@sinclair/typebox 0.32.0-dev-10 → 0.32.0-dev-11
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/build/import/compiler/compiler.mjs +1 -1
- package/build/import/type/tuple/tuple.d.mts +3 -1
- package/build/import/value/index.d.mts +1 -1
- package/build/import/value/index.mjs +1 -1
- package/build/import/value/transform/decode.d.mts +1 -1
- package/build/import/value/transform/decode.mjs +1 -1
- package/build/import/value/transform/encode.d.mts +1 -1
- package/build/import/value/transform/encode.mjs +1 -1
- package/build/import/value/value/value.mjs +3 -3
- package/build/require/compiler/compiler.js +2 -2
- package/build/require/type/tuple/tuple.d.ts +3 -1
- package/build/require/value/index.d.ts +1 -1
- package/build/require/value/index.js +3 -3
- package/build/require/value/transform/decode.d.ts +1 -1
- package/build/require/value/transform/decode.js +3 -3
- package/build/require/value/transform/encode.d.ts +1 -1
- package/build/require/value/transform/encode.js +3 -3
- package/build/require/value/value/value.js +2 -2
- package/package.json +4 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformEncode, TransformDecode, HasTransform, TransformDecodeCheckError, TransformEncodeCheckError } from '../value/transform/index.mjs';
|
|
2
2
|
import { IsArray, IsString, IsNumber, IsBigInt } from '../value/guard/index.mjs';
|
|
3
3
|
import { Errors } from '../errors/index.mjs';
|
|
4
4
|
import { TypeSystemPolicy } from '../system/index.mjs';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index.mjs';
|
|
2
2
|
import type { Static } from '../static/index.mjs';
|
|
3
3
|
import { Kind } from '../symbols/index.mjs';
|
|
4
|
-
|
|
4
|
+
type FromRest<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...FromRest<R, P>] : [];
|
|
5
|
+
type TupleResolve<T extends TSchema[], P extends unknown[], R extends unknown[] = FromRest<T, P>> = R;
|
|
5
6
|
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
6
7
|
[Kind]: 'Tuple';
|
|
7
8
|
static: TupleResolve<T, this['params']>;
|
|
@@ -12,3 +13,4 @@ export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
|
12
13
|
maxItems: number;
|
|
13
14
|
}
|
|
14
15
|
export declare function Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
16
|
+
export {};
|
|
@@ -11,6 +11,6 @@ export { Equal } from './equal/index.mjs';
|
|
|
11
11
|
export { Hash, ValueHashError } from './hash/index.mjs';
|
|
12
12
|
export { Mutate, type Mutable, ValueMutateInvalidRootMutationError, ValueMutateTypeMismatchError } from './mutate/index.mjs';
|
|
13
13
|
export { ValuePointer } from './pointer/index.mjs';
|
|
14
|
-
export {
|
|
14
|
+
export { TransformDecode as DecodeTransform, TransformEncode as EncodeTransform, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index.mjs';
|
|
15
15
|
export { ArrayType, HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, ObjectType, TypedArrayType, ValueType, } from './guard/index.mjs';
|
|
16
16
|
export { Value } from './value/index.mjs';
|
|
@@ -11,6 +11,6 @@ export { Equal } from './equal/index.mjs';
|
|
|
11
11
|
export { Hash, ValueHashError } from './hash/index.mjs';
|
|
12
12
|
export { Mutate, ValueMutateInvalidRootMutationError, ValueMutateTypeMismatchError } from './mutate/index.mjs';
|
|
13
13
|
export { ValuePointer } from './pointer/index.mjs';
|
|
14
|
-
export {
|
|
14
|
+
export { TransformDecode as DecodeTransform, TransformEncode as EncodeTransform, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index.mjs';
|
|
15
15
|
export { HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, } from './guard/index.mjs';
|
|
16
16
|
export { Value } from './value/index.mjs';
|
|
@@ -11,4 +11,4 @@ export declare class TransformDecodeError extends Error {
|
|
|
11
11
|
readonly value: unknown;
|
|
12
12
|
constructor(schema: TSchema, value: unknown, error: any);
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function TransformDecode(schema: TSchema, references: TSchema[], value: unknown): unknown;
|
|
@@ -155,6 +155,6 @@ function Visit(schema, references, value) {
|
|
|
155
155
|
return Default(schema_, value);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
export function
|
|
158
|
+
export function TransformDecode(schema, references, value) {
|
|
159
159
|
return Visit(schema, references, value);
|
|
160
160
|
}
|
|
@@ -11,4 +11,4 @@ export declare class TransformEncodeError extends Error {
|
|
|
11
11
|
readonly value: unknown;
|
|
12
12
|
constructor(schema: TSchema, value: unknown, error: any);
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function TransformEncode(schema: TSchema, references: TSchema[], value: unknown): unknown;
|
|
@@ -161,6 +161,6 @@ function Visit(schema, references, value) {
|
|
|
161
161
|
return Default(schema_, value);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
export function
|
|
164
|
+
export function TransformEncode(schema, references, value) {
|
|
165
165
|
return Visit(schema, references, value);
|
|
166
166
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformDecode, TransformEncode, TransformDecodeCheckError, TransformEncodeCheckError } from '../transform/index.mjs';
|
|
2
2
|
import { Mutate as MutateValue } from '../mutate/index.mjs';
|
|
3
3
|
import { Hash as HashValue } from '../hash/index.mjs';
|
|
4
4
|
import { Equal as EqualValue } from '../equal/index.mjs';
|
|
@@ -33,14 +33,14 @@ export function Decode(...args) {
|
|
|
33
33
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
34
34
|
if (!Check(schema, references, value))
|
|
35
35
|
throw new TransformDecodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
36
|
-
return
|
|
36
|
+
return TransformDecode(schema, references, value);
|
|
37
37
|
}
|
|
38
38
|
export function Default(...args) {
|
|
39
39
|
return DefaultValue.apply(DefaultValue, args);
|
|
40
40
|
}
|
|
41
41
|
export function Encode(...args) {
|
|
42
42
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
43
|
-
const encoded =
|
|
43
|
+
const encoded = TransformEncode(schema, references, value);
|
|
44
44
|
if (!Check(schema, references, encoded))
|
|
45
45
|
throw new TransformEncodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
46
46
|
return encoded;
|
|
@@ -33,10 +33,10 @@ class TypeCheck {
|
|
|
33
33
|
Decode(value) {
|
|
34
34
|
if (!this.checkFunc(value))
|
|
35
35
|
throw new index_1.TransformDecodeCheckError(this.schema, value, this.Errors(value).First());
|
|
36
|
-
return this.hasTransform ? (0, index_1.
|
|
36
|
+
return this.hasTransform ? (0, index_1.TransformDecode)(this.schema, this.references, value) : value;
|
|
37
37
|
}
|
|
38
38
|
Encode(value) {
|
|
39
|
-
const encoded = this.hasTransform ? (0, index_1.
|
|
39
|
+
const encoded = this.hasTransform ? (0, index_1.TransformEncode)(this.schema, this.references, value) : value;
|
|
40
40
|
if (!this.checkFunc(encoded))
|
|
41
41
|
throw new index_1.TransformEncodeCheckError(this.schema, value, this.Errors(value).First());
|
|
42
42
|
return encoded;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import { Kind } from '../symbols/index';
|
|
4
|
-
|
|
4
|
+
type FromRest<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...FromRest<R, P>] : [];
|
|
5
|
+
type TupleResolve<T extends TSchema[], P extends unknown[], R extends unknown[] = FromRest<T, P>> = R;
|
|
5
6
|
export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
6
7
|
[Kind]: 'Tuple';
|
|
7
8
|
static: TupleResolve<T, this['params']>;
|
|
@@ -12,3 +13,4 @@ export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
|
12
13
|
maxItems: number;
|
|
13
14
|
}
|
|
14
15
|
export declare function Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>;
|
|
16
|
+
export {};
|
|
@@ -11,6 +11,6 @@ export { Equal } from './equal/index';
|
|
|
11
11
|
export { Hash, ValueHashError } from './hash/index';
|
|
12
12
|
export { Mutate, type Mutable, ValueMutateInvalidRootMutationError, ValueMutateTypeMismatchError } from './mutate/index';
|
|
13
13
|
export { ValuePointer } from './pointer/index';
|
|
14
|
-
export {
|
|
14
|
+
export { TransformDecode as DecodeTransform, TransformEncode as EncodeTransform, HasTransform, TransformDecodeCheckError, TransformDecodeError, TransformEncodeCheckError, TransformEncodeError } from './transform/index';
|
|
15
15
|
export { ArrayType, HasPropertyKey, IsArray, IsAsyncIterator, IsBigInt, IsBoolean, IsDate, IsFunction, IsInteger, IsIterator, IsNull, IsNumber, IsObject, IsPlainObject, IsPromise, IsString, IsSymbol, IsTypedArray, IsUint8Array, IsUndefined, IsValueType, ObjectType, TypedArrayType, ValueType, } from './guard/index';
|
|
16
16
|
export { Value } from './value/index';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.HasPropertyKey = exports.TransformEncodeError = exports.TransformEncodeCheckError = exports.TransformDecodeError = exports.TransformDecodeCheckError = exports.HasTransform = exports.
|
|
3
|
+
exports.IsInteger = exports.IsFunction = exports.IsDate = exports.IsBoolean = exports.IsBigInt = exports.IsAsyncIterator = exports.IsArray = exports.HasPropertyKey = exports.TransformEncodeError = exports.TransformEncodeCheckError = exports.TransformDecodeError = exports.TransformDecodeCheckError = exports.HasTransform = exports.EncodeTransform = exports.DecodeTransform = exports.ValuePointer = exports.ValueMutateTypeMismatchError = exports.ValueMutateInvalidRootMutationError = exports.Mutate = exports.ValueHashError = exports.Hash = exports.Equal = exports.ValueDeltaUnableToDiffUnknownValue = exports.ValueDeltaObjectWithSymbolKeyError = exports.Update = exports.Insert = exports.Delete = exports.Edit = exports.Patch = exports.Diff = exports.Default = exports.ValueCreateUnknownTypeError = exports.ValueCreateTempateLiteralTypeError = exports.ValueCreateRecursiveInstantiationError = exports.ValueCreateNotTypeError = exports.ValueCreateNeverTypeError = exports.ValueCreateIntersectTypeError = exports.Create = exports.ValueConvertUnknownTypeError = exports.Convert = exports.Clone = exports.Clean = exports.Check = exports.ValueCastUnknownTypeError = exports.ValueCastRecursiveTypeError = exports.ValueCastNeverTypeError = exports.ValueCastArrayUniqueItemsTypeError = exports.Cast = exports.ValueErrorIterator = exports.ValueErrorType = void 0;
|
|
4
4
|
exports.Value = exports.IsValueType = exports.IsUndefined = exports.IsUint8Array = exports.IsTypedArray = exports.IsSymbol = exports.IsString = exports.IsPromise = exports.IsPlainObject = exports.IsObject = exports.IsNumber = exports.IsNull = exports.IsIterator = void 0;
|
|
5
5
|
var index_1 = require("../errors/index");
|
|
6
6
|
Object.defineProperty(exports, "ValueErrorType", { enumerable: true, get: function () { return index_1.ValueErrorType; } });
|
|
@@ -51,8 +51,8 @@ Object.defineProperty(exports, "ValueMutateTypeMismatchError", { enumerable: tru
|
|
|
51
51
|
var index_13 = require("./pointer/index");
|
|
52
52
|
Object.defineProperty(exports, "ValuePointer", { enumerable: true, get: function () { return index_13.ValuePointer; } });
|
|
53
53
|
var index_14 = require("./transform/index");
|
|
54
|
-
Object.defineProperty(exports, "
|
|
55
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "DecodeTransform", { enumerable: true, get: function () { return index_14.TransformDecode; } });
|
|
55
|
+
Object.defineProperty(exports, "EncodeTransform", { enumerable: true, get: function () { return index_14.TransformEncode; } });
|
|
56
56
|
Object.defineProperty(exports, "HasTransform", { enumerable: true, get: function () { return index_14.HasTransform; } });
|
|
57
57
|
Object.defineProperty(exports, "TransformDecodeCheckError", { enumerable: true, get: function () { return index_14.TransformDecodeCheckError; } });
|
|
58
58
|
Object.defineProperty(exports, "TransformDecodeError", { enumerable: true, get: function () { return index_14.TransformDecodeError; } });
|
|
@@ -11,4 +11,4 @@ export declare class TransformDecodeError extends Error {
|
|
|
11
11
|
readonly value: unknown;
|
|
12
12
|
constructor(schema: TSchema, value: unknown, error: any);
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function TransformDecode(schema: TSchema, references: TSchema[], value: unknown): unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TransformDecode = exports.TransformDecodeError = exports.TransformDecodeCheckError = void 0;
|
|
4
4
|
const type_1 = require("../../type/guard/type");
|
|
5
5
|
const index_1 = require("../../type/symbols/index");
|
|
6
6
|
const index_2 = require("../guard/index");
|
|
@@ -155,7 +155,7 @@ function Visit(schema, references, value) {
|
|
|
155
155
|
return Default(schema_, value);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function TransformDecode(schema, references, value) {
|
|
159
159
|
return Visit(schema, references, value);
|
|
160
160
|
}
|
|
161
|
-
exports.
|
|
161
|
+
exports.TransformDecode = TransformDecode;
|
|
@@ -11,4 +11,4 @@ export declare class TransformEncodeError extends Error {
|
|
|
11
11
|
readonly value: unknown;
|
|
12
12
|
constructor(schema: TSchema, value: unknown, error: any);
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function TransformEncode(schema: TSchema, references: TSchema[], value: unknown): unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TransformEncode = exports.TransformEncodeError = exports.TransformEncodeCheckError = void 0;
|
|
4
4
|
const type_1 = require("../../type/guard/type");
|
|
5
5
|
const index_1 = require("../../type/symbols/index");
|
|
6
6
|
const index_2 = require("../guard/index");
|
|
@@ -161,7 +161,7 @@ function Visit(schema, references, value) {
|
|
|
161
161
|
return Default(schema_, value);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function TransformEncode(schema, references, value) {
|
|
165
165
|
return Visit(schema, references, value);
|
|
166
166
|
}
|
|
167
|
-
exports.
|
|
167
|
+
exports.TransformEncode = TransformEncode;
|
|
@@ -42,7 +42,7 @@ function Decode(...args) {
|
|
|
42
42
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
43
43
|
if (!Check(schema, references, value))
|
|
44
44
|
throw new index_1.TransformDecodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
45
|
-
return (0, index_1.
|
|
45
|
+
return (0, index_1.TransformDecode)(schema, references, value);
|
|
46
46
|
}
|
|
47
47
|
exports.Decode = Decode;
|
|
48
48
|
function Default(...args) {
|
|
@@ -51,7 +51,7 @@ function Default(...args) {
|
|
|
51
51
|
exports.Default = Default;
|
|
52
52
|
function Encode(...args) {
|
|
53
53
|
const [schema, references, value] = args.length === 3 ? [args[0], args[1], args[2]] : [args[0], [], args[1]];
|
|
54
|
-
const encoded = (0, index_1.
|
|
54
|
+
const encoded = (0, index_1.TransformEncode)(schema, references, value);
|
|
55
55
|
if (!Check(schema, references, encoded))
|
|
56
56
|
throw new index_1.TransformEncodeCheckError(schema, value, Errors(schema, references, value).First());
|
|
57
57
|
return encoded;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinclair/typebox",
|
|
3
|
-
"version": "0.32.0-dev-
|
|
3
|
+
"version": "0.32.0-dev-11",
|
|
4
4
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "https://github.com/sinclairzx81/typebox"
|
|
16
16
|
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo test"
|
|
19
|
+
},
|
|
17
20
|
"module": "./build/import/index.mjs",
|
|
18
21
|
"types": "./build/require/index.d.ts",
|
|
19
22
|
"main": "./build/require/index.js",
|