@sinclair/typebox 0.32.0-dev-20 → 0.32.0-dev-22
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 +62 -62
- package/build/import/errors/errors.mjs +62 -62
- package/build/import/index.d.mts +6 -6
- package/build/import/index.mjs +1 -1
- package/build/import/type/awaited/awaited.d.mts +4 -6
- package/build/import/type/awaited/awaited.mjs +3 -3
- package/build/import/type/composite/composite.d.mts +8 -8
- package/build/import/type/const/const.d.mts +4 -7
- package/build/import/type/constructor/constructor.d.mts +4 -4
- package/build/import/type/deref/deref.d.mts +2 -2
- package/build/import/type/deref/deref.mjs +26 -36
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
- package/build/import/type/exclude/exclude.d.mts +7 -8
- package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
- package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
- package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
- package/build/import/type/extends/extends.d.mts +2 -3
- package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
- package/build/import/type/extract/extract.d.mts +8 -8
- package/build/import/type/function/function.d.mts +1 -1
- package/build/import/type/helpers/helpers.d.mts +1 -1
- package/build/import/type/index.d.mts +0 -1
- package/build/import/type/index.mjs +0 -1
- package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
- package/build/import/type/indexed/indexed-property-keys.d.mts +5 -8
- package/build/import/type/indexed/indexed-property-keys.mjs +6 -11
- package/build/import/type/indexed/indexed.d.mts +13 -23
- package/build/import/type/indexed/indexed.mjs +13 -13
- package/build/import/type/intersect/intersect-create.mjs +0 -1
- package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
- package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
- package/build/import/type/intersect/intersect-type.d.mts +2 -2
- package/build/import/type/intersect/intersect.mjs +1 -2
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
- package/build/import/type/intrinsic/intrinsic.mjs +8 -6
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
- package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
- package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
- package/build/import/type/keyof/keyof.d.mts +7 -8
- package/build/import/type/keyof/keyof.mjs +8 -6
- package/build/import/type/mapped/mapped.d.mts +9 -13
- package/build/import/type/mapped/mapped.mjs +9 -9
- package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
- package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
- package/build/import/type/omit/omit.d.mts +6 -9
- package/build/import/type/omit/omit.mjs +0 -1
- package/build/import/type/operators/operators.d.mts +16 -16
- package/build/import/type/operators/operators.mjs +21 -25
- package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
- package/build/import/type/optional/optional.d.mts +3 -7
- package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
- package/build/import/type/partial/partial.d.mts +4 -7
- package/build/import/type/partial/partial.mjs +6 -7
- package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
- package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
- package/build/import/type/pick/pick.d.mts +4 -4
- package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
- package/build/import/type/readonly/readonly.d.mts +3 -7
- package/build/import/type/record/record.d.mts +14 -20
- package/build/import/type/record/record.mjs +2 -4
- package/build/import/type/ref/ref.mjs +3 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
- package/build/import/type/required/required.d.mts +5 -9
- package/build/import/type/required/required.mjs +6 -7
- package/build/import/type/rest/rest.d.mts +3 -3
- package/build/import/type/schema/schema.d.mts +1 -1
- package/build/import/type/static/static.d.mts +1 -1
- package/build/import/type/symbol/symbol.d.mts +1 -1
- package/build/import/type/template-literal/finite.d.mts +7 -5
- package/build/import/type/template-literal/finite.mjs +14 -5
- package/build/import/type/template-literal/generate.d.mts +14 -9
- package/build/import/type/template-literal/generate.mjs +19 -9
- package/build/import/type/template-literal/index.d.mts +1 -1
- package/build/import/type/template-literal/index.mjs +1 -1
- package/build/import/type/template-literal/{parser.mjs → parse.mjs} +7 -2
- package/build/import/type/template-literal/syntax.d.mts +3 -3
- package/build/import/type/template-literal/syntax.mjs +2 -3
- package/build/import/type/template-literal/template-literal.d.mts +2 -2
- package/build/import/type/template-literal/template-literal.mjs +1 -1
- package/build/import/type/template-literal/union.d.mts +2 -2
- package/build/import/type/template-literal/union.mjs +5 -10
- package/build/import/type/transform/transform.mjs +0 -1
- package/build/import/type/tuple/tuple.d.mts +1 -2
- package/build/import/type/type/json.d.mts +2 -2
- package/build/import/type/union/union-evaluated.d.mts +6 -10
- package/build/import/type/union/union-evaluated.mjs +7 -2
- package/build/import/value/cast/cast.mjs +20 -20
- package/build/import/value/check/check.mjs +62 -62
- package/build/import/value/clean/clean.mjs +16 -16
- package/build/import/value/convert/convert.mjs +36 -36
- package/build/import/value/create/create.mjs +66 -67
- package/build/import/value/default/default.mjs +16 -16
- package/build/import/value/transform/decode.mjs +18 -18
- package/build/import/value/transform/encode.mjs +18 -18
- package/build/import/value/transform/has.mjs +28 -28
- package/build/require/compiler/compiler.js +62 -62
- package/build/require/errors/errors.js +62 -62
- package/build/require/index.d.ts +6 -6
- package/build/require/index.js +4 -2
- package/build/require/type/awaited/awaited.d.ts +4 -6
- package/build/require/type/awaited/awaited.js +3 -3
- package/build/require/type/composite/composite.d.ts +8 -8
- package/build/require/type/const/const.d.ts +4 -7
- package/build/require/type/constructor/constructor.d.ts +4 -4
- package/build/require/type/deref/deref.d.ts +2 -2
- package/build/require/type/deref/deref.js +25 -35
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
- package/build/require/type/exclude/exclude.d.ts +7 -8
- package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
- package/build/require/type/extends/extends-from-mapped-key.js +3 -3
- package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
- package/build/require/type/extends/extends.d.ts +2 -3
- package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
- package/build/require/type/extract/extract.d.ts +8 -8
- package/build/require/type/function/function.d.ts +1 -1
- package/build/require/type/helpers/helpers.d.ts +1 -1
- package/build/require/type/index.d.ts +0 -1
- package/build/require/type/index.js +0 -1
- package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
- package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
- package/build/require/type/indexed/indexed-property-keys.d.ts +5 -8
- package/build/require/type/indexed/indexed-property-keys.js +4 -9
- package/build/require/type/indexed/indexed.d.ts +13 -23
- package/build/require/type/indexed/indexed.js +13 -13
- package/build/require/type/intersect/intersect-create.js +0 -1
- package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
- package/build/require/type/intersect/intersect-evaluated.js +9 -4
- package/build/require/type/intersect/intersect-type.d.ts +2 -2
- package/build/require/type/intersect/intersect.js +0 -1
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
- package/build/require/type/intrinsic/intrinsic.js +7 -5
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
- package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
- package/build/require/type/keyof/keyof-property-keys.js +12 -9
- package/build/require/type/keyof/keyof.d.ts +7 -8
- package/build/require/type/keyof/keyof.js +8 -6
- package/build/require/type/mapped/mapped.d.ts +9 -13
- package/build/require/type/mapped/mapped.js +9 -9
- package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
- package/build/require/type/omit/omit-from-mapped-key.js +3 -3
- package/build/require/type/omit/omit.d.ts +6 -9
- package/build/require/type/omit/omit.js +0 -1
- package/build/require/type/operators/operators.d.ts +16 -16
- package/build/require/type/operators/operators.js +21 -25
- package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
- package/build/require/type/optional/optional.d.ts +3 -7
- package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
- package/build/require/type/partial/partial.d.ts +4 -7
- package/build/require/type/partial/partial.js +6 -7
- package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
- package/build/require/type/pick/pick-from-mapped-key.js +3 -3
- package/build/require/type/pick/pick.d.ts +4 -4
- package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
- package/build/require/type/readonly/readonly.d.ts +3 -7
- package/build/require/type/record/record.d.ts +14 -20
- package/build/require/type/record/record.js +1 -3
- package/build/require/type/ref/ref.js +3 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
- package/build/require/type/required/required.d.ts +5 -9
- package/build/require/type/required/required.js +6 -7
- package/build/require/type/rest/rest.d.ts +3 -3
- package/build/require/type/schema/schema.d.ts +1 -1
- package/build/require/type/static/static.d.ts +1 -1
- package/build/require/type/symbol/symbol.d.ts +1 -1
- package/build/require/type/template-literal/finite.d.ts +7 -5
- package/build/require/type/template-literal/finite.js +16 -6
- package/build/require/type/template-literal/generate.d.ts +14 -9
- package/build/require/type/template-literal/generate.js +22 -11
- package/build/require/type/template-literal/index.d.ts +1 -1
- package/build/require/type/template-literal/index.js +1 -1
- package/build/require/type/template-literal/{parser.js → parse.js} +7 -2
- package/build/require/type/template-literal/syntax.d.ts +3 -3
- package/build/require/type/template-literal/syntax.js +1 -2
- package/build/require/type/template-literal/template-literal.d.ts +2 -2
- package/build/require/type/template-literal/template-literal.js +1 -1
- package/build/require/type/template-literal/union.d.ts +2 -2
- package/build/require/type/template-literal/union.js +5 -10
- package/build/require/type/transform/transform.js +0 -1
- package/build/require/type/tuple/tuple.d.ts +1 -2
- package/build/require/type/type/json.d.ts +2 -2
- package/build/require/type/union/union-evaluated.d.ts +6 -10
- package/build/require/type/union/union-evaluated.js +7 -2
- package/build/require/value/cast/cast.js +20 -20
- package/build/require/value/check/check.js +62 -62
- package/build/require/value/clean/clean.js +16 -16
- package/build/require/value/convert/convert.js +36 -36
- package/build/require/value/create/create.js +65 -66
- package/build/require/value/default/default.js +16 -16
- package/build/require/value/transform/decode.js +18 -18
- package/build/require/value/transform/encode.js +18 -18
- package/build/require/value/transform/has.js +28 -28
- package/package.json +1 -1
- package/readme.md +47 -47
- package/build/import/type/modifiers/index.d.mts +0 -1
- package/build/import/type/modifiers/index.mjs +0 -1
- package/build/import/type/modifiers/modifiers.d.mts +0 -18
- package/build/import/type/modifiers/modifiers.mjs +0 -50
- package/build/require/type/modifiers/index.d.ts +0 -1
- package/build/require/type/modifiers/index.js +0 -18
- package/build/require/type/modifiers/modifiers.d.ts +0 -18
- package/build/require/type/modifiers/modifiers.js +0 -56
- /package/build/import/type/template-literal/{parser.d.mts → parse.d.mts} +0 -0
- /package/build/require/type/template-literal/{parser.d.ts → parse.d.ts} +0 -0
|
@@ -133,8 +133,8 @@ function Create(type, schema, path, value) {
|
|
|
133
133
|
// --------------------------------------------------------------------------
|
|
134
134
|
// Types
|
|
135
135
|
// --------------------------------------------------------------------------
|
|
136
|
-
function*
|
|
137
|
-
function*
|
|
136
|
+
function* FromAny(schema, references, path, value) { }
|
|
137
|
+
function* FromArray(schema, references, path, value) {
|
|
138
138
|
if (!(0, index_8.IsArray)(value)) {
|
|
139
139
|
return yield Create(ValueErrorType.Array, schema, path, value);
|
|
140
140
|
}
|
|
@@ -175,11 +175,11 @@ function* TArray(schema, references, path, value) {
|
|
|
175
175
|
yield Create(ValueErrorType.ArrayMaxContains, schema, path, value);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
function*
|
|
178
|
+
function* FromAsyncIterator(schema, references, path, value) {
|
|
179
179
|
if (!(0, index_8.IsAsyncIterator)(value))
|
|
180
180
|
yield Create(ValueErrorType.AsyncIterator, schema, path, value);
|
|
181
181
|
}
|
|
182
|
-
function*
|
|
182
|
+
function* FromBigInt(schema, references, path, value) {
|
|
183
183
|
if (!(0, index_8.IsBigInt)(value))
|
|
184
184
|
return yield Create(ValueErrorType.BigInt, schema, path, value);
|
|
185
185
|
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
@@ -198,14 +198,14 @@ function* TBigInt(schema, references, path, value) {
|
|
|
198
198
|
yield Create(ValueErrorType.BigIntMultipleOf, schema, path, value);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function*
|
|
201
|
+
function* FromBoolean(schema, references, path, value) {
|
|
202
202
|
if (!(0, index_8.IsBoolean)(value))
|
|
203
203
|
yield Create(ValueErrorType.Boolean, schema, path, value);
|
|
204
204
|
}
|
|
205
|
-
function*
|
|
205
|
+
function* FromConstructor(schema, references, path, value) {
|
|
206
206
|
yield* Visit(schema.returns, references, path, value.prototype);
|
|
207
207
|
}
|
|
208
|
-
function*
|
|
208
|
+
function* FromDate(schema, references, path, value) {
|
|
209
209
|
if (!(0, index_8.IsDate)(value))
|
|
210
210
|
return yield Create(ValueErrorType.Date, schema, path, value);
|
|
211
211
|
if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
@@ -224,11 +224,11 @@ function* TDate(schema, references, path, value) {
|
|
|
224
224
|
yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path, value);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function*
|
|
227
|
+
function* FromFunction(schema, references, path, value) {
|
|
228
228
|
if (!(0, index_8.IsFunction)(value))
|
|
229
229
|
yield Create(ValueErrorType.Function, schema, path, value);
|
|
230
230
|
}
|
|
231
|
-
function*
|
|
231
|
+
function* FromInteger(schema, references, path, value) {
|
|
232
232
|
if (!(0, index_8.IsInteger)(value))
|
|
233
233
|
return yield Create(ValueErrorType.Integer, schema, path, value);
|
|
234
234
|
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
@@ -247,7 +247,7 @@ function* TInteger(schema, references, path, value) {
|
|
|
247
247
|
yield Create(ValueErrorType.IntegerMultipleOf, schema, path, value);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
function*
|
|
250
|
+
function* FromIntersect(schema, references, path, value) {
|
|
251
251
|
for (const inner of schema.allOf) {
|
|
252
252
|
const next = Visit(inner, references, path, value).next();
|
|
253
253
|
if (!next.done) {
|
|
@@ -274,26 +274,26 @@ function* TIntersect(schema, references, path, value) {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
function*
|
|
277
|
+
function* FromIterator(schema, references, path, value) {
|
|
278
278
|
if (!(0, index_8.IsIterator)(value))
|
|
279
279
|
yield Create(ValueErrorType.Iterator, schema, path, value);
|
|
280
280
|
}
|
|
281
|
-
function*
|
|
281
|
+
function* FromLiteral(schema, references, path, value) {
|
|
282
282
|
if (!(value === schema.const))
|
|
283
283
|
yield Create(ValueErrorType.Literal, schema, path, value);
|
|
284
284
|
}
|
|
285
|
-
function*
|
|
285
|
+
function* FromNever(schema, references, path, value) {
|
|
286
286
|
yield Create(ValueErrorType.Never, schema, path, value);
|
|
287
287
|
}
|
|
288
|
-
function*
|
|
288
|
+
function* FromNot(schema, references, path, value) {
|
|
289
289
|
if (Visit(schema.not, references, path, value).next().done === true)
|
|
290
290
|
yield Create(ValueErrorType.Not, schema, path, value);
|
|
291
291
|
}
|
|
292
|
-
function*
|
|
292
|
+
function* FromNull(schema, references, path, value) {
|
|
293
293
|
if (!(0, index_8.IsNull)(value))
|
|
294
294
|
yield Create(ValueErrorType.Null, schema, path, value);
|
|
295
295
|
}
|
|
296
|
-
function*
|
|
296
|
+
function* FromNumber(schema, references, path, value) {
|
|
297
297
|
if (!index_1.TypeSystemPolicy.IsNumberLike(value))
|
|
298
298
|
return yield Create(ValueErrorType.Number, schema, path, value);
|
|
299
299
|
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
@@ -312,7 +312,7 @@ function* TNumber(schema, references, path, value) {
|
|
|
312
312
|
yield Create(ValueErrorType.NumberMultipleOf, schema, path, value);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
function*
|
|
315
|
+
function* FromObject(schema, references, path, value) {
|
|
316
316
|
if (!index_1.TypeSystemPolicy.IsObjectLike(value))
|
|
317
317
|
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
318
318
|
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
@@ -358,11 +358,11 @@ function* TObject(schema, references, path, value) {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
function*
|
|
361
|
+
function* FromPromise(schema, references, path, value) {
|
|
362
362
|
if (!(0, index_8.IsPromise)(value))
|
|
363
363
|
yield Create(ValueErrorType.Promise, schema, path, value);
|
|
364
364
|
}
|
|
365
|
-
function*
|
|
365
|
+
function* FromRecord(schema, references, path, value) {
|
|
366
366
|
if (!index_1.TypeSystemPolicy.IsRecordLike(value))
|
|
367
367
|
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
368
368
|
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
@@ -391,10 +391,10 @@ function* TRecord(schema, references, path, value) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
function*
|
|
394
|
+
function* FromRef(schema, references, path, value) {
|
|
395
395
|
yield* Visit((0, index_4.Deref)(schema, references), references, path, value);
|
|
396
396
|
}
|
|
397
|
-
function*
|
|
397
|
+
function* FromString(schema, references, path, value) {
|
|
398
398
|
if (!(0, index_8.IsString)(value))
|
|
399
399
|
return yield Create(ValueErrorType.String, schema, path, value);
|
|
400
400
|
if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
@@ -421,11 +421,11 @@ function* TString(schema, references, path, value) {
|
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
function*
|
|
424
|
+
function* FromSymbol(schema, references, path, value) {
|
|
425
425
|
if (!(0, index_8.IsSymbol)(value))
|
|
426
426
|
yield Create(ValueErrorType.Symbol, schema, path, value);
|
|
427
427
|
}
|
|
428
|
-
function*
|
|
428
|
+
function* FromTemplateLiteral(schema, references, path, value) {
|
|
429
429
|
if (!(0, index_8.IsString)(value))
|
|
430
430
|
return yield Create(ValueErrorType.String, schema, path, value);
|
|
431
431
|
const regex = new RegExp(schema.pattern);
|
|
@@ -433,10 +433,10 @@ function* TTemplateLiteral(schema, references, path, value) {
|
|
|
433
433
|
yield Create(ValueErrorType.StringPattern, schema, path, value);
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
|
-
function*
|
|
436
|
+
function* FromThis(schema, references, path, value) {
|
|
437
437
|
yield* Visit((0, index_4.Deref)(schema, references), references, path, value);
|
|
438
438
|
}
|
|
439
|
-
function*
|
|
439
|
+
function* FromTuple(schema, references, path, value) {
|
|
440
440
|
if (!(0, index_8.IsArray)(value))
|
|
441
441
|
return yield Create(ValueErrorType.Tuple, schema, path, value);
|
|
442
442
|
if (schema.items === undefined && !(value.length === 0)) {
|
|
@@ -452,11 +452,11 @@ function* TTuple(schema, references, path, value) {
|
|
|
452
452
|
yield* Visit(schema.items[i], references, `${path}/${i}`, value[i]);
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
function*
|
|
455
|
+
function* FromUndefined(schema, references, path, value) {
|
|
456
456
|
if (!(0, index_8.IsUndefined)(value))
|
|
457
457
|
yield Create(ValueErrorType.Undefined, schema, path, value);
|
|
458
458
|
}
|
|
459
|
-
function*
|
|
459
|
+
function* FromUnion(schema, references, path, value) {
|
|
460
460
|
let count = 0;
|
|
461
461
|
for (const subschema of schema.anyOf) {
|
|
462
462
|
const errors = [...Visit(subschema, references, path, value)];
|
|
@@ -468,7 +468,7 @@ function* TUnion(schema, references, path, value) {
|
|
|
468
468
|
yield Create(ValueErrorType.Union, schema, path, value);
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
function*
|
|
471
|
+
function* FromUint8Array(schema, references, path, value) {
|
|
472
472
|
if (!(0, index_8.IsUint8Array)(value))
|
|
473
473
|
return yield Create(ValueErrorType.Uint8Array, schema, path, value);
|
|
474
474
|
if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
@@ -478,12 +478,12 @@ function* TUint8Array(schema, references, path, value) {
|
|
|
478
478
|
yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path, value);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
function*
|
|
482
|
-
function*
|
|
481
|
+
function* FromUnknown(schema, references, path, value) { }
|
|
482
|
+
function* FromVoid(schema, references, path, value) {
|
|
483
483
|
if (!index_1.TypeSystemPolicy.IsVoidLike(value))
|
|
484
484
|
yield Create(ValueErrorType.Void, schema, path, value);
|
|
485
485
|
}
|
|
486
|
-
function*
|
|
486
|
+
function* FromKind(schema, references, path, value) {
|
|
487
487
|
const check = index_3.TypeRegistry.Get(schema[index_6.Kind]);
|
|
488
488
|
if (!check(schema, value))
|
|
489
489
|
yield Create(ValueErrorType.Kind, schema, path, value);
|
|
@@ -493,69 +493,69 @@ function* Visit(schema, references, path, value) {
|
|
|
493
493
|
const schema_ = schema;
|
|
494
494
|
switch (schema_[index_6.Kind]) {
|
|
495
495
|
case 'Any':
|
|
496
|
-
return yield*
|
|
496
|
+
return yield* FromAny(schema_, references_, path, value);
|
|
497
497
|
case 'Array':
|
|
498
|
-
return yield*
|
|
498
|
+
return yield* FromArray(schema_, references_, path, value);
|
|
499
499
|
case 'AsyncIterator':
|
|
500
|
-
return yield*
|
|
500
|
+
return yield* FromAsyncIterator(schema_, references_, path, value);
|
|
501
501
|
case 'BigInt':
|
|
502
|
-
return yield*
|
|
502
|
+
return yield* FromBigInt(schema_, references_, path, value);
|
|
503
503
|
case 'Boolean':
|
|
504
|
-
return yield*
|
|
504
|
+
return yield* FromBoolean(schema_, references_, path, value);
|
|
505
505
|
case 'Constructor':
|
|
506
|
-
return yield*
|
|
506
|
+
return yield* FromConstructor(schema_, references_, path, value);
|
|
507
507
|
case 'Date':
|
|
508
|
-
return yield*
|
|
508
|
+
return yield* FromDate(schema_, references_, path, value);
|
|
509
509
|
case 'Function':
|
|
510
|
-
return yield*
|
|
510
|
+
return yield* FromFunction(schema_, references_, path, value);
|
|
511
511
|
case 'Integer':
|
|
512
|
-
return yield*
|
|
512
|
+
return yield* FromInteger(schema_, references_, path, value);
|
|
513
513
|
case 'Intersect':
|
|
514
|
-
return yield*
|
|
514
|
+
return yield* FromIntersect(schema_, references_, path, value);
|
|
515
515
|
case 'Iterator':
|
|
516
|
-
return yield*
|
|
516
|
+
return yield* FromIterator(schema_, references_, path, value);
|
|
517
517
|
case 'Literal':
|
|
518
|
-
return yield*
|
|
518
|
+
return yield* FromLiteral(schema_, references_, path, value);
|
|
519
519
|
case 'Never':
|
|
520
|
-
return yield*
|
|
520
|
+
return yield* FromNever(schema_, references_, path, value);
|
|
521
521
|
case 'Not':
|
|
522
|
-
return yield*
|
|
522
|
+
return yield* FromNot(schema_, references_, path, value);
|
|
523
523
|
case 'Null':
|
|
524
|
-
return yield*
|
|
524
|
+
return yield* FromNull(schema_, references_, path, value);
|
|
525
525
|
case 'Number':
|
|
526
|
-
return yield*
|
|
526
|
+
return yield* FromNumber(schema_, references_, path, value);
|
|
527
527
|
case 'Object':
|
|
528
|
-
return yield*
|
|
528
|
+
return yield* FromObject(schema_, references_, path, value);
|
|
529
529
|
case 'Promise':
|
|
530
|
-
return yield*
|
|
530
|
+
return yield* FromPromise(schema_, references_, path, value);
|
|
531
531
|
case 'Record':
|
|
532
|
-
return yield*
|
|
532
|
+
return yield* FromRecord(schema_, references_, path, value);
|
|
533
533
|
case 'Ref':
|
|
534
|
-
return yield*
|
|
534
|
+
return yield* FromRef(schema_, references_, path, value);
|
|
535
535
|
case 'String':
|
|
536
|
-
return yield*
|
|
536
|
+
return yield* FromString(schema_, references_, path, value);
|
|
537
537
|
case 'Symbol':
|
|
538
|
-
return yield*
|
|
538
|
+
return yield* FromSymbol(schema_, references_, path, value);
|
|
539
539
|
case 'TemplateLiteral':
|
|
540
|
-
return yield*
|
|
540
|
+
return yield* FromTemplateLiteral(schema_, references_, path, value);
|
|
541
541
|
case 'This':
|
|
542
|
-
return yield*
|
|
542
|
+
return yield* FromThis(schema_, references_, path, value);
|
|
543
543
|
case 'Tuple':
|
|
544
|
-
return yield*
|
|
544
|
+
return yield* FromTuple(schema_, references_, path, value);
|
|
545
545
|
case 'Undefined':
|
|
546
|
-
return yield*
|
|
546
|
+
return yield* FromUndefined(schema_, references_, path, value);
|
|
547
547
|
case 'Union':
|
|
548
|
-
return yield*
|
|
548
|
+
return yield* FromUnion(schema_, references_, path, value);
|
|
549
549
|
case 'Uint8Array':
|
|
550
|
-
return yield*
|
|
550
|
+
return yield* FromUint8Array(schema_, references_, path, value);
|
|
551
551
|
case 'Unknown':
|
|
552
|
-
return yield*
|
|
552
|
+
return yield* FromUnknown(schema_, references_, path, value);
|
|
553
553
|
case 'Void':
|
|
554
|
-
return yield*
|
|
554
|
+
return yield* FromVoid(schema_, references_, path, value);
|
|
555
555
|
default:
|
|
556
556
|
if (!index_3.TypeRegistry.Has(schema_[index_6.Kind]))
|
|
557
557
|
throw new ValueErrorsUnknownTypeError(schema);
|
|
558
|
-
return yield*
|
|
558
|
+
return yield* FromKind(schema_, references_, path, value);
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
/** Returns an iterator for each error in this value. */
|
package/build/require/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { Any, type TAny } from './type/any/index';
|
|
|
7
7
|
export { Array, type TArray, type ArrayOptions } from './type/array/index';
|
|
8
8
|
export { AsyncIterator, type TAsyncIterator } from './type/async-iterator/index';
|
|
9
9
|
export { Awaited, type TAwaited } from './type/awaited/index';
|
|
10
|
-
export { BigInt, type TBigInt, BigIntOptions } from './type/bigint/index';
|
|
10
|
+
export { BigInt, type TBigInt, type BigIntOptions } from './type/bigint/index';
|
|
11
11
|
export { Boolean, type TBoolean } from './type/boolean/index';
|
|
12
12
|
export { Composite, type TComposite } from './type/composite/index';
|
|
13
13
|
export { Const, type TConst } from './type/const/index';
|
|
@@ -24,7 +24,7 @@ export { Increment, type Assert, type AssertType, type AssertRest, type AssertPr
|
|
|
24
24
|
export { Index, IndexPropertyKeys, IndexFromMappedKey, type TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey } from './type/indexed/index';
|
|
25
25
|
export { InstanceType, type TInstanceType } from './type/instance-type/index';
|
|
26
26
|
export { Integer, type TInteger, type IntegerOptions } from './type/integer/index';
|
|
27
|
-
export { Intersect, IntersectEvaluated, type TIntersect, type IntersectOptions } from './type/intersect/index';
|
|
27
|
+
export { Intersect, IntersectEvaluated, type TIntersect, type TIntersectEvaluated, type IntersectOptions } from './type/intersect/index';
|
|
28
28
|
export { Iterator, type TIterator } from './type/iterator/index';
|
|
29
29
|
export { Intrinsic, IntrinsicFromMappedKey, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index';
|
|
30
30
|
export { KeyOf, type TKeyOf, type KeyOfFromMappedResult, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index';
|
|
@@ -54,13 +54,13 @@ export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from '.
|
|
|
54
54
|
export { type Static, type StaticDecode, type StaticEncode } from './type/static/index';
|
|
55
55
|
export { Strict } from './type/strict/index';
|
|
56
56
|
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index';
|
|
57
|
-
export { Symbol, type TSymbol, type SymbolValue } from './type/symbol/index';
|
|
58
|
-
export { TemplateLiteral, IsTemplateLiteralFinite, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralGenerate, type TTemplateLiteral, type TTemplateLiteralKind } from './type/template-literal/index';
|
|
59
|
-
export { Transform, type TTransform, type TransformOptions, type TransformFunction
|
|
57
|
+
export { Symbol, type TSymbol, type TSymbolValue as SymbolValue } from './type/symbol/index';
|
|
58
|
+
export { TemplateLiteral, IsTemplateLiteralFinite, IsTemplateLiteralExpressionFinite, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralGenerate, TemplateLiteralExpressionGenerate, type TTemplateLiteral, type TIsTemplateLiteralFinite, type TTemplateLiteralGenerate, type TTemplateLiteralKind, } from './type/template-literal/index';
|
|
59
|
+
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index';
|
|
60
60
|
export { Tuple, type TTuple } from './type/tuple/index';
|
|
61
61
|
export { Uint8Array, type TUint8Array, type Uint8ArrayOptions } from './type/uint8array/index';
|
|
62
62
|
export { Undefined, type TUndefined } from './type/undefined/index';
|
|
63
|
-
export { Union, UnionEvaluated, type TUnion } from './type/union/index';
|
|
63
|
+
export { Union, UnionEvaluated, type TUnion, type TUnionEvaluated } from './type/union/index';
|
|
64
64
|
export { Unknown, type TUnknown } from './type/unknown/index';
|
|
65
65
|
export { Unsafe, type TUnsafe } from './type/unsafe/index';
|
|
66
66
|
export { Void, type TVoid } from './type/void/index';
|
package/build/require/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedKey = exports.IndexPropertyKeys = exports.Index = exports.Increment = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = void 0;
|
|
5
|
+
exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.TemplateLiteralExpressionGenerate = exports.TemplateLiteralGenerate = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.IsTemplateLiteralExpressionFinite = exports.IsTemplateLiteralFinite = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = void 0;
|
|
6
|
+
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = void 0;
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// Infrastructure
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -153,9 +153,11 @@ Object.defineProperty(exports, "Symbol", { enumerable: true, get: function () {
|
|
|
153
153
|
var index_55 = require("./type/template-literal/index");
|
|
154
154
|
Object.defineProperty(exports, "TemplateLiteral", { enumerable: true, get: function () { return index_55.TemplateLiteral; } });
|
|
155
155
|
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_55.IsTemplateLiteralFinite; } });
|
|
156
|
+
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_55.IsTemplateLiteralExpressionFinite; } });
|
|
156
157
|
Object.defineProperty(exports, "TemplateLiteralParse", { enumerable: true, get: function () { return index_55.TemplateLiteralParse; } });
|
|
157
158
|
Object.defineProperty(exports, "TemplateLiteralParseExact", { enumerable: true, get: function () { return index_55.TemplateLiteralParseExact; } });
|
|
158
159
|
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_55.TemplateLiteralGenerate; } });
|
|
160
|
+
Object.defineProperty(exports, "TemplateLiteralExpressionGenerate", { enumerable: true, get: function () { return index_55.TemplateLiteralExpressionGenerate; } });
|
|
159
161
|
var index_56 = require("./type/transform/index");
|
|
160
162
|
Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return index_56.Transform; } });
|
|
161
163
|
Object.defineProperty(exports, "TransformDecodeBuilder", { enumerable: true, get: function () { return index_56.TransformDecodeBuilder; } });
|
|
@@ -2,11 +2,9 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import { type TIntersect } from '../intersect/index';
|
|
3
3
|
import { type TUnion } from '../union/index';
|
|
4
4
|
import { type TPromise } from '../promise/index';
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
declare function FromSchema<T extends TSchema>(T: T): FromSchema<T>;
|
|
9
|
-
export type TAwaited<T extends TSchema> = (FromSchema<T>);
|
|
5
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TFromSchema<L>]> : Acc;
|
|
6
|
+
type TFromSchema<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TPromise<infer S> ? TFromSchema<S> : T;
|
|
7
|
+
export type TAwaited<T extends TSchema> = (TFromSchema<T>);
|
|
10
8
|
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
|
|
11
|
-
export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions):
|
|
9
|
+
export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions): TFromSchema<T>;
|
|
12
10
|
export {};
|
|
@@ -11,11 +11,11 @@ const type_1 = require("../clone/type");
|
|
|
11
11
|
// prettier-ignore
|
|
12
12
|
const type_2 = require("../guard/type");
|
|
13
13
|
// prettier-ignore
|
|
14
|
-
function FromRest(T) {
|
|
14
|
+
function FromRest(T, Acc = []) {
|
|
15
15
|
const [L, ...R] = T;
|
|
16
16
|
return (T.length > 0
|
|
17
|
-
?
|
|
18
|
-
:
|
|
17
|
+
? FromRest(R, [...Acc, FromSchema(L)])
|
|
18
|
+
: Acc);
|
|
19
19
|
}
|
|
20
20
|
// prettier-ignore
|
|
21
21
|
function FromIntersect(T) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { UnionToTuple, Assert, Evaluate } from '../helpers/index';
|
|
2
|
-
import { type TObject, type ObjectOptions } from '../object/index';
|
|
2
|
+
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
3
3
|
import { type TIntersect } from '../intersect/index';
|
|
4
4
|
import { type TIndex } from '../indexed/index';
|
|
5
|
-
type
|
|
6
|
-
type
|
|
5
|
+
type TCompositeKeys<T extends TObject[], Acc extends PropertyKey = never> = T extends [infer L extends TObject, ...infer R extends TObject[]] ? TCompositeKeys<R, Acc | keyof L['properties']> : Acc;
|
|
6
|
+
type TCompositeIndex<T extends TIntersect<TObject[]>, K extends string[], Acc extends TProperties = {}> = K extends [infer L extends string, ...infer R extends string[]] ? TCompositeIndex<T, R, Acc & {
|
|
7
7
|
[_ in L]: TIndex<T, [L]>;
|
|
8
|
-
}
|
|
9
|
-
type
|
|
10
|
-
export type
|
|
11
|
-
export declare function CompositeResolve<T extends TObject[]>(T: [...T]):
|
|
12
|
-
export type TComposite<T extends TObject[]> =
|
|
8
|
+
}> : Acc;
|
|
9
|
+
type TCompositeReduce<T extends TObject[]> = UnionToTuple<TCompositeKeys<T>> extends infer K ? Evaluate<TCompositeIndex<TIntersect<T>, Assert<K, string[]>>> : {};
|
|
10
|
+
export type TCompositeResolve<T extends TObject[]> = TIntersect<T> extends TIntersect ? TObject<TCompositeReduce<T>> : TObject<{}>;
|
|
11
|
+
export declare function CompositeResolve<T extends TObject[]>(T: [...T]): TCompositeResolve<T>;
|
|
12
|
+
export type TComposite<T extends TObject[]> = TCompositeResolve<T>;
|
|
13
13
|
/** `[Json]` Creates a Composite object type */
|
|
14
14
|
export declare function Composite<T extends TObject[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
|
|
15
15
|
export {};
|
|
@@ -14,15 +14,12 @@ import { type TReadonly } from '../readonly/index';
|
|
|
14
14
|
import { type TUndefined } from '../undefined/index';
|
|
15
15
|
import { type TUint8Array } from '../uint8array/index';
|
|
16
16
|
import { type TUnknown } from '../unknown/index';
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
type FromProperties<T extends Record<PropertyKey, unknown>> = {
|
|
17
|
+
type TFromArray<T extends readonly unknown[]> = T extends readonly [infer L extends unknown, ...infer R extends unknown[]] ? [FromValue<L, false>, ...TFromArray<R>] : T;
|
|
18
|
+
type TFromProperties<T extends Record<PropertyKey, unknown>> = {
|
|
20
19
|
-readonly [K in keyof T]: FromValue<T[K], false> extends infer R extends TSchema ? TReadonly<R> : TReadonly<TNever>;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
type
|
|
24
|
-
declare function ConditionalReadonly<T extends TSchema, Root extends boolean>(T: T, root: Root): ConditionalReadonly<T, Root>;
|
|
25
|
-
type FromValue<T, Root extends boolean> = T extends AsyncIterableIterator<unknown> ? ConditionalReadonly<TAny, Root> : T extends IterableIterator<unknown> ? ConditionalReadonly<TAny, Root> : T extends readonly unknown[] ? TReadonly<TTuple<AssertRest<FromArray<T>>>> : T extends Uint8Array ? TUint8Array : T extends Date ? TDate : T extends Record<PropertyKey, unknown> ? ConditionalReadonly<TObject<Evaluate<FromProperties<T>>>, Root> : T extends Function ? ConditionalReadonly<TFunction<[], TUnknown>, Root> : T extends undefined ? TUndefined : T extends null ? TNull : T extends symbol ? TSymbol : T extends number ? TLiteral<T> : T extends boolean ? TLiteral<T> : T extends string ? TLiteral<T> : T extends bigint ? TBigInt : TObject<{}>;
|
|
21
|
+
type TConditionalReadonly<T extends TSchema, Root extends boolean> = Root extends true ? T : TReadonly<T>;
|
|
22
|
+
type FromValue<T, Root extends boolean> = T extends AsyncIterableIterator<unknown> ? TConditionalReadonly<TAny, Root> : T extends IterableIterator<unknown> ? TConditionalReadonly<TAny, Root> : T extends readonly unknown[] ? TReadonly<TTuple<AssertRest<TFromArray<T>>>> : T extends Uint8Array ? TUint8Array : T extends Date ? TDate : T extends Record<PropertyKey, unknown> ? TConditionalReadonly<TObject<Evaluate<TFromProperties<T>>>, Root> : T extends Function ? TConditionalReadonly<TFunction<[], TUnknown>, Root> : T extends undefined ? TUndefined : T extends null ? TNull : T extends symbol ? TSymbol : T extends number ? TLiteral<T> : T extends boolean ? TLiteral<T> : T extends string ? TLiteral<T> : T extends bigint ? TBigInt : TObject<{}>;
|
|
26
23
|
declare function FromValue<T, Root extends boolean>(value: T, root: Root): FromValue<T, Root>;
|
|
27
24
|
export type TConst<T> = FromValue<T, true>;
|
|
28
25
|
/** `[JavaScript]` Creates a readonly const type from the given value. */
|
|
@@ -2,12 +2,12 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import type { Ensure } from '../helpers/index';
|
|
4
4
|
import { Kind } from '../symbols/index';
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
export type
|
|
5
|
+
type ConstructorStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
6
|
+
type ConstructorStaticParameters<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? ConstructorStaticParameters<R, P, [...Acc, Static<L, P>]> : Acc;
|
|
7
|
+
export type ConstructorStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<new (...param: ConstructorStaticParameters<T, P>) => ConstructorStaticReturnType<U, P>>);
|
|
8
8
|
export interface TConstructor<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
9
9
|
[Kind]: 'Constructor';
|
|
10
|
-
static:
|
|
10
|
+
static: ConstructorStatic<T, U, this['params']>;
|
|
11
11
|
type: 'Constructor';
|
|
12
12
|
parameters: T;
|
|
13
13
|
returns: U;
|
|
@@ -11,12 +11,12 @@ import type { TConstructor } from '../constructor/index';
|
|
|
11
11
|
import type { TFunction } from '../function/index';
|
|
12
12
|
import type { TRef } from '../ref/index';
|
|
13
13
|
import type { TObject, TProperties } from '../object/index';
|
|
14
|
-
export type
|
|
14
|
+
export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, DerefResolve<L>]> : Acc);
|
|
15
15
|
type FromProperties<T extends TProperties> = Evaluate<{
|
|
16
16
|
[K in keyof T]: DerefResolve<T[K]>;
|
|
17
17
|
}>;
|
|
18
18
|
declare function FromProperties(properties: TProperties, references: TSchema[]): TProperties;
|
|
19
|
-
export type DerefResolve<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<
|
|
19
|
+
export type DerefResolve<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, DerefResolve<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, DerefResolve<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest<S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<S>> : T extends TArray<infer S extends TSchema> ? TArray<DerefResolve<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<DerefResolve<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DerefResolve<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DerefResolve<S>> : T extends TRef<infer S extends TSchema> ? DerefResolve<S> : T;
|
|
20
20
|
export declare function DerefResolve<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
|
|
21
21
|
export type TDeref<T extends TSchema> = DerefResolve<T>;
|
|
22
22
|
/** `[Json]` Creates a dereferenced type */
|
|
@@ -21,67 +21,57 @@ function FromProperties(properties, references) {
|
|
|
21
21
|
}
|
|
22
22
|
// prettier-ignore
|
|
23
23
|
function FromConstructor(schema, references) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return clone;
|
|
24
|
+
schema.parameters = FromRest(schema.parameters, references);
|
|
25
|
+
schema.returns = Deref(schema.returns, references);
|
|
26
|
+
return schema;
|
|
28
27
|
}
|
|
29
28
|
// prettier-ignore
|
|
30
29
|
function FromFunction(schema, references) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return clone;
|
|
30
|
+
schema.parameters = FromRest(schema.parameters, references);
|
|
31
|
+
schema.returns = Deref(schema.returns, references);
|
|
32
|
+
return schema;
|
|
35
33
|
}
|
|
36
34
|
// prettier-ignore
|
|
37
35
|
function FromIntersect(schema, references) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return clone;
|
|
36
|
+
schema.allOf = FromRest(schema.allOf, references);
|
|
37
|
+
return schema;
|
|
41
38
|
}
|
|
42
39
|
// prettier-ignore
|
|
43
40
|
function FromUnion(schema, references) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return clone;
|
|
41
|
+
schema.anyOf = FromRest(schema.anyOf, references);
|
|
42
|
+
return schema;
|
|
47
43
|
}
|
|
48
44
|
// prettier-ignore
|
|
49
45
|
function FromTuple(schema, references) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return clone;
|
|
46
|
+
if ((0, value_1.IsUndefined)(schema.items))
|
|
47
|
+
return schema;
|
|
48
|
+
schema.items = FromRest(schema.items, references);
|
|
49
|
+
return schema;
|
|
55
50
|
}
|
|
56
51
|
// prettier-ignore
|
|
57
52
|
function FromArray(schema, references) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return clone;
|
|
53
|
+
schema.items = Deref(schema.items, references);
|
|
54
|
+
return schema;
|
|
61
55
|
}
|
|
62
56
|
// prettier-ignore
|
|
63
57
|
function FromObject(schema, references) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return clone;
|
|
58
|
+
schema.properties = FromProperties(schema.properties, references);
|
|
59
|
+
return schema;
|
|
67
60
|
}
|
|
68
61
|
// prettier-ignore
|
|
69
62
|
function FromPromise(schema, references) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return clone;
|
|
63
|
+
schema.item = Deref(schema.item, references);
|
|
64
|
+
return schema;
|
|
73
65
|
}
|
|
74
66
|
// prettier-ignore
|
|
75
67
|
function FromAsyncIterator(schema, references) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return clone;
|
|
68
|
+
schema.items = Deref(schema.items, references);
|
|
69
|
+
return schema;
|
|
79
70
|
}
|
|
80
71
|
// prettier-ignore
|
|
81
72
|
function FromIterator(schema, references) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return clone;
|
|
73
|
+
schema.items = Deref(schema.items, references);
|
|
74
|
+
return schema;
|
|
85
75
|
}
|
|
86
76
|
// prettier-ignore
|
|
87
77
|
function FromRef(schema, references) {
|
|
@@ -109,6 +99,6 @@ function DerefResolve(schema, references) {
|
|
|
109
99
|
exports.DerefResolve = DerefResolve;
|
|
110
100
|
/** `[Json]` Creates a dereferenced type */
|
|
111
101
|
function Deref(schema, references) {
|
|
112
|
-
return DerefResolve(schema, references);
|
|
102
|
+
return DerefResolve((0, type_1.CloneType)(schema), (0, type_1.CloneRest)(references));
|
|
113
103
|
}
|
|
114
104
|
exports.Deref = Deref;
|
|
@@ -2,12 +2,10 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TExclude } from './exclude';
|
|
5
|
-
type
|
|
5
|
+
type TFromProperties<K extends TProperties, U extends TSchema> = ({
|
|
6
6
|
[K2 in keyof K]: TExclude<K[K2], U>;
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
declare function
|
|
11
|
-
export type TExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>> = (TMappedResult<P>);
|
|
12
|
-
export declare function ExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = FromMappedResult<T, U>>(T: T, U: U, options: SchemaOptions): TMappedResult<P>;
|
|
8
|
+
type TFromMappedResult<K extends TMappedResult, U extends TSchema> = (TFromProperties<K['properties'], U>);
|
|
9
|
+
export type TExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = TFromMappedResult<T, U>> = (TMappedResult<P>);
|
|
10
|
+
export declare function ExcludeFromMappedResult<T extends TMappedResult, U extends TSchema, P extends TProperties = TFromMappedResult<T, U>>(T: T, U: U, options: SchemaOptions): TMappedResult<P>;
|
|
13
11
|
export {};
|