@venok/core 1.1.0 → 2.0.1-next.1
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/dist/application/config.js +92 -0
- package/dist/application/context.js +252 -0
- package/dist/application/factory.js +136 -0
- package/dist/constants.js +100 -0
- package/dist/context/context-id.factory.js +58 -0
- package/dist/context/context.js +186 -0
- package/dist/context/creator.js +49 -0
- package/dist/context/execution-host.js +51 -0
- package/dist/context/proxy.js +43 -0
- package/dist/decorators/apply.decorator.js +33 -0
- package/dist/decorators/bind.decorator.js +28 -0
- package/dist/decorators/catch.decorator.js +29 -0
- package/dist/decorators/dependencies.decorator.js +30 -0
- package/dist/decorators/exception-filters.decorator.js +40 -0
- package/dist/decorators/global.decorator.js +28 -0
- package/dist/decorators/inject.decorator.js +42 -0
- package/dist/decorators/injectable.decorator.js +38 -0
- package/dist/decorators/module.decorator.js +42 -0
- package/dist/decorators/optional.decorator.js +35 -0
- package/dist/decorators/set-metadata.decorator.js +35 -0
- package/dist/decorators/use-guards.decorator.js +39 -0
- package/dist/decorators/use-interceptors.decorator.js +39 -0
- package/dist/decorators/use-pipes.decorator.js +38 -0
- package/dist/enums/scope.enum.js +28 -0
- package/dist/enums/shutdown-signal.enum.js +36 -0
- package/dist/errors/exceptions/circular-dependency.exception.js +30 -0
- package/dist/errors/exceptions/invalid-class-module.exception.js +30 -0
- package/dist/errors/exceptions/invalid-class-scope.exception.js +33 -0
- package/dist/errors/exceptions/invalid-class.exception.js +30 -0
- package/dist/errors/exceptions/invalid-exception-filter.exception.js +30 -0
- package/dist/errors/exceptions/invalid-module.exception.js +30 -0
- package/dist/errors/exceptions/runtime.exception.js +30 -0
- package/dist/errors/exceptions/undefined-dependency.exception.js +30 -0
- package/dist/errors/exceptions/undefined-forwardref.exception.js +30 -0
- package/dist/errors/exceptions/undefined-module.exception.js +30 -0
- package/dist/errors/exceptions/unknown-dependencies.exception.js +38 -0
- package/dist/errors/exceptions/unknown-element.exception.js +31 -0
- package/dist/errors/exceptions/unknown-export.exception.js +30 -0
- package/dist/errors/exceptions/unknown-module.exception.js +29 -0
- package/dist/errors/messages.js +134 -0
- package/dist/exceptions/handler.js +53 -0
- package/dist/exceptions/zone/handler.js +30 -0
- package/dist/exceptions/zone/zone.js +49 -0
- package/dist/filters/context-creator.js +65 -0
- package/dist/filters/context.js +58 -0
- package/dist/filters/filter.js +36 -0
- package/dist/guards/consumer.js +54 -0
- package/dist/guards/context-creator.js +76 -0
- package/dist/helpers/color.helper.js +35 -0
- package/dist/helpers/context-id-factory.helper.js +25 -0
- package/dist/helpers/context.helper.js +65 -0
- package/dist/helpers/create-param-decorator.helper.js +73 -0
- package/dist/helpers/filter-log-levels.util.js +38 -0
- package/dist/helpers/flatten.helper.js +26 -0
- package/dist/helpers/is-log-level-enabled.util.js +39 -0
- package/dist/helpers/is-log-level.util.js +26 -0
- package/dist/helpers/messages.helper.js +23 -0
- package/dist/helpers/metadata.helper.js +51 -0
- package/dist/helpers/noop.helper.js +23 -0
- package/dist/helpers/random-string-generator.helper.js +24 -0
- package/dist/helpers/rethrow.helper.js +25 -0
- package/dist/helpers/shared.helper.js +49 -0
- package/dist/helpers/silent.helper.js +34 -0
- package/dist/helpers/transient.helper.js +30 -0
- package/dist/helpers/uuid.helper.js +60 -0
- package/dist/helpers/validate-each.helper.js +42 -0
- package/dist/hooks/before-app-shutdown.hook.js +43 -0
- package/dist/hooks/on-app-bootstrap.hook.js +43 -0
- package/dist/hooks/on-app-shutdown.hook.js +43 -0
- package/dist/hooks/on-module-destroy.hook.js +43 -0
- package/dist/hooks/on-module-init.hook.js +43 -0
- package/dist/index.d.ts +3141 -0
- package/dist/index.js +117 -0
- package/dist/injector/constants.js +28 -0
- package/dist/injector/container.js +229 -0
- package/dist/injector/helpers/barrier.js +48 -0
- package/dist/injector/helpers/class-scope.helper.js +27 -0
- package/dist/injector/helpers/classifier.helper.js +35 -0
- package/dist/injector/helpers/is-durable.helper.js +27 -0
- package/dist/injector/injector.js +490 -0
- package/dist/injector/instance/links-host.js +68 -0
- package/dist/injector/instance/loader.js +95 -0
- package/dist/injector/instance/resolver.js +61 -0
- package/dist/injector/instance/wrapper.js +324 -0
- package/dist/injector/internal-core-module/core-providers.js +42 -0
- package/dist/injector/internal-core-module/internal-core-module-factory.js +66 -0
- package/dist/injector/internal-core-module/internal-core-module.js +46 -0
- package/dist/injector/module/compiler.js +47 -0
- package/dist/injector/module/container.js +33 -0
- package/dist/injector/module/lazy/loader.js +71 -0
- package/dist/injector/module/module.js +395 -0
- package/dist/injector/module/ref.js +78 -0
- package/dist/injector/module/token-factory.js +82 -0
- package/dist/injector/settlement-signal.js +50 -0
- package/dist/injector/topology-tree/topology-tree.js +68 -0
- package/dist/injector/topology-tree/tree-node.js +68 -0
- package/dist/inspector/graph-inspector.js +182 -0
- package/dist/inspector/initialize-on-preview.allowlist.js +31 -0
- package/dist/inspector/noop-graph-inspector.js +27 -0
- package/dist/inspector/partial-graph.host.js +34 -0
- package/dist/inspector/serialized-graph.js +128 -0
- package/dist/interceptors/consumer.js +54 -0
- package/dist/interceptors/context-creator.js +75 -0
- package/dist/interfaces/application/context-options.interface.js +31 -0
- package/dist/interfaces/application/context.interface.js +0 -0
- package/dist/interfaces/application/index.js +3 -0
- package/dist/interfaces/context/arguments-host.interface.js +0 -0
- package/dist/interfaces/context/context-id-factory.interface.js +0 -0
- package/dist/interfaces/context/context.interface.js +0 -0
- package/dist/interfaces/context/creator.interface.js +0 -0
- package/dist/interfaces/context/execution.interface.js +0 -0
- package/dist/interfaces/context/index.js +7 -0
- package/dist/interfaces/context/params.interface.js +0 -0
- package/dist/interfaces/features/exception-filter.interface.js +0 -0
- package/dist/interfaces/features/guards.interface.js +0 -0
- package/dist/interfaces/features/index.js +5 -0
- package/dist/interfaces/features/interceptor.interface.js +0 -0
- package/dist/interfaces/features/pipes.interface.js +0 -0
- package/dist/interfaces/helper.interface.js +0 -0
- package/dist/interfaces/hooks/before-application-shutdown.interface.js +0 -0
- package/dist/interfaces/hooks/index.js +6 -0
- package/dist/interfaces/hooks/on-application-bootstrap.interface.js +0 -0
- package/dist/interfaces/hooks/on-application-shutdown.interface.js +0 -0
- package/dist/interfaces/hooks/on-destroy.interface.js +0 -0
- package/dist/interfaces/hooks/on-init.interface.js +0 -0
- package/dist/interfaces/index.js +16 -0
- package/dist/interfaces/injectable.interface.js +0 -0
- package/dist/interfaces/injector/index.js +6 -0
- package/dist/interfaces/injector/injector.interface.js +0 -0
- package/dist/interfaces/injector/instance-wrapper.interface.js +0 -0
- package/dist/interfaces/injector/lazy-module-options.interface.js +0 -0
- package/dist/interfaces/injector/module-compiler.interface.js +0 -0
- package/dist/interfaces/injector/module-ref.interface.js +0 -0
- package/dist/interfaces/inspector/edge.interface.js +0 -0
- package/dist/interfaces/inspector/enhancer-metadata-cache-entry.interface.js +0 -0
- package/dist/interfaces/inspector/entrypoint.interface.js +0 -0
- package/dist/interfaces/inspector/extras.interface.js +0 -0
- package/dist/interfaces/inspector/index.js +8 -0
- package/dist/interfaces/inspector/node.interface.js +0 -0
- package/dist/interfaces/inspector/serialized-graph-json.interface.js +0 -0
- package/dist/interfaces/inspector/serialized-graph-metadata.interface.js +0 -0
- package/dist/interfaces/modules/definition.interface.js +0 -0
- package/dist/interfaces/modules/dynamic-module.interface.js +0 -0
- package/dist/interfaces/modules/forward-reference.interface.js +0 -0
- package/dist/interfaces/modules/index.js +10 -0
- package/dist/interfaces/modules/injection-token.interface.js +0 -0
- package/dist/interfaces/modules/introspection-result.interface.js +0 -0
- package/dist/interfaces/modules/module-metadata.interface.js +0 -0
- package/dist/interfaces/modules/module.interface.js +0 -0
- package/dist/interfaces/modules/optional-factory-dependency.interface.js +0 -0
- package/dist/interfaces/modules/override.interface.js +0 -0
- package/dist/interfaces/modules/provider.interface.js +0 -0
- package/dist/interfaces/param-decorator.interface.js +0 -0
- package/dist/interfaces/scope.interface.js +0 -0
- package/dist/interfaces/services/console.interface.js +0 -0
- package/dist/interfaces/services/index.js +4 -0
- package/dist/interfaces/services/logger.interface.js +0 -0
- package/dist/interfaces/services/reflector.interface.js +0 -0
- package/dist/interfaces/set-metadata.interface.js +0 -0
- package/dist/interfaces/type.interface.js +0 -0
- package/dist/metadata-scanner.js +50 -0
- package/dist/pipes/consumer.js +33 -0
- package/dist/pipes/context-creator.js +78 -0
- package/dist/scanner.js +371 -0
- package/dist/services/console.service.js +347 -0
- package/dist/services/logger.service.js +276 -0
- package/dist/services/reflector.service.js +82 -0
- package/dist/storage/handler-metadata.storage.js +42 -0
- package/dist/storage/meta-host.storage.js +62 -0
- package/package.json +52 -40
- package/application/config.d.ts +0 -35
- package/application/config.js +0 -85
- package/application/context.d.ts +0 -198
- package/application/context.js +0 -325
- package/application/factory.d.ts +0 -43
- package/application/factory.js +0 -147
- package/constants.d.ts +0 -44
- package/constants.js +0 -51
- package/context/context.d.ts +0 -66
- package/context/context.js +0 -156
- package/context/creator.d.ts +0 -9
- package/context/creator.js +0 -32
- package/context/execution-host.d.ts +0 -16
- package/context/execution-host.js +0 -30
- package/context/index.d.ts +0 -4
- package/context/index.js +0 -20
- package/context/proxy.d.ts +0 -6
- package/context/proxy.js +0 -33
- package/decorators/apply.decorator.d.ts +0 -10
- package/decorators/apply.decorator.js +0 -24
- package/decorators/bind.decorator.d.ts +0 -11
- package/decorators/bind.decorator.js +0 -20
- package/decorators/catch.decorator.d.ts +0 -17
- package/decorators/catch.decorator.js +0 -26
- package/decorators/create-param.decorator.d.ts +0 -29
- package/decorators/create-param.decorator.js +0 -51
- package/decorators/dependencies.decorator.d.ts +0 -6
- package/decorators/dependencies.decorator.js +0 -17
- package/decorators/exception-filters.decorator.d.ts +0 -21
- package/decorators/exception-filters.decorator.js +0 -41
- package/decorators/global.decorator.d.ts +0 -10
- package/decorators/global.decorator.js +0 -19
- package/decorators/index.d.ts +0 -15
- package/decorators/index.js +0 -31
- package/decorators/inject.decorator.d.ts +0 -26
- package/decorators/inject.decorator.js +0 -45
- package/decorators/injectable.decorator.d.ts +0 -40
- package/decorators/injectable.decorator.js +0 -51
- package/decorators/module.decorator.d.ts +0 -14
- package/decorators/module.decorator.js +0 -38
- package/decorators/optional.decorator.d.ts +0 -14
- package/decorators/optional.decorator.js +0 -30
- package/decorators/set-metadata.decorator.d.ts +0 -18
- package/decorators/set-metadata.decorator.js +0 -30
- package/decorators/use-guards.decorator.d.ts +0 -21
- package/decorators/use-guards.decorator.js +0 -40
- package/decorators/use-interceptors.decorator.d.ts +0 -21
- package/decorators/use-interceptors.decorator.js +0 -40
- package/decorators/use-pipes.decorator.d.ts +0 -21
- package/decorators/use-pipes.decorator.js +0 -39
- package/discovery/meta-host-collection.d.ts +0 -32
- package/discovery/meta-host-collection.js +0 -79
- package/discovery/module.d.ts +0 -5
- package/discovery/module.js +0 -24
- package/discovery/service.d.ts +0 -68
- package/discovery/service.js +0 -90
- package/errors/exceptions/circular-dependency.exception.d.ts +0 -4
- package/errors/exceptions/circular-dependency.exception.js +0 -11
- package/errors/exceptions/index.d.ts +0 -8
- package/errors/exceptions/index.js +0 -24
- package/errors/exceptions/invalid-class-module.exception.d.ts +0 -4
- package/errors/exceptions/invalid-class-module.exception.js +0 -11
- package/errors/exceptions/invalid-class-scope.exception.d.ts +0 -5
- package/errors/exceptions/invalid-class-scope.exception.js +0 -14
- package/errors/exceptions/invalid-class.exception.d.ts +0 -4
- package/errors/exceptions/invalid-class.exception.js +0 -11
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +0 -4
- package/errors/exceptions/invalid-exception-filter.exception.js +0 -11
- package/errors/exceptions/invalid-module.exception.d.ts +0 -4
- package/errors/exceptions/invalid-module.exception.js +0 -11
- package/errors/exceptions/runtime.exception.d.ts +0 -4
- package/errors/exceptions/runtime.exception.js +0 -12
- package/errors/exceptions/undefined-dependency.exception.d.ts +0 -6
- package/errors/exceptions/undefined-dependency.exception.js +0 -11
- package/errors/exceptions/undefined-forwardref.exception.d.ts +0 -5
- package/errors/exceptions/undefined-forwardref.exception.js +0 -11
- package/errors/exceptions/undefined-module.exception.d.ts +0 -4
- package/errors/exceptions/undefined-module.exception.js +0 -11
- package/errors/exceptions/unknown-dependencies.exception.d.ts +0 -16
- package/errors/exceptions/unknown-dependencies.exception.js +0 -15
- package/errors/exceptions/unknown-element.exception.d.ts +0 -4
- package/errors/exceptions/unknown-element.exception.js +0 -12
- package/errors/exceptions/unknown-export.exception.d.ts +0 -4
- package/errors/exceptions/unknown-export.exception.js +0 -11
- package/errors/exceptions/unknown-module.exception.d.ts +0 -4
- package/errors/exceptions/unknown-module.exception.js +0 -10
- package/errors/messages.d.ts +0 -15
- package/errors/messages.js +0 -126
- package/exceptions/handler.d.ts +0 -10
- package/exceptions/handler.js +0 -34
- package/exceptions/index.d.ts +0 -2
- package/exceptions/index.js +0 -18
- package/exceptions/zone/handler.d.ts +0 -5
- package/exceptions/zone/handler.js +0 -15
- package/exceptions/zone/index.d.ts +0 -2
- package/exceptions/zone/index.js +0 -18
- package/exceptions/zone/zone.d.ts +0 -5
- package/exceptions/zone/zone.js +0 -32
- package/filters/context-creator.d.ts +0 -14
- package/filters/context-creator.js +0 -48
- package/filters/context.d.ts +0 -12
- package/filters/context.js +0 -41
- package/filters/filter.d.ts +0 -6
- package/filters/filter.js +0 -16
- package/filters/index.d.ts +0 -3
- package/filters/index.js +0 -19
- package/guards/consumer.d.ts +0 -9
- package/guards/consumer.js +0 -33
- package/guards/context-creator.d.ts +0 -17
- package/guards/context-creator.js +0 -69
- package/guards/index.d.ts +0 -2
- package/guards/index.js +0 -18
- package/helpers/color.helper.d.ts +0 -9
- package/helpers/color.helper.js +0 -14
- package/helpers/context-id-factory.helper.d.ts +0 -2
- package/helpers/context-id-factory.helper.js +0 -15
- package/helpers/context.helper.d.ts +0 -23
- package/helpers/context.helper.js +0 -49
- package/helpers/extends-metadata.helper.d.ts +0 -1
- package/helpers/extends-metadata.helper.js +0 -9
- package/helpers/flatten.helper.d.ts +0 -1
- package/helpers/flatten.helper.js +0 -9
- package/helpers/messages.helper.d.ts +0 -2
- package/helpers/messages.helper.js +0 -7
- package/helpers/noop.helper.d.ts +0 -1
- package/helpers/noop.helper.js +0 -5
- package/helpers/random-string-generator.helper.d.ts +0 -1
- package/helpers/random-string-generator.helper.js +0 -6
- package/helpers/rethrow.helper.d.ts +0 -1
- package/helpers/rethrow.helper.js +0 -7
- package/helpers/shared.helper.d.ts +0 -10
- package/helpers/shared.helper.js +0 -33
- package/helpers/silent.helper.d.ts +0 -10
- package/helpers/silent.helper.js +0 -18
- package/helpers/transient.helper.d.ts +0 -12
- package/helpers/transient.helper.js +0 -26
- package/helpers/uuid.helper.d.ts +0 -15
- package/helpers/uuid.helper.js +0 -54
- package/helpers/validate-each.helper.d.ts +0 -8
- package/helpers/validate-each.helper.js +0 -25
- package/hooks/before-app-shutdown.hook.d.ts +0 -9
- package/hooks/before-app-shutdown.hook.js +0 -45
- package/hooks/index.d.ts +0 -5
- package/hooks/index.js +0 -21
- package/hooks/on-app-bootstrap.hook.d.ts +0 -8
- package/hooks/on-app-bootstrap.hook.js +0 -45
- package/hooks/on-app-shutdown.hook.d.ts +0 -9
- package/hooks/on-app-shutdown.hook.js +0 -46
- package/hooks/on-module-destroy.hook.d.ts +0 -8
- package/hooks/on-module-destroy.hook.js +0 -45
- package/hooks/on-module-init.hook.d.ts +0 -8
- package/hooks/on-module-init.hook.js +0 -45
- package/index.d.ts +0 -10
- package/index.js +0 -32
- package/injector/constants.d.ts +0 -2
- package/injector/constants.js +0 -7
- package/injector/container.d.ts +0 -61
- package/injector/container.js +0 -194
- package/injector/helpers/class-scope.helper.d.ts +0 -2
- package/injector/helpers/class-scope.helper.js +0 -9
- package/injector/helpers/classifier.helper.d.ts +0 -4
- package/injector/helpers/classifier.helper.js +0 -17
- package/injector/helpers/is-durable.helper.d.ts +0 -2
- package/injector/helpers/is-durable.helper.js +0 -9
- package/injector/index.d.ts +0 -5
- package/injector/index.js +0 -20
- package/injector/injector.d.ts +0 -87
- package/injector/injector.js +0 -452
- package/injector/instance/links-host.d.ts +0 -22
- package/injector/instance/links-host.js +0 -50
- package/injector/instance/loader.d.ts +0 -21
- package/injector/instance/loader.js +0 -73
- package/injector/instance/resolver.d.ts +0 -16
- package/injector/instance/resolver.js +0 -43
- package/injector/instance/wrapper.d.ts +0 -90
- package/injector/instance/wrapper.js +0 -272
- package/injector/internal-core-module/core-providers.d.ts +0 -4
- package/injector/internal-core-module/core-providers.js +0 -21
- package/injector/internal-core-module/internal-core-module-factory.d.ts +0 -8
- package/injector/internal-core-module/internal-core-module-factory.js +0 -47
- package/injector/internal-core-module/internal-core-module.d.ts +0 -4
- package/injector/internal-core-module/internal-core-module.js +0 -31
- package/injector/module/compiler.d.ts +0 -19
- package/injector/module/compiler.js +0 -27
- package/injector/module/container.d.ts +0 -6
- package/injector/module/container.js +0 -24
- package/injector/module/lazy/loader.d.ts +0 -21
- package/injector/module/lazy/loader.js +0 -49
- package/injector/module/lazy/options.d.ts +0 -6
- package/injector/module/lazy/options.js +0 -2
- package/injector/module/module.d.ts +0 -74
- package/injector/module/module.js +0 -383
- package/injector/module/ref.d.ts +0 -106
- package/injector/module/ref.js +0 -62
- package/injector/module/token-factory.d.ts +0 -13
- package/injector/module/token-factory.js +0 -71
- package/injector/settlement-signal.d.ts +0 -37
- package/injector/settlement-signal.js +0 -55
- package/inspector/graph-inspector.d.ts +0 -26
- package/inspector/graph-inspector.js +0 -163
- package/inspector/initialize-on-preview.allowlist.d.ts +0 -6
- package/inspector/initialize-on-preview.allowlist.js +0 -13
- package/inspector/interfaces/edge.interface.d.ts +0 -28
- package/inspector/interfaces/edge.interface.js +0 -2
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +0 -12
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +0 -2
- package/inspector/interfaces/entrypoint.interface.d.ts +0 -10
- package/inspector/interfaces/entrypoint.interface.js +0 -2
- package/inspector/interfaces/extras.interface.d.ts +0 -18
- package/inspector/interfaces/extras.interface.js +0 -2
- package/inspector/interfaces/node.interface.d.ts +0 -49
- package/inspector/interfaces/node.interface.js +0 -2
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +0 -14
- package/inspector/interfaces/serialized-graph-json.interface.js +0 -2
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +0 -10
- package/inspector/interfaces/serialized-graph-metadata.interface.js +0 -2
- package/inspector/noop-graph-inspector.d.ts +0 -2
- package/inspector/noop-graph-inspector.js +0 -8
- package/inspector/partial-graph.host.d.ts +0 -7
- package/inspector/partial-graph.host.js +0 -15
- package/inspector/serialized-graph.d.ts +0 -52
- package/inspector/serialized-graph.js +0 -121
- package/interceptors/consumer.d.ts +0 -9
- package/interceptors/consumer.js +0 -37
- package/interceptors/context-creator.d.ts +0 -17
- package/interceptors/context-creator.js +0 -67
- package/interceptors/index.d.ts +0 -2
- package/interceptors/index.js +0 -18
- package/interfaces/abstract.interface.d.ts +0 -3
- package/interfaces/abstract.interface.js +0 -2
- package/interfaces/application/context-options.interface.d.ts +0 -41
- package/interfaces/application/context-options.interface.js +0 -9
- package/interfaces/application/context.interface.d.ts +0 -162
- package/interfaces/application/context.interface.js +0 -2
- package/interfaces/application/index.d.ts +0 -1
- package/interfaces/application/index.js +0 -17
- package/interfaces/context/arguments-host.interface.d.ts +0 -22
- package/interfaces/context/arguments-host.interface.js +0 -2
- package/interfaces/context/execution.interface.d.ts +0 -18
- package/interfaces/context/execution.interface.js +0 -2
- package/interfaces/context/index.d.ts +0 -2
- package/interfaces/context/index.js +0 -18
- package/interfaces/features/exception-filter.interface.d.ts +0 -21
- package/interfaces/features/exception-filter.interface.js +0 -2
- package/interfaces/features/guards.interface.d.ts +0 -20
- package/interfaces/features/guards.interface.js +0 -2
- package/interfaces/features/index.d.ts +0 -4
- package/interfaces/features/index.js +0 -20
- package/interfaces/features/interceptor.interface.d.ts +0 -30
- package/interfaces/features/interceptor.interface.js +0 -2
- package/interfaces/features/pipes.interface.d.ts +0 -37
- package/interfaces/features/pipes.interface.js +0 -2
- package/interfaces/helper.interface.d.ts +0 -3
- package/interfaces/helper.interface.js +0 -2
- package/interfaces/hooks/before-application-shutdown.interface.d.ts +0 -3
- package/interfaces/hooks/before-application-shutdown.interface.js +0 -2
- package/interfaces/hooks/index.d.ts +0 -5
- package/interfaces/hooks/index.js +0 -21
- package/interfaces/hooks/on-application-bootstrap.interface.d.ts +0 -9
- package/interfaces/hooks/on-application-bootstrap.interface.js +0 -2
- package/interfaces/hooks/on-application-shutdown.interface.d.ts +0 -9
- package/interfaces/hooks/on-application-shutdown.interface.js +0 -2
- package/interfaces/hooks/on-destroy.interface.d.ts +0 -10
- package/interfaces/hooks/on-destroy.interface.js +0 -2
- package/interfaces/hooks/on-init.interface.d.ts +0 -8
- package/interfaces/hooks/on-init.interface.js +0 -2
- package/interfaces/index.d.ts +0 -8
- package/interfaces/index.js +0 -24
- package/interfaces/injectable.interface.d.ts +0 -1
- package/interfaces/injectable.interface.js +0 -2
- package/interfaces/modules/configurable/async-options.interface.d.ts +0 -42
- package/interfaces/modules/configurable/async-options.interface.js +0 -2
- package/interfaces/modules/configurable/cls.interface.d.ts +0 -13
- package/interfaces/modules/configurable/cls.interface.js +0 -2
- package/interfaces/modules/configurable/host.interface.d.ts +0 -62
- package/interfaces/modules/configurable/host.interface.js +0 -2
- package/interfaces/modules/configurable/index.d.ts +0 -3
- package/interfaces/modules/configurable/index.js +0 -19
- package/interfaces/modules/definition.interface.d.ts +0 -4
- package/interfaces/modules/definition.interface.js +0 -2
- package/interfaces/modules/dynamic-module.interface.d.ts +0 -23
- package/interfaces/modules/dynamic-module.interface.js +0 -2
- package/interfaces/modules/forward-reference.interface.d.ts +0 -3
- package/interfaces/modules/forward-reference.interface.js +0 -2
- package/interfaces/modules/index.d.ts +0 -9
- package/interfaces/modules/index.js +0 -25
- package/interfaces/modules/injection-token.interface.d.ts +0 -5
- package/interfaces/modules/injection-token.interface.js +0 -2
- package/interfaces/modules/introspection-result.interface.d.ts +0 -10
- package/interfaces/modules/introspection-result.interface.js +0 -2
- package/interfaces/modules/module-metadata.interface.d.ts +0 -24
- package/interfaces/modules/module-metadata.interface.js +0 -2
- package/interfaces/modules/module.interface.d.ts +0 -2
- package/interfaces/modules/module.interface.js +0 -2
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +0 -8
- package/interfaces/modules/optional-factory-dependency.interface.js +0 -2
- package/interfaces/modules/override.interface.d.ts +0 -5
- package/interfaces/modules/override.interface.js +0 -2
- package/interfaces/modules/provider.interface.d.ts +0 -142
- package/interfaces/modules/provider.interface.js +0 -2
- package/interfaces/scope.interface.d.ts +0 -35
- package/interfaces/scope.interface.js +0 -23
- package/interfaces/type.interface.d.ts +0 -3
- package/interfaces/type.interface.js +0 -2
- package/metadata-scanner.d.ts +0 -4
- package/metadata-scanner.js +0 -34
- package/module/configurable-module.builder.d.ts +0 -93
- package/module/configurable-module.builder.js +0 -204
- package/module/constants.d.ts +0 -4
- package/module/constants.js +0 -7
- package/module/helpers/generate-options-injection-token.helper.d.ts +0 -1
- package/module/helpers/generate-options-injection-token.helper.js +0 -9
- package/module/helpers/get-injection-providers.helper.d.ts +0 -8
- package/module/helpers/get-injection-providers.helper.js +0 -36
- package/module/helpers/index.d.ts +0 -2
- package/module/helpers/index.js +0 -18
- package/module/index.d.ts +0 -2
- package/module/index.js +0 -18
- package/pipes/consumer.d.ts +0 -9
- package/pipes/consumer.js +0 -15
- package/pipes/context-creator.d.ts +0 -18
- package/pipes/context-creator.js +0 -70
- package/pipes/index.d.ts +0 -2
- package/pipes/index.js +0 -18
- package/scanner.d.ts +0 -81
- package/scanner.js +0 -374
- package/services/console.service.d.ts +0 -86
- package/services/console.service.js +0 -233
- package/services/index.d.ts +0 -1
- package/services/index.js +0 -17
- package/services/logger.service.d.ts +0 -157
- package/services/logger.service.js +0 -269
- package/services/reflector.service.d.ts +0 -110
- package/services/reflector.service.js +0 -87
- package/test/context/creator.spec.d.ts +0 -1
- package/test/context/creator.spec.js +0 -149
- package/test/context/execution-host.spec.d.ts +0 -1
- package/test/context/execution-host.spec.js +0 -31
- package/test/context/proxy.spec.d.ts +0 -1
- package/test/context/proxy.spec.js +0 -46
- package/test/exceptions/handler.spec.d.ts +0 -1
- package/test/exceptions/handler.spec.js +0 -90
- package/test/exceptions/messages.spec.js +0 -201
- package/test/exceptions/zona/handler.spec.d.ts +0 -1
- package/test/exceptions/zona/handler.spec.js +0 -51
- package/test/exceptions/zona/zone.spec.d.ts +0 -1
- package/test/exceptions/zona/zone.spec.js +0 -66
- package/test/filters/context-creator.spec.d.ts +0 -2
- package/test/filters/context-creator.spec.js +0 -91
- package/test/guards/consumer.spec.d.ts +0 -1
- package/test/guards/consumer.spec.js +0 -47
- package/test/guards/context-creator.spec.d.ts +0 -1
- package/test/guards/context-creator.spec.js +0 -138
- package/test/helpers/context-id-factory.spec.d.ts +0 -1
- package/test/helpers/context-id-factory.spec.js +0 -9
- package/test/helpers/shared.spec.d.ts +0 -1
- package/test/helpers/shared.spec.js +0 -122
- package/test/hooks/before-app-shutdown.hook.spec.d.ts +0 -1
- package/test/hooks/before-app-shutdown.hook.spec.js +0 -44
- package/test/hooks/on-app-bootstrap.hook.spec.d.ts +0 -1
- package/test/hooks/on-app-bootstrap.hook.spec.js +0 -43
- package/test/hooks/on-app-shutdown.hook.spec.d.ts +0 -1
- package/test/hooks/on-app-shutdown.hook.spec.js +0 -43
- package/test/hooks/on-module-destroy.hook.spec.d.ts +0 -1
- package/test/hooks/on-module-destroy.hook.spec.js +0 -43
- package/test/hooks/on-module-init.hook.spec.d.ts +0 -1
- package/test/hooks/on-module-init.hook.spec.js +0 -43
- package/test/injector/compiler.spec.d.ts +0 -1
- package/test/injector/compiler.spec.js +0 -42
- package/test/injector/container.spec.d.ts +0 -1
- package/test/injector/container.spec.js +0 -203
- package/test/injector/helpers/classifier.spec.d.ts +0 -1
- package/test/injector/helpers/classifier.spec.js +0 -102
- package/test/injector/injector.spec.d.ts +0 -1
- package/test/injector/injector.spec.js +0 -678
- package/test/injector/instance/loader.spec.d.ts +0 -1
- package/test/injector/instance/loader.spec.js +0 -108
- package/test/injector/instance/wrapper.spec.d.ts +0 -1
- package/test/injector/instance/wrapper.spec.js +0 -772
- package/test/injector/internal-core-module/internal-core-module-factory.spec.d.ts +0 -1
- package/test/injector/internal-core-module/internal-core-module-factory.spec.js +0 -27
- package/test/injector/module/lazy/loader.spec.d.ts +0 -1
- package/test/injector/module/lazy/loader.spec.js +0 -71
- package/test/injector/module/module.spec.d.ts +0 -1
- package/test/injector/module/module.spec.js +0 -410
- package/test/injector/module/token-factory.spec.d.ts +0 -1
- package/test/injector/module/token-factory.spec.js +0 -84
- package/test/interceptors/consumer.spec.d.ts +0 -1
- package/test/interceptors/consumer.spec.js +0 -136
- package/test/interceptors/context-creator.spec.d.ts +0 -1
- package/test/interceptors/context-creator.spec.js +0 -139
- package/test/metadata-scanner.spec.d.ts +0 -1
- package/test/metadata-scanner.spec.js +0 -41
- package/test/module/configurable-module.builder.spec.d.ts +0 -1
- package/test/module/configurable-module.builder.spec.js +0 -102
- package/test/module/helpers/get-injection-providers.helper.spec.d.ts +0 -1
- package/test/module/helpers/get-injection-providers.helper.spec.js +0 -49
- package/test/pipes/consumer.spec.d.ts +0 -1
- package/test/pipes/consumer.spec.js +0 -42
- package/test/pipes/context-creator.spec.d.ts +0 -1
- package/test/pipes/context-creator.spec.js +0 -108
- package/test/scanner.spec.d.ts +0 -1
- package/test/scanner.spec.js +0 -620
- package/test/services/logger.service.spec.d.ts +0 -1
- package/test/services/logger.service.spec.js +0 -487
- package/test/services/reflector.service.spec.d.ts +0 -1
- package/test/services/reflector.service.spec.js +0 -105
- package/tsconfig.tsbuildinfo +0 -1
- /package/{test/exceptions/messages.spec.d.ts → dist/interfaces/abstract.interface.js} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __legacyDecorateClassTS = 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")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
// packages/core/src/application/config.ts
|
|
20
|
+
class ApplicationConfig {
|
|
21
|
+
globalPipes = [];
|
|
22
|
+
globalFilters = [];
|
|
23
|
+
globalInterceptors = [];
|
|
24
|
+
globalGuards = [];
|
|
25
|
+
globalRequestPipes = [];
|
|
26
|
+
globalRequestFilters = [];
|
|
27
|
+
globalRequestInterceptors = [];
|
|
28
|
+
globalRequestGuards = [];
|
|
29
|
+
addGlobalPipe(pipe) {
|
|
30
|
+
this.globalPipes.push(pipe);
|
|
31
|
+
}
|
|
32
|
+
useGlobalPipes(...pipes) {
|
|
33
|
+
this.globalPipes = this.globalPipes.concat(pipes);
|
|
34
|
+
}
|
|
35
|
+
getGlobalFilters() {
|
|
36
|
+
return this.globalFilters;
|
|
37
|
+
}
|
|
38
|
+
addGlobalFilter(filter) {
|
|
39
|
+
this.globalFilters.push(filter);
|
|
40
|
+
}
|
|
41
|
+
useGlobalFilters(...filters) {
|
|
42
|
+
this.globalFilters = this.globalFilters.concat(filters);
|
|
43
|
+
}
|
|
44
|
+
getGlobalPipes() {
|
|
45
|
+
return this.globalPipes;
|
|
46
|
+
}
|
|
47
|
+
getGlobalInterceptors() {
|
|
48
|
+
return this.globalInterceptors;
|
|
49
|
+
}
|
|
50
|
+
addGlobalInterceptor(interceptor) {
|
|
51
|
+
this.globalInterceptors.push(interceptor);
|
|
52
|
+
}
|
|
53
|
+
useGlobalInterceptors(...interceptors) {
|
|
54
|
+
this.globalInterceptors = this.globalInterceptors.concat(interceptors);
|
|
55
|
+
}
|
|
56
|
+
getGlobalGuards() {
|
|
57
|
+
return this.globalGuards;
|
|
58
|
+
}
|
|
59
|
+
addGlobalGuard(guard) {
|
|
60
|
+
this.globalGuards.push(guard);
|
|
61
|
+
}
|
|
62
|
+
useGlobalGuards(...guards) {
|
|
63
|
+
this.globalGuards = this.globalGuards.concat(guards);
|
|
64
|
+
}
|
|
65
|
+
addGlobalRequestInterceptor(wrapper) {
|
|
66
|
+
this.globalRequestInterceptors.push(wrapper);
|
|
67
|
+
}
|
|
68
|
+
getGlobalRequestInterceptors() {
|
|
69
|
+
return this.globalRequestInterceptors;
|
|
70
|
+
}
|
|
71
|
+
addGlobalRequestPipe(wrapper) {
|
|
72
|
+
this.globalRequestPipes.push(wrapper);
|
|
73
|
+
}
|
|
74
|
+
getGlobalRequestPipes() {
|
|
75
|
+
return this.globalRequestPipes;
|
|
76
|
+
}
|
|
77
|
+
addGlobalRequestFilter(wrapper) {
|
|
78
|
+
this.globalRequestFilters.push(wrapper);
|
|
79
|
+
}
|
|
80
|
+
getGlobalRequestFilters() {
|
|
81
|
+
return this.globalRequestFilters;
|
|
82
|
+
}
|
|
83
|
+
addGlobalRequestGuard(wrapper) {
|
|
84
|
+
this.globalRequestGuards.push(wrapper);
|
|
85
|
+
}
|
|
86
|
+
getGlobalRequestGuards() {
|
|
87
|
+
return this.globalRequestGuards;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
ApplicationConfig
|
|
92
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __legacyDecorateClassTS = 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")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
// packages/core/src/application/context.ts
|
|
20
|
+
import { UnknownModuleException } from "../errors/exceptions/unknown-module.exception.js";
|
|
21
|
+
import { callBeforeAppShutdownHook } from "../hooks/before-app-shutdown.hook.js";
|
|
22
|
+
import { callModuleBootstrapHook } from "../hooks/on-app-bootstrap.hook.js";
|
|
23
|
+
import { AbstractInstanceResolver } from "../injector/instance/resolver.js";
|
|
24
|
+
import { callModuleDestroyHook } from "../hooks/on-module-destroy.hook.js";
|
|
25
|
+
import { createContextId } from "../helpers/context-id-factory.helper.js";
|
|
26
|
+
import { callAppShutdownHook } from "../hooks/on-app-shutdown.hook.js";
|
|
27
|
+
import { callModuleInitHook } from "../hooks/on-module-init.hook.js";
|
|
28
|
+
import { InstanceLinksHost } from "../injector/instance/links-host.js";
|
|
29
|
+
import { ShutdownSignal } from "../enums/shutdown-signal.enum.js";
|
|
30
|
+
import { ModuleCompiler } from "../injector/module/compiler.js";
|
|
31
|
+
import { Logger } from "../services/logger.service.js";
|
|
32
|
+
import { isEmpty } from "../helpers/shared.helper.js";
|
|
33
|
+
import { Injector } from "../injector/injector.js";
|
|
34
|
+
import { MESSAGES } from "../constants.js";
|
|
35
|
+
|
|
36
|
+
class ApplicationContext extends AbstractInstanceResolver {
|
|
37
|
+
container;
|
|
38
|
+
config;
|
|
39
|
+
appOptions;
|
|
40
|
+
contextModule;
|
|
41
|
+
scope;
|
|
42
|
+
isInitialized = false;
|
|
43
|
+
injector;
|
|
44
|
+
logger = new Logger(ApplicationContext.name, {
|
|
45
|
+
timestamp: true
|
|
46
|
+
});
|
|
47
|
+
shouldFlushLogsOnOverride = false;
|
|
48
|
+
activeShutdownSignals = new Array;
|
|
49
|
+
moduleCompiler = new ModuleCompiler;
|
|
50
|
+
shutdownCleanupRef;
|
|
51
|
+
_instanceLinksHost;
|
|
52
|
+
_moduleRefsForHooksByDistance;
|
|
53
|
+
initializationPromise;
|
|
54
|
+
get instanceLinksHost() {
|
|
55
|
+
if (!this._instanceLinksHost) {
|
|
56
|
+
this._instanceLinksHost = new InstanceLinksHost(this.container);
|
|
57
|
+
}
|
|
58
|
+
return this._instanceLinksHost;
|
|
59
|
+
}
|
|
60
|
+
constructor(container, config, appOptions = {}, contextModule = null, scope = new Array) {
|
|
61
|
+
super();
|
|
62
|
+
this.container = container;
|
|
63
|
+
this.config = config;
|
|
64
|
+
this.appOptions = appOptions;
|
|
65
|
+
this.contextModule = contextModule;
|
|
66
|
+
this.scope = scope;
|
|
67
|
+
this.injector = new Injector;
|
|
68
|
+
if (!this.contextModule)
|
|
69
|
+
this.selectContextModule();
|
|
70
|
+
if (this.appOptions.preview)
|
|
71
|
+
this.printInPreviewModeWarning();
|
|
72
|
+
}
|
|
73
|
+
selectContextModule() {
|
|
74
|
+
const modules = this.container.getModules().values();
|
|
75
|
+
this.contextModule = modules.next().value;
|
|
76
|
+
}
|
|
77
|
+
select(moduleType, selectOptions) {
|
|
78
|
+
const modulesContainer = this.container.getModules();
|
|
79
|
+
const contextModuleCtor = this.contextModule.metatype;
|
|
80
|
+
const scope = this.scope.concat(contextModuleCtor);
|
|
81
|
+
const moduleTokenFactory = this.container.getModuleTokenFactory();
|
|
82
|
+
const { type, dynamicMetadata } = this.moduleCompiler.extractMetadata(moduleType);
|
|
83
|
+
const token = moduleTokenFactory.create(type, dynamicMetadata);
|
|
84
|
+
const selectedModule = modulesContainer.get(token);
|
|
85
|
+
if (!selectedModule)
|
|
86
|
+
throw new UnknownModuleException(type.name);
|
|
87
|
+
const options = typeof selectOptions?.abortOnError !== "undefined" ? { ...this.appOptions, ...selectOptions } : this.appOptions;
|
|
88
|
+
return new ApplicationContext(this.container, this.config, options, selectedModule, scope);
|
|
89
|
+
}
|
|
90
|
+
get(typeOrToken, options = { strict: false }) {
|
|
91
|
+
return !(options && options.strict) ? this.find(typeOrToken, options) : this.find(typeOrToken, { moduleId: this.contextModule?.id, each: options.each });
|
|
92
|
+
}
|
|
93
|
+
resolve(typeOrToken, contextId = createContextId(), options = { strict: false }) {
|
|
94
|
+
return this.resolvePerContext(typeOrToken, this.contextModule, contextId, options);
|
|
95
|
+
}
|
|
96
|
+
registerRequestByContextId(request, contextId) {
|
|
97
|
+
this.container.registerRequestProvider(request, contextId);
|
|
98
|
+
}
|
|
99
|
+
async init() {
|
|
100
|
+
if (this.isInitialized)
|
|
101
|
+
return this;
|
|
102
|
+
this.initializationPromise = this.initializationPromise = new Promise(async (resolve, reject) => {
|
|
103
|
+
try {
|
|
104
|
+
await this.callInitHook();
|
|
105
|
+
await this.callBootstrapHook();
|
|
106
|
+
resolve();
|
|
107
|
+
} catch (err) {
|
|
108
|
+
reject(err);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
await this.initializationPromise;
|
|
112
|
+
this.isInitialized = true;
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
async close(signal) {
|
|
116
|
+
await this.initializationPromise;
|
|
117
|
+
await this.callDestroyHook();
|
|
118
|
+
await this.callBeforeShutdownHook(signal);
|
|
119
|
+
await this.dispose();
|
|
120
|
+
await this.callShutdownHook(signal);
|
|
121
|
+
this.unsubscribeFromProcessSignals();
|
|
122
|
+
}
|
|
123
|
+
useLogger(logger) {
|
|
124
|
+
Logger.overrideLogger(logger);
|
|
125
|
+
if (this.shouldFlushLogsOnOverride)
|
|
126
|
+
this.flushLogs();
|
|
127
|
+
}
|
|
128
|
+
useGlobalFilters(...filters) {
|
|
129
|
+
this.config.useGlobalFilters(...filters);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
useGlobalPipes(...pipes) {
|
|
133
|
+
this.config.useGlobalPipes(...pipes);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
useGlobalInterceptors(...interceptors) {
|
|
137
|
+
this.config.useGlobalInterceptors(...interceptors);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
useGlobalGuards(...guards) {
|
|
141
|
+
this.config.useGlobalGuards(...guards);
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
flushLogs() {
|
|
145
|
+
Logger.flush();
|
|
146
|
+
}
|
|
147
|
+
flushLogsOnOverride() {
|
|
148
|
+
this.shouldFlushLogsOnOverride = true;
|
|
149
|
+
}
|
|
150
|
+
enableShutdownHooks(signals = []) {
|
|
151
|
+
if (isEmpty(signals)) {
|
|
152
|
+
const keys = Object.keys(ShutdownSignal);
|
|
153
|
+
signals = keys.map((key) => ShutdownSignal[key]);
|
|
154
|
+
} else {
|
|
155
|
+
signals = Array.from(new Set(signals));
|
|
156
|
+
}
|
|
157
|
+
signals = signals.map((signal) => signal.toString().toUpperCase().trim()).filter((signal) => !this.activeShutdownSignals.includes(signal));
|
|
158
|
+
this.listenToShutdownSignals(signals);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
async dispose() {
|
|
162
|
+
return Promise.resolve();
|
|
163
|
+
}
|
|
164
|
+
listenToShutdownSignals(signals) {
|
|
165
|
+
let receivedSignal = false;
|
|
166
|
+
const cleanup = async (signal) => {
|
|
167
|
+
try {
|
|
168
|
+
if (receivedSignal)
|
|
169
|
+
return;
|
|
170
|
+
receivedSignal = true;
|
|
171
|
+
await this.initializationPromise;
|
|
172
|
+
await this.callDestroyHook();
|
|
173
|
+
await this.callBeforeShutdownHook(signal);
|
|
174
|
+
await this.dispose();
|
|
175
|
+
await this.callShutdownHook(signal);
|
|
176
|
+
signals.forEach((sig) => process.removeListener(sig, cleanup));
|
|
177
|
+
process.kill(process.pid, signal);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
Logger.error(MESSAGES.ERROR_DURING_SHUTDOWN, err?.stack, ApplicationContext.name);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
this.shutdownCleanupRef = cleanup;
|
|
184
|
+
signals.forEach((signal) => {
|
|
185
|
+
this.activeShutdownSignals.push(signal);
|
|
186
|
+
process.on(signal, cleanup);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
unsubscribeFromProcessSignals() {
|
|
190
|
+
if (!this.shutdownCleanupRef)
|
|
191
|
+
return;
|
|
192
|
+
this.activeShutdownSignals.forEach((signal) => {
|
|
193
|
+
process.removeListener(signal, this.shutdownCleanupRef);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
async callInitHook() {
|
|
197
|
+
const modulesSortedByDistance = this.getModulesToTriggerHooksOn();
|
|
198
|
+
for (const module of modulesSortedByDistance) {
|
|
199
|
+
await callModuleInitHook(module);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async callDestroyHook() {
|
|
203
|
+
const modulesSortedByDistance = [...this.getModulesToTriggerHooksOn()].reverse();
|
|
204
|
+
for (const module of modulesSortedByDistance) {
|
|
205
|
+
await callModuleDestroyHook(module);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async callBootstrapHook() {
|
|
209
|
+
const modulesSortedByDistance = this.getModulesToTriggerHooksOn();
|
|
210
|
+
for (const module of modulesSortedByDistance) {
|
|
211
|
+
await callModuleBootstrapHook(module);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async callShutdownHook(signal) {
|
|
215
|
+
const modulesSortedByDistance = [...this.getModulesToTriggerHooksOn()].reverse();
|
|
216
|
+
for (const module of modulesSortedByDistance) {
|
|
217
|
+
await callAppShutdownHook(module, signal);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async callBeforeShutdownHook(signal) {
|
|
221
|
+
const modulesSortedByDistance = [...this.getModulesToTriggerHooksOn()].reverse();
|
|
222
|
+
for (const module of modulesSortedByDistance) {
|
|
223
|
+
await callBeforeAppShutdownHook(module, signal);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
assertNotInPreviewMode(methodName) {
|
|
227
|
+
if (this.appOptions.preview) {
|
|
228
|
+
const error = `Calling the "${methodName}" in the preview mode is not supported.`;
|
|
229
|
+
this.logger.error(error);
|
|
230
|
+
throw new Error(error);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
getModulesToTriggerHooksOn() {
|
|
234
|
+
if (this._moduleRefsForHooksByDistance) {
|
|
235
|
+
return this._moduleRefsForHooksByDistance;
|
|
236
|
+
}
|
|
237
|
+
const modulesContainer = this.container.getModules();
|
|
238
|
+
const compareFn = (a, b) => b.distance - a.distance;
|
|
239
|
+
const modulesSortedByDistance = Array.from(modulesContainer.values()).sort(compareFn);
|
|
240
|
+
this._moduleRefsForHooksByDistance = this.appOptions?.preview ? modulesSortedByDistance.filter((moduleRef) => moduleRef.initOnPreview) : modulesSortedByDistance;
|
|
241
|
+
return this._moduleRefsForHooksByDistance;
|
|
242
|
+
}
|
|
243
|
+
printInPreviewModeWarning() {
|
|
244
|
+
this.logger.warn("------------------------------------------------");
|
|
245
|
+
this.logger.warn("Application is running in the PREVIEW mode!");
|
|
246
|
+
this.logger.warn("Providers will not be instantiated.");
|
|
247
|
+
this.logger.warn("------------------------------------------------");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
export {
|
|
251
|
+
ApplicationContext
|
|
252
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __legacyDecorateClassTS = 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")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
// packages/core/src/application/factory.ts
|
|
20
|
+
import { isFunction, isNull } from "../helpers/shared.helper.js";
|
|
21
|
+
import { rethrow } from "../helpers/rethrow.helper.js";
|
|
22
|
+
import { UuidFactory, UuidFactoryMode } from "../helpers/uuid.helper.js";
|
|
23
|
+
import { ApplicationConfig } from "../application/config.js";
|
|
24
|
+
import { ApplicationContext } from "../application/context.js";
|
|
25
|
+
import { ConsoleLogger } from "../services/console.service.js";
|
|
26
|
+
import { Logger } from "../services/logger.service.js";
|
|
27
|
+
import { NoopGraphInspector } from "../inspector/noop-graph-inspector.js";
|
|
28
|
+
import { GraphInspector } from "../inspector/graph-inspector.js";
|
|
29
|
+
import { Injector } from "../injector/injector.js";
|
|
30
|
+
import { VenokContainer } from "../injector/container.js";
|
|
31
|
+
import { InstanceLoader } from "../injector/instance/loader.js";
|
|
32
|
+
import { MetadataScanner } from "../metadata-scanner.js";
|
|
33
|
+
import { DependenciesScanner } from "../scanner.js";
|
|
34
|
+
import { ExceptionsZone } from "../exceptions/zone/zone.js";
|
|
35
|
+
import { MESSAGES } from "../constants.js";
|
|
36
|
+
|
|
37
|
+
class VenokFactoryStatic {
|
|
38
|
+
logger = new Logger("VenokFactory", {
|
|
39
|
+
timestamp: true
|
|
40
|
+
});
|
|
41
|
+
abortOnError = true;
|
|
42
|
+
autoFlushLogs = false;
|
|
43
|
+
async createApplicationContext(moduleCls, options) {
|
|
44
|
+
try {
|
|
45
|
+
const nest = __require("@nestjs/common");
|
|
46
|
+
if (nest)
|
|
47
|
+
nest.Logger.overrideLogger(new ConsoleLogger);
|
|
48
|
+
} catch {}
|
|
49
|
+
const applicationConfig = new ApplicationConfig;
|
|
50
|
+
const container = new VenokContainer(applicationConfig);
|
|
51
|
+
const graphInspector = this.createGraphInspector(options, container);
|
|
52
|
+
this.setAbortOnError(options);
|
|
53
|
+
this.registerLoggerConfiguration(options);
|
|
54
|
+
await this.initialize(moduleCls, container, graphInspector, applicationConfig, options);
|
|
55
|
+
const modules = container.getModules().values();
|
|
56
|
+
const root = modules.next().value;
|
|
57
|
+
const context = this.createVenokInstance(new ApplicationContext(container, applicationConfig, options, root));
|
|
58
|
+
if (this.autoFlushLogs)
|
|
59
|
+
context.flushLogsOnOverride();
|
|
60
|
+
return context;
|
|
61
|
+
}
|
|
62
|
+
createVenokInstance(instance) {
|
|
63
|
+
return this.createProxy(instance);
|
|
64
|
+
}
|
|
65
|
+
setAbortOnError(options) {
|
|
66
|
+
this.abortOnError = !(options && options.abortOnError === false);
|
|
67
|
+
}
|
|
68
|
+
async initialize(module, container, graphInspector, config = new ApplicationConfig, options = {}) {
|
|
69
|
+
UuidFactory.mode = options.snapshot ? UuidFactoryMode.Deterministic : UuidFactoryMode.Random;
|
|
70
|
+
const injector = new Injector({ preview: options.preview });
|
|
71
|
+
const instanceLoader = new InstanceLoader(container, injector, graphInspector);
|
|
72
|
+
const metadataScanner = new MetadataScanner;
|
|
73
|
+
const dependenciesScanner = new DependenciesScanner(container, metadataScanner, graphInspector, config);
|
|
74
|
+
const teardown = !this.abortOnError ? rethrow : undefined;
|
|
75
|
+
try {
|
|
76
|
+
this.logger.log(MESSAGES.APPLICATION_START);
|
|
77
|
+
await ExceptionsZone.asyncRun(async () => {
|
|
78
|
+
await dependenciesScanner.scan(module);
|
|
79
|
+
await instanceLoader.createInstancesOfDependencies();
|
|
80
|
+
dependenciesScanner.applyApplicationProviders();
|
|
81
|
+
}, teardown, this.autoFlushLogs);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
this.handleInitializationError(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
handleInitializationError(err) {
|
|
87
|
+
if (this.abortOnError)
|
|
88
|
+
process.abort();
|
|
89
|
+
rethrow(err);
|
|
90
|
+
}
|
|
91
|
+
createProxy(target) {
|
|
92
|
+
const proxy = this.createExceptionProxy();
|
|
93
|
+
return new Proxy(target, { get: proxy, set: proxy });
|
|
94
|
+
}
|
|
95
|
+
createExceptionProxy() {
|
|
96
|
+
return (receiver, prop) => {
|
|
97
|
+
if (!(prop in receiver))
|
|
98
|
+
return;
|
|
99
|
+
if (isFunction(receiver[prop]))
|
|
100
|
+
return this.createExceptionZone(receiver, prop);
|
|
101
|
+
return receiver[prop];
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
createExceptionZone(receiver, prop) {
|
|
105
|
+
const teardown = !this.abortOnError ? rethrow : undefined;
|
|
106
|
+
return (...args) => {
|
|
107
|
+
let result;
|
|
108
|
+
ExceptionsZone.run(() => {
|
|
109
|
+
result = receiver[prop](...args);
|
|
110
|
+
}, teardown);
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
registerLoggerConfiguration(options) {
|
|
115
|
+
if (!options)
|
|
116
|
+
return;
|
|
117
|
+
const { logger, bufferLogs, autoFlushLogs, forceConsole } = options;
|
|
118
|
+
if (!!logger && !isNull(logger))
|
|
119
|
+
Logger.overrideLogger(logger);
|
|
120
|
+
else if (forceConsole) {
|
|
121
|
+
const consoleLogger = new ConsoleLogger({ forceConsole: true });
|
|
122
|
+
Logger.overrideLogger(consoleLogger);
|
|
123
|
+
}
|
|
124
|
+
if (bufferLogs)
|
|
125
|
+
Logger.attachBuffer();
|
|
126
|
+
this.autoFlushLogs = autoFlushLogs ?? true;
|
|
127
|
+
}
|
|
128
|
+
createGraphInspector(appOptions, container) {
|
|
129
|
+
return appOptions?.snapshot ? new GraphInspector(container) : NoopGraphInspector;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var VenokFactory = new VenokFactoryStatic;
|
|
133
|
+
export {
|
|
134
|
+
VenokFactoryStatic,
|
|
135
|
+
VenokFactory
|
|
136
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __legacyDecorateClassTS = 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")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
// packages/core/src/constants.ts
|
|
20
|
+
var MESSAGES = {
|
|
21
|
+
APPLICATION_START: `Starting Venok application...`,
|
|
22
|
+
APPLICATION_READY: `Venok application successfully started`,
|
|
23
|
+
UNKNOWN_EXCEPTION_MESSAGE: "Internal server error",
|
|
24
|
+
ERROR_DURING_SHUTDOWN: "Error happened during shutdown"
|
|
25
|
+
};
|
|
26
|
+
var FORBIDDEN_MESSAGE = "Forbidden resource";
|
|
27
|
+
var MODULE_METADATA = {
|
|
28
|
+
IMPORTS: "imports",
|
|
29
|
+
PROVIDERS: "providers",
|
|
30
|
+
EXPORTS: "exports"
|
|
31
|
+
};
|
|
32
|
+
var PIPES_METADATA = "__pipes__";
|
|
33
|
+
var GUARDS_METADATA = "__guards__";
|
|
34
|
+
var INTERCEPTORS_METADATA = "__interceptors__";
|
|
35
|
+
var EXCEPTION_FILTERS_METADATA = "__exceptionFilters__";
|
|
36
|
+
var ENHANCER_KEY_TO_SUBTYPE_MAP = {
|
|
37
|
+
[GUARDS_METADATA]: "guard",
|
|
38
|
+
[INTERCEPTORS_METADATA]: "interceptor",
|
|
39
|
+
[PIPES_METADATA]: "pipe",
|
|
40
|
+
[EXCEPTION_FILTERS_METADATA]: "filter"
|
|
41
|
+
};
|
|
42
|
+
var APP_INTERCEPTOR = "APP_INTERCEPTOR";
|
|
43
|
+
var APP_PIPE = "APP_PIPE";
|
|
44
|
+
var APP_GUARD = "APP_GUARD";
|
|
45
|
+
var APP_FILTER = "APP_FILTER";
|
|
46
|
+
var ENHANCER_TOKEN_TO_SUBTYPE_MAP = {
|
|
47
|
+
[APP_GUARD]: "guard",
|
|
48
|
+
[APP_INTERCEPTOR]: "interceptor",
|
|
49
|
+
[APP_PIPE]: "pipe",
|
|
50
|
+
[APP_FILTER]: "filter"
|
|
51
|
+
};
|
|
52
|
+
var REQUEST = "REQUEST";
|
|
53
|
+
var GLOBAL_MODULE_METADATA = "__module:global__";
|
|
54
|
+
var PARAMTYPES_METADATA = "design:paramtypes";
|
|
55
|
+
var SELF_DECLARED_DEPS_METADATA = "self:paramtypes";
|
|
56
|
+
var OPTIONAL_DEPS_METADATA = "optional:paramtypes";
|
|
57
|
+
var PROPERTY_DEPS_METADATA = "self:properties_metadata";
|
|
58
|
+
var OPTIONAL_PROPERTY_DEPS_METADATA = "optional:properties_metadata";
|
|
59
|
+
var SCOPE_OPTIONS_METADATA = "scope:options";
|
|
60
|
+
var MODULE_PATH = "__module_path__";
|
|
61
|
+
var ROUTE_ARGS_METADATA = "__routeArguments__";
|
|
62
|
+
var CUSTOM_ROUTE_ARGS_METADATA = "__customRouteArgs__";
|
|
63
|
+
var FILTER_CATCH_EXCEPTIONS = "__filterCatchExceptions__";
|
|
64
|
+
var INJECTABLE_WATERMARK = "__injectable__";
|
|
65
|
+
var CATCH_WATERMARK = "__catch__";
|
|
66
|
+
var ENTRY_PROVIDER_WATERMARK = "__entryProvider__";
|
|
67
|
+
var INQUIRER = "INQUIRER";
|
|
68
|
+
var REQUEST_CONTEXT_ID = Symbol("REQUEST_CONTEXT_ID");
|
|
69
|
+
export {
|
|
70
|
+
SELF_DECLARED_DEPS_METADATA,
|
|
71
|
+
SCOPE_OPTIONS_METADATA,
|
|
72
|
+
ROUTE_ARGS_METADATA,
|
|
73
|
+
REQUEST_CONTEXT_ID,
|
|
74
|
+
REQUEST,
|
|
75
|
+
PROPERTY_DEPS_METADATA,
|
|
76
|
+
PIPES_METADATA,
|
|
77
|
+
PARAMTYPES_METADATA,
|
|
78
|
+
OPTIONAL_PROPERTY_DEPS_METADATA,
|
|
79
|
+
OPTIONAL_DEPS_METADATA,
|
|
80
|
+
MODULE_PATH,
|
|
81
|
+
MODULE_METADATA,
|
|
82
|
+
MESSAGES,
|
|
83
|
+
INTERCEPTORS_METADATA,
|
|
84
|
+
INQUIRER,
|
|
85
|
+
INJECTABLE_WATERMARK,
|
|
86
|
+
GUARDS_METADATA,
|
|
87
|
+
GLOBAL_MODULE_METADATA,
|
|
88
|
+
FORBIDDEN_MESSAGE,
|
|
89
|
+
FILTER_CATCH_EXCEPTIONS,
|
|
90
|
+
EXCEPTION_FILTERS_METADATA,
|
|
91
|
+
ENTRY_PROVIDER_WATERMARK,
|
|
92
|
+
ENHANCER_TOKEN_TO_SUBTYPE_MAP,
|
|
93
|
+
ENHANCER_KEY_TO_SUBTYPE_MAP,
|
|
94
|
+
CUSTOM_ROUTE_ARGS_METADATA,
|
|
95
|
+
CATCH_WATERMARK,
|
|
96
|
+
APP_PIPE,
|
|
97
|
+
APP_INTERCEPTOR,
|
|
98
|
+
APP_GUARD,
|
|
99
|
+
APP_FILTER
|
|
100
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __legacyDecorateClassTS = 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")
|
|
5
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else
|
|
7
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
8
|
+
if (d = decorators[i])
|
|
9
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __legacyDecorateParamTS = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
|
+
var __legacyMetadataTS = (k, v) => {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
// packages/core/src/context/context-id.factory.ts
|
|
20
|
+
import { createContextId } from "../helpers/context-id-factory.helper.js";
|
|
21
|
+
import { isObject } from "../helpers/shared.helper.js";
|
|
22
|
+
import { REQUEST_CONTEXT_ID } from "../constants.js";
|
|
23
|
+
|
|
24
|
+
class ContextIdFactory {
|
|
25
|
+
static strategy;
|
|
26
|
+
static create() {
|
|
27
|
+
return createContextId();
|
|
28
|
+
}
|
|
29
|
+
static getByRequest(request, propsToInspect = ["raw"]) {
|
|
30
|
+
if (!request)
|
|
31
|
+
return ContextIdFactory.create();
|
|
32
|
+
if (request[REQUEST_CONTEXT_ID])
|
|
33
|
+
return request[REQUEST_CONTEXT_ID];
|
|
34
|
+
for (const key of propsToInspect)
|
|
35
|
+
if (request[key]?.[REQUEST_CONTEXT_ID])
|
|
36
|
+
return request[key][REQUEST_CONTEXT_ID];
|
|
37
|
+
if (!this.strategy)
|
|
38
|
+
return ContextIdFactory.create();
|
|
39
|
+
const contextId = createContextId();
|
|
40
|
+
const resolverObjectOrFunction = this.strategy.attach(contextId, request);
|
|
41
|
+
if (this.isContextIdResolverWithPayload(resolverObjectOrFunction)) {
|
|
42
|
+
contextId.getParent = resolverObjectOrFunction.resolve;
|
|
43
|
+
contextId.payload = resolverObjectOrFunction.payload;
|
|
44
|
+
} else {
|
|
45
|
+
contextId.getParent = resolverObjectOrFunction;
|
|
46
|
+
}
|
|
47
|
+
return contextId;
|
|
48
|
+
}
|
|
49
|
+
static apply(strategy) {
|
|
50
|
+
this.strategy = strategy;
|
|
51
|
+
}
|
|
52
|
+
static isContextIdResolverWithPayload(resolverOrResolverFn) {
|
|
53
|
+
return isObject(resolverOrResolverFn);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
ContextIdFactory
|
|
58
|
+
};
|