@tstdl/base 0.78.0-beta9 → 0.78.0
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 +38 -16
- package/api/client/client.js.map +1 -1
- package/api/response.js +4 -3
- package/api/response.js.map +1 -1
- package/api/server/api-controller.d.ts +3 -1
- package/api/server/api-controller.js +7 -2
- package/api/server/api-controller.js.map +1 -1
- package/api/server/gateway.d.ts +15 -3
- package/api/server/gateway.js +53 -37
- package/api/server/gateway.js.map +1 -1
- package/api/server/middlewares/allowed-methods.middleware.js +1 -1
- package/api/server/middlewares/allowed-methods.middleware.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 +36 -14
- 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.d.ts +17 -4
- package/application/application.js +97 -48
- package/application/application.js.map +1 -1
- package/collections/awaitable/awaitable-list.js +10 -11
- package/collections/awaitable/awaitable-list.js.map +1 -1
- package/collections/observable/observable-array.js +1 -1
- package/collections/observable/observable-array.js.map +1 -1
- package/collections/observable/observable-collection-base.js +12 -14
- package/collections/observable/observable-collection-base.js.map +1 -1
- package/collections/observable/observable-list-base.js +6 -8
- package/collections/observable/observable-list-base.js.map +1 -1
- package/collections/observable/observable-sorted-array-list.js +3 -3
- package/collections/observable/observable-sorted-array-list.js.map +1 -1
- package/collections/sorted-array-list.js +3 -3
- package/collections/sorted-array-list.js.map +1 -1
- package/collections/sorted-map.js +1 -1
- package/collections/sorted-map.js.map +1 -1
- package/container/container.js +19 -21
- package/container/container.js.map +1 -1
- package/container/decorators.d.ts +1 -1
- package/container/decorators.js.map +1 -1
- package/container/resolve-chain.d.ts +2 -1
- package/container/resolve-chain.js +6 -2
- package/container/resolve-chain.js.map +1 -1
- package/core.js +4 -3
- package/core.js.map +1 -1
- package/css/theme/theme.service.js.map +1 -1
- package/data-structures/circular-buffer.js +5 -6
- package/data-structures/circular-buffer.js.map +1 -1
- package/data-structures/collection.js +4 -5
- package/data-structures/collection.js.map +1 -1
- package/data-structures/index-out-of-bounds.error.d.ts +1 -1
- package/data-structures/index-out-of-bounds.error.js +2 -2
- package/data-structures/index-out-of-bounds.error.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.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/map.d.ts +20 -0
- package/data-structures/map.js +65 -0
- package/data-structures/map.js.map +1 -0
- package/data-structures/sorted-array-list.js +2 -2
- package/data-structures/sorted-array-list.js.map +1 -1
- package/database/mongo/classes.js.map +1 -1
- package/database/mongo/mongo-base.repository.d.ts +1 -0
- package/database/mongo/mongo-base.repository.js +6 -3
- package/database/mongo/mongo-base.repository.js.map +1 -1
- package/database/mongo/mongo-entity-repository.js +18 -25
- 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/environment.d.ts +10 -0
- package/environment.js +26 -0
- package/environment.js.map +1 -0
- package/error/custom.error.d.ts +7 -3
- package/error/custom.error.js +17 -8
- package/error/custom.error.js.map +1 -1
- package/error/index.d.ts +1 -0
- package/error/index.js +1 -0
- package/error/index.js.map +1 -1
- package/error/max-bytes-exceeded.error.d.ts +1 -0
- package/error/max-bytes-exceeded.error.js +3 -0
- package/error/max-bytes-exceeded.error.js.map +1 -1
- package/error/not-implemented.error.js +1 -1
- package/error/not-implemented.error.js.map +1 -1
- package/error/not-supported.error.d.ts +7 -0
- package/error/not-supported.error.js +17 -0
- package/error/not-supported.error.js.map +1 -0
- package/error/unsupported-media-type.error.js +1 -1
- package/error/unsupported-media-type.error.js.map +1 -1
- package/examples/api/basic-overview.js +17 -25
- package/examples/api/basic-overview.js.map +1 -1
- package/examples/api/streaming.d.ts +1 -0
- package/examples/api/streaming.js +79 -0
- package/examples/api/streaming.js.map +1 -0
- 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 +9 -6
- 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/examples/template/basic.d.ts +1 -0
- package/examples/template/basic.js +25 -0
- package/examples/template/basic.js.map +1 -0
- package/examples/template/templates/hello-name.d.ts +2 -0
- package/examples/template/templates/hello-name.js +23 -0
- package/examples/template/templates/hello-name.js.map +1 -0
- package/http/client/adapters/undici-http-client.adapter.d.ts +1 -2
- package/http/client/adapters/undici-http-client.adapter.js +11 -12
- package/http/client/adapters/undici-http-client.adapter.js.map +1 -1
- package/http/client/http-client-request.d.ts +24 -14
- package/http/client/http-client-request.js +4 -2
- package/http/client/http-client-request.js.map +1 -1
- package/http/client/http-client-response.d.ts +10 -12
- package/http/client/http-client-response.js +5 -1
- package/http/client/http-client-response.js.map +1 -1
- package/http/client/http-client.adapter.d.ts +1 -2
- package/http/client/http-client.adapter.js.map +1 -1
- package/http/client/http-client.d.ts +30 -31
- package/http/client/http-client.js +107 -74
- package/http/client/http-client.js.map +1 -1
- package/http/http-body.d.ts +19 -0
- package/http/http-body.js +52 -0
- package/http/http-body.js.map +1 -0
- package/http/http-headers.d.ts +3 -0
- package/http/http-headers.js +6 -0
- package/http/http-headers.js.map +1 -1
- package/http/http-value-map.js +2 -2
- package/http/http-value-map.js.map +1 -1
- package/http/http.error.d.ts +5 -2
- package/http/http.error.js +27 -5
- package/http/http.error.js.map +1 -1
- package/http/index.d.ts +2 -0
- package/http/index.js +2 -0
- package/http/index.js.map +1 -1
- package/http/server/http-server-request.d.ts +5 -10
- package/http/server/http-server-request.js +3 -30
- package/http/server/http-server-request.js.map +1 -1
- package/http/server/http-server-response.d.ts +4 -4
- package/http/server/node/node-http-server.js +6 -5
- package/http/server/node/node-http-server.js.map +1 -1
- package/http/types.d.ts +1 -11
- package/http/types.js +1 -2
- package/http/types.js.map +1 -1
- package/http/utils.d.ts +15 -0
- package/http/utils.js +113 -0
- package/http/utils.js.map +1 -0
- package/image-service/image-service.js.map +1 -1
- package/image-service/imgproxy/imgproxy-image-service.js.map +1 -1
- package/json-path/json-path.d.ts +8 -5
- package/json-path/json-path.js +15 -1
- package/json-path/json-path.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 +1 -1
- package/logger/console/logger.js.map +1 -1
- package/logger/logger.d.ts +2 -2
- 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/message-bus/message-bus-base.js +1 -2
- package/message-bus/message-bus-base.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 +72 -25
- package/openid-connect/oidc.service.js.map +1 -1
- package/package.json +13 -12
- package/pdf/pdf.service.d.ts +92 -12
- package/pdf/pdf.service.js +234 -34
- package/pdf/pdf.service.js.map +1 -1
- package/pool/pool.d.ts +23 -4
- package/pool/pool.js +76 -40
- package/pool/pool.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/require.d.ts +1 -0
- package/require.js +9 -0
- package/require.js.map +1 -0
- package/rpc/endpoints/message-port.rpc-endpoint.d.ts +19 -0
- package/rpc/endpoints/message-port.rpc-endpoint.js +34 -0
- package/rpc/endpoints/message-port.rpc-endpoint.js.map +1 -0
- package/rpc/index.d.ts +4 -0
- package/rpc/index.js +21 -0
- package/rpc/index.js.map +1 -0
- package/rpc/model.d.ts +72 -0
- package/rpc/model.js +13 -0
- package/rpc/model.js.map +1 -0
- package/rpc/rpc-endpoint.d.ts +11 -0
- package/rpc/rpc-endpoint.js +23 -0
- package/rpc/rpc-endpoint.js.map +1 -0
- package/rpc/rpc-error.d.ts +8 -0
- package/rpc/rpc-error.js +26 -0
- package/rpc/rpc-error.js.map +1 -0
- package/rpc/rpc.d.ts +19 -0
- package/rpc/rpc.js +263 -0
- package/rpc/rpc.js.map +1 -0
- package/rxjs/retry-backoff.js +4 -5
- package/rxjs/retry-backoff.js.map +1 -1
- package/schema/array-constraints/maximum-length.d.ts +2 -2
- package/schema/array-constraints/maximum-length.js +2 -2
- package/schema/array-constraints/maximum-length.js.map +1 -1
- package/schema/array-constraints/minimum-length.d.ts +2 -2
- package/schema/array-constraints/minimum-length.js +2 -2
- 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 +3 -3
- 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 +3 -3
- 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 +6 -6
- package/schema/constraints/enumeration.js.map +1 -1
- package/schema/constraints/generic.d.ts +2 -2
- package/schema/constraints/generic.js +2 -2
- package/schema/constraints/generic.js.map +1 -1
- package/schema/constraints/integer.d.ts +2 -2
- package/schema/constraints/integer.js +2 -2
- package/schema/constraints/integer.js.map +1 -1
- package/schema/constraints/literal.d.ts +2 -2
- package/schema/constraints/literal.js +2 -2
- package/schema/constraints/literal.js.map +1 -1
- package/schema/constraints/maximum-date.d.ts +2 -2
- package/schema/constraints/maximum-date.js +2 -2
- package/schema/constraints/maximum-date.js.map +1 -1
- package/schema/constraints/maximum-length.d.ts +3 -3
- package/schema/constraints/maximum-length.js +2 -2
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/maximum.d.ts +2 -2
- package/schema/constraints/maximum.js +2 -2
- package/schema/constraints/maximum.js.map +1 -1
- package/schema/constraints/minimum-date.d.ts +2 -2
- package/schema/constraints/minimum-date.js +2 -2
- package/schema/constraints/minimum-date.js.map +1 -1
- package/schema/constraints/minimum-length.d.ts +3 -3
- package/schema/constraints/minimum-length.js +2 -2
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/constraints/minimum.d.ts +2 -2
- package/schema/constraints/minimum.js +2 -2
- package/schema/constraints/minimum.js.map +1 -1
- package/schema/constraints/pattern.d.ts +2 -2
- package/schema/constraints/pattern.js +2 -2
- package/schema/constraints/pattern.js.map +1 -1
- package/schema/decorators/array.d.ts +2 -2
- package/schema/decorators/array.js.map +1 -1
- package/schema/decorators/defaulted.d.ts +2 -2
- package/schema/decorators/defaulted.js.map +1 -1
- package/schema/decorators/index.d.ts +1 -0
- package/schema/decorators/index.js +1 -0
- package/schema/decorators/index.js.map +1 -1
- package/schema/decorators/one-or-many.d.ts +6 -0
- package/schema/decorators/one-or-many.js +12 -0
- package/schema/decorators/one-or-many.js.map +1 -0
- 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/decorators/utils.d.ts +3 -2
- package/schema/decorators/utils.js +8 -4
- package/schema/decorators/utils.js.map +1 -1
- package/schema/schema.d.ts +4 -10
- package/schema/schema.error.d.ts +6 -5
- package/schema/schema.error.js +13 -10
- package/schema/schema.error.js.map +1 -1
- package/schema/schema.js +113 -104
- package/schema/schema.js.map +1 -1
- package/schema/schemas/array.d.ts +3 -3
- package/schema/schemas/array.js +1 -1
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/assign.d.ts +6 -6
- package/schema/schemas/assign.js +3 -1
- package/schema/schemas/assign.js.map +1 -1
- package/schema/schemas/constraint.d.ts +3 -2
- package/schema/schemas/constraint.js.map +1 -1
- package/schema/schemas/defaulted.d.ts +2 -2
- package/schema/schemas/defaulted.js.map +1 -1
- package/schema/schemas/enumeration.js +1 -1
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/index.d.ts +3 -1
- package/schema/schemas/index.js +3 -1
- package/schema/schemas/index.js.map +1 -1
- package/schema/schemas/nullable.d.ts +2 -2
- package/schema/schemas/nullable.js.map +1 -1
- package/schema/schemas/number.d.ts +1 -1
- package/schema/schemas/number.js +0 -3
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/omit.d.ts +4 -0
- package/schema/schemas/{exclude.js → omit.js} +8 -6
- package/schema/schemas/omit.js.map +1 -0
- package/schema/schemas/one-or-many.d.ts +10 -0
- package/schema/schemas/one-or-many.js +12 -0
- package/schema/schemas/one-or-many.js.map +1 -0
- package/schema/schemas/optional.d.ts +3 -2
- package/schema/schemas/optional.js.map +1 -1
- package/schema/schemas/partial.d.ts +4 -0
- package/schema/schemas/partial.js +22 -0
- package/schema/schemas/partial.js.map +1 -0
- package/schema/schemas/pick.d.ts +2 -2
- package/schema/schemas/pick.js +3 -1
- package/schema/schemas/pick.js.map +1 -1
- package/schema/schemas/record.d.ts +2 -2
- package/schema/schemas/record.js.map +1 -1
- package/schema/schemas/union.d.ts +4 -9
- package/schema/schemas/union.js.map +1 -1
- package/schema/types.d.ts +30 -20
- package/schema/types.js +22 -8
- package/schema/types.js.map +1 -1
- package/schema/utils/schema.d.ts +6 -1
- package/schema/utils/schema.js +60 -7
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +5 -3
- package/schema/utils/value-type.js +22 -7
- 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/module.js +15 -1
- package/search-index/elastic/module.js.map +1 -1
- package/search-index/elastic/search-index.js +5 -4
- package/search-index/elastic/search-index.js.map +1 -1
- package/search-index/error.d.ts +1 -1
- package/search-index/error.js +2 -2
- package/search-index/error.js.map +1 -1
- package/serializer/handlers/register.d.ts +2 -2
- package/serializer/handlers/register.js +6 -2
- package/serializer/handlers/register.js.map +1 -1
- package/serializer/serializable.d.ts +11 -8
- package/serializer/serializable.js +13 -4
- package/serializer/serializable.js.map +1 -1
- package/serializer/serializer.js +21 -8
- package/serializer/serializer.js.map +1 -1
- package/serializer/types.d.ts +21 -6
- package/serializer/types.js +2 -1
- package/serializer/types.js.map +1 -1
- package/supports.d.ts +5 -0
- package/supports.js +9 -0
- package/supports.js.map +1 -0
- 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 +2 -0
- package/{rxjs/compat → threading}/index.js +2 -1
- package/threading/index.js.map +1 -0
- package/threading/thread-pool.d.ts +20 -0
- package/threading/thread-pool.js +50 -0
- package/threading/thread-pool.js.map +1 -0
- package/threading/thread-worker.d.ts +3 -0
- package/threading/thread-worker.js +9 -0
- package/threading/thread-worker.js.map +1 -0
- package/types.d.ts +27 -9
- package/utils/alphabet.d.ts +3 -1
- package/utils/alphabet.js +2 -0
- package/utils/alphabet.js.map +1 -1
- package/utils/array/array.d.ts +1 -2
- package/utils/array/array.js.map +1 -1
- package/utils/async-iterable-helpers/observable-iterable.js +1 -2
- package/utils/async-iterable-helpers/observable-iterable.js.map +1 -1
- package/utils/async-iterable-helpers/take-until.js +2 -3
- package/utils/async-iterable-helpers/take-until.js.map +1 -1
- package/utils/base64.js +3 -2
- package/utils/base64.js.map +1 -1
- package/utils/binary.js +3 -2
- package/utils/binary.js.map +1 -1
- package/utils/cancellation-token.d.ts +28 -28
- package/utils/cancellation-token.js +14 -14
- package/utils/cancellation-token.js.map +1 -1
- package/utils/clone.js +4 -0
- package/utils/clone.js.map +1 -1
- package/utils/compression.d.ts +19 -15
- package/utils/compression.js +43 -10
- package/utils/compression.js.map +1 -1
- package/utils/encoding.d.ts +10 -0
- package/utils/encoding.js +20 -4
- 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/feedable-async-iterable.js +1 -2
- package/utils/feedable-async-iterable.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 +3 -14
- package/utils/helpers.js.map +1 -1
- package/utils/image.js +7 -8
- package/utils/image.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/math.d.ts +37 -10
- package/utils/math.js +57 -12
- package/utils/math.js.map +1 -1
- package/utils/object/decycle.js +10 -21
- package/utils/object/decycle.js.map +1 -1
- package/utils/object/dereference.d.ts +7 -5
- package/utils/object/dereference.js +4 -4
- package/utils/object/dereference.js.map +1 -1
- package/utils/object/forward-ref.js +3 -19
- package/utils/object/forward-ref.js.map +1 -1
- package/utils/object/merge.js +3 -3
- package/utils/object/merge.js.map +1 -1
- package/utils/object/object.js +3 -3
- package/utils/object/object.js.map +1 -1
- package/utils/object/property-name.d.ts +2 -2
- package/utils/patch-worker.js +1 -2
- package/utils/patch-worker.js.map +1 -1
- package/utils/periodic-sampler.js +2 -2
- package/utils/periodic-sampler.js.map +1 -1
- package/utils/proxy.d.ts +6 -0
- package/utils/proxy.js +21 -0
- package/utils/proxy.js.map +1 -0
- package/utils/stream/finalize-stream.d.ts +1 -0
- package/utils/stream/finalize-stream.js +38 -0
- package/utils/stream/finalize-stream.js.map +1 -0
- package/utils/stream/index.d.ts +4 -3
- package/utils/stream/index.js +4 -3
- package/utils/stream/index.js.map +1 -1
- package/utils/stream/readable-stream-adapter.d.ts +5 -0
- package/utils/stream/readable-stream-adapter.js +45 -0
- package/utils/stream/readable-stream-adapter.js.map +1 -0
- package/utils/stream/readable-stream-from-promise.d.ts +1 -0
- package/utils/stream/readable-stream-from-promise.js +12 -0
- package/utils/stream/readable-stream-from-promise.js.map +1 -0
- package/utils/stream/size-limited-stream.d.ts +2 -0
- package/utils/stream/size-limited-stream.js +18 -0
- package/utils/stream/size-limited-stream.js.map +1 -0
- package/utils/stream/stream-reader.d.ts +2 -1
- package/utils/stream/stream-reader.js +7 -10
- package/utils/stream/stream-reader.js.map +1 -1
- package/utils/throw.d.ts +2 -0
- package/utils/throw.js +15 -0
- package/utils/throw.js.map +1 -0
- package/utils/timer.js +2 -2
- package/utils/timer.js.map +1 -1
- package/utils/timing.js +2 -2
- package/utils/timing.js.map +1 -1
- package/utils/type-guards.d.ts +34 -16
- package/utils/type-guards.js +112 -75
- 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/http/client/adapters/got-http-client.adapter.d.ts +0 -10
- package/http/client/adapters/got-http-client.adapter.js +0 -141
- package/http/client/adapters/got-http-client.adapter.js.map +0 -1
- package/http/client/adapters/utils.d.ts +0 -11
- package/http/client/adapters/utils.js +0 -79
- package/http/client/adapters/utils.js.map +0 -1
- 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/rxjs/compat/first-value-from.d.ts +0 -2
- package/rxjs/compat/first-value-from.js +0 -9
- package/rxjs/compat/first-value-from.js.map +0 -1
- package/rxjs/compat/index.d.ts +0 -1
- package/rxjs/compat/index.js.map +0 -1
- package/schema/schemas/exclude.d.ts +0 -4
- package/schema/schemas/exclude.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
- package/utils/stream/async-iterable-readable.d.ts +0 -13
- package/utils/stream/async-iterable-readable.js +0 -40
- package/utils/stream/async-iterable-readable.js.map +0 -1
- package/utils/stream/async-writable-stream.d.ts +0 -16
- package/utils/stream/async-writable-stream.js +0 -41
- package/utils/stream/async-writable-stream.js.map +0 -1
- package/utils/stream/typed-readable.d.ts +0 -58
- package/utils/stream/typed-readable.js +0 -9
- package/utils/stream/typed-readable.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;AAExE,oCAAmD;AAQnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,WAAW,GAA4B,EAAE,CAAC;IAEhD,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC1D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC1D;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE;QAC3B,WAAW,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;KACrC;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,gBAAgB,EAAE,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAnBD,wBAmBC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OneOrMany, Record } from "../../types";
|
|
2
|
+
import type { Simplify } from 'type-fest';
|
|
3
|
+
import type { ObjectSchema, ObjectSchemaOrType } from '../types';
|
|
4
|
+
export declare function omit<T extends Record, K extends keyof T>(schemaOrType: ObjectSchemaOrType<T>, keys: OneOrMany<K>): ObjectSchema<Simplify<Omit<T, K>>>;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.omit = void 0;
|
|
4
4
|
const array_1 = require("../../utils/array/array");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const schema_1 = require("../utils/schema");
|
|
7
|
+
function omit(schemaOrType, keys) {
|
|
8
|
+
const schema = (0, schema_1.getObjectSchema)(schemaOrType);
|
|
9
|
+
const keyArray = (0, array_1.toArray)(keys);
|
|
8
10
|
const entries = Object.entries(schema.properties);
|
|
9
|
-
const pickedEntries = entries.filter(([propertyKey]) => !
|
|
11
|
+
const pickedEntries = entries.filter(([propertyKey]) => !keyArray.includes(propertyKey));
|
|
10
12
|
const pickedSchema = (0, types_1.objectSchema)({
|
|
11
13
|
...schema,
|
|
12
14
|
properties: Object.fromEntries(pickedEntries)
|
|
13
15
|
});
|
|
14
16
|
return pickedSchema;
|
|
15
17
|
}
|
|
16
|
-
exports.
|
|
17
|
-
//# sourceMappingURL=
|
|
18
|
+
exports.omit = omit;
|
|
19
|
+
//# sourceMappingURL=omit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../../source/schema/schemas/omit.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAG9C,oCAAwC;AACxC,4CAAkD;AAElD,SAAgB,IAAI,CAAsC,YAAmC,EAAE,IAAkB;IAC/G,MAAM,MAAM,GAAG,IAAA,wBAAe,EAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAA,eAAO,EAAC,IAAI,CAAC,CAAC;IAE/B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAgB,CAAC,CAAC,CAAC;IAE9F,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC;QAChC,GAAG,MAAM;QACT,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAA8B;KAC3E,CAAC,CAAC;IAEH,OAAO,YAAmD,CAAC;AAC7D,CAAC;AAbD,oBAaC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OneOrMany } from "../../types";
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
3
|
+
import type { ValueSchema } from '../types';
|
|
4
|
+
export declare type OneOrManyOptions = {
|
|
5
|
+
/** minimum array length */
|
|
6
|
+
minimumLength?: number;
|
|
7
|
+
/** maximum array length */
|
|
8
|
+
maximumLength?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function oneOrMany<T, O = T>(innerValues: OneOrMany<SchemaTestable<T, O>>, options?: OneOrManyOptions): ValueSchema<T, O | O[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.oneOrMany = void 0;
|
|
5
|
+
const array_1 = require("../../utils/array");
|
|
6
|
+
const array_2 = require("./array");
|
|
7
|
+
const union_1 = require("./union");
|
|
8
|
+
function oneOrMany(innerValues, options = {}) {
|
|
9
|
+
return (0, union_1.union)((0, array_2.array)(innerValues, options), ...(0, array_1.toArray)(innerValues));
|
|
10
|
+
}
|
|
11
|
+
exports.oneOrMany = oneOrMany;
|
|
12
|
+
//# sourceMappingURL=one-or-many.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-or-many.js","sourceRoot":"","sources":["../../../source/schema/schemas/one-or-many.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,6CAAwC;AAGxC,mCAAgC;AAChC,mCAAgC;AAUhC,SAAgB,SAAS,CAAW,WAA4C,EAAE,UAA4B,EAAE;IAC9G,OAAO,IAAA,aAAK,EAAC,IAAA,aAAK,EAAC,WAAW,EAAE,OAAO,CAAC,EAAE,GAAG,IAAA,eAAO,EAAC,WAAW,CAAC,CAA4B,CAAC;AAChG,CAAC;AAFD,8BAEC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OneOrMany } from "../../types";
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
2
3
|
import type { ValueSchema } from '../types';
|
|
3
|
-
export declare function optional<T, O>(schema:
|
|
4
|
+
export declare function optional<T, O>(schema: OneOrMany<SchemaTestable<T, O>>): ValueSchema<T | undefined, O | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;AAGA,oCAAuC;AAEvC,SAAgB,QAAQ,CAAO,MAAuC;IACpE,OAAO,IAAA,mBAAW,EAAC,MAAsD,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACjG,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OneOrMany, PartialProperty, Record } from "../../types";
|
|
2
|
+
import type { ObjectSchema, ObjectSchemaOrType } from '../types';
|
|
3
|
+
export declare function partial<T extends Record>(schema: ObjectSchemaOrType<T>): ObjectSchema<Partial<T>>;
|
|
4
|
+
export declare function partial<T extends Record, K extends keyof T>(schema: ObjectSchemaOrType<T>, keys: OneOrMany<K>): ObjectSchema<PartialProperty<T, K>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.partial = void 0;
|
|
4
|
+
const array_1 = require("../../utils/array/array");
|
|
5
|
+
const object_1 = require("../../utils/object");
|
|
6
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const optional_1 = require("./optional");
|
|
10
|
+
function partial(schemaOrType, keys) {
|
|
11
|
+
const schema = (0, utils_1.getObjectSchema)(schemaOrType);
|
|
12
|
+
const keyArray = (0, type_guards_1.isDefined)(keys) ? (0, array_1.toArray)(keys) : undefined;
|
|
13
|
+
const makeAllOptional = (0, type_guards_1.isUndefined)(keyArray);
|
|
14
|
+
const partialEntries = (0, object_1.mapObjectValues)(schema.properties, (propertySchema, key) => ((makeAllOptional || keyArray.includes(key)) ? (0, optional_1.optional)(propertySchema) : propertySchema));
|
|
15
|
+
const pickedSchema = (0, types_1.objectSchema)({
|
|
16
|
+
...schema,
|
|
17
|
+
properties: partialEntries
|
|
18
|
+
});
|
|
19
|
+
return pickedSchema;
|
|
20
|
+
}
|
|
21
|
+
exports.partial = partial;
|
|
22
|
+
//# sourceMappingURL=partial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial.js","sourceRoot":"","sources":["../../../source/schema/schemas/partial.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAC9C,+CAAiD;AACjD,yDAA6D;AAE7D,oCAAwC;AACxC,oCAA2C;AAC3C,yCAAsC;AAItC,SAAgB,OAAO,CAAsC,YAAmC,EAAE,IAAmB;IACnH,MAAM,MAAM,GAAG,IAAA,uBAAe,EAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,QAAQ,GAAG,IAAA,uBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,eAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,MAAM,eAAe,GAAG,IAAA,yBAAW,EAAC,QAAQ,CAAC,CAAC;IAE9C,MAAM,cAAc,GAAG,IAAA,wBAAe,EAAC,MAAM,CAAC,UAAU,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAA8B,CAAC;IAEhN,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC;QAChC,GAAG,MAAM;QACT,UAAU,EAAE,cAAc;KAC3B,CAAC,CAAC;IAEH,OAAO,YAAmD,CAAC;AAC7D,CAAC;AAdD,0BAcC"}
|
package/schema/schemas/pick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { OneOrMany, Record } from "../../types";
|
|
2
2
|
import type { Simplify } from 'type-fest';
|
|
3
|
-
import type { ObjectSchema } from '../types';
|
|
4
|
-
export declare function pick<T extends Record, K extends keyof T>(
|
|
3
|
+
import type { ObjectSchema, ObjectSchemaOrType } from '../types';
|
|
4
|
+
export declare function pick<T extends Record, K extends keyof T>(schemaOrType: ObjectSchemaOrType<T>, key: OneOrMany<K>): ObjectSchema<Simplify<Pick<T, K>>>;
|
package/schema/schemas/pick.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pick = void 0;
|
|
4
4
|
const array_1 = require("../../utils/array/array");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
|
|
6
|
+
const schema_1 = require("../utils/schema");
|
|
7
|
+
function pick(schemaOrType, key) {
|
|
8
|
+
const schema = (0, schema_1.getObjectSchema)(schemaOrType);
|
|
7
9
|
const keys = (0, array_1.toArray)(key);
|
|
8
10
|
const entries = Object.entries(schema.properties);
|
|
9
11
|
const pickedEntries = entries.filter(([propertyKey]) => keys.includes(propertyKey));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../source/schema/schemas/pick.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAG9C,oCAAwC;
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../source/schema/schemas/pick.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAG9C,oCAAwC;AACxC,4CAAkD;AAElD,SAAgB,IAAI,CAAsC,YAAmC,EAAE,GAAiB;IAC9G,MAAM,MAAM,GAAG,IAAA,wBAAe,EAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IAE1B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAgB,CAAC,CAAC,CAAC;IAEzF,MAAM,YAAY,GAAG,IAAA,oBAAY,EAAC;QAChC,GAAG,MAAM;QACT,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAA8B;KAC3E,CAAC,CAAC;IAEH,OAAO,YAAmD,CAAC;AAC7D,CAAC;AAbD,oBAaC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OneOrMany, Record, TypedOmit } from "../../types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
3
3
|
import type { ObjectSchema } from '../types';
|
|
4
4
|
export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties' | 'mask'>;
|
|
5
|
-
export declare function record<T, O>(valueType: OneOrMany<
|
|
5
|
+
export declare function record<T, O>(valueType: OneOrMany<SchemaTestable<T, O>>, options?: RecordOptions): ObjectSchema<Record<any, O>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAO,
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAO,SAA0C,EAAE,OAAuB;IAC9F,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,SAAS;QACjC,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
import type { ValueSchema } from '../types';
|
|
4
|
-
export declare function union<
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>): ValueSchema<T1 | T2 | T3 | T4, O1 | O2 | O3 | O4>;
|
|
7
|
-
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4, T5, O5>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>, schema5: Schema<T5, O5>): ValueSchema<T1 | T2 | T3 | T4 | T5, O1 | O2 | O3 | O4 | O5>;
|
|
8
|
-
export declare function union<T1, O1, T2, O2, T3, O3, T4, O4, T5, O5, T6, O6>(schema1: Schema<T1, O1>, schema2: Schema<T2, O2>, schema3: Schema<T3, O3>, schema4: Schema<T4, O4>, schema5: Schema<T5, O5>, schema6: Schema<T6>): ValueSchema<T1 | T2 | T3 | T4 | T5 | T6, O1 | O2 | O3 | O4 | O5 | O6>;
|
|
9
|
-
export declare function union(...schemas: Schema[]): ValueSchema;
|
|
10
|
-
export declare function Union(...schemas: Schema[]): Decorator<'property' | 'accessor'>;
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
3
|
+
import type { SchemaInput, SchemaOutput, ValueSchema } from '../types';
|
|
4
|
+
export declare function union<T extends SchemaTestable[]>(...schemas: [...T]): ValueSchema<SchemaInput<T[number]>, SchemaOutput<T[number]>>;
|
|
5
|
+
export declare function Union(...schemas: SchemaTestable[]): Decorator<'property' | 'accessor'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAA6C;AAC7C,8CAAwE;AAGxE,oCAAuC;
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAA6C;AAC7C,8CAAwE;AAGxE,oCAAuC;AAEvC,SAAgB,KAAK,CAA6B,GAAG,OAAe;IAClE,IAAA,oBAAM,EAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,qCAAqC,CAAC,CAAC;IACnE,OAAO,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAHD,sBAGC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAyB;IAChD,OAAO,IAAA,oDAAuC,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sBAEC"}
|
package/schema/types.d.ts
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import type { JsonPath } from "../json-path/json-path";
|
|
2
2
|
import type { AbstractConstructor, OneOrMany, Record, Type, TypedOmit } from "../types";
|
|
3
|
-
import type { NormalizedSchema, Schema } from './schema';
|
|
3
|
+
import type { NormalizedSchema, Schema, SchemaTestable } from './schema';
|
|
4
4
|
import type { SchemaError } from './schema.error';
|
|
5
5
|
declare const schemaOutputTypeSymbol: unique symbol;
|
|
6
|
-
export declare type SchemaFactoryFunction<T
|
|
7
|
-
export declare type SchemaFactory<T
|
|
6
|
+
export declare type SchemaFactoryFunction<T, O = T> = (data: T) => NormalizeValueType<O>;
|
|
7
|
+
export declare type SchemaFactory<T, O = T> = {
|
|
8
8
|
type: Type<T>;
|
|
9
9
|
builder?: undefined;
|
|
10
10
|
} | {
|
|
11
11
|
type?: undefined;
|
|
12
12
|
builder: SchemaFactoryFunction<T, O>;
|
|
13
13
|
};
|
|
14
|
-
export declare type ObjectSchemaProperties<T
|
|
15
|
-
[K in keyof T]-?: OneOrMany<
|
|
14
|
+
export declare type ObjectSchemaProperties<T> = {
|
|
15
|
+
[K in keyof T]-?: OneOrMany<SchemaTestable<any, T[K]>>;
|
|
16
16
|
};
|
|
17
17
|
export declare type NormalizedObjectSchemaProperties<T> = {
|
|
18
18
|
[K in keyof T]-?: Schema<any, T[K]>;
|
|
19
19
|
};
|
|
20
|
-
export declare type
|
|
21
|
-
export declare type
|
|
20
|
+
export declare type SchemaInput<T extends SchemaTestable> = T extends ObjectSchema<infer U, any> ? U : T extends ValueSchema<infer U, any> ? U : T extends TypeSchema<infer U> ? U : T extends ValueType<infer U> ? NormalizeValueType<U> : never;
|
|
21
|
+
export declare type SchemaOutput<T extends SchemaTestable> = T extends ObjectSchema<any, infer O> ? O : T extends ValueSchema<any, infer O> ? O : T extends TypeSchema<infer O> ? O : T extends ValueType<infer O> ? NormalizeValueType<O> : never;
|
|
22
|
+
export declare type TupleSchemaOutput<T extends readonly SchemaTestable[]> = {
|
|
23
|
+
[P in keyof T]: SchemaOutput<T[P]>;
|
|
24
|
+
};
|
|
25
|
+
export declare type ObjectSchemaOrType<T = any, O = T> = ObjectSchema<T, O> | AbstractConstructor<O>;
|
|
26
|
+
export declare type ObjectSchema<T = any, O = T> = {
|
|
22
27
|
[schemaOutputTypeSymbol]?: O;
|
|
23
28
|
sourceType?: ValueType;
|
|
24
29
|
factory?: SchemaFactory<T, O>;
|
|
25
30
|
properties: ObjectSchemaProperties<T>;
|
|
26
31
|
mask?: boolean;
|
|
27
|
-
allowUnknownProperties?: OneOrMany<
|
|
32
|
+
allowUnknownProperties?: OneOrMany<SchemaTestable>;
|
|
28
33
|
};
|
|
29
34
|
export declare type TypeSchema<T = any> = {
|
|
30
35
|
type: ValueType<T>;
|
|
@@ -34,7 +39,7 @@ export declare type NormalizedTypeSchema<T = any> = {
|
|
|
34
39
|
};
|
|
35
40
|
export declare type ValueSchema<T = unknown, O = T> = {
|
|
36
41
|
[schemaOutputTypeSymbol]?: O;
|
|
37
|
-
schema: OneOrMany<
|
|
42
|
+
schema: OneOrMany<SchemaTestable<T, O>>;
|
|
38
43
|
array?: boolean;
|
|
39
44
|
optional?: boolean;
|
|
40
45
|
nullable?: boolean;
|
|
@@ -46,7 +51,7 @@ export declare type ValueSchema<T = unknown, O = T> = {
|
|
|
46
51
|
arrayConstraints?: OneOrMany<SchemaArrayConstraint>;
|
|
47
52
|
valueConstraints?: OneOrMany<SchemaValueConstraint>;
|
|
48
53
|
};
|
|
49
|
-
export declare type NormalizedObjectSchema<T
|
|
54
|
+
export declare type NormalizedObjectSchema<T = any, O = T> = {
|
|
50
55
|
[schemaOutputTypeSymbol]?: O;
|
|
51
56
|
factory?: SchemaFactory<T, O>;
|
|
52
57
|
properties: NormalizedObjectSchemaProperties<T>;
|
|
@@ -75,11 +80,10 @@ export declare type CoercerContext = SchemaContext;
|
|
|
75
80
|
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
81
|
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
82
|
export declare type ValueType<T = any> = AbstractConstructor<T> | NormalizeToValueType<T> | DeferredValueType<T>;
|
|
78
|
-
export declare type DeferredValueType<T =
|
|
83
|
+
export declare type DeferredValueType<T = any> = {
|
|
79
84
|
deferred: () => ValueType<T>;
|
|
80
85
|
};
|
|
81
|
-
export declare type ResolvedValueType<T =
|
|
82
|
-
export declare type ValueTypeOutput<T extends ValueType> = T extends ValueType<infer U> ? NormalizeValueType<U> : never;
|
|
86
|
+
export declare type ResolvedValueType<T = any> = Exclude<ValueType<T>, DeferredValueType>;
|
|
83
87
|
export declare type Coercible = {
|
|
84
88
|
coerce?: boolean;
|
|
85
89
|
};
|
|
@@ -106,15 +110,19 @@ export declare abstract class SchemaValueCoercer {
|
|
|
106
110
|
}
|
|
107
111
|
export declare type SchemaTestOptions = {
|
|
108
112
|
/**
|
|
109
|
-
*
|
|
113
|
+
* Try to convert wrong input into desired output.
|
|
110
114
|
* Can be specified on definition and validation. If specified on both, definition has higher priority
|
|
111
115
|
*/
|
|
112
116
|
coerce?: boolean;
|
|
113
117
|
/**
|
|
114
|
-
*
|
|
118
|
+
* Remove unspecified fields on input data instead of raising an error.
|
|
115
119
|
* Can be specified on definition and validation. If specified on both, definition has higher priority
|
|
116
120
|
*/
|
|
117
121
|
mask?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Use fast errors which can improve performance a lot but misses detailed stack traces.
|
|
124
|
+
*/
|
|
125
|
+
fastErrors?: boolean;
|
|
118
126
|
};
|
|
119
127
|
export declare type SchemaTestResult<T> = {
|
|
120
128
|
valid: true;
|
|
@@ -150,10 +158,11 @@ export declare type TransformResult<T> = {
|
|
|
150
158
|
value?: undefined;
|
|
151
159
|
error: SchemaError;
|
|
152
160
|
};
|
|
153
|
-
export declare function
|
|
154
|
-
export declare function
|
|
161
|
+
export declare function objectSchemaProperties<T extends Record>(properties: ObjectSchemaProperties<T>): ObjectSchemaProperties<T>;
|
|
162
|
+
export declare function objectSchema<T extends Record, O extends Record = T>(schema: ObjectSchema<T, O>): ObjectSchema<T, O>;
|
|
163
|
+
export declare function valueSchema<T, O = T>(schema: OneOrMany<SchemaTestable<T, O>>, options?: TypedOmit<ValueSchema<T, O>, 'schema'>): ValueSchema<T, O>;
|
|
155
164
|
export declare function typeSchema<T>(type: ValueType<T>): TypeSchema<NormalizeValueType<T>>;
|
|
156
|
-
export declare function isSchema<T
|
|
165
|
+
export declare function isSchema<T, O>(value: any): value is Schema<T, O>;
|
|
157
166
|
export declare function isObjectSchema<T extends Record, O extends Record>(schema: Schema<T, O>): schema is ObjectSchema<T, O>;
|
|
158
167
|
export declare function isObjectSchema<T extends Record, O extends Record>(schema: any): schema is ObjectSchema<T, O>;
|
|
159
168
|
export declare function isValueSchema<T, O>(schema: Schema<T, O>): schema is ValueSchema<T, O>;
|
|
@@ -161,8 +170,9 @@ export declare function isValueSchema<T, O>(schema: any): schema is ValueSchema<
|
|
|
161
170
|
export declare function isTypeSchema<T, O>(schema: Schema<T, O>): schema is TypeSchema<O>;
|
|
162
171
|
export declare function isTypeSchema<T, O>(schema: any): schema is TypeSchema<O>;
|
|
163
172
|
export declare function isDeferredValueType<T>(value: ValueType<T>): value is DeferredValueType<T>;
|
|
173
|
+
export declare function isDeferredValueType(value: any): value is DeferredValueType;
|
|
164
174
|
export declare function resolveValueTypes<T>(valueTypes: OneOrMany<ValueType<T>>): OneOrMany<ResolvedValueType<T>>;
|
|
165
175
|
export declare function resolveValueType<T>(valueType: ValueType<T>): ResolvedValueType<T>;
|
|
166
|
-
export declare function valueTypesOrSchemasToSchemas<T, O>(valueTypesOrSchemas: OneOrMany<
|
|
167
|
-
export declare function
|
|
176
|
+
export declare function valueTypesOrSchemasToSchemas<T, O>(valueTypesOrSchemas: OneOrMany<SchemaTestable<T, O>>): OneOrMany<Schema<T, O>>;
|
|
177
|
+
export declare function schemaTestableToSchema<T, O>(valueTypeOrSchema: SchemaTestable<T, O>): Schema<T, O>;
|
|
168
178
|
export {};
|
package/schema/types.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.schemaTestableToSchema = exports.valueTypesOrSchemasToSchemas = exports.resolveValueType = exports.resolveValueTypes = exports.isDeferredValueType = exports.isTypeSchema = exports.isValueSchema = exports.isObjectSchema = exports.isSchema = exports.typeSchema = exports.valueSchema = exports.objectSchema = exports.objectSchemaProperties = exports.SchemaValueCoercer = exports.SchemaValueTransformer = exports.SchemaValueConstraint = exports.SchemaArrayConstraint = exports.primitiveConstructorSet = exports.primitiveConstructors = void 0;
|
|
5
|
+
const object_1 = require("../utils/object/object");
|
|
5
6
|
const type_guards_1 = require("../utils/type-guards");
|
|
6
7
|
exports.primitiveConstructors = [String, Number, Boolean, Symbol, BigInt, Function, 'undefined', 'null'];
|
|
7
8
|
exports.primitiveConstructorSet = new Set(exports.primitiveConstructors);
|
|
@@ -17,12 +18,16 @@ exports.SchemaValueTransformer = SchemaValueTransformer;
|
|
|
17
18
|
class SchemaValueCoercer {
|
|
18
19
|
}
|
|
19
20
|
exports.SchemaValueCoercer = SchemaValueCoercer;
|
|
21
|
+
function objectSchemaProperties(properties) {
|
|
22
|
+
return (0, object_1.filterObject)(properties, type_guards_1.isDefined);
|
|
23
|
+
}
|
|
24
|
+
exports.objectSchemaProperties = objectSchemaProperties;
|
|
20
25
|
function objectSchema(schema) {
|
|
21
|
-
return schema;
|
|
26
|
+
return (0, object_1.filterObject)(schema, type_guards_1.isDefined);
|
|
22
27
|
}
|
|
23
28
|
exports.objectSchema = objectSchema;
|
|
24
29
|
function valueSchema(schema, options) {
|
|
25
|
-
return { schema, ...options };
|
|
30
|
+
return (0, object_1.filterObject)({ schema, ...options }, type_guards_1.isDefined);
|
|
26
31
|
}
|
|
27
32
|
exports.valueSchema = valueSchema;
|
|
28
33
|
function typeSchema(type) {
|
|
@@ -42,7 +47,16 @@ function isValueSchema(schema) {
|
|
|
42
47
|
}
|
|
43
48
|
exports.isValueSchema = isValueSchema;
|
|
44
49
|
function isTypeSchema(schema) {
|
|
45
|
-
|
|
50
|
+
if (!(0, type_guards_1.isObject)(schema)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const type = schema.type;
|
|
54
|
+
return (0, type_guards_1.isObject)(schema)
|
|
55
|
+
&& ((0, type_guards_1.isFunction)(type)
|
|
56
|
+
|| ((0, type_guards_1.isObject)(type) && (0, type_guards_1.isFunction)(type.deferred))
|
|
57
|
+
|| (type == 'undefined')
|
|
58
|
+
|| (type == 'null')
|
|
59
|
+
|| (type == 'any'));
|
|
46
60
|
}
|
|
47
61
|
exports.isTypeSchema = isTypeSchema;
|
|
48
62
|
function isDeferredValueType(value) {
|
|
@@ -64,16 +78,16 @@ function resolveValueType(valueType) {
|
|
|
64
78
|
exports.resolveValueType = resolveValueType;
|
|
65
79
|
function valueTypesOrSchemasToSchemas(valueTypesOrSchemas) {
|
|
66
80
|
if ((0, type_guards_1.isArray)(valueTypesOrSchemas)) {
|
|
67
|
-
return valueTypesOrSchemas.map(
|
|
81
|
+
return valueTypesOrSchemas.map(schemaTestableToSchema);
|
|
68
82
|
}
|
|
69
|
-
return
|
|
83
|
+
return schemaTestableToSchema(valueTypesOrSchemas);
|
|
70
84
|
}
|
|
71
85
|
exports.valueTypesOrSchemasToSchemas = valueTypesOrSchemasToSchemas;
|
|
72
|
-
function
|
|
86
|
+
function schemaTestableToSchema(valueTypeOrSchema) {
|
|
73
87
|
if (isSchema(valueTypeOrSchema)) {
|
|
74
88
|
return valueTypeOrSchema;
|
|
75
89
|
}
|
|
76
90
|
return typeSchema(valueTypeOrSchema);
|
|
77
91
|
}
|
|
78
|
-
exports.
|
|
92
|
+
exports.schemaTestableToSchema = schemaTestableToSchema;
|
|
79
93
|
//# 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":";AAAA,iDAAiD;;;AAIjD,sDAA+E;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/schema/types.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AAIjD,mDAAqD;AACrD,sDAA+E;AA0HlE,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;AAqCD,SAAgB,sBAAsB,CAAmB,UAAqC;IAC5F,OAAO,IAAA,qBAAY,EAAC,UAAU,EAAE,uBAAS,CAA8B,CAA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
2
|
import type { NormalizedSchema, Schema } from '../schema';
|
|
2
|
-
import type { NormalizedObjectSchema, NormalizedTypeSchema, NormalizedValueSchema, ObjectSchema, TypeSchema, ValueSchema } from '../types';
|
|
3
|
+
import type { NormalizedObjectSchema, NormalizedTypeSchema, NormalizedValueSchema, ObjectSchema, ObjectSchemaOrType, TypeSchema, ValueSchema } from '../types';
|
|
3
4
|
export declare const normalizeSchema: typeof _normalizeSchema;
|
|
4
5
|
export declare const normalizeObjectSchema: typeof _normalizeObjectSchema;
|
|
5
6
|
export declare const normalizeValueSchema: typeof _normalizeValueSchema;
|
|
6
7
|
export declare const normalizeTypeSchema: typeof _normalizeTypeSchema;
|
|
7
8
|
export declare const getArrayItemSchema: typeof _getArrayItemSchema;
|
|
9
|
+
export declare const tryGetObjectSchemaFromReflection: typeof _tryGetObjectSchemaFromReflection;
|
|
10
|
+
export declare function getObjectSchema<T, O = T>(schemaOrType: ObjectSchemaOrType<T, O>): ObjectSchema<T, O>;
|
|
8
11
|
declare function _normalizeSchema<T, O>(schema: Schema<T, O>): NormalizedSchema<T, O>;
|
|
9
12
|
declare function _normalizeObjectSchema<T, O>(schema: ObjectSchema<T, O>): NormalizedObjectSchema<T, O>;
|
|
10
13
|
declare function _normalizeValueSchema<T, O>(schema: ValueSchema<T, O>): NormalizedValueSchema<T, O>;
|
|
11
14
|
declare function _normalizeTypeSchema<T>(schema: TypeSchema<T>): NormalizedTypeSchema<T>;
|
|
12
15
|
declare function _getArrayItemSchema<T, O>(schema: ValueSchema<T, O>): ValueSchema<T, O>;
|
|
16
|
+
export declare function getObjectSchemaFromReflection<T>(type: AbstractConstructor<T>): ObjectSchema<T>;
|
|
17
|
+
declare function _tryGetObjectSchemaFromReflection<T>(type: AbstractConstructor<T>): ObjectSchema<T> | null;
|
|
13
18
|
export {};
|
package/schema/utils/schema.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getArrayItemSchema = exports.normalizeTypeSchema = exports.normalizeValueSchema = exports.normalizeObjectSchema = exports.normalizeSchema = void 0;
|
|
3
|
+
exports.getObjectSchemaFromReflection = exports.getObjectSchema = exports.tryGetObjectSchemaFromReflection = exports.getArrayItemSchema = exports.normalizeTypeSchema = exports.normalizeValueSchema = exports.normalizeObjectSchema = exports.normalizeSchema = void 0;
|
|
4
|
+
const registry_1 = require("../../reflection/registry");
|
|
4
5
|
const array_1 = require("../../utils/array/array");
|
|
5
6
|
const memoize_1 = require("../../utils/function/memoize");
|
|
6
7
|
const object_1 = require("../../utils/object/object");
|
|
7
8
|
const type_guards_1 = require("../../utils/type-guards");
|
|
9
|
+
const assign_1 = require("../schemas/assign");
|
|
8
10
|
const types_1 = require("../types");
|
|
9
11
|
exports.normalizeSchema = (0, memoize_1.memoizeSingle)(_normalizeSchema, { weak: true });
|
|
10
12
|
exports.normalizeObjectSchema = (0, memoize_1.memoizeSingle)(_normalizeObjectSchema, { weak: true });
|
|
11
13
|
exports.normalizeValueSchema = (0, memoize_1.memoizeSingle)(_normalizeValueSchema, { weak: true });
|
|
12
14
|
exports.normalizeTypeSchema = (0, memoize_1.memoizeSingle)(_normalizeTypeSchema, { weak: true });
|
|
13
15
|
exports.getArrayItemSchema = (0, memoize_1.memoizeSingle)(_getArrayItemSchema, { weak: true });
|
|
16
|
+
exports.tryGetObjectSchemaFromReflection = (0, memoize_1.memoizeSingle)(_tryGetObjectSchemaFromReflection, { weak: true });
|
|
17
|
+
function getObjectSchema(schemaOrType) {
|
|
18
|
+
return ((0, type_guards_1.isFunction)(schemaOrType)
|
|
19
|
+
? getObjectSchemaFromReflection(schemaOrType)
|
|
20
|
+
: schemaOrType);
|
|
21
|
+
}
|
|
22
|
+
exports.getObjectSchema = getObjectSchema;
|
|
14
23
|
function _normalizeSchema(schema) {
|
|
15
24
|
if ((0, types_1.isObjectSchema)(schema)) {
|
|
16
25
|
return (0, exports.normalizeObjectSchema)(schema);
|
|
@@ -26,15 +35,15 @@ function _normalizeSchema(schema) {
|
|
|
26
35
|
function _normalizeObjectSchema(schema) {
|
|
27
36
|
const normalizedSchema = {
|
|
28
37
|
factory: schema.factory,
|
|
29
|
-
properties: (0, object_1.mapObjectValues)(schema.properties, (propertyValueType) => (
|
|
38
|
+
properties: (0, object_1.mapObjectValues)(schema.properties, (propertyValueType) => (0, types_1.valueTypesOrSchemasToSchemas)(propertyValueType)),
|
|
30
39
|
mask: schema.mask,
|
|
31
|
-
allowUnknownProperties: new Set((0, array_1.toArray)(schema.allowUnknownProperties ?? []).map(types_1.
|
|
40
|
+
allowUnknownProperties: new Set((0, array_1.toArray)(schema.allowUnknownProperties ?? []).map(types_1.schemaTestableToSchema))
|
|
32
41
|
};
|
|
33
42
|
return normalizedSchema;
|
|
34
43
|
}
|
|
35
44
|
function _normalizeValueSchema(schema) {
|
|
36
45
|
const normalizedValueSchema = {
|
|
37
|
-
schema: new Set((0, array_1.toArray)(schema.schema)),
|
|
46
|
+
schema: new Set((0, array_1.toArray)(schema.schema).map(types_1.schemaTestableToSchema)),
|
|
38
47
|
array: schema.array ?? false,
|
|
39
48
|
optional: schema.optional ?? false,
|
|
40
49
|
nullable: schema.nullable ?? false,
|
|
@@ -63,12 +72,56 @@ function _normalizeTypeSchema(schema) {
|
|
|
63
72
|
function _getArrayItemSchema(schema) {
|
|
64
73
|
const itemSchema = {
|
|
65
74
|
schema: schema.schema,
|
|
66
|
-
array: false,
|
|
67
|
-
optional: false,
|
|
68
|
-
nullable: false,
|
|
69
75
|
transformers: schema.transformers,
|
|
70
76
|
valueConstraints: schema.valueConstraints
|
|
71
77
|
};
|
|
72
78
|
return itemSchema;
|
|
73
79
|
}
|
|
80
|
+
function getObjectSchemaFromReflection(type) {
|
|
81
|
+
const schema = (0, exports.tryGetObjectSchemaFromReflection)(type);
|
|
82
|
+
if ((0, type_guards_1.isNull)(schema)) {
|
|
83
|
+
throw new Error(`Could not get schema for ${type.name} from reflection data.`);
|
|
84
|
+
}
|
|
85
|
+
return schema;
|
|
86
|
+
}
|
|
87
|
+
exports.getObjectSchemaFromReflection = getObjectSchemaFromReflection;
|
|
88
|
+
function _tryGetObjectSchemaFromReflection(type) {
|
|
89
|
+
const metadata = registry_1.reflectionRegistry.getMetadata(type);
|
|
90
|
+
if (!metadata.registered) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const typeData = metadata.data.tryGet('schema');
|
|
94
|
+
const properties = {};
|
|
95
|
+
for (const [key, propertyMetadata] of metadata.properties) {
|
|
96
|
+
const reflectionData = propertyMetadata.data.tryGet('schema');
|
|
97
|
+
const itemType = reflectionData?.schema;
|
|
98
|
+
const array = (reflectionData?.array == true) ? true : undefined;
|
|
99
|
+
if (array && ((0, type_guards_1.isUndefined)(itemType) || ((0, type_guards_1.isArray)(itemType) && (itemType.length == 0)))) {
|
|
100
|
+
throw new Error(`Item type missing on type ${type.name} at property "${String(key)}"`);
|
|
101
|
+
}
|
|
102
|
+
properties[key] = (0, types_1.valueSchema)((0, types_1.valueTypesOrSchemasToSchemas)(itemType ?? propertyMetadata.type), {
|
|
103
|
+
array,
|
|
104
|
+
optional: reflectionData?.optional,
|
|
105
|
+
nullable: reflectionData?.nullable,
|
|
106
|
+
coerce: reflectionData?.coerce,
|
|
107
|
+
coercers: reflectionData?.coercers,
|
|
108
|
+
transformers: reflectionData?.transformers,
|
|
109
|
+
arrayConstraints: reflectionData?.arrayConstraints,
|
|
110
|
+
valueConstraints: reflectionData?.valueConstraints
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const schema = (0, types_1.objectSchema)({
|
|
114
|
+
sourceType: type,
|
|
115
|
+
factory: (0, type_guards_1.isDefined)(typeData?.factory) ? { builder: typeData.factory } : { type: type },
|
|
116
|
+
properties,
|
|
117
|
+
mask: typeData?.mask,
|
|
118
|
+
allowUnknownProperties: ((0, type_guards_1.isUndefined)(typeData?.allowUnknownProperties) || ((0, type_guards_1.isArray)(typeData?.allowUnknownProperties) && (typeData?.allowUnknownProperties.length == 0))) ? undefined : typeData?.allowUnknownProperties
|
|
119
|
+
});
|
|
120
|
+
const prototype = Reflect.getPrototypeOf(type);
|
|
121
|
+
if ((0, type_guards_1.isNotNull)(prototype) && registry_1.reflectionRegistry.hasType(prototype)) {
|
|
122
|
+
const parentSchema = getObjectSchemaFromReflection(prototype);
|
|
123
|
+
return (0, assign_1.assign)(parentSchema, schema);
|
|
124
|
+
}
|
|
125
|
+
return schema;
|
|
126
|
+
}
|
|
74
127
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../source/schema/utils/schema.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,0DAAyD;AACzD,sDAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../source/schema/utils/schema.ts"],"names":[],"mappings":";;;AAAA,wDAA2D;AAE3D,mDAA8C;AAC9C,0DAAyD;AACzD,sDAAwD;AACxD,yDAAqG;AAGrG,8CAA2C;AAE3C,oCAA0K;AAE7J,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;AACxE,QAAA,gCAAgC,GAAG,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AEtE,IAAI,IAAA,uBAAS,EAAC,SAAS,CAAC,IAAI,6BAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QACjE,MAAM,YAAY,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAAC;QAC9D,OAAO,IAAA,eAAM,EAAC,YAAY,EAAE,MAAM,CAAoB,CAAC;KACxD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OneOrMany } from "../../types";
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
2
3
|
import type { ResolvedValueType, ValueType } from '../types';
|
|
3
|
-
export declare function getValueType(value: unknown): ResolvedValueType
|
|
4
|
+
export declare function getValueType(value: unknown): ResolvedValueType;
|
|
4
5
|
export declare function getValueTypeName(valueType: ValueType): string;
|
|
5
|
-
export declare function getSchemaTypeNames(schema:
|
|
6
|
+
export declare function getSchemaTypeNames(schema: SchemaTestable): string[];
|
|
7
|
+
export declare function getSchemaValueTypes(schema: OneOrMany<SchemaTestable>): ResolvedValueType[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSchemaTypeNames = exports.getValueTypeName = exports.getValueType = void 0;
|
|
3
|
+
exports.getSchemaValueTypes = exports.getSchemaTypeNames = exports.getValueTypeName = exports.getValueType = void 0;
|
|
4
4
|
const array_1 = require("../../utils/array/array");
|
|
5
5
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
6
|
const types_1 = require("../types");
|
|
@@ -22,18 +22,33 @@ function getValueTypeName(valueType) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.getValueTypeName = getValueTypeName;
|
|
24
24
|
function getSchemaTypeNames(schema) {
|
|
25
|
+
return getSchemaValueTypes(schema)
|
|
26
|
+
.map((valueType) => ((0, type_guards_1.isString)(valueType) ? valueType : valueType.name));
|
|
27
|
+
}
|
|
28
|
+
exports.getSchemaTypeNames = getSchemaTypeNames;
|
|
29
|
+
function getSchemaValueTypes(schema) {
|
|
25
30
|
if ((0, types_1.isTypeSchema)(schema)) {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
return [(0, types_1.resolveValueType)(schema.type)];
|
|
32
|
+
}
|
|
33
|
+
if ((0, type_guards_1.isFunction)(schema)) {
|
|
34
|
+
return [schema];
|
|
35
|
+
}
|
|
36
|
+
if ((0, type_guards_1.isString)(schema)) {
|
|
37
|
+
return [schema];
|
|
28
38
|
}
|
|
29
39
|
if ((0, types_1.isObjectSchema)(schema)) {
|
|
30
|
-
|
|
31
|
-
return [name];
|
|
40
|
+
return [(0, types_1.resolveValueType)(schema.sourceType ?? Object)];
|
|
32
41
|
}
|
|
33
42
|
if ((0, types_1.isValueSchema)(schema)) {
|
|
34
|
-
return [...new Set((0, array_1.toArray)(schema.schema).flatMap(
|
|
43
|
+
return [...new Set((0, array_1.toArray)(schema.schema).flatMap(getSchemaValueTypes))];
|
|
44
|
+
}
|
|
45
|
+
if ((0, types_1.isDeferredValueType)(schema)) {
|
|
46
|
+
return getSchemaValueTypes((0, types_1.resolveValueType)(schema));
|
|
47
|
+
}
|
|
48
|
+
if ((0, type_guards_1.isArray)(schema)) {
|
|
49
|
+
return schema.flatMap(getSchemaValueTypes);
|
|
35
50
|
}
|
|
36
51
|
throw new Error('Unsupported schema');
|
|
37
52
|
}
|
|
38
|
-
exports.
|
|
53
|
+
exports.getSchemaValueTypes = getSchemaValueTypes;
|
|
39
54
|
//# sourceMappingURL=value-type.js.map
|