@tstdl/base 0.86.0-beta2 → 0.86.0-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -0
- package/__container/decorators.d.ts +2 -0
- package/__container/decorators.js +34 -0
- package/__container/index.d.ts +3 -0
- package/__container/index.js +20 -0
- package/__container/interfaces.d.ts +2 -0
- package/__container/interfaces.js +25 -0
- package/__container/token.d.ts +2 -0
- package/__container/token.js +26 -0
- package/_container/container.js +443 -0
- package/_container/decorators.js +110 -0
- package/_container/index.js +27 -0
- package/_container/interfaces.js +26 -0
- package/_container/provider.js +60 -0
- package/_container/resolve-chain.js +105 -0
- package/_container/resolve.error.js +36 -0
- package/_container/token.js +41 -0
- package/_container/type-info.js +16 -0
- package/_container/types.js +16 -0
- package/_container/utils.js +44 -0
- package/api/client/client.d.ts +2 -2
- package/api/client/client.js +127 -109
- package/api/client/index.js +18 -1
- package/api/default-error-handlers.js +44 -18
- package/api/index.js +20 -14
- package/api/response.js +123 -99
- package/api/server/api-controller.d.ts +2 -2
- package/api/server/api-controller.js +71 -42
- package/api/server/api-request-token.provider.js +40 -12
- package/api/server/error-handler.js +46 -25
- package/api/server/gateway.d.ts +5 -6
- package/api/server/gateway.js +226 -207
- package/api/server/index.js +22 -5
- package/api/server/middlewares/allowed-methods.middleware.js +40 -17
- package/api/server/middlewares/catch-error.middleware.js +33 -12
- package/api/server/middlewares/cors.middleware.js +69 -49
- package/api/server/middlewares/index.js +21 -4
- package/api/server/middlewares/response-time.middleware.js +31 -8
- package/api/server/module.js +42 -18
- package/api/server/tokens.d.ts +4 -1
- package/api/server/tokens.js +31 -2
- package/api/types.js +40 -14
- package/api/utils.js +36 -13
- package/application/application.d.ts +7 -8
- package/application/application.js +163 -155
- package/application/index.js +18 -1
- package/async-iterator-symbol.js +28 -5
- package/authentication/authentication.api.js +113 -89
- package/authentication/client/api.client.js +57 -28
- package/authentication/client/authentication.service.d.ts +4 -4
- package/authentication/client/authentication.service.js +249 -223
- package/authentication/client/http-client.middleware.d.ts +3 -5
- package/authentication/client/http-client.middleware.js +35 -21
- package/authentication/client/index.js +22 -5
- package/authentication/client/module.d.ts +2 -1
- package/authentication/client/module.js +46 -15
- package/authentication/client/tokens.d.ts +2 -2
- package/authentication/client/tokens.js +30 -5
- package/authentication/errors/index.js +18 -1
- package/authentication/errors/secret-requirements.error.js +29 -6
- package/authentication/index.js +19 -2
- package/authentication/models/authentication-credentials.model.js +66 -37
- package/authentication/models/authentication-session.model.js +80 -51
- package/authentication/models/index.js +23 -6
- package/authentication/models/init-secret-reset-data.model.js +44 -16
- package/authentication/models/secret-check-result.model.js +36 -9
- package/authentication/models/token-payload-base.model.js +59 -31
- package/authentication/models/token.model.js +16 -1
- package/authentication/server/authentication-api-request-token.provider.js +52 -24
- package/authentication/server/authentication-credentials.repository.js +24 -1
- package/authentication/server/authentication-secret-requirements.validator.d.ts +11 -2
- package/authentication/server/authentication-secret-requirements.validator.js +58 -23
- package/authentication/server/authentication-secret-reset.handler.js +24 -1
- package/authentication/server/authentication-session.repository.js +24 -1
- package/authentication/server/authentication-subject.resolver.js +24 -5
- package/authentication/server/authentication-token-payload.provider.js +29 -5
- package/authentication/server/authentication.api-controller.js +114 -88
- package/authentication/server/authentication.service.d.ts +10 -3
- package/authentication/server/authentication.service.js +308 -264
- package/authentication/server/helper.js +87 -66
- package/authentication/server/index.js +28 -11
- package/authentication/server/module.d.ts +2 -1
- package/authentication/server/module.js +48 -25
- package/authentication/server/mongo/index.js +19 -2
- package/authentication/server/mongo/mongo-authentication-credentials.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-credentials.repository.js +84 -52
- package/authentication/server/mongo/mongo-authentication-session.repository.d.ts +3 -3
- package/authentication/server/mongo/mongo-authentication-session.repository.js +81 -49
- package/browser/browser-context-controller.d.ts +4 -4
- package/browser/browser-context-controller.js +106 -72
- package/browser/browser-controller.d.ts +12 -5
- package/browser/browser-controller.js +115 -74
- package/browser/browser.service.d.ts +12 -6
- package/browser/browser.service.js +117 -83
- package/browser/document-controller.js +81 -48
- package/browser/element-controller.d.ts +24 -0
- package/browser/element-controller.js +217 -139
- package/browser/frame-controller.js +50 -27
- package/browser/index.js +27 -10
- package/browser/locator-controller.js +59 -36
- package/browser/module.js +47 -23
- package/browser/page-controller.js +108 -89
- package/browser/pdf-options.js +103 -73
- package/browser/types.js +16 -1
- package/browser/utils.d.ts +2 -0
- package/browser/utils.js +116 -77
- package/collections/awaitable/awaitable-list.js +122 -99
- package/collections/awaitable/awaitable-map.js +116 -93
- package/collections/awaitable/awaitable-set.js +86 -63
- package/collections/awaitable/index.js +20 -3
- package/collections/collection.js +16 -1
- package/collections/index.js +23 -6
- package/collections/keyed-set.js +77 -53
- package/collections/list.js +16 -1
- package/collections/observable/index.js +25 -8
- package/collections/observable/observable-array.js +118 -95
- package/collections/observable/observable-collection-base.js +83 -60
- package/collections/observable/observable-collection.js +16 -1
- package/collections/observable/observable-list-base.js +78 -55
- package/collections/observable/observable-list.js +16 -1
- package/collections/observable/observable-map.js +79 -56
- package/collections/observable/observable-set.js +98 -75
- package/collections/observable/observable-sorted-array-list.js +188 -165
- package/collections/sorted-array-list.js +179 -156
- package/collections/sorted-list.js +16 -1
- package/collections/sorted-map.js +93 -70
- package/cookie/cookie.js +71 -49
- package/cookie/index.js +18 -1
- package/core.d.ts +4 -2
- package/core.js +82 -46
- package/data-structures/array-dictionary.js +110 -89
- package/data-structures/array-list.d.ts +1 -1
- package/data-structures/array-list.js +128 -105
- package/data-structures/cache.js +64 -41
- package/data-structures/circular-buffer.js +219 -195
- package/data-structures/collection.js +109 -86
- package/data-structures/dictionary.js +75 -51
- package/data-structures/distinct-collection.d.ts +24 -0
- package/data-structures/distinct-collection.js +77 -0
- package/data-structures/index-out-of-bounds.error.js +31 -8
- package/data-structures/index.d.ts +2 -1
- package/data-structures/index.js +33 -15
- package/data-structures/iterable-weak-map.js +149 -129
- package/data-structures/linked-list.js +385 -367
- package/data-structures/list.js +109 -78
- package/data-structures/map-dictionary.js +78 -55
- package/data-structures/multi-key-map.d.ts +1 -1
- package/data-structures/multi-key-map.js +163 -138
- package/data-structures/multi-key-set.d.ts +19 -0
- package/data-structures/multi-key-set.js +81 -0
- package/data-structures/{set.d.ts → set-collection.d.ts} +3 -3
- package/data-structures/set-collection.js +79 -0
- package/data-structures/sorted-array-list.d.ts +1 -1
- package/data-structures/sorted-array-list.js +166 -142
- package/data-structures/weak-ref-map.js +146 -123
- package/database/entity-repository.js +26 -2
- package/database/entity.js +16 -1
- package/database/id.js +29 -8
- package/database/index.js +23 -6
- package/database/module.js +33 -9
- package/database/mongo/classes.d.ts +5 -5
- package/database/mongo/classes.js +43 -13
- package/database/mongo/index.js +27 -10
- package/database/mongo/model/document.js +93 -62
- package/database/mongo/model/index.js +18 -1
- package/database/mongo/module.js +79 -51
- package/database/mongo/mongo-base.repository.js +283 -259
- package/database/mongo/mongo-bulk.js +110 -87
- package/database/mongo/mongo-entity-repository.d.ts +5 -5
- package/database/mongo/mongo-entity-repository.js +296 -270
- package/database/mongo/operations.js +76 -48
- package/database/mongo/query-converter.js +96 -73
- package/database/mongo/simple-entity-repository.js +28 -5
- package/database/mongo/types.js +25 -2
- package/database/query.js +36 -7
- package/database/utils.js +25 -2
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +18 -0
- package/decorators/log.d.ts +2 -0
- package/decorators/log.js +56 -0
- package/disposable/async-disposer.d.ts +4 -4
- package/disposable/async-disposer.js +105 -93
- package/disposable/disposable.js +33 -7
- package/disposable/index.js +20 -3
- package/disposable/using.js +37 -15
- package/distributed-loop/controller.js +16 -1
- package/distributed-loop/distributed-loop.d.ts +3 -3
- package/distributed-loop/distributed-loop.js +105 -78
- package/distributed-loop/index.js +20 -3
- package/distributed-loop/provider.js +48 -20
- package/enumerable/async-enumerable.js +261 -238
- package/enumerable/enumerable-methods.js +16 -1
- package/enumerable/enumerable.js +200 -177
- package/enumerable/index.js +19 -2
- package/environment.js +57 -25
- package/error/api.error.js +33 -10
- package/error/assertion.error.js +29 -6
- package/error/bad-request.error.js +29 -6
- package/error/custom.error.js +47 -25
- package/error/details.error.js +31 -8
- package/error/forbidden.error.js +29 -6
- package/error/index.js +33 -16
- package/error/invalid-token.error.js +29 -6
- package/error/max-bytes-exceeded.error.js +32 -9
- package/error/method-not-allowed.error.js +29 -6
- package/error/multi.error.js +31 -8
- package/error/not-found.error.js +29 -6
- package/error/not-implemented.error.js +29 -6
- package/error/not-supported.error.js +34 -11
- package/error/timeout.error.js +29 -6
- package/error/unauthorized.error.js +29 -6
- package/error/unsupported-media-type.error.js +29 -6
- package/examples/api/authentication.js +49 -42
- package/examples/api/basic-overview.js +85 -81
- package/examples/api/custom-authentication.js +69 -61
- package/examples/api/streaming.js +95 -90
- package/examples/browser/basic.js +21 -20
- package/examples/http/client.js +16 -13
- package/examples/mail/basic.js +42 -36
- package/examples/mail/templates/hello-name.js +33 -10
- package/examples/pdf/basic.js +49 -44
- package/examples/pdf/templates/hello-name.js +58 -35
- package/examples/reflection/basic.js +84 -52
- package/examples/template/basic.js +33 -30
- package/examples/template/templates/hello-jsx.js +32 -8
- package/examples/template/templates/hello-name.js +41 -18
- package/function/index.d.ts +1 -0
- package/function/index.js +18 -0
- package/function/log.d.ts +6 -0
- package/function/log.js +37 -0
- package/global-this.js +36 -17
- package/http/client/adapters/undici-http-client.adapter.js +111 -90
- package/http/client/http-client-options.d.ts +0 -5
- package/http/client/http-client-options.js +33 -14
- package/http/client/http-client-request.js +171 -149
- package/http/client/http-client-response.js +56 -33
- package/http/client/http-client.adapter.js +24 -1
- package/http/client/http-client.d.ts +5 -8
- package/http/client/http-client.js +325 -301
- package/http/client/index.js +23 -6
- package/http/client/middleware.d.ts +6 -0
- package/http/client/middleware.js +16 -0
- package/http/client/module.d.ts +6 -1
- package/http/client/module.js +42 -14
- package/http/client/tokens.d.ts +2 -0
- package/http/client/tokens.js +25 -0
- package/http/cookie-parser.js +42 -19
- package/http/http-body.js +75 -52
- package/http/http-form.js +37 -14
- package/http/http-headers.js +109 -86
- package/http/http-query.js +37 -14
- package/http/http-url-parameters.js +31 -8
- package/http/http-value-map.js +133 -110
- package/http/http.error.js +82 -60
- package/http/index.js +28 -11
- package/http/server/http-server-request.js +47 -24
- package/http/server/http-server-response.js +45 -22
- package/http/server/http-server.js +25 -2
- package/http/server/index.js +20 -3
- package/http/server/node/index.js +19 -2
- package/http/server/node/module.js +28 -8
- package/http/server/node/node-http-server.d.ts +1 -4
- package/http/server/node/node-http-server.js +230 -208
- package/http/types.js +47 -21
- package/http/utils.js +108 -92
- package/image-service/image-service.js +91 -59
- package/image-service/imgproxy/imgproxy-image-service.d.ts +6 -8
- package/image-service/imgproxy/imgproxy-image-service.js +125 -86
- package/image-service/imgproxy/index.js +18 -1
- package/image-service/index.js +18 -1
- package/import.js +25 -2
- package/index.js +18 -1
- package/injector/decorators.d.ts +81 -0
- package/injector/decorators.js +126 -0
- package/{container/index.js → injector/index.d.ts} +3 -2
- package/injector/index.js +28 -0
- package/injector/inject.d.ts +85 -0
- package/injector/inject.js +106 -0
- package/injector/injector.d.ts +91 -0
- package/injector/injector.js +497 -0
- package/injector/interfaces.d.ts +16 -0
- package/injector/interfaces.js +26 -0
- package/injector/provider.d.ts +49 -0
- package/injector/provider.js +64 -0
- package/injector/resolve-chain.d.ts +31 -0
- package/injector/resolve-chain.js +113 -0
- package/injector/resolve.error.d.ts +5 -0
- package/injector/resolve.error.js +36 -0
- package/injector/symbols.d.ts +2 -0
- package/injector/symbols.js +26 -0
- package/injector/token.d.ts +25 -0
- package/injector/token.js +41 -0
- package/injector/type-info.d.ts +20 -0
- package/injector/type-info.js +16 -0
- package/injector/types.d.ts +49 -0
- package/injector/types.js +16 -0
- package/interfaces.js +16 -1
- package/json-path/index.js +18 -1
- package/json-path/json-path.js +138 -138
- package/key-value-store/index.js +19 -2
- package/key-value-store/key-value-store.provider.js +24 -1
- package/key-value-store/key-value.store.d.ts +3 -3
- package/key-value-store/key-value.store.js +29 -6
- package/key-value-store/mongo/index.js +23 -6
- package/key-value-store/mongo/module.js +35 -17
- package/key-value-store/mongo/mongo-key-value-store.provider.js +48 -20
- package/key-value-store/mongo/mongo-key-value.model.js +16 -1
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +3 -3
- package/key-value-store/mongo/mongo-key-value.repository.js +52 -22
- package/key-value-store/mongo/mongo-key-value.store.js +89 -59
- package/key-value-store/mongo/tokens.d.ts +1 -1
- package/key-value-store/mongo/tokens.js +25 -2
- package/lock/index.js +19 -2
- package/lock/lock.d.ts +3 -2
- package/lock/lock.js +29 -5
- package/lock/mongo/index.js +22 -5
- package/lock/mongo/lock.js +135 -111
- package/lock/mongo/model.js +16 -1
- package/lock/mongo/module.js +37 -18
- package/lock/mongo/mongo-lock-repository.d.ts +3 -3
- package/lock/mongo/mongo-lock-repository.js +85 -56
- package/lock/mongo/provider.js +68 -38
- package/lock/provider.d.ts +3 -2
- package/lock/provider.js +25 -1
- package/lock/web/index.js +20 -3
- package/lock/web/module.js +31 -11
- package/lock/web/web-lock.js +105 -80
- package/lock/web/web-lock.provider.js +57 -27
- package/logger/console/index.js +18 -1
- package/logger/console/logger.js +80 -53
- package/logger/index.js +19 -2
- package/logger/level.js +31 -8
- package/logger/logger.d.ts +3 -2
- package/logger/logger.js +61 -37
- package/logger/noop/index.js +18 -1
- package/logger/noop/logger.js +42 -20
- package/mail/clients/nodemailer.mail-client.js +91 -62
- package/mail/index.js +22 -5
- package/mail/mail-log.repository.js +25 -2
- package/mail/mail.client.d.ts +3 -2
- package/mail/mail.client.js +63 -34
- package/mail/mail.service.js +106 -73
- package/mail/models/index.js +23 -6
- package/mail/models/mail-address.model.js +16 -1
- package/mail/models/mail-content.model.js +16 -1
- package/mail/models/mail-data.model.js +16 -1
- package/mail/models/mail-log.model.js +16 -1
- package/mail/models/mail-send-result.model.js +16 -1
- package/mail/models/mail-template.model.js +28 -5
- package/mail/module.js +41 -21
- package/mail/repositories/mongo-mail-log.repository.d.ts +3 -3
- package/mail/repositories/mongo-mail-log.repository.js +56 -24
- package/mail/tokens.d.ts +1 -1
- package/mail/tokens.js +25 -2
- package/memory/finalization.js +60 -36
- package/memory/index.js +19 -2
- package/memory/observable-finalization-registry.js +32 -9
- package/message-bus/broadcast-channel/broadcast-channel-message-bus-provider.js +53 -23
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.d.ts +1 -1
- package/message-bus/broadcast-channel/broadcast-channel-message-bus.js +74 -46
- package/message-bus/broadcast-channel/index.js +20 -3
- package/message-bus/broadcast-channel/module.js +31 -11
- package/message-bus/index.js +20 -3
- package/message-bus/local/index.js +20 -3
- package/message-bus/local/local-message-bus-provider.js +65 -35
- package/message-bus/local/local-message-bus.d.ts +1 -1
- package/message-bus/local/local-message-bus.js +66 -38
- package/message-bus/local/module.js +31 -11
- package/message-bus/local/types.js +16 -1
- package/message-bus/message-bus-base.js +63 -41
- package/message-bus/message-bus-provider.js +24 -1
- package/message-bus/message-bus.d.ts +3 -3
- package/message-bus/message-bus.js +29 -5
- package/migration/index.d.ts +1 -1
- package/migration/index.js +20 -3
- package/migration/migration-state-repository.js +25 -2
- package/migration/migration-state.js +16 -1
- package/migration/migrator.js +108 -80
- package/migration/mongo/index.js +19 -2
- package/migration/mongo/migration-state-repository.d.ts +3 -3
- package/migration/mongo/migration-state-repository.js +53 -23
- package/migration/mongo/module.js +34 -15
- package/module/index.js +21 -4
- package/module/module-base.js +60 -37
- package/module/module-metric-reporter.js +77 -58
- package/module/module.js +34 -10
- package/module/modules/function.module.js +34 -11
- package/module/modules/index.js +19 -2
- package/module/modules/web-server.module.d.ts +5 -10
- package/module/modules/web-server.module.js +83 -67
- package/module/utils.js +43 -19
- package/notification/api.js +50 -21
- package/notification/models/index.js +19 -2
- package/notification/models/notification-channel-job.model.js +16 -1
- package/notification/models/notification.model.js +103 -74
- package/notification/module.js +28 -8
- package/notification/notification-channel.service.js +24 -1
- package/notification/notification.repository.js +24 -1
- package/notification/notification.service.js +58 -30
- package/object-storage/index.js +20 -3
- package/object-storage/object-storage-provider.js +24 -1
- package/object-storage/object-storage.d.ts +3 -3
- package/object-storage/object-storage.js +30 -6
- package/object-storage/object.js +30 -7
- package/object-storage/s3/index.js +20 -3
- package/object-storage/s3/s3.object-storage-provider.js +109 -82
- package/object-storage/s3/s3.object-storage.d.ts +2 -2
- package/object-storage/s3/s3.object-storage.js +157 -130
- package/object-storage/s3/s3.object.js +62 -39
- package/openid-connect/cached-oidc-configuration.service.js +65 -35
- package/openid-connect/index.d.ts +1 -1
- package/openid-connect/index.js +28 -11
- package/openid-connect/mongo-oidc-state.repository.d.ts +3 -3
- package/openid-connect/mongo-oidc-state.repository.js +65 -38
- package/openid-connect/oidc-configuration.service.js +66 -38
- package/openid-connect/oidc-state.model.js +16 -1
- package/openid-connect/oidc-state.repository.js +25 -2
- package/openid-connect/oidc.service-model.js +16 -1
- package/openid-connect/oidc.service.js +187 -157
- package/package.json +18 -18
- package/password/have-i-been-pwned.js +39 -21
- package/password/index.js +21 -4
- package/password/password-check-result.model.js +63 -34
- package/password/password-check.js +76 -46
- package/password/password-check.localization.js +111 -86
- package/pdf/index.js +18 -1
- package/pdf/pdf.service.d.ts +3 -3
- package/pdf/pdf.service.js +206 -171
- package/pool/index.js +18 -1
- package/pool/pool.js +133 -116
- package/process-shutdown.d.ts +2 -2
- package/process-shutdown.js +75 -54
- package/promise/cancelable-promise.js +41 -23
- package/promise/deferred-promise.js +92 -68
- package/promise/index.js +20 -3
- package/promise/lazy-promise.js +47 -24
- package/queue/enqueue-batch.js +41 -18
- package/queue/index.js +20 -3
- package/queue/mongo/index.js +21 -4
- package/queue/mongo/job.js +16 -1
- package/queue/mongo/mongo-job.repository.d.ts +3 -3
- package/queue/mongo/mongo-job.repository.js +70 -44
- package/queue/mongo/queue.js +265 -242
- package/queue/mongo/queue.provider.d.ts +3 -3
- package/queue/mongo/queue.provider.js +72 -44
- package/queue/provider.js +24 -1
- package/queue/queue.d.ts +3 -3
- package/queue/queue.js +41 -15
- package/random/index.js +19 -2
- package/random/number-generator/index.js +20 -3
- package/random/number-generator/mulberry32.js +51 -34
- package/random/number-generator/random-number-generator-function.js +24 -1
- package/random/number-generator/random-number-generator.js +31 -8
- package/random/number-generator/seeded-random-number-generator.js +28 -5
- package/random/number-generator/sfc32.js +64 -41
- package/random/number-generator/utils.js +25 -2
- package/random/series.js +43 -41
- package/reflection/decorator-data.js +80 -63
- package/reflection/decorators.js +69 -39
- package/reflection/index.js +22 -5
- package/reflection/reflection-data-map.js +55 -32
- package/reflection/registry.d.ts +0 -1
- package/reflection/registry.js +130 -111
- package/reflection/types.js +16 -1
- package/reflection/utils.js +124 -96
- package/require.js +26 -3
- package/rpc/endpoints/message-port.rpc-endpoint.js +48 -29
- package/rpc/index.js +21 -4
- package/rpc/model.js +30 -7
- package/rpc/rpc-endpoint.js +40 -17
- package/rpc/rpc-error.js +40 -17
- package/rpc/rpc.js +235 -223
- package/rxjs/cast.js +28 -4
- package/rxjs/index.d.ts +1 -0
- package/rxjs/index.js +30 -12
- package/rxjs/intersection-observer.js +48 -25
- package/rxjs/media-query.js +27 -8
- package/rxjs/mutation-observer.js +50 -28
- package/rxjs/noop.js +28 -4
- package/rxjs/performance-observer.js +60 -37
- package/rxjs/resize-observer.js +50 -28
- package/rxjs/retry-backoff.js +47 -23
- package/rxjs/slow-array.js +36 -22
- package/rxjs/start-with-provider.d.ts +2 -0
- package/rxjs/start-with-provider.js +29 -0
- package/rxjs/teardown.js +44 -21
- package/rxjs/timing.js +57 -26
- package/rxjs/touch.js +30 -11
- package/schema/array-constraints/index.js +19 -2
- package/schema/array-constraints/maximum-length.js +42 -19
- package/schema/array-constraints/minimum-length.js +42 -19
- package/schema/coercers/boolean.coercer.js +49 -25
- package/schema/coercers/date.coercer.js +38 -14
- package/schema/coercers/index.js +23 -6
- package/schema/coercers/number.coercer.js +36 -12
- package/schema/coercers/regexp.coercer.js +41 -18
- package/schema/coercers/string.coercer.js +36 -12
- package/schema/coercers/uint8-array.coercer.js +44 -20
- package/schema/constraints/enumeration.js +49 -27
- package/schema/constraints/generic.js +41 -21
- package/schema/constraints/index.js +29 -12
- package/schema/constraints/integer.js +44 -20
- package/schema/constraints/length.js +36 -14
- package/schema/constraints/literal.js +44 -22
- package/schema/constraints/maximum-date.js +46 -23
- package/schema/constraints/maximum-length.js +45 -22
- package/schema/constraints/maximum.js +44 -21
- package/schema/constraints/minimum-date.js +46 -23
- package/schema/constraints/minimum-length.js +45 -22
- package/schema/constraints/minimum.js +44 -21
- package/schema/constraints/pattern.js +46 -23
- package/schema/decorators/class.js +26 -4
- package/schema/decorators/coerce.js +26 -4
- package/schema/decorators/constraint.js +28 -6
- package/schema/decorators/index.js +23 -6
- package/schema/decorators/property.js +38 -16
- package/schema/decorators/types.js +16 -1
- package/schema/decorators/utils.js +73 -45
- package/schema/index.js +27 -10
- package/schema/schema.error.js +72 -59
- package/schema/schema.js +274 -256
- package/schema/schemas/any.js +30 -7
- package/schema/schemas/array.js +44 -21
- package/schema/schemas/assign.js +46 -23
- package/schema/schemas/boolean.js +30 -7
- package/schema/schemas/constraint.js +29 -6
- package/schema/schemas/date.js +43 -20
- package/schema/schemas/defaulted.js +31 -8
- package/schema/schemas/enumeration.js +38 -15
- package/schema/schemas/index.js +43 -26
- package/schema/schemas/instance.js +26 -4
- package/schema/schemas/literal.js +38 -15
- package/schema/schemas/nullable.js +30 -7
- package/schema/schemas/number.js +48 -25
- package/schema/schemas/object.js +34 -10
- package/schema/schemas/omit.js +37 -14
- package/schema/schemas/one-or-many.js +35 -13
- package/schema/schemas/optional.js +30 -6
- package/schema/schemas/partial.js +39 -16
- package/schema/schemas/pick.js +37 -14
- package/schema/schemas/readable-stream.js +30 -7
- package/schema/schemas/record.js +31 -9
- package/schema/schemas/regexp.js +30 -7
- package/schema/schemas/string.js +59 -36
- package/schema/schemas/transform.js +29 -6
- package/schema/schemas/uint8-array.js +50 -27
- package/schema/schemas/union.js +34 -11
- package/schema/schemas/unknown.js +30 -7
- package/schema/transformers/generic.js +39 -16
- package/schema/transformers/index.js +21 -4
- package/schema/transformers/lowercase.js +33 -10
- package/schema/transformers/trim.js +33 -10
- package/schema/transformers/uppercase.js +33 -10
- package/schema/types/index.js +22 -5
- package/schema/types/schema-array-constraint.js +24 -1
- package/schema/types/schema-value-coercer.js +24 -1
- package/schema/types/schema-value-constraint.js +24 -1
- package/schema/types/schema-value-transformer.js +24 -1
- package/schema/types/types.js +191 -161
- package/schema/utils/index.js +19 -2
- package/schema/utils/schema.js +142 -120
- package/schema/utils/value-type.js +74 -51
- package/search-index/elastic/config.d.ts +3 -3
- package/search-index/elastic/config.js +50 -19
- package/search-index/elastic/index.js +23 -6
- package/search-index/elastic/keyword-rewriter.js +40 -17
- package/search-index/elastic/model/elastic-query.js +16 -1
- package/search-index/elastic/model/index-mapping.js +26 -4
- package/search-index/elastic/model/index.js +20 -3
- package/search-index/elastic/model/sort.js +16 -1
- package/search-index/elastic/module.d.ts +1 -1
- package/search-index/elastic/module.js +72 -39
- package/search-index/elastic/query-builder/boolean-query-builder.js +69 -46
- package/search-index/elastic/query-builder/index.js +18 -1
- package/search-index/elastic/query-converter.js +192 -174
- package/search-index/elastic/search-index.d.ts +2 -2
- package/search-index/elastic/search-index.js +153 -132
- package/search-index/elastic/sort-converter.js +34 -12
- package/search-index/elastic/types.js +16 -1
- package/search-index/error.js +35 -12
- package/search-index/index.js +20 -3
- package/search-index/memory/index.js +18 -1
- package/search-index/memory/memory-search-index.js +152 -130
- package/search-index/search-index.js +53 -30
- package/search-index/search-result.js +16 -1
- package/serializer/handlers/binary.js +47 -19
- package/serializer/handlers/date.js +28 -4
- package/serializer/handlers/error.js +31 -7
- package/serializer/handlers/index.js +24 -7
- package/serializer/handlers/map.js +40 -16
- package/serializer/handlers/regex.js +31 -7
- package/serializer/handlers/register.js +59 -36
- package/serializer/handlers/set.js +37 -13
- package/serializer/index.js +30 -3
- package/serializer/serializable.js +68 -43
- package/serializer/serializer.js +264 -244
- package/serializer/types.js +34 -6
- package/signals/api.d.ts +1 -1
- package/signals/api.js +48 -17
- package/signals/computed-with-dependencies.js +31 -8
- package/signals/effect-with-dependencies.js +31 -8
- package/signals/implementation/api.js +33 -33
- package/signals/implementation/computed.js +104 -125
- package/signals/implementation/configure.js +41 -18
- package/signals/implementation/effect.js +66 -48
- package/signals/implementation/errors.js +29 -5
- package/signals/implementation/graph.js +136 -164
- package/signals/implementation/index.js +27 -10
- package/signals/implementation/signal.js +101 -91
- package/signals/implementation/to-observable.js +38 -21
- package/signals/implementation/to-signal.js +60 -44
- package/signals/implementation/untracked.js +31 -15
- package/signals/implementation/watch.js +73 -58
- package/signals/index.d.ts +2 -0
- package/signals/index.js +26 -7
- package/signals/lazylize.d.ts +2 -0
- package/signals/lazylize.js +28 -0
- package/signals/pipe.d.ts +1 -1
- package/signals/pipe.js +33 -7
- package/signals/switch-map.js +27 -4
- package/signals/to-signal-2.d.ts +14 -0
- package/signals/to-signal-2.js +67 -0
- package/signals/types.js +16 -1
- package/signals/untracked-operator.js +33 -11
- package/sse/index.js +19 -2
- package/sse/model.js +16 -1
- package/sse/server-sent-events-source.js +76 -54
- package/sse/server-sent-events.js +72 -48
- package/supports.js +32 -5
- package/templates/index.js +26 -9
- package/templates/module.d.ts +2 -2
- package/templates/module.js +47 -40
- package/templates/providers/file.template-provider.d.ts +3 -3
- package/templates/providers/file.template-provider.js +82 -39
- package/templates/providers/memory.template-provider.js +55 -27
- package/templates/renderers/handlebars.template-renderer.js +122 -84
- package/templates/renderers/jsx.template-renderer.js +56 -28
- package/templates/renderers/mjml.template-renderer.js +82 -42
- package/templates/renderers/string.template-renderer.js +52 -24
- package/templates/resolvers/file.template-resolver.d.ts +3 -3
- package/templates/resolvers/file.template-resolver.js +90 -45
- package/templates/resolvers/jsx.template-resolver.js +59 -29
- package/templates/resolvers/string.template-resolver.js +59 -29
- package/templates/template-renderer.provider.js +66 -36
- package/templates/template-resolver.provider.js +66 -36
- package/templates/template.model.js +69 -39
- package/templates/template.provider.js +24 -1
- package/templates/template.renderer.js +34 -11
- package/templates/template.resolver.js +24 -1
- package/templates/template.service.js +82 -49
- package/templates/tokens.d.ts +2 -2
- package/templates/tokens.js +27 -3
- package/templates/types/jsx.intrinsic-elements.js +16 -1
- package/text/dynamic-text.model.js +69 -41
- package/text/index.js +20 -3
- package/text/localizable-text.model.js +16 -1
- package/text/localization.service.js +229 -196
- package/theme/adapters/css-adapter.js +46 -23
- package/theme/adapters/tailwind-adapter.js +52 -29
- package/theme/index.js +18 -1
- package/theme/theme-service.d.ts +1 -1
- package/theme/theme-service.js +147 -107
- package/threading/index.js +19 -2
- package/threading/thread-pool.js +70 -48
- package/threading/thread-worker.js +26 -3
- package/tokens.d.ts +1 -1
- package/tokens.js +25 -2
- package/types/geo-json.js +16 -1
- package/types.js +16 -2
- package/utils/alphabet.js +35 -12
- package/utils/any-iterable-iterator.js +27 -4
- package/utils/array/array-backtracker.js +65 -42
- package/utils/array/array.js +79 -76
- package/utils/array/index.js +19 -2
- package/utils/async-iterable-helpers/all.js +46 -25
- package/utils/async-iterable-helpers/any.js +46 -25
- package/utils/async-iterable-helpers/assert.js +43 -22
- package/utils/async-iterable-helpers/batch.js +46 -26
- package/utils/async-iterable-helpers/buffer.js +64 -47
- package/utils/async-iterable-helpers/concat.js +27 -5
- package/utils/async-iterable-helpers/default-if-empty.js +32 -9
- package/utils/async-iterable-helpers/deferred.js +26 -3
- package/utils/async-iterable-helpers/difference.js +48 -24
- package/utils/async-iterable-helpers/distinct.js +44 -23
- package/utils/async-iterable-helpers/drain.js +26 -4
- package/utils/async-iterable-helpers/filter.js +44 -23
- package/utils/async-iterable-helpers/first-or-default.js +30 -8
- package/utils/async-iterable-helpers/first.js +30 -8
- package/utils/async-iterable-helpers/for-each.js +38 -18
- package/utils/async-iterable-helpers/group-single.js +26 -3
- package/utils/async-iterable-helpers/group-to-map.js +41 -20
- package/utils/async-iterable-helpers/group-to-single-map.js +44 -23
- package/utils/async-iterable-helpers/group.js +26 -3
- package/utils/async-iterable-helpers/includes.js +28 -7
- package/utils/async-iterable-helpers/index.js +65 -48
- package/utils/async-iterable-helpers/interrupt.js +43 -19
- package/utils/async-iterable-helpers/is-async-iterable.js +29 -5
- package/utils/async-iterable-helpers/last-or-default.js +36 -13
- package/utils/async-iterable-helpers/last.js +36 -13
- package/utils/async-iterable-helpers/map-many.js +40 -19
- package/utils/async-iterable-helpers/map.js +40 -19
- package/utils/async-iterable-helpers/materialize.js +42 -21
- package/utils/async-iterable-helpers/metadata.js +58 -38
- package/utils/async-iterable-helpers/multiplex.js +44 -23
- package/utils/async-iterable-helpers/observable-iterable.js +53 -31
- package/utils/async-iterable-helpers/pairwise.js +44 -26
- package/utils/async-iterable-helpers/parallel/feed.js +45 -24
- package/utils/async-iterable-helpers/parallel/filter.js +31 -8
- package/utils/async-iterable-helpers/parallel/for-each.js +44 -21
- package/utils/async-iterable-helpers/parallel/group.js +32 -9
- package/utils/async-iterable-helpers/parallel/index.js +24 -7
- package/utils/async-iterable-helpers/parallel/map.js +29 -6
- package/utils/async-iterable-helpers/parallel/tap.js +29 -6
- package/utils/async-iterable-helpers/parallel/types.js +16 -1
- package/utils/async-iterable-helpers/reduce.js +46 -31
- package/utils/async-iterable-helpers/retry.js +58 -43
- package/utils/async-iterable-helpers/single-or-default.js +40 -17
- package/utils/async-iterable-helpers/single.js +42 -19
- package/utils/async-iterable-helpers/skip.js +26 -3
- package/utils/async-iterable-helpers/sort.js +29 -6
- package/utils/async-iterable-helpers/take-until.js +49 -32
- package/utils/async-iterable-helpers/take-while.js +46 -29
- package/utils/async-iterable-helpers/take.js +33 -10
- package/utils/async-iterable-helpers/tap.js +40 -19
- package/utils/async-iterable-helpers/throttle.js +30 -9
- package/utils/async-iterable-helpers/to-array.js +33 -10
- package/utils/async-iterable-helpers/to-async-iterable-iterator.js +59 -40
- package/utils/async-iterable-helpers/to-async-iterator.js +54 -32
- package/utils/async-iterable-helpers/to-set.js +33 -10
- package/utils/async-iterable-helpers/to-sync-iterable.js +27 -6
- package/utils/async-iterable-helpers/types.js +16 -1
- package/utils/async-iterable-helpers/while.js +46 -25
- package/utils/async-iterator-iterable-iterator.js +62 -41
- package/utils/backoff.js +109 -109
- package/utils/base64.js +140 -153
- package/utils/benchmark.js +107 -114
- package/utils/binary-search.js +87 -70
- package/utils/binary.js +61 -50
- package/utils/cancellation-token.js +140 -120
- package/utils/clone.js +64 -43
- package/utils/comparison.js +98 -76
- package/utils/compression.js +118 -107
- package/utils/config-parser.js +48 -21
- package/utils/crc32.js +42 -20
- package/utils/cryptography.js +121 -163
- package/utils/date-time.js +138 -102
- package/utils/encoding.js +60 -62
- package/utils/enum.js +53 -27
- package/utils/equals.js +119 -103
- package/utils/event-loop.js +39 -19
- package/utils/factory-map.js +75 -53
- package/utils/feedable-async-iterable.js +70 -47
- package/utils/file-reader.js +41 -15
- package/utils/format-error.js +57 -36
- package/utils/format.js +53 -32
- package/utils/function/index.js +19 -2
- package/utils/function/memoize.js +53 -38
- package/utils/function/throttle.js +48 -26
- package/utils/helpers.js +102 -93
- package/utils/image.js +88 -62
- package/utils/index.js +65 -48
- package/utils/iterable-helpers/all.js +31 -8
- package/utils/iterable-helpers/any.js +31 -8
- package/utils/iterable-helpers/assert.js +30 -7
- package/utils/iterable-helpers/batch.js +34 -11
- package/utils/iterable-helpers/concat.js +27 -4
- package/utils/iterable-helpers/default-if-empty.js +32 -9
- package/utils/iterable-helpers/deferred.js +25 -2
- package/utils/iterable-helpers/difference.js +45 -21
- package/utils/iterable-helpers/distinct.js +32 -9
- package/utils/iterable-helpers/drain.js +26 -4
- package/utils/iterable-helpers/filter.js +30 -7
- package/utils/iterable-helpers/first-or-default.js +30 -8
- package/utils/iterable-helpers/first.js +30 -8
- package/utils/iterable-helpers/for-each.js +28 -5
- package/utils/iterable-helpers/group-single.js +26 -3
- package/utils/iterable-helpers/group-to-map.js +32 -9
- package/utils/iterable-helpers/group-to-single-map.js +33 -10
- package/utils/iterable-helpers/group.js +26 -3
- package/utils/iterable-helpers/includes.js +26 -3
- package/utils/iterable-helpers/index.js +56 -39
- package/utils/iterable-helpers/is-iterable.js +29 -5
- package/utils/iterable-helpers/last-or-default.js +36 -13
- package/utils/iterable-helpers/last.js +36 -13
- package/utils/iterable-helpers/map-many.js +29 -6
- package/utils/iterable-helpers/map.js +29 -6
- package/utils/iterable-helpers/materialize.js +25 -2
- package/utils/iterable-helpers/metadata.js +38 -16
- package/utils/iterable-helpers/pairwise.js +33 -11
- package/utils/iterable-helpers/range.js +27 -4
- package/utils/iterable-helpers/reduce.js +33 -11
- package/utils/iterable-helpers/single-or-default.js +37 -14
- package/utils/iterable-helpers/single.js +40 -17
- package/utils/iterable-helpers/skip.js +29 -6
- package/utils/iterable-helpers/sort.js +27 -4
- package/utils/iterable-helpers/take-until.js +31 -8
- package/utils/iterable-helpers/take-while.js +33 -10
- package/utils/iterable-helpers/take.js +33 -10
- package/utils/iterable-helpers/tap.js +29 -6
- package/utils/iterable-helpers/types.js +16 -1
- package/utils/iterable-helpers/while.js +31 -8
- package/utils/jwt.js +100 -77
- package/utils/map.js +62 -35
- package/utils/math.js +64 -102
- package/utils/merge.js +45 -26
- package/utils/middleware.js +60 -36
- package/utils/moving-metric.js +188 -155
- package/utils/noop.js +27 -4
- package/utils/object/decycle.js +78 -57
- package/utils/object/dereference.js +44 -46
- package/utils/object/forward-ref.js +73 -57
- package/utils/object/index.js +24 -7
- package/utils/object/lazy-property.js +96 -81
- package/utils/object/merge.js +70 -48
- package/utils/object/object.js +136 -106
- package/utils/object/property-name.js +72 -69
- package/utils/ordered-feedable-async-iterable.js +65 -42
- package/utils/patch-worker.js +90 -69
- package/utils/patterns.js +29 -7
- package/utils/periodic-reporter.js +82 -60
- package/utils/periodic-sampler.js +91 -67
- package/utils/provider-function-iterable.js +48 -26
- package/utils/proxy.js +42 -17
- package/utils/random.js +50 -40
- package/utils/reflection.js +41 -13
- package/utils/repl.js +33 -14
- package/utils/set.js +62 -36
- package/utils/singleton.js +41 -18
- package/utils/sort.js +77 -53
- package/utils/stream/finalize-stream.js +62 -43
- package/utils/stream/index.js +23 -6
- package/utils/stream/readable-stream-adapter.js +57 -35
- package/utils/stream/readable-stream-from-promise.js +28 -7
- package/utils/stream/size-limited-stream.js +35 -12
- package/utils/stream/stream-helper-types.js +16 -1
- package/utils/stream/stream-reader.js +52 -30
- package/utils/string/hypenate.js +25 -2
- package/utils/string/index.js +20 -3
- package/utils/string/title-case.js +26 -6
- package/utils/string/trim.js +32 -9
- package/utils/throw.js +30 -7
- package/utils/timer.js +91 -70
- package/utils/timing.js +80 -52
- package/utils/type-guards.js +1076 -253
- package/utils/type-of.js +43 -25
- package/utils/units.js +124 -53
- package/utils/url-builder.js +68 -47
- package/utils/value-or-provider.js +29 -6
- package/utils/z-base32.js +63 -42
- package/web-types.js +16 -1
- package/container/container.js +0 -428
- package/container/decorators.js +0 -126
- package/container/interfaces.js +0 -2
- package/container/provider.js +0 -29
- package/container/resolve-chain.js +0 -80
- package/container/resolve.error.js +0 -11
- package/container/token.js +0 -20
- package/container/type-info.js +0 -1
- package/container/types.js +0 -1
- package/container/utils.js +0 -20
- package/data-structures/set.js +0 -56
- /package/{container → _container}/container.d.ts +0 -0
- /package/{container → _container}/decorators.d.ts +0 -0
- /package/{container → _container}/index.d.ts +0 -0
- /package/{container → _container}/interfaces.d.ts +0 -0
- /package/{container → _container}/provider.d.ts +0 -0
- /package/{container → _container}/resolve-chain.d.ts +0 -0
- /package/{container → _container}/resolve.error.d.ts +0 -0
- /package/{container → _container}/token.d.ts +0 -0
- /package/{container → _container}/type-info.d.ts +0 -0
- /package/{container → _container}/types.d.ts +0 -0
- /package/{container → _container}/utils.d.ts +0 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var injector_exports = {};
|
|
20
|
+
__export(injector_exports, {
|
|
21
|
+
Injector: () => Injector
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(injector_exports);
|
|
24
|
+
var import_circular_buffer = require("../data-structures/circular-buffer.js");
|
|
25
|
+
var import_multi_key_map = require("../data-structures/multi-key-map.js");
|
|
26
|
+
var import_async_disposer = require("../disposable/async-disposer.js");
|
|
27
|
+
var import_disposable = require("../disposable/disposable.js");
|
|
28
|
+
var import_deferred_promise = require("../promise/deferred-promise.js");
|
|
29
|
+
var import_registry = require("../reflection/registry.js");
|
|
30
|
+
var import_array = require("../utils/array/array.js");
|
|
31
|
+
var import_factory_map = require("../utils/factory-map.js");
|
|
32
|
+
var import_forward_ref = require("../utils/object/forward-ref.js");
|
|
33
|
+
var import_object = require("../utils/object/object.js");
|
|
34
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
35
|
+
var import_inject = require("./inject.js");
|
|
36
|
+
var import_interfaces = require("./interfaces.js");
|
|
37
|
+
var import_provider = require("./provider.js");
|
|
38
|
+
var import_resolve_chain = require("./resolve-chain.js");
|
|
39
|
+
var import_resolve_error = require("./resolve.error.js");
|
|
40
|
+
var import_symbols = require("./symbols.js");
|
|
41
|
+
var import_token = require("./token.js");
|
|
42
|
+
class Injector {
|
|
43
|
+
static #globalRegistrations = /* @__PURE__ */ new Map();
|
|
44
|
+
#parent;
|
|
45
|
+
#children = [];
|
|
46
|
+
#disposer = new import_async_disposer.AsyncDisposer();
|
|
47
|
+
#registrations = /* @__PURE__ */ new Map();
|
|
48
|
+
#injectorScopedResolutions = new import_multi_key_map.MultiKeyMap();
|
|
49
|
+
name;
|
|
50
|
+
constructor(name, parent = null) {
|
|
51
|
+
this.name = name;
|
|
52
|
+
this.#parent = parent;
|
|
53
|
+
this.register(Injector, { useValue: this });
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Globally register a provider for a token
|
|
57
|
+
* @param token token to register
|
|
58
|
+
* @param provider provider used to resolve the token
|
|
59
|
+
* @param options registration options
|
|
60
|
+
*/
|
|
61
|
+
static register(token, providers, options = {}) {
|
|
62
|
+
for (const provider of (0, import_array.toArray)(providers)) {
|
|
63
|
+
const registration = {
|
|
64
|
+
token,
|
|
65
|
+
provider,
|
|
66
|
+
options: { multi: (0, import_type_guards.isArray)(providers), ...options }
|
|
67
|
+
};
|
|
68
|
+
addRegistration(Injector.#globalRegistrations, registration);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Globally register a provider for a token as a singleton. Alias for {@link register} with `singleton` lifecycle
|
|
73
|
+
* @param token token to register
|
|
74
|
+
* @param provider provider used to resolve the token
|
|
75
|
+
* @param options registration options
|
|
76
|
+
*/
|
|
77
|
+
static registerSingleton(token, providers, options) {
|
|
78
|
+
Injector.register(token, providers, { ...options, lifecycle: "singleton" });
|
|
79
|
+
}
|
|
80
|
+
async dispose() {
|
|
81
|
+
await this.#disposer.dispose();
|
|
82
|
+
}
|
|
83
|
+
async [import_disposable.disposeAsync]() {
|
|
84
|
+
await this.dispose();
|
|
85
|
+
}
|
|
86
|
+
fork(name) {
|
|
87
|
+
const child = new Injector(name, this);
|
|
88
|
+
this.#children.push(child);
|
|
89
|
+
this.#disposer.add(child);
|
|
90
|
+
return child;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Register a provider for a token
|
|
94
|
+
* @param token token to register
|
|
95
|
+
* @param provider provider used to resolve the token
|
|
96
|
+
* @param options registration options
|
|
97
|
+
*/
|
|
98
|
+
register(token, providers, options = {}) {
|
|
99
|
+
for (const provider of (0, import_array.toArray)(providers)) {
|
|
100
|
+
const registration = {
|
|
101
|
+
token,
|
|
102
|
+
provider,
|
|
103
|
+
options: { multi: (0, import_type_guards.isArray)(providers), ...options },
|
|
104
|
+
resolutions: /* @__PURE__ */ new Map()
|
|
105
|
+
};
|
|
106
|
+
addRegistration(this.#registrations, registration);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Register a provider for a token as a singleton. Alias for {@link register} with `singleton` lifecycle
|
|
111
|
+
* @param token token to register
|
|
112
|
+
* @param provider provider used to resolve the token
|
|
113
|
+
* @param options registration options
|
|
114
|
+
*/
|
|
115
|
+
registerSingleton(token, providers, options) {
|
|
116
|
+
this.register(token, providers, { ...options, lifecycle: "singleton" });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if token has a registered provider
|
|
120
|
+
* @param token token check
|
|
121
|
+
*/
|
|
122
|
+
hasRegistration(token, options) {
|
|
123
|
+
const registration = this.tryGetRegistration(token, options);
|
|
124
|
+
return (0, import_type_guards.isDefined)(registration);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Try to get registration
|
|
128
|
+
* @param token token to get registration for
|
|
129
|
+
*/
|
|
130
|
+
tryGetRegistration(token, options) {
|
|
131
|
+
if ((0, import_type_guards.isNull)(this.#parent) && !this.#registrations.has(token) && Injector.#globalRegistrations.has(token)) {
|
|
132
|
+
const globalRegistrations = (0, import_array.toArray)(Injector.#globalRegistrations.get(token));
|
|
133
|
+
for (const globalRegistration of globalRegistrations) {
|
|
134
|
+
this.register(globalRegistration.token, globalRegistration.provider, globalRegistration.options);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const ownRegistration = options?.skipSelf != true ? this.#registrations.get(token) : void 0;
|
|
138
|
+
if ((0, import_type_guards.isDefined)(ownRegistration)) {
|
|
139
|
+
return ownRegistration;
|
|
140
|
+
}
|
|
141
|
+
if (options?.onlySelf == true) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
return this.#parent?.tryGetRegistration(token);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get registration
|
|
148
|
+
* @param token token to get registration for
|
|
149
|
+
*/
|
|
150
|
+
getRegistration(token, options) {
|
|
151
|
+
const registration = this.tryGetRegistration(token, options);
|
|
152
|
+
if ((0, import_type_guards.isUndefined)(registration)) {
|
|
153
|
+
const tokenName = (0, import_token.getTokenName)(token);
|
|
154
|
+
throw new Error(`No provider for ${tokenName} registered.`);
|
|
155
|
+
}
|
|
156
|
+
return registration;
|
|
157
|
+
}
|
|
158
|
+
resolve(token, argument, options = {}) {
|
|
159
|
+
const context = newInternalResolveContext();
|
|
160
|
+
const value = this._resolve(token, argument, options, context, import_resolve_chain.ResolveChain.startWith(token));
|
|
161
|
+
postProcess(context);
|
|
162
|
+
context.$done.resolve();
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
resolveAll(token, argument, options = {}) {
|
|
166
|
+
const context = newInternalResolveContext();
|
|
167
|
+
const values = this._resolveAll(token, argument, options, context, import_resolve_chain.ResolveChain.startWith(token));
|
|
168
|
+
postProcess(context);
|
|
169
|
+
context.$done.resolve();
|
|
170
|
+
return values;
|
|
171
|
+
}
|
|
172
|
+
async resolveAsync(token, argument, options = {}) {
|
|
173
|
+
const context = newInternalResolveContext();
|
|
174
|
+
const value = this._resolve(token, argument, options, context, import_resolve_chain.ResolveChain.startWith(token));
|
|
175
|
+
await postProcessAsync(context);
|
|
176
|
+
context.$done.resolve();
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
async resolveAllAsync(token, argument, options = {}) {
|
|
180
|
+
const context = newInternalResolveContext();
|
|
181
|
+
const values = this._resolveAll(token, argument, options, context, import_resolve_chain.ResolveChain.startWith(token));
|
|
182
|
+
await postProcessAsync(context);
|
|
183
|
+
context.$done.resolve();
|
|
184
|
+
return values;
|
|
185
|
+
}
|
|
186
|
+
_resolve(token, argument, options, context, chain) {
|
|
187
|
+
if ((0, import_type_guards.isUndefined)(token)) {
|
|
188
|
+
throw new import_resolve_error.ResolveError("Token is undefined - this might be because of circular dependencies, use alias or forwardRef in this case.", chain);
|
|
189
|
+
}
|
|
190
|
+
const registration = options.skipSelf == true ? void 0 : this.tryGetRegistration(token);
|
|
191
|
+
if ((0, import_type_guards.isUndefined)(registration)) {
|
|
192
|
+
if ((0, import_type_guards.isNotNull)(this.#parent) && options.onlySelf != true) {
|
|
193
|
+
return this.#parent._resolve(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
194
|
+
}
|
|
195
|
+
if (options.optional == true) {
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
198
|
+
throw new import_resolve_error.ResolveError(`No provider for ${(0, import_token.getTokenName)(token)} registered.`, chain);
|
|
199
|
+
}
|
|
200
|
+
const singleRegistration = (0, import_type_guards.isArray)(registration) ? registration[0] : registration;
|
|
201
|
+
return this._resolveRegistration(singleRegistration, argument, options, context, chain);
|
|
202
|
+
}
|
|
203
|
+
_resolveAll(token, argument, options, context, chain) {
|
|
204
|
+
if ((0, import_type_guards.isUndefined)(token)) {
|
|
205
|
+
throw new import_resolve_error.ResolveError("Token is undefined - this might be because of circular dependencies, use alias or forwardRef in this case.", chain);
|
|
206
|
+
}
|
|
207
|
+
const registration = options.skipSelf == true ? void 0 : this.tryGetRegistration(token);
|
|
208
|
+
if ((0, import_type_guards.isUndefined)(registration)) {
|
|
209
|
+
if ((0, import_type_guards.isNotNull)(this.#parent) && options.onlySelf != true) {
|
|
210
|
+
return this.#parent._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain);
|
|
211
|
+
}
|
|
212
|
+
if (options.optional == true) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
throw new import_resolve_error.ResolveError(`No provider for ${(0, import_token.getTokenName)(token)} registered.`, chain);
|
|
216
|
+
}
|
|
217
|
+
const registrations = (0, import_type_guards.isArray)(registration) ? registration : [registration];
|
|
218
|
+
return registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
|
|
219
|
+
}
|
|
220
|
+
_resolveRegistration(registration, argument, options, context, chain) {
|
|
221
|
+
checkOverflow(chain, context);
|
|
222
|
+
const injectionContext = this.getInjectionContext(context, argument, chain);
|
|
223
|
+
const previousInjectionContext = (0, import_inject.setCurrentInjectionContext)(injectionContext);
|
|
224
|
+
const resolutionTag = Symbol();
|
|
225
|
+
try {
|
|
226
|
+
const token = registration.token;
|
|
227
|
+
const resolutionScoped = registration.options.lifecycle == "resolution";
|
|
228
|
+
const injectorScoped = registration.options.lifecycle == "injector";
|
|
229
|
+
const singletonScoped = registration.options.lifecycle == "singleton";
|
|
230
|
+
const resolveArgument = argument ?? registration.options.defaultArgument ?? registration.options.defaultArgumentProvider?.(this.getResolveContext(resolutionTag, context, chain));
|
|
231
|
+
const argumentIdentity = resolveArgumentIdentity(registration, resolveArgument);
|
|
232
|
+
if (resolutionScoped && context.resolutionScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
233
|
+
return context.resolutionScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
234
|
+
} else if (injectorScoped && this.#injectorScopedResolutions.hasFlat(token, argumentIdentity)) {
|
|
235
|
+
return this.#injectorScopedResolutions.getFlat(token, argumentIdentity).value;
|
|
236
|
+
} else if (singletonScoped && registration.resolutions.has(argumentIdentity)) {
|
|
237
|
+
return registration.resolutions.get(argumentIdentity);
|
|
238
|
+
}
|
|
239
|
+
const value = this._resolveProvider(resolutionTag, registration, resolveArgument, options, context, injectionContext, chain);
|
|
240
|
+
const resolution = { tag: resolutionTag, registration, value, argument, chain };
|
|
241
|
+
context.resolutions.push(resolution);
|
|
242
|
+
if (resolutionScoped) {
|
|
243
|
+
context.resolutionScopedResolutions.setFlat(token, argumentIdentity, resolution);
|
|
244
|
+
}
|
|
245
|
+
if (injectorScoped) {
|
|
246
|
+
this.#injectorScopedResolutions.setFlat(token, argumentIdentity, resolution);
|
|
247
|
+
}
|
|
248
|
+
if (singletonScoped) {
|
|
249
|
+
registration.resolutions.set(argumentIdentity, value);
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
} finally {
|
|
253
|
+
(0, import_inject.setCurrentInjectionContext)(previousInjectionContext);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
_resolveProvider(resolutionTag, registration, resolveArgument, options, context, injectionContext, chain) {
|
|
257
|
+
try {
|
|
258
|
+
setResolving(registration.token, context, chain);
|
|
259
|
+
const provider = registration.provider;
|
|
260
|
+
let result;
|
|
261
|
+
if ((0, import_provider.isClassProvider)(provider)) {
|
|
262
|
+
const typeMetadata = import_registry.reflectionRegistry.getMetadata(provider.useClass);
|
|
263
|
+
const arg = resolveArgument ?? provider.defaultArgument ?? provider.defaultArgumentProvider?.();
|
|
264
|
+
injectionContext.argument = arg;
|
|
265
|
+
if (provider.useClass.length > 0 && ((0, import_type_guards.isUndefined)(typeMetadata) || !typeMetadata.data.has(import_symbols.injectableMetadataSymbol))) {
|
|
266
|
+
throw new import_resolve_error.ResolveError(`${provider.useClass.name} has constructor parameters but is not injectable.`, chain);
|
|
267
|
+
}
|
|
268
|
+
const parameters = (typeMetadata?.parameters ?? []).map((metadata) => this.resolveClassInjection(resolutionTag, context, provider.useClass, metadata, arg, chain));
|
|
269
|
+
result = { value: new provider.useClass(...parameters) };
|
|
270
|
+
}
|
|
271
|
+
if ((0, import_provider.isValueProvider)(provider)) {
|
|
272
|
+
result = { value: provider.useValue };
|
|
273
|
+
}
|
|
274
|
+
if ((0, import_provider.isTokenProvider)(provider)) {
|
|
275
|
+
const innerToken = provider.useToken ?? provider.useTokenProvider();
|
|
276
|
+
const arg = resolveArgument ?? provider.defaultArgument ?? provider.defaultArgumentProvider?.();
|
|
277
|
+
injectionContext.argument = arg;
|
|
278
|
+
if (provider.resolveAll == true) {
|
|
279
|
+
return this._resolveAll(innerToken, arg, options, context, chain.addToken(innerToken));
|
|
280
|
+
}
|
|
281
|
+
result = { value: this._resolve(innerToken, arg, options, context, chain.addToken(innerToken)) };
|
|
282
|
+
}
|
|
283
|
+
if ((0, import_provider.isFactoryProvider)(provider)) {
|
|
284
|
+
try {
|
|
285
|
+
const arg = resolveArgument ?? provider.defaultArgument ?? provider.defaultArgumentProvider?.();
|
|
286
|
+
injectionContext.argument = arg;
|
|
287
|
+
result = { value: provider.useFactory(arg, this.getResolveContext(resolutionTag, context, chain)) };
|
|
288
|
+
} catch (error) {
|
|
289
|
+
throw new import_resolve_error.ResolveError("Error in provider factory.", chain, error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if ((0, import_type_guards.isUndefined)(result)) {
|
|
293
|
+
throw new Error("Unsupported provider.");
|
|
294
|
+
}
|
|
295
|
+
if ((0, import_disposable.isDisposable)(result.value) || (0, import_disposable.isAsyncDisposable)(result.value)) {
|
|
296
|
+
this.#disposer.add(result.value);
|
|
297
|
+
}
|
|
298
|
+
return result.value;
|
|
299
|
+
} finally {
|
|
300
|
+
deleteResolving(registration.token, context);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
resolveClassInjection(resolutionTag, context, constructor, metadata, resolveArgument, chain) {
|
|
304
|
+
const getChain = (injectToken2) => chain.addParameter(constructor, metadata.index, injectToken2).addToken(injectToken2);
|
|
305
|
+
const injectMetadata = metadata.data.tryGet(import_symbols.injectMetadataSymbol) ?? {};
|
|
306
|
+
const injectToken = injectMetadata.injectToken ?? metadata.type;
|
|
307
|
+
if ((0, import_type_guards.isDefined)(injectMetadata.injectArgumentMapper) && (!this.hasRegistration(injectToken) || (0, import_type_guards.isDefined)(resolveArgument) || (0, import_type_guards.isUndefined)(injectToken))) {
|
|
308
|
+
return injectMetadata.injectArgumentMapper(resolveArgument);
|
|
309
|
+
}
|
|
310
|
+
const parameterResolveArgument = injectMetadata.forwardArgumentMapper?.(resolveArgument) ?? injectMetadata.resolveArgumentProvider?.(this.getResolveContext(resolutionTag, context, getChain(injectToken)));
|
|
311
|
+
if ((0, import_type_guards.isDefined)(injectMetadata.forwardRefToken)) {
|
|
312
|
+
const forwardRef = import_forward_ref.ForwardRef.create();
|
|
313
|
+
const forwardRefToken = injectMetadata.forwardRefToken;
|
|
314
|
+
context.forwardRefQueue.add(() => {
|
|
315
|
+
const forwardToken = (0, import_type_guards.isFunction)(forwardRefToken) ? forwardRefToken() : forwardRefToken;
|
|
316
|
+
if ((0, import_type_guards.isDefined)(injectMetadata.mapper)) {
|
|
317
|
+
throw new import_resolve_error.ResolveError("Cannot use inject mapper with forwardRef.", getChain(forwardToken));
|
|
318
|
+
}
|
|
319
|
+
const resolved2 = this[injectMetadata.resolveAll == true ? "_resolveAll" : "_resolve"](forwardToken, parameterResolveArgument, { optional: injectMetadata.optional }, context, getChain(forwardToken));
|
|
320
|
+
import_forward_ref.ForwardRef.setRef(forwardRef, resolved2);
|
|
321
|
+
});
|
|
322
|
+
context.forwardRefs.add(forwardRef);
|
|
323
|
+
return forwardRef;
|
|
324
|
+
}
|
|
325
|
+
const resolved = this._resolve(injectToken, parameterResolveArgument, { optional: injectMetadata.optional }, context, getChain(injectToken));
|
|
326
|
+
return (0, import_type_guards.isDefined)(injectMetadata.mapper) ? injectMetadata.mapper(resolved) : resolved;
|
|
327
|
+
}
|
|
328
|
+
resolveInjection(token, argument, options, context, chain) {
|
|
329
|
+
if ((0, import_type_guards.isDefined)(options.forwardRef)) {
|
|
330
|
+
const forwardRef = import_forward_ref.ForwardRef.create();
|
|
331
|
+
context.forwardRefQueue.add(() => {
|
|
332
|
+
const resolved = this._resolve(token, argument, options, context, chain.addToken(token));
|
|
333
|
+
import_forward_ref.ForwardRef.setRef(forwardRef, resolved);
|
|
334
|
+
});
|
|
335
|
+
context.forwardRefs.add(forwardRef);
|
|
336
|
+
return forwardRef;
|
|
337
|
+
}
|
|
338
|
+
return this._resolve(token, argument, options, context, chain.addToken(token));
|
|
339
|
+
}
|
|
340
|
+
async resolveInjectionAsync(token, argument, options, context, chain) {
|
|
341
|
+
const value = this.resolveInjection(token, argument, options, context, chain);
|
|
342
|
+
await context.$done;
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
resolveInjectionAll(token, argument, options, context, chain) {
|
|
346
|
+
if ((0, import_type_guards.isDefined)(options.forwardRef)) {
|
|
347
|
+
const forwardRef = import_forward_ref.ForwardRef.create();
|
|
348
|
+
context.forwardRefQueue.add(() => {
|
|
349
|
+
const resolved = this._resolveAll(token, argument, options, context, chain.addToken(token));
|
|
350
|
+
import_forward_ref.ForwardRef.setRef(forwardRef, resolved);
|
|
351
|
+
});
|
|
352
|
+
context.forwardRefs.add(forwardRef);
|
|
353
|
+
return forwardRef;
|
|
354
|
+
}
|
|
355
|
+
return this._resolveAll(token, argument, options, context, chain.addToken(token));
|
|
356
|
+
}
|
|
357
|
+
async resolveInjectionAllAsync(token, argument, options, context, chain) {
|
|
358
|
+
const values = this.resolveInjectionAll(token, argument, options, context, chain);
|
|
359
|
+
await context.$done;
|
|
360
|
+
return values;
|
|
361
|
+
}
|
|
362
|
+
getResolveContext(resolutionTag, resolveContext, chain) {
|
|
363
|
+
const context = {
|
|
364
|
+
resolve: (token, argument, options) => this._resolve(token, argument, options ?? {}, resolveContext, chain.addToken(token)),
|
|
365
|
+
resolveAll: (token, argument, options) => this._resolveAll(token, argument, options ?? {}, resolveContext, chain.addToken(token)),
|
|
366
|
+
addDisposeHandler: (handler) => this.#disposer.add(handler),
|
|
367
|
+
get context() {
|
|
368
|
+
return resolveContext.resolutionContexts.get(resolutionTag);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
return context;
|
|
372
|
+
}
|
|
373
|
+
getInjectionContext(resolveContext, resolveArgument, chain) {
|
|
374
|
+
const context = {
|
|
375
|
+
injector: this,
|
|
376
|
+
argument: resolveArgument,
|
|
377
|
+
inject: (token, argument, options) => this.resolveInjection(token, argument, options ?? {}, resolveContext, chain),
|
|
378
|
+
injectAll: (token, argument, options) => this.resolveInjectionAll(token, argument, options ?? {}, resolveContext, chain),
|
|
379
|
+
injectAsync: async (token, argument, options) => this.resolveInjectionAsync(token, argument, options ?? {}, resolveContext, chain),
|
|
380
|
+
injectAllAsync: async (token, argument, options) => this.resolveInjectionAllAsync(token, argument, options ?? {}, resolveContext, chain)
|
|
381
|
+
};
|
|
382
|
+
return context;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function addRegistration(registrations, registration) {
|
|
386
|
+
if ((0, import_provider.isClassProvider)(registration.provider)) {
|
|
387
|
+
const injectable = import_registry.reflectionRegistry.getMetadata(registration.provider.useClass)?.data.has(import_symbols.injectableMetadataSymbol) ?? false;
|
|
388
|
+
if (!injectable) {
|
|
389
|
+
throw new Error(`${registration.provider.useClass.name} is not injectable.`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const multi = registration.options.multi ?? false;
|
|
393
|
+
const existingRegistration = registrations.get(registration.token);
|
|
394
|
+
const hasExistingRegistration = (0, import_type_guards.isDefined)(existingRegistration);
|
|
395
|
+
const existingIsMulti = hasExistingRegistration && (0, import_type_guards.isArray)(existingRegistration);
|
|
396
|
+
if (hasExistingRegistration && existingIsMulti != multi) {
|
|
397
|
+
throw new Error("Cannot mix multi and non-multi registrations.");
|
|
398
|
+
}
|
|
399
|
+
if (multi && existingIsMulti) {
|
|
400
|
+
existingRegistration.push(registration);
|
|
401
|
+
} else {
|
|
402
|
+
registrations.set(registration.token, multi ? [registration] : registration);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function newInternalResolveContext() {
|
|
406
|
+
return {
|
|
407
|
+
resolves: 0,
|
|
408
|
+
resolving: /* @__PURE__ */ new Set(),
|
|
409
|
+
resolutionScopedResolutions: new import_multi_key_map.MultiKeyMap(),
|
|
410
|
+
resolutions: [],
|
|
411
|
+
resolutionContexts: new import_factory_map.FactoryMap(() => ({})),
|
|
412
|
+
forwardRefQueue: new import_circular_buffer.CircularBuffer(),
|
|
413
|
+
forwardRefs: /* @__PURE__ */ new Set(),
|
|
414
|
+
$done: new import_deferred_promise.DeferredPromise()
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function postProcess(context) {
|
|
418
|
+
for (const fn of context.forwardRefQueue.consume()) {
|
|
419
|
+
fn();
|
|
420
|
+
}
|
|
421
|
+
derefForwardRefs(context);
|
|
422
|
+
for (const resolution of context.resolutions) {
|
|
423
|
+
if ((0, import_type_guards.isFunction)(resolution.value?.[import_interfaces.afterResolve])) {
|
|
424
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
425
|
+
const returnValue = resolution.value[import_interfaces.afterResolve](resolution.argument, resolutionContext);
|
|
426
|
+
throwOnPromise(returnValue, "[afterResolve]", resolution.chain);
|
|
427
|
+
}
|
|
428
|
+
if ((0, import_provider.isProviderWithInitializer)(resolution.registration.provider)) {
|
|
429
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
430
|
+
const returnValue = resolution.registration.provider.afterResolve?.(resolution.value, resolution.argument, resolutionContext);
|
|
431
|
+
throwOnPromise(returnValue, "provider afterResolve handler", resolution.chain);
|
|
432
|
+
}
|
|
433
|
+
if ((0, import_type_guards.isDefined)(resolution.registration.options.afterResolve)) {
|
|
434
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
435
|
+
const returnValue = resolution.registration.options.afterResolve(resolution.value, resolution.argument, resolutionContext);
|
|
436
|
+
throwOnPromise(returnValue, "registration afterResolve handler", resolution.chain);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
async function postProcessAsync(context) {
|
|
441
|
+
for (const fn of context.forwardRefQueue.consume()) {
|
|
442
|
+
fn();
|
|
443
|
+
}
|
|
444
|
+
derefForwardRefs(context);
|
|
445
|
+
for (const resolution of context.resolutions) {
|
|
446
|
+
if ((0, import_type_guards.isFunction)(resolution.value?.[import_interfaces.afterResolve])) {
|
|
447
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
448
|
+
await resolution.value[import_interfaces.afterResolve](resolution.argument, resolutionContext);
|
|
449
|
+
}
|
|
450
|
+
if ((0, import_provider.isProviderWithInitializer)(resolution.registration.provider)) {
|
|
451
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
452
|
+
await resolution.registration.provider.afterResolve?.(resolution.value, resolution.argument, resolutionContext);
|
|
453
|
+
}
|
|
454
|
+
if ((0, import_type_guards.isDefined)(resolution.registration.options.afterResolve)) {
|
|
455
|
+
const resolutionContext = context.resolutionContexts.get(resolution.tag);
|
|
456
|
+
await resolution.registration.options.afterResolve(resolution.value, resolution.argument, resolutionContext);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function resolveArgumentIdentity(registration, resolveArgument) {
|
|
461
|
+
if ((0, import_type_guards.isDefined)(registration.options.argumentIdentityProvider) && (registration.options.lifecycle == "resolution" || registration.options.lifecycle == "singleton")) {
|
|
462
|
+
return registration.options.argumentIdentityProvider(resolveArgument);
|
|
463
|
+
}
|
|
464
|
+
return resolveArgument;
|
|
465
|
+
}
|
|
466
|
+
function setResolving(token, context, chain) {
|
|
467
|
+
if (context.resolving.has(token)) {
|
|
468
|
+
throw new import_resolve_error.ResolveError("Circular dependency to itself detected. Please check your registrations and providers. ForwardRef might be a solution.", chain);
|
|
469
|
+
}
|
|
470
|
+
context.resolving.add(token);
|
|
471
|
+
}
|
|
472
|
+
function deleteResolving(token, context) {
|
|
473
|
+
context.resolving.delete(token);
|
|
474
|
+
}
|
|
475
|
+
function throwOnPromise(value, type, chain) {
|
|
476
|
+
if ((0, import_type_guards.isPromise)(value)) {
|
|
477
|
+
throw new import_resolve_error.ResolveError(`Cannot evaluate async ${type} in synchronous resolve, use resolveAsync() instead.`, chain);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function checkOverflow(chain, context) {
|
|
481
|
+
if (chain.length > 750 || ++context.resolves > 750) {
|
|
482
|
+
throw new import_resolve_error.ResolveError("Resolve stack overflow. This can happen on circular dependencies with transient lifecycles and self reference. Use scoped or singleton lifecycle or forwardRef instead.", chain);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function derefForwardRefs(context) {
|
|
486
|
+
for (const resolution of context.resolutions.values()) {
|
|
487
|
+
if (!(typeof resolution.value == "object")) {
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
for (const [key, value] of (0, import_object.objectEntries)(resolution.value)) {
|
|
491
|
+
if (!context.forwardRefs.has(value)) {
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
resolution.value[key] = import_forward_ref.ForwardRef.deref(value);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Record, Type } from '../types.js';
|
|
2
|
+
import type { ArgumentedInjectionToken, InjectionTokenArgument, ReifyingInjectionToken } from './token.js';
|
|
3
|
+
export declare const resolveArgumentType: unique symbol;
|
|
4
|
+
export declare const afterResolve: unique symbol;
|
|
5
|
+
export type ResolveArgumentType = typeof resolveArgumentType;
|
|
6
|
+
export type ResolveArgument<T, Fallback = undefined> = undefined | (T extends Resolvable<infer U> ? U : T extends Type<Resolvable<infer U>> ? U : T extends (ArgumentedInjectionToken<any, any> | ReifyingInjectionToken) ? InjectionTokenArgument<T> : Fallback);
|
|
7
|
+
export interface Resolvable<A = unknown, C extends Record = Record> extends Partial<AfterResolve<A, C>> {
|
|
8
|
+
/**
|
|
9
|
+
* type of resolve argument
|
|
10
|
+
* @deprecated only used for type inference
|
|
11
|
+
*/
|
|
12
|
+
readonly [resolveArgumentType]: A;
|
|
13
|
+
}
|
|
14
|
+
export interface AfterResolve<A = unknown, C extends Record = Record> {
|
|
15
|
+
[afterResolve](argument: A, context: C): void | Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var interfaces_exports = {};
|
|
20
|
+
__export(interfaces_exports, {
|
|
21
|
+
afterResolve: () => afterResolve,
|
|
22
|
+
resolveArgumentType: () => resolveArgumentType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
25
|
+
const resolveArgumentType = Symbol("resolveArgumentType");
|
|
26
|
+
const afterResolve = Symbol("after resolve");
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Constructor, Record, TypedOmit } from '../types.js';
|
|
2
|
+
import type { ResolveArgument } from './interfaces.js';
|
|
3
|
+
import type { InjectionToken } from './token.js';
|
|
4
|
+
import type { ResolveContext } from './types.js';
|
|
5
|
+
export type Factory<T, A = any, C extends Record = Record> = (argument: ResolveArgument<T, A>, context: ResolveContext<C>) => T;
|
|
6
|
+
export type ProviderWithArgument<T, A> = {
|
|
7
|
+
defaultArgument?: ResolveArgument<T, A>;
|
|
8
|
+
defaultArgumentProvider?: () => ResolveArgument<T, A>;
|
|
9
|
+
};
|
|
10
|
+
export type ProviderWithInitializer<T, A, C extends Record> = {
|
|
11
|
+
afterResolve?: (value: T, argument: A, context: C) => void | Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type Provider<T = any, A = any, C extends Record = Record> = ClassProvider<T, A, C> | ValueProvider<T> | TokenProvider<T, A, C> | FactoryProvider<T, A, C>;
|
|
14
|
+
export type ClassProvider<T = any, A = any, C extends Record = Record> = ProviderWithArgument<T, A> & ProviderWithInitializer<T, A, C> & {
|
|
15
|
+
useClass: Constructor<T>;
|
|
16
|
+
};
|
|
17
|
+
export type ValueProvider<T = any> = {
|
|
18
|
+
useValue: T;
|
|
19
|
+
};
|
|
20
|
+
export type TokenProvider<T = any, A = any, C extends Record = Record> = ProviderWithArgument<T, A> & ProviderWithInitializer<T, A, C> & ({
|
|
21
|
+
useToken: InjectionToken<T, A>;
|
|
22
|
+
useTokenProvider?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
useToken?: undefined;
|
|
25
|
+
useTokenProvider: () => InjectionToken<T, A>;
|
|
26
|
+
}) & {
|
|
27
|
+
/**
|
|
28
|
+
* whether to resolve all providers registered for the token
|
|
29
|
+
*/
|
|
30
|
+
resolveAll?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type FactoryProvider<T = any, A = unknown, C extends Record = Record> = ProviderWithArgument<T, A> & ProviderWithInitializer<T, A, C> & {
|
|
33
|
+
useFactory: Factory<T, A, C>;
|
|
34
|
+
};
|
|
35
|
+
export declare function classProvider<T, A, C extends Record>(constructor: Constructor<T>, options?: TypedOmit<ClassProvider<T, A, C>, 'useClass'>): ClassProvider<T, A, C>;
|
|
36
|
+
export declare function valueProvider<T>(value: T, options?: TypedOmit<ValueProvider<T>, 'useValue'>): ValueProvider<T>;
|
|
37
|
+
export declare function tokenProvider<T, A, C extends Record>(token: InjectionToken<T, A>, options?: TypedOmit<TokenProvider<T, A, C>, 'useToken' | 'useTokenProvider'>): TokenProvider<T>;
|
|
38
|
+
export declare function factoryProvider<T, A, C extends Record>(factory: Factory<T, A, C>, options?: TypedOmit<FactoryProvider<T, A, C>, 'useFactory'>): FactoryProvider<T, A, C>;
|
|
39
|
+
export declare function isClassProvider<T, A>(value: Provider<T, A>): value is ClassProvider<T, A>;
|
|
40
|
+
export declare function isClassProvider<T, A>(value: unknown): value is ClassProvider<T, A>;
|
|
41
|
+
export declare function isValueProvider<T>(value: Provider<T>): value is ValueProvider<T>;
|
|
42
|
+
export declare function isValueProvider<T>(value: unknown): value is ValueProvider<T>;
|
|
43
|
+
export declare function isTokenProvider<T, A>(value: Provider<T, A>): value is TokenProvider<T, A>;
|
|
44
|
+
export declare function isTokenProvider<T, A>(value: unknown): value is TokenProvider<T, A>;
|
|
45
|
+
export declare function isFactoryProvider<T, A>(value: Provider<T, A>): value is FactoryProvider<T, A>;
|
|
46
|
+
export declare function isFactoryProvider<T, A>(value: unknown): value is FactoryProvider<T, A>;
|
|
47
|
+
export declare function isProvider<T, A>(value: Provider<T, A>): value is Provider<T, A>;
|
|
48
|
+
export declare function isProvider<T, A>(value: unknown): value is Provider<T, A>;
|
|
49
|
+
export declare function isProviderWithInitializer<T, A, C extends Record>(value: Provider<T, A, C>): value is Extract<Provider<T, A, C>, ProviderWithInitializer<T, A, C>>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var provider_exports = {};
|
|
20
|
+
__export(provider_exports, {
|
|
21
|
+
classProvider: () => classProvider,
|
|
22
|
+
factoryProvider: () => factoryProvider,
|
|
23
|
+
isClassProvider: () => isClassProvider,
|
|
24
|
+
isFactoryProvider: () => isFactoryProvider,
|
|
25
|
+
isProvider: () => isProvider,
|
|
26
|
+
isProviderWithInitializer: () => isProviderWithInitializer,
|
|
27
|
+
isTokenProvider: () => isTokenProvider,
|
|
28
|
+
isValueProvider: () => isValueProvider,
|
|
29
|
+
tokenProvider: () => tokenProvider,
|
|
30
|
+
valueProvider: () => valueProvider
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(provider_exports);
|
|
33
|
+
var import_object = require("../utils/object/object.js");
|
|
34
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
35
|
+
function classProvider(constructor, options) {
|
|
36
|
+
return { useClass: constructor, ...options };
|
|
37
|
+
}
|
|
38
|
+
function valueProvider(value, options) {
|
|
39
|
+
return { useValue: value, ...options };
|
|
40
|
+
}
|
|
41
|
+
function tokenProvider(token, options) {
|
|
42
|
+
return { useToken: token, ...options };
|
|
43
|
+
}
|
|
44
|
+
function factoryProvider(factory, options) {
|
|
45
|
+
return { useFactory: factory, ...options };
|
|
46
|
+
}
|
|
47
|
+
function isClassProvider(value) {
|
|
48
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useClass");
|
|
49
|
+
}
|
|
50
|
+
function isValueProvider(value) {
|
|
51
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useValue");
|
|
52
|
+
}
|
|
53
|
+
function isTokenProvider(value) {
|
|
54
|
+
return (0, import_type_guards.isObject)(value) && ((0, import_object.hasOwnProperty)(value, "useToken") || (0, import_object.hasOwnProperty)(value, "useTokenProvider"));
|
|
55
|
+
}
|
|
56
|
+
function isFactoryProvider(value) {
|
|
57
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useFactory");
|
|
58
|
+
}
|
|
59
|
+
function isProvider(value) {
|
|
60
|
+
return isClassProvider(value) || isValueProvider(value) || isTokenProvider(value) || isFactoryProvider(value);
|
|
61
|
+
}
|
|
62
|
+
function isProviderWithInitializer(value) {
|
|
63
|
+
return (0, import_type_guards.isFunction)(value.afterResolve);
|
|
64
|
+
}
|