@tstdl/base 0.78.0-beta5 → 0.78.0-beta52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/client/client.d.ts +2 -1
- package/api/client/client.js +7 -14
- package/api/client/client.js.map +1 -1
- package/api/response.js.map +1 -1
- package/api/server/gateway.d.ts +3 -0
- package/api/server/gateway.js +11 -11
- package/api/server/gateway.js.map +1 -1
- package/api/server/middlewares/cors.middleware.d.ts +6 -4
- package/api/server/middlewares/cors.middleware.js +30 -30
- package/api/server/middlewares/cors.middleware.js.map +1 -1
- package/api/types.d.ts +13 -2
- package/api/types.js +1 -2
- package/api/types.js.map +1 -1
- package/api/utils.d.ts +9 -0
- package/api/utils.js +15 -0
- package/api/utils.js.map +1 -0
- package/application/application.js.map +1 -1
- package/container/container.js.map +1 -1
- package/container/decorators.d.ts +1 -1
- package/container/decorators.js.map +1 -1
- package/css/theme/theme.service.js.map +1 -1
- package/data-structures/iterable-weak-map.js +1 -1
- package/data-structures/iterable-weak-map.js.map +1 -1
- package/data-structures/linked-list.js.map +1 -1
- package/data-structures/sorted-array-list.js.map +1 -1
- package/database/mongo/classes.js.map +1 -1
- package/database/mongo/mongo-entity-repository.js +2 -2
- package/database/mongo/mongo-entity-repository.js.map +1 -1
- package/distributed-loop/distributed-loop.js.map +1 -1
- package/distributed-loop/provider.js.map +1 -1
- package/error/custom.error.d.ts +2 -2
- package/error/custom.error.js +13 -7
- package/error/custom.error.js.map +1 -1
- package/examples/api/basic-overview.js +0 -1
- package/examples/api/basic-overview.js.map +1 -1
- package/examples/mail/basic.js +12 -7
- package/examples/mail/basic.js.map +1 -1
- package/examples/mail/templates/hello-name.d.ts +2 -0
- package/examples/mail/templates/hello-name.js +11 -0
- package/examples/mail/templates/hello-name.js.map +1 -0
- package/examples/pdf/basic.js +6 -3
- package/examples/pdf/basic.js.map +1 -1
- package/examples/pdf/templates/hello-name.d.ts +1 -4
- package/examples/pdf/templates/hello-name.js +30 -4
- package/examples/pdf/templates/hello-name.js.map +1 -1
- package/examples/reflection/basic.js +1 -1
- package/examples/reflection/basic.js.map +1 -1
- package/http/client/adapters/got-http-client.adapter.js.map +1 -1
- package/http/client/adapters/undici-http-client.adapter.js.map +1 -1
- package/http/client/adapters/utils.js +20 -8
- package/http/client/adapters/utils.js.map +1 -1
- package/http/client/http-client-request.d.ts +13 -3
- package/http/client/http-client-request.js +4 -0
- package/http/client/http-client-request.js.map +1 -1
- package/http/client/http-client.d.ts +0 -3
- package/http/client/http-client.js +31 -24
- package/http/client/http-client.js.map +1 -1
- package/http/http-headers.d.ts +2 -0
- package/http/http-headers.js +6 -0
- package/http/http-headers.js.map +1 -1
- package/http/server/node/node-http-server.js.map +1 -1
- package/image-service/image-service.js.map +1 -1
- package/image-service/imgproxy/imgproxy-image-service.js.map +1 -1
- package/key-value-store/mongo/mongo-key-value-store.provider.js.map +1 -1
- package/key-value-store/mongo/mongo-key-value.repository.js.map +1 -1
- package/key-value-store/mongo/mongo-key-value.store.js.map +1 -1
- package/lock/mongo/lock.js.map +1 -1
- package/lock/mongo/mongo-lock-repository.js.map +1 -1
- package/lock/mongo/provider.js.map +1 -1
- package/logger/console/logger.js.map +1 -1
- package/mail/clients/nodemailer.mail-client.js.map +1 -1
- package/mail/index.d.ts +0 -3
- package/mail/index.js +0 -3
- package/mail/index.js.map +1 -1
- package/mail/mail.service.d.ts +3 -5
- package/mail/mail.service.js +8 -14
- package/mail/mail.service.js.map +1 -1
- package/mail/models/mail-template.model.d.ts +11 -10
- package/mail/models/mail-template.model.js +7 -0
- package/mail/models/mail-template.model.js.map +1 -1
- package/mail/module.d.ts +1 -5
- package/mail/module.js +2 -11
- package/mail/module.js.map +1 -1
- package/mail/repositories/mongo-mail-log.repository.js.map +1 -1
- package/mail/tokens.d.ts +0 -3
- package/mail/tokens.js +1 -2
- package/mail/tokens.js.map +1 -1
- package/message-bus/local/local-message-bus-provider.js.map +1 -1
- package/message-bus/local/local-message-bus.js.map +1 -1
- package/migration/migrator.js.map +1 -1
- package/migration/mongo/migration-state-repository.js.map +1 -1
- package/module/modules/web-server.module.js.map +1 -1
- package/object-storage/s3/s3.object-storage-provider.js.map +1 -1
- package/object-storage/s3/s3.object-storage.js.map +1 -1
- package/openid-connect/cached-oidc-configuration.service.js.map +1 -1
- package/openid-connect/mongo-oidc-state.repository.js.map +1 -1
- package/openid-connect/oidc-configuration.service.d.ts +2 -1
- package/openid-connect/oidc-configuration.service.js +5 -3
- package/openid-connect/oidc-configuration.service.js.map +1 -1
- package/openid-connect/oidc.service-model.d.ts +11 -3
- package/openid-connect/oidc.service.d.ts +6 -3
- package/openid-connect/oidc.service.js +69 -23
- package/openid-connect/oidc.service.js.map +1 -1
- package/package.json +9 -10
- package/pdf/pdf.service.d.ts +48 -10
- package/pdf/pdf.service.js +123 -13
- package/pdf/pdf.service.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/index.d.ts +1 -0
- package/promise/index.js +1 -0
- package/promise/index.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/queue/mongo/mongo-job.repository.js +1 -1
- package/queue/mongo/mongo-job.repository.js.map +1 -1
- package/queue/mongo/queue.js.map +1 -1
- package/queue/mongo/queue.provider.js.map +1 -1
- package/reflection/decorator-data.js +1 -1
- package/reflection/decorator-data.js.map +1 -1
- package/reflection/decorators.d.ts +2 -2
- package/reflection/decorators.js +7 -7
- package/reflection/decorators.js.map +1 -1
- package/reflection/registry.d.ts +8 -8
- package/reflection/registry.js +1 -1
- package/reflection/registry.js.map +1 -1
- package/reflection/types.d.ts +3 -2
- package/reflection/utils.d.ts +7 -2
- package/reflection/utils.js +38 -12
- package/reflection/utils.js.map +1 -1
- package/schema/array-constraints/maximum-length.d.ts +2 -2
- package/schema/array-constraints/maximum-length.js +3 -3
- package/schema/array-constraints/maximum-length.js.map +1 -1
- package/schema/array-constraints/minimum-length.d.ts +2 -2
- package/schema/array-constraints/minimum-length.js +3 -3
- package/schema/array-constraints/minimum-length.js.map +1 -1
- package/schema/coercers/boolean.coercer.d.ts +2 -2
- package/schema/coercers/boolean.coercer.js +2 -2
- package/schema/coercers/boolean.coercer.js.map +1 -1
- package/schema/coercers/date.coercer.d.ts +2 -2
- package/schema/coercers/date.coercer.js +2 -2
- package/schema/coercers/date.coercer.js.map +1 -1
- package/schema/coercers/number.coercer.d.ts +2 -2
- package/schema/coercers/number.coercer.js +2 -2
- package/schema/coercers/number.coercer.js.map +1 -1
- package/schema/coercers/regexp.coercer.d.ts +2 -2
- package/schema/coercers/regexp.coercer.js +2 -2
- package/schema/coercers/regexp.coercer.js.map +1 -1
- package/schema/coercers/string.coercer.d.ts +2 -2
- package/schema/coercers/string.coercer.js +2 -2
- package/schema/coercers/string.coercer.js.map +1 -1
- package/schema/coercers/uint8-array.coercer.js +2 -2
- package/schema/coercers/uint8-array.coercer.js.map +1 -1
- package/schema/constraints/enumeration.d.ts +5 -5
- package/schema/constraints/enumeration.js +3 -3
- package/schema/constraints/enumeration.js.map +1 -1
- package/schema/constraints/generic.d.ts +2 -2
- package/schema/constraints/generic.js +3 -3
- package/schema/constraints/generic.js.map +1 -1
- package/schema/constraints/integer.d.ts +2 -2
- package/schema/constraints/integer.js +3 -3
- package/schema/constraints/integer.js.map +1 -1
- package/schema/constraints/literal.d.ts +2 -2
- package/schema/constraints/literal.js +3 -3
- package/schema/constraints/literal.js.map +1 -1
- package/schema/constraints/maximum-date.d.ts +2 -2
- package/schema/constraints/maximum-date.js +3 -3
- package/schema/constraints/maximum-date.js.map +1 -1
- package/schema/constraints/maximum-length.d.ts +2 -2
- package/schema/constraints/maximum-length.js +3 -3
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/maximum.d.ts +2 -2
- package/schema/constraints/maximum.js +3 -3
- package/schema/constraints/maximum.js.map +1 -1
- package/schema/constraints/minimum-date.d.ts +2 -2
- package/schema/constraints/minimum-date.js +3 -3
- package/schema/constraints/minimum-date.js.map +1 -1
- package/schema/constraints/minimum-length.d.ts +2 -2
- package/schema/constraints/minimum-length.js +3 -3
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/constraints/minimum.d.ts +2 -2
- package/schema/constraints/minimum.js +3 -3
- package/schema/constraints/minimum.js.map +1 -1
- package/schema/constraints/pattern.d.ts +2 -2
- package/schema/constraints/pattern.js +3 -3
- package/schema/constraints/pattern.js.map +1 -1
- package/schema/decorators/optional.d.ts +3 -1
- package/schema/decorators/optional.js +2 -2
- package/schema/decorators/optional.js.map +1 -1
- package/schema/decorators/types.d.ts +3 -3
- package/schema/schema.d.ts +0 -4
- package/schema/schema.error.d.ts +5 -4
- package/schema/schema.error.js +3 -3
- package/schema/schema.error.js.map +1 -1
- package/schema/schema.js +85 -106
- package/schema/schema.js.map +1 -1
- package/schema/schemas/assign.d.ts +5 -5
- package/schema/schemas/assign.js.map +1 -1
- package/schema/schemas/exclude.d.ts +4 -1
- package/schema/schemas/exclude.js +6 -11
- package/schema/schemas/exclude.js.map +1 -1
- package/schema/schemas/index.d.ts +2 -0
- package/schema/schemas/index.js +2 -0
- package/schema/schemas/index.js.map +1 -1
- package/schema/schemas/number.d.ts +1 -1
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/omit.d.ts +4 -0
- package/schema/schemas/omit.js +17 -0
- package/schema/schemas/omit.js.map +1 -0
- package/schema/schemas/union.d.ts +2 -7
- package/schema/schemas/union.js.map +1 -1
- package/schema/types.d.ts +25 -18
- package/schema/types.js +17 -4
- package/schema/types.js.map +1 -1
- package/schema/utils/schema.d.ts +3 -0
- package/schema/utils/schema.js +44 -2
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +2 -2
- package/schema/utils/value-type.js +11 -1
- package/schema/utils/value-type.js.map +1 -1
- package/search-index/elastic/config.js.map +1 -1
- package/search-index/elastic/model/index-mapping.d.ts +2 -1
- package/search-index/elastic/model/index-mapping.js.map +1 -1
- package/search-index/elastic/search-index.js +1 -1
- package/search-index/elastic/search-index.js.map +1 -1
- package/serializer/serializable.d.ts +4 -4
- package/serializer/serializable.js.map +1 -1
- package/templates/index.d.ts +2 -0
- package/templates/index.js +2 -0
- package/templates/index.js.map +1 -1
- package/templates/module.d.ts +3 -1
- package/templates/module.js +31 -8
- package/templates/module.js.map +1 -1
- package/templates/providers/file.provider-template.d.ts +16 -0
- package/templates/providers/{file-template.provider.js → file.provider-template.js} +22 -15
- package/templates/providers/file.provider-template.js.map +1 -0
- package/templates/providers/memory.template-provider.d.ts +8 -0
- package/templates/providers/{memory-template.provider.base.js → memory.template-provider.js} +8 -6
- package/templates/providers/memory.template-provider.js.map +1 -0
- package/templates/renderers/handlebars.template-renderer.d.ts +38 -6
- package/templates/renderers/handlebars.template-renderer.js +70 -3
- package/templates/renderers/handlebars.template-renderer.js.map +1 -1
- package/templates/renderers/mjml.template-renderer.d.ts +6 -6
- package/templates/renderers/mjml.template-renderer.js +8 -9
- package/templates/renderers/mjml.template-renderer.js.map +1 -1
- package/templates/renderers/string.template-renderer.d.ts +8 -0
- package/{mail/template-providers/memory-mail-template.provider.js → templates/renderers/string.template-renderer.js} +13 -7
- package/templates/renderers/string.template-renderer.js.map +1 -0
- package/templates/resolvers/file.template-resolver.d.ts +23 -0
- package/templates/resolvers/file.template-resolver.js +63 -0
- package/templates/resolvers/file.template-resolver.js.map +1 -0
- package/templates/resolvers/string.template-resolver.d.ts +13 -0
- package/templates/resolvers/string.template-resolver.js +44 -0
- package/templates/resolvers/string.template-resolver.js.map +1 -0
- package/templates/template-renderer.provider.js +7 -19
- package/templates/template-renderer.provider.js.map +1 -1
- package/templates/template-resolver.provider.d.ts +8 -0
- package/templates/template-resolver.provider.js +48 -0
- package/templates/template-resolver.provider.js.map +1 -0
- package/templates/template.model.d.ts +15 -4
- package/templates/template.model.js +50 -0
- package/templates/template.model.js.map +1 -1
- package/templates/template.renderer.d.ts +14 -3
- package/templates/template.renderer.js +3 -0
- package/templates/template.renderer.js.map +1 -1
- package/templates/template.resolver.d.ts +5 -0
- package/templates/template.resolver.js +7 -0
- package/templates/template.resolver.js.map +1 -0
- package/templates/template.service.d.ts +10 -4
- package/templates/template.service.js +19 -6
- package/templates/template.service.js.map +1 -1
- package/templates/tokens.d.ts +3 -2
- package/templates/tokens.js +2 -1
- package/templates/tokens.js.map +1 -1
- package/threading/index.d.ts +1 -0
- package/threading/index.js +18 -0
- package/threading/index.js.map +1 -0
- package/threading/message-proxy.d.ts +66 -0
- package/threading/message-proxy.js +34 -0
- package/threading/message-proxy.js.map +1 -0
- package/threading/thread-pool.d.ts +4 -0
- package/threading/thread-pool.js +10 -0
- package/threading/thread-pool.js.map +1 -0
- package/threading/thread.d.ts +16 -0
- package/threading/thread.js +30 -0
- package/threading/thread.js.map +1 -0
- package/types.d.ts +20 -7
- package/utils/array/array.d.ts +1 -2
- package/utils/array/array.js.map +1 -1
- package/utils/clone.js +4 -0
- package/utils/clone.js.map +1 -1
- package/utils/compression.d.ts +13 -13
- package/utils/compression.js +10 -9
- 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 +5 -8
- package/utils/enum.js +15 -13
- package/utils/enum.js.map +1 -1
- package/utils/function/memoize.js +4 -4
- package/utils/function/memoize.js.map +1 -1
- package/utils/helpers.d.ts +0 -2
- package/utils/helpers.js +1 -12
- package/utils/helpers.js.map +1 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/index.js.map +1 -1
- package/utils/object/forward-ref.js +3 -19
- package/utils/object/forward-ref.js.map +1 -1
- package/utils/object/property-name.d.ts +2 -2
- package/utils/proxy.d.ts +6 -0
- package/utils/proxy.js +21 -0
- package/utils/proxy.js.map +1 -0
- package/utils/throw.d.ts +2 -0
- package/utils/throw.js +15 -0
- package/utils/throw.js.map +1 -0
- package/utils/type-guards.d.ts +13 -1
- package/utils/type-guards.js +29 -5
- package/utils/type-guards.js.map +1 -1
- package/web-types.d.ts +28 -0
- package/web-types.js +3 -0
- package/web-types.js.map +1 -0
- package/mail/mail-template-renderer.provider.d.ts +0 -8
- package/mail/mail-template-renderer.provider.js +0 -60
- package/mail/mail-template-renderer.provider.js.map +0 -1
- package/mail/mail-template.provider.d.ts +0 -4
- package/mail/mail-template.provider.js +0 -7
- package/mail/mail-template.provider.js.map +0 -1
- package/mail/mail-template.renderer.d.ts +0 -10
- package/mail/mail-template.renderer.js +0 -7
- package/mail/mail-template.renderer.js.map +0 -1
- package/mail/template-providers/file-mail-template.provider.d.ts +0 -24
- package/mail/template-providers/file-mail-template.provider.js +0 -51
- package/mail/template-providers/file-mail-template.provider.js.map +0 -1
- package/mail/template-providers/memory-mail-template.provider.d.ts +0 -6
- package/mail/template-providers/memory-mail-template.provider.js.map +0 -1
- package/mail/template-renderers/handlebars.mail-template-renderer.d.ts +0 -13
- package/mail/template-renderers/handlebars.mail-template-renderer.js +0 -49
- package/mail/template-renderers/handlebars.mail-template-renderer.js.map +0 -1
- package/mail/template-renderers/mjml.mail-template-renderer.d.ts +0 -14
- package/mail/template-renderers/mjml.mail-template-renderer.js +0 -63
- package/mail/template-renderers/mjml.mail-template-renderer.js.map +0 -1
- package/templates/providers/file-template.provider.base.d.ts +0 -12
- package/templates/providers/file-template.provider.base.js +0 -50
- package/templates/providers/file-template.provider.base.js.map +0 -1
- package/templates/providers/file-template.provider.d.ts +0 -22
- package/templates/providers/file-template.provider.js.map +0 -1
- package/templates/providers/memory-template.provider.base.d.ts +0 -9
- package/templates/providers/memory-template.provider.base.js.map +0 -1
- package/templates/providers/memory-template.provider.d.ts +0 -4
- package/templates/providers/memory-template.provider.js +0 -18
- package/templates/providers/memory-template.provider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../source/reflection/registry.ts"],"names":[],"mappings":";;;AAEA,sDAA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IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;qBACtG;oBAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAA2B,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,uCAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,uCAAiB,EAAE,EAAE,CAAC;gBACzP,CAAC,CAAC;aACH;YACD,IAAI,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,uCAAiB,EAAE,EAAE;YACpD,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAjHD,gDAiHC;AAEY,QAAA,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
package/reflection/types.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import type { Constructor, Record } from "../types";
|
|
|
2
2
|
import type { UnionToIntersection } from 'type-fest';
|
|
3
3
|
import type { ConstructorParameterMetadata, MethodMetadata, MethodParameterMetadata, ParameterMetadata, PropertyMetadata, TypeMetadata } from './registry';
|
|
4
4
|
export declare type DecoratorType = 'class' | 'property' | 'accessor' | 'method' | 'parameter' | 'methodParameter' | 'constructorParameter';
|
|
5
|
-
export declare type DecoratorHandler<T extends DecoratorType = DecoratorType> = (data: DecoratorData<T>, metadata: DecoratorMetadata<T
|
|
5
|
+
export declare type DecoratorHandler<T extends DecoratorType = DecoratorType> = (data: DecoratorData<T>, metadata: DecoratorMetadata<T>, originalArguments: Parameters<DecoratorUnion<T>>) => DecoratorHandlerReturnType<T>;
|
|
6
6
|
export declare type DecoratorHandlerReturnType<T extends DecoratorType = DecoratorType> = DecoratorOptionsTypeMap<DecoratorHandlerReturnTypeMap, T>;
|
|
7
7
|
export declare type Decorator<T extends DecoratorType = DecoratorType> = DecoratorOptionsTypeMapIntersection<DecoratorMap, T>;
|
|
8
8
|
export declare type DecoratorUnion<T extends DecoratorType = DecoratorType> = DecoratorOptionsTypeMap<DecoratorMap, T>;
|
|
9
9
|
export declare type DecoratorData<T extends DecoratorType = DecoratorType> = DecoratorOptionsTypeMap<DecoratorDataMap, T>;
|
|
10
10
|
export declare type DecoratorMetadata<T extends DecoratorType = DecoratorType> = DecoratorOptionsTypeMap<DecoratorMetadataMap, T>;
|
|
11
|
+
export declare type CombinedDecoratorParameters = [target: object, propertyKey?: string | symbol, descriptorOrParameterIndex?: PropertyDescriptor | number];
|
|
11
12
|
export declare type DecoratorTypeMap<T extends Record<DecoratorType> = Record<DecoratorType>> = T;
|
|
12
13
|
export declare type DecoratorOptionsTypeMap<T extends DecoratorTypeMap, U extends DecoratorType> = {
|
|
13
14
|
[D in U]: T[D];
|
|
@@ -70,7 +71,7 @@ export declare type MethodDecoratorData = DecoratorDataBase<'method'> & {
|
|
|
70
71
|
methodKey: string | symbol;
|
|
71
72
|
descriptor: PropertyDescriptor;
|
|
72
73
|
};
|
|
73
|
-
export declare type MethodParameterDecoratorData = DecoratorDataBase<'parameter'> & {
|
|
74
|
+
export declare type MethodParameterDecoratorData = DecoratorDataBase<'method-parameter'> & {
|
|
74
75
|
static: boolean;
|
|
75
76
|
methodKey: string | symbol;
|
|
76
77
|
index: number;
|
package/reflection/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Constructor, OneOrMany, PropertiesOfType, Record, TypedOmit } from "../types";
|
|
2
|
-
import type { Decorator, DecoratorHandler, DecoratorType, DecoratorUnion } from './types';
|
|
2
|
+
import type { CombinedDecoratorParameters, Decorator, DecoratorData, DecoratorHandler, DecoratorMetadata, DecoratorType, DecoratorUnion } from './types';
|
|
3
3
|
export declare type CreateDecoratorTypeOptions = {
|
|
4
4
|
[P in DecoratorType]?: boolean;
|
|
5
5
|
};
|
|
@@ -14,6 +14,9 @@ export declare type SpecificCreateDecoratorOptions<T extends DecoratorType> = Ty
|
|
|
14
14
|
handler?: DecoratorHandler<T>;
|
|
15
15
|
include?: OneOrMany<DecoratorUnion<T>>;
|
|
16
16
|
};
|
|
17
|
+
export declare type WrapDecoratorOptions = CreateDecoratorOptions & {
|
|
18
|
+
handler?: (data: DecoratorData, metadata: DecoratorMetadata, originalArguments: CombinedDecoratorParameters) => void;
|
|
19
|
+
};
|
|
17
20
|
declare type CreateDecoratorType<T extends CreateDecoratorOptions> = Extract<PropertiesOfType<T, true>, DecoratorType>;
|
|
18
21
|
export declare function createDecorator<T extends CreateDecoratorTypeOptions & CreateDecoratorOptions>(options: T, handler?: DecoratorHandler<CreateDecoratorType<T>>): Decorator<CreateDecoratorType<T>>;
|
|
19
22
|
export declare function createClassDecorator(options?: SpecificCreateDecoratorOptions<'class'>): ClassDecorator;
|
|
@@ -21,9 +24,11 @@ export declare function createPropertyDecorator(options?: SpecificCreateDecorato
|
|
|
21
24
|
export declare function createAccessorDecorator(options?: SpecificCreateDecoratorOptions<'accessor'>): MethodDecorator;
|
|
22
25
|
export declare function createPropertyOrAccessorDecorator(options?: SpecificCreateDecoratorOptions<'property' | 'accessor'>): Decorator<'property' | 'accessor'>;
|
|
23
26
|
export declare function createMethodDecorator(options?: SpecificCreateDecoratorOptions<'method'>): MethodDecorator;
|
|
24
|
-
export declare function createParameterDecorator(options?: SpecificCreateDecoratorOptions<'parameter'>): ParameterDecorator;
|
|
25
27
|
export declare function createMethodParameterDecorator(options?: SpecificCreateDecoratorOptions<'methodParameter'>): ParameterDecorator;
|
|
26
28
|
export declare function createConstructorParameterDecorator(options?: SpecificCreateDecoratorOptions<'constructorParameter'>): ParameterDecorator;
|
|
29
|
+
export declare function createParameterDecorator(options?: SpecificCreateDecoratorOptions<'parameter'>): ParameterDecorator;
|
|
30
|
+
export declare function wrapDecoratorFactory<T extends (...args: any[]) => DecoratorUnion>(decoratorFactory: T, options?: WrapDecoratorOptions): T;
|
|
31
|
+
export declare function wrapDecorator<T extends DecoratorUnion>(decorator: T, options?: WrapDecoratorOptions): T;
|
|
27
32
|
export declare function getConstructor<T extends Constructor = Constructor>(constructorOrTarget: object): T;
|
|
28
33
|
export declare function getTypeInfoString(type: Constructor): string;
|
|
29
34
|
export declare function printType(type: Constructor): void;
|
package/reflection/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printType = exports.getTypeInfoString = exports.getConstructor = exports.
|
|
3
|
+
exports.printType = exports.getTypeInfoString = exports.getConstructor = exports.wrapDecorator = exports.wrapDecoratorFactory = exports.createParameterDecorator = exports.createConstructorParameterDecorator = exports.createMethodParameterDecorator = exports.createMethodDecorator = exports.createPropertyOrAccessorDecorator = exports.createAccessorDecorator = exports.createPropertyDecorator = exports.createClassDecorator = exports.createDecorator = void 0;
|
|
4
4
|
const array_1 = require("../utils/array/array");
|
|
5
5
|
const noop_1 = require("../utils/noop");
|
|
6
6
|
const type_guards_1 = require("../utils/type-guards");
|
|
@@ -9,21 +9,23 @@ const registry_1 = require("./registry");
|
|
|
9
9
|
// eslint-disable-next-line max-lines-per-function
|
|
10
10
|
function createDecorator(options, handler = noop_1.noop) {
|
|
11
11
|
// eslint-disable-next-line max-statements, max-lines-per-function
|
|
12
|
-
function decoratorWrapper(
|
|
13
|
-
const data = (0, decorator_data_1.getDecoratorData)(
|
|
14
|
-
const optionsType = (data.type == 'constructor-parameter') ? 'constructorParameter'
|
|
12
|
+
function decoratorWrapper(...args) {
|
|
13
|
+
const data = (0, decorator_data_1.getDecoratorData)(...args);
|
|
14
|
+
const optionsType = (data.type == 'constructor-parameter') ? 'constructorParameter'
|
|
15
|
+
: (data.type == 'method-parameter') ? 'methodParameter'
|
|
16
|
+
: data.type;
|
|
15
17
|
const valid = (options[optionsType] == true)
|
|
16
|
-
|| (optionsType == '
|
|
17
|
-
|| (
|
|
18
|
+
|| (optionsType == 'methodParameter' && ((options.methodParameter == true) || (options.parameter == true)))
|
|
19
|
+
|| (optionsType == 'constructorParameter' && ((options.constructorParameter == true) || (options.parameter == true)));
|
|
18
20
|
(0, type_guards_1.assert)(valid, () => `Decorator cannot be used for ${data.type}.`);
|
|
19
21
|
const metadata = registry_1.reflectionRegistry.registerDecoratorData(data);
|
|
20
22
|
if ((0, type_guards_1.isDefined)(options.data)) {
|
|
21
23
|
metadata.data.setMany(options.data, options.mergeData);
|
|
22
24
|
}
|
|
23
|
-
const result = handler(data, metadata);
|
|
25
|
+
const result = handler(data, metadata, args);
|
|
24
26
|
if ((0, type_guards_1.isDefined)(options.include)) {
|
|
25
27
|
for (const include of (0, array_1.toArray)(options.include)) {
|
|
26
|
-
include(
|
|
28
|
+
include(...args); // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
return result;
|
|
@@ -51,10 +53,6 @@ function createMethodDecorator(options = {}) {
|
|
|
51
53
|
return createDecorator({ ...options, method: true }, options.handler);
|
|
52
54
|
}
|
|
53
55
|
exports.createMethodDecorator = createMethodDecorator;
|
|
54
|
-
function createParameterDecorator(options = {}) {
|
|
55
|
-
return createDecorator({ ...options, parameter: true }, options.handler);
|
|
56
|
-
}
|
|
57
|
-
exports.createParameterDecorator = createParameterDecorator;
|
|
58
56
|
function createMethodParameterDecorator(options = {}) {
|
|
59
57
|
return createDecorator({ ...options, methodParameter: true }, options.handler);
|
|
60
58
|
}
|
|
@@ -63,6 +61,34 @@ function createConstructorParameterDecorator(options = {}) {
|
|
|
63
61
|
return createDecorator({ ...options, constructorParameter: true }, options.handler);
|
|
64
62
|
}
|
|
65
63
|
exports.createConstructorParameterDecorator = createConstructorParameterDecorator;
|
|
64
|
+
function createParameterDecorator(options = {}) {
|
|
65
|
+
return createDecorator({ ...options, parameter: true }, options.handler);
|
|
66
|
+
}
|
|
67
|
+
exports.createParameterDecorator = createParameterDecorator;
|
|
68
|
+
function wrapDecoratorFactory(decoratorFactory, options) {
|
|
69
|
+
function wrappedDecoratorFactory(...args) {
|
|
70
|
+
const decorator = decoratorFactory(...args);
|
|
71
|
+
return wrapDecorator(decorator, options);
|
|
72
|
+
}
|
|
73
|
+
return wrappedDecoratorFactory;
|
|
74
|
+
}
|
|
75
|
+
exports.wrapDecoratorFactory = wrapDecoratorFactory;
|
|
76
|
+
function wrapDecorator(decorator, options) {
|
|
77
|
+
const wrappedDecorator = createDecorator({
|
|
78
|
+
class: true,
|
|
79
|
+
property: true,
|
|
80
|
+
method: true,
|
|
81
|
+
parameter: true,
|
|
82
|
+
methodParameter: true,
|
|
83
|
+
constructorParameter: true,
|
|
84
|
+
...options
|
|
85
|
+
}, (data, metadata, args) => {
|
|
86
|
+
options?.handler?.(data, metadata, args);
|
|
87
|
+
return decorator(...args); // eslint-disable-line @typescript-eslint/no-unsafe-argument
|
|
88
|
+
});
|
|
89
|
+
return wrappedDecorator;
|
|
90
|
+
}
|
|
91
|
+
exports.wrapDecorator = wrapDecorator;
|
|
66
92
|
function getConstructor(constructorOrTarget) {
|
|
67
93
|
return (0, type_guards_1.isFunction)(constructorOrTarget)
|
|
68
94
|
? constructorOrTarget
|
package/reflection/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../source/reflection/utils.ts"],"names":[],"mappings":";;;AACA,gDAA8C;AAC9C,wCAAoC;AACpC,sDAA8E;AAC9E,qDAAoD;AACpD,yCAAgD;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../source/reflection/utils.ts"],"names":[],"mappings":";;;AACA,gDAA8C;AAC9C,wCAAoC;AACpC,sDAA8E;AAC9E,qDAAoD;AACpD,yCAAgD;AA0BhD,kDAAkD;AAClD,SAAgB,eAAe,CAAgE,OAAU,EAAE,UAAoD,WAAI;IACjK,kEAAkE;IAClE,SAAS,gBAAgB,CAAC,GAAG,IAAiC;QAC5D,MAAM,IAAI,GAAG,IAAA,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 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path/json-path";
|
|
2
2
|
import type { Decorator } from "../../reflection";
|
|
3
|
-
import type { ConstraintResult } from '../types';
|
|
3
|
+
import type { ConstraintContext, ConstraintResult } from '../types';
|
|
4
4
|
import { SchemaArrayConstraint } from '../types';
|
|
5
5
|
export declare class ArrayMaximumLengthConstraint extends SchemaArrayConstraint {
|
|
6
6
|
private readonly maximumLength;
|
|
7
7
|
readonly expects: string;
|
|
8
8
|
constructor(maximumLength: number);
|
|
9
|
-
validate(value: any[], path: JsonPath): ConstraintResult;
|
|
9
|
+
validate(value: any[], path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
10
10
|
}
|
|
11
11
|
export declare function ArrayMaximumLength(maximumLength: number): Decorator<'property' | 'accessor'>;
|
|
@@ -11,11 +11,11 @@ class ArrayMaximumLengthConstraint extends types_1.SchemaArrayConstraint {
|
|
|
11
11
|
this.maximumLength = maximumLength;
|
|
12
12
|
this.expects = `a maximum array length of ${this.maximumLength}`;
|
|
13
13
|
}
|
|
14
|
-
validate(value, path) {
|
|
14
|
+
validate(value, path, context) {
|
|
15
15
|
if (value.length > this.maximumLength) {
|
|
16
|
-
return {
|
|
16
|
+
return { valid: false, error: schema_error_1.SchemaError.expectedButGot(this.expects, `an array length of ${value.length}`, path, { fast: context.options.fastErrors }) };
|
|
17
17
|
}
|
|
18
|
-
return {
|
|
18
|
+
return { valid: true };
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.ArrayMaximumLengthConstraint = ArrayMaximumLengthConstraint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maximum-length.js","sourceRoot":"","sources":["../../../source/schema/array-constraints/maximum-length.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAEjD,MAAa,4BAA6B,SAAQ,6BAAqB;IAKrE,YAAY,aAAqB;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,6BAA6B,IAAI,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"maximum-length.js","sourceRoot":"","sources":["../../../source/schema/array-constraints/maximum-length.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAEjD,MAAa,4BAA6B,SAAQ,6BAAqB;IAKrE,YAAY,aAAqB;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,6BAA6B,IAAI,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,IAAc,EAAE,OAA0B;QAC/D,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE;YACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SAC5J;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AAnBD,oEAmBC;AAED,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,OAAO,IAAA,iDAAoC,EAAC,IAAI,4BAA4B,CAAC,aAAa,CAAC,CAAC,CAAC;AAC/F,CAAC;AAFD,gDAEC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path/json-path";
|
|
2
2
|
import type { Decorator } from "../../reflection";
|
|
3
|
-
import type { ConstraintResult } from '../types';
|
|
3
|
+
import type { ConstraintContext, ConstraintResult } from '../types';
|
|
4
4
|
import { SchemaArrayConstraint } from '../types';
|
|
5
5
|
export declare class MinimumArrayLengthConstraint extends SchemaArrayConstraint {
|
|
6
6
|
private readonly minimumLength;
|
|
7
7
|
readonly expects: string;
|
|
8
8
|
constructor(minimumLength: number);
|
|
9
|
-
validate(value: any[], path: JsonPath): ConstraintResult;
|
|
9
|
+
validate(value: any[], path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
10
10
|
}
|
|
11
11
|
export declare function MinimumArrayLength(minimumLength: number): Decorator<'property' | 'accessor'>;
|
|
@@ -11,11 +11,11 @@ class MinimumArrayLengthConstraint extends types_1.SchemaArrayConstraint {
|
|
|
11
11
|
this.minimumLength = minimumLength;
|
|
12
12
|
this.expects = `a minimum array length of ${this.minimumLength}`;
|
|
13
13
|
}
|
|
14
|
-
validate(value, path) {
|
|
14
|
+
validate(value, path, context) {
|
|
15
15
|
if (value.length < this.minimumLength) {
|
|
16
|
-
return {
|
|
16
|
+
return { valid: false, error: schema_error_1.SchemaError.expectedButGot(this.expects, `an array length of ${value.length}`, path, { fast: context.options.fastErrors }) };
|
|
17
17
|
}
|
|
18
|
-
return {
|
|
18
|
+
return { valid: true };
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.MinimumArrayLengthConstraint = MinimumArrayLengthConstraint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimum-length.js","sourceRoot":"","sources":["../../../source/schema/array-constraints/minimum-length.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAEjD,MAAa,4BAA6B,SAAQ,6BAAqB;IAKrE,YAAY,aAAqB;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,6BAA6B,IAAI,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"minimum-length.js","sourceRoot":"","sources":["../../../source/schema/array-constraints/minimum-length.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAEjD,MAAa,4BAA6B,SAAQ,6BAAqB;IAKrE,YAAY,aAAqB;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,6BAA6B,IAAI,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,IAAc,EAAE,OAA0B;QAC/D,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE;YACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SAC5J;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AAnBD,oEAmBC;AAED,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,OAAO,IAAA,iDAAoC,EAAC,IAAI,4BAA4B,CAAC,aAAa,CAAC,CAAC,CAAC;AAC/F,CAAC;AAFD,gDAEC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path";
|
|
2
|
-
import type { CoerceResult } from '../types';
|
|
2
|
+
import type { CoercerContext, CoerceResult } from '../types';
|
|
3
3
|
import { SchemaValueCoercer } from '../types';
|
|
4
4
|
export declare class BooleanCoercer extends SchemaValueCoercer {
|
|
5
5
|
readonly sourceType: (NumberConstructor | StringConstructor | BigIntConstructor)[];
|
|
6
6
|
readonly targetType: BooleanConstructor;
|
|
7
|
-
coerce(value: number | string | bigint, path: JsonPath): CoerceResult;
|
|
7
|
+
coerce(value: number | string | bigint, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
8
8
|
}
|
|
9
9
|
export declare const booleanCoercer: BooleanCoercer;
|
|
@@ -10,7 +10,7 @@ class BooleanCoercer extends types_1.SchemaValueCoercer {
|
|
|
10
10
|
this.sourceType = [Number, String, BigInt];
|
|
11
11
|
this.targetType = Boolean;
|
|
12
12
|
}
|
|
13
|
-
coerce(value, path) {
|
|
13
|
+
coerce(value, path, context) {
|
|
14
14
|
const normalizedValue = (0, type_guards_1.isString)(value) ? value.toLowerCase() : value;
|
|
15
15
|
switch (normalizedValue) {
|
|
16
16
|
case 1:
|
|
@@ -26,7 +26,7 @@ class BooleanCoercer extends types_1.SchemaValueCoercer {
|
|
|
26
26
|
case 'no':
|
|
27
27
|
return { success: true, value: false };
|
|
28
28
|
default:
|
|
29
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(Boolean, value.toString(), path) };
|
|
29
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(Boolean, value.toString(), path, undefined, { fast: context.options.fastErrors }) };
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/boolean.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA+C;AAC/C,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,cAAe,SAAQ,0BAAkB;IAAtD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAU,GAAG,OAAO,CAAC;IAwBhC,CAAC;IAtBC,MAAM,CAAC,KAA+B,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"boolean.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/boolean.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA+C;AAC/C,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,cAAe,SAAQ,0BAAkB;IAAtD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAU,GAAG,OAAO,CAAC;IAwBhC,CAAC;IAtBC,MAAM,CAAC,KAA+B,EAAE,IAAc,EAAE,OAAuB;QAC7E,MAAM,eAAe,GAAG,IAAA,sBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAEtE,QAAQ,eAAe,EAAE;YACvB,KAAK,CAAC,CAAC;YACP,KAAK,EAAE,CAAC;YACR,KAAK,MAAM,CAAC;YACZ,KAAK,GAAG,CAAC;YACT,KAAK,KAAK;gBACR,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YAExC,KAAK,CAAC,CAAC;YACP,KAAK,EAAE,CAAC;YACR,KAAK,OAAO,CAAC;YACb,KAAK,GAAG,CAAC;YACT,KAAK,IAAI;gBACP,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YAEzC;gBACE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SAClJ;IACH,CAAC;CACF;AA1BD,wCA0BC;AAEY,QAAA,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path";
|
|
2
|
-
import type { CoerceResult } from '../types';
|
|
2
|
+
import type { CoercerContext, CoerceResult } from '../types';
|
|
3
3
|
import { SchemaValueCoercer } from '../types';
|
|
4
4
|
export declare class DateCoercer extends SchemaValueCoercer {
|
|
5
5
|
readonly sourceType: (NumberConstructor | StringConstructor | BigIntConstructor)[];
|
|
6
6
|
readonly targetType: DateConstructor;
|
|
7
|
-
coerce(value: number | string | bigint, path: JsonPath): CoerceResult;
|
|
7
|
+
coerce(value: number | string | bigint, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
8
8
|
}
|
|
9
9
|
export declare const dateCoercer: DateCoercer;
|
|
@@ -10,11 +10,11 @@ class DateCoercer extends types_1.SchemaValueCoercer {
|
|
|
10
10
|
this.sourceType = [Number, String, BigInt];
|
|
11
11
|
this.targetType = Date;
|
|
12
12
|
}
|
|
13
|
-
coerce(value, path) {
|
|
13
|
+
coerce(value, path, context) {
|
|
14
14
|
const parseValue = (0, type_guards_1.isBigInt)(value) ? Number(value) : value;
|
|
15
15
|
const date = new Date(parseValue);
|
|
16
16
|
if (Number.isNaN(date.getTime())) {
|
|
17
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, value.toString(), path) };
|
|
17
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, value.toString(), path, undefined, { fast: context.options.fastErrors }) };
|
|
18
18
|
}
|
|
19
19
|
return { success: true, value: date };
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/date.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA+C;AAC/C,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,WAAY,SAAQ,0BAAkB;IAAnD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;IAY7B,CAAC;IAVC,MAAM,CAAC,KAA+B,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"date.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/date.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA+C;AAC/C,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,WAAY,SAAQ,0BAAkB;IAAnD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;IAY7B,CAAC;IAVC,MAAM,CAAC,KAA+B,EAAE,IAAc,EAAE,OAAuB;QAC7E,MAAM,UAAU,GAAG,IAAA,sBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;QAElC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE;YAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SACxJ;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;CACF;AAdD,kCAcC;AACY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path";
|
|
2
|
-
import type { CoerceResult } from '../types';
|
|
2
|
+
import type { CoercerContext, CoerceResult } from '../types';
|
|
3
3
|
import { SchemaValueCoercer } from '../types';
|
|
4
4
|
export declare class NumberCoercer extends SchemaValueCoercer {
|
|
5
5
|
readonly sourceType: (StringConstructor | BooleanConstructor | BigIntConstructor)[];
|
|
6
6
|
readonly targetType: NumberConstructor;
|
|
7
|
-
coerce(value: string | bigint | boolean, path: JsonPath): CoerceResult;
|
|
7
|
+
coerce(value: string | bigint | boolean, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
8
8
|
}
|
|
9
9
|
export declare const numberCoercer: NumberCoercer;
|
|
@@ -9,10 +9,10 @@ class NumberCoercer extends types_1.SchemaValueCoercer {
|
|
|
9
9
|
this.sourceType = [String, BigInt, Boolean];
|
|
10
10
|
this.targetType = Number;
|
|
11
11
|
}
|
|
12
|
-
coerce(value, path) {
|
|
12
|
+
coerce(value, path, context) {
|
|
13
13
|
const result = Number(value);
|
|
14
14
|
if (Number.isNaN(result)) {
|
|
15
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, value.toString(), path, 'Value is not a number.') };
|
|
15
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, value.toString(), path, 'Value is not a number.', { fast: context.options.fastErrors }) };
|
|
16
16
|
}
|
|
17
17
|
return { success: true, value: result };
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/number.coercer.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAArD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,eAAU,GAAG,MAAM,CAAC;IAW/B,CAAC;IATC,MAAM,CAAC,KAAgC,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"number.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/number.coercer.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAArD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,eAAU,GAAG,MAAM,CAAC;IAW/B,CAAC;IATC,MAAM,CAAC,KAAgC,EAAE,IAAc,EAAE,OAAuB;QAC9E,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACxB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SACvK;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF;AAbD,sCAaC;AAEY,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path/json-path";
|
|
2
|
-
import type { CoerceResult } from '../types';
|
|
2
|
+
import type { CoercerContext, CoerceResult } from '../types';
|
|
3
3
|
import { SchemaValueCoercer } from '../types';
|
|
4
4
|
export declare class RegExpCoercer extends SchemaValueCoercer {
|
|
5
5
|
readonly sourceType: StringConstructor;
|
|
6
6
|
readonly targetType: RegExpConstructor;
|
|
7
7
|
readonly flags: string | undefined;
|
|
8
8
|
constructor(flags?: string);
|
|
9
|
-
coerce(value: string, path: JsonPath): CoerceResult;
|
|
9
|
+
coerce(value: string, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
10
10
|
}
|
|
11
11
|
export declare const regExpCoercer: RegExpCoercer;
|
|
@@ -10,12 +10,12 @@ class RegExpCoercer extends types_1.SchemaValueCoercer {
|
|
|
10
10
|
this.targetType = RegExp;
|
|
11
11
|
this.flags = flags;
|
|
12
12
|
}
|
|
13
|
-
coerce(value, path) {
|
|
13
|
+
coerce(value, path, context) {
|
|
14
14
|
try {
|
|
15
15
|
return { success: true, value: RegExp(value, this.flags) };
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, 'invalid regexp pattern', path, error.message) };
|
|
18
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, 'invalid regexp pattern', path, error.message, { fast: context.options.fastErrors }) };
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/regexp.coercer.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAKnD,YAAY,QAAgB,GAAG;QAC7B,KAAK,EAAE,CAAC;QALD,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;QAM3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"regexp.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/regexp.coercer.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAKnD,YAAY,QAAgB,GAAG;QAC7B,KAAK,EAAE,CAAC;QALD,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;QAM3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,IAAc,EAAE,OAAuB;QAC3D,IAAI;YACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;SAC5D;QACD,OAAO,KAAK,EAAE;YACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,wBAAwB,EAAE,IAAI,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SAC/K;IACH,CAAC;CACF;AAnBD,sCAmBC;AAEY,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path";
|
|
2
|
-
import type { CoerceResult } from '../types';
|
|
2
|
+
import type { CoercerContext, CoerceResult } from '../types';
|
|
3
3
|
import { SchemaValueCoercer } from '../types';
|
|
4
4
|
export declare class StringCoercer extends SchemaValueCoercer {
|
|
5
5
|
readonly sourceType: (NumberConstructor | DateConstructor | BooleanConstructor | BigIntConstructor)[];
|
|
6
6
|
readonly targetType: StringConstructor;
|
|
7
|
-
coerce(value: number | boolean | bigint | Date, path: JsonPath): CoerceResult;
|
|
7
|
+
coerce(value: number | boolean | bigint | Date, path: JsonPath, context: CoercerContext): CoerceResult;
|
|
8
8
|
}
|
|
9
9
|
export declare const stringCoercer: StringCoercer;
|
|
@@ -10,9 +10,9 @@ class StringCoercer extends types_1.SchemaValueCoercer {
|
|
|
10
10
|
this.sourceType = [Number, Boolean, BigInt, Date];
|
|
11
11
|
this.targetType = String;
|
|
12
12
|
}
|
|
13
|
-
coerce(value, path) {
|
|
13
|
+
coerce(value, path, context) {
|
|
14
14
|
if ((0, type_guards_1.isDate)(value) && !(0, type_guards_1.isValidDate)(value)) {
|
|
15
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, 'invalid date', path) };
|
|
15
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(this.targetType, 'invalid date', path, undefined, { fast: context.options.fastErrors }) };
|
|
16
16
|
}
|
|
17
17
|
return { success: true, value: value.toString() };
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/string.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA0D;AAC1D,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAArD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7C,eAAU,GAAG,MAAM,CAAC;IAS/B,CAAC;IAPC,MAAM,CAAC,KAAuC,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"string.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/string.coercer.ts"],"names":[],"mappings":";;;AACA,yDAA0D;AAC1D,kDAA8C;AAE9C,oCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAkB;IAArD;;QACW,eAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7C,eAAU,GAAG,MAAM,CAAC;IAS/B,CAAC;IAPC,MAAM,CAAC,KAAuC,EAAE,IAAc,EAAE,OAAuB;QACrF,IAAI,IAAA,oBAAM,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,CAAC,EAAE;YACxC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SACtJ;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpD,CAAC;CACF;AAXD,sCAWC;AAEY,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -15,8 +15,8 @@ class Uint8ArrayCoercer extends types_1.SchemaValueCoercer {
|
|
|
15
15
|
}
|
|
16
16
|
coerce(value, path, { options }) {
|
|
17
17
|
const testResult = schema_1.Schema.testWithFastError(byteNumberArraySchema, value, options, path);
|
|
18
|
-
if (!testResult.
|
|
19
|
-
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(Uint8Array, Array, path, undefined, { inner: testResult.error }) };
|
|
18
|
+
if (!testResult.valid) {
|
|
19
|
+
return { success: false, error: schema_error_1.SchemaError.couldNotCoerce(Uint8Array, Array, path, undefined, { inner: testResult.error, fast: options.fastErrors }) };
|
|
20
20
|
}
|
|
21
21
|
return { success: true, value: Uint8Array.from(testResult.value) };
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8-array.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/uint8-array.coercer.ts"],"names":[],"mappings":";;;AACA,sCAAmC;AACnC,kDAA8C;AAC9C,4CAAyC;AACzC,8CAA2C;AAE3C,oCAA8C;AAE9C,MAAM,qBAAqB,GAAG,IAAA,aAAK,EAAC,IAAA,eAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAEzF,MAAa,iBAAkB,SAAQ,0BAAkB;IAAzD;;QACW,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,UAAU,CAAC;IAWnC,CAAC;IATC,MAAM,CAAC,KAAY,EAAE,IAAc,EAAE,EAAE,OAAO,EAAkB;QAC9D,MAAM,UAAU,GAAG,eAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAEzF,IAAI,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"uint8-array.coercer.js","sourceRoot":"","sources":["../../../source/schema/coercers/uint8-array.coercer.ts"],"names":[],"mappings":";;;AACA,sCAAmC;AACnC,kDAA8C;AAC9C,4CAAyC;AACzC,8CAA2C;AAE3C,oCAA8C;AAE9C,MAAM,qBAAqB,GAAG,IAAA,aAAK,EAAC,IAAA,eAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AAEzF,MAAa,iBAAkB,SAAQ,0BAAkB;IAAzD;;QACW,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,UAAU,CAAC;IAWnC,CAAC;IATC,MAAM,CAAC,KAAY,EAAE,IAAc,EAAE,EAAE,OAAO,EAAkB;QAC9D,MAAM,UAAU,GAAG,eAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAEzF,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;YACrB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SACzJ;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IACrE,CAAC;CACF;AAbD,8CAaC;AAEY,QAAA,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path/json-path";
|
|
2
|
-
import type { Enumeration
|
|
3
|
-
import type { ConstraintResult } from '../types';
|
|
2
|
+
import type { Enumeration, OneOrMany } from "../../types";
|
|
3
|
+
import type { ConstraintContext, ConstraintResult } from '../types';
|
|
4
4
|
import { SchemaValueConstraint } from '../types';
|
|
5
5
|
export declare class EnumerationConstraint extends SchemaValueConstraint {
|
|
6
6
|
private readonly allowedValuesSet;
|
|
7
7
|
private readonly allowedValuesString;
|
|
8
|
-
readonly enumeration:
|
|
8
|
+
readonly enumeration: Enumeration;
|
|
9
9
|
readonly suitableTypes: SchemaValueConstraint['suitableTypes'];
|
|
10
10
|
readonly expects: OneOrMany<string>;
|
|
11
|
-
constructor(enumeration:
|
|
12
|
-
validate(value: number, path: JsonPath): ConstraintResult;
|
|
11
|
+
constructor(enumeration: Enumeration);
|
|
12
|
+
validate(value: number, path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
13
13
|
}
|
|
@@ -18,11 +18,11 @@ class EnumerationConstraint extends types_1.SchemaValueConstraint {
|
|
|
18
18
|
this.suitableTypes = [...(0, iterable_helpers_1.distinct)(allowedValues.map((value) => (0, utils_2.getValueType)(value)))];
|
|
19
19
|
this.expects = `one of [${this.allowedValuesString}]`;
|
|
20
20
|
}
|
|
21
|
-
validate(value, path) {
|
|
21
|
+
validate(value, path, context) {
|
|
22
22
|
if (!this.allowedValuesSet.has(value)) {
|
|
23
|
-
return {
|
|
23
|
+
return { valid: false, error: schema_error_1.SchemaError.expectedButGot(this.expects, value.toString(), path, { fast: context.options.fastErrors }) };
|
|
24
24
|
}
|
|
25
|
-
return {
|
|
25
|
+
return { valid: true };
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
exports.EnumerationConstraint = EnumerationConstraint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumeration.js","sourceRoot":"","sources":["../../../source/schema/constraints/enumeration.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,uCAAqC;AACrC,mEAAoD;AACpD,yDAAwD;AACxD,kDAA8C;AAE9C,oCAAiD;AACjD,oCAAwC;AAExC,MAAa,qBAAsB,SAAQ,6BAAqB;IAQ9D,YAAY,
|
|
1
|
+
{"version":3,"file":"enumeration.js","sourceRoot":"","sources":["../../../source/schema/constraints/enumeration.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,uCAAqC;AACrC,mEAAoD;AACpD,yDAAwD;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EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AA5BD,sDA4BC"}
|
|
@@ -2,7 +2,7 @@ import type { JsonPath } from "../../json-path/json-path";
|
|
|
2
2
|
import type { Decorator } from "../../reflection";
|
|
3
3
|
import type { OneOrMany } from "../../types";
|
|
4
4
|
import { SchemaError } from '../schema.error';
|
|
5
|
-
import type { ConstraintResult } from '../types';
|
|
5
|
+
import type { ConstraintContext, ConstraintResult } from '../types';
|
|
6
6
|
import { SchemaValueConstraint } from '../types';
|
|
7
7
|
export declare type GenericConstraintResult = {
|
|
8
8
|
success: true;
|
|
@@ -17,6 +17,6 @@ export declare class GenericConstraint<T> extends SchemaValueConstraint {
|
|
|
17
17
|
readonly expects: OneOrMany<string>;
|
|
18
18
|
readonly constraintFunction: GenericConstraintFunction<T>;
|
|
19
19
|
constructor(constraintFunction: GenericConstraintFunction<T>, expects?: OneOrMany<string>);
|
|
20
|
-
validate(value: T, path: JsonPath): ConstraintResult;
|
|
20
|
+
validate(value: T, path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
21
21
|
}
|
|
22
22
|
export declare function Constraint<T>(constraintFunction: GenericConstraintFunction<T>, expects?: OneOrMany<string>): Decorator<'property' | 'accessor'>;
|
|
@@ -13,12 +13,12 @@ class GenericConstraint extends types_1.SchemaValueConstraint {
|
|
|
13
13
|
this.constraintFunction = constraintFunction;
|
|
14
14
|
this.expects = expects;
|
|
15
15
|
}
|
|
16
|
-
validate(value, path) {
|
|
16
|
+
validate(value, path, context) {
|
|
17
17
|
const result = this.constraintFunction(value, path);
|
|
18
18
|
if ((0, type_guards_1.isBoolean)(result)) {
|
|
19
19
|
return result
|
|
20
|
-
? {
|
|
21
|
-
: {
|
|
20
|
+
? { valid: true }
|
|
21
|
+
: { valid: false, error: schema_error_1.SchemaError.expectedButGot(this.expects, 'invalid value', path, { fast: context.options.fastErrors }) };
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/constraints/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,yDAAgD;AAChD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAQjD,MAAa,iBAAqB,SAAQ,6BAAqB;IAK7D,YAAY,kBAAgD,EAAE,UAA6B,aAAa;QACtG,KAAK,EAAE,CAAC;QALD,kBAAa,GAAG,MAAM,CAAC;QAO9B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,QAAQ,CAAC,KAAQ,EAAE,IAAc;
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/constraints/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,yDAAgD;AAChD,8CAAqE;AACrE,kDAA8C;AAE9C,oCAAiD;AAQjD,MAAa,iBAAqB,SAAQ,6BAAqB;IAK7D,YAAY,kBAAgD,EAAE,UAA6B,aAAa;QACtG,KAAK,EAAE,CAAC;QALD,kBAAa,GAAG,MAAM,CAAC;QAO9B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,QAAQ,CAAC,KAAQ,EAAE,IAAc,EAAE,OAA0B;QAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEpD,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,EAAE;YACrB,OAAO,MAAM;gBACX,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;gBACjB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,0BAAW,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;SACpI;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvBD,8CAuBC;AAED,SAAgB,UAAU,CAAI,kBAAgD,EAAE,OAA2B;IACzG,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO,IAAA,iDAAoC,EAAC,UAAU,CAAC,CAAC;AAC1D,CAAC;AAHD,gCAGC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { JsonPath } from "../../json-path/json-path";
|
|
2
2
|
import type { Decorator } from "../../reflection";
|
|
3
|
-
import type { ConstraintResult } from '../types';
|
|
3
|
+
import type { ConstraintContext, ConstraintResult } from '../types';
|
|
4
4
|
import { SchemaValueConstraint } from '../types';
|
|
5
5
|
export declare class IntegerConstraint extends SchemaValueConstraint {
|
|
6
6
|
readonly suitableTypes: NumberConstructor;
|
|
7
7
|
readonly expects: string;
|
|
8
8
|
constructor();
|
|
9
|
-
validate(value: number, path: JsonPath): ConstraintResult;
|
|
9
|
+
validate(value: number, path: JsonPath, context: ConstraintContext): ConstraintResult;
|
|
10
10
|
}
|
|
11
11
|
export declare const integerConstraint: IntegerConstraint;
|
|
12
12
|
export declare function Integer(): Decorator<'property' | 'accessor'>;
|
|
@@ -11,11 +11,11 @@ class IntegerConstraint extends types_1.SchemaValueConstraint {
|
|
|
11
11
|
this.suitableTypes = Number;
|
|
12
12
|
this.expects = 'an integer';
|
|
13
13
|
}
|
|
14
|
-
validate(value, path) {
|
|
14
|
+
validate(value, path, context) {
|
|
15
15
|
if (!Number.isInteger(value)) {
|
|
16
|
-
return {
|
|
16
|
+
return { valid: false, error: schema_error_1.SchemaError.expectedButGot(this.expects, value.toString(), path, { fast: context.options.fastErrors }) };
|
|
17
17
|
}
|
|
18
|
-
return {
|
|
18
|
+
return { valid: true };
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.IntegerConstraint = IntegerConstraint;
|