@venok/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/config.d.ts +35 -0
- package/application/config.js +85 -0
- package/application/context.d.ts +198 -0
- package/application/context.js +325 -0
- package/application/factory.d.ts +43 -0
- package/application/factory.js +147 -0
- package/constants.d.ts +46 -0
- package/constants.js +53 -0
- package/context/creator.d.ts +9 -0
- package/context/creator.js +32 -0
- package/context/execution-host.d.ts +16 -0
- package/context/execution-host.js +30 -0
- package/context/external/creator.d.ts +63 -0
- package/context/external/creator.js +159 -0
- package/context/external/proxy.d.ts +5 -0
- package/context/external/proxy.js +19 -0
- package/decorators/apply.decorator.d.ts +10 -0
- package/decorators/apply.decorator.js +24 -0
- package/decorators/bind.decorator.d.ts +11 -0
- package/decorators/bind.decorator.js +20 -0
- package/decorators/catch.decorator.d.ts +17 -0
- package/decorators/catch.decorator.js +26 -0
- package/decorators/create-param.decorator.d.ts +29 -0
- package/decorators/create-param.decorator.js +51 -0
- package/decorators/dependencies.decorator.d.ts +6 -0
- package/decorators/dependencies.decorator.js +17 -0
- package/decorators/exception-filters.decorator.d.ts +21 -0
- package/decorators/exception-filters.decorator.js +41 -0
- package/decorators/global.decorator.d.ts +10 -0
- package/decorators/global.decorator.js +19 -0
- package/decorators/index.d.ts +15 -0
- package/decorators/index.js +31 -0
- package/decorators/inject.decorator.d.ts +26 -0
- package/decorators/inject.decorator.js +45 -0
- package/decorators/injectable.decorator.d.ts +40 -0
- package/decorators/injectable.decorator.js +51 -0
- package/decorators/module.decorator.d.ts +14 -0
- package/decorators/module.decorator.js +38 -0
- package/decorators/optional.decorator.d.ts +14 -0
- package/decorators/optional.decorator.js +30 -0
- package/decorators/set-metadata.decorator.d.ts +18 -0
- package/decorators/set-metadata.decorator.js +30 -0
- package/decorators/use-guards.decorator.d.ts +21 -0
- package/decorators/use-guards.decorator.js +40 -0
- package/decorators/use-interceptors.decorator.d.ts +21 -0
- package/decorators/use-interceptors.decorator.js +40 -0
- package/decorators/use-pipes.decorator.d.ts +21 -0
- package/decorators/use-pipes.decorator.js +39 -0
- package/discovery/meta-host-collection.d.ts +32 -0
- package/discovery/meta-host-collection.js +79 -0
- package/discovery/module.d.ts +5 -0
- package/discovery/module.js +24 -0
- package/discovery/service.d.ts +68 -0
- package/discovery/service.js +90 -0
- package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
- package/errors/exceptions/circular-dependency.exception.js +11 -0
- package/errors/exceptions/index.d.ts +8 -0
- package/errors/exceptions/index.js +24 -0
- package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class-module.exception.js +11 -0
- package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
- package/errors/exceptions/invalid-class-scope.exception.js +14 -0
- package/errors/exceptions/invalid-class.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class.exception.js +11 -0
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
- package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
- package/errors/exceptions/invalid-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-module.exception.js +11 -0
- package/errors/exceptions/runtime.exception.d.ts +4 -0
- package/errors/exceptions/runtime.exception.js +12 -0
- package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
- package/errors/exceptions/undefined-dependency.exception.js +11 -0
- package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
- package/errors/exceptions/undefined-forwardref.exception.js +11 -0
- package/errors/exceptions/undefined-module.exception.d.ts +4 -0
- package/errors/exceptions/undefined-module.exception.js +11 -0
- package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
- package/errors/exceptions/unknown-dependencies.exception.js +15 -0
- package/errors/exceptions/unknown-element.exception.d.ts +4 -0
- package/errors/exceptions/unknown-element.exception.js +12 -0
- package/errors/exceptions/unknown-export.exception.d.ts +4 -0
- package/errors/exceptions/unknown-export.exception.js +11 -0
- package/errors/exceptions/unknown-module.exception.d.ts +4 -0
- package/errors/exceptions/unknown-module.exception.js +10 -0
- package/errors/messages.d.ts +15 -0
- package/errors/messages.js +126 -0
- package/exceptions/external/filter-context.d.ts +10 -0
- package/exceptions/external/filter-context.js +37 -0
- package/exceptions/external/filter.d.ts +5 -0
- package/exceptions/external/filter.js +16 -0
- package/exceptions/external/handler.d.ts +9 -0
- package/exceptions/external/handler.js +31 -0
- package/exceptions/filter-context.d.ts +14 -0
- package/exceptions/filter-context.js +55 -0
- package/exceptions/select-exception-filter-metadata.d.ts +2 -0
- package/exceptions/select-exception-filter-metadata.js +6 -0
- package/exceptions/zone/handler.d.ts +5 -0
- package/exceptions/zone/handler.js +15 -0
- package/exceptions/zone/zone.d.ts +5 -0
- package/exceptions/zone/zone.js +32 -0
- package/guards/consumer.d.ts +9 -0
- package/guards/consumer.js +33 -0
- package/guards/context-creator.d.ts +17 -0
- package/guards/context-creator.js +69 -0
- package/guards/index.d.ts +2 -0
- package/guards/index.js +18 -0
- package/helpers/color.helper.d.ts +9 -0
- package/helpers/color.helper.js +14 -0
- package/helpers/context-id-factory.helper.d.ts +2 -0
- package/helpers/context-id-factory.helper.js +15 -0
- package/helpers/context.helper.d.ts +23 -0
- package/helpers/context.helper.js +49 -0
- package/helpers/extends-metadata.helper.d.ts +1 -0
- package/helpers/extends-metadata.helper.js +9 -0
- package/helpers/flatten.helper.d.ts +1 -0
- package/helpers/flatten.helper.js +9 -0
- package/helpers/messages.helper.d.ts +2 -0
- package/helpers/messages.helper.js +7 -0
- package/helpers/noop.helper.d.ts +1 -0
- package/helpers/noop.helper.js +5 -0
- package/helpers/random-string-generator.helper.d.ts +1 -0
- package/helpers/random-string-generator.helper.js +6 -0
- package/helpers/rethrow.helper.d.ts +1 -0
- package/helpers/rethrow.helper.js +7 -0
- package/helpers/shared.helper.d.ts +10 -0
- package/helpers/shared.helper.js +33 -0
- package/helpers/silent.helper.d.ts +10 -0
- package/helpers/silent.helper.js +18 -0
- package/helpers/transient.helper.d.ts +12 -0
- package/helpers/transient.helper.js +26 -0
- package/helpers/uuid.helper.d.ts +15 -0
- package/helpers/uuid.helper.js +54 -0
- package/helpers/validate-each.helper.d.ts +8 -0
- package/helpers/validate-each.helper.js +25 -0
- package/hooks/before-app-shutdown.hook.d.ts +9 -0
- package/hooks/before-app-shutdown.hook.js +45 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +21 -0
- package/hooks/on-app-bootstrap.hook.d.ts +8 -0
- package/hooks/on-app-bootstrap.hook.js +45 -0
- package/hooks/on-app-shutdown.hook.d.ts +9 -0
- package/hooks/on-app-shutdown.hook.js +46 -0
- package/hooks/on-module-destroy.hook.d.ts +8 -0
- package/hooks/on-module-destroy.hook.js +45 -0
- package/hooks/on-module-init.hook.d.ts +8 -0
- package/hooks/on-module-init.hook.js +45 -0
- package/index.d.ts +10 -0
- package/index.js +32 -0
- package/injector/constants.d.ts +2 -0
- package/injector/constants.js +7 -0
- package/injector/container.d.ts +61 -0
- package/injector/container.js +194 -0
- package/injector/helpers/class-scope.helper.d.ts +2 -0
- package/injector/helpers/class-scope.helper.js +9 -0
- package/injector/helpers/classifier.helper.d.ts +4 -0
- package/injector/helpers/classifier.helper.js +17 -0
- package/injector/helpers/is-durable.helper.d.ts +2 -0
- package/injector/helpers/is-durable.helper.js +9 -0
- package/injector/index.d.ts +5 -0
- package/injector/index.js +20 -0
- package/injector/injector.d.ts +87 -0
- package/injector/injector.js +452 -0
- package/injector/instance/links-host.d.ts +22 -0
- package/injector/instance/links-host.js +50 -0
- package/injector/instance/loader.d.ts +21 -0
- package/injector/instance/loader.js +73 -0
- package/injector/instance/resolver.d.ts +16 -0
- package/injector/instance/resolver.js +43 -0
- package/injector/instance/wrapper.d.ts +90 -0
- package/injector/instance/wrapper.js +272 -0
- package/injector/internal-core-module/core-providers.d.ts +4 -0
- package/injector/internal-core-module/core-providers.js +21 -0
- package/injector/internal-core-module/internal-core-module-factory.d.ts +8 -0
- package/injector/internal-core-module/internal-core-module-factory.js +42 -0
- package/injector/internal-core-module/internal-core-module.d.ts +4 -0
- package/injector/internal-core-module/internal-core-module.js +31 -0
- package/injector/module/compiler.d.ts +19 -0
- package/injector/module/compiler.js +27 -0
- package/injector/module/container.d.ts +6 -0
- package/injector/module/container.js +24 -0
- package/injector/module/lazy/loader.d.ts +21 -0
- package/injector/module/lazy/loader.js +49 -0
- package/injector/module/lazy/options.d.ts +6 -0
- package/injector/module/lazy/options.js +2 -0
- package/injector/module/module.d.ts +74 -0
- package/injector/module/module.js +383 -0
- package/injector/module/ref.d.ts +106 -0
- package/injector/module/ref.js +62 -0
- package/injector/module/token-factory.d.ts +13 -0
- package/injector/module/token-factory.js +71 -0
- package/injector/settlement-signal.d.ts +37 -0
- package/injector/settlement-signal.js +55 -0
- package/inspector/graph-inspector.d.ts +26 -0
- package/inspector/graph-inspector.js +163 -0
- package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
- package/inspector/initialize-on-preview.allowlist.js +13 -0
- package/inspector/interfaces/edge.interface.d.ts +28 -0
- package/inspector/interfaces/edge.interface.js +2 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
- package/inspector/interfaces/entrypoint.interface.d.ts +10 -0
- package/inspector/interfaces/entrypoint.interface.js +2 -0
- package/inspector/interfaces/extras.interface.d.ts +18 -0
- package/inspector/interfaces/extras.interface.js +2 -0
- package/inspector/interfaces/node.interface.d.ts +49 -0
- package/inspector/interfaces/node.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
- package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
- package/inspector/noop-graph-inspector.d.ts +2 -0
- package/inspector/noop-graph-inspector.js +8 -0
- package/inspector/partial-graph.host.d.ts +7 -0
- package/inspector/partial-graph.host.js +15 -0
- package/inspector/serialized-graph.d.ts +52 -0
- package/inspector/serialized-graph.js +121 -0
- package/interceptors/consumer.d.ts +9 -0
- package/interceptors/consumer.js +37 -0
- package/interceptors/context-creator.d.ts +17 -0
- package/interceptors/context-creator.js +67 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +18 -0
- package/interfaces/abstract.interface.d.ts +3 -0
- package/interfaces/abstract.interface.js +2 -0
- package/interfaces/application/context-options.interface.d.ts +41 -0
- package/interfaces/application/context-options.interface.js +9 -0
- package/interfaces/application/context.interface.d.ts +162 -0
- package/interfaces/application/context.interface.js +2 -0
- package/interfaces/application/index.d.ts +1 -0
- package/interfaces/application/index.js +17 -0
- package/interfaces/context/arguments-host.interface.d.ts +22 -0
- package/interfaces/context/arguments-host.interface.js +2 -0
- package/interfaces/context/execution.interface.d.ts +18 -0
- package/interfaces/context/execution.interface.js +2 -0
- package/interfaces/features/exception-filter.interface.d.ts +21 -0
- package/interfaces/features/exception-filter.interface.js +2 -0
- package/interfaces/features/guards.interface.d.ts +20 -0
- package/interfaces/features/guards.interface.js +2 -0
- package/interfaces/features/interceptor.interface.d.ts +30 -0
- package/interfaces/features/interceptor.interface.js +2 -0
- package/interfaces/features/pipes.interface.d.ts +37 -0
- package/interfaces/features/pipes.interface.js +2 -0
- package/interfaces/helper.interface.d.ts +3 -0
- package/interfaces/helper.interface.js +2 -0
- package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
- package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/index.d.ts +5 -0
- package/interfaces/hooks/index.js +21 -0
- package/interfaces/hooks/on-application-bootstrap.interface.d.ts +9 -0
- package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
- package/interfaces/hooks/on-application-shutdown.interface.d.ts +9 -0
- package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/on-destroy.interface.d.ts +10 -0
- package/interfaces/hooks/on-destroy.interface.js +2 -0
- package/interfaces/hooks/on-init.interface.d.ts +8 -0
- package/interfaces/hooks/on-init.interface.js +2 -0
- package/interfaces/index.d.ts +6 -0
- package/interfaces/index.js +22 -0
- package/interfaces/injectable.interface.d.ts +1 -0
- package/interfaces/injectable.interface.js +2 -0
- package/interfaces/modules/configurable/async-options.interface.d.ts +42 -0
- package/interfaces/modules/configurable/async-options.interface.js +2 -0
- package/interfaces/modules/configurable/cls.interface.d.ts +13 -0
- package/interfaces/modules/configurable/cls.interface.js +2 -0
- package/interfaces/modules/configurable/host.interface.d.ts +62 -0
- package/interfaces/modules/configurable/host.interface.js +2 -0
- package/interfaces/modules/configurable/index.d.ts +3 -0
- package/interfaces/modules/configurable/index.js +19 -0
- package/interfaces/modules/definition.interface.d.ts +4 -0
- package/interfaces/modules/definition.interface.js +2 -0
- package/interfaces/modules/dynamic-module.interface.d.ts +23 -0
- package/interfaces/modules/dynamic-module.interface.js +2 -0
- package/interfaces/modules/forward-reference.interface.d.ts +3 -0
- package/interfaces/modules/forward-reference.interface.js +2 -0
- package/interfaces/modules/index.d.ts +9 -0
- package/interfaces/modules/index.js +25 -0
- package/interfaces/modules/injection-token.interface.d.ts +5 -0
- package/interfaces/modules/injection-token.interface.js +2 -0
- package/interfaces/modules/introspection-result.interface.d.ts +10 -0
- package/interfaces/modules/introspection-result.interface.js +2 -0
- package/interfaces/modules/module-metadata.interface.d.ts +24 -0
- package/interfaces/modules/module-metadata.interface.js +2 -0
- package/interfaces/modules/module.interface.d.ts +2 -0
- package/interfaces/modules/module.interface.js +2 -0
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
- package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
- package/interfaces/modules/override.interface.d.ts +5 -0
- package/interfaces/modules/override.interface.js +2 -0
- package/interfaces/modules/provider.interface.d.ts +142 -0
- package/interfaces/modules/provider.interface.js +2 -0
- package/interfaces/scope.interface.d.ts +35 -0
- package/interfaces/scope.interface.js +23 -0
- package/interfaces/type.interface.d.ts +3 -0
- package/interfaces/type.interface.js +2 -0
- package/metadata-scanner.d.ts +4 -0
- package/metadata-scanner.js +34 -0
- package/module/configurable-module.builder.d.ts +93 -0
- package/module/configurable-module.builder.js +204 -0
- package/module/constants.d.ts +4 -0
- package/module/constants.js +7 -0
- package/module/helpers/generate-options-injection-token.helper.d.ts +1 -0
- package/module/helpers/generate-options-injection-token.helper.js +9 -0
- package/module/helpers/get-injection-providers.helper.d.ts +8 -0
- package/module/helpers/get-injection-providers.helper.js +36 -0
- package/module/helpers/index.d.ts +2 -0
- package/module/helpers/index.js +18 -0
- package/module/index.d.ts +2 -0
- package/module/index.js +18 -0
- package/package.json +35 -0
- package/pipes/consumer.d.ts +9 -0
- package/pipes/consumer.js +15 -0
- package/pipes/context-creator.d.ts +18 -0
- package/pipes/context-creator.js +70 -0
- package/pipes/index.d.ts +2 -0
- package/pipes/index.js +18 -0
- package/scanner.d.ts +81 -0
- package/scanner.js +374 -0
- package/services/console.service.d.ts +86 -0
- package/services/console.service.js +233 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +17 -0
- package/services/logger.service.d.ts +157 -0
- package/services/logger.service.js +269 -0
- package/services/reflector.service.d.ts +110 -0
- package/services/reflector.service.js +87 -0
- package/test/context/execution-host.spec.d.ts +1 -0
- package/test/context/execution-host.spec.js +31 -0
- package/test/context/external/creator.spec.d.ts +1 -0
- package/test/context/external/creator.spec.js +149 -0
- package/test/context/external/proxy.spec.d.ts +1 -0
- package/test/context/external/proxy.spec.js +45 -0
- package/test/exceptions/external/handler.spec.d.ts +1 -0
- package/test/exceptions/external/handler.spec.js +89 -0
- package/test/exceptions/filter-context.spec.d.ts +2 -0
- package/test/exceptions/filter-context.spec.js +91 -0
- package/test/exceptions/messages.spec.d.ts +0 -0
- package/test/exceptions/messages.spec.js +201 -0
- package/test/exceptions/zona/handler.spec.d.ts +1 -0
- package/test/exceptions/zona/handler.spec.js +51 -0
- package/test/exceptions/zona/zone.spec.d.ts +1 -0
- package/test/exceptions/zona/zone.spec.js +66 -0
- package/test/guards/consumer.spec.d.ts +1 -0
- package/test/guards/consumer.spec.js +47 -0
- package/test/guards/context-creator.spec.d.ts +1 -0
- package/test/guards/context-creator.spec.js +138 -0
- package/test/helpers/context-id-factory.spec.d.ts +1 -0
- package/test/helpers/context-id-factory.spec.js +9 -0
- package/test/helpers/shared.spec.d.ts +1 -0
- package/test/helpers/shared.spec.js +122 -0
- package/test/hooks/before-app-shutdown.hook.spec.d.ts +1 -0
- package/test/hooks/before-app-shutdown.hook.spec.js +44 -0
- package/test/hooks/on-app-bootstrap.hook.spec.d.ts +1 -0
- package/test/hooks/on-app-bootstrap.hook.spec.js +43 -0
- package/test/hooks/on-app-shutdown.hook.spec.d.ts +1 -0
- package/test/hooks/on-app-shutdown.hook.spec.js +43 -0
- package/test/hooks/on-module-destroy.hook.spec.d.ts +1 -0
- package/test/hooks/on-module-destroy.hook.spec.js +43 -0
- package/test/hooks/on-module-init.hook.spec.d.ts +1 -0
- package/test/hooks/on-module-init.hook.spec.js +43 -0
- package/test/injector/compiler.spec.d.ts +1 -0
- package/test/injector/compiler.spec.js +42 -0
- package/test/injector/container.spec.d.ts +1 -0
- package/test/injector/container.spec.js +203 -0
- package/test/injector/helpers/classifier.spec.d.ts +1 -0
- package/test/injector/helpers/classifier.spec.js +102 -0
- package/test/injector/injector.spec.d.ts +1 -0
- package/test/injector/injector.spec.js +678 -0
- package/test/injector/instance/loader.spec.d.ts +1 -0
- package/test/injector/instance/loader.spec.js +108 -0
- package/test/injector/instance/wrapper.spec.d.ts +1 -0
- package/test/injector/instance/wrapper.spec.js +772 -0
- package/test/injector/internal-core-module/internal-core-module-factory.spec.d.ts +1 -0
- package/test/injector/internal-core-module/internal-core-module-factory.spec.js +27 -0
- package/test/injector/module/lazy/loader.spec.d.ts +1 -0
- package/test/injector/module/lazy/loader.spec.js +71 -0
- package/test/injector/module/module.spec.d.ts +1 -0
- package/test/injector/module/module.spec.js +410 -0
- package/test/injector/module/token-factory.spec.d.ts +1 -0
- package/test/injector/module/token-factory.spec.js +84 -0
- package/test/interceptors/consumer.spec.d.ts +1 -0
- package/test/interceptors/consumer.spec.js +136 -0
- package/test/interceptors/context-creator.spec.d.ts +1 -0
- package/test/interceptors/context-creator.spec.js +139 -0
- package/test/metadata-scanner.spec.d.ts +1 -0
- package/test/metadata-scanner.spec.js +41 -0
- package/test/module/configurable-module.builder.spec.d.ts +1 -0
- package/test/module/configurable-module.builder.spec.js +102 -0
- package/test/module/helpers/get-injection-providers.helper.spec.d.ts +1 -0
- package/test/module/helpers/get-injection-providers.helper.spec.js +49 -0
- package/test/pipes/consumer.spec.d.ts +1 -0
- package/test/pipes/consumer.spec.js +42 -0
- package/test/pipes/context-creator.spec.d.ts +1 -0
- package/test/pipes/context-creator.spec.js +108 -0
- package/test/scanner.spec.d.ts +1 -0
- package/test/scanner.spec.js +620 -0
- package/test/services/logger.service.spec.d.ts +1 -0
- package/test/services/logger.service.spec.js +487 -0
- package/test/services/reflector.service.spec.d.ts +1 -0
- package/test/services/reflector.service.spec.js +105 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseGuards = void 0;
|
|
4
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
+
const constants_1 = require("@venok/core/constants");
|
|
6
|
+
const validate_each_helper_1 = require("@venok/core/helpers/validate-each.helper");
|
|
7
|
+
const extends_metadata_helper_1 = require("@venok/core/helpers/extends-metadata.helper");
|
|
8
|
+
/**
|
|
9
|
+
* Decorator that binds guards to the scope of the provider or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UseGuards` is used at the controller level, the guard will be
|
|
13
|
+
* applied to every handler (method) in the provider.
|
|
14
|
+
*
|
|
15
|
+
* When `@UseGuards` is used at the individual handler level, the guard
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param guards a single guard instance or class, or a list of guard instances
|
|
19
|
+
* or classes.
|
|
20
|
+
*
|
|
21
|
+
* @usageNotes
|
|
22
|
+
* Guards can also be set up globally for all controllers and routes
|
|
23
|
+
* using `app.useGlobalGuards()`.
|
|
24
|
+
*
|
|
25
|
+
* @publicApi
|
|
26
|
+
*/
|
|
27
|
+
function UseGuards(...guards) {
|
|
28
|
+
return (target, key, descriptor) => {
|
|
29
|
+
const isGuardValid = (guard) => guard && ((0, shared_helper_1.isFunction)(guard) || (0, shared_helper_1.isFunction)(guard.canActivate));
|
|
30
|
+
if (descriptor) {
|
|
31
|
+
(0, validate_each_helper_1.validateEach)(target.constructor, guards, isGuardValid, "@UseGuards", "guard");
|
|
32
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, descriptor.value);
|
|
33
|
+
return descriptor;
|
|
34
|
+
}
|
|
35
|
+
(0, validate_each_helper_1.validateEach)(target, guards, isGuardValid, "@UseGuards", "guard");
|
|
36
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, target);
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.UseGuards = UseGuards;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VenokInterceptor } from "@venok/core/interfaces/features/interceptor.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that binds interceptors to the scope of the provider or method,
|
|
4
|
+
* depending on its context.
|
|
5
|
+
*
|
|
6
|
+
* When `@UseInterceptors` is used at the controller level, the interceptor will
|
|
7
|
+
* be applied to every handler (method) in the provider.
|
|
8
|
+
*
|
|
9
|
+
* When `@UseInterceptors` is used at the individual handler level, the interceptor
|
|
10
|
+
* will apply only to that specific method.
|
|
11
|
+
*
|
|
12
|
+
* @param interceptors a single interceptor instance or class, or a list of
|
|
13
|
+
* interceptor instances or classes.
|
|
14
|
+
*
|
|
15
|
+
* @usageNotes
|
|
16
|
+
* Interceptors can also be set up globally for all controllers and routes
|
|
17
|
+
* using `app.useGlobalInterceptors()`.
|
|
18
|
+
*
|
|
19
|
+
* @publicApi
|
|
20
|
+
*/
|
|
21
|
+
export declare function UseInterceptors(...interceptors: (VenokInterceptor | Function)[]): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseInterceptors = void 0;
|
|
4
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
+
const constants_1 = require("@venok/core/constants");
|
|
6
|
+
const validate_each_helper_1 = require("@venok/core/helpers/validate-each.helper");
|
|
7
|
+
const extends_metadata_helper_1 = require("@venok/core/helpers/extends-metadata.helper");
|
|
8
|
+
/**
|
|
9
|
+
* Decorator that binds interceptors to the scope of the provider or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UseInterceptors` is used at the controller level, the interceptor will
|
|
13
|
+
* be applied to every handler (method) in the provider.
|
|
14
|
+
*
|
|
15
|
+
* When `@UseInterceptors` is used at the individual handler level, the interceptor
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param interceptors a single interceptor instance or class, or a list of
|
|
19
|
+
* interceptor instances or classes.
|
|
20
|
+
*
|
|
21
|
+
* @usageNotes
|
|
22
|
+
* Interceptors can also be set up globally for all controllers and routes
|
|
23
|
+
* using `app.useGlobalInterceptors()`.
|
|
24
|
+
*
|
|
25
|
+
* @publicApi
|
|
26
|
+
*/
|
|
27
|
+
function UseInterceptors(...interceptors) {
|
|
28
|
+
return (target, key, descriptor) => {
|
|
29
|
+
const isInterceptorValid = (interceptor) => interceptor && ((0, shared_helper_1.isFunction)(interceptor) || (0, shared_helper_1.isFunction)(interceptor.intercept));
|
|
30
|
+
if (descriptor) {
|
|
31
|
+
(0, validate_each_helper_1.validateEach)(target.constructor, interceptors, isInterceptorValid, "@UseInterceptors", "interceptor");
|
|
32
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
|
33
|
+
return descriptor;
|
|
34
|
+
}
|
|
35
|
+
(0, validate_each_helper_1.validateEach)(target, interceptors, isInterceptorValid, "@UseInterceptors", "interceptor");
|
|
36
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, target);
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.UseInterceptors = UseInterceptors;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PipeTransform } from "@venok/core/interfaces/features/pipes.interface";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that binds pipes to the scope of the provider or method,
|
|
4
|
+
* depending on its context.
|
|
5
|
+
*
|
|
6
|
+
* When `@UsePipes` is used at the controller level, the pipe will be
|
|
7
|
+
* applied to every handler (method) in the provider.
|
|
8
|
+
*
|
|
9
|
+
* When `@UsePipes` is used at the individual handler level, the pipe
|
|
10
|
+
* will apply only to that specific method.
|
|
11
|
+
*
|
|
12
|
+
* @param pipes a single pipe instance or class, or a list of pipe instances or
|
|
13
|
+
* classes.
|
|
14
|
+
*
|
|
15
|
+
* @usageNotes
|
|
16
|
+
* Pipes can also be set up globally for all controllers and routes
|
|
17
|
+
* using `app.useGlobalPipes()`.
|
|
18
|
+
*
|
|
19
|
+
* @publicApi
|
|
20
|
+
*/
|
|
21
|
+
export declare function UsePipes(...pipes: (PipeTransform | Function)[]): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsePipes = void 0;
|
|
4
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
+
const constants_1 = require("@venok/core/constants");
|
|
6
|
+
const extends_metadata_helper_1 = require("@venok/core/helpers/extends-metadata.helper");
|
|
7
|
+
const validate_each_helper_1 = require("@venok/core/helpers/validate-each.helper");
|
|
8
|
+
/**
|
|
9
|
+
* Decorator that binds pipes to the scope of the provider or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UsePipes` is used at the controller level, the pipe will be
|
|
13
|
+
* applied to every handler (method) in the provider.
|
|
14
|
+
*
|
|
15
|
+
* When `@UsePipes` is used at the individual handler level, the pipe
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param pipes a single pipe instance or class, or a list of pipe instances or
|
|
19
|
+
* classes.
|
|
20
|
+
*
|
|
21
|
+
* @usageNotes
|
|
22
|
+
* Pipes can also be set up globally for all controllers and routes
|
|
23
|
+
* using `app.useGlobalPipes()`.
|
|
24
|
+
*
|
|
25
|
+
* @publicApi
|
|
26
|
+
*/
|
|
27
|
+
function UsePipes(...pipes) {
|
|
28
|
+
return (target, key, descriptor) => {
|
|
29
|
+
const isPipeValid = (pipe) => pipe && ((0, shared_helper_1.isFunction)(pipe) || (0, shared_helper_1.isFunction)(pipe.transform));
|
|
30
|
+
if (descriptor) {
|
|
31
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, descriptor.value);
|
|
32
|
+
return descriptor;
|
|
33
|
+
}
|
|
34
|
+
(0, validate_each_helper_1.validateEach)(target, pipes, isPipeValid, "@UsePipes", "pipe");
|
|
35
|
+
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, target);
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.UsePipes = UsePipes;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Type } from "@venok/core/interfaces";
|
|
2
|
+
import { ModulesContainer } from "@venok/core/injector/module/container";
|
|
3
|
+
import { InstanceWrapper } from "@venok/core/injector/instance/wrapper";
|
|
4
|
+
export declare class DiscoverableMetaHostCollection {
|
|
5
|
+
/**
|
|
6
|
+
* A map of class references to metadata keys.
|
|
7
|
+
*/
|
|
8
|
+
static readonly metaHostLinks: Map<Function | Type<any>, string>;
|
|
9
|
+
/**
|
|
10
|
+
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
|
|
11
|
+
* The map is weakly referenced by the modules container (unique per application).
|
|
12
|
+
*/
|
|
13
|
+
private static readonly providersByMetaKey;
|
|
14
|
+
/**
|
|
15
|
+
* Adds a link between a class reference and a metadata key.
|
|
16
|
+
* @param target The class reference.
|
|
17
|
+
* @param metadataKey The metadata key.
|
|
18
|
+
*/
|
|
19
|
+
static addClassMetaHostLink(target: Type | Function, metadataKey: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Inspects a provider instance wrapper and adds it to the collection of providers
|
|
22
|
+
* if it has a metadata key.
|
|
23
|
+
* @param hostContainerRef A reference to the module's container.
|
|
24
|
+
* @param instanceWrapper A provider instance wrapper.
|
|
25
|
+
* @returns void
|
|
26
|
+
*/
|
|
27
|
+
static inspectProvider(hostContainerRef: ModulesContainer, instanceWrapper: InstanceWrapper): void;
|
|
28
|
+
static insertByMetaKey(metaKey: string, instanceWrapper: InstanceWrapper, collection: Map<string, Set<InstanceWrapper>>): void;
|
|
29
|
+
static getProvidersByMetaKey(hostContainerRef: ModulesContainer, metaKey: string): Set<InstanceWrapper>;
|
|
30
|
+
private static inspectInstanceWrapper;
|
|
31
|
+
private static getMetaKeyByInstanceWrapper;
|
|
32
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscoverableMetaHostCollection = void 0;
|
|
4
|
+
class DiscoverableMetaHostCollection {
|
|
5
|
+
/**
|
|
6
|
+
* Adds a link between a class reference and a metadata key.
|
|
7
|
+
* @param target The class reference.
|
|
8
|
+
* @param metadataKey The metadata key.
|
|
9
|
+
*/
|
|
10
|
+
static addClassMetaHostLink(target, metadataKey) {
|
|
11
|
+
this.metaHostLinks.set(target, metadataKey);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Inspects a provider instance wrapper and adds it to the collection of providers
|
|
15
|
+
* if it has a metadata key.
|
|
16
|
+
* @param hostContainerRef A reference to the module's container.
|
|
17
|
+
* @param instanceWrapper A provider instance wrapper.
|
|
18
|
+
* @returns void
|
|
19
|
+
*/
|
|
20
|
+
static inspectProvider(hostContainerRef, instanceWrapper) {
|
|
21
|
+
return this.inspectInstanceWrapper(hostContainerRef, instanceWrapper, this.providersByMetaKey);
|
|
22
|
+
}
|
|
23
|
+
static insertByMetaKey(metaKey, instanceWrapper, collection) {
|
|
24
|
+
if (collection.has(metaKey)) {
|
|
25
|
+
const wrappers = collection.get(metaKey);
|
|
26
|
+
wrappers.add(instanceWrapper);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const wrappers = new Set();
|
|
30
|
+
wrappers.add(instanceWrapper);
|
|
31
|
+
collection.set(metaKey, wrappers);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
static getProvidersByMetaKey(hostContainerRef, metaKey) {
|
|
35
|
+
const wrappersByMetaKey = this.providersByMetaKey.get(hostContainerRef);
|
|
36
|
+
return wrappersByMetaKey.get(metaKey);
|
|
37
|
+
}
|
|
38
|
+
static inspectInstanceWrapper(hostContainerRef, instanceWrapper, wrapperByMetaKeyMap) {
|
|
39
|
+
const metaKey = DiscoverableMetaHostCollection.getMetaKeyByInstanceWrapper(instanceWrapper);
|
|
40
|
+
if (!metaKey) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let collection;
|
|
44
|
+
if (wrapperByMetaKeyMap.has(hostContainerRef)) {
|
|
45
|
+
collection = wrapperByMetaKeyMap.get(hostContainerRef);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
collection = new Map();
|
|
49
|
+
wrapperByMetaKeyMap.set(hostContainerRef, collection);
|
|
50
|
+
}
|
|
51
|
+
this.insertByMetaKey(metaKey, instanceWrapper, collection);
|
|
52
|
+
}
|
|
53
|
+
static getMetaKeyByInstanceWrapper(instanceWrapper) {
|
|
54
|
+
return this.metaHostLinks.get(
|
|
55
|
+
// NOTE: Regarding the ternary statement below,
|
|
56
|
+
// - The condition `!wrapper.metatype` is needed because when we use `useValue`
|
|
57
|
+
// the value of `wrapper.metatype` will be `null`.
|
|
58
|
+
// - The condition `wrapper.inject` is needed here because when we use
|
|
59
|
+
// `useFactory`, the value of `wrapper.metatype` will be the supplied
|
|
60
|
+
// factory function.
|
|
61
|
+
// For both cases, we should use `wrapper.instance.constructor` instead
|
|
62
|
+
// of `wrapper.metatype` to resolve processor's class properly.
|
|
63
|
+
// But since calling `wrapper.instance` could degrade overall performance
|
|
64
|
+
// we must defer it as much we can.
|
|
65
|
+
instanceWrapper.metatype || instanceWrapper.inject
|
|
66
|
+
? instanceWrapper.instance?.constructor ?? instanceWrapper.metatype
|
|
67
|
+
: instanceWrapper.metatype);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.DiscoverableMetaHostCollection = DiscoverableMetaHostCollection;
|
|
71
|
+
/**
|
|
72
|
+
* A map of class references to metadata keys.
|
|
73
|
+
*/
|
|
74
|
+
DiscoverableMetaHostCollection.metaHostLinks = new Map();
|
|
75
|
+
/**
|
|
76
|
+
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
|
|
77
|
+
* The map is weakly referenced by the modules container (unique per application).
|
|
78
|
+
*/
|
|
79
|
+
DiscoverableMetaHostCollection.providersByMetaKey = new WeakMap();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DiscoveryModule = void 0;
|
|
10
|
+
const metadata_scanner_1 = require("@venok/core/metadata-scanner");
|
|
11
|
+
const module_decorator_1 = require("@venok/core/decorators/module.decorator");
|
|
12
|
+
const service_1 = require("@venok/core/discovery/service");
|
|
13
|
+
/**
|
|
14
|
+
* @publicApi
|
|
15
|
+
*/
|
|
16
|
+
let DiscoveryModule = class DiscoveryModule {
|
|
17
|
+
};
|
|
18
|
+
exports.DiscoveryModule = DiscoveryModule;
|
|
19
|
+
exports.DiscoveryModule = DiscoveryModule = __decorate([
|
|
20
|
+
(0, module_decorator_1.Module)({
|
|
21
|
+
providers: [metadata_scanner_1.MetadataScanner, service_1.DiscoveryService],
|
|
22
|
+
exports: [metadata_scanner_1.MetadataScanner, service_1.DiscoveryService],
|
|
23
|
+
})
|
|
24
|
+
], DiscoveryModule);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ModulesContainer } from "@venok/core/injector/module/container";
|
|
2
|
+
import { CustomDecorator } from "@venok/core/decorators/set-metadata.decorator";
|
|
3
|
+
import { Module } from "@venok/core/injector/module/module";
|
|
4
|
+
import { InstanceWrapper } from "@venok/core/injector/instance/wrapper";
|
|
5
|
+
/**
|
|
6
|
+
* @publicApi
|
|
7
|
+
*/
|
|
8
|
+
export interface FilterByInclude {
|
|
9
|
+
/**
|
|
10
|
+
* List of modules to include (whitelist) into the discovery process.
|
|
11
|
+
*/
|
|
12
|
+
include?: Function[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @publicApi
|
|
16
|
+
*/
|
|
17
|
+
export interface FilterByMetadataKey {
|
|
18
|
+
/**
|
|
19
|
+
* A key to filter controllers and providers by.
|
|
20
|
+
* Only instance wrappers with the specified metadata key will be returned.
|
|
21
|
+
*/
|
|
22
|
+
metadataKey?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @publicApi
|
|
26
|
+
*/
|
|
27
|
+
export type DiscoveryOptions = FilterByInclude | FilterByMetadataKey;
|
|
28
|
+
/**
|
|
29
|
+
* @publicApi
|
|
30
|
+
*/
|
|
31
|
+
export type DiscoverableDecorator<T> = ((opts?: T) => CustomDecorator) & {
|
|
32
|
+
KEY: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @publicApi
|
|
36
|
+
*/
|
|
37
|
+
export declare class DiscoveryService {
|
|
38
|
+
private readonly modulesContainer;
|
|
39
|
+
constructor(modulesContainer: ModulesContainer);
|
|
40
|
+
/**
|
|
41
|
+
* Creates a decorator that can be used to decorate classes and methods with metadata.
|
|
42
|
+
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
|
|
43
|
+
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
|
|
44
|
+
* @returns A decorator function.
|
|
45
|
+
*/
|
|
46
|
+
static createDecorator<T>(): DiscoverableDecorator<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns an array of instance wrappers (providers).
|
|
49
|
+
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
|
|
50
|
+
* @param options Discovery options.
|
|
51
|
+
* @param modules A list of modules to filter by.
|
|
52
|
+
* @returns An array of instance wrappers (providers).
|
|
53
|
+
*/
|
|
54
|
+
getProviders(options?: DiscoveryOptions, modules?: Module[]): InstanceWrapper[];
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves metadata from the specified instance wrapper.
|
|
57
|
+
* @param decorator The decorator to retrieve metadata of.
|
|
58
|
+
* @param instanceWrapper Reference to the instance wrapper.
|
|
59
|
+
* @param methodKey An optional method key to retrieve metadata from.
|
|
60
|
+
* @returns Discovered metadata.
|
|
61
|
+
*/
|
|
62
|
+
getMetadataByDecorator<T extends DiscoverableDecorator<any>>(decorator: T, instanceWrapper: InstanceWrapper, methodKey?: string): T extends DiscoverableDecorator<infer R> ? R | undefined : T | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Returns a list of modules to be used for discovery.
|
|
65
|
+
*/
|
|
66
|
+
protected getModules(options?: DiscoveryOptions): Module[];
|
|
67
|
+
private includeWhitelisted;
|
|
68
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DiscoveryService = void 0;
|
|
13
|
+
const container_1 = require("@venok/core/injector/module/container");
|
|
14
|
+
const set_metadata_decorator_1 = require("@venok/core/decorators/set-metadata.decorator");
|
|
15
|
+
const injectable_decorator_1 = require("@venok/core/decorators/injectable.decorator");
|
|
16
|
+
const uid_1 = require("uid");
|
|
17
|
+
const meta_host_collection_1 = require("@venok/core/discovery/meta-host-collection");
|
|
18
|
+
const flatten_helper_1 = require("@venok/core/helpers/flatten.helper");
|
|
19
|
+
/**
|
|
20
|
+
* @publicApi
|
|
21
|
+
*/
|
|
22
|
+
let DiscoveryService = class DiscoveryService {
|
|
23
|
+
constructor(modulesContainer) {
|
|
24
|
+
this.modulesContainer = modulesContainer;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a decorator that can be used to decorate classes and methods with metadata.
|
|
28
|
+
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
|
|
29
|
+
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
|
|
30
|
+
* @returns A decorator function.
|
|
31
|
+
*/
|
|
32
|
+
static createDecorator() {
|
|
33
|
+
const metadataKey = (0, uid_1.uid)(21);
|
|
34
|
+
const decoratorFn = (opts) => (target, key, descriptor) => {
|
|
35
|
+
if (!descriptor) {
|
|
36
|
+
meta_host_collection_1.DiscoverableMetaHostCollection.addClassMetaHostLink(target, metadataKey);
|
|
37
|
+
}
|
|
38
|
+
(0, set_metadata_decorator_1.SetMetadata)(metadataKey, opts ?? {})(target, key ?? "", descriptor);
|
|
39
|
+
};
|
|
40
|
+
decoratorFn.KEY = metadataKey;
|
|
41
|
+
return decoratorFn;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns an array of instance wrappers (providers).
|
|
45
|
+
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
|
|
46
|
+
* @param options Discovery options.
|
|
47
|
+
* @param modules A list of modules to filter by.
|
|
48
|
+
* @returns An array of instance wrappers (providers).
|
|
49
|
+
*/
|
|
50
|
+
getProviders(options = {}, modules = this.getModules(options)) {
|
|
51
|
+
if ("metadataKey" in options && options.metadataKey) {
|
|
52
|
+
const providers = meta_host_collection_1.DiscoverableMetaHostCollection.getProvidersByMetaKey(this.modulesContainer, options.metadataKey);
|
|
53
|
+
return Array.from(providers);
|
|
54
|
+
}
|
|
55
|
+
const providers = modules.map((item) => [...item.providers.values()]);
|
|
56
|
+
return (0, flatten_helper_1.flatten)(providers);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves metadata from the specified instance wrapper.
|
|
60
|
+
* @param decorator The decorator to retrieve metadata of.
|
|
61
|
+
* @param instanceWrapper Reference to the instance wrapper.
|
|
62
|
+
* @param methodKey An optional method key to retrieve metadata from.
|
|
63
|
+
* @returns Discovered metadata.
|
|
64
|
+
*/
|
|
65
|
+
getMetadataByDecorator(decorator, instanceWrapper, methodKey) {
|
|
66
|
+
if (methodKey) {
|
|
67
|
+
return Reflect.getMetadata(decorator.KEY, instanceWrapper.instance[methodKey]);
|
|
68
|
+
}
|
|
69
|
+
const clsRef = instanceWrapper.instance?.constructor ?? instanceWrapper.metatype;
|
|
70
|
+
return Reflect.getMetadata(decorator.KEY, clsRef);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns a list of modules to be used for discovery.
|
|
74
|
+
*/
|
|
75
|
+
getModules(options = {}) {
|
|
76
|
+
if (!("include" in options && options.include)) {
|
|
77
|
+
return [...this.modulesContainer.values()];
|
|
78
|
+
}
|
|
79
|
+
return this.includeWhitelisted(options.include);
|
|
80
|
+
}
|
|
81
|
+
includeWhitelisted(include) {
|
|
82
|
+
const moduleRefs = [...this.modulesContainer.values()];
|
|
83
|
+
return moduleRefs.filter(({ metatype }) => include.some((item) => item === metatype));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
exports.DiscoveryService = DiscoveryService;
|
|
87
|
+
exports.DiscoveryService = DiscoveryService = __decorate([
|
|
88
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
89
|
+
__metadata("design:paramtypes", [container_1.ModulesContainer])
|
|
90
|
+
], DiscoveryService);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircularDependencyException = void 0;
|
|
4
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
+
class CircularDependencyException extends runtime_exception_1.RuntimeException {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
const ctx = context ? ` inside ${context}` : ``;
|
|
8
|
+
super(`A circular dependency has been detected${ctx}. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CircularDependencyException = CircularDependencyException;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './circular-dependency.exception';
|
|
2
|
+
export * from './runtime.exception';
|
|
3
|
+
export * from './unknown-element.exception';
|
|
4
|
+
export * from './invalid-class-scope.exception';
|
|
5
|
+
export * from './invalid-class.exception';
|
|
6
|
+
export * from './unknown-export.exception';
|
|
7
|
+
export * from './unknown-module.exception';
|
|
8
|
+
export * from './undefined-forwardref.exception';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./circular-dependency.exception"), exports);
|
|
18
|
+
__exportStar(require("./runtime.exception"), exports);
|
|
19
|
+
__exportStar(require("./unknown-element.exception"), exports);
|
|
20
|
+
__exportStar(require("./invalid-class-scope.exception"), exports);
|
|
21
|
+
__exportStar(require("./invalid-class.exception"), exports);
|
|
22
|
+
__exportStar(require("./unknown-export.exception"), exports);
|
|
23
|
+
__exportStar(require("./unknown-module.exception"), exports);
|
|
24
|
+
__exportStar(require("./undefined-forwardref.exception"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidClassModuleException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class InvalidClassModuleException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(metatypeUsedAsAModule, scope) {
|
|
8
|
+
super((0, messages_1.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE)(metatypeUsedAsAModule, scope));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidClassModuleException = InvalidClassModuleException;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RuntimeException } from "./runtime.exception";
|
|
2
|
+
import { Abstract, Type } from "@venok/core/interfaces";
|
|
3
|
+
export declare class InvalidClassScopeException extends RuntimeException {
|
|
4
|
+
constructor(metatypeOrToken: Type<any> | Abstract<any> | string | symbol);
|
|
5
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidClassScopeException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
7
|
+
class InvalidClassScopeException extends runtime_exception_1.RuntimeException {
|
|
8
|
+
constructor(metatypeOrToken) {
|
|
9
|
+
let name = (0, shared_helper_1.isFunction)(metatypeOrToken) ? metatypeOrToken.name : metatypeOrToken;
|
|
10
|
+
name = name && name.toString();
|
|
11
|
+
super((0, messages_1.INVALID_CLASS_SCOPE_MESSAGE) `${name}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.InvalidClassScopeException = InvalidClassScopeException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidClassException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class InvalidClassException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(value) {
|
|
8
|
+
super((0, messages_1.INVALID_CLASS_MESSAGE) `${value}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidClassException = InvalidClassException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidExceptionFilterException = void 0;
|
|
4
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
+
const messages_1 = require("../messages");
|
|
6
|
+
class InvalidExceptionFilterException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(messages_1.INVALID_EXCEPTION_FILTER);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidExceptionFilterException = InvalidExceptionFilterException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidModuleException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class InvalidModuleException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(parentModule, index, scope) {
|
|
8
|
+
super((0, messages_1.INVALID_MODULE_MESSAGE)(parentModule, index, scope));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidModuleException = InvalidModuleException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeException = void 0;
|
|
4
|
+
class RuntimeException extends Error {
|
|
5
|
+
constructor(message = ``) {
|
|
6
|
+
super(message);
|
|
7
|
+
}
|
|
8
|
+
what() {
|
|
9
|
+
return this.message;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.RuntimeException = RuntimeException;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InjectorDependencyContext } from "../../injector/injector";
|
|
2
|
+
import { RuntimeException } from "./runtime.exception";
|
|
3
|
+
import { Module } from "../../injector/module/module";
|
|
4
|
+
export declare class UndefinedDependencyException extends RuntimeException {
|
|
5
|
+
constructor(type: string, undefinedDependencyContext: InjectorDependencyContext, module: Module);
|
|
6
|
+
}
|