@tstdl/base 0.78.0-beta8 → 0.78.0-beta81
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 +3 -2
- 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 +15 -2
- package/application/application.js +89 -42
- 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 +2 -2
- 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/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 +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.js +3 -3
- package/database/mongo/mongo-base.repository.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/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 +10 -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/notification/api.d.ts +20 -0
- package/notification/api.js +35 -0
- package/notification/api.js.map +1 -0
- package/notification/model.d.ts +18 -0
- package/notification/model.js +36 -0
- package/notification/model.js.map +1 -0
- package/notification/module.d.ts +9 -0
- package/notification/module.js +15 -0
- package/notification/module.js.map +1 -0
- 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/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/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
|
@@ -10,34 +10,44 @@ import type { HttpQueryObject } from '../http-query';
|
|
|
10
10
|
import { HttpQuery } from '../http-query';
|
|
11
11
|
import type { HttpUrlParametersObject } from '../http-url-parameters';
|
|
12
12
|
import { HttpUrlParameters } from '../http-url-parameters';
|
|
13
|
-
import type {
|
|
13
|
+
import type { HttpMethod } from '../types';
|
|
14
14
|
/** only one type at a time is supported. If multiple are set, behaviour is undefined */
|
|
15
|
-
export declare type HttpRequestBody =
|
|
15
|
+
export declare type HttpRequestBody = {
|
|
16
16
|
text?: string;
|
|
17
17
|
json?: UndefinableJson;
|
|
18
18
|
form?: HttpForm;
|
|
19
19
|
buffer?: Uint8Array;
|
|
20
|
-
|
|
20
|
+
blob?: Blob;
|
|
21
|
+
stream?: ReadableStream<Uint8Array>;
|
|
21
22
|
};
|
|
22
|
-
export declare type
|
|
23
|
+
export declare type HttpRequestAuthorization = {
|
|
24
|
+
basic?: {
|
|
25
|
+
username: string;
|
|
26
|
+
password: string;
|
|
27
|
+
};
|
|
28
|
+
bearer?: string;
|
|
29
|
+
token?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortToken' | 'abort' | 'headers' | 'query' | 'body'>> & {
|
|
23
32
|
urlParameter?: HttpUrlParametersObject | HttpUrlParameters;
|
|
24
33
|
headers?: HttpHeadersObject | HttpHeaders;
|
|
25
34
|
query?: HttpQueryObject | HttpQuery;
|
|
26
|
-
|
|
35
|
+
authorization?: HttpRequestAuthorization;
|
|
36
|
+
body?: {
|
|
27
37
|
text?: string;
|
|
28
38
|
json?: UndefinableJson;
|
|
29
39
|
form?: HttpFormObject | HttpForm;
|
|
30
40
|
buffer?: Uint8Array;
|
|
31
|
-
stream?:
|
|
41
|
+
stream?: ReadableStream<Uint8Array>;
|
|
32
42
|
};
|
|
33
43
|
abortToken?: ReadonlyCancellationToken;
|
|
34
44
|
};
|
|
35
|
-
export declare type HttpClientRequestObject
|
|
45
|
+
export declare type HttpClientRequestObject = HttpClientRequestOptions & {
|
|
36
46
|
url: string;
|
|
37
47
|
method?: HttpMethod;
|
|
38
48
|
};
|
|
39
49
|
export declare type CredentialsOptions = 'omit' | 'same-origin' | 'include';
|
|
40
|
-
export declare class HttpClientRequest
|
|
50
|
+
export declare class HttpClientRequest implements Disposable {
|
|
41
51
|
private readonly _abortToken;
|
|
42
52
|
url: string;
|
|
43
53
|
method: HttpMethod;
|
|
@@ -86,8 +96,8 @@ export declare class HttpClientRequest<T extends HttpBodyType = HttpBodyType> im
|
|
|
86
96
|
* // -> http://domain.tld/search?categories=3&categories=8&limit=10
|
|
87
97
|
*/
|
|
88
98
|
query: HttpQuery;
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
authorization: HttpRequestAuthorization | undefined;
|
|
100
|
+
body: HttpRequestBody | undefined;
|
|
91
101
|
credentials: CredentialsOptions;
|
|
92
102
|
/**
|
|
93
103
|
* request timeout in milliseconds
|
|
@@ -105,11 +115,11 @@ export declare class HttpClientRequest<T extends HttpBodyType = HttpBodyType> im
|
|
|
105
115
|
* can be used to cancel the request. Throws HttpError
|
|
106
116
|
*/
|
|
107
117
|
get abortToken(): ReadonlyCancellationToken;
|
|
108
|
-
constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions
|
|
109
|
-
constructor(requestObject: HttpClientRequestObject
|
|
118
|
+
constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions);
|
|
119
|
+
constructor(requestObject: HttpClientRequestObject);
|
|
110
120
|
[dispose](): void;
|
|
111
121
|
/** abort the request */
|
|
112
122
|
abort(): void;
|
|
113
|
-
clone(): HttpClientRequest
|
|
114
|
-
asObject(): HttpClientRequestObject
|
|
123
|
+
clone(): HttpClientRequest;
|
|
124
|
+
asObject(): HttpClientRequestObject;
|
|
115
125
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HttpClientRequest = void 0;
|
|
4
4
|
const disposable_1 = require("../../disposable");
|
|
5
5
|
const cancellation_token_1 = require("../../utils/cancellation-token");
|
|
6
|
+
const clone_1 = require("../../utils/clone");
|
|
6
7
|
const type_guards_1 = require("../../utils/type-guards");
|
|
7
8
|
const http_form_1 = require("../http-form");
|
|
8
9
|
const http_headers_1 = require("../http-headers");
|
|
@@ -27,8 +28,8 @@ class HttpClientRequest {
|
|
|
27
28
|
this.urlParameters = new http_url_parameters_1.HttpUrlParameters(requestOptions.urlParameters);
|
|
28
29
|
this.urlParametersSeparator = requestOptions.urlParametersSeparator ?? ';';
|
|
29
30
|
this.query = new http_query_1.HttpQuery(requestOptions.query);
|
|
31
|
+
this.authorization = requestOptions.authorization;
|
|
30
32
|
this.body = normalizeBody(requestOptions.body);
|
|
31
|
-
this.responseType = requestOptions.responseType ?? 'auto';
|
|
32
33
|
this.credentials = requestOptions.credentials ?? 'omit';
|
|
33
34
|
this.timeout = requestOptions.timeout ?? 30000;
|
|
34
35
|
this.throwOnNon200 = requestOptions.throwOnNon200 ?? true;
|
|
@@ -54,6 +55,7 @@ class HttpClientRequest {
|
|
|
54
55
|
const request = new HttpClientRequest(this);
|
|
55
56
|
request.headers = new http_headers_1.HttpHeaders(request.headers);
|
|
56
57
|
request.query = new http_query_1.HttpQuery(request.query);
|
|
58
|
+
request.authorization = (0, clone_1.clone)(request.authorization, true);
|
|
57
59
|
request.urlParameters = new http_url_parameters_1.HttpUrlParameters(request.urlParameters);
|
|
58
60
|
request.body = normalizeBody(request.body);
|
|
59
61
|
return request;
|
|
@@ -67,8 +69,8 @@ class HttpClientRequest {
|
|
|
67
69
|
urlParameter: this.urlParameters.asObject(),
|
|
68
70
|
headers: this.headers.asObject(),
|
|
69
71
|
query: this.query.asObject(),
|
|
72
|
+
authorization: this.authorization,
|
|
70
73
|
body,
|
|
71
|
-
responseType: this.responseType,
|
|
72
74
|
timeout: this.timeout,
|
|
73
75
|
throwOnNon200: this.throwOnNon200,
|
|
74
76
|
context: this.context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-request.js","sourceRoot":"","sources":["../../../source/http/client/http-client-request.ts"],"names":[],"mappings":";;;AACA,iDAAuC;AAGvC,uEAA+D;AAC/D,yDAAuE;AAEvE,4CAAwC;AAExC,kDAA8C;AAE9C,8CAA0C;AAE1C,gEAA2D;
|
|
1
|
+
{"version":3,"file":"http-client-request.js","sourceRoot":"","sources":["../../../source/http/client/http-client-request.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import type { TypedOmit } from "../../types";
|
|
2
|
+
import type { HttpBodySource } from '../http-body';
|
|
3
|
+
import { HttpBody } from '../http-body';
|
|
2
4
|
import type { HttpHeadersObject } from '../http-headers';
|
|
3
5
|
import { HttpHeaders } from '../http-headers';
|
|
4
|
-
import type { HttpBody, HttpBodyType } from '../types';
|
|
5
6
|
import type { HttpClientRequest, HttpClientRequestObject } from './http-client-request';
|
|
6
|
-
export declare type
|
|
7
|
-
maxBytes?: number;
|
|
8
|
-
};
|
|
9
|
-
export declare type HttpClientResponseObject = TypedOmit<HttpClientResponse, 'request' | 'headers' | 'close' | 'asObject'> & {
|
|
7
|
+
export declare type HttpClientResponseObject = TypedOmit<HttpClientResponse, 'hasBody' | 'request' | 'headers' | 'close' | 'asObject'> & {
|
|
10
8
|
request: HttpClientRequestObject;
|
|
11
9
|
headers: HttpHeadersObject;
|
|
12
|
-
body?: any;
|
|
13
10
|
};
|
|
14
|
-
export declare type HttpClientResponseOptions
|
|
15
|
-
request: HttpClientRequest
|
|
11
|
+
export declare type HttpClientResponseOptions = {
|
|
12
|
+
request: HttpClientRequest;
|
|
16
13
|
statusCode: number;
|
|
17
14
|
statusMessage: string;
|
|
18
15
|
headers: HttpHeadersObject | HttpHeaders;
|
|
19
|
-
body: HttpBody
|
|
16
|
+
body: HttpBody | HttpBodySource;
|
|
20
17
|
closeHandler: () => void;
|
|
21
18
|
};
|
|
22
|
-
export declare class HttpClientResponse
|
|
19
|
+
export declare class HttpClientResponse {
|
|
23
20
|
private readonly closeHandler;
|
|
24
21
|
readonly request: HttpClientRequest;
|
|
25
22
|
readonly statusCode: number;
|
|
26
23
|
readonly statusMessage: string;
|
|
27
24
|
readonly headers: HttpHeaders;
|
|
28
|
-
readonly body: HttpBody
|
|
29
|
-
|
|
25
|
+
readonly body: HttpBody;
|
|
26
|
+
get hasBody(): boolean;
|
|
27
|
+
constructor(options: HttpClientResponseOptions);
|
|
30
28
|
close(): void;
|
|
31
29
|
asObject(): HttpClientResponseObject;
|
|
32
30
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClientResponse = void 0;
|
|
4
|
+
const http_body_1 = require("../http-body");
|
|
4
5
|
const http_headers_1 = require("../http-headers");
|
|
5
6
|
class HttpClientResponse {
|
|
6
7
|
constructor(options) {
|
|
@@ -8,9 +9,12 @@ class HttpClientResponse {
|
|
|
8
9
|
this.statusCode = options.statusCode;
|
|
9
10
|
this.statusMessage = options.statusMessage;
|
|
10
11
|
this.headers = new http_headers_1.HttpHeaders(options.headers);
|
|
11
|
-
this.body = options.body;
|
|
12
|
+
this.body = (options.body instanceof http_body_1.HttpBody) ? options.body : new http_body_1.HttpBody(options.body, this.headers);
|
|
12
13
|
this.closeHandler = options.closeHandler;
|
|
13
14
|
}
|
|
15
|
+
get hasBody() {
|
|
16
|
+
return this.body.available;
|
|
17
|
+
}
|
|
14
18
|
close() {
|
|
15
19
|
this.closeHandler();
|
|
16
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-response.js","sourceRoot":"","sources":["../../../source/http/client/http-client-response.ts"],"names":[],"mappings":";;;AAEA,kDAA8C;
|
|
1
|
+
{"version":3,"file":"http-client-response.js","sourceRoot":"","sources":["../../../source/http/client/http-client-response.ts"],"names":[],"mappings":";;;AAEA,4CAAwC;AAExC,kDAA8C;AAiB9C,MAAa,kBAAkB;IAa7B,YAAY,OAAkC;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,0BAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,YAAY,oBAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,oBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzG,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAXD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAC7B,CAAC;IAWD,KAAK;QACH,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,MAAM,GAAG,GAA6B;YACpC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChC,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArCD,gDAqCC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { HttpBodyType } from '../types';
|
|
2
1
|
import type { HttpClientRequest } from './http-client-request';
|
|
3
2
|
import type { HttpClientResponse } from './http-client-response';
|
|
4
3
|
export declare abstract class HttpClientAdapter {
|
|
5
4
|
/**
|
|
6
5
|
* should return a response with an stream (preferred) or Uint8Array if streams are not supported
|
|
7
6
|
*/
|
|
8
|
-
abstract call
|
|
7
|
+
abstract call(request: HttpClientRequest): Promise<HttpClientResponse>;
|
|
9
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.adapter.js","sourceRoot":"","sources":["../../../source/http/client/http-client.adapter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"http-client.adapter.js","sourceRoot":"","sources":["../../../source/http/client/http-client.adapter.ts"],"names":[],"mappings":";;;AAGA,MAAsB,iBAAiB;CAKtC;AALD,8CAKC"}
|
|
@@ -2,7 +2,7 @@ import type { Injectable } from "../../container";
|
|
|
2
2
|
import { resolveArgumentType } from "../../container";
|
|
3
3
|
import type { OneOrMany, UndefinableJson } from "../../types";
|
|
4
4
|
import type { AsyncMiddleware, AsyncMiddlewareHandler, AsyncMiddlewareNext } from "../../utils/middleware";
|
|
5
|
-
import type {
|
|
5
|
+
import type { HttpMethod, HttpValue } from '../types';
|
|
6
6
|
import type { HttpClientRequestOptions } from './http-client-request';
|
|
7
7
|
import { HttpClientRequest } from './http-client-request';
|
|
8
8
|
import type { HttpClientResponse } from './http-client-response';
|
|
@@ -28,48 +28,47 @@ export declare type HttpClientMiddlewareNext = AsyncMiddlewareNext<HttpClientReq
|
|
|
28
28
|
export declare const HTTP_CLIENT_OPTIONS: import("../../container").InjectionToken<HttpClientOptions, any>;
|
|
29
29
|
export declare type HttpClientArgument = HttpClientOptions;
|
|
30
30
|
export declare class HttpClient implements Injectable<HttpClientArgument> {
|
|
31
|
-
private static _instance?;
|
|
32
31
|
private readonly adapter;
|
|
33
32
|
private readonly options;
|
|
34
33
|
private readonly headers;
|
|
35
34
|
private readonly middleware;
|
|
36
35
|
private readonly internalMiddleware;
|
|
37
36
|
private callHandler;
|
|
38
|
-
static get instance(): HttpClient;
|
|
39
37
|
readonly [resolveArgumentType]: HttpClientOptions;
|
|
40
38
|
constructor(adapter: HttpClientAdapter, options?: HttpClientOptions);
|
|
41
|
-
static configureGlobalInstance(adapter: HttpClientAdapter, options?: HttpClientOptions): void;
|
|
42
39
|
addMiddleware(middleware: HttpClientMiddleware): void;
|
|
43
40
|
setDefaultHeader(name: string, value: OneOrMany<HttpValue>): void;
|
|
44
41
|
deleteDefaultHeader(name: string): void;
|
|
45
42
|
head(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
46
|
-
get
|
|
47
|
-
getText(url: string, options?: HttpClientRequestOptions
|
|
48
|
-
getJson<T extends UndefinableJson>(url: string, options?: HttpClientRequestOptions
|
|
49
|
-
getBuffer(url: string, options?: HttpClientRequestOptions
|
|
50
|
-
getStream(url: string, options?: HttpClientRequestOptions
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
43
|
+
get(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
44
|
+
getText(url: string, options?: HttpClientRequestOptions): Promise<string>;
|
|
45
|
+
getJson<T extends UndefinableJson>(url: string, options?: HttpClientRequestOptions): Promise<T>;
|
|
46
|
+
getBuffer(url: string, options?: HttpClientRequestOptions): Promise<Uint8Array>;
|
|
47
|
+
getStream(url: string, options?: HttpClientRequestOptions): ReadableStream<string> | ReadableStream<Uint8Array>;
|
|
48
|
+
getTextStream(url: string, options?: HttpClientRequestOptions): ReadableStream<string>;
|
|
49
|
+
getBinaryStream(url: string, options?: HttpClientRequestOptions): ReadableStream<Uint8Array>;
|
|
50
|
+
post(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
51
|
+
postText(url: string, options?: HttpClientRequestOptions): Promise<string>;
|
|
52
|
+
postJson<T extends UndefinableJson>(url: string, options?: HttpClientRequestOptions): Promise<T>;
|
|
53
|
+
postBuffer(url: string, options?: HttpClientRequestOptions): Promise<Uint8Array>;
|
|
54
|
+
postStream(url: string, options?: HttpClientRequestOptions): ReadableStream<Uint8Array>;
|
|
55
|
+
put(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
56
|
+
putText(url: string, options?: HttpClientRequestOptions): Promise<string>;
|
|
57
|
+
putJson<T extends UndefinableJson = UndefinableJson>(url: string, options?: HttpClientRequestOptions): Promise<T>;
|
|
58
|
+
putBuffer(url: string, options?: HttpClientRequestOptions): Promise<Uint8Array>;
|
|
59
|
+
putStream(url: string, options?: HttpClientRequestOptions): ReadableStream<Uint8Array>;
|
|
60
|
+
patch(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
61
|
+
patchText(url: string, options?: HttpClientRequestOptions): Promise<string>;
|
|
62
|
+
patchJson<T extends UndefinableJson = UndefinableJson>(url: string, options?: HttpClientRequestOptions): Promise<T>;
|
|
63
|
+
patchBuffer(url: string, options?: HttpClientRequestOptions): Promise<Uint8Array>;
|
|
64
|
+
patchStream(url: string, options?: HttpClientRequestOptions): ReadableStream<Uint8Array>;
|
|
65
|
+
delete(url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
66
|
+
deleteText(url: string, options?: HttpClientRequestOptions): Promise<string>;
|
|
67
|
+
deleteJson<T extends UndefinableJson>(url: string, options?: HttpClientRequestOptions): Promise<T>;
|
|
68
|
+
deleteBuffer(url: string, options?: HttpClientRequestOptions): Promise<Uint8Array>;
|
|
69
|
+
deleteStream(url: string, options?: HttpClientRequestOptions): ReadableStream<Uint8Array>;
|
|
70
|
+
request(method: HttpMethod, url: string, options?: HttpClientRequestOptions): Promise<HttpClientResponse>;
|
|
71
|
+
rawRequest(request: HttpClientRequest): Promise<HttpClientResponse>;
|
|
73
72
|
private updateHandlers;
|
|
74
73
|
private prepareRequest;
|
|
75
74
|
}
|
|
@@ -11,13 +11,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var HttpClient_1;
|
|
15
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
15
|
exports.HttpClient = exports.HTTP_CLIENT_OPTIONS = void 0;
|
|
17
16
|
const response_1 = require("../../api/response");
|
|
18
17
|
const container_1 = require("../../container");
|
|
19
18
|
const array_1 = require("../../utils/array");
|
|
19
|
+
const base64_1 = require("../../utils/base64");
|
|
20
|
+
const encoding_1 = require("../../utils/encoding");
|
|
20
21
|
const middleware_1 = require("../../utils/middleware");
|
|
22
|
+
const readable_stream_from_promise_1 = require("../../utils/stream/readable-stream-from-promise");
|
|
21
23
|
const type_guards_1 = require("../../utils/type-guards");
|
|
22
24
|
const url_builder_1 = require("../../utils/url-builder");
|
|
23
25
|
const http_headers_1 = require("../http-headers");
|
|
@@ -26,7 +28,7 @@ const types_1 = require("../types");
|
|
|
26
28
|
const http_client_request_1 = require("./http-client-request");
|
|
27
29
|
const http_client_adapter_1 = require("./http-client.adapter");
|
|
28
30
|
exports.HTTP_CLIENT_OPTIONS = (0, container_1.injectionToken)(Symbol('HttpClientOptions'));
|
|
29
|
-
let HttpClient =
|
|
31
|
+
let HttpClient = class HttpClient {
|
|
30
32
|
constructor(adapter, options = {}) {
|
|
31
33
|
this.adapter = adapter;
|
|
32
34
|
this.options = options;
|
|
@@ -39,15 +41,6 @@ let HttpClient = HttpClient_1 = class HttpClient {
|
|
|
39
41
|
];
|
|
40
42
|
this.updateHandlers();
|
|
41
43
|
}
|
|
42
|
-
static get instance() {
|
|
43
|
-
if ((0, type_guards_1.isUndefined)(this._instance)) {
|
|
44
|
-
throw new Error('global instance not configured');
|
|
45
|
-
}
|
|
46
|
-
return this._instance;
|
|
47
|
-
}
|
|
48
|
-
static configureGlobalInstance(adapter, options = {}) {
|
|
49
|
-
this._instance = new HttpClient_1(adapter, options);
|
|
50
|
-
}
|
|
51
44
|
addMiddleware(middleware) {
|
|
52
45
|
this.middleware.push(middleware);
|
|
53
46
|
this.updateHandlers();
|
|
@@ -59,102 +52,124 @@ let HttpClient = HttpClient_1 = class HttpClient {
|
|
|
59
52
|
this.headers.remove(name);
|
|
60
53
|
}
|
|
61
54
|
async head(url, options) {
|
|
62
|
-
return this.request('HEAD', url, { ...options
|
|
55
|
+
return this.request('HEAD', url, { ...options });
|
|
63
56
|
}
|
|
64
57
|
async get(url, options) {
|
|
65
58
|
return this.request('GET', url, options);
|
|
66
59
|
}
|
|
67
60
|
async getText(url, options) {
|
|
68
|
-
const response = await this.request('GET', url, { ...options
|
|
69
|
-
return response.body;
|
|
61
|
+
const response = await this.request('GET', url, { ...options });
|
|
62
|
+
return response.body.readAsText();
|
|
70
63
|
}
|
|
71
64
|
async getJson(url, options) {
|
|
72
|
-
const response = await this.request('GET', url, { ...options
|
|
73
|
-
return response.body;
|
|
65
|
+
const response = await this.request('GET', url, { ...options });
|
|
66
|
+
return response.body.readAsJson();
|
|
74
67
|
}
|
|
75
68
|
async getBuffer(url, options) {
|
|
76
|
-
const response = await this.request('GET', url, { ...options
|
|
77
|
-
return response.body;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
const response = await this.request('GET', url, { ...options });
|
|
70
|
+
return response.body.readAsBuffer();
|
|
71
|
+
}
|
|
72
|
+
getStream(url, options) {
|
|
73
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
74
|
+
const response = await this.request('GET', url, { ...options });
|
|
75
|
+
return response.body.readAsStream();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
getTextStream(url, options) {
|
|
79
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
80
|
+
const response = await this.request('GET', url, { ...options });
|
|
81
|
+
return response.body.readAsTextStream();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getBinaryStream(url, options) {
|
|
85
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
86
|
+
const response = await this.request('GET', url, { ...options });
|
|
87
|
+
return response.body.readAsBinaryStream();
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
90
|
async post(url, options) {
|
|
84
91
|
return this.request('POST', url, options);
|
|
85
92
|
}
|
|
86
93
|
async postText(url, options) {
|
|
87
|
-
const response = await this.request('POST', url, { ...options
|
|
88
|
-
return response.body;
|
|
94
|
+
const response = await this.request('POST', url, { ...options });
|
|
95
|
+
return response.body.readAsText();
|
|
89
96
|
}
|
|
90
97
|
async postJson(url, options) {
|
|
91
|
-
const response = await this.request('POST', url, { ...options
|
|
92
|
-
return response.body;
|
|
98
|
+
const response = await this.request('POST', url, { ...options });
|
|
99
|
+
return response.body.readAsJson();
|
|
93
100
|
}
|
|
94
101
|
async postBuffer(url, options) {
|
|
95
|
-
const response = await this.request('POST', url, { ...options
|
|
96
|
-
return response.body;
|
|
102
|
+
const response = await this.request('POST', url, { ...options });
|
|
103
|
+
return response.body.readAsBuffer();
|
|
97
104
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
postStream(url, options) {
|
|
106
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
107
|
+
const response = await this.request('POST', url, { ...options });
|
|
108
|
+
return response.body.readAsBinaryStream();
|
|
109
|
+
});
|
|
101
110
|
}
|
|
102
111
|
async put(url, options) {
|
|
103
112
|
return this.request('PUT', url, options);
|
|
104
113
|
}
|
|
105
114
|
async putText(url, options) {
|
|
106
|
-
const response = await this.request('PUT', url, { ...options
|
|
107
|
-
return response.body;
|
|
115
|
+
const response = await this.request('PUT', url, { ...options });
|
|
116
|
+
return response.body.readAsText();
|
|
108
117
|
}
|
|
109
118
|
async putJson(url, options) {
|
|
110
|
-
const response = await this.request('PUT', url, { ...options
|
|
111
|
-
return response.body;
|
|
119
|
+
const response = await this.request('PUT', url, { ...options });
|
|
120
|
+
return response.body.readAsJson();
|
|
112
121
|
}
|
|
113
122
|
async putBuffer(url, options) {
|
|
114
|
-
const response = await this.request('PUT', url, { ...options
|
|
115
|
-
return response.body;
|
|
123
|
+
const response = await this.request('PUT', url, { ...options });
|
|
124
|
+
return response.body.readAsBuffer();
|
|
116
125
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
putStream(url, options) {
|
|
127
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
128
|
+
const response = await this.request('PUT', url, { ...options });
|
|
129
|
+
return response.body.readAsBinaryStream();
|
|
130
|
+
});
|
|
120
131
|
}
|
|
121
132
|
async patch(url, options) {
|
|
122
133
|
return this.request('PATCH', url, options);
|
|
123
134
|
}
|
|
124
135
|
async patchText(url, options) {
|
|
125
|
-
const response = await this.request('PATCH', url, { ...options
|
|
126
|
-
return response.body;
|
|
136
|
+
const response = await this.request('PATCH', url, { ...options });
|
|
137
|
+
return response.body.readAsText();
|
|
127
138
|
}
|
|
128
139
|
async patchJson(url, options) {
|
|
129
|
-
const response = await this.request('PATCH', url, { ...options
|
|
130
|
-
return response.body;
|
|
140
|
+
const response = await this.request('PATCH', url, { ...options });
|
|
141
|
+
return response.body.readAsJson();
|
|
131
142
|
}
|
|
132
143
|
async patchBuffer(url, options) {
|
|
133
|
-
const response = await this.request('PATCH', url, { ...options
|
|
134
|
-
return response.body;
|
|
144
|
+
const response = await this.request('PATCH', url, { ...options });
|
|
145
|
+
return response.body.readAsBuffer();
|
|
135
146
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
patchStream(url, options) {
|
|
148
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
149
|
+
const response = await this.request('PATCH', url, { ...options });
|
|
150
|
+
return response.body.readAsBinaryStream();
|
|
151
|
+
});
|
|
139
152
|
}
|
|
140
153
|
async delete(url, options) {
|
|
141
154
|
return this.request('DELETE', url, options);
|
|
142
155
|
}
|
|
143
156
|
async deleteText(url, options) {
|
|
144
|
-
const response = await this.request('DELETE', url, { ...options
|
|
145
|
-
return response.body;
|
|
157
|
+
const response = await this.request('DELETE', url, { ...options });
|
|
158
|
+
return response.body.readAsText();
|
|
146
159
|
}
|
|
147
160
|
async deleteJson(url, options) {
|
|
148
|
-
const response = await this.request('DELETE', url, { ...options
|
|
149
|
-
return response.body;
|
|
161
|
+
const response = await this.request('DELETE', url, { ...options });
|
|
162
|
+
return response.body.readAsJson();
|
|
150
163
|
}
|
|
151
164
|
async deleteBuffer(url, options) {
|
|
152
|
-
const response = await this.request('DELETE', url, { ...options
|
|
153
|
-
return response.body;
|
|
165
|
+
const response = await this.request('DELETE', url, { ...options });
|
|
166
|
+
return response.body.readAsBuffer();
|
|
154
167
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
168
|
+
deleteStream(url, options) {
|
|
169
|
+
return (0, readable_stream_from_promise_1.readableStreamFromPromise)(async () => {
|
|
170
|
+
const response = await this.request('DELETE', url, { ...options });
|
|
171
|
+
return response.body.readAsBinaryStream();
|
|
172
|
+
});
|
|
158
173
|
}
|
|
159
174
|
async request(method, url, options = {}) {
|
|
160
175
|
const request = new http_client_request_1.HttpClientRequest(url, method, options);
|
|
@@ -174,7 +189,7 @@ let HttpClient = HttpClient_1 = class HttpClient {
|
|
|
174
189
|
return clone;
|
|
175
190
|
}
|
|
176
191
|
};
|
|
177
|
-
HttpClient =
|
|
192
|
+
HttpClient = __decorate([
|
|
178
193
|
(0, container_1.singleton)(),
|
|
179
194
|
__param(1, (0, container_1.inject)(exports.HTTP_CLIENT_OPTIONS)),
|
|
180
195
|
__param(1, (0, container_1.optional)()),
|
|
@@ -191,17 +206,35 @@ function getBuildRequestUrlMiddleware(baseUrl) {
|
|
|
191
206
|
}
|
|
192
207
|
async function addRequestHeadersMiddleware(request, next) {
|
|
193
208
|
const clone = request.clone();
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
209
|
+
const { body, authorization } = clone;
|
|
210
|
+
if ((0, type_guards_1.isDefined)(body) && (0, type_guards_1.isUndefined)(clone.headers.contentType)) {
|
|
211
|
+
if ((0, type_guards_1.isDefined)(body.json)) {
|
|
212
|
+
clone.headers.contentType = 'application/json';
|
|
213
|
+
}
|
|
214
|
+
else if ((0, type_guards_1.isDefined)(body.text)) {
|
|
215
|
+
clone.headers.contentType = 'text/plain';
|
|
216
|
+
}
|
|
217
|
+
else if ((0, type_guards_1.isDefined)(body.form)) {
|
|
218
|
+
clone.headers.contentType = 'application/x-www-form-urlencoded';
|
|
219
|
+
}
|
|
220
|
+
else if ((0, type_guards_1.isDefined)(body.blob)) {
|
|
221
|
+
clone.headers.contentType = (body.blob.type.length > 0) ? body.blob.type : 'application/octet-stream';
|
|
222
|
+
}
|
|
223
|
+
else if ((0, type_guards_1.isDefined)(body.stream) || (0, type_guards_1.isDefined)(body.buffer)) {
|
|
224
|
+
clone.headers.contentType = 'application/octet-stream';
|
|
225
|
+
}
|
|
202
226
|
}
|
|
203
|
-
|
|
204
|
-
|
|
227
|
+
if ((0, type_guards_1.isDefined)(authorization) && (0, type_guards_1.isUndefined)(clone.headers.authorization)) {
|
|
228
|
+
if ((0, type_guards_1.isDefined)(authorization.basic)) {
|
|
229
|
+
const base64 = (0, base64_1.encodeBase64)((0, encoding_1.encodeUtf8)(`${authorization.basic.username}:${authorization.basic.password}`));
|
|
230
|
+
clone.headers.authorization = `Basic ${base64}`;
|
|
231
|
+
}
|
|
232
|
+
else if ((0, type_guards_1.isDefined)(authorization.bearer)) {
|
|
233
|
+
clone.headers.authorization = `Bearer ${authorization.bearer}`;
|
|
234
|
+
}
|
|
235
|
+
else if ((0, type_guards_1.isDefined)(authorization.token)) {
|
|
236
|
+
clone.headers.authorization = `Token ${authorization.token}`;
|
|
237
|
+
}
|
|
205
238
|
}
|
|
206
239
|
return next(clone);
|
|
207
240
|
}
|
|
@@ -209,7 +242,8 @@ async function errorMiddleware(request, next) {
|
|
|
209
242
|
try {
|
|
210
243
|
const response = await next(request);
|
|
211
244
|
if (request.throwOnNon200 && ((response.statusCode < 200) || (response.statusCode >= 300))) {
|
|
212
|
-
|
|
245
|
+
const httpError = await http_error_1.HttpError.create(http_error_1.HttpErrorReason.Non200StatusCode, request, response, `Status code ${response.statusCode}.`);
|
|
246
|
+
throw httpError;
|
|
213
247
|
}
|
|
214
248
|
return response;
|
|
215
249
|
}
|
|
@@ -217,8 +251,8 @@ async function errorMiddleware(request, next) {
|
|
|
217
251
|
if (!(error instanceof http_error_1.HttpError) || (error.responseInstance?.headers.contentType?.includes('json') == false)) {
|
|
218
252
|
throw error;
|
|
219
253
|
}
|
|
220
|
-
|
|
221
|
-
|
|
254
|
+
const body = error.response?.body;
|
|
255
|
+
if ((0, type_guards_1.isDefined)(body)) {
|
|
222
256
|
if (!(0, response_1.isErrorResponse)(body) || !(0, response_1.hasErrorHandler)(body)) {
|
|
223
257
|
throw error;
|
|
224
258
|
}
|
|
@@ -263,8 +297,7 @@ function mapParameters(request, baseUrl) {
|
|
|
263
297
|
}
|
|
264
298
|
}
|
|
265
299
|
if (parameterEntries.size > 0) {
|
|
266
|
-
|
|
267
|
-
throw new http_error_1.HttpError(http_error_1.HttpErrorReason.InvalidRequest, request, undefined, error);
|
|
300
|
+
throw new http_error_1.HttpError(http_error_1.HttpErrorReason.InvalidRequest, request, undefined, 'Not all parameters could be mapped to url, query and body because request is either GET/HEAD or body is already defined');
|
|
268
301
|
}
|
|
269
302
|
if ((0, type_guards_1.isDefined)(request.query)) {
|
|
270
303
|
for (const [key, valueOrValues] of request.query) {
|