@sinclair/typebox 0.34.15 → 0.34.17
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/cjs/compiler/compiler.js +5 -0
- package/build/cjs/errors/errors.js +3 -0
- package/build/cjs/index.d.ts +3 -0
- package/build/cjs/index.js +3 -0
- package/build/cjs/syntax/index.d.ts +1 -1
- package/build/cjs/syntax/index.js +1 -1
- package/build/cjs/syntax/runtime.d.ts +40 -54
- package/build/cjs/syntax/runtime.js +91 -203
- package/build/cjs/syntax/static.d.ts +80 -146
- package/build/cjs/syntax/syntax.d.ts +33 -0
- package/build/cjs/syntax/syntax.js +37 -0
- package/build/cjs/type/argument/argument.d.ts +9 -0
- package/build/cjs/type/argument/argument.js +10 -0
- package/build/cjs/type/argument/index.d.ts +1 -0
- package/build/cjs/type/argument/index.js +18 -0
- package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +3 -3
- package/build/cjs/type/constructor-parameters/constructor-parameters.js +3 -1
- package/build/cjs/type/guard/kind.d.ts +9 -6
- package/build/cjs/type/guard/kind.js +6 -0
- package/build/cjs/type/guard/type.d.ts +9 -6
- package/build/cjs/type/guard/type.js +9 -0
- package/build/cjs/type/index.d.ts +2 -0
- package/build/cjs/type/index.js +2 -0
- package/build/cjs/type/instance-type/instance-type.d.ts +5 -4
- package/build/cjs/type/instance-type/instance-type.js +3 -1
- package/build/cjs/type/instantiate/index.d.ts +1 -0
- package/build/cjs/type/instantiate/index.js +18 -0
- package/build/cjs/type/instantiate/instantiate.d.ts +25 -0
- package/build/cjs/type/instantiate/instantiate.js +32 -0
- package/build/cjs/type/parameters/parameters.d.ts +3 -3
- package/build/cjs/type/parameters/parameters.js +3 -1
- package/build/cjs/type/record/record.d.ts +16 -1
- package/build/cjs/type/record/record.js +53 -23
- package/build/cjs/type/remap/index.d.ts +1 -0
- package/build/cjs/type/remap/index.js +18 -0
- package/build/cjs/type/remap/remap.d.ts +19 -0
- package/build/cjs/type/remap/remap.js +35 -0
- package/build/cjs/type/return-type/return-type.d.ts +5 -4
- package/build/cjs/type/return-type/return-type.js +3 -1
- package/build/cjs/type/type/javascript.d.ts +10 -4
- package/build/cjs/type/type/javascript.js +44 -34
- package/build/cjs/type/type/type.d.ts +3 -0
- package/build/cjs/type/type/type.js +123 -117
- package/build/cjs/value/check/check.js +5 -0
- package/build/cjs/value/create/create.js +5 -0
- package/build/esm/compiler/compiler.mjs +5 -0
- package/build/esm/errors/errors.mjs +3 -0
- package/build/esm/index.d.mts +3 -0
- package/build/esm/index.mjs +3 -0
- package/build/esm/syntax/index.d.mts +1 -1
- package/build/esm/syntax/index.mjs +1 -1
- package/build/esm/syntax/runtime.d.mts +40 -54
- package/build/esm/syntax/runtime.mjs +91 -203
- package/build/esm/syntax/static.d.mts +80 -146
- package/build/esm/syntax/syntax.d.mts +33 -0
- package/build/esm/syntax/syntax.mjs +30 -0
- package/build/esm/type/argument/argument.d.mts +9 -0
- package/build/esm/type/argument/argument.mjs +6 -0
- package/build/esm/type/argument/index.d.mts +1 -0
- package/build/esm/type/argument/index.mjs +1 -0
- package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +3 -3
- package/build/esm/type/constructor-parameters/constructor-parameters.mjs +3 -1
- package/build/esm/type/guard/kind.d.mts +9 -6
- package/build/esm/type/guard/kind.mjs +5 -0
- package/build/esm/type/guard/type.d.mts +9 -6
- package/build/esm/type/guard/type.mjs +8 -0
- package/build/esm/type/index.d.mts +2 -0
- package/build/esm/type/index.mjs +2 -0
- package/build/esm/type/instance-type/instance-type.d.mts +5 -4
- package/build/esm/type/instance-type/instance-type.mjs +3 -1
- package/build/esm/type/instantiate/index.d.mts +1 -0
- package/build/esm/type/instantiate/index.mjs +1 -0
- package/build/esm/type/instantiate/instantiate.d.mts +25 -0
- package/build/esm/type/instantiate/instantiate.mjs +28 -0
- package/build/esm/type/parameters/parameters.d.mts +3 -3
- package/build/esm/type/parameters/parameters.mjs +3 -1
- package/build/esm/type/record/record.d.mts +16 -1
- package/build/esm/type/record/record.mjs +35 -8
- package/build/esm/type/remap/index.d.mts +1 -0
- package/build/esm/type/remap/index.mjs +1 -0
- package/build/esm/type/remap/remap.d.mts +19 -0
- package/build/esm/type/remap/remap.mjs +31 -0
- package/build/esm/type/return-type/return-type.d.mts +5 -4
- package/build/esm/type/return-type/return-type.mjs +3 -1
- package/build/esm/type/type/javascript.d.mts +10 -4
- package/build/esm/type/type/javascript.mjs +10 -0
- package/build/esm/type/type/type.d.mts +3 -0
- package/build/esm/type/type/type.mjs +3 -0
- package/build/esm/value/check/check.mjs +5 -0
- package/build/esm/value/create/create.mjs +5 -0
- package/package.json +11 -1
- package/parser/package.json +4 -0
- package/readme.md +107 -184
- package/build/cjs/syntax/parse.d.ts +0 -15
- package/build/cjs/syntax/parse.js +0 -19
- package/build/esm/syntax/parse.d.mts +0 -15
- package/build/esm/syntax/parse.mjs +0 -14
- /package/build/cjs/{syntax/parsebox → parser}/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.js +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.mjs +0 -0
|
@@ -209,6 +209,9 @@ var TypeCompiler;
|
|
|
209
209
|
function* FromAny(schema, references, value) {
|
|
210
210
|
yield 'true';
|
|
211
211
|
}
|
|
212
|
+
function* FromArgument(schema, references, value) {
|
|
213
|
+
yield 'true';
|
|
214
|
+
}
|
|
212
215
|
function* FromArray(schema, references, value) {
|
|
213
216
|
yield `Array.isArray(${value})`;
|
|
214
217
|
const [parameter, accumulator] = [CreateParameter('value', 'any'), CreateParameter('acc', 'number')];
|
|
@@ -493,6 +496,8 @@ var TypeCompiler;
|
|
|
493
496
|
switch (schema_[index_7.Kind]) {
|
|
494
497
|
case 'Any':
|
|
495
498
|
return yield* FromAny(schema_, references_, value);
|
|
499
|
+
case 'Argument':
|
|
500
|
+
return yield* FromArgument(schema_, references_, value);
|
|
496
501
|
case 'Array':
|
|
497
502
|
return yield* FromArray(schema_, references_, value);
|
|
498
503
|
case 'AsyncIterator':
|
|
@@ -145,6 +145,7 @@ function Create(errorType, schema, path, value, errors = []) {
|
|
|
145
145
|
// Types
|
|
146
146
|
// --------------------------------------------------------------------------
|
|
147
147
|
function* FromAny(schema, references, path, value) { }
|
|
148
|
+
function* FromArgument(schema, references, path, value) { }
|
|
148
149
|
function* FromArray(schema, references, path, value) {
|
|
149
150
|
if (!(0, index_10.IsArray)(value)) {
|
|
150
151
|
return yield Create(ValueErrorType.Array, schema, path, value);
|
|
@@ -521,6 +522,8 @@ function* Visit(schema, references, path, value) {
|
|
|
521
522
|
switch (schema_[index_8.Kind]) {
|
|
522
523
|
case 'Any':
|
|
523
524
|
return yield* FromAny(schema_, references_, path, value);
|
|
525
|
+
case 'Argument':
|
|
526
|
+
return yield* FromArgument(schema_, references_, path, value);
|
|
524
527
|
case 'Array':
|
|
525
528
|
return yield* FromArray(schema_, references_, path, value);
|
|
526
529
|
case 'AsyncIterator':
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './type/sets/index';
|
|
|
9
9
|
export * from './type/symbols/index';
|
|
10
10
|
export * from './type/any/index';
|
|
11
11
|
export * from './type/array/index';
|
|
12
|
+
export * from './type/argument/index';
|
|
12
13
|
export * from './type/async-iterator/index';
|
|
13
14
|
export * from './type/awaited/index';
|
|
14
15
|
export * from './type/bigint/index';
|
|
@@ -25,6 +26,7 @@ export * from './type/extract/index';
|
|
|
25
26
|
export * from './type/function/index';
|
|
26
27
|
export * from './type/indexed/index';
|
|
27
28
|
export * from './type/instance-type/index';
|
|
29
|
+
export * from './type/instantiate/index';
|
|
28
30
|
export * from './type/integer/index';
|
|
29
31
|
export * from './type/intersect/index';
|
|
30
32
|
export * from './type/iterator/index';
|
|
@@ -50,6 +52,7 @@ export * from './type/record/index';
|
|
|
50
52
|
export * from './type/recursive/index';
|
|
51
53
|
export * from './type/ref/index';
|
|
52
54
|
export * from './type/regexp/index';
|
|
55
|
+
export * from './type/remap/index';
|
|
53
56
|
export * from './type/required/index';
|
|
54
57
|
export * from './type/rest/index';
|
|
55
58
|
export * from './type/return-type/index';
|
package/build/cjs/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./type/symbols/index"), exports);
|
|
|
32
32
|
// ------------------------------------------------------------------
|
|
33
33
|
__exportStar(require("./type/any/index"), exports);
|
|
34
34
|
__exportStar(require("./type/array/index"), exports);
|
|
35
|
+
__exportStar(require("./type/argument/index"), exports);
|
|
35
36
|
__exportStar(require("./type/async-iterator/index"), exports);
|
|
36
37
|
__exportStar(require("./type/awaited/index"), exports);
|
|
37
38
|
__exportStar(require("./type/bigint/index"), exports);
|
|
@@ -48,6 +49,7 @@ __exportStar(require("./type/extract/index"), exports);
|
|
|
48
49
|
__exportStar(require("./type/function/index"), exports);
|
|
49
50
|
__exportStar(require("./type/indexed/index"), exports);
|
|
50
51
|
__exportStar(require("./type/instance-type/index"), exports);
|
|
52
|
+
__exportStar(require("./type/instantiate/index"), exports);
|
|
51
53
|
__exportStar(require("./type/integer/index"), exports);
|
|
52
54
|
__exportStar(require("./type/intersect/index"), exports);
|
|
53
55
|
__exportStar(require("./type/iterator/index"), exports);
|
|
@@ -73,6 +75,7 @@ __exportStar(require("./type/record/index"), exports);
|
|
|
73
75
|
__exportStar(require("./type/recursive/index"), exports);
|
|
74
76
|
__exportStar(require("./type/ref/index"), exports);
|
|
75
77
|
__exportStar(require("./type/regexp/index"), exports);
|
|
78
|
+
__exportStar(require("./type/remap/index"), exports);
|
|
76
79
|
__exportStar(require("./type/required/index"), exports);
|
|
77
80
|
__exportStar(require("./type/rest/index"), exports);
|
|
78
81
|
__exportStar(require("./type/return-type/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './syntax';
|
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./syntax"), exports);
|
|
@@ -1,71 +1,57 @@
|
|
|
1
|
-
import { Runtime } from '
|
|
2
|
-
import * as
|
|
1
|
+
import { Runtime } from '../parser/index';
|
|
2
|
+
import * as t from '../type/index';
|
|
3
3
|
export declare const Module: Runtime.Module<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Heritage: Runtime.IUnion<unknown[]>;
|
|
7
|
-
InterfaceDeclaration: Runtime.ITuple<{
|
|
8
|
-
[x: string]: Types.TIntersect<[...Types.TRef<string>[], Types.TObject<Types.TProperties>]>;
|
|
9
|
-
}>;
|
|
10
|
-
TypeAliasDeclaration: Runtime.ITuple<{
|
|
11
|
-
[x: string]: Types.TSchema;
|
|
12
|
-
}>;
|
|
13
|
-
ModuleType: Runtime.IUnion<unknown>;
|
|
14
|
-
ModuleProperties: Runtime.IUnion<Types.TProperties>;
|
|
15
|
-
ModuleDeclaration: Runtime.ITuple<Types.TModule<Types.TProperties, {
|
|
16
|
-
[x: string]: Types.TSchema;
|
|
17
|
-
[x: number]: Types.TSchema;
|
|
18
|
-
}>>;
|
|
19
|
-
Literal: Runtime.IUnion<Types.TLiteral<string> | Types.TLiteral<number> | Types.TLiteral<boolean>>;
|
|
20
|
-
Keyword: Runtime.IUnion<Types.TAny | Types.TNever | Types.TString | Types.TBoolean | Types.TNumber | Types.TInteger | Types.TBigInt | Types.TNull | Types.TSymbol | Types.TUndefined | Types.TUnknown | Types.TVoid>;
|
|
4
|
+
Literal: Runtime.IUnion<t.TLiteral<string> | t.TLiteral<number> | t.TLiteral<boolean>>;
|
|
5
|
+
Keyword: Runtime.IUnion<t.TAny | t.TBoolean | t.TBigInt | t.TNever | t.TString | t.TNumber | t.TInteger | t.TNull | t.TSymbol | t.TUndefined | t.TUnknown | t.TVoid>;
|
|
21
6
|
KeyOf: Runtime.IUnion<boolean>;
|
|
22
7
|
IndexArray: Runtime.IUnion<unknown[]>;
|
|
23
8
|
Extends: Runtime.IUnion<unknown[]>;
|
|
24
9
|
Base: Runtime.IUnion<unknown>;
|
|
25
|
-
Factor: Runtime.ITuple<
|
|
10
|
+
Factor: Runtime.ITuple<t.TSchema>;
|
|
26
11
|
ExprTermTail: Runtime.IUnion<[] | ["&", unknown, unknown]>;
|
|
27
|
-
ExprTerm: Runtime.ITuple<
|
|
12
|
+
ExprTerm: Runtime.ITuple<t.TSchema>;
|
|
28
13
|
ExprTail: Runtime.IUnion<[] | ["|", unknown, unknown]>;
|
|
29
|
-
Expr: Runtime.ITuple<
|
|
14
|
+
Expr: Runtime.ITuple<t.TSchema>;
|
|
30
15
|
Type: Runtime.IRef<unknown>;
|
|
31
16
|
PropertyKey: Runtime.IUnion<string>;
|
|
32
17
|
Readonly: Runtime.IUnion<boolean>;
|
|
33
18
|
Optional: Runtime.IUnion<boolean>;
|
|
34
19
|
Property: Runtime.ITuple<{
|
|
35
|
-
[x: string]:
|
|
20
|
+
[x: string]: t.TSchema;
|
|
36
21
|
}>;
|
|
37
22
|
PropertyDelimiter: Runtime.IUnion<[","] | [",", "\n"] | [";"] | [";", "\n"] | ["\n"]>;
|
|
38
|
-
Properties: Runtime.IUnion<
|
|
39
|
-
Object: Runtime.ITuple<
|
|
23
|
+
Properties: Runtime.IUnion<t.TProperties>;
|
|
24
|
+
Object: Runtime.ITuple<t.TObject<t.TProperties>>;
|
|
40
25
|
Elements: Runtime.IUnion<unknown[]>;
|
|
41
|
-
Tuple: Runtime.ITuple<
|
|
42
|
-
Parameter: Runtime.ITuple<
|
|
43
|
-
Function: Runtime.ITuple<
|
|
26
|
+
Tuple: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
27
|
+
Parameter: Runtime.ITuple<t.TSchema>;
|
|
28
|
+
Function: Runtime.ITuple<t.TFunction<t.TSchema[], t.TSchema>>;
|
|
44
29
|
Parameters: Runtime.IUnion<unknown[]>;
|
|
45
|
-
Constructor: Runtime.ITuple<
|
|
46
|
-
Mapped: Runtime.ITuple<
|
|
47
|
-
AsyncIterator: Runtime.ITuple<
|
|
48
|
-
Iterator: Runtime.ITuple<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
30
|
+
Constructor: Runtime.ITuple<t.TConstructor<t.TSchema[], t.TSchema>>;
|
|
31
|
+
Mapped: Runtime.ITuple<t.TLiteral<"Mapped types not supported">>;
|
|
32
|
+
AsyncIterator: Runtime.ITuple<t.TAsyncIterator<t.TSchema>>;
|
|
33
|
+
Iterator: Runtime.ITuple<t.TIterator<t.TSchema>>;
|
|
34
|
+
Argument: Runtime.ITuple<t.TNever | t.TArgument<number>>;
|
|
35
|
+
Awaited: Runtime.ITuple<t.TSchema>;
|
|
36
|
+
Array: Runtime.ITuple<t.TArray<t.TSchema>>;
|
|
37
|
+
Record: Runtime.ITuple<t.TNever>;
|
|
38
|
+
Promise: Runtime.ITuple<t.TPromise<t.TSchema>>;
|
|
39
|
+
ConstructorParameters: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
40
|
+
FunctionParameters: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
|
|
41
|
+
InstanceType: Runtime.ITuple<t.TSchema>;
|
|
42
|
+
ReturnType: Runtime.ITuple<t.TSchema>;
|
|
43
|
+
Partial: Runtime.ITuple<t.TObject<{}>>;
|
|
44
|
+
Required: Runtime.ITuple<t.TObject<{}>>;
|
|
45
|
+
Pick: Runtime.ITuple<t.TObject<{}>>;
|
|
46
|
+
Omit: Runtime.ITuple<t.TObject<{}>>;
|
|
47
|
+
Exclude: Runtime.ITuple<t.TNever>;
|
|
48
|
+
Extract: Runtime.ITuple<t.TSchema>;
|
|
49
|
+
Uppercase: Runtime.ITuple<t.TSchema>;
|
|
50
|
+
Lowercase: Runtime.ITuple<t.TSchema>;
|
|
51
|
+
Capitalize: Runtime.ITuple<t.TSchema>;
|
|
52
|
+
Uncapitalize: Runtime.ITuple<t.TSchema>;
|
|
53
|
+
Date: Runtime.IConst<t.TDate>;
|
|
54
|
+
Uint8Array: Runtime.IConst<t.TUint8Array>;
|
|
55
|
+
GenericReference: Runtime.ITuple<t.TSchema>;
|
|
56
|
+
Reference: Runtime.IIdent<t.TSchema>;
|
|
71
57
|
}>;
|