@tstdl/base 0.71.88 → 0.78.0-beta2
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/.eslintrc.js +2 -4
- package/api/client/client.js +2 -12
- package/api/client/client.js.map +1 -1
- package/api/default-error-handlers.d.ts +0 -4
- package/api/default-error-handlers.js +1 -6
- package/api/default-error-handlers.js.map +1 -1
- package/api/server/gateway.js +12 -18
- package/api/server/gateway.js.map +1 -1
- package/api/server/module.d.ts +0 -4
- package/api/server/module.js +1 -12
- package/api/server/module.js.map +1 -1
- package/api/types.d.ts +8 -32
- package/api/types.js.map +1 -1
- package/container/container.js +2 -2
- package/container/container.js.map +1 -1
- package/data-structures/index.d.ts +1 -0
- package/data-structures/index.js +1 -0
- package/data-structures/index.js.map +1 -1
- package/data-structures/iterable-weak-map.d.ts +29 -0
- package/data-structures/iterable-weak-map.js +128 -0
- package/data-structures/iterable-weak-map.js.map +1 -0
- package/data-structures/multi-key-map.d.ts +12 -1
- package/data-structures/multi-key-map.js +22 -11
- package/data-structures/multi-key-map.js.map +1 -1
- package/error/custom.error.d.ts +3 -1
- package/error/custom.error.js +16 -7
- package/error/custom.error.js.map +1 -1
- package/examples/api/basic-overview.js +16 -8
- package/examples/api/basic-overview.js.map +1 -1
- package/image-service/image-service.d.ts +32 -65
- package/image-service/image-service.js +73 -15
- package/image-service/image-service.js.map +1 -1
- package/json-path/json-path.d.ts +8 -3
- package/json-path/json-path.js +24 -7
- package/json-path/json-path.js.map +1 -1
- package/module/modules/index.d.ts +0 -1
- package/module/modules/index.js +0 -1
- package/module/modules/index.js.map +1 -1
- package/openid-connect/oidc-configuration.service.js +7 -7
- package/openid-connect/oidc-configuration.service.js.map +1 -1
- package/openid-connect/oidc.service.js +7 -7
- package/openid-connect/oidc.service.js.map +1 -1
- package/package.json +3 -4
- package/process-shutdown.js +3 -2
- package/process-shutdown.js.map +1 -1
- package/reflection/decorators.js +1 -0
- package/reflection/decorators.js.map +1 -1
- package/reflection/reflection-data-map.d.ts +10 -0
- package/reflection/reflection-data-map.js +40 -0
- package/reflection/reflection-data-map.js.map +1 -0
- package/reflection/registry.d.ts +7 -7
- package/reflection/registry.js +7 -6
- package/reflection/registry.js.map +1 -1
- package/reflection/types.d.ts +1 -0
- package/reflection/utils.d.ts +6 -3
- package/reflection/utils.js +9 -35
- package/reflection/utils.js.map +1 -1
- package/schema/array-constraints/index.d.ts +2 -0
- package/{old-api/validation/validators → schema/array-constraints}/index.js +2 -1
- package/schema/array-constraints/index.js.map +1 -0
- package/schema/array-constraints/maximum-length.d.ts +11 -0
- package/schema/array-constraints/maximum-length.js +26 -0
- package/schema/array-constraints/maximum-length.js.map +1 -0
- package/schema/array-constraints/minimum-length.d.ts +11 -0
- package/schema/array-constraints/minimum-length.js +26 -0
- package/schema/array-constraints/minimum-length.js.map +1 -0
- package/schema/coercers/boolean.coercer.d.ts +9 -0
- package/schema/coercers/boolean.coercer.js +35 -0
- package/schema/coercers/boolean.coercer.js.map +1 -0
- package/schema/coercers/date.coercer.d.ts +9 -0
- package/schema/coercers/date.coercer.js +24 -0
- package/schema/coercers/date.coercer.js.map +1 -0
- package/schema/coercers/default-value.coercer.d.ts +9 -0
- package/schema/coercers/default-value.coercer.js +16 -0
- package/schema/coercers/default-value.coercer.js.map +1 -0
- package/schema/coercers/index.d.ts +7 -0
- package/schema/coercers/index.js +24 -0
- package/schema/coercers/index.js.map +1 -0
- package/schema/coercers/number.coercer.d.ts +9 -0
- package/schema/coercers/number.coercer.js +22 -0
- package/schema/coercers/number.coercer.js.map +1 -0
- package/schema/coercers/regexp.coercer.d.ts +11 -0
- package/schema/coercers/regexp.coercer.js +24 -0
- package/schema/coercers/regexp.coercer.js.map +1 -0
- package/schema/coercers/string.coercer.d.ts +9 -0
- package/schema/coercers/string.coercer.js +22 -0
- package/schema/coercers/string.coercer.js.map +1 -0
- package/schema/coercers/uint8-array.coercer.d.ts +9 -0
- package/schema/coercers/uint8-array.coercer.js +31 -0
- package/schema/coercers/uint8-array.coercer.js.map +1 -0
- package/schema/constraints/enumeration.d.ts +13 -0
- package/schema/constraints/enumeration.js +29 -0
- package/schema/constraints/enumeration.js.map +1 -0
- package/schema/constraints/generic.d.ts +22 -0
- package/schema/constraints/generic.js +32 -0
- package/schema/constraints/generic.js.map +1 -0
- package/schema/constraints/index.d.ts +12 -0
- package/schema/constraints/index.js +29 -0
- package/schema/constraints/index.js.map +1 -0
- package/schema/constraints/integer.d.ts +12 -0
- package/schema/constraints/integer.js +27 -0
- package/schema/constraints/integer.js.map +1 -0
- package/schema/constraints/length.d.ts +6 -0
- package/schema/constraints/length.js +20 -0
- package/schema/constraints/length.js.map +1 -0
- package/schema/constraints/literal.d.ts +10 -0
- package/schema/constraints/literal.js +26 -0
- package/schema/constraints/literal.js.map +1 -0
- package/schema/constraints/maximum-date.d.ts +12 -0
- package/schema/constraints/maximum-date.js +29 -0
- package/schema/constraints/maximum-date.js.map +1 -0
- package/schema/constraints/maximum-length.d.ts +12 -0
- package/schema/constraints/maximum-length.js +29 -0
- package/schema/constraints/maximum-length.js.map +1 -0
- package/schema/constraints/maximum.d.ts +12 -0
- package/schema/constraints/maximum.js +27 -0
- package/schema/constraints/maximum.js.map +1 -0
- package/schema/constraints/minimum-date.d.ts +12 -0
- package/schema/constraints/minimum-date.js +29 -0
- package/schema/constraints/minimum-date.js.map +1 -0
- package/schema/constraints/minimum-length.d.ts +12 -0
- package/schema/constraints/minimum-length.js +29 -0
- package/schema/constraints/minimum-length.js.map +1 -0
- package/schema/constraints/minimum.d.ts +12 -0
- package/schema/constraints/minimum.js +27 -0
- package/schema/constraints/minimum.js.map +1 -0
- package/schema/constraints/pattern.d.ts +13 -0
- package/schema/constraints/pattern.js +28 -0
- package/schema/constraints/pattern.js.map +1 -0
- package/schema/decorators/array.d.ts +4 -0
- package/schema/decorators/array.js +11 -0
- package/schema/decorators/array.js.map +1 -0
- package/schema/decorators/coerce.d.ts +2 -0
- package/schema/decorators/coerce.js +10 -0
- package/schema/decorators/coerce.js.map +1 -0
- package/schema/decorators/defaulted.d.ts +3 -0
- package/schema/decorators/defaulted.js +11 -0
- package/schema/decorators/defaulted.js.map +1 -0
- package/schema/decorators/index.d.ts +8 -0
- package/{old-api → schema/decorators}/index.js +8 -3
- package/schema/decorators/index.js.map +1 -0
- package/schema/decorators/nullable.d.ts +2 -0
- package/schema/decorators/nullable.js +10 -0
- package/schema/decorators/nullable.js.map +1 -0
- package/schema/decorators/optional.d.ts +2 -0
- package/schema/decorators/optional.js +10 -0
- package/schema/decorators/optional.js.map +1 -0
- package/schema/decorators/property.d.ts +6 -0
- package/schema/decorators/property.js +19 -0
- package/schema/decorators/property.js.map +1 -0
- package/schema/decorators/type.d.ts +3 -0
- package/schema/decorators/type.js +10 -0
- package/schema/decorators/type.js.map +1 -0
- package/schema/decorators/types.d.ts +18 -0
- package/schema/decorators/types.js +3 -0
- package/schema/decorators/types.js.map +1 -0
- package/schema/decorators/utils.d.ts +10 -0
- package/schema/decorators/utils.js +59 -0
- package/schema/decorators/utils.js.map +1 -0
- package/schema/index.d.ts +7 -1
- package/schema/index.js +7 -1
- package/schema/index.js.map +1 -1
- package/schema/schema.d.ts +19 -0
- package/schema/schema.error.d.ts +13 -7
- package/schema/schema.error.js +45 -13
- package/schema/schema.error.js.map +1 -1
- package/schema/schema.js +286 -0
- package/schema/schema.js.map +1 -0
- package/schema/schemas/any.d.ts +4 -8
- package/schema/schemas/any.js +9 -14
- package/schema/schemas/any.js.map +1 -1
- package/schema/schemas/array.d.ts +7 -13
- package/schema/schemas/array.js +14 -43
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/assign.d.ts +8 -0
- package/schema/schemas/assign.js +28 -0
- package/schema/schemas/assign.js.map +1 -0
- package/schema/schemas/boolean.d.ts +5 -9
- package/schema/schemas/boolean.js +11 -38
- package/schema/schemas/boolean.js.map +1 -1
- package/schema/schemas/constraint.d.ts +4 -0
- package/schema/schemas/constraint.js +14 -0
- package/schema/schemas/constraint.js.map +1 -0
- package/schema/schemas/date.d.ts +7 -11
- package/schema/schemas/date.js +18 -53
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/defaulted.d.ts +2 -15
- package/schema/schemas/defaulted.js +7 -23
- package/schema/schemas/defaulted.js.map +1 -1
- package/schema/schemas/enumeration.d.ts +6 -18
- package/schema/schemas/enumeration.js +13 -50
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/exclude.d.ts +4 -0
- package/schema/schemas/exclude.js +17 -0
- package/schema/schemas/exclude.js.map +1 -0
- package/schema/schemas/index.d.ts +5 -6
- package/schema/schemas/index.js +5 -6
- package/schema/schemas/index.js.map +1 -1
- package/schema/schemas/instance.d.ts +2 -12
- package/schema/schemas/instance.js +4 -20
- package/schema/schemas/instance.js.map +1 -1
- package/schema/schemas/literal.d.ts +4 -11
- package/schema/schemas/literal.js +13 -18
- package/schema/schemas/literal.js.map +1 -1
- package/schema/schemas/nullable.d.ts +3 -13
- package/schema/schemas/nullable.js +3 -26
- package/schema/schemas/nullable.js.map +1 -1
- package/schema/schemas/number.d.ts +7 -14
- package/schema/schemas/number.js +23 -44
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/object.d.ts +6 -34
- package/schema/schemas/object.js +8 -112
- package/schema/schemas/object.js.map +1 -1
- package/schema/schemas/optional.d.ts +3 -13
- package/schema/schemas/optional.js +3 -26
- package/schema/schemas/optional.js.map +1 -1
- package/schema/schemas/pick.d.ts +4 -0
- package/schema/schemas/pick.js +17 -0
- package/schema/schemas/pick.js.map +1 -0
- package/schema/schemas/readable-stream.d.ts +4 -9
- package/schema/schemas/readable-stream.js +9 -15
- package/schema/schemas/readable-stream.js.map +1 -1
- package/schema/schemas/record.d.ts +4 -0
- package/schema/schemas/record.js +14 -0
- package/schema/schemas/record.js.map +1 -0
- package/schema/schemas/regexp.d.ts +6 -9
- package/schema/schemas/regexp.js +10 -27
- package/schema/schemas/regexp.js.map +1 -1
- package/schema/schemas/string.d.ts +9 -13
- package/schema/schemas/string.js +34 -46
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/transform.d.ts +4 -16
- package/schema/schemas/transform.js +7 -36
- package/schema/schemas/transform.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +8 -11
- package/schema/schemas/uint8-array.js +20 -32
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/schemas/union.d.ts +5 -17
- package/schema/schemas/union.js +9 -35
- package/schema/schemas/union.js.map +1 -1
- package/schema/schemas/unknown.d.ts +4 -8
- package/schema/schemas/unknown.js +9 -14
- package/schema/schemas/unknown.js.map +1 -1
- package/schema/transformers/generic.d.ts +13 -0
- package/schema/transformers/generic.js +28 -0
- package/schema/transformers/generic.js.map +1 -0
- package/schema/transformers/index.d.ts +3 -0
- package/{old-api/endpoints → schema/transformers}/index.js +3 -1
- package/schema/transformers/index.js.map +1 -0
- package/schema/transformers/lowercase.d.ts +9 -0
- package/schema/transformers/lowercase.js +22 -0
- package/schema/transformers/lowercase.js.map +1 -0
- package/schema/transformers/trim.d.ts +9 -0
- package/schema/transformers/trim.js +22 -0
- package/schema/transformers/trim.js.map +1 -0
- package/schema/transformers/uppercase.d.ts +9 -0
- package/schema/transformers/uppercase.js +22 -0
- package/schema/transformers/uppercase.js.map +1 -0
- package/schema/types.d.ts +135 -15
- package/schema/types.js +39 -3
- package/schema/types.js.map +1 -1
- package/schema/utils/index.d.ts +2 -0
- package/{old-api/validation → schema/utils}/index.js +2 -1
- package/schema/utils/index.js.map +1 -0
- package/schema/utils/schema.d.ts +12 -0
- package/schema/utils/schema.js +78 -0
- package/schema/utils/schema.js.map +1 -0
- package/schema/utils/value-type.d.ts +4 -0
- package/schema/utils/value-type.js +35 -0
- package/schema/utils/value-type.js.map +1 -0
- package/templates/providers/file-template.provider.base.d.ts +1 -1
- package/templates/providers/file-template.provider.base.js +3 -2
- package/templates/providers/file-template.provider.base.js.map +1 -1
- package/types.d.ts +6 -3
- package/utils/enum.d.ts +1 -1
- package/utils/function/memoize.d.ts +6 -2
- package/utils/function/memoize.js +28 -20
- package/utils/function/memoize.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/index.js.map +1 -1
- package/utils/merge.d.ts +5 -0
- package/utils/merge.js +32 -0
- package/utils/merge.js.map +1 -0
- package/utils/object/dereference.js.map +1 -1
- package/utils/object/object.d.ts +4 -0
- package/utils/object/object.js +9 -2
- package/utils/object/object.js.map +1 -1
- package/utils/patterns.d.ts +1 -1
- package/utils/patterns.js +3 -3
- package/utils/patterns.js.map +1 -1
- package/utils/timing.d.ts +0 -8
- package/utils/timing.js.map +1 -1
- package/utils/type-guards.d.ts +6 -0
- package/utils/type-guards.js +16 -4
- package/utils/type-guards.js.map +1 -1
- package/instance-provider.d.ts +0 -17
- package/instance-provider.js +0 -55
- package/instance-provider.js.map +0 -1
- package/module/modules/old-web-server.module.d.ts +0 -22
- package/module/modules/old-web-server.module.js +0 -37
- package/module/modules/old-web-server.module.js.map +0 -1
- package/old-api/endpoint.d.ts +0 -5
- package/old-api/endpoint.js +0 -20
- package/old-api/endpoint.js.map +0 -1
- package/old-api/endpoints/echo.endpoint.d.ts +0 -2
- package/old-api/endpoints/echo.endpoint.js +0 -6
- package/old-api/endpoints/echo.endpoint.js.map +0 -1
- package/old-api/endpoints/index.d.ts +0 -1
- package/old-api/endpoints/index.js.map +0 -1
- package/old-api/http-api.d.ts +0 -63
- package/old-api/http-api.js +0 -269
- package/old-api/http-api.js.map +0 -1
- package/old-api/index.d.ts +0 -3
- package/old-api/index.js.map +0 -1
- package/old-api/validation/index.d.ts +0 -1
- package/old-api/validation/index.js.map +0 -1
- package/old-api/validation/types.d.ts +0 -6
- package/old-api/validation/types.js +0 -6
- package/old-api/validation/types.js.map +0 -1
- package/old-api/validation/validators/index.d.ts +0 -1
- package/old-api/validation/validators/index.js.map +0 -1
- package/old-api/validation/validators/noop.d.ts +0 -2
- package/old-api/validation/validators/noop.js +0 -8
- package/old-api/validation/validators/noop.js.map +0 -1
- package/old-api/validation/validators/superstruct.d.ts +0 -14
- package/old-api/validation/validators/superstruct.js +0 -66
- package/old-api/validation/validators/superstruct.js.map +0 -1
- package/old-api/validation/validators/yup.d.ts +0 -7
- package/old-api/validation/validators/yup.js +0 -60
- package/old-api/validation/validators/yup.js.map +0 -1
- package/schema/schema.validator.d.ts +0 -40
- package/schema/schema.validator.js +0 -75
- package/schema/schema.validator.js.map +0 -1
- package/schema/schemas/async-iterable.d.ts +0 -13
- package/schema/schemas/async-iterable.js +0 -40
- package/schema/schemas/async-iterable.js.map +0 -1
- package/schema/schemas/iterable.d.ts +0 -13
- package/schema/schemas/iterable.js +0 -40
- package/schema/schemas/iterable.js.map +0 -1
- package/schema/schemas/never.d.ts +0 -9
- package/schema/schemas/never.js +0 -22
- package/schema/schemas/never.js.map +0 -1
- package/schema/schemas/preprocess.d.ts +0 -16
- package/schema/schemas/preprocess.js +0 -35
- package/schema/schemas/preprocess.js.map +0 -1
- package/schema/schemas/refine.d.ts +0 -24
- package/schema/schemas/refine.js +0 -52
- package/schema/schemas/refine.js.map +0 -1
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.ReadableStream = exports.readableStream = void 0;
|
|
4
|
+
const decorators_1 = require("../decorators");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[schema_validator_1.test](value, options, path) {
|
|
10
|
-
return readableStreamInstanceSchema[schema_validator_1.test](value, options, path);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.ReadableStreamSchemaValidator = ReadableStreamSchemaValidator;
|
|
14
|
-
function readableStream(options) {
|
|
15
|
-
const schema = (0, types_1.schemaHelper)({
|
|
16
|
-
type: 'readableStream',
|
|
17
|
-
...options
|
|
6
|
+
function readableStream() {
|
|
7
|
+
return (0, types_1.valueSchema)({
|
|
8
|
+
type: globalThis.ReadableStream
|
|
18
9
|
});
|
|
19
|
-
return new ReadableStreamSchemaValidator(schema);
|
|
20
10
|
}
|
|
21
11
|
exports.readableStream = readableStream;
|
|
12
|
+
function ReadableStream() {
|
|
13
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(readableStream());
|
|
14
|
+
}
|
|
15
|
+
exports.ReadableStream = ReadableStream;
|
|
22
16
|
//# sourceMappingURL=readable-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";;;AACA,8CAA2E;AAE3E,oCAAuC;AAEvC,SAAgB,cAAc;IAC5B,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,UAAU,CAAC,cAAc;KAChC,CAAC,CAAC;AACL,CAAC;AAJD,wCAIC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,uDAA0C,EAAC,cAAc,EAAE,CAAC,CAAC;AACtE,CAAC;AAFD,wCAEC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Record, TypedOmit } from "../../types";
|
|
2
|
+
import type { MaybeDeferredValueTypes, ObjectSchema } from '../types';
|
|
3
|
+
export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties'>;
|
|
4
|
+
export declare function record<T extends MaybeDeferredValueTypes>(schemas: T, options?: RecordOptions): ObjectSchema<Record<any, T extends MaybeDeferredValueTypes<infer U> ? U : never>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.record = void 0;
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function record(schemas, options) {
|
|
7
|
+
return (0, types_1.objectSchema)({
|
|
8
|
+
properties: {},
|
|
9
|
+
allowUnknownProperties: schemas,
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.record = record;
|
|
14
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAoC,OAAU,EAAE,OAAuB;IAC3F,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,OAAO;QAC/B,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
[test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<RegExp>;
|
|
8
|
-
}
|
|
9
|
-
export declare function regexp(options?: SchemaOptions<RegExpSchemaDefinition>): RegExpSchemaValidator;
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
import type { Coercible } from '../types';
|
|
4
|
+
export declare type RegExpSchemaOptions = Coercible;
|
|
5
|
+
export declare function regexp(options?: RegExpSchemaOptions): Schema<globalThis.RegExp>;
|
|
6
|
+
export declare function RegExp(options?: RegExpSchemaOptions): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/regexp.js
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const type_of_1 = require("../../utils/type-of");
|
|
6
|
-
const schema_error_1 = require("../schema.error");
|
|
7
|
-
const schema_validator_1 = require("../schema.validator");
|
|
3
|
+
exports.RegExp = exports.regexp = void 0;
|
|
4
|
+
const decorators_1 = require("../decorators");
|
|
8
5
|
const types_1 = require("../types");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
return { valid: true, value: RegExp(value, 'u') };
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
return { valid: false, error: (0, schema_error_1.schemaError)(`could not coerce provided string to regular expression: ${error.message}`, path) };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return { valid: false, error: schema_error_1.SchemaError.expectedButGot('RegExp', (0, type_of_1.typeOf)(value), path) };
|
|
21
|
-
}
|
|
22
|
-
return { valid: true, value };
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.RegExpSchemaValidator = RegExpSchemaValidator;
|
|
26
|
-
function regexp(options) {
|
|
27
|
-
const schema = (0, types_1.schemaHelper)({
|
|
28
|
-
type: 'regexp',
|
|
29
|
-
...options
|
|
6
|
+
function regexp(options = {}) {
|
|
7
|
+
return (0, types_1.valueSchema)({
|
|
8
|
+
type: globalThis.RegExp,
|
|
9
|
+
coerce: options.coerce
|
|
30
10
|
});
|
|
31
|
-
return new RegExpSchemaValidator(schema);
|
|
32
11
|
}
|
|
33
12
|
exports.regexp = regexp;
|
|
13
|
+
function RegExp(options) {
|
|
14
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(regexp(options));
|
|
15
|
+
}
|
|
16
|
+
exports.RegExp = RegExp;
|
|
34
17
|
//# sourceMappingURL=regexp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";;;AACA,8CAA2E;AAG3E,oCAAuC;AAIvC,SAAgB,MAAM,CAAC,UAA+B,EAAE;IACtD,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC;AALD,wBAKC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,uDAA0C,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import type { Coercible, SchemaDefinition, SchemaOptions } from '../types';
|
|
5
|
-
export declare type StringSchemaDefinition = SchemaDefinition<'string', unknown, string> & Coercible & {
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { Coercible, ValueSchema } from '../types';
|
|
3
|
+
export declare type StringOptions = Coercible & {
|
|
6
4
|
/** trim */
|
|
7
5
|
trim?: boolean;
|
|
8
6
|
/** lowercase */
|
|
@@ -10,17 +8,15 @@ export declare type StringSchemaDefinition = SchemaDefinition<'string', unknown,
|
|
|
10
8
|
/** uppercase */
|
|
11
9
|
uppercase?: boolean;
|
|
12
10
|
/** minimum length */
|
|
13
|
-
|
|
11
|
+
minimumLength?: number;
|
|
14
12
|
/** maximum length */
|
|
15
|
-
|
|
13
|
+
maximumLength?: number;
|
|
16
14
|
/** regular expression */
|
|
17
15
|
pattern?: string | RegExp;
|
|
18
16
|
/** regular expression flags */
|
|
19
17
|
patternFlags?: string;
|
|
18
|
+
/** name for errors */
|
|
19
|
+
patternName?: string;
|
|
20
20
|
};
|
|
21
|
-
export declare
|
|
22
|
-
|
|
23
|
-
constructor(schema: StringSchemaDefinition);
|
|
24
|
-
[test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<string>;
|
|
25
|
-
}
|
|
26
|
-
export declare function string(options?: SchemaOptions<StringSchemaDefinition>): StringSchemaValidator;
|
|
21
|
+
export declare function string(options?: StringOptions): ValueSchema<string>;
|
|
22
|
+
export declare function String(options?: StringOptions): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/string.js
CHANGED
|
@@ -1,56 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.String = exports.string = void 0;
|
|
4
5
|
const type_guards_1 = require("../../utils/type-guards");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
6
|
+
const constraints_1 = require("../constraints");
|
|
7
|
+
const decorators_1 = require("../decorators");
|
|
8
|
+
const transformers_1 = require("../transformers");
|
|
7
9
|
const types_1 = require("../types");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class StringSchemaValidator extends schema_validator_1.SchemaValidator {
|
|
14
|
-
constructor(schema) {
|
|
15
|
-
const pattern = (0, type_guards_1.isRegExp)(schema.pattern) ? schema.pattern.source : schema.pattern;
|
|
16
|
-
const patternFlags = (0, type_guards_1.isRegExp)(schema.pattern) ? (schema.patternFlags ?? schema.pattern.flags) : schema.patternFlags;
|
|
17
|
-
super({ ...schema, pattern, patternFlags });
|
|
18
|
-
this.regexp = (0, type_guards_1.isDefined)(pattern) ? RegExp(pattern, patternFlags) : undefined;
|
|
10
|
+
function string(options = {}) {
|
|
11
|
+
const constraints = [];
|
|
12
|
+
const transformers = [];
|
|
13
|
+
if ((0, type_guards_1.isDefined)(options.minimumLength)) {
|
|
14
|
+
constraints.push(new constraints_1.MinimumLengthConstraint(options.minimumLength));
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!result.valid) {
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
let resultValue = result.value;
|
|
26
|
-
if (this.schema.trim == true) {
|
|
27
|
-
resultValue = resultValue.trim();
|
|
28
|
-
}
|
|
29
|
-
if (this.schema.lowercase == true) {
|
|
30
|
-
resultValue = resultValue.toLowerCase();
|
|
31
|
-
}
|
|
32
|
-
if (this.schema.uppercase == true) {
|
|
33
|
-
resultValue = resultValue.toUpperCase();
|
|
34
|
-
}
|
|
35
|
-
if ((0, type_guards_1.isDefined)(this.schema.min) && (resultValue.length < this.schema.min)) {
|
|
36
|
-
return { valid: false, error: (0, schema_error_1.schemaError)(`minimum length is ${this.schema.min} but value has ${resultValue.length}`, path) };
|
|
37
|
-
}
|
|
38
|
-
if ((0, type_guards_1.isDefined)(this.schema.max) && (resultValue.length > this.schema.max)) {
|
|
39
|
-
return { valid: false, error: (0, schema_error_1.schemaError)(`maximum length is ${this.schema.max} but value has ${resultValue.length}`, path) };
|
|
40
|
-
}
|
|
41
|
-
if ((0, type_guards_1.isDefined)(this.regexp) && !this.regexp.test(resultValue)) {
|
|
42
|
-
return { valid: false, error: (0, schema_error_1.schemaError)('pattern did not match', path) };
|
|
43
|
-
}
|
|
44
|
-
return { valid: true, value: resultValue };
|
|
16
|
+
if ((0, type_guards_1.isDefined)(options.maximumLength)) {
|
|
17
|
+
constraints.push(new constraints_1.MaximumLengthConstraint(options.maximumLength));
|
|
45
18
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
19
|
+
if ((0, type_guards_1.isDefined)(options.pattern)) {
|
|
20
|
+
const pattern = RegExp(options.pattern, options.patternFlags);
|
|
21
|
+
constraints.push(new constraints_1.PatternConstraint(pattern, options.patternName));
|
|
22
|
+
}
|
|
23
|
+
if ((0, type_guards_1.isDefined)(options.trim)) {
|
|
24
|
+
transformers.push(new transformers_1.TrimTransformer());
|
|
25
|
+
}
|
|
26
|
+
if ((0, type_guards_1.isDefined)(options.lowercase)) {
|
|
27
|
+
transformers.push(new transformers_1.LowercaseTransformer());
|
|
28
|
+
}
|
|
29
|
+
if ((0, type_guards_1.isDefined)(options.uppercase)) {
|
|
30
|
+
transformers.push(new transformers_1.UppercaseTransformer());
|
|
31
|
+
}
|
|
32
|
+
return (0, types_1.valueSchema)({
|
|
33
|
+
type: globalThis.String,
|
|
34
|
+
coerce: options.coerce,
|
|
35
|
+
valueConstraints: constraints,
|
|
36
|
+
transformers
|
|
52
37
|
});
|
|
53
|
-
return new StringSchemaValidator(schema);
|
|
54
38
|
}
|
|
55
39
|
exports.string = string;
|
|
40
|
+
function String(options) {
|
|
41
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(string(options));
|
|
42
|
+
}
|
|
43
|
+
exports.String = String;
|
|
56
44
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAAqG;AACrG,8CAA2E;AAC3E,kDAA8F;AAE9F,oCAAuC;AA4BvC,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;QACjB,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;QAC7B,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAnCD,wBAmCC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,uDAA0C,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare type Transformer<T extends SchemaDefinition, Output> = (value: SchemaOutput<T>) => Output | Promise<Output>;
|
|
6
|
-
export declare type TransformSchemaDefinition<T extends SchemaDefinition = SchemaDefinition, Output = unknown> = SchemaDefinition<'transform', SchemaInput<T>, Output> & {
|
|
7
|
-
inputSchema: T;
|
|
8
|
-
transformer: Transformer<T, Output>;
|
|
9
|
-
};
|
|
10
|
-
export declare class TransformSchemaValidator<T extends SchemaDefinition, Output> extends SchemaValidator<TransformSchemaDefinition<T, Output>> {
|
|
11
|
-
private readonly inputValidator;
|
|
12
|
-
constructor(schema: TransformSchemaDefinition<T, Output>, inputValidator: SchemaValidator<T>);
|
|
13
|
-
[test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<Output>;
|
|
14
|
-
protected [testAsync](value: unknown, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<Output>>;
|
|
15
|
-
}
|
|
16
|
-
export declare function transform<T extends SchemaDefinition, Output>(inputSchemaValidator: SchemaValidator<T>, transformer: Transformer<T, Output>, options?: SchemaOptions<TransformSchemaDefinition<T, Output>, 'inputSchema' | 'transformer'>): TransformSchemaValidator<T, Output>;
|
|
1
|
+
import type { OneOrMany } from "../../types";
|
|
2
|
+
import type { GenericTransformFunction } from '../transformers/generic';
|
|
3
|
+
import type { MaybeDeferredValueTypes, ValueSchema, ValueType } from '../types';
|
|
4
|
+
export declare function transform<T>(schema: MaybeDeferredValueTypes<T>, sourceType: OneOrMany<ValueType>, targetType: ValueType, transformFunction: GenericTransformFunction<T>): ValueSchema<T>;
|
|
@@ -1,43 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transform =
|
|
4
|
-
const
|
|
5
|
-
const schema_validator_1 = require("../schema.validator");
|
|
3
|
+
exports.transform = void 0;
|
|
4
|
+
const generic_1 = require("../transformers/generic");
|
|
6
5
|
const types_1 = require("../types");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
[schema_validator_1.test](value, options, path) {
|
|
13
|
-
const inputTestResult = this.inputValidator[schema_validator_1.test](value, options, path);
|
|
14
|
-
if (!inputTestResult.valid) {
|
|
15
|
-
return inputTestResult;
|
|
16
|
-
}
|
|
17
|
-
const transformed = this.schema.transformer(inputTestResult.value);
|
|
18
|
-
if ((0, type_guards_1.isPromise)(transformed)) {
|
|
19
|
-
throw new Error(`cannot handle async transform in sync validation. Use async instead (path: ${path.path})`);
|
|
20
|
-
}
|
|
21
|
-
return { valid: true, value: transformed };
|
|
22
|
-
}
|
|
23
|
-
async [schema_validator_1.testAsync](value, options, path) {
|
|
24
|
-
const inputTestResult = await this.inputValidator[schema_validator_1.testAsync](value, options, path);
|
|
25
|
-
if (!inputTestResult.valid) {
|
|
26
|
-
return inputTestResult;
|
|
27
|
-
}
|
|
28
|
-
const transformed = await this.schema.transformer(inputTestResult.value);
|
|
29
|
-
return { valid: true, value: transformed };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.TransformSchemaValidator = TransformSchemaValidator;
|
|
33
|
-
function transform(inputSchemaValidator, transformer, options) {
|
|
34
|
-
const schema = (0, types_1.schemaHelper)({
|
|
35
|
-
type: 'transform',
|
|
36
|
-
inputSchema: inputSchemaValidator.schema,
|
|
37
|
-
transformer,
|
|
38
|
-
...options
|
|
6
|
+
function transform(schema, sourceType, targetType, transformFunction) {
|
|
7
|
+
return (0, types_1.valueSchema)({
|
|
8
|
+
type: schema,
|
|
9
|
+
transformers: new generic_1.GenericTransformer(sourceType, targetType, transformFunction)
|
|
39
10
|
});
|
|
40
|
-
return new TransformSchemaValidator(schema, inputSchemaValidator);
|
|
41
11
|
}
|
|
42
12
|
exports.transform = transform;
|
|
13
|
+
/* decorator is in file of GenericTransformer */
|
|
43
14
|
//# sourceMappingURL=transform.js.map
|
|
@@ -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":";;;AAEA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,CAAI,MAAkC,EAAE,UAAgC,EAAE,UAAqB,EAAE,iBAA8C;IACtK,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,IAAI,4BAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AALD,8BAKC;AAED,gDAAgD"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
max?: number;
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
import type { Coercible } from '../types';
|
|
4
|
+
export declare type Uint8ArraySchemaOptions = Coercible & {
|
|
5
|
+
minimumLength?: number;
|
|
6
|
+
maximumLength?: number;
|
|
8
7
|
};
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export declare function uint8Array(options?: SchemaOptions<Uint8ArraySchemaDefinition>): Uint8ArraySchemaValidator;
|
|
8
|
+
export declare function uint8Array(options?: Uint8ArraySchemaOptions): Schema<Uint8Array>;
|
|
9
|
+
export declare function Uint8Array(options?: Uint8ArraySchemaOptions): Decorator<'property' | 'accessor'>;
|
|
@@ -1,41 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Uint8Array = exports.uint8Array = void 0;
|
|
4
4
|
const type_guards_1 = require("../../utils/type-guards");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const uint8_array_coercer_1 = require("../coercers/uint8-array.coercer");
|
|
6
|
+
const maximum_length_1 = require("../constraints/maximum-length");
|
|
7
|
+
const minimum_length_1 = require("../constraints/minimum-length");
|
|
8
|
+
const decorators_1 = require("../decorators");
|
|
7
9
|
const types_1 = require("../types");
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const instanceTestResult = uint8ArrayInstanceSchema[schema_validator_1.test](value, options, path);
|
|
13
|
-
let array;
|
|
14
|
-
if (instanceTestResult.valid) {
|
|
15
|
-
array = instanceTestResult.value;
|
|
16
|
-
}
|
|
17
|
-
else if ((this.schema.coerce ?? options.coerce) && (0, type_guards_1.isArray)(value) && value.every((v) => (0, type_guards_1.isNumber)(v) && Number.isInteger(v) && (v >= 0) && (v <= 255))) {
|
|
18
|
-
array = Uint8Array.from(value);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return instanceTestResult;
|
|
22
|
-
}
|
|
23
|
-
if ((0, type_guards_1.isDefined)(this.schema.min) && (array.byteLength < this.schema.min)) {
|
|
24
|
-
return { valid: false, error: (0, schema_error_1.schemaError)(`minimum buffer length is ${this.schema.min}`, path) };
|
|
25
|
-
}
|
|
26
|
-
if ((0, type_guards_1.isDefined)(this.schema.max) && (array.byteLength > this.schema.max)) {
|
|
27
|
-
return { valid: false, error: (0, schema_error_1.schemaError)(`maximum buffer length is ${this.schema.max}`, path) };
|
|
28
|
-
}
|
|
29
|
-
return { valid: true, value: array };
|
|
10
|
+
function uint8Array(options = {}) {
|
|
11
|
+
const constraints = [];
|
|
12
|
+
if ((0, type_guards_1.isDefined)(options.minimumLength)) {
|
|
13
|
+
constraints.push(new minimum_length_1.MinimumLengthConstraint(options.minimumLength));
|
|
30
14
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type:
|
|
36
|
-
|
|
15
|
+
if ((0, type_guards_1.isDefined)(options.maximumLength)) {
|
|
16
|
+
constraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
|
|
17
|
+
}
|
|
18
|
+
return (0, types_1.valueSchema)({
|
|
19
|
+
type: globalThis.Uint8Array,
|
|
20
|
+
coercers: (options.coerce == true) ? uint8_array_coercer_1.uint8ArrayCoercer : undefined,
|
|
21
|
+
valueConstraints: constraints
|
|
37
22
|
});
|
|
38
|
-
return new Uint8ArraySchemaValidator(schema);
|
|
39
23
|
}
|
|
40
24
|
exports.uint8Array = uint8Array;
|
|
25
|
+
function Uint8Array(options) {
|
|
26
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(uint8Array(options));
|
|
27
|
+
}
|
|
28
|
+
exports.Uint8Array = Uint8Array;
|
|
41
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":";;;AACA,
|
|
1
|
+
{"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";;;AACA,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE,8CAA2E;AAG3E,oCAAuC;AAOvC,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;QACjB,IAAI,EAAE,UAAU,CAAC,UAAU;QAC3B,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;AAhBD,gCAgBC;AAED,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,IAAA,uDAA0C,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAFD,gCAEC"}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
export declare type UnionSchemaOutput<A extends SchemaDefinition, B extends SchemaDefinition[]> = SchemaOutput<A> | SchemaOutput<B[number]>;
|
|
7
|
-
export declare type UnionSchemaDefinition<A extends SchemaDefinition, B extends SchemaDefinition[]> = SchemaDefinition<'union', UnionSchemaInput<A, B>, UnionSchemaOutput<A, B>> & {
|
|
8
|
-
schemas: [A, ...B];
|
|
9
|
-
};
|
|
10
|
-
export declare class UnionSchemaValidator<A extends SchemaDefinition, B extends SchemaDefinition[]> extends SchemaValidator<UnionSchemaDefinition<A, B>> {
|
|
11
|
-
private readonly innerSchemaTypesString;
|
|
12
|
-
readonly innerSchemas: [SchemaValidator<A>, ...SchemaValidator<B[number]>[]];
|
|
13
|
-
constructor(innerSchemas: [SchemaValidator<A>, ...SchemaValidator<B[number]>[]], schema: UnionSchemaDefinition<A, B>);
|
|
14
|
-
[test](value: unknown, options: DefinedValidationOptions, path: JsonPath): ValidationTestResult<UnionSchemaOutput<A, B>>;
|
|
15
|
-
protected [testAsync](value: unknown, options: DefinedValidationOptions, path: JsonPath): Promise<ValidationTestResult<UnionSchemaOutput<A, B>>>;
|
|
16
|
-
}
|
|
17
|
-
export declare function union<A extends SchemaValidator, B extends SchemaValidator[]>(schemas: [A, ...B], options?: SchemaOptions<UnionSchemaDefinition<A['schema'], B[number]['schema'][]>, 'schemas'>): UnionSchemaValidator<A['schema'], B[number]['schema'][]>;
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { MaybeDeferredValueTypes, ValueSchema } from '../types';
|
|
3
|
+
export declare type UnionTypeHelper<T extends MaybeDeferredValueTypes> = T extends MaybeDeferredValueTypes<infer U> ? U : never;
|
|
4
|
+
export declare function union<T extends [MaybeDeferredValueTypes, ...MaybeDeferredValueTypes[]]>(...schemas: T): ValueSchema<UnionTypeHelper<T[number]>>;
|
|
5
|
+
export declare function Union(...schemas: [MaybeDeferredValueTypes, ...MaybeDeferredValueTypes[]]): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/union.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const schema_validator_1 = require("../schema.validator");
|
|
3
|
+
exports.Union = exports.union = void 0;
|
|
4
|
+
const decorators_1 = require("../decorators");
|
|
6
5
|
const types_1 = require("../types");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.innerSchemas = innerSchemas;
|
|
11
|
-
this.innerSchemaTypesString = this.innerSchemas.map((innerSchema) => innerSchema.schema.type).join(', ');
|
|
12
|
-
}
|
|
13
|
-
[schema_validator_1.test](value, options, path) {
|
|
14
|
-
for (const schema of this.innerSchemas) {
|
|
15
|
-
const result = schema.test(value, options);
|
|
16
|
-
if (result.valid) {
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return { valid: false, error: new schema_error_1.SchemaError(`Value did not match any of the allowed schemas (${this.innerSchemaTypesString}).`, { path }) };
|
|
21
|
-
}
|
|
22
|
-
async [schema_validator_1.testAsync](value, options, path) {
|
|
23
|
-
for (const schema of this.innerSchemas) {
|
|
24
|
-
const result = await schema.testAsync(value, options);
|
|
25
|
-
if (result.valid) {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return { valid: false, error: new schema_error_1.SchemaError(`Value did not match any of the allowed schemas (${this.innerSchemaTypesString}).`, { path }) };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.UnionSchemaValidator = UnionSchemaValidator;
|
|
33
|
-
function union(schemas, options) {
|
|
34
|
-
const schema = (0, types_1.schemaHelper)({
|
|
35
|
-
type: 'union',
|
|
36
|
-
schemas: schemas.map((innerSchema) => innerSchema.schema),
|
|
37
|
-
...options
|
|
6
|
+
function union(...schemas) {
|
|
7
|
+
return (0, types_1.valueSchema)({
|
|
8
|
+
type: schemas
|
|
38
9
|
});
|
|
39
|
-
return new UnionSchemaValidator(schemas, schema);
|
|
40
10
|
}
|
|
41
11
|
exports.union = union;
|
|
12
|
+
function Union(...schemas) {
|
|
13
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(union(...schemas));
|
|
14
|
+
}
|
|
15
|
+
exports.Union = Union;
|
|
42
16
|
//# sourceMappingURL=union.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";;;AACA,8CAA2E;AAE3E,oCAAuC;AAIvC,SAAgB,KAAK,CAAoE,GAAG,OAAU;IACpG,OAAO,IAAA,mBAAW,EAAC;QACjB,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;AACL,CAAC;AAJD,sBAIC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAgE;IACvF,OAAO,IAAA,uDAA0C,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC;AAFD,sBAEC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
export declare class UnknownSchemaValidator extends SchemaValidator<UnknownSchemaDefinition> {
|
|
6
|
-
[test](value: unknown): ValidationTestResult<unknown>;
|
|
7
|
-
}
|
|
8
|
-
export declare function unknown(options?: SchemaOptions<UnknownSchemaDefinition>): UnknownSchemaValidator;
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { ValueSchema } from '../types';
|
|
3
|
+
export declare function unknown(): ValueSchema<unknown>;
|
|
4
|
+
export declare function Unknwon(): Decorator<'property' | 'accessor'>;
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
4
|
+
exports.Unknwon = exports.unknown = void 0;
|
|
5
|
+
const decorators_1 = require("../decorators");
|
|
5
6
|
const types_1 = require("../types");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return { valid: true, value };
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.UnknownSchemaValidator = UnknownSchemaValidator;
|
|
12
|
-
function unknown(options) {
|
|
13
|
-
const schema = (0, types_1.schemaHelper)({
|
|
14
|
-
type: 'unknown',
|
|
15
|
-
...options
|
|
16
|
-
});
|
|
17
|
-
return new UnknownSchemaValidator(schema);
|
|
7
|
+
function unknown() {
|
|
8
|
+
return (0, types_1.valueSchema)({ type: 'any' });
|
|
18
9
|
}
|
|
19
10
|
exports.unknown = unknown;
|
|
11
|
+
function Unknwon() {
|
|
12
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromValueType)(unknown());
|
|
13
|
+
}
|
|
14
|
+
exports.Unknwon = Unknwon;
|
|
20
15
|
//# sourceMappingURL=unknown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAA2E;AAE3E,oCAAuC;AAEvC,SAAgB,OAAO;IACrB,OAAO,IAAA,mBAAW,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO;IACrB,OAAO,IAAA,uDAA0C,EAAC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC;AAFD,0BAEC"}
|