@tstdl/base 0.71.89 → 0.78.0-beta10
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 +15 -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 +15 -36
- package/api/types.js.map +1 -1
- package/container/container.js +2 -2
- package/container/container.js.map +1 -1
- package/container/resolve-chain.d.ts +5 -5
- package/container/resolve-chain.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/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/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/http/client/adapters/utils.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/mail/template-providers/file-mail-template.provider.js +2 -2
- package/mail/template-providers/file-mail-template.provider.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 +2 -4
- package/process-shutdown.js +3 -2
- package/process-shutdown.js.map +1 -1
- package/promise/deferred-promise.d.ts +2 -15
- package/promise/deferred-promise.js +5 -10
- package/promise/deferred-promise.js.map +1 -1
- package/promise/lazy-promise.d.ts +11 -0
- package/promise/lazy-promise.js +31 -0
- package/promise/lazy-promise.js.map +1 -0
- 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 +15 -15
- 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 +26 -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 +5 -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 +4 -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 +22 -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 +11 -0
- package/schema/decorators/utils.js +55 -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 +20 -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 +282 -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 +9 -13
- package/schema/schemas/array.js +13 -43
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/assign.d.ts +8 -0
- package/schema/schemas/assign.js +27 -0
- package/schema/schemas/assign.js.map +1 -0
- package/schema/schemas/boolean.d.ts +5 -9
- package/schema/schemas/boolean.js +10 -38
- package/schema/schemas/boolean.js.map +1 -1
- package/schema/schemas/constraint.d.ts +4 -0
- package/schema/schemas/constraint.js +13 -0
- package/schema/schemas/constraint.js.map +1 -0
- package/schema/schemas/date.d.ts +7 -11
- package/schema/schemas/date.js +17 -53
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/defaulted.d.ts +4 -15
- package/schema/schemas/defaulted.js +6 -23
- package/schema/schemas/defaulted.js.map +1 -1
- package/schema/schemas/enumeration.d.ts +6 -18
- package/schema/schemas/enumeration.js +12 -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 -5
- package/schema/schemas/index.js +5 -5
- 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 +12 -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 +25 -44
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/object.d.ts +5 -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 -16
- package/schema/schemas/readable-stream.js.map +1 -1
- package/schema/schemas/record.d.ts +5 -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 +33 -46
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/transform.d.ts +5 -16
- package/schema/schemas/transform.js +5 -36
- package/schema/schemas/transform.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +7 -11
- package/schema/schemas/uint8-array.js +20 -32
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/schemas/union.d.ts +10 -17
- package/schema/schemas/union.js +11 -36
- 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 +155 -17
- package/schema/types.js +74 -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 +13 -0
- package/schema/utils/schema.js +74 -0
- package/schema/utils/schema.js.map +1 -0
- package/schema/utils/value-type.d.ts +5 -0
- package/schema/utils/value-type.js +39 -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/templates/providers/file-template.provider.js.map +1 -1
- package/types.d.ts +8 -4
- 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/compression.d.ts +13 -13
- package/utils/compression.js +2 -1
- package/utils/compression.js.map +1 -1
- package/utils/encoding.js +1 -1
- package/utils/encoding.js.map +1 -1
- 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/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/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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Trim = exports.TrimTransformer = void 0;
|
|
5
|
+
const decorators_1 = require("../decorators");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class TrimTransformer extends types_1.SchemaValueTransformer {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.sourceType = String;
|
|
11
|
+
this.targetType = String;
|
|
12
|
+
}
|
|
13
|
+
transform(value) {
|
|
14
|
+
return { success: true, value: value.trim() };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.TrimTransformer = TrimTransformer;
|
|
18
|
+
function Trim() {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new TrimTransformer(), { schema: (0, types_1.typeSchema)(String) });
|
|
20
|
+
}
|
|
21
|
+
exports.Trim = Trim;
|
|
22
|
+
//# sourceMappingURL=trim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Decorator } from "../../reflection";
|
|
2
|
+
import type { TransformResult } from '../types';
|
|
3
|
+
import { SchemaValueTransformer } from '../types';
|
|
4
|
+
export declare class UppercaseTransformer extends SchemaValueTransformer<string, string, string> {
|
|
5
|
+
readonly sourceType: StringConstructor;
|
|
6
|
+
readonly targetType: StringConstructor;
|
|
7
|
+
transform(value: string): TransformResult<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function Uppercase(): Decorator<'property' | 'accessor'>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Uppercase = exports.UppercaseTransformer = void 0;
|
|
5
|
+
const decorators_1 = require("../decorators");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class UppercaseTransformer extends types_1.SchemaValueTransformer {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.sourceType = String;
|
|
11
|
+
this.targetType = String;
|
|
12
|
+
}
|
|
13
|
+
transform(value) {
|
|
14
|
+
return { success: true, value: value.toUpperCase() };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.UppercaseTransformer = UppercaseTransformer;
|
|
18
|
+
function Uppercase() {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new UppercaseTransformer(), { schema: (0, types_1.typeSchema)(String) });
|
|
20
|
+
}
|
|
21
|
+
exports.Uppercase = Uppercase;
|
|
22
|
+
//# sourceMappingURL=uppercase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,30 +1,168 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare type
|
|
1
|
+
import type { JsonPath } from "../json-path/json-path";
|
|
2
|
+
import type { AbstractConstructor, OneOrMany, Record, Type, TypedOmit } from "../types";
|
|
3
|
+
import type { NormalizedSchema, Schema } from './schema';
|
|
4
|
+
import type { SchemaError } from './schema.error';
|
|
5
|
+
declare const schemaOutputTypeSymbol: unique symbol;
|
|
6
|
+
export declare type SchemaFactoryFunction<T extends Record, O = T> = (data: T) => NormalizeValueType<O>;
|
|
7
|
+
export declare type SchemaFactory<T extends Record, O = T> = {
|
|
8
|
+
type: Type<T>;
|
|
9
|
+
builder?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
type?: undefined;
|
|
12
|
+
builder: SchemaFactoryFunction<T, O>;
|
|
13
|
+
};
|
|
14
|
+
export declare type ObjectSchemaProperties<T extends Record> = {
|
|
15
|
+
[K in keyof T]-?: OneOrMany<Schema<any, T[K]>>;
|
|
16
|
+
};
|
|
17
|
+
export declare type NormalizedObjectSchemaProperties<T> = {
|
|
18
|
+
[K in keyof T]-?: Schema<any, T[K]>;
|
|
19
|
+
};
|
|
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
|
+
export declare type ObjectSchema<T extends Record = any, O extends Record = T> = {
|
|
22
|
+
[schemaOutputTypeSymbol]?: O;
|
|
23
|
+
sourceType?: ValueType;
|
|
24
|
+
factory?: SchemaFactory<T, O>;
|
|
25
|
+
properties: ObjectSchemaProperties<T>;
|
|
26
|
+
mask?: boolean;
|
|
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>;
|
|
34
|
+
};
|
|
35
|
+
export declare type ValueSchema<T = unknown, O = T> = {
|
|
36
|
+
[schemaOutputTypeSymbol]?: O;
|
|
37
|
+
schema: OneOrMany<Schema<T, O>>;
|
|
38
|
+
array?: boolean;
|
|
39
|
+
optional?: boolean;
|
|
40
|
+
nullable?: boolean;
|
|
41
|
+
/** use default coercers */
|
|
42
|
+
coerce?: boolean;
|
|
43
|
+
/** custom coercers */
|
|
44
|
+
coercers?: OneOrMany<SchemaValueCoercer>;
|
|
45
|
+
transformers?: OneOrMany<SchemaValueTransformer>;
|
|
46
|
+
arrayConstraints?: OneOrMany<SchemaArrayConstraint>;
|
|
47
|
+
valueConstraints?: OneOrMany<SchemaValueConstraint>;
|
|
48
|
+
};
|
|
49
|
+
export declare type NormalizedObjectSchema<T extends Record = any, O extends Record = T> = {
|
|
50
|
+
[schemaOutputTypeSymbol]?: O;
|
|
51
|
+
factory?: SchemaFactory<T, O>;
|
|
52
|
+
properties: NormalizedObjectSchemaProperties<T>;
|
|
53
|
+
mask?: boolean;
|
|
54
|
+
allowUnknownProperties: Set<Schema>;
|
|
55
|
+
};
|
|
56
|
+
export declare type NormalizedValueSchema<T = any, O = T> = {
|
|
57
|
+
[schemaOutputTypeSymbol]?: O;
|
|
58
|
+
schema: Set<Schema<T, O>>;
|
|
59
|
+
array: boolean;
|
|
60
|
+
optional: boolean;
|
|
61
|
+
nullable: boolean;
|
|
62
|
+
coerce: boolean;
|
|
63
|
+
coercers: Map<ValueType, SchemaValueCoercer[]>;
|
|
64
|
+
transformers: readonly SchemaValueTransformer<any, any, any>[];
|
|
65
|
+
arrayConstraints: readonly SchemaArrayConstraint[];
|
|
66
|
+
valueConstraints: readonly SchemaValueConstraint[];
|
|
67
|
+
};
|
|
68
|
+
export declare type SchemaContext = {
|
|
69
|
+
schema: NormalizedSchema;
|
|
70
|
+
options: SchemaTestOptions;
|
|
71
|
+
};
|
|
72
|
+
export declare type ConstraintContext = SchemaContext;
|
|
73
|
+
export declare type TransformerContext = SchemaContext;
|
|
74
|
+
export declare type CoercerContext = SchemaContext;
|
|
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;
|
|
15
83
|
export declare type Coercible = {
|
|
84
|
+
coerce?: boolean;
|
|
85
|
+
};
|
|
86
|
+
export declare const primitiveConstructors: ValueType[];
|
|
87
|
+
export declare const primitiveConstructorSet: Set<ValueType<any>>;
|
|
88
|
+
export declare abstract class SchemaArrayConstraint {
|
|
89
|
+
abstract validate(value: readonly unknown[], path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
90
|
+
}
|
|
91
|
+
export declare type OptionKeys<T extends Record> = readonly (keyof T)[];
|
|
92
|
+
export declare abstract class SchemaValueConstraint {
|
|
93
|
+
abstract readonly suitableTypes: OneOrMany<ValueType>;
|
|
94
|
+
abstract readonly expects: OneOrMany<string>;
|
|
95
|
+
abstract validate(value: unknown, path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
96
|
+
}
|
|
97
|
+
export declare abstract class SchemaValueTransformer<T = any, O = T, TransformOutput = O> {
|
|
98
|
+
abstract readonly sourceType: OneOrMany<ValueType<T>>;
|
|
99
|
+
abstract readonly targetType: ValueType<TransformOutput>;
|
|
100
|
+
abstract transform(value: O, path: JsonPath, context: TransformerContext): TransformResult<TransformOutput>;
|
|
101
|
+
}
|
|
102
|
+
export declare abstract class SchemaValueCoercer {
|
|
103
|
+
abstract readonly sourceType: OneOrMany<ValueType>;
|
|
104
|
+
abstract readonly targetType: ValueType;
|
|
105
|
+
abstract coerce(value: unknown, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
106
|
+
}
|
|
107
|
+
export declare type SchemaTestOptions = {
|
|
16
108
|
/**
|
|
17
109
|
* try to convert wrong input into desired output.
|
|
18
110
|
* Can be specified on definition and validation. If specified on both, definition has higher priority
|
|
19
111
|
*/
|
|
20
112
|
coerce?: boolean;
|
|
21
|
-
};
|
|
22
|
-
export declare type Maskable = {
|
|
23
113
|
/**
|
|
24
114
|
* remove unspecified fields on input data instead of raising an error.
|
|
25
115
|
* Can be specified on definition and validation. If specified on both, definition has higher priority
|
|
26
116
|
*/
|
|
27
117
|
mask?: boolean;
|
|
28
118
|
};
|
|
29
|
-
export declare
|
|
119
|
+
export declare type SchemaTestResult<T> = {
|
|
120
|
+
valid: true;
|
|
121
|
+
value: T;
|
|
122
|
+
error?: undefined;
|
|
123
|
+
} | {
|
|
124
|
+
valid: false;
|
|
125
|
+
value?: undefined;
|
|
126
|
+
error: SchemaError;
|
|
127
|
+
};
|
|
128
|
+
export declare type ConstraintResult = {
|
|
129
|
+
valid: true;
|
|
130
|
+
error?: undefined;
|
|
131
|
+
} | {
|
|
132
|
+
valid: false;
|
|
133
|
+
error: SchemaError;
|
|
134
|
+
};
|
|
135
|
+
export declare type CoerceResult = {
|
|
136
|
+
success: true;
|
|
137
|
+
value: any;
|
|
138
|
+
error?: undefined;
|
|
139
|
+
} | {
|
|
140
|
+
success: false;
|
|
141
|
+
value?: undefined;
|
|
142
|
+
error: SchemaError;
|
|
143
|
+
};
|
|
144
|
+
export declare type TransformResult<T> = {
|
|
145
|
+
success: true;
|
|
146
|
+
value: T;
|
|
147
|
+
error?: undefined;
|
|
148
|
+
} | {
|
|
149
|
+
success: false;
|
|
150
|
+
value?: undefined;
|
|
151
|
+
error: SchemaError;
|
|
152
|
+
};
|
|
153
|
+
export declare function objectSchema<T, O = T>(schema: ObjectSchema<T, O>): ObjectSchema<T, O>;
|
|
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>;
|
|
30
168
|
export {};
|
package/schema/types.js
CHANGED
|
@@ -1,8 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
4
|
+
exports.valueTypeOrSchemaToSchema = exports.valueTypesOrSchemasToSchemas = exports.resolveValueType = exports.resolveValueTypes = exports.isDeferredValueType = exports.isTypeSchema = exports.isValueSchema = exports.isObjectSchema = exports.isSchema = exports.typeSchema = exports.valueSchema = exports.objectSchema = exports.SchemaValueCoercer = exports.SchemaValueTransformer = exports.SchemaValueConstraint = exports.SchemaArrayConstraint = exports.primitiveConstructorSet = exports.primitiveConstructors = void 0;
|
|
5
|
+
const type_guards_1 = require("../utils/type-guards");
|
|
6
|
+
exports.primitiveConstructors = [String, Number, Boolean, Symbol, BigInt, Function, 'undefined', 'null'];
|
|
7
|
+
exports.primitiveConstructorSet = new Set(exports.primitiveConstructors);
|
|
8
|
+
class SchemaArrayConstraint {
|
|
9
|
+
}
|
|
10
|
+
exports.SchemaArrayConstraint = SchemaArrayConstraint;
|
|
11
|
+
class SchemaValueConstraint {
|
|
12
|
+
}
|
|
13
|
+
exports.SchemaValueConstraint = SchemaValueConstraint;
|
|
14
|
+
class SchemaValueTransformer {
|
|
15
|
+
}
|
|
16
|
+
exports.SchemaValueTransformer = SchemaValueTransformer;
|
|
17
|
+
class SchemaValueCoercer {
|
|
18
|
+
}
|
|
19
|
+
exports.SchemaValueCoercer = SchemaValueCoercer;
|
|
20
|
+
function objectSchema(schema) {
|
|
5
21
|
return schema;
|
|
6
22
|
}
|
|
7
|
-
exports.
|
|
23
|
+
exports.objectSchema = objectSchema;
|
|
24
|
+
function valueSchema(schema, options) {
|
|
25
|
+
return { schema, ...options };
|
|
26
|
+
}
|
|
27
|
+
exports.valueSchema = valueSchema;
|
|
28
|
+
function typeSchema(type) {
|
|
29
|
+
return { type };
|
|
30
|
+
}
|
|
31
|
+
exports.typeSchema = typeSchema;
|
|
32
|
+
function isSchema(value) {
|
|
33
|
+
return isObjectSchema(value) || isValueSchema(value) || isTypeSchema(value);
|
|
34
|
+
}
|
|
35
|
+
exports.isSchema = isSchema;
|
|
36
|
+
function isObjectSchema(schema) {
|
|
37
|
+
return (0, type_guards_1.isObject)(schema?.properties);
|
|
38
|
+
}
|
|
39
|
+
exports.isObjectSchema = isObjectSchema;
|
|
40
|
+
function isValueSchema(schema) {
|
|
41
|
+
return (0, type_guards_1.isObject)(schema) && (0, type_guards_1.isDefined)(schema?.schema);
|
|
42
|
+
}
|
|
43
|
+
exports.isValueSchema = isValueSchema;
|
|
44
|
+
function isTypeSchema(schema) {
|
|
45
|
+
return (0, type_guards_1.isObject)(schema) && (0, type_guards_1.isFunction)(schema?.type);
|
|
46
|
+
}
|
|
47
|
+
exports.isTypeSchema = isTypeSchema;
|
|
48
|
+
function isDeferredValueType(value) {
|
|
49
|
+
return (0, type_guards_1.isObject)(value) && (0, type_guards_1.isFunction)(value.deferred);
|
|
50
|
+
}
|
|
51
|
+
exports.isDeferredValueType = isDeferredValueType;
|
|
52
|
+
function resolveValueTypes(valueTypes) {
|
|
53
|
+
if ((0, type_guards_1.isArray)(valueTypes)) {
|
|
54
|
+
return valueTypes.flatMap((valueType) => resolveValueTypes(valueType));
|
|
55
|
+
}
|
|
56
|
+
return resolveValueType(valueTypes);
|
|
57
|
+
}
|
|
58
|
+
exports.resolveValueTypes = resolveValueTypes;
|
|
59
|
+
function resolveValueType(valueType) {
|
|
60
|
+
return isDeferredValueType(valueType)
|
|
61
|
+
? resolveValueType(valueType.deferred())
|
|
62
|
+
: valueType;
|
|
63
|
+
}
|
|
64
|
+
exports.resolveValueType = resolveValueType;
|
|
65
|
+
function valueTypesOrSchemasToSchemas(valueTypesOrSchemas) {
|
|
66
|
+
if ((0, type_guards_1.isArray)(valueTypesOrSchemas)) {
|
|
67
|
+
return valueTypesOrSchemas.map(valueTypeOrSchemaToSchema);
|
|
68
|
+
}
|
|
69
|
+
return valueTypeOrSchemaToSchema(valueTypesOrSchemas);
|
|
70
|
+
}
|
|
71
|
+
exports.valueTypesOrSchemasToSchemas = valueTypesOrSchemasToSchemas;
|
|
72
|
+
function valueTypeOrSchemaToSchema(valueTypeOrSchema) {
|
|
73
|
+
if (isSchema(valueTypeOrSchema)) {
|
|
74
|
+
return valueTypeOrSchema;
|
|
75
|
+
}
|
|
76
|
+
return typeSchema(valueTypeOrSchema);
|
|
77
|
+
}
|
|
78
|
+
exports.valueTypeOrSchemaToSchema = valueTypeOrSchemaToSchema;
|
|
8
79
|
//# sourceMappingURL=types.js.map
|
package/schema/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/schema/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/schema/types.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AAIjD,sDAA+E;AAgHlE,QAAA,qBAAqB,GAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAwC,EAAE,MAAwC,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAClL,QAAA,uBAAuB,GAAG,IAAI,GAAG,CAAC,6BAAqB,CAAC,CAAC;AAEtE,MAAsB,qBAAqB;CAE1C;AAFD,sDAEC;AAID,MAAsB,qBAAqB;CAK1C;AALD,sDAKC;AAED,MAAsB,sBAAsB;CAK3C;AALD,wDAKC;AAED,MAAsB,kBAAkB;CAKvC;AALD,gDAKC;AAgCD,SAAgB,YAAY,CAAW,MAA0B;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC;AAFD,oCAEC;AAED,SAAgB,WAAW,CAAW,MAA+B,EAAE,OAAgD;IACrH,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;AAChC,CAAC;AAFD,kCAEC;AAED,SAAgB,UAAU,CAAI,IAAkB;IAC9C,OAAO,EAAE,IAAI,EAAuC,CAAC;AACvD,CAAC;AAFD,gCAEC;AAED,SAAgB,QAAQ,CAAqC,KAAU;IACrE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,YAAY,CA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CAAC,CAAC;KAC3D;IAED,OAAO,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;AACxD,CAAC;AAND,oEAMC;AAED,SAAgB,yBAAyB,CAAO,iBAA8C;IAC5F,IAAI,QAAQ,CAAO,iBAAiB,CAAC,EAAE;QACrC,OAAO,iBAAiB,CAAC;KAC1B;IAED,OAAO,UAAU,CAAC,iBAAiB,CAAkB,CAAC;AACxD,CAAC;AAND,8DAMC"}
|
|
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./schema"), exports);
|
|
18
|
+
__exportStar(require("./value-type"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/schema/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NormalizedSchema, Schema } from '../schema';
|
|
2
|
+
import type { NormalizedObjectSchema, NormalizedTypeSchema, NormalizedValueSchema, ObjectSchema, TypeSchema, ValueSchema } from '../types';
|
|
3
|
+
export declare const normalizeSchema: typeof _normalizeSchema;
|
|
4
|
+
export declare const normalizeObjectSchema: typeof _normalizeObjectSchema;
|
|
5
|
+
export declare const normalizeValueSchema: typeof _normalizeValueSchema;
|
|
6
|
+
export declare const normalizeTypeSchema: typeof _normalizeTypeSchema;
|
|
7
|
+
export declare const getArrayItemSchema: typeof _getArrayItemSchema;
|
|
8
|
+
declare function _normalizeSchema<T, O>(schema: Schema<T, O>): NormalizedSchema<T, O>;
|
|
9
|
+
declare function _normalizeObjectSchema<T, O>(schema: ObjectSchema<T, O>): NormalizedObjectSchema<T, O>;
|
|
10
|
+
declare function _normalizeValueSchema<T, O>(schema: ValueSchema<T, O>): NormalizedValueSchema<T, O>;
|
|
11
|
+
declare function _normalizeTypeSchema<T>(schema: TypeSchema<T>): NormalizedTypeSchema<T>;
|
|
12
|
+
declare function _getArrayItemSchema<T, O>(schema: ValueSchema<T, O>): ValueSchema<T, O>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArrayItemSchema = exports.normalizeTypeSchema = exports.normalizeValueSchema = exports.normalizeObjectSchema = exports.normalizeSchema = void 0;
|
|
4
|
+
const array_1 = require("../../utils/array/array");
|
|
5
|
+
const memoize_1 = require("../../utils/function/memoize");
|
|
6
|
+
const object_1 = require("../../utils/object/object");
|
|
7
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
exports.normalizeSchema = (0, memoize_1.memoizeSingle)(_normalizeSchema, { weak: true });
|
|
10
|
+
exports.normalizeObjectSchema = (0, memoize_1.memoizeSingle)(_normalizeObjectSchema, { weak: true });
|
|
11
|
+
exports.normalizeValueSchema = (0, memoize_1.memoizeSingle)(_normalizeValueSchema, { weak: true });
|
|
12
|
+
exports.normalizeTypeSchema = (0, memoize_1.memoizeSingle)(_normalizeTypeSchema, { weak: true });
|
|
13
|
+
exports.getArrayItemSchema = (0, memoize_1.memoizeSingle)(_getArrayItemSchema, { weak: true });
|
|
14
|
+
function _normalizeSchema(schema) {
|
|
15
|
+
if ((0, types_1.isObjectSchema)(schema)) {
|
|
16
|
+
return (0, exports.normalizeObjectSchema)(schema);
|
|
17
|
+
}
|
|
18
|
+
if ((0, types_1.isValueSchema)(schema)) {
|
|
19
|
+
return (0, exports.normalizeValueSchema)(schema);
|
|
20
|
+
}
|
|
21
|
+
if ((0, types_1.isTypeSchema)(schema)) {
|
|
22
|
+
return (0, exports.normalizeTypeSchema)(schema);
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Unsupported schema.');
|
|
25
|
+
}
|
|
26
|
+
function _normalizeObjectSchema(schema) {
|
|
27
|
+
const normalizedSchema = {
|
|
28
|
+
factory: schema.factory,
|
|
29
|
+
properties: (0, object_1.mapObjectValues)(schema.properties, (propertyValueType) => ((0, type_guards_1.isArray)(propertyValueType) ? (0, types_1.valueSchema)(propertyValueType) : propertyValueType)),
|
|
30
|
+
mask: schema.mask,
|
|
31
|
+
allowUnknownProperties: new Set((0, array_1.toArray)(schema.allowUnknownProperties ?? []).map(types_1.valueTypeOrSchemaToSchema))
|
|
32
|
+
};
|
|
33
|
+
return normalizedSchema;
|
|
34
|
+
}
|
|
35
|
+
function _normalizeValueSchema(schema) {
|
|
36
|
+
const normalizedValueSchema = {
|
|
37
|
+
schema: new Set((0, array_1.toArray)(schema.schema)),
|
|
38
|
+
array: schema.array ?? false,
|
|
39
|
+
optional: schema.optional ?? false,
|
|
40
|
+
nullable: schema.nullable ?? false,
|
|
41
|
+
coerce: schema.coerce ?? false,
|
|
42
|
+
coercers: new Map(),
|
|
43
|
+
transformers: (0, array_1.toArray)(schema.transformers ?? []),
|
|
44
|
+
arrayConstraints: (0, array_1.toArray)(schema.arrayConstraints ?? []),
|
|
45
|
+
valueConstraints: (0, array_1.toArray)(schema.valueConstraints ?? [])
|
|
46
|
+
};
|
|
47
|
+
for (const coercer of (0, array_1.toArray)(schema.coercers ?? [])) {
|
|
48
|
+
for (const sourceType of (0, array_1.toArray)(coercer.sourceType)) {
|
|
49
|
+
if (!normalizedValueSchema.coercers.has(sourceType)) {
|
|
50
|
+
normalizedValueSchema.coercers.set(sourceType, []);
|
|
51
|
+
}
|
|
52
|
+
normalizedValueSchema.coercers.get(sourceType).push(coercer);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return normalizedValueSchema;
|
|
56
|
+
}
|
|
57
|
+
function _normalizeTypeSchema(schema) {
|
|
58
|
+
const normalizedSchema = {
|
|
59
|
+
foo: (0, types_1.resolveValueType)(schema.type)
|
|
60
|
+
};
|
|
61
|
+
return normalizedSchema;
|
|
62
|
+
}
|
|
63
|
+
function _getArrayItemSchema(schema) {
|
|
64
|
+
const itemSchema = {
|
|
65
|
+
schema: schema.schema,
|
|
66
|
+
array: false,
|
|
67
|
+
optional: false,
|
|
68
|
+
nullable: false,
|
|
69
|
+
transformers: schema.transformers,
|
|
70
|
+
valueConstraints: schema.valueConstraints
|
|
71
|
+
};
|
|
72
|
+
return itemSchema;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../source/schema/utils/schema.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,0DAAyD;AACzD,sDAAwD;AACxD,yDAA8C;AAG9C,oCAAiI;AAEpH,QAAA,eAAe,GAAG,IAAA,uBAAa,EAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,QAAA,qBAAqB,GAAG,IAAA,uBAAa,EAAC,sBAAsB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9E,QAAA,oBAAoB,GAAG,IAAA,uBAAa,EAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5E,QAAA,mBAAmB,GAAG,IAAA,uBAAa,EAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1E,QAAA,kBAAkB,GAAG,IAAA,uBAAa,EAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAGrF,SAAS,gBAAgB,CAAO,MAAoB;IAClD,IAAI,IAAA,sBAAc,EAAC,MAAM,CAAC,EAAE;QAC1B,OAAO,IAAA,6BAAqB,EAAC,MAAM,C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import type { ResolvedValueType, ValueType } from '../types';
|
|
3
|
+
export declare function getValueType(value: unknown): ResolvedValueType<any>;
|
|
4
|
+
export declare function getValueTypeName(valueType: ValueType): string;
|
|
5
|
+
export declare function getSchemaTypeNames(schema: Schema): string[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSchemaTypeNames = exports.getValueTypeName = exports.getValueType = void 0;
|
|
4
|
+
const array_1 = require("../../utils/array/array");
|
|
5
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
function getValueType(value) {
|
|
8
|
+
if ((0, type_guards_1.isUndefined)(value)) {
|
|
9
|
+
return 'undefined';
|
|
10
|
+
}
|
|
11
|
+
if ((0, type_guards_1.isNull)(value)) {
|
|
12
|
+
return 'null';
|
|
13
|
+
}
|
|
14
|
+
return value.constructor;
|
|
15
|
+
}
|
|
16
|
+
exports.getValueType = getValueType;
|
|
17
|
+
function getValueTypeName(valueType) {
|
|
18
|
+
const resolvedValueType = (0, types_1.resolveValueType)(valueType);
|
|
19
|
+
return (0, type_guards_1.isString)(resolvedValueType)
|
|
20
|
+
? resolvedValueType
|
|
21
|
+
: resolvedValueType.name;
|
|
22
|
+
}
|
|
23
|
+
exports.getValueTypeName = getValueTypeName;
|
|
24
|
+
function getSchemaTypeNames(schema) {
|
|
25
|
+
if ((0, types_1.isTypeSchema)(schema)) {
|
|
26
|
+
const name = getValueTypeName(schema.type);
|
|
27
|
+
return [name];
|
|
28
|
+
}
|
|
29
|
+
if ((0, types_1.isObjectSchema)(schema)) {
|
|
30
|
+
const name = getValueTypeName(schema.sourceType ?? Object);
|
|
31
|
+
return [name];
|
|
32
|
+
}
|
|
33
|
+
if ((0, types_1.isValueSchema)(schema)) {
|
|
34
|
+
return [...new Set((0, array_1.toArray)(schema.schema).flatMap(getSchemaTypeNames))];
|
|
35
|
+
}
|
|
36
|
+
throw new Error('Unsupported schema');
|
|
37
|
+
}
|
|
38
|
+
exports.getSchemaTypeNames = getSchemaTypeNames;
|
|
39
|
+
//# sourceMappingURL=value-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-type.js","sourceRoot":"","sources":["../../../source/schema/utils/value-type.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAC9C,yDAAoE;AAGpE,oCAAyF;AAEzF,SAAgB,YAAY,CAAC,KAAc;IACzC,IAAI,IAAA,yBAAW,EAAC,KAAK,CAAC,EAAE;QACtB,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,IAAA,oBAAM,EAAC,KAAK,CAAC,EAAE;QACjB,OAAO,MAAM,CAAC;KACf;IAED,OAAQ,KAAgB,CAAC,WAAkC,CAAC;AAC9D,CAAC;AAVD,oCAUC;AAED,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,MAAM,iBAAiB,GAAG,IAAA,wBAAgB,EAAC,SAAS,CAAC,CAAC;IAEtD,OAAO,IAAA,sBAAQ,EAAC,iBAAiB,CAAC;QAChC,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC;AAC7B,CAAC;AAND,4CAMC;AAED,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,IAAI,IAAA,oBAAY,EAAC,MAAM,CAAC,EAAE;QACxB,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IAED,IAAI,IAAA,sBAAc,EAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IAED,IAAI,IAAA,qBAAa,EAAC,MAAM,CAAC,EAAE;QACzB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAA,eAAO,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;KACzE;IAED,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACxC,CAAC;AAhBD,gDAgBC"}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileTemplateProviderBase = void 0;
|
|
4
4
|
const bad_request_error_1 = require("../../error/bad-request.error");
|
|
5
|
+
const schema_1 = require("../../schema");
|
|
5
6
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
7
|
const fs = require("fs/promises");
|
|
7
8
|
const path = require("path");
|
|
8
|
-
const keyPattern = /^[\w
|
|
9
|
+
const keyPattern = /^[\w\-/]+$/u;
|
|
9
10
|
class FileTemplateProviderBase {
|
|
10
11
|
constructor(schema, basePath, fileForwards) {
|
|
11
12
|
this.schema = schema;
|
|
@@ -19,7 +20,7 @@ class FileTemplateProviderBase {
|
|
|
19
20
|
const filePath = path.resolve(this.basePath, `${key}.js`);
|
|
20
21
|
const templateModule = await Promise.resolve().then(() => require(filePath));
|
|
21
22
|
const fileContent = templateModule.default;
|
|
22
|
-
const fileTemplate =
|
|
23
|
+
const fileTemplate = schema_1.Schema.parse(this.schema, fileContent);
|
|
23
24
|
const result = {};
|
|
24
25
|
const entries = Object.entries(fileTemplate);
|
|
25
26
|
for (const [property, value] of entries) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-template.provider.base.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.base.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;
|
|
1
|
+
{"version":3,"file":"file-template.provider.base.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.base.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;AAC5D,yCAAkC;AAElC,yDAAkE;AAClE,kCAAkC;AAClC,6BAA6B;AAO7B,MAAM,UAAU,GAAG,a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AAI,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;iBAC7F;gBAED,SAAS;aACV;YAED,IAAI,IAAA,uBAAS,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;gBACpC,MAAM,eAAe,GAAG,IAAA,8BAAgB,EAAC,YAAY,CAAC,OAAO,CAAC,EAAE,6BAA6B,CAAC,CAAC;gBAC/F,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;gBAEtG,MAAM,CAAC,SAAS,CAAC,GAAG,OAAc,CAAC;gBACnC,SAAS;aACV;YAED,MAAM,IAAI,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;SAC7F;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AApDD,4DAoDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-template.provider.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AAExE,yCAA6D;AAI7D,+EAAyE;AAe5D,QAAA,0BAA0B,GAA+B,EAAE,CAAC;AAEzE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"file-template.provider.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AAExE,yCAA6D;AAI7D,+EAAyE;AAe5D,QAAA,0BAA0B,GAA+B,EAAE,CAAC;AAEzE,MAAM,kBAAkB,GAAG,IAAA,eAAM,EAAe;IAC9C,IAAI,EAAE,IAAA,eAAM,GAAE;IACd,QAAQ,EAAE,IAAA,iBAAQ,EAAC,IAAA,eAAM,GAAE,CAAC;IAC5B,YAAY,EAAE,IAAA,iBAAQ,EAAC,IAAA,eAAM,GAAE,CAAC;IAChC,OAAO,EAAE,IAAA,iBAAQ,EAAC,IAAA,gBAAO,GAAE,CAAC;CAC7B,CAAC,CAAC;AAKH,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,sDAAgD;IAGxF,YAAyB,QAAgB;QACvC,KAAK,CAAC,kBAAkB,EAAE,QAAQ,EAAE,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;CACF,CAAA;AANY,oBAAoB;IAHhC,IAAA,qBAAS,EAAC;QACT,uBAAuB,EAAE,GAAG,EAAE,CAAC,kCAA0B,CAAC,QAAQ;KACnE,CAAC;IAIa,WAAA,IAAA,qBAAS,GAAE,CAAA;;GAHb,oBAAoB,CAMhC;AANY,oDAAoB;AAQjC,SAAgB,6BAA6B,CAAC,SAA8C,EAAE;IAC5F,kCAA0B,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,kCAA0B,CAAC,QAAQ,CAAC;AAC/F,CAAC;AAFD,sEAEC;AAED,SAAgB,YAAY,CAAyB,QAAW;IAC9D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAFD,oCAEC"}
|
package/types.d.ts
CHANGED
|
@@ -35,10 +35,10 @@ export declare type UndefinableJsonObject = {
|
|
|
35
35
|
[key: string]: UndefinableJsonInnerNode;
|
|
36
36
|
};
|
|
37
37
|
export declare type UndefinableJsonArray = UndefinableJsonInnerNode[];
|
|
38
|
-
export declare type EnumerationValue = string | number;
|
|
39
38
|
export declare type Enumeration = EnumerationArray | EnumerationObject;
|
|
40
|
-
export declare type EnumerationArray = readonly [
|
|
41
|
-
export declare type EnumerationObject = Record<string,
|
|
39
|
+
export declare type EnumerationArray = readonly [string | number, ...(string | number)[]];
|
|
40
|
+
export declare type EnumerationObject = Record<string, string | number>;
|
|
41
|
+
export declare type EnumerationValue<T extends Enumeration = Enumeration> = T extends EnumerationArray ? T[number] : T[Extract<keyof T, string>];
|
|
42
42
|
export declare type Type<T = any, Arguments extends any[] = any> = Constructor<T, Arguments> & {
|
|
43
43
|
prototype: T;
|
|
44
44
|
};
|
|
@@ -82,7 +82,8 @@ export declare type OmitBy<T, V> = Omit<T, {
|
|
|
82
82
|
/**
|
|
83
83
|
* normalize properties of a type that allow `undefined` to make them optional.
|
|
84
84
|
*/
|
|
85
|
-
export declare type Optionalize<
|
|
85
|
+
export declare type Optionalize<T extends object> = OmitBy<T, undefined> & Partial<PickBy<T, undefined>>;
|
|
86
|
+
export declare type SimplifiedOptionalize<T extends object> = Simplify<Optionalize<T>>;
|
|
86
87
|
/**
|
|
87
88
|
* remove nested type information
|
|
88
89
|
*/
|
|
@@ -95,6 +96,9 @@ export declare type Simplify<T> = T extends (Primitive | Function | Date | RegEx
|
|
|
95
96
|
export declare type SimplifyObject<T extends Record> = {
|
|
96
97
|
[K in keyof T]: T[K];
|
|
97
98
|
} & {};
|
|
99
|
+
export declare type UndefinableObject<T extends Record> = {
|
|
100
|
+
[K in keyof T]: T[K] | undefined;
|
|
101
|
+
};
|
|
98
102
|
/**
|
|
99
103
|
* pick properties from a type that extend from a specific type.
|
|
100
104
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.includesAsync = void 0;
|
|
4
|
+
const any_1 = require("../iterable-helpers/any");
|
|
5
|
+
const any_2 = require("./any");
|
|
6
|
+
const is_async_iterable_1 = require("./is-async-iterable");
|
|
7
|
+
async function includesAsync(iterable, value) {
|
|
8
|
+
return (0, is_async_iterable_1.isAsyncIterable)(iterable)
|
|
9
|
+
? (0, any_2.anyAsync)(iterable, (item) => item == value)
|
|
10
|
+
: (0, any_1.any)(iterable, (item) => item == value);
|
|
11
|
+
}
|
|
12
|
+
exports.includesAsync = includesAsync;
|
|
13
|
+
//# sourceMappingURL=includes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"includes.js","sourceRoot":"","sources":["../../../source/utils/async-iterable-helpers/includes.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AAC9C,+BAAiC;AACjC,2DAAsD;AAE/C,KAAK,UAAU,aAAa,CAAI,QAAwB,EAAE,KAAQ;IACvE,OAAO,IAAA,mCAAe,EAAC,QAAQ,CAAC;QAC9B,CAAC,CAAC,IAAA,cAAQ,EAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC;QAC7C,CAAC,CAAC,IAAA,SAAG,EAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;AAC7C,CAAC;AAJD,sCAIC"}
|
|
@@ -17,6 +17,7 @@ export * from './group';
|
|
|
17
17
|
export * from './group-single';
|
|
18
18
|
export * from './group-to-map';
|
|
19
19
|
export * from './group-to-single-map';
|
|
20
|
+
export * from './includes';
|
|
20
21
|
export * from './interrupt';
|
|
21
22
|
export * from './is-async-iterable';
|
|
22
23
|
export * from './last';
|
|
@@ -33,6 +33,7 @@ __exportStar(require("./group"), exports);
|
|
|
33
33
|
__exportStar(require("./group-single"), exports);
|
|
34
34
|
__exportStar(require("./group-to-map"), exports);
|
|
35
35
|
__exportStar(require("./group-to-single-map"), exports);
|
|
36
|
+
__exportStar(require("./includes"), exports);
|
|
36
37
|
__exportStar(require("./interrupt"), exports);
|
|
37
38
|
__exportStar(require("./is-async-iterable"), exports);
|
|
38
39
|
__exportStar(require("./last"), exports);
|