@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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UndefinedDependencyException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(type, undefinedDependencyContext, module) {
|
|
8
|
+
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, undefinedDependencyContext, module));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UndefinedDependencyException = UndefinedDependencyException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UndefinedForwardRefException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class UndefinedForwardRefException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(scope) {
|
|
8
|
+
super((0, messages_1.UNDEFINED_FORWARDREF_MESSAGE)(scope));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UndefinedForwardRefException = UndefinedForwardRefException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UndefinedModuleException = void 0;
|
|
4
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
+
const messages_1 = require("../messages");
|
|
6
|
+
class UndefinedModuleException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(parentModule, index, scope) {
|
|
8
|
+
super((0, messages_1.UNDEFINED_MODULE_MESSAGE)(parentModule, index, scope));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UndefinedModuleException = UndefinedModuleException;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InjectorDependencyContext } from "../../injector/injector";
|
|
2
|
+
import { Module } from "../../injector/module/module";
|
|
3
|
+
import { RuntimeException } from "./runtime.exception";
|
|
4
|
+
export declare class UnknownDependenciesException extends RuntimeException {
|
|
5
|
+
readonly type: string | symbol;
|
|
6
|
+
readonly context: InjectorDependencyContext;
|
|
7
|
+
readonly metadata?: {
|
|
8
|
+
id: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
readonly moduleRef: {
|
|
11
|
+
id: string;
|
|
12
|
+
} | undefined;
|
|
13
|
+
constructor(type: string | symbol, context: InjectorDependencyContext, moduleRef: Module, metadata?: {
|
|
14
|
+
id: string;
|
|
15
|
+
} | undefined);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownDependenciesException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class UnknownDependenciesException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(type, context, moduleRef, metadata) {
|
|
8
|
+
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, context, moduleRef));
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.metadata = metadata;
|
|
12
|
+
this.moduleRef = moduleRef && { id: moduleRef.id };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.UnknownDependenciesException = UnknownDependenciesException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownElementException = void 0;
|
|
4
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
+
class UnknownElementException extends runtime_exception_1.RuntimeException {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
name = name && name.toString();
|
|
8
|
+
super(`Venok could not find ${name || "given"}
|
|
9
|
+
element (this provider does not exist in the current context)`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.UnknownElementException = UnknownElementException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownExportException = void 0;
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
6
|
+
class UnknownExportException extends runtime_exception_1.RuntimeException {
|
|
7
|
+
constructor(token, moduleName) {
|
|
8
|
+
super((0, messages_1.UNKNOWN_EXPORT_MESSAGE)(token, moduleName));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UnknownExportException = UnknownExportException;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownModuleException = void 0;
|
|
4
|
+
const runtime_exception_1 = require("./runtime.exception");
|
|
5
|
+
class UnknownModuleException extends runtime_exception_1.RuntimeException {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("Venok could not select the given module (it does not exist in current context)");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UnknownModuleException = UnknownModuleException;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InjectorDependencyContext } from "@venok/core/injector/injector";
|
|
2
|
+
import { ForwardReference } from "@venok/core/interfaces/modules";
|
|
3
|
+
import { Module } from "@venok/core/injector/module/module";
|
|
4
|
+
import { Type } from "@venok/core/interfaces";
|
|
5
|
+
export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, module: Module) => string;
|
|
6
|
+
export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
|
|
7
|
+
export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
|
|
8
|
+
export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
|
|
9
|
+
export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
|
|
10
|
+
export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol | undefined, module: string) => string;
|
|
11
|
+
export declare const INVALID_CLASS_MESSAGE: (text: TemplateStringsArray, value: any) => string;
|
|
12
|
+
export declare const INVALID_CLASS_SCOPE_MESSAGE: (text: TemplateStringsArray, name: string | undefined) => string;
|
|
13
|
+
export declare const UNHANDLED_RUNTIME_EXCEPTION = "Unhandled Runtime Exception.";
|
|
14
|
+
export declare const INVALID_EXCEPTION_FILTER = "Invalid exception filters (@UseFilters()).";
|
|
15
|
+
export declare const MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = "Unable to load @Venok/microservices package. (Please make sure that it's already installed.)";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
|
|
4
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
+
/**
|
|
6
|
+
* Returns the name of an instance or `undefined`
|
|
7
|
+
* @param instance The instance which should get the name from
|
|
8
|
+
*/
|
|
9
|
+
const getInstanceName = (instance) => {
|
|
10
|
+
if (instance?.forwardRef)
|
|
11
|
+
return instance.forwardRef()?.name;
|
|
12
|
+
if (instance?.module)
|
|
13
|
+
return instance.module?.name;
|
|
14
|
+
return instance?.name;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Returns the name of the dependency
|
|
18
|
+
* Tries to get the class name, otherwise the string value
|
|
19
|
+
* (= injection token). As fallback, it returns '+'
|
|
20
|
+
* @param dependency The name of the dependency to be displayed
|
|
21
|
+
*/
|
|
22
|
+
const getDependencyName = (dependency) =>
|
|
23
|
+
// use class name
|
|
24
|
+
getInstanceName(dependency) ||
|
|
25
|
+
// use injection token (symbol)
|
|
26
|
+
((0, shared_helper_1.isSymbol)(dependency) && dependency.toString()) ||
|
|
27
|
+
// use string directly
|
|
28
|
+
dependency ||
|
|
29
|
+
// otherwise
|
|
30
|
+
"+";
|
|
31
|
+
/**
|
|
32
|
+
* Returns the name of the module
|
|
33
|
+
* Tries to get the class name. As fallback, it returns 'current'.
|
|
34
|
+
* @param module The module which should get displayed
|
|
35
|
+
*/
|
|
36
|
+
const getModuleName = (module) => (module && getInstanceName(module.metatype)) || "current";
|
|
37
|
+
const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(" -> ");
|
|
38
|
+
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, module) => {
|
|
39
|
+
const { index, name = "dependency", dependencies, key } = unknownDependencyContext;
|
|
40
|
+
const moduleName = getModuleName(module);
|
|
41
|
+
const dependencyName = getDependencyName(name);
|
|
42
|
+
const potentialSolutions =
|
|
43
|
+
// If module's name is well-defined
|
|
44
|
+
moduleName !== "current"
|
|
45
|
+
? `\n
|
|
46
|
+
Potential solutions:
|
|
47
|
+
- Is ${moduleName} a valid Venok module?
|
|
48
|
+
- If ${dependencyName} is a provider, is it part of the current ${moduleName}?
|
|
49
|
+
- If ${dependencyName} is exported from a separate @Module, is that module imported within ${moduleName}?
|
|
50
|
+
@Module({
|
|
51
|
+
imports: [ /* the Module containing ${dependencyName} */ ]
|
|
52
|
+
})
|
|
53
|
+
`
|
|
54
|
+
: `\n
|
|
55
|
+
Potential solutions:
|
|
56
|
+
- If ${dependencyName} is a provider, is it part of the current Module?
|
|
57
|
+
- If ${dependencyName} is exported from a separate @Module, is that module imported within Module?
|
|
58
|
+
@Module({
|
|
59
|
+
imports: [ /* the Module containing ${dependencyName} */ ]
|
|
60
|
+
})
|
|
61
|
+
`;
|
|
62
|
+
let message = `Venok can't resolve dependencies of the ${type.toString()}`;
|
|
63
|
+
if ((0, shared_helper_1.isNull)(index) && key) {
|
|
64
|
+
message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
|
|
65
|
+
return message;
|
|
66
|
+
}
|
|
67
|
+
const dependenciesName = (dependencies || []).map(getDependencyName);
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
dependenciesName[index] = "?";
|
|
70
|
+
message += ` (`;
|
|
71
|
+
message += dependenciesName.join(", ");
|
|
72
|
+
message += `). Please make sure that the argument ${dependencyName} at index [${index}] is available in the ${moduleName} context.`;
|
|
73
|
+
message += potentialSolutions;
|
|
74
|
+
return message;
|
|
75
|
+
};
|
|
76
|
+
exports.UNKNOWN_DEPENDENCIES_MESSAGE = UNKNOWN_DEPENDENCIES_MESSAGE;
|
|
77
|
+
const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Venok cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
|
|
78
|
+
|
|
79
|
+
Scope [${stringifyScope(scope)}]
|
|
80
|
+
`;
|
|
81
|
+
exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
|
|
82
|
+
const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
83
|
+
const parentModuleName = parentModule?.name || "module";
|
|
84
|
+
return `Venok cannot create the ${parentModuleName} instance.
|
|
85
|
+
Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
|
|
86
|
+
|
|
87
|
+
Scope [${stringifyScope(scope)}]`;
|
|
88
|
+
};
|
|
89
|
+
exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
|
|
90
|
+
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
|
|
91
|
+
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"` || "that class";
|
|
92
|
+
return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
|
|
93
|
+
Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
|
|
94
|
+
|
|
95
|
+
Scope [${stringifyScope(scope)}]
|
|
96
|
+
`;
|
|
97
|
+
};
|
|
98
|
+
exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = USING_INVALID_CLASS_AS_A_MODULE_MESSAGE;
|
|
99
|
+
const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
|
|
100
|
+
const parentModuleName = parentModule?.name || "module";
|
|
101
|
+
return `Venok cannot create the ${parentModuleName} instance.
|
|
102
|
+
The module at index [${index}] of the ${parentModuleName} "imports" array is undefined.
|
|
103
|
+
|
|
104
|
+
Potential causes:
|
|
105
|
+
- A circular dependency between modules. Use forwardRef() to avoid it.
|
|
106
|
+
- The module at index [${index}] is of type "undefined". Check your import statements and the type of the module.
|
|
107
|
+
|
|
108
|
+
Scope [${stringifyScope(scope)}]`;
|
|
109
|
+
};
|
|
110
|
+
exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
|
|
111
|
+
const UNKNOWN_EXPORT_MESSAGE = (token = "item", module) => {
|
|
112
|
+
token = (0, shared_helper_1.isSymbol)(token) ? token.toString() : token;
|
|
113
|
+
return `Venok cannot export a provider/module that is not a part of the currently processed module (${module}). Please verify whether the exported ${token} is available in this particular context.
|
|
114
|
+
|
|
115
|
+
Possible Solutions:
|
|
116
|
+
- Is ${token} part of the relevant providers/imports within ${module}?
|
|
117
|
+
`;
|
|
118
|
+
};
|
|
119
|
+
exports.UNKNOWN_EXPORT_MESSAGE = UNKNOWN_EXPORT_MESSAGE;
|
|
120
|
+
const INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
|
|
121
|
+
exports.INVALID_CLASS_MESSAGE = INVALID_CLASS_MESSAGE;
|
|
122
|
+
const INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name || "This class"} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
|
|
123
|
+
exports.INVALID_CLASS_SCOPE_MESSAGE = INVALID_CLASS_SCOPE_MESSAGE;
|
|
124
|
+
exports.UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
|
|
125
|
+
exports.INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
|
|
126
|
+
exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @Venok/microservices package. (Please make sure that it's already installed.)`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VenokContainer } from "@venok/core/injector/container";
|
|
2
|
+
import { ApplicationConfig } from "@venok/core/application/config";
|
|
3
|
+
import { BaseExceptionFilterContext } from "@venok/core/exceptions/filter-context";
|
|
4
|
+
import { ExternalExceptionsHandler } from "@venok/core/exceptions/external/handler";
|
|
5
|
+
export declare class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
|
|
6
|
+
private readonly config?;
|
|
7
|
+
constructor(container: VenokContainer, config?: ApplicationConfig | undefined);
|
|
8
|
+
create(instance: object, callback: () => void, module: string, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): ExternalExceptionsHandler;
|
|
9
|
+
getGlobalMetadata<T extends any[]>(contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): T;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalExceptionFilterContext = void 0;
|
|
4
|
+
const filter_context_1 = require("@venok/core/exceptions/filter-context");
|
|
5
|
+
const constants_1 = require("@venok/core/injector/constants");
|
|
6
|
+
const constants_2 = require("@venok/core/constants");
|
|
7
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
8
|
+
const handler_1 = require("@venok/core/exceptions/external/handler");
|
|
9
|
+
class ExternalExceptionFilterContext extends filter_context_1.BaseExceptionFilterContext {
|
|
10
|
+
constructor(container, config) {
|
|
11
|
+
super(container);
|
|
12
|
+
this.config = config;
|
|
13
|
+
}
|
|
14
|
+
create(instance, callback, module, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
|
|
15
|
+
this.moduleContext = module;
|
|
16
|
+
const exceptionHandler = new handler_1.ExternalExceptionsHandler();
|
|
17
|
+
const filters = this.createContext(instance, callback, constants_2.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
|
|
18
|
+
if ((0, shared_helper_1.isEmpty)(filters))
|
|
19
|
+
return exceptionHandler;
|
|
20
|
+
exceptionHandler.setCustomFilters(filters.reverse());
|
|
21
|
+
return exceptionHandler;
|
|
22
|
+
}
|
|
23
|
+
getGlobalMetadata(contextId = constants_1.STATIC_CONTEXT, inquirerId) {
|
|
24
|
+
if (!this.config)
|
|
25
|
+
return [];
|
|
26
|
+
const globalFilters = this.config.getGlobalFilters();
|
|
27
|
+
if (contextId === constants_1.STATIC_CONTEXT && !inquirerId)
|
|
28
|
+
return globalFilters;
|
|
29
|
+
const scopedFilterWrappers = this.config.getGlobalRequestFilters();
|
|
30
|
+
const scopedFilters = scopedFilterWrappers
|
|
31
|
+
.map((wrapper) => wrapper.getInstanceByContextId(contextId, inquirerId))
|
|
32
|
+
.filter((host) => !!host)
|
|
33
|
+
.map((host) => host.instance);
|
|
34
|
+
return globalFilters.concat(scopedFilters);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ExternalExceptionFilterContext = ExternalExceptionFilterContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalExceptionFilter = void 0;
|
|
4
|
+
const logger_service_1 = require("@venok/core/services/logger.service");
|
|
5
|
+
const exceptions_1 = require("@venok/core/errors/exceptions");
|
|
6
|
+
class ExternalExceptionFilter {
|
|
7
|
+
catch(exception, host) {
|
|
8
|
+
if (exception instanceof exceptions_1.RuntimeException) {
|
|
9
|
+
return ExternalExceptionFilter.logger.error(exception.what(), exception.stack);
|
|
10
|
+
}
|
|
11
|
+
if (exception instanceof Error)
|
|
12
|
+
return ExternalExceptionFilter.logger.error(exception.message, exception.stack);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ExternalExceptionFilter = ExternalExceptionFilter;
|
|
16
|
+
ExternalExceptionFilter.logger = new logger_service_1.Logger("ExternalExceptionsHandler");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExternalExceptionFilter } from "@venok/core/exceptions/external/filter";
|
|
2
|
+
import { ArgumentsHost } from "@venok/core/interfaces/context/arguments-host.interface";
|
|
3
|
+
import { ExceptionFilterMetadata } from "@venok/core/interfaces/features/exception-filter.interface";
|
|
4
|
+
export declare class ExternalExceptionsHandler extends ExternalExceptionFilter {
|
|
5
|
+
private filters;
|
|
6
|
+
next(exception: Error | any, host: ArgumentsHost): void | Promise<any>;
|
|
7
|
+
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
|
|
8
|
+
invokeCustomFilters<T = any>(exception: T, host: ArgumentsHost): Promise<any> | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalExceptionsHandler = void 0;
|
|
4
|
+
const filter_1 = require("@venok/core/exceptions/external/filter");
|
|
5
|
+
const invalid_exception_filter_exception_1 = require("@venok/core/errors/exceptions/invalid-exception-filter.exception");
|
|
6
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
7
|
+
const select_exception_filter_metadata_1 = require("@venok/core/exceptions/select-exception-filter-metadata");
|
|
8
|
+
class ExternalExceptionsHandler extends filter_1.ExternalExceptionFilter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.filters = [];
|
|
12
|
+
}
|
|
13
|
+
next(exception, host) {
|
|
14
|
+
const result = this.invokeCustomFilters(exception, host);
|
|
15
|
+
if (result)
|
|
16
|
+
return result;
|
|
17
|
+
return super.catch(exception, host);
|
|
18
|
+
}
|
|
19
|
+
setCustomFilters(filters) {
|
|
20
|
+
if (!Array.isArray(filters))
|
|
21
|
+
throw new invalid_exception_filter_exception_1.InvalidExceptionFilterException();
|
|
22
|
+
this.filters = filters;
|
|
23
|
+
}
|
|
24
|
+
invokeCustomFilters(exception, host) {
|
|
25
|
+
if ((0, shared_helper_1.isEmpty)(this.filters))
|
|
26
|
+
return null;
|
|
27
|
+
const filter = (0, select_exception_filter_metadata_1.selectExceptionFilterMetadata)(this.filters, exception);
|
|
28
|
+
return filter ? filter.func(exception, host) : null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ExternalExceptionsHandler = ExternalExceptionsHandler;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VenokContainer } from "@venok/core/injector/container";
|
|
2
|
+
import { ContextCreator } from "@venok/core/context/creator";
|
|
3
|
+
import { Type } from "@venok/core/interfaces";
|
|
4
|
+
import { InstanceWrapper } from "@venok/core/injector/instance/wrapper";
|
|
5
|
+
import { ExceptionFilter } from "@venok/core/interfaces/features/exception-filter.interface";
|
|
6
|
+
export declare class BaseExceptionFilterContext extends ContextCreator {
|
|
7
|
+
private readonly container;
|
|
8
|
+
protected moduleContext: string;
|
|
9
|
+
constructor(container: VenokContainer);
|
|
10
|
+
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): R;
|
|
11
|
+
getFilterInstance(filter: Function | ExceptionFilter, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): ExceptionFilter | null;
|
|
12
|
+
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
|
|
13
|
+
reflectCatchExceptions(instance: ExceptionFilter): Type<any>[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseExceptionFilterContext = void 0;
|
|
4
|
+
const creator_1 = require("@venok/core/context/creator");
|
|
5
|
+
const constants_1 = require("@venok/core/injector/constants");
|
|
6
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
7
|
+
const constants_2 = require("@venok/core/constants");
|
|
8
|
+
class BaseExceptionFilterContext extends creator_1.ContextCreator {
|
|
9
|
+
constructor(container) {
|
|
10
|
+
super();
|
|
11
|
+
this.container = container;
|
|
12
|
+
}
|
|
13
|
+
createConcreteContext(metadata, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
|
|
14
|
+
if ((0, shared_helper_1.isEmpty)(metadata)) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
return metadata
|
|
18
|
+
.filter((instance) => instance && ((0, shared_helper_1.isFunction)(instance.catch) || instance.name))
|
|
19
|
+
.map((filter) => this.getFilterInstance(filter, contextId, inquirerId))
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.map((instance) => ({
|
|
22
|
+
func: instance.catch.bind(instance),
|
|
23
|
+
exceptionMetatypes: this.reflectCatchExceptions(instance),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
getFilterInstance(filter, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
|
|
27
|
+
const isObject = filter.catch;
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
if (isObject) {
|
|
30
|
+
return filter;
|
|
31
|
+
}
|
|
32
|
+
const instanceWrapper = this.getInstanceByMetatype(filter);
|
|
33
|
+
if (!instanceWrapper) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const instanceHost = instanceWrapper.getInstanceByContextId(this.getContextId(contextId, instanceWrapper), inquirerId);
|
|
37
|
+
return instanceHost && instanceHost.instance;
|
|
38
|
+
}
|
|
39
|
+
getInstanceByMetatype(metatype) {
|
|
40
|
+
if (!this.moduleContext) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const collection = this.container.getModules();
|
|
44
|
+
const moduleRef = collection.get(this.moduleContext);
|
|
45
|
+
if (!moduleRef) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
return moduleRef.injectables.get(metatype);
|
|
49
|
+
}
|
|
50
|
+
reflectCatchExceptions(instance) {
|
|
51
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
52
|
+
return Reflect.getMetadata(constants_2.FILTER_CATCH_EXCEPTIONS, prototype.constructor) || [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.BaseExceptionFilterContext = BaseExceptionFilterContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectExceptionFilterMetadata = void 0;
|
|
4
|
+
const selectExceptionFilterMetadata = (filters, exception) => filters.find(({ exceptionMetatypes }) => !exceptionMetatypes.length ||
|
|
5
|
+
exceptionMetatypes.some((ExceptionMetaType) => exception instanceof ExceptionMetaType));
|
|
6
|
+
exports.selectExceptionFilterMetadata = selectExceptionFilterMetadata;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionHandler = void 0;
|
|
4
|
+
const logger_service_1 = require("@venok/core/services/logger.service");
|
|
5
|
+
const exceptions_1 = require("@venok/core/errors/exceptions");
|
|
6
|
+
class ExceptionHandler {
|
|
7
|
+
handle(exception) {
|
|
8
|
+
if (!(exception instanceof exceptions_1.RuntimeException)) {
|
|
9
|
+
return ExceptionHandler.logger.error(exception.message, exception.stack);
|
|
10
|
+
}
|
|
11
|
+
return ExceptionHandler.logger.error(exception.what(), exception.stack);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ExceptionHandler = ExceptionHandler;
|
|
15
|
+
ExceptionHandler.logger = new logger_service_1.Logger(ExceptionHandler.name);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare class ExceptionsZone {
|
|
2
|
+
private static readonly exceptionHandler;
|
|
3
|
+
static run(callback: () => void, teardown?: (err: any) => void, autoFlushLogs?: boolean): void;
|
|
4
|
+
static asyncRun(callback: () => Promise<void>, teardown?: (err: any) => void, autoFlushLogs?: boolean): Promise<void>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExceptionsZone = void 0;
|
|
4
|
+
const handler_1 = require("@venok/core/exceptions/zone/handler");
|
|
5
|
+
const logger_service_1 = require("@venok/core/services/logger.service");
|
|
6
|
+
const DEFAULT_TEARDOWN = () => process.exit(1);
|
|
7
|
+
class ExceptionsZone {
|
|
8
|
+
static run(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
|
|
9
|
+
try {
|
|
10
|
+
callback();
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
this.exceptionHandler.handle(e);
|
|
14
|
+
if (autoFlushLogs)
|
|
15
|
+
logger_service_1.Logger.flush();
|
|
16
|
+
teardown(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
static async asyncRun(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
|
|
20
|
+
try {
|
|
21
|
+
await callback();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
this.exceptionHandler.handle(e);
|
|
25
|
+
if (autoFlushLogs)
|
|
26
|
+
logger_service_1.Logger.flush();
|
|
27
|
+
teardown(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ExceptionsZone = ExceptionsZone;
|
|
32
|
+
ExceptionsZone.exceptionHandler = new handler_1.ExceptionHandler();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContextType } from "@venok/core/interfaces/context/arguments-host.interface";
|
|
2
|
+
import { ExecutionContextHost } from "@venok/core/context/execution-host";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { CanActivate } from "@venok/core/interfaces/features/guards.interface";
|
|
5
|
+
export declare class GuardsConsumer {
|
|
6
|
+
tryActivate<TContext extends string = ContextType>(guards: CanActivate[], args: unknown[], instance: object, callback: (...args: unknown[]) => unknown, type?: TContext): Promise<boolean>;
|
|
7
|
+
createContext(args: unknown[], instance: object, callback: (...args: unknown[]) => unknown): ExecutionContextHost;
|
|
8
|
+
pickResult(result: boolean | Promise<boolean> | Observable<boolean>): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuardsConsumer = void 0;
|
|
4
|
+
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
+
const execution_host_1 = require("@venok/core/context/execution-host");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
class GuardsConsumer {
|
|
8
|
+
async tryActivate(guards, args, instance, callback, type) {
|
|
9
|
+
if (!guards || (0, shared_helper_1.isEmpty)(guards)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const context = this.createContext(args, instance, callback);
|
|
13
|
+
context.setType(type);
|
|
14
|
+
for (const guard of guards) {
|
|
15
|
+
const result = guard.canActivate(context);
|
|
16
|
+
if (await this.pickResult(result)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
createContext(args, instance, callback) {
|
|
24
|
+
return new execution_host_1.ExecutionContextHost(args, instance.constructor, callback);
|
|
25
|
+
}
|
|
26
|
+
async pickResult(result) {
|
|
27
|
+
if (result instanceof rxjs_1.Observable) {
|
|
28
|
+
return (0, rxjs_1.lastValueFrom)(result);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GuardsConsumer = GuardsConsumer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { VenokContainer } from "@venok/core/injector/container";
|
|
2
|
+
import { ApplicationConfig } from "@venok/core/application/config";
|
|
3
|
+
import { ContextCreator } from "@venok/core/context/creator";
|
|
4
|
+
import { CanActivate } from "@venok/core/interfaces/features/guards.interface";
|
|
5
|
+
import { Type } from "@venok/core/interfaces";
|
|
6
|
+
import { InstanceWrapper } from "@venok/core/injector/instance/wrapper";
|
|
7
|
+
export declare class GuardsContextCreator extends ContextCreator {
|
|
8
|
+
private readonly container;
|
|
9
|
+
private readonly config?;
|
|
10
|
+
private moduleContext;
|
|
11
|
+
constructor(container: VenokContainer, config?: ApplicationConfig | undefined);
|
|
12
|
+
create(instance: object, callback: (...args: unknown[]) => unknown, module: string, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): CanActivate[];
|
|
13
|
+
createConcreteContext<T extends unknown[], R extends unknown[]>(metadata: T, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): R;
|
|
14
|
+
getGuardInstance(metatype: Function | CanActivate, contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): CanActivate | null;
|
|
15
|
+
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
|
|
16
|
+
getGlobalMetadata<T extends unknown[]>(contextId?: import("@venok/core/injector/instance/wrapper").ContextId, inquirerId?: string): T;
|
|
17
|
+
}
|