@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
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { Scope, Type } from "@venok/core/interfaces";
|
|
2
|
-
import { InjectionToken, OptionalFactoryDependency } from "@venok/core/interfaces/modules";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export type Provider<T = any> = Type | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
8
|
-
/**
|
|
9
|
-
* Interface defining a *Class* type provider.
|
|
10
|
-
*
|
|
11
|
-
* For example:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const configServiceProvider = {
|
|
14
|
-
* provide: ConfigService,
|
|
15
|
-
* useClass:
|
|
16
|
-
* process.env.NODE_ENV === 'development'
|
|
17
|
-
* ? DevelopmentConfigService
|
|
18
|
-
* : ProductionConfigService,
|
|
19
|
-
* };
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @publicApi
|
|
23
|
-
*/
|
|
24
|
-
export interface ClassProvider<T = any> {
|
|
25
|
-
/**
|
|
26
|
-
* Injection token
|
|
27
|
-
*/
|
|
28
|
-
provide: InjectionToken;
|
|
29
|
-
/**
|
|
30
|
-
* Type (class name) of provider (instance to be injected).
|
|
31
|
-
*/
|
|
32
|
-
useClass: Type<T>;
|
|
33
|
-
/**
|
|
34
|
-
* Optional enum defining lifetime of the provider that is injected.
|
|
35
|
-
*/
|
|
36
|
-
scope?: Scope;
|
|
37
|
-
/**
|
|
38
|
-
* This option is only available on factory providers!
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
inject?: never;
|
|
42
|
-
/**
|
|
43
|
-
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
44
|
-
* factory strategy to construct lazy DI subtrees.
|
|
45
|
-
*
|
|
46
|
-
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
47
|
-
*/
|
|
48
|
-
durable?: boolean;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Interface defining a *Value* type provider.
|
|
52
|
-
*
|
|
53
|
-
* For example:
|
|
54
|
-
* ```typescript
|
|
55
|
-
* const connectionProvider = {
|
|
56
|
-
* provide: 'CONNECTION',
|
|
57
|
-
* useValue: connection,
|
|
58
|
-
* };
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @publicApi
|
|
62
|
-
*/
|
|
63
|
-
export interface ValueProvider<T = any> {
|
|
64
|
-
/**
|
|
65
|
-
* Injection token
|
|
66
|
-
*/
|
|
67
|
-
provide: InjectionToken;
|
|
68
|
-
/**
|
|
69
|
-
* Instance of a provider to be injected.
|
|
70
|
-
*/
|
|
71
|
-
useValue: T;
|
|
72
|
-
/**
|
|
73
|
-
* This option is only available on factory providers!
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
inject?: never;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Interface defining a *Factory* type provider.
|
|
80
|
-
*
|
|
81
|
-
* For example:
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const connectionFactory = {
|
|
84
|
-
* provide: 'CONNECTION',
|
|
85
|
-
* useFactory: (optionsProvider: OptionsProvider) => {
|
|
86
|
-
* const options = optionsProvider.get();
|
|
87
|
-
* return new DatabaseConnection(options);
|
|
88
|
-
* },
|
|
89
|
-
* inject: [OptionsProvider],
|
|
90
|
-
* };
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @publicApi
|
|
94
|
-
*/
|
|
95
|
-
export interface FactoryProvider<T = any> {
|
|
96
|
-
/**
|
|
97
|
-
* Injection token
|
|
98
|
-
*/
|
|
99
|
-
provide: InjectionToken;
|
|
100
|
-
/**
|
|
101
|
-
* Factory function that returns an instance of the provider to be injected.
|
|
102
|
-
*/
|
|
103
|
-
useFactory: (...args: any[]) => T | Promise<T>;
|
|
104
|
-
/**
|
|
105
|
-
* Optional list of providers to be injected into the context of the Factory function.
|
|
106
|
-
*/
|
|
107
|
-
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
108
|
-
/**
|
|
109
|
-
* Optional enum defining lifetime of the provider that is returned by the Factory function.
|
|
110
|
-
*/
|
|
111
|
-
scope?: Scope;
|
|
112
|
-
/**
|
|
113
|
-
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
114
|
-
* factory strategy to construct lazy DI subtrees.
|
|
115
|
-
*
|
|
116
|
-
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
117
|
-
*/
|
|
118
|
-
durable?: boolean;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Interface defining an *Existing* (aliased) type provider.
|
|
122
|
-
*
|
|
123
|
-
* For example:
|
|
124
|
-
* ```typescript
|
|
125
|
-
* const loggerAliasProvider = {
|
|
126
|
-
* provide: 'AliasedLoggerService',
|
|
127
|
-
* useExisting: LoggerService
|
|
128
|
-
* };
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* @publicApi
|
|
132
|
-
*/
|
|
133
|
-
export interface ExistingProvider<T = any> {
|
|
134
|
-
/**
|
|
135
|
-
* Injection token
|
|
136
|
-
*/
|
|
137
|
-
provide: InjectionToken;
|
|
138
|
-
/**
|
|
139
|
-
* Provider to be aliased by the Injection token.
|
|
140
|
-
*/
|
|
141
|
-
useExisting: any;
|
|
142
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @publicApi
|
|
3
|
-
*/
|
|
4
|
-
export declare enum Scope {
|
|
5
|
-
/**
|
|
6
|
-
* The provider can be shared across multiple classes. The provider lifetime
|
|
7
|
-
* is strictly tied to the application lifecycle. Once the application has
|
|
8
|
-
* bootstrapped, all providers have been instantiated.
|
|
9
|
-
*/
|
|
10
|
-
DEFAULT = 0,
|
|
11
|
-
/**
|
|
12
|
-
* A new private instance of the provider is instantiated for every use
|
|
13
|
-
*/
|
|
14
|
-
TRANSIENT = 1,
|
|
15
|
-
/**
|
|
16
|
-
* A new instance is instantiated for each request processing pipeline
|
|
17
|
-
*/
|
|
18
|
-
REQUEST = 2
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @publicApi
|
|
22
|
-
*/
|
|
23
|
-
export interface ScopeOptions {
|
|
24
|
-
/**
|
|
25
|
-
* Specifies the lifetime of an injected Provider or Controller.
|
|
26
|
-
*/
|
|
27
|
-
scope?: Scope;
|
|
28
|
-
/**
|
|
29
|
-
* Flags provider as durable. This flag can be used in combination with custom context id
|
|
30
|
-
* factory strategy to construct lazy DI subtrees.
|
|
31
|
-
*
|
|
32
|
-
* This flag can be used only in conjunction with scope = Scope.REQUEST.
|
|
33
|
-
*/
|
|
34
|
-
durable?: boolean;
|
|
35
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Scope = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
var Scope;
|
|
8
|
-
(function (Scope) {
|
|
9
|
-
/**
|
|
10
|
-
* The provider can be shared across multiple classes. The provider lifetime
|
|
11
|
-
* is strictly tied to the application lifecycle. Once the application has
|
|
12
|
-
* bootstrapped, all providers have been instantiated.
|
|
13
|
-
*/
|
|
14
|
-
Scope[Scope["DEFAULT"] = 0] = "DEFAULT";
|
|
15
|
-
/**
|
|
16
|
-
* A new private instance of the provider is instantiated for every use
|
|
17
|
-
*/
|
|
18
|
-
Scope[Scope["TRANSIENT"] = 1] = "TRANSIENT";
|
|
19
|
-
/**
|
|
20
|
-
* A new instance is instantiated for each request processing pipeline
|
|
21
|
-
*/
|
|
22
|
-
Scope[Scope["REQUEST"] = 2] = "REQUEST";
|
|
23
|
-
})(Scope || (exports.Scope = Scope = {}));
|
package/metadata-scanner.d.ts
DELETED
package/metadata-scanner.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetadataScanner = void 0;
|
|
4
|
-
const shared_helper_1 = require("@venok/core/helpers/shared.helper");
|
|
5
|
-
class MetadataScanner {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.cachedScannedPrototypes = new Map();
|
|
8
|
-
}
|
|
9
|
-
getAllMethodNames(prototype) {
|
|
10
|
-
if (!prototype)
|
|
11
|
-
return [];
|
|
12
|
-
if (this.cachedScannedPrototypes.has(prototype)) {
|
|
13
|
-
return this.cachedScannedPrototypes.get(prototype);
|
|
14
|
-
}
|
|
15
|
-
const visitedNames = new Map();
|
|
16
|
-
const result = [];
|
|
17
|
-
this.cachedScannedPrototypes.set(prototype, result);
|
|
18
|
-
do {
|
|
19
|
-
for (const property of Object.getOwnPropertyNames(prototype)) {
|
|
20
|
-
if (visitedNames.has(property))
|
|
21
|
-
continue;
|
|
22
|
-
visitedNames.set(property, true);
|
|
23
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, property);
|
|
24
|
-
if (descriptor?.set || descriptor?.get)
|
|
25
|
-
continue;
|
|
26
|
-
if ((0, shared_helper_1.isConstructor)(property) || !(0, shared_helper_1.isFunction)(prototype[property]))
|
|
27
|
-
continue;
|
|
28
|
-
result.push(property);
|
|
29
|
-
}
|
|
30
|
-
} while ((prototype = Reflect.getPrototypeOf(prototype)) && prototype !== Object.prototype);
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.MetadataScanner = MetadataScanner;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from "@venok/core/module/constants";
|
|
2
|
-
import { DynamicModule } from "@venok/core/interfaces";
|
|
3
|
-
import { Logger } from "@venok/core/services/logger.service";
|
|
4
|
-
import { ConfigurableModuleHost } from "@venok/core/interfaces/modules/configurable";
|
|
5
|
-
/**
|
|
6
|
-
* @publicApi
|
|
7
|
-
*/
|
|
8
|
-
export interface ConfigurableModuleBuilderOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Specified what injection token should be used for the module options provider.
|
|
11
|
-
* By default, an auto-generated UUID will be used.
|
|
12
|
-
*/
|
|
13
|
-
optionsInjectionToken?: string | symbol;
|
|
14
|
-
/**
|
|
15
|
-
* By default, a UUID will be used as a module options provider token.
|
|
16
|
-
* Explicitly specifying the "moduleName" will instruct the "ConfigurableModuleBuilder"
|
|
17
|
-
* to use a more descriptive provider token.
|
|
18
|
-
*
|
|
19
|
-
* For example, if `moduleName: "Cache"` then auto-generated provider token will be "CACHE_MODULE_OPTIONS".
|
|
20
|
-
*/
|
|
21
|
-
moduleName?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Indicates whether module should always be "transient", meaning,
|
|
24
|
-
* every time you call the static method to construct a dynamic module,
|
|
25
|
-
* regardless of what arguments you pass in, a new "unique" module will be created.
|
|
26
|
-
*
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
alwaysTransient?: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Factory that lets you create configurable module and
|
|
33
|
-
* provides a way to reduce the majority of dynamic module boilerplate.
|
|
34
|
-
*
|
|
35
|
-
* @publicApi
|
|
36
|
-
*/
|
|
37
|
-
export declare class ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> {
|
|
38
|
-
protected readonly options: ConfigurableModuleBuilderOptions;
|
|
39
|
-
protected staticMethodKey: StaticMethodKey;
|
|
40
|
-
protected factoryClassMethodKey: FactoryClassMethodKey;
|
|
41
|
-
protected extras: ExtraModuleDefinitionOptions;
|
|
42
|
-
protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule;
|
|
43
|
-
protected readonly logger: Logger;
|
|
44
|
-
constructor(options?: ConfigurableModuleBuilderOptions, parentBuilder?: ConfigurableModuleBuilder<ModuleOptions>);
|
|
45
|
-
/**
|
|
46
|
-
* Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
|
47
|
-
* Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
|
|
48
|
-
*
|
|
49
|
-
* This method also applies the so-called "module definition transform function" that takes the auto-generated
|
|
50
|
-
* dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
|
51
|
-
* The "extras" object consists of values explicitly specified by module consumers and default values.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
|
56
|
-
* ({ ...definition, global: extras.isGlobal })
|
|
57
|
-
* )
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
setExtras<ExtraModuleDefinitionOptions>(extras: ExtraModuleDefinitionOptions, transformDefinition?: (definition: DynamicModule, extras: ExtraModuleDefinitionOptions) => DynamicModule): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
61
|
-
/**
|
|
62
|
-
* Dynamic module must expose public static methods that let you pass in
|
|
63
|
-
* configuration parameters (control the module's behavior from the outside).
|
|
64
|
-
* Some frequently used names that you may have seen in other module are:
|
|
65
|
-
* "forRoot", "forFeature", "register", "configure".
|
|
66
|
-
*
|
|
67
|
-
* This method "setClassMethodName" lets you specify the name of the
|
|
68
|
-
* method that will be auto-generated.
|
|
69
|
-
*
|
|
70
|
-
* @param key name of the method
|
|
71
|
-
*/
|
|
72
|
-
setClassMethodName<StaticMethodKey extends string>(key: StaticMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
73
|
-
/**
|
|
74
|
-
* Asynchronously configured module (that rely on other module, i.e. "ConfigModule")
|
|
75
|
-
* let you pass the configuration factory class that will be registered and instantiated as a provider.
|
|
76
|
-
* This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
|
77
|
-
* the corresponding factory method must be implemented.
|
|
78
|
-
*
|
|
79
|
-
* This method ("setFactoryMethodName") lets you control what method name will have to be
|
|
80
|
-
* implemented by the config factory (default is "create").
|
|
81
|
-
*
|
|
82
|
-
* @param key name of the method
|
|
83
|
-
*/
|
|
84
|
-
setFactoryMethodName<FactoryClassMethodKey extends string>(key: FactoryClassMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
85
|
-
/**
|
|
86
|
-
* Returns an object consisting of multiple properties that lets you
|
|
87
|
-
* easily construct dynamic configurable module. See "ConfigurableModuleHost" interface for more details.
|
|
88
|
-
*/
|
|
89
|
-
build(): ConfigurableModuleHost<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
|
90
|
-
private constructInjectionTokenString;
|
|
91
|
-
private createConfigurableModuleCls;
|
|
92
|
-
private createTypeProxy;
|
|
93
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfigurableModuleBuilder = void 0;
|
|
4
|
-
const constants_1 = require("@venok/core/module/constants");
|
|
5
|
-
const logger_service_1 = require("@venok/core/services/logger.service");
|
|
6
|
-
const helpers_1 = require("@venok/core/module/helpers");
|
|
7
|
-
const random_string_generator_helper_1 = require("@venok/core/helpers/random-string-generator.helper");
|
|
8
|
-
/**
|
|
9
|
-
* Factory that lets you create configurable module and
|
|
10
|
-
* provides a way to reduce the majority of dynamic module boilerplate.
|
|
11
|
-
*
|
|
12
|
-
* @publicApi
|
|
13
|
-
*/
|
|
14
|
-
class ConfigurableModuleBuilder {
|
|
15
|
-
constructor(options = {}, parentBuilder) {
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.logger = new logger_service_1.Logger(ConfigurableModuleBuilder.name);
|
|
18
|
-
if (parentBuilder) {
|
|
19
|
-
this.staticMethodKey = parentBuilder.staticMethodKey;
|
|
20
|
-
this.factoryClassMethodKey = parentBuilder.factoryClassMethodKey;
|
|
21
|
-
this.transformModuleDefinition = parentBuilder.transformModuleDefinition;
|
|
22
|
-
this.extras = parentBuilder.extras;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
|
27
|
-
* Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
|
|
28
|
-
*
|
|
29
|
-
* This method also applies the so-called "module definition transform function" that takes the auto-generated
|
|
30
|
-
* dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
|
31
|
-
* The "extras" object consists of values explicitly specified by module consumers and default values.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
|
36
|
-
* ({ ...definition, global: extras.isGlobal })
|
|
37
|
-
* )
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
setExtras(extras, transformDefinition = (def) => def) {
|
|
41
|
-
const builder = new ConfigurableModuleBuilder(this.options, this);
|
|
42
|
-
builder.extras = extras;
|
|
43
|
-
builder.transformModuleDefinition = transformDefinition;
|
|
44
|
-
return builder;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Dynamic module must expose public static methods that let you pass in
|
|
48
|
-
* configuration parameters (control the module's behavior from the outside).
|
|
49
|
-
* Some frequently used names that you may have seen in other module are:
|
|
50
|
-
* "forRoot", "forFeature", "register", "configure".
|
|
51
|
-
*
|
|
52
|
-
* This method "setClassMethodName" lets you specify the name of the
|
|
53
|
-
* method that will be auto-generated.
|
|
54
|
-
*
|
|
55
|
-
* @param key name of the method
|
|
56
|
-
*/
|
|
57
|
-
setClassMethodName(key) {
|
|
58
|
-
const builder = new ConfigurableModuleBuilder(this.options, this);
|
|
59
|
-
builder.staticMethodKey = key;
|
|
60
|
-
return builder;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Asynchronously configured module (that rely on other module, i.e. "ConfigModule")
|
|
64
|
-
* let you pass the configuration factory class that will be registered and instantiated as a provider.
|
|
65
|
-
* This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
|
66
|
-
* the corresponding factory method must be implemented.
|
|
67
|
-
*
|
|
68
|
-
* This method ("setFactoryMethodName") lets you control what method name will have to be
|
|
69
|
-
* implemented by the config factory (default is "create").
|
|
70
|
-
*
|
|
71
|
-
* @param key name of the method
|
|
72
|
-
*/
|
|
73
|
-
setFactoryMethodName(key) {
|
|
74
|
-
const builder = new ConfigurableModuleBuilder(this.options, this);
|
|
75
|
-
builder.factoryClassMethodKey = key;
|
|
76
|
-
return builder;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns an object consisting of multiple properties that lets you
|
|
80
|
-
* easily construct dynamic configurable module. See "ConfigurableModuleHost" interface for more details.
|
|
81
|
-
*/
|
|
82
|
-
build() {
|
|
83
|
-
this.staticMethodKey ??= constants_1.DEFAULT_METHOD_KEY;
|
|
84
|
-
this.factoryClassMethodKey ??= constants_1.DEFAULT_FACTORY_CLASS_METHOD_KEY;
|
|
85
|
-
this.options.optionsInjectionToken ??= this.options.moduleName
|
|
86
|
-
? this.constructInjectionTokenString()
|
|
87
|
-
: (0, helpers_1.generateOptionsInjectionToken)();
|
|
88
|
-
this.transformModuleDefinition ??= (definition) => definition;
|
|
89
|
-
return {
|
|
90
|
-
ConfigurableModuleClass: this.createConfigurableModuleCls(),
|
|
91
|
-
MODULE_OPTIONS_TOKEN: this.options.optionsInjectionToken,
|
|
92
|
-
ASYNC_OPTIONS_TYPE: this.createTypeProxy("ASYNC_OPTIONS_TYPE"),
|
|
93
|
-
OPTIONS_TYPE: this.createTypeProxy("OPTIONS_TYPE"),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
constructInjectionTokenString() {
|
|
97
|
-
const moduleNameInSnakeCase = (this.options.moduleName ?? (0, random_string_generator_helper_1.randomStringGenerator)())
|
|
98
|
-
.trim()
|
|
99
|
-
.split(/(?=[A-Z])/)
|
|
100
|
-
.join("_")
|
|
101
|
-
.toUpperCase();
|
|
102
|
-
return `${moduleNameInSnakeCase}_MODULE_OPTIONS`;
|
|
103
|
-
}
|
|
104
|
-
createConfigurableModuleCls() {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
106
|
-
const self = this;
|
|
107
|
-
const asyncMethodKey = this.staticMethodKey + constants_1.ASYNC_METHOD_SUFFIX;
|
|
108
|
-
class InternalModuleClass {
|
|
109
|
-
static [self.staticMethodKey](options) {
|
|
110
|
-
const providers = [
|
|
111
|
-
{
|
|
112
|
-
provide: self.options.optionsInjectionToken,
|
|
113
|
-
useValue: this.omitExtras(options, self.extras),
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
if (self.options.alwaysTransient) {
|
|
117
|
-
providers.push({
|
|
118
|
-
provide: constants_1.CONFIGURABLE_MODULE_ID,
|
|
119
|
-
useValue: (0, random_string_generator_helper_1.randomStringGenerator)(),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return self.transformModuleDefinition({
|
|
123
|
-
module: this,
|
|
124
|
-
providers,
|
|
125
|
-
}, {
|
|
126
|
-
...self.extras,
|
|
127
|
-
...options,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
static [asyncMethodKey](options) {
|
|
131
|
-
const providers = this.createAsyncProviders(options);
|
|
132
|
-
if (self.options.alwaysTransient) {
|
|
133
|
-
providers.push({
|
|
134
|
-
provide: constants_1.CONFIGURABLE_MODULE_ID,
|
|
135
|
-
useValue: (0, random_string_generator_helper_1.randomStringGenerator)(),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return self.transformModuleDefinition({
|
|
139
|
-
module: this,
|
|
140
|
-
imports: options.imports || [],
|
|
141
|
-
providers,
|
|
142
|
-
}, {
|
|
143
|
-
...self.extras,
|
|
144
|
-
...options,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
static omitExtras(input, extras) {
|
|
148
|
-
if (!extras)
|
|
149
|
-
return input;
|
|
150
|
-
const moduleOptions = {};
|
|
151
|
-
const extrasKeys = Object.keys(extras);
|
|
152
|
-
Object.keys(input)
|
|
153
|
-
.filter((key) => !extrasKeys.includes(key))
|
|
154
|
-
.forEach((key) => {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
moduleOptions[key] = input[key];
|
|
157
|
-
});
|
|
158
|
-
return moduleOptions;
|
|
159
|
-
}
|
|
160
|
-
static createAsyncProviders(options) {
|
|
161
|
-
if (options.useExisting || options.useFactory) {
|
|
162
|
-
if (options.inject && options.provideInjectionTokensFrom) {
|
|
163
|
-
return [
|
|
164
|
-
this.createAsyncOptionsProvider(options),
|
|
165
|
-
...(0, helpers_1.getInjectionProviders)(options.provideInjectionTokensFrom, options.inject),
|
|
166
|
-
];
|
|
167
|
-
}
|
|
168
|
-
return [this.createAsyncOptionsProvider(options)];
|
|
169
|
-
}
|
|
170
|
-
return [
|
|
171
|
-
this.createAsyncOptionsProvider(options),
|
|
172
|
-
{
|
|
173
|
-
provide: options.useClass,
|
|
174
|
-
useClass: options.useClass,
|
|
175
|
-
},
|
|
176
|
-
];
|
|
177
|
-
}
|
|
178
|
-
static createAsyncOptionsProvider(options) {
|
|
179
|
-
if (options.useFactory) {
|
|
180
|
-
return {
|
|
181
|
-
provide: self.options.optionsInjectionToken,
|
|
182
|
-
useFactory: options.useFactory,
|
|
183
|
-
inject: options.inject || [],
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
provide: self.options.optionsInjectionToken,
|
|
188
|
-
useFactory: async (optionsFactory) => await optionsFactory[self.factoryClassMethodKey](),
|
|
189
|
-
inject: [options.useExisting || options.useClass],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return InternalModuleClass;
|
|
194
|
-
}
|
|
195
|
-
createTypeProxy(typeName) {
|
|
196
|
-
const proxy = new Proxy({}, {
|
|
197
|
-
get: () => {
|
|
198
|
-
throw new Error(`"${typeName}" is not supposed to be used as a value.`);
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
return proxy;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
exports.ConfigurableModuleBuilder = ConfigurableModuleBuilder;
|
package/module/constants.d.ts
DELETED
package/module/constants.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONFIGURABLE_MODULE_ID = exports.ASYNC_METHOD_SUFFIX = exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = exports.DEFAULT_METHOD_KEY = void 0;
|
|
4
|
-
exports.DEFAULT_METHOD_KEY = 'register';
|
|
5
|
-
exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = 'create';
|
|
6
|
-
exports.ASYNC_METHOD_SUFFIX = 'Async';
|
|
7
|
-
exports.CONFIGURABLE_MODULE_ID = 'CONFIGURABLE_MODULE_ID';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateOptionsInjectionToken(): string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateOptionsInjectionToken = void 0;
|
|
4
|
-
const random_string_generator_helper_1 = require("@venok/core/helpers/random-string-generator.helper");
|
|
5
|
-
function generateOptionsInjectionToken() {
|
|
6
|
-
const hash = (0, random_string_generator_helper_1.randomStringGenerator)();
|
|
7
|
-
return `CONFIGURABLE_MODULE_OPTIONS[${hash}]`;
|
|
8
|
-
}
|
|
9
|
-
exports.generateOptionsInjectionToken = generateOptionsInjectionToken;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FactoryProvider, Provider } from "@venok/core/interfaces";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param providers List of a module's providers
|
|
5
|
-
* @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
|
|
6
|
-
* @returns All the providers needed for the tokens' injection (searched recursively)
|
|
7
|
-
*/
|
|
8
|
-
export declare function getInjectionProviders(providers: Provider[], tokens: FactoryProvider["inject"]): Provider[];
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInjectionProviders = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* check if x is OptionalFactoryDependency, based on prototype presence
|
|
6
|
-
* (to avoid classes with a static 'token' field)
|
|
7
|
-
* @param x
|
|
8
|
-
* @returns x is OptionalFactoryDependency
|
|
9
|
-
*/
|
|
10
|
-
function isOptionalFactoryDependency(x) {
|
|
11
|
-
return !!(x?.token && !x?.prototype);
|
|
12
|
-
}
|
|
13
|
-
const mapInjectToTokens = (t) => isOptionalFactoryDependency(t) ? t.token : t;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param providers List of a module's providers
|
|
17
|
-
* @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
|
|
18
|
-
* @returns All the providers needed for the tokens' injection (searched recursively)
|
|
19
|
-
*/
|
|
20
|
-
function getInjectionProviders(providers, tokens) {
|
|
21
|
-
const result = [];
|
|
22
|
-
let search = tokens.map(mapInjectToTokens);
|
|
23
|
-
while (search.length > 0) {
|
|
24
|
-
const match = (providers ?? []).filter((p) => !result.includes(p) && // this prevents circular loops and duplication
|
|
25
|
-
(search.includes(p) || search.includes(p?.provide)));
|
|
26
|
-
result.push(...match);
|
|
27
|
-
// get injection tokens of the matched providers, if any
|
|
28
|
-
search = match
|
|
29
|
-
.filter((p) => p?.inject)
|
|
30
|
-
.map((p) => p.inject)
|
|
31
|
-
.flat()
|
|
32
|
-
.map(mapInjectToTokens);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
exports.getInjectionProviders = getInjectionProviders;
|
package/module/helpers/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./generate-options-injection-token.helper"), exports);
|
|
18
|
-
__exportStar(require("./get-injection-providers.helper"), exports);
|
package/module/index.d.ts
DELETED