@sinclair/typebox 0.34.16 → 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/runtime.d.ts +3 -1
- package/build/cjs/syntax/runtime.js +33 -3
- package/build/cjs/syntax/static.d.ts +22 -2
- 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/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/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/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/type/javascript.d.ts +6 -0
- 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/runtime.d.mts +3 -1
- package/build/esm/syntax/runtime.mjs +33 -3
- package/build/esm/syntax/static.d.mts +22 -2
- 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/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/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/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/type/javascript.d.mts +6 -0
- 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 +1 -1
- package/readme.md +36 -39
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Record = Record;
|
|
5
|
+
exports.RecordPattern = RecordPattern;
|
|
6
|
+
exports.RecordKey = RecordKey;
|
|
7
|
+
exports.RecordValue = RecordValue;
|
|
5
8
|
const type_1 = require("../create/type");
|
|
6
9
|
const index_1 = require("../symbols/index");
|
|
7
10
|
const index_2 = require("../computed/index");
|
|
8
11
|
const index_3 = require("../never/index");
|
|
9
|
-
const index_4 = require("../
|
|
10
|
-
const index_5 = require("../
|
|
11
|
-
const index_6 = require("../
|
|
12
|
-
const index_7 = require("../
|
|
13
|
-
const index_8 = require("../
|
|
14
|
-
const index_9 = require("../
|
|
12
|
+
const index_4 = require("../number/index");
|
|
13
|
+
const index_5 = require("../object/index");
|
|
14
|
+
const index_6 = require("../ref/index");
|
|
15
|
+
const index_7 = require("../string/index");
|
|
16
|
+
const index_8 = require("../union/index");
|
|
17
|
+
const index_9 = require("../template-literal/index");
|
|
18
|
+
const index_10 = require("../patterns/index");
|
|
19
|
+
const index_11 = require("../indexed/index");
|
|
15
20
|
// ------------------------------------------------------------------
|
|
16
21
|
// ValueGuard
|
|
17
22
|
// ------------------------------------------------------------------
|
|
@@ -35,17 +40,17 @@ function RecordCreateFromKeys(K, T, options) {
|
|
|
35
40
|
const result = {};
|
|
36
41
|
for (const K2 of K)
|
|
37
42
|
result[K2] = T;
|
|
38
|
-
return (0,
|
|
43
|
+
return (0, index_5.Object)(result, { ...options, [index_1.Hint]: 'Record' });
|
|
39
44
|
}
|
|
40
45
|
// prettier-ignore
|
|
41
46
|
function FromTemplateLiteralKey(K, T, options) {
|
|
42
|
-
return ((0,
|
|
43
|
-
? RecordCreateFromKeys((0,
|
|
47
|
+
return ((0, index_9.IsTemplateLiteralFinite)(K)
|
|
48
|
+
? RecordCreateFromKeys((0, index_11.IndexPropertyKeys)(K), T, options)
|
|
44
49
|
: RecordCreateFromPattern(K.pattern, T, options));
|
|
45
50
|
}
|
|
46
51
|
// prettier-ignore
|
|
47
52
|
function FromUnionKey(key, type, options) {
|
|
48
|
-
return RecordCreateFromKeys((0,
|
|
53
|
+
return RecordCreateFromKeys((0, index_11.IndexPropertyKeys)((0, index_8.Union)(key)), type, options);
|
|
49
54
|
}
|
|
50
55
|
// prettier-ignore
|
|
51
56
|
function FromLiteralKey(key, type, options) {
|
|
@@ -57,24 +62,28 @@ function FromRegExpKey(key, type, options) {
|
|
|
57
62
|
}
|
|
58
63
|
// prettier-ignore
|
|
59
64
|
function FromStringKey(key, type, options) {
|
|
60
|
-
const pattern = (0, value_1.IsUndefined)(key.pattern) ?
|
|
65
|
+
const pattern = (0, value_1.IsUndefined)(key.pattern) ? index_10.PatternStringExact : key.pattern;
|
|
61
66
|
return RecordCreateFromPattern(pattern, type, options);
|
|
62
67
|
}
|
|
63
68
|
// prettier-ignore
|
|
64
69
|
function FromAnyKey(_, type, options) {
|
|
65
|
-
return RecordCreateFromPattern(
|
|
70
|
+
return RecordCreateFromPattern(index_10.PatternStringExact, type, options);
|
|
66
71
|
}
|
|
67
72
|
// prettier-ignore
|
|
68
73
|
function FromNeverKey(_key, type, options) {
|
|
69
|
-
return RecordCreateFromPattern(
|
|
74
|
+
return RecordCreateFromPattern(index_10.PatternNeverExact, type, options);
|
|
75
|
+
}
|
|
76
|
+
// prettier-ignore
|
|
77
|
+
function FromBooleanKey(_key, type, options) {
|
|
78
|
+
return (0, index_5.Object)({ true: type, false: type }, options);
|
|
70
79
|
}
|
|
71
80
|
// prettier-ignore
|
|
72
81
|
function FromIntegerKey(_key, type, options) {
|
|
73
|
-
return RecordCreateFromPattern(
|
|
82
|
+
return RecordCreateFromPattern(index_10.PatternNumberExact, type, options);
|
|
74
83
|
}
|
|
75
84
|
// prettier-ignore
|
|
76
85
|
function FromNumberKey(_, type, options) {
|
|
77
|
-
return RecordCreateFromPattern(
|
|
86
|
+
return RecordCreateFromPattern(index_10.PatternNumberExact, type, options);
|
|
78
87
|
}
|
|
79
88
|
// ------------------------------------------------------------------
|
|
80
89
|
// TRecordOrObject
|
|
@@ -84,15 +93,36 @@ function Record(key, type, options = {}) {
|
|
|
84
93
|
// prettier-ignore
|
|
85
94
|
return ((0, kind_1.IsComputed)(type) ? (0, index_2.Computed)('Record', [key, (0, index_2.Computed)(type.target, type.parameters)], options) :
|
|
86
95
|
(0, kind_1.IsComputed)(key) ? (0, index_2.Computed)('Record', [(0, index_2.Computed)(type.target, type.parameters), type], options) :
|
|
87
|
-
(0, kind_1.IsRef)(key) ? (0, index_2.Computed)('Record', [(0,
|
|
96
|
+
(0, kind_1.IsRef)(key) ? (0, index_2.Computed)('Record', [(0, index_6.Ref)(key.$ref), type]) :
|
|
88
97
|
(0, kind_1.IsUnion)(key) ? FromUnionKey(key.anyOf, type, options) :
|
|
89
98
|
(0, kind_1.IsTemplateLiteral)(key) ? FromTemplateLiteralKey(key, type, options) :
|
|
90
99
|
(0, kind_1.IsLiteral)(key) ? FromLiteralKey(key.const, type, options) :
|
|
91
|
-
(0, kind_1.
|
|
92
|
-
(0, kind_1.
|
|
93
|
-
(0, kind_1.
|
|
94
|
-
(0, kind_1.
|
|
95
|
-
(0, kind_1.
|
|
96
|
-
(0, kind_1.
|
|
97
|
-
(0,
|
|
100
|
+
(0, kind_1.IsBoolean)(key) ? FromBooleanKey(key, type, options) :
|
|
101
|
+
(0, kind_1.IsInteger)(key) ? FromIntegerKey(key, type, options) :
|
|
102
|
+
(0, kind_1.IsNumber)(key) ? FromNumberKey(key, type, options) :
|
|
103
|
+
(0, kind_1.IsRegExp)(key) ? FromRegExpKey(key, type, options) :
|
|
104
|
+
(0, kind_1.IsString)(key) ? FromStringKey(key, type, options) :
|
|
105
|
+
(0, kind_1.IsAny)(key) ? FromAnyKey(key, type, options) :
|
|
106
|
+
(0, kind_1.IsNever)(key) ? FromNeverKey(key, type, options) :
|
|
107
|
+
(0, index_3.Never)(options));
|
|
108
|
+
}
|
|
109
|
+
// ------------------------------------------------------------------
|
|
110
|
+
// Record Utilities
|
|
111
|
+
// ------------------------------------------------------------------
|
|
112
|
+
/** Gets the Records Pattern */
|
|
113
|
+
function RecordPattern(record) {
|
|
114
|
+
return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
|
|
115
|
+
}
|
|
116
|
+
/** Gets the Records Key Type */
|
|
117
|
+
// prettier-ignore
|
|
118
|
+
function RecordKey(type) {
|
|
119
|
+
const pattern = RecordPattern(type);
|
|
120
|
+
return (pattern === index_10.PatternStringExact ? (0, index_7.String)() :
|
|
121
|
+
pattern === index_10.PatternNumberExact ? (0, index_4.Number)() :
|
|
122
|
+
(0, index_7.String)({ pattern }));
|
|
123
|
+
}
|
|
124
|
+
/** Gets a Record Value Type */
|
|
125
|
+
// prettier-ignore
|
|
126
|
+
function RecordValue(type) {
|
|
127
|
+
return type.patternProperties[RecordPattern(type)];
|
|
98
128
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './remap';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./remap"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as t from '@sinclair/typebox';
|
|
2
|
+
export type TCallback = (schema: t.TSchema) => t.TSchema;
|
|
3
|
+
export interface TMapping {
|
|
4
|
+
input: unknown;
|
|
5
|
+
output: unknown;
|
|
6
|
+
}
|
|
7
|
+
type TApply<Type extends t.TSchema, Mapping extends TMapping, Mapped = (Mapping & {
|
|
8
|
+
input: Type;
|
|
9
|
+
})['output'], Result = Mapped extends t.TSchema ? Mapped : never> = Result;
|
|
10
|
+
type TFromProperties<Properties extends t.TProperties, Mapping extends TMapping, Result extends t.TProperties = {
|
|
11
|
+
[Key in keyof Properties]: TRemap<Properties[Key], Mapping>;
|
|
12
|
+
}> = Result;
|
|
13
|
+
type TFromTypes<Types extends t.TSchema[], Mapping extends TMapping, Result extends t.TSchema[] = []> = (Types extends [infer Left extends t.TSchema, ...infer Right extends t.TSchema[]] ? TFromTypes<Right, Mapping, [...Result, TRemap<Left, Mapping>]> : Result);
|
|
14
|
+
type TFromType<Type extends t.TSchema, Mapping extends TMapping, Result extends t.TSchema = (TApply<Type, Mapping>)> = Result;
|
|
15
|
+
/** `[Internal]` Applies a recursive conditional remapping of a type and its sub type constituents */
|
|
16
|
+
export type TRemap<Type extends t.TSchema, Mapping extends TMapping, Mapped extends t.TSchema = TFromType<Type, Mapping>, Result extends t.TSchema = (Mapped extends t.TConstructor<infer Parameters extends t.TSchema[], infer ReturnType extends t.TSchema> ? t.TConstructor<TFromTypes<Parameters, Mapping>, TFromType<ReturnType, Mapping>> : Mapped extends t.TFunction<infer Parameters extends t.TSchema[], infer ReturnType extends t.TSchema> ? t.TFunction<TFromTypes<Parameters, Mapping>, TFromType<ReturnType, Mapping>> : Mapped extends t.TIntersect<infer Types extends t.TSchema[]> ? t.TIntersect<TFromTypes<Types, Mapping>> : Mapped extends t.TUnion<infer Types extends t.TSchema[]> ? t.TUnion<TFromTypes<Types, Mapping>> : Mapped extends t.TTuple<infer Types extends t.TSchema[]> ? t.TTuple<TFromTypes<Types, Mapping>> : Mapped extends t.TArray<infer Type extends t.TSchema> ? t.TArray<TFromType<Type, Mapping>> : Mapped extends t.TAsyncIterator<infer Type extends t.TSchema> ? t.TAsyncIterator<TFromType<Type, Mapping>> : Mapped extends t.TIterator<infer Type extends t.TSchema> ? t.TIterator<TFromType<Type, Mapping>> : Mapped extends t.TPromise<infer Type extends t.TSchema> ? t.TPromise<TFromType<Type, Mapping>> : Mapped extends t.TObject<infer Properties extends t.TProperties> ? t.TObject<TFromProperties<Properties, Mapping>> : Mapped extends t.TRecord<infer Key extends t.TSchema, infer Value extends t.TSchema> ? t.TRecordOrObject<TFromType<Key, Mapping>, TFromType<Value, Mapping>> : Mapped)> = Result;
|
|
17
|
+
/** `[Internal]` Applies a recursive conditional remapping of a type and its sub type constituents */
|
|
18
|
+
export declare function Remap(type: t.TSchema, callback: TCallback): t.TSchema;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Remap = Remap;
|
|
5
|
+
const t = require("@sinclair/typebox");
|
|
6
|
+
function FromProperties(properties, func) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
|
|
8
|
+
return { ...result, [key]: Remap(properties[key], func) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromTypes(types, callback) {
|
|
12
|
+
return types.map((type) => Remap(type, callback));
|
|
13
|
+
}
|
|
14
|
+
function FromType(type, callback) {
|
|
15
|
+
return callback(type);
|
|
16
|
+
}
|
|
17
|
+
/** `[Internal]` Applies a recursive conditional remapping of a type and its sub type constituents */
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
function Remap(type, callback) {
|
|
20
|
+
// Map incoming type
|
|
21
|
+
const mapped = t.CloneType(FromType(type, callback));
|
|
22
|
+
// Return remapped interior
|
|
23
|
+
return (t.KindGuard.IsConstructor(type) ? t.Constructor(FromTypes(type.parameters, callback), FromType(type.returns, callback), mapped) :
|
|
24
|
+
t.KindGuard.IsFunction(type) ? t.Function(FromTypes(type.parameters, callback), FromType(type.returns, callback), mapped) :
|
|
25
|
+
t.KindGuard.IsIntersect(type) ? t.Intersect(FromTypes(type.allOf, callback), mapped) :
|
|
26
|
+
t.KindGuard.IsUnion(type) ? t.Union(FromTypes(type.anyOf, callback), mapped) :
|
|
27
|
+
t.KindGuard.IsTuple(type) ? t.Tuple(FromTypes(type.items || [], callback), mapped) :
|
|
28
|
+
t.KindGuard.IsArray(type) ? t.Array(FromType(type.items, callback), mapped) :
|
|
29
|
+
t.KindGuard.IsAsyncIterator(type) ? t.AsyncIterator(FromType(type.items, callback), mapped) :
|
|
30
|
+
t.KindGuard.IsIterator(type) ? t.Iterator(FromType(type.items, callback), mapped) :
|
|
31
|
+
t.KindGuard.IsPromise(type) ? t.Promise(FromType(type.items, callback), mapped) :
|
|
32
|
+
t.KindGuard.IsObject(type) ? t.Object(FromProperties(type.properties, callback), mapped) :
|
|
33
|
+
t.KindGuard.IsRecord(type) ? t.Record(FromType(t.RecordKey(type), callback), FromType(t.RecordValue(type), callback), mapped) :
|
|
34
|
+
t.CloneType(mapped));
|
|
35
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JsonTypeBuilder } from './json';
|
|
2
|
+
import { type TArgument } from '../argument/index';
|
|
2
3
|
import { type TAsyncIterator } from '../async-iterator/index';
|
|
3
4
|
import { type TAwaited } from '../awaited/index';
|
|
4
5
|
import { type TBigInt, type BigIntOptions } from '../bigint/index';
|
|
@@ -7,6 +8,7 @@ import { type TConstructorParameters } from '../constructor-parameters/index';
|
|
|
7
8
|
import { type TDate, type DateOptions } from '../date/index';
|
|
8
9
|
import { type TFunction } from '../function/index';
|
|
9
10
|
import { type TInstanceType } from '../instance-type/index';
|
|
11
|
+
import { type TInstantiate } from '../instantiate/index';
|
|
10
12
|
import { type TIterator } from '../iterator/index';
|
|
11
13
|
import { type TParameters } from '../parameters/index';
|
|
12
14
|
import { type TPromise } from '../promise/index';
|
|
@@ -19,6 +21,8 @@ import { type TUndefined } from '../undefined/index';
|
|
|
19
21
|
import { type TVoid } from '../void/index';
|
|
20
22
|
/** JavaScript Type Builder with Static Resolution for TypeScript */
|
|
21
23
|
export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
24
|
+
/** `[JavaScript]` Creates a Generic Argument Type */
|
|
25
|
+
Argument<Index extends number>(index: Index): TArgument<Index>;
|
|
22
26
|
/** `[JavaScript]` Creates a AsyncIterator type */
|
|
23
27
|
AsyncIterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TAsyncIterator<Type>;
|
|
24
28
|
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
|
|
@@ -35,6 +39,8 @@ export declare class JavaScriptTypeBuilder extends JsonTypeBuilder {
|
|
|
35
39
|
Function<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [...Parameters], returnType: ReturnType, options?: SchemaOptions): TFunction<Parameters, ReturnType>;
|
|
36
40
|
/** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
|
|
37
41
|
InstanceType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TInstanceType<Type>;
|
|
42
|
+
/** `[JavaScript]` Instantiates a type with the given parameters */
|
|
43
|
+
Instantiate<Type extends TSchema, Parameters extends TSchema[]>(schema: Type, parameters: [...Parameters]): TInstantiate<Type, Parameters>;
|
|
38
44
|
/** `[JavaScript]` Creates an Iterator type */
|
|
39
45
|
Iterator<Type extends TSchema>(items: Type, options?: SchemaOptions): TIterator<Type>;
|
|
40
46
|
/** `[JavaScript]` Extracts the Parameters from the given Function type */
|
|
@@ -3,92 +3,102 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.JavaScriptTypeBuilder = void 0;
|
|
5
5
|
const json_1 = require("./json");
|
|
6
|
-
const index_1 = require("../
|
|
7
|
-
const index_2 = require("../
|
|
8
|
-
const index_3 = require("../
|
|
9
|
-
const index_4 = require("../
|
|
10
|
-
const index_5 = require("../constructor
|
|
11
|
-
const index_6 = require("../
|
|
12
|
-
const index_7 = require("../
|
|
13
|
-
const index_8 = require("../
|
|
14
|
-
const index_9 = require("../
|
|
15
|
-
const index_10 = require("../
|
|
16
|
-
const index_11 = require("../
|
|
17
|
-
const index_12 = require("../
|
|
18
|
-
const index_13 = require("../
|
|
19
|
-
const index_14 = require("../
|
|
20
|
-
const index_15 = require("../
|
|
21
|
-
const index_16 = require("../
|
|
22
|
-
const index_17 = require("../
|
|
6
|
+
const index_1 = require("../argument/index");
|
|
7
|
+
const index_2 = require("../async-iterator/index");
|
|
8
|
+
const index_3 = require("../awaited/index");
|
|
9
|
+
const index_4 = require("../bigint/index");
|
|
10
|
+
const index_5 = require("../constructor/index");
|
|
11
|
+
const index_6 = require("../constructor-parameters/index");
|
|
12
|
+
const index_7 = require("../date/index");
|
|
13
|
+
const index_8 = require("../function/index");
|
|
14
|
+
const index_9 = require("../instance-type/index");
|
|
15
|
+
const index_10 = require("../instantiate/index");
|
|
16
|
+
const index_11 = require("../iterator/index");
|
|
17
|
+
const index_12 = require("../parameters/index");
|
|
18
|
+
const index_13 = require("../promise/index");
|
|
19
|
+
const index_14 = require("../regexp/index");
|
|
20
|
+
const index_15 = require("../return-type/index");
|
|
21
|
+
const index_16 = require("../symbol/index");
|
|
22
|
+
const index_17 = require("../uint8array/index");
|
|
23
|
+
const index_18 = require("../undefined/index");
|
|
24
|
+
const index_19 = require("../void/index");
|
|
23
25
|
/** JavaScript Type Builder with Static Resolution for TypeScript */
|
|
24
26
|
class JavaScriptTypeBuilder extends json_1.JsonTypeBuilder {
|
|
27
|
+
/** `[JavaScript]` Creates a Generic Argument Type */
|
|
28
|
+
Argument(index) {
|
|
29
|
+
return (0, index_1.Argument)(index);
|
|
30
|
+
}
|
|
25
31
|
/** `[JavaScript]` Creates a AsyncIterator type */
|
|
26
32
|
AsyncIterator(items, options) {
|
|
27
|
-
return (0,
|
|
33
|
+
return (0, index_2.AsyncIterator)(items, options);
|
|
28
34
|
}
|
|
29
35
|
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
|
|
30
36
|
Awaited(schema, options) {
|
|
31
|
-
return (0,
|
|
37
|
+
return (0, index_3.Awaited)(schema, options);
|
|
32
38
|
}
|
|
33
39
|
/** `[JavaScript]` Creates a BigInt type */
|
|
34
40
|
BigInt(options) {
|
|
35
|
-
return (0,
|
|
41
|
+
return (0, index_4.BigInt)(options);
|
|
36
42
|
}
|
|
37
43
|
/** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
|
|
38
44
|
ConstructorParameters(schema, options) {
|
|
39
|
-
return (0,
|
|
45
|
+
return (0, index_6.ConstructorParameters)(schema, options);
|
|
40
46
|
}
|
|
41
47
|
/** `[JavaScript]` Creates a Constructor type */
|
|
42
48
|
Constructor(parameters, instanceType, options) {
|
|
43
|
-
return (0,
|
|
49
|
+
return (0, index_5.Constructor)(parameters, instanceType, options);
|
|
44
50
|
}
|
|
45
51
|
/** `[JavaScript]` Creates a Date type */
|
|
46
52
|
Date(options = {}) {
|
|
47
|
-
return (0,
|
|
53
|
+
return (0, index_7.Date)(options);
|
|
48
54
|
}
|
|
49
55
|
/** `[JavaScript]` Creates a Function type */
|
|
50
56
|
Function(parameters, returnType, options) {
|
|
51
|
-
return (0,
|
|
57
|
+
return (0, index_8.Function)(parameters, returnType, options);
|
|
52
58
|
}
|
|
53
59
|
/** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
|
|
54
60
|
InstanceType(schema, options) {
|
|
55
|
-
return (0,
|
|
61
|
+
return (0, index_9.InstanceType)(schema, options);
|
|
62
|
+
}
|
|
63
|
+
/** `[JavaScript]` Instantiates a type with the given parameters */
|
|
64
|
+
Instantiate(schema, parameters) {
|
|
65
|
+
return (0, index_10.Instantiate)(schema, parameters);
|
|
56
66
|
}
|
|
57
67
|
/** `[JavaScript]` Creates an Iterator type */
|
|
58
68
|
Iterator(items, options) {
|
|
59
|
-
return (0,
|
|
69
|
+
return (0, index_11.Iterator)(items, options);
|
|
60
70
|
}
|
|
61
71
|
/** `[JavaScript]` Extracts the Parameters from the given Function type */
|
|
62
72
|
Parameters(schema, options) {
|
|
63
|
-
return (0,
|
|
73
|
+
return (0, index_12.Parameters)(schema, options);
|
|
64
74
|
}
|
|
65
75
|
/** `[JavaScript]` Creates a Promise type */
|
|
66
76
|
Promise(item, options) {
|
|
67
|
-
return (0,
|
|
77
|
+
return (0, index_13.Promise)(item, options);
|
|
68
78
|
}
|
|
69
79
|
/** `[JavaScript]` Creates a RegExp type */
|
|
70
80
|
RegExp(unresolved, options) {
|
|
71
|
-
return (0,
|
|
81
|
+
return (0, index_14.RegExp)(unresolved, options);
|
|
72
82
|
}
|
|
73
83
|
/** `[JavaScript]` Extracts the ReturnType from the given Function type */
|
|
74
84
|
ReturnType(type, options) {
|
|
75
|
-
return (0,
|
|
85
|
+
return (0, index_15.ReturnType)(type, options);
|
|
76
86
|
}
|
|
77
87
|
/** `[JavaScript]` Creates a Symbol type */
|
|
78
88
|
Symbol(options) {
|
|
79
|
-
return (0,
|
|
89
|
+
return (0, index_16.Symbol)(options);
|
|
80
90
|
}
|
|
81
91
|
/** `[JavaScript]` Creates a Undefined type */
|
|
82
92
|
Undefined(options) {
|
|
83
|
-
return (0,
|
|
93
|
+
return (0, index_18.Undefined)(options);
|
|
84
94
|
}
|
|
85
95
|
/** `[JavaScript]` Creates a Uint8Array type */
|
|
86
96
|
Uint8Array(options) {
|
|
87
|
-
return (0,
|
|
97
|
+
return (0, index_17.Uint8Array)(options);
|
|
88
98
|
}
|
|
89
99
|
/** `[JavaScript]` Creates a Void type */
|
|
90
100
|
Void(options) {
|
|
91
|
-
return (0,
|
|
101
|
+
return (0, index_19.Void)(options);
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
exports.JavaScriptTypeBuilder = JavaScriptTypeBuilder;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Any } from '../any/index';
|
|
2
|
+
export { Argument } from '../argument/index';
|
|
2
3
|
export { Array } from '../array/index';
|
|
3
4
|
export { AsyncIterator } from '../async-iterator/index';
|
|
4
5
|
export { Awaited } from '../awaited/index';
|
|
@@ -16,6 +17,7 @@ export { Extract } from '../extract/index';
|
|
|
16
17
|
export { Function } from '../function/index';
|
|
17
18
|
export { Index } from '../indexed/index';
|
|
18
19
|
export { InstanceType } from '../instance-type/index';
|
|
20
|
+
export { Instantiate } from '../instantiate/index';
|
|
19
21
|
export { Integer } from '../integer/index';
|
|
20
22
|
export { Intersect } from '../intersect/index';
|
|
21
23
|
export { Capitalize, Uncapitalize, Lowercase, Uppercase } from '../intrinsic/index';
|
|
@@ -41,6 +43,7 @@ export { Record } from '../record/index';
|
|
|
41
43
|
export { Recursive } from '../recursive/index';
|
|
42
44
|
export { Ref } from '../ref/index';
|
|
43
45
|
export { RegExp } from '../regexp/index';
|
|
46
|
+
export { Remap } from '../remap/index';
|
|
44
47
|
export { Required } from '../required/index';
|
|
45
48
|
export { Rest } from '../rest/index';
|
|
46
49
|
export { ReturnType } from '../return-type/index';
|