@tstdl/base 0.78.0-beta4 → 0.78.0-beta7
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/api/server/gateway.js +3 -0
- package/api/server/gateway.js.map +1 -1
- package/api/types.d.ts +9 -7
- package/api/types.js.map +1 -1
- package/enumerable/async-enumerable.d.ts +2 -1
- package/enumerable/async-enumerable.js +3 -0
- package/enumerable/async-enumerable.js.map +1 -1
- package/enumerable/enumerable-methods.d.ts +1 -0
- package/enumerable/enumerable.d.ts +1 -0
- package/enumerable/enumerable.js +12 -18
- package/enumerable/enumerable.js.map +1 -1
- package/package.json +2 -3
- package/schema/array-constraints/maximum-length.js +2 -2
- package/schema/array-constraints/maximum-length.js.map +1 -1
- package/schema/array-constraints/minimum-length.js +2 -2
- package/schema/array-constraints/minimum-length.js.map +1 -1
- package/schema/coercers/default-value.coercer.d.ts +1 -1
- package/schema/coercers/default-value.coercer.js +1 -1
- package/schema/coercers/default-value.coercer.js.map +1 -1
- package/schema/coercers/uint8-array.coercer.js +4 -3
- package/schema/coercers/uint8-array.coercer.js.map +1 -1
- package/schema/constraints/enumeration.js +2 -2
- package/schema/constraints/enumeration.js.map +1 -1
- package/schema/constraints/generic.js +2 -2
- package/schema/constraints/generic.js.map +1 -1
- package/schema/constraints/integer.js +3 -3
- package/schema/constraints/integer.js.map +1 -1
- package/schema/constraints/literal.js +2 -2
- package/schema/constraints/literal.js.map +1 -1
- package/schema/constraints/maximum-date.js +3 -3
- package/schema/constraints/maximum-date.js.map +1 -1
- package/schema/constraints/maximum-length.js +2 -2
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/maximum.js +3 -3
- package/schema/constraints/maximum.js.map +1 -1
- package/schema/constraints/minimum-date.js +3 -3
- package/schema/constraints/minimum-date.js.map +1 -1
- package/schema/constraints/minimum-length.js +2 -2
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/constraints/minimum.js +3 -3
- package/schema/constraints/minimum.js.map +1 -1
- package/schema/constraints/pattern.js +3 -3
- package/schema/constraints/pattern.js.map +1 -1
- package/schema/decorators/array.d.ts +2 -2
- package/schema/decorators/array.js +1 -1
- package/schema/decorators/array.js.map +1 -1
- package/schema/decorators/defaulted.d.ts +2 -2
- package/schema/decorators/defaulted.js +1 -1
- package/schema/decorators/defaulted.js.map +1 -1
- package/schema/decorators/property.d.ts +1 -1
- package/schema/decorators/property.js +3 -1
- package/schema/decorators/property.js.map +1 -1
- package/schema/decorators/types.d.ts +3 -3
- package/schema/decorators/utils.d.ts +3 -2
- package/schema/decorators/utils.js +4 -8
- package/schema/decorators/utils.js.map +1 -1
- package/schema/schema.d.ts +10 -8
- package/schema/schema.js +102 -107
- package/schema/schema.js.map +1 -1
- package/schema/schemas/any.d.ts +2 -2
- package/schema/schemas/any.js +2 -2
- package/schema/schemas/any.js.map +1 -1
- package/schema/schemas/array.d.ts +2 -1
- package/schema/schemas/array.js +1 -1
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/boolean.js +2 -2
- package/schema/schemas/boolean.js.map +1 -1
- package/schema/schemas/date.js +2 -2
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/defaulted.d.ts +3 -2
- package/schema/schemas/defaulted.js.map +1 -1
- package/schema/schemas/enumeration.js +2 -2
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/index.d.ts +1 -0
- package/schema/schemas/index.js +1 -0
- package/schema/schemas/index.js.map +1 -1
- package/schema/schemas/instance.d.ts +2 -2
- package/schema/schemas/instance.js +1 -1
- package/schema/schemas/instance.js.map +1 -1
- package/schema/schemas/literal.js +2 -2
- package/schema/schemas/literal.js.map +1 -1
- package/schema/schemas/nullable.d.ts +3 -2
- package/schema/schemas/nullable.js.map +1 -1
- package/schema/schemas/number.d.ts +1 -1
- package/schema/schemas/number.js +2 -2
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/object.d.ts +2 -3
- package/schema/schemas/object.js.map +1 -1
- package/schema/schemas/readable-stream.d.ts +2 -2
- package/schema/schemas/readable-stream.js +2 -2
- package/schema/schemas/readable-stream.js.map +1 -1
- package/schema/schemas/record.d.ts +3 -2
- package/schema/schemas/record.js.map +1 -1
- package/schema/schemas/regexp.js +2 -2
- package/schema/schemas/regexp.js.map +1 -1
- package/schema/schemas/string.js +2 -2
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/transform.d.ts +3 -2
- package/schema/schemas/transform.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +2 -3
- package/schema/schemas/uint8-array.js +3 -3
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/schemas/union.d.ts +9 -8
- package/schema/schemas/union.js +1 -1
- package/schema/schemas/union.js.map +1 -1
- package/schema/schemas/unknown.d.ts +2 -2
- package/schema/schemas/unknown.js +2 -2
- package/schema/schemas/unknown.js.map +1 -1
- package/schema/transformers/generic.d.ts +4 -4
- package/schema/transformers/generic.js.map +1 -1
- package/schema/transformers/lowercase.js +1 -1
- package/schema/transformers/lowercase.js.map +1 -1
- package/schema/transformers/trim.js +1 -1
- package/schema/transformers/trim.js.map +1 -1
- package/schema/transformers/uppercase.js +1 -1
- package/schema/transformers/uppercase.js.map +1 -1
- package/schema/types.d.ts +45 -33
- package/schema/types.js +35 -33
- package/schema/types.js.map +1 -1
- package/schema/utils/schema.d.ts +10 -5
- package/schema/utils/schema.js +44 -26
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +3 -1
- package/schema/utils/value-type.js +23 -3
- package/schema/utils/value-type.js.map +1 -1
- package/types.d.ts +2 -1
- package/utils/async-iterable-helpers/includes.d.ts +2 -0
- package/utils/async-iterable-helpers/includes.js +13 -0
- package/utils/async-iterable-helpers/includes.js.map +1 -0
- package/utils/async-iterable-helpers/index.d.ts +1 -0
- package/utils/async-iterable-helpers/index.js +1 -0
- package/utils/async-iterable-helpers/index.js.map +1 -1
- package/utils/iterable-helpers/includes.d.ts +1 -0
- package/utils/iterable-helpers/includes.js +9 -0
- package/utils/iterable-helpers/includes.js.map +1 -0
- package/utils/iterable-helpers/index.d.ts +1 -0
- package/utils/iterable-helpers/index.js +1 -0
- package/utils/iterable-helpers/index.js.map +1 -1
package/schema/schemas/number.js
CHANGED
|
@@ -19,7 +19,7 @@ function number(options = {}) {
|
|
|
19
19
|
if (options.integer == true) {
|
|
20
20
|
constraints.push(integer_1.integerConstraint);
|
|
21
21
|
}
|
|
22
|
-
return (0, types_1.valueSchema)(globalThis.Number, {
|
|
22
|
+
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Number), {
|
|
23
23
|
array: false,
|
|
24
24
|
optional: false,
|
|
25
25
|
nullable: false,
|
|
@@ -29,7 +29,7 @@ function number(options = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
exports.number = number;
|
|
31
31
|
function Number(options) {
|
|
32
|
-
return (0, decorators_1.
|
|
32
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(number(options));
|
|
33
33
|
}
|
|
34
34
|
exports.Number = Number;
|
|
35
35
|
//# sourceMappingURL=number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;AACxE,oCAAkG;AAQlG,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC1D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC1D;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE;QAC3B,WAAW,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;KACrC;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAtBD,wBAsBC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Record, TypedOmit } from "../../types";
|
|
2
|
-
import type { PartialOnUndefinedDeep } from 'type-fest';
|
|
1
|
+
import type { Record, SimplifiedOptionalize, TypedOmit } from "../../types";
|
|
3
2
|
import type { ObjectSchema, ObjectSchemaProperties } from '../types';
|
|
4
3
|
export declare type ObjectOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties'>;
|
|
5
4
|
export declare function explicitObject<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<T>;
|
|
6
|
-
export declare function object<T extends Record
|
|
5
|
+
export declare function object<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<SimplifiedOptionalize<T>, SimplifiedOptionalize<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,cAAc,CAAmB,UAAqC,EAAE,OAA0B;IAChH,OAAO,MAAM,CAAC,UAAU,EAAE,OAAO,CAA2B,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED,SAAgB,MAAM,CAAmB,UAAqC,EAAE,OAA0B;IACxG,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU;QACV,GAAG,OAAO;KACX,CAAgF,CAAC;AACpF,CAAC;AALD,wBAKC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function readableStream():
|
|
2
|
+
import type { TypeSchema } from '../types';
|
|
3
|
+
export declare function readableStream(): TypeSchema<globalThis.ReadableStream>;
|
|
4
4
|
export declare function ReadableStream(): Decorator<'property' | 'accessor'>;
|
|
@@ -5,11 +5,11 @@ exports.ReadableStream = exports.readableStream = void 0;
|
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
function readableStream() {
|
|
8
|
-
return (0, types_1.
|
|
8
|
+
return (0, types_1.typeSchema)(globalThis.ReadableStream);
|
|
9
9
|
}
|
|
10
10
|
exports.readableStream = readableStream;
|
|
11
11
|
function ReadableStream() {
|
|
12
|
-
return (0, decorators_1.
|
|
12
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(readableStream());
|
|
13
13
|
}
|
|
14
14
|
exports.ReadableStream = ReadableStream;
|
|
15
15
|
//# sourceMappingURL=readable-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,
|
|
1
|
+
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAExE,oCAAsC;AAEtC,SAAgB,cAAc;IAC5B,OAAO,IAAA,kBAAU,EAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,oDAAuC,EAAC,cAAc,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wCAEC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OneOrMany, Record, TypedOmit } from "../../types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
import type { ObjectSchema } from '../types';
|
|
3
4
|
export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties' | 'mask'>;
|
|
4
|
-
export declare function record<T, O>(valueType: OneOrMany<
|
|
5
|
+
export declare function record<T, O>(valueType: OneOrMany<Schema<T, O>>, options?: RecordOptions): ObjectSchema<Record<any, O>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAO,SAAkC,EAAE,OAAuB;IACtF,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,SAAS;QACjC,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
|
package/schema/schemas/regexp.js
CHANGED
|
@@ -5,13 +5,13 @@ exports.RegExp = exports.regexp = void 0;
|
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
function regexp(options = {}) {
|
|
8
|
-
return (0, types_1.valueSchema)(globalThis.RegExp, {
|
|
8
|
+
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.RegExp), {
|
|
9
9
|
coerce: options.coerce
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
exports.regexp = regexp;
|
|
13
13
|
function RegExp(options) {
|
|
14
|
-
return (0, decorators_1.
|
|
14
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(regexp(options));
|
|
15
15
|
}
|
|
16
16
|
exports.RegExp = RegExp;
|
|
17
17
|
//# sourceMappingURL=regexp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,
|
|
1
|
+
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAmD;AAInD,SAAgB,MAAM,CAAC,UAA+B,EAAE;IACtD,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
package/schema/schemas/string.js
CHANGED
|
@@ -29,7 +29,7 @@ function string(options = {}) {
|
|
|
29
29
|
if ((0, type_guards_1.isDefined)(options.uppercase)) {
|
|
30
30
|
transformers.push(new transformers_1.UppercaseTransformer());
|
|
31
31
|
}
|
|
32
|
-
return (0, types_1.valueSchema)(globalThis.String, {
|
|
32
|
+
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.String), {
|
|
33
33
|
coerce: options.coerce,
|
|
34
34
|
valueConstraints: constraints,
|
|
35
35
|
transformers
|
|
@@ -37,7 +37,7 @@ function string(options = {}) {
|
|
|
37
37
|
}
|
|
38
38
|
exports.string = string;
|
|
39
39
|
function String(options) {
|
|
40
|
-
return (0, decorators_1.
|
|
40
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(string(options));
|
|
41
41
|
}
|
|
42
42
|
exports.String = String;
|
|
43
43
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAAqG;AACrG,
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAAqG;AACrG,8CAAwE;AACxE,kDAA8F;AAE9F,oCAAmD;AA4BnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,WAAW,GAA4B,EAAE,CAAC;IAChD,MAAM,YAAY,GAA6B,EAAE,CAAC;IAElD,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,IAAI,qCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KACtE;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,IAAI,qCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KACtE;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAC9D,WAAW,CAAC,IAAI,CAAC,IAAI,+BAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;KACvE;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,8BAAe,EAAE,CAAC,CAAC;KAC1C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;QAC7B,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAlCD,wBAkCC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { OneOrMany } from "../../types";
|
|
1
|
+
import type { AbstractConstructor, OneOrMany } from "../../types";
|
|
2
|
+
import type { Schema } from '../schema';
|
|
2
3
|
import type { GenericTransformFunction } from '../transformers/generic';
|
|
3
4
|
import type { ValueSchema, ValueType } from '../types';
|
|
4
|
-
export declare function transform<T, O, TransformOutput>(schema: OneOrMany<
|
|
5
|
+
export declare function transform<T, O, TransformOutput>(schema: OneOrMany<Schema<T, O>>, sourceType: OneOrMany<ValueType<T>>, targetType: AbstractConstructor<TransformOutput>, transformFunction: GenericTransformFunction<O, TransformOutput>): ValueSchema<TransformOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AAGA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,CAAwB,MAA+B,EAAE,UAAmC,EAAE,UAAgD,EAAE,iBAA+D;IACtO,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE;QACzB,YAAY,EAAE,IAAI,4BAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC;KAChF,CAAqB,CAAC;AACzB,CAAC;AAJD,8BAIC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
import type { Coercible } from '../types';
|
|
2
|
+
import type { Coercible, ValueSchema } from '../types';
|
|
4
3
|
export declare type Uint8ArraySchemaOptions = Coercible & {
|
|
5
4
|
minimumLength?: number;
|
|
6
5
|
maximumLength?: number;
|
|
7
6
|
};
|
|
8
|
-
export declare function uint8Array(options?: Uint8ArraySchemaOptions):
|
|
7
|
+
export declare function uint8Array(options?: Uint8ArraySchemaOptions): ValueSchema<globalThis.Uint8Array>;
|
|
9
8
|
export declare function Uint8Array(options?: Uint8ArraySchemaOptions): Decorator<'property' | 'accessor'>;
|
|
@@ -6,7 +6,7 @@ const type_guards_1 = require("../../utils/type-guards");
|
|
|
6
6
|
const uint8_array_coercer_1 = require("../coercers/uint8-array.coercer");
|
|
7
7
|
const maximum_length_1 = require("../constraints/maximum-length");
|
|
8
8
|
const minimum_length_1 = require("../constraints/minimum-length");
|
|
9
|
-
const
|
|
9
|
+
const utils_1 = require("../decorators/utils");
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
function uint8Array(options = {}) {
|
|
12
12
|
const constraints = [];
|
|
@@ -16,14 +16,14 @@ function uint8Array(options = {}) {
|
|
|
16
16
|
if ((0, type_guards_1.isDefined)(options.maximumLength)) {
|
|
17
17
|
constraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
|
|
18
18
|
}
|
|
19
|
-
return (0, types_1.valueSchema)(globalThis.Uint8Array, {
|
|
19
|
+
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Uint8Array), {
|
|
20
20
|
coercers: (options.coerce == true) ? uint8_array_coercer_1.uint8ArrayCoercer : undefined,
|
|
21
21
|
valueConstraints: constraints
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
exports.uint8Array = uint8Array;
|
|
25
25
|
function Uint8Array(options) {
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, utils_1.createSchemaPropertyDecoratorFromSchema)(uint8Array(options));
|
|
27
27
|
}
|
|
28
28
|
exports.Uint8Array = Uint8Array;
|
|
29
29
|
//# sourceMappingURL=uint8-array.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE
|
|
1
|
+
{"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE,+CAA8E;AAE9E,oCAAmD;AAOnD,SAAgB,UAAU,CAAC,UAAmC,EAAE;IAC9D,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KACtE;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KACtE;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACpD,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,uCAAiB,CAAC,CAAC,CAAC,SAAS;QAClE,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAfD,gCAeC;AAED,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,IAAA,+CAAuC,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,gCAEC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export declare function union<T1, O1, T2, O2
|
|
5
|
-
export declare function union<T1, O1, T2, O2, T3, O3
|
|
6
|
-
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4
|
|
7
|
-
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4, T5, O5
|
|
8
|
-
export declare function union(
|
|
9
|
-
export declare function
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
import type { ValueSchema } from '../types';
|
|
4
|
+
export declare function union<T1, O1, T2, O2>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>): ValueSchema<T1 | T2, O1 | O2>;
|
|
5
|
+
export declare function union<T1, O1, T2, O2, T3, O3>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>): ValueSchema<T1 | T2 | T3, O1 | O2 | O3>;
|
|
6
|
+
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>): ValueSchema<T1 | T2 | T3 | T4, O1 | O2 | O3 | O4>;
|
|
7
|
+
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4, T5, O5>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>, schema5: Schema<T5, O5>): ValueSchema<T1 | T2 | T3 | T4 | T5, O1 | O2 | O3 | O4 | O5>;
|
|
8
|
+
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4, T5, O5, T6, O6>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>, schema5: Schema<T5, O5>, schema6: Schema<T6>): ValueSchema<T1 | T2 | T3 | T4 | T5 | T6, O1 | O2 | O3 | O4 | O5 | O6>;
|
|
9
|
+
export declare function union(...schemas: Schema[]): ValueSchema;
|
|
10
|
+
export declare function Union(...schemas: Schema[]): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/union.js
CHANGED
|
@@ -11,7 +11,7 @@ function union(...schemas) {
|
|
|
11
11
|
}
|
|
12
12
|
exports.union = union;
|
|
13
13
|
function Union(...schemas) {
|
|
14
|
-
return (0, decorators_1.
|
|
14
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(union(...schemas));
|
|
15
15
|
}
|
|
16
16
|
exports.Union = Union;
|
|
17
17
|
//# sourceMappingURL=union.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAA6C;AAC7C,8CAAwE;AAGxE,oCAAuC;AAQvC,SAAgB,KAAK,CAAC,GAAG,OAAiB;IACxC,IAAA,oBAAM,EAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,qCAAqC,CAAC,CAAC;IACnE,OAAO,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAHD,sBAGC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAiB;IACxC,OAAO,IAAA,oDAAuC,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sBAEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function unknown():
|
|
2
|
+
import type { TypeSchema } from '../types';
|
|
3
|
+
export declare function unknown(): TypeSchema<unknown>;
|
|
4
4
|
export declare function Unknwon(): Decorator<'property' | 'accessor'>;
|
|
@@ -5,11 +5,11 @@ exports.Unknwon = exports.unknown = void 0;
|
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
function unknown() {
|
|
8
|
-
return (0, types_1.
|
|
8
|
+
return (0, types_1.typeSchema)('any');
|
|
9
9
|
}
|
|
10
10
|
exports.unknown = unknown;
|
|
11
11
|
function Unknwon() {
|
|
12
|
-
return (0, decorators_1.
|
|
12
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(unknown());
|
|
13
13
|
}
|
|
14
14
|
exports.Unknwon = Unknwon;
|
|
15
15
|
//# sourceMappingURL=unknown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,
|
|
1
|
+
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAExE,oCAAsC;AAEtC,SAAgB,OAAO;IACrB,OAAO,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO;IACrB,OAAO,IAAA,oDAAuC,EAAC,OAAO,EAAE,CAAC,CAAC;AAC5D,CAAC;AAFD,0BAEC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type { OneOrMany, TypedOmit } from "../../types";
|
|
2
|
+
import type { AbstractConstructor, OneOrMany, TypedOmit } from "../../types";
|
|
3
3
|
import type { TransformResult, ValueType } from '../types';
|
|
4
4
|
import { SchemaValueTransformer } from '../types';
|
|
5
5
|
export declare type GenericTransformFunction<T, O> = (value: T) => TypedOmit<TransformResult<O>, 'success'>;
|
|
6
6
|
export declare class GenericTransformer<T, O, TransformOutput> extends SchemaValueTransformer<T, O, TransformOutput> {
|
|
7
|
-
readonly sourceType: OneOrMany<ValueType<T
|
|
7
|
+
readonly sourceType: OneOrMany<ValueType<T>>;
|
|
8
8
|
readonly targetType: ValueType<TransformOutput>;
|
|
9
9
|
readonly transformFunction: GenericTransformFunction<O, TransformOutput>;
|
|
10
|
-
constructor(sourceType: OneOrMany<ValueType<T
|
|
10
|
+
constructor(sourceType: OneOrMany<ValueType<T>>, targetType: AbstractConstructor<TransformOutput>, transformFunction: GenericTransformFunction<O, TransformOutput>);
|
|
11
11
|
transform(value: O): TransformResult<TransformOutput>;
|
|
12
12
|
}
|
|
13
|
-
export declare function Transform<T, O, TransformOutput>(sourceType: OneOrMany<
|
|
13
|
+
export declare function Transform<T, O, TransformOutput>(sourceType: OneOrMany<AbstractConstructor<T>>, targetType: AbstractConstructor, transformFunction: GenericTransformFunction<O, TransformOutput>): Decorator<'property' | 'accessor'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/transformers/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,yDAAgD;AAChD,8CAAsE;AAEtE,oCAAkD;AAIlD,MAAa,kBAA0C,SAAQ,8BAA6C;IAK1G,YAAY,
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/transformers/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,yDAAgD;AAChD,8CAAsE;AAEtE,oCAAkD;AAIlD,MAAa,kBAA0C,SAAQ,8BAA6C;IAK1G,YAAY,UAAmC,EAAE,UAAgD,EAAE,iBAA+D;QAChK,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,SAAS,CAAC,KAAQ;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAE7C,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;SAChD;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAM,EAAE,CAAC;IACjD,CAAC;CACF;AAtBD,gDAsBC;AAED,SAAgB,SAAS,CAAwB,UAA6C,EAAE,UAA+B,EAAE,iBAA+D;IAC9L,OAAO,IAAA,kDAAqC,EAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAClH,CAAC;AAFD,8BAEC"}
|
|
@@ -16,7 +16,7 @@ class LowercaseTransformer extends types_1.SchemaValueTransformer {
|
|
|
16
16
|
}
|
|
17
17
|
exports.LowercaseTransformer = LowercaseTransformer;
|
|
18
18
|
function Lowercase() {
|
|
19
|
-
return (0, decorators_1.createSchemaValueTransformerDecorator)(new LowercaseTransformer(), {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new LowercaseTransformer(), { schema: (0, types_1.typeSchema)(String) });
|
|
20
20
|
}
|
|
21
21
|
exports.Lowercase = Lowercase;
|
|
22
22
|
//# sourceMappingURL=lowercase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/lowercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,
|
|
1
|
+
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/lowercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,8BAA8C;IAAxF;;QACW,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;IACvD,CAAC;CACF;AAPD,oDAOC;AAED,SAAgB,SAAS;IACvB,OAAO,IAAA,kDAAqC,EAAC,IAAI,oBAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAFD,8BAEC"}
|
|
@@ -16,7 +16,7 @@ class TrimTransformer extends types_1.SchemaValueTransformer {
|
|
|
16
16
|
}
|
|
17
17
|
exports.TrimTransformer = TrimTransformer;
|
|
18
18
|
function Trim() {
|
|
19
|
-
return (0, decorators_1.createSchemaValueTransformerDecorator)(new TrimTransformer(), {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new TrimTransformer(), { schema: (0, types_1.typeSchema)(String) });
|
|
20
20
|
}
|
|
21
21
|
exports.Trim = Trim;
|
|
22
22
|
//# sourceMappingURL=trim.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../source/schema/transformers/trim.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,
|
|
1
|
+
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../source/schema/transformers/trim.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,eAAgB,SAAQ,8BAA8C;IAAnF;;QACW,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;IAChD,CAAC;CACF;AAPD,0CAOC;AAED,SAAgB,IAAI;IAClB,OAAO,IAAA,kDAAqC,EAAC,IAAI,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACtG,CAAC;AAFD,oBAEC"}
|
|
@@ -16,7 +16,7 @@ class UppercaseTransformer extends types_1.SchemaValueTransformer {
|
|
|
16
16
|
}
|
|
17
17
|
exports.UppercaseTransformer = UppercaseTransformer;
|
|
18
18
|
function Uppercase() {
|
|
19
|
-
return (0, decorators_1.createSchemaValueTransformerDecorator)(new UppercaseTransformer(), {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new UppercaseTransformer(), { schema: (0, types_1.typeSchema)(String) });
|
|
20
20
|
}
|
|
21
21
|
exports.Uppercase = Uppercase;
|
|
22
22
|
//# sourceMappingURL=uppercase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/uppercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,
|
|
1
|
+
{"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/uppercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,8BAA8C;IAAxF;;QACW,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;IACvD,CAAC;CACF;AAPD,oDAOC;AAED,SAAgB,SAAS;IACvB,OAAO,IAAA,kDAAqC,EAAC,IAAI,oBAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAFD,8BAEC"}
|
package/schema/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JsonPath } from "../json-path/json-path";
|
|
2
2
|
import type { AbstractConstructor, OneOrMany, Record, Type, TypedOmit } from "../types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { NormalizedSchema, Schema } from './schema';
|
|
4
4
|
import type { SchemaError } from './schema.error';
|
|
5
5
|
declare const schemaOutputTypeSymbol: unique symbol;
|
|
6
6
|
export declare type SchemaFactoryFunction<T extends Record, O = T> = (data: T) => NormalizeValueType<O>;
|
|
@@ -12,22 +12,29 @@ export declare type SchemaFactory<T extends Record, O = T> = {
|
|
|
12
12
|
builder: SchemaFactoryFunction<T, O>;
|
|
13
13
|
};
|
|
14
14
|
export declare type ObjectSchemaProperties<T extends Record> = {
|
|
15
|
-
[K in keyof T]-?: OneOrMany<
|
|
15
|
+
[K in keyof T]-?: OneOrMany<Schema<any, T[K]>>;
|
|
16
16
|
};
|
|
17
17
|
export declare type NormalizedObjectSchemaProperties<T> = {
|
|
18
|
-
[K in keyof T]
|
|
18
|
+
[K in keyof T]-?: Schema<any, T[K]>;
|
|
19
19
|
};
|
|
20
|
-
export declare type SchemaOutput<T extends
|
|
20
|
+
export declare type SchemaOutput<T extends Schema> = T extends ObjectSchema<any, infer O> ? O : T extends ValueSchema<any, infer O> ? O : T extends TypeSchema<infer O> ? O : never;
|
|
21
21
|
export declare type ObjectSchema<T extends Record = any, O extends Record = T> = {
|
|
22
22
|
[schemaOutputTypeSymbol]?: O;
|
|
23
|
+
sourceType?: ValueType;
|
|
23
24
|
factory?: SchemaFactory<T, O>;
|
|
24
25
|
properties: ObjectSchemaProperties<T>;
|
|
25
26
|
mask?: boolean;
|
|
26
|
-
allowUnknownProperties?: OneOrMany<
|
|
27
|
+
allowUnknownProperties?: OneOrMany<Schema>;
|
|
28
|
+
};
|
|
29
|
+
export declare type TypeSchema<T = any> = {
|
|
30
|
+
type: ValueType<T>;
|
|
31
|
+
};
|
|
32
|
+
export declare type NormalizedTypeSchema<T = any> = {
|
|
33
|
+
foo: ResolvedValueType<T>;
|
|
27
34
|
};
|
|
28
|
-
export declare type TypeSchema<T = any, O = T> = AbstractConstructor<T & O>;
|
|
29
35
|
export declare type ValueSchema<T = unknown, O = T> = {
|
|
30
|
-
|
|
36
|
+
[schemaOutputTypeSymbol]?: O;
|
|
37
|
+
schema: OneOrMany<Schema<T, O>>;
|
|
31
38
|
array?: boolean;
|
|
32
39
|
optional?: boolean;
|
|
33
40
|
nullable?: boolean;
|
|
@@ -48,7 +55,7 @@ export declare type NormalizedObjectSchema<T extends Record = any, O extends Rec
|
|
|
48
55
|
};
|
|
49
56
|
export declare type NormalizedValueSchema<T = any, O = T> = {
|
|
50
57
|
[schemaOutputTypeSymbol]?: O;
|
|
51
|
-
|
|
58
|
+
schema: Set<Schema<T, O>>;
|
|
52
59
|
array: boolean;
|
|
53
60
|
optional: boolean;
|
|
54
61
|
nullable: boolean;
|
|
@@ -59,25 +66,25 @@ export declare type NormalizedValueSchema<T = any, O = T> = {
|
|
|
59
66
|
valueConstraints: readonly SchemaValueConstraint[];
|
|
60
67
|
};
|
|
61
68
|
export declare type SchemaContext = {
|
|
62
|
-
schema:
|
|
69
|
+
schema: NormalizedSchema;
|
|
63
70
|
options: SchemaTestOptions;
|
|
64
71
|
};
|
|
65
72
|
export declare type ConstraintContext = SchemaContext;
|
|
66
73
|
export declare type TransformerContext = SchemaContext;
|
|
67
74
|
export declare type CoercerContext = SchemaContext;
|
|
68
|
-
export declare type NormalizeValueType<T> = T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends BigInt ? bigint : T extends Symbol ? symbol : T extends 'undefined' ? undefined : T extends 'null' ? null : T;
|
|
69
|
-
export declare type NormalizeToValueType<T> = T extends string ? typeof String : T extends number ? typeof Number : T extends boolean ? typeof Boolean : T extends bigint ? typeof BigInt : T extends symbol ? typeof Symbol : T extends undefined ? 'undefined' : T extends null ? 'null' : never;
|
|
70
|
-
export declare type ValueType<T = any
|
|
71
|
-
export declare type DeferredValueType<T = unknown
|
|
72
|
-
deferred: () => ValueType<T
|
|
73
|
-
};
|
|
74
|
-
export declare type ResolvedValueType<T = unknown
|
|
75
|
-
export declare type ValueTypeOutput<T extends ValueType
|
|
75
|
+
export declare type NormalizeValueType<T> = T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T extends BigInt ? bigint : T extends Symbol ? symbol : T extends 'undefined' ? undefined : T extends 'null' ? null : T extends 'any' ? any : T;
|
|
76
|
+
export declare type NormalizeToValueType<T> = T extends string | String ? typeof String : T extends number ? typeof Number : T extends boolean ? typeof Boolean : T extends bigint ? typeof BigInt : T extends symbol ? typeof Symbol : T extends undefined ? 'undefined' : T extends null ? 'null' : T extends any ? 'any' : never;
|
|
77
|
+
export declare type ValueType<T = any> = AbstractConstructor<T> | NormalizeToValueType<T> | DeferredValueType<T>;
|
|
78
|
+
export declare type DeferredValueType<T = unknown> = {
|
|
79
|
+
deferred: () => ValueType<T>;
|
|
80
|
+
};
|
|
81
|
+
export declare type ResolvedValueType<T = unknown> = Exclude<ValueType<T>, DeferredValueType>;
|
|
82
|
+
export declare type ValueTypeOutput<T extends ValueType> = T extends ValueType<infer U> ? NormalizeValueType<U> : never;
|
|
76
83
|
export declare type Coercible = {
|
|
77
84
|
coerce?: boolean;
|
|
78
85
|
};
|
|
79
|
-
export declare const
|
|
80
|
-
export declare const
|
|
86
|
+
export declare const primitiveConstructors: ValueType[];
|
|
87
|
+
export declare const primitiveConstructorSet: Set<ValueType<any>>;
|
|
81
88
|
export declare abstract class SchemaArrayConstraint {
|
|
82
89
|
abstract validate(value: readonly unknown[], path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
83
90
|
}
|
|
@@ -88,7 +95,7 @@ export declare abstract class SchemaValueConstraint {
|
|
|
88
95
|
abstract validate(value: unknown, path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
89
96
|
}
|
|
90
97
|
export declare abstract class SchemaValueTransformer<T = any, O = T, TransformOutput = O> {
|
|
91
|
-
abstract readonly sourceType: OneOrMany<ValueType<T
|
|
98
|
+
abstract readonly sourceType: OneOrMany<ValueType<T>>;
|
|
92
99
|
abstract readonly targetType: ValueType<TransformOutput>;
|
|
93
100
|
abstract transform(value: O, path: JsonPath, context: TransformerContext): TransformResult<TransformOutput>;
|
|
94
101
|
}
|
|
@@ -110,19 +117,19 @@ export declare type SchemaTestOptions = {
|
|
|
110
117
|
mask?: boolean;
|
|
111
118
|
};
|
|
112
119
|
export declare type SchemaTestResult<T> = {
|
|
113
|
-
|
|
120
|
+
valid: true;
|
|
114
121
|
value: T;
|
|
115
122
|
error?: undefined;
|
|
116
123
|
} | {
|
|
117
|
-
|
|
124
|
+
valid: false;
|
|
118
125
|
value?: undefined;
|
|
119
126
|
error: SchemaError;
|
|
120
127
|
};
|
|
121
128
|
export declare type ConstraintResult = {
|
|
122
|
-
|
|
129
|
+
valid: true;
|
|
123
130
|
error?: undefined;
|
|
124
131
|
} | {
|
|
125
|
-
|
|
132
|
+
valid: false;
|
|
126
133
|
error: SchemaError;
|
|
127
134
|
};
|
|
128
135
|
export declare type CoerceResult = {
|
|
@@ -144,13 +151,18 @@ export declare type TransformResult<T> = {
|
|
|
144
151
|
error: SchemaError;
|
|
145
152
|
};
|
|
146
153
|
export declare function objectSchema<T, O = T>(schema: ObjectSchema<T, O>): ObjectSchema<T, O>;
|
|
147
|
-
export declare function valueSchema<T, O = T>(
|
|
148
|
-
export declare function
|
|
149
|
-
export declare function
|
|
150
|
-
export declare function
|
|
151
|
-
export declare function
|
|
152
|
-
export declare function
|
|
153
|
-
export declare function
|
|
154
|
-
export declare function
|
|
155
|
-
export declare function
|
|
154
|
+
export declare function valueSchema<T, O = T>(schema: OneOrMany<Schema<T, O>>, options?: TypedOmit<ValueSchema<T, O>, 'schema'>): ValueSchema<T, O>;
|
|
155
|
+
export declare function typeSchema<T>(type: ValueType<T>): TypeSchema<NormalizeValueType<T>>;
|
|
156
|
+
export declare function isSchema<T extends Record, O extends Record>(value: any): value is Schema<T, O>;
|
|
157
|
+
export declare function isObjectSchema<T extends Record, O extends Record>(schema: Schema<T, O>): schema is ObjectSchema<T, O>;
|
|
158
|
+
export declare function isObjectSchema<T extends Record, O extends Record>(schema: any): schema is ObjectSchema<T, O>;
|
|
159
|
+
export declare function isValueSchema<T, O>(schema: Schema<T, O>): schema is ValueSchema<T, O>;
|
|
160
|
+
export declare function isValueSchema<T, O>(schema: any): schema is ValueSchema<T, O>;
|
|
161
|
+
export declare function isTypeSchema<T, O>(schema: Schema<T, O>): schema is TypeSchema<O>;
|
|
162
|
+
export declare function isTypeSchema<T, O>(schema: any): schema is TypeSchema<O>;
|
|
163
|
+
export declare function isDeferredValueType<T>(value: ValueType<T>): value is DeferredValueType<T>;
|
|
164
|
+
export declare function resolveValueTypes<T>(valueTypes: OneOrMany<ValueType<T>>): OneOrMany<ResolvedValueType<T>>;
|
|
165
|
+
export declare function resolveValueType<T>(valueType: ValueType<T>): ResolvedValueType<T>;
|
|
166
|
+
export declare function valueTypesOrSchemasToSchemas<T, O>(valueTypesOrSchemas: OneOrMany<ValueType<O> | Schema<T, O>>): OneOrMany<Schema<T, O>>;
|
|
167
|
+
export declare function valueTypeOrSchemaToSchema<T, O>(valueTypeOrSchema: ValueType<O> | Schema<T, O>): Schema<T, O>;
|
|
156
168
|
export {};
|