@nestjs/core 11.1.16 → 12.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/http-adapter.d.ts +5 -3
- package/adapters/http-adapter.js +8 -5
- package/adapters/index.d.ts +1 -1
- package/adapters/index.js +1 -4
- package/application-config.d.ts +7 -4
- package/application-config.js +20 -15
- package/constants.d.ts +1 -1
- package/constants.js +10 -13
- package/discovery/discoverable-meta-host-collection.d.ts +3 -3
- package/discovery/discoverable-meta-host-collection.js +15 -19
- package/discovery/discovery-module.js +9 -12
- package/discovery/discovery-service.d.ts +4 -4
- package/discovery/discovery-service.js +17 -19
- package/discovery/index.d.ts +2 -2
- package/discovery/index.js +2 -5
- package/errors/exception-handler.js +3 -7
- package/errors/exceptions/circular-dependency.exception.d.ts +1 -1
- package/errors/exceptions/circular-dependency.exception.js +2 -6
- package/errors/exceptions/index.d.ts +8 -8
- package/errors/exceptions/index.js +8 -11
- package/errors/exceptions/invalid-class-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class-module.exception.js +4 -8
- package/errors/exceptions/invalid-class-scope.exception.d.ts +2 -2
- package/errors/exceptions/invalid-class-scope.exception.js +6 -10
- package/errors/exceptions/invalid-class.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class.exception.js +4 -8
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +1 -1
- package/errors/exceptions/invalid-exception-filter.exception.js +4 -8
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware-configuration.exception.js +4 -8
- package/errors/exceptions/invalid-middleware.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +4 -8
- package/errors/exceptions/invalid-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-module.exception.js +4 -8
- package/errors/exceptions/runtime.exception.js +1 -5
- package/errors/exceptions/undefined-dependency.exception.d.ts +3 -3
- package/errors/exceptions/undefined-dependency.exception.js +4 -8
- package/errors/exceptions/undefined-forwardref.exception.d.ts +2 -2
- package/errors/exceptions/undefined-forwardref.exception.js +4 -8
- package/errors/exceptions/undefined-module.exception.d.ts +1 -1
- package/errors/exceptions/undefined-module.exception.js +4 -8
- package/errors/exceptions/unknown-dependencies.exception.d.ts +3 -3
- package/errors/exceptions/unknown-dependencies.exception.js +8 -8
- package/errors/exceptions/unknown-element.exception.d.ts +1 -1
- package/errors/exceptions/unknown-element.exception.js +2 -6
- package/errors/exceptions/unknown-export.exception.d.ts +1 -1
- package/errors/exceptions/unknown-export.exception.js +4 -8
- package/errors/exceptions/unknown-module.exception.d.ts +1 -1
- package/errors/exceptions/unknown-module.exception.js +2 -6
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +1 -1
- package/errors/exceptions/unknown-request-mapping.exception.js +4 -8
- package/errors/exceptions-zone.js +6 -10
- package/errors/messages.d.ts +2 -2
- package/errors/messages.js +20 -36
- package/exceptions/base-exception-filter-context.d.ts +6 -7
- package/exceptions/base-exception-filter-context.js +13 -16
- package/exceptions/base-exception-filter.d.ts +4 -4
- package/exceptions/base-exception-filter.js +33 -23
- package/exceptions/exceptions-handler.d.ts +4 -4
- package/exceptions/exceptions-handler.js +8 -16
- package/exceptions/external-exception-filter-context.d.ts +8 -8
- package/exceptions/external-exception-filter-context.js +14 -18
- package/exceptions/external-exception-filter.d.ts +1 -1
- package/exceptions/external-exception-filter.js +4 -8
- package/exceptions/external-exceptions-handler.d.ts +3 -3
- package/exceptions/external-exceptions-handler.js +8 -16
- package/exceptions/index.d.ts +1 -1
- package/exceptions/index.js +1 -4
- package/guards/constants.js +1 -4
- package/guards/guards-consumer.d.ts +4 -3
- package/guards/guards-consumer.js +8 -12
- package/guards/guards-context-creator.d.ts +11 -10
- package/guards/guards-context-creator.js +18 -20
- package/guards/index.d.ts +3 -3
- package/guards/index.js +3 -6
- package/helpers/barrier.js +5 -5
- package/helpers/context-creator.d.ts +2 -2
- package/helpers/context-creator.js +3 -7
- package/helpers/context-id-factory.d.ts +1 -1
- package/helpers/context-id-factory.js +10 -14
- package/helpers/context-utils.d.ts +6 -3
- package/helpers/context-utils.js +7 -12
- package/helpers/execution-context-host.d.ts +3 -3
- package/helpers/execution-context-host.js +5 -6
- package/helpers/external-context-creator.d.ts +15 -18
- package/helpers/external-context-creator.js +54 -43
- package/helpers/external-proxy.d.ts +2 -2
- package/helpers/external-proxy.js +3 -7
- package/helpers/get-class-scope.d.ts +2 -2
- package/helpers/get-class-scope.js +3 -6
- package/helpers/handler-metadata-storage.d.ts +4 -4
- package/helpers/handler-metadata-storage.js +7 -15
- package/helpers/http-adapter-host.d.ts +1 -1
- package/helpers/http-adapter-host.js +6 -11
- package/helpers/index.d.ts +3 -3
- package/helpers/index.js +3 -6
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +2 -2
- package/helpers/interfaces/external-handler-metadata.interface.js +1 -2
- package/helpers/interfaces/index.d.ts +2 -2
- package/helpers/interfaces/index.js +2 -5
- package/helpers/interfaces/params-metadata.interface.d.ts +1 -1
- package/helpers/interfaces/params-metadata.interface.js +1 -2
- package/helpers/is-durable.d.ts +1 -1
- package/helpers/is-durable.js +3 -6
- package/helpers/load-adapter.d.ts +1 -1
- package/helpers/load-adapter.js +4 -7
- package/helpers/messages.d.ts +1 -1
- package/helpers/messages.js +10 -20
- package/helpers/optional-require.d.ts +1 -1
- package/helpers/optional-require.js +2 -5
- package/helpers/rethrow.js +1 -5
- package/helpers/router-method-factory.d.ts +2 -2
- package/helpers/router-method-factory.js +20 -24
- package/hooks/before-app-shutdown.hook.d.ts +3 -3
- package/hooks/before-app-shutdown.hook.js +15 -22
- package/hooks/index.d.ts +5 -5
- package/hooks/index.js +5 -8
- package/hooks/on-app-bootstrap.hook.d.ts +3 -3
- package/hooks/on-app-bootstrap.hook.js +15 -22
- package/hooks/on-app-shutdown.hook.d.ts +3 -3
- package/hooks/on-app-shutdown.hook.js +15 -22
- package/hooks/on-module-destroy.hook.d.ts +3 -3
- package/hooks/on-module-destroy.hook.js +15 -22
- package/hooks/on-module-init.hook.d.ts +3 -3
- package/hooks/on-module-init.hook.js +15 -22
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
- package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
- package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
- package/index.d.ts +16 -16
- package/index.js +17 -26
- package/injector/abstract-instance-resolver.d.ts +6 -6
- package/injector/abstract-instance-resolver.js +7 -11
- package/injector/compiler.d.ts +2 -2
- package/injector/compiler.js +2 -5
- package/injector/constants.d.ts +1 -1
- package/injector/constants.js +2 -5
- package/injector/container.d.ts +13 -14
- package/injector/container.js +40 -40
- package/injector/helpers/provider-classifier.d.ts +1 -1
- package/injector/helpers/provider-classifier.js +5 -10
- package/injector/helpers/silent-logger.js +9 -16
- package/injector/index.d.ts +6 -6
- package/injector/index.js +5 -8
- package/injector/injector.d.ts +7 -6
- package/injector/injector.js +78 -78
- package/injector/inquirer/index.d.ts +1 -1
- package/injector/inquirer/index.js +1 -4
- package/injector/inquirer/inquirer-constants.js +1 -4
- package/injector/inquirer/inquirer-providers.d.ts +1 -1
- package/injector/inquirer/inquirer-providers.js +5 -8
- package/injector/instance-links-host.d.ts +3 -3
- package/injector/instance-links-host.js +8 -11
- package/injector/instance-loader.d.ts +5 -5
- package/injector/instance-loader.js +11 -11
- package/injector/instance-wrapper.d.ts +8 -5
- package/injector/instance-wrapper.js +93 -74
- package/injector/internal-core-module/index.d.ts +1 -1
- package/injector/internal-core-module/index.js +1 -4
- package/injector/internal-core-module/internal-core-module-factory.d.ts +6 -6
- package/injector/internal-core-module/internal-core-module-factory.js +23 -27
- package/injector/internal-core-module/internal-core-module.d.ts +2 -2
- package/injector/internal-core-module/internal-core-module.js +17 -20
- package/injector/internal-providers-storage.d.ts +2 -2
- package/injector/internal-providers-storage.js +4 -9
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +1 -2
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +8 -8
- package/injector/lazy-module-loader/lazy-module-loader.js +10 -9
- package/injector/module-ref.d.ts +7 -7
- package/injector/module-ref.js +19 -20
- package/injector/module.d.ts +5 -5
- package/injector/module.js +93 -79
- package/injector/modules-container.d.ts +1 -1
- package/injector/modules-container.js +5 -12
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +2 -4
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +6 -9
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +2 -3
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +17 -22
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +1 -3
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +1 -2
- package/injector/settlement-signal.js +5 -7
- package/injector/topology-tree/topology-tree.d.ts +1 -1
- package/injector/topology-tree/topology-tree.js +6 -9
- package/injector/topology-tree/tree-node.js +4 -6
- package/inspector/deterministic-uuid-registry.js +2 -6
- package/inspector/graph-inspector.d.ts +7 -7
- package/inspector/graph-inspector.js +10 -12
- package/inspector/index.d.ts +4 -4
- package/inspector/index.js +4 -7
- package/inspector/initialize-on-preview.allowlist.d.ts +1 -1
- package/inspector/initialize-on-preview.allowlist.js +2 -6
- package/inspector/interfaces/edge.interface.d.ts +1 -1
- package/inspector/interfaces/edge.interface.js +1 -2
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +3 -3
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +1 -2
- package/inspector/interfaces/entrypoint.interface.d.ts +2 -2
- package/inspector/interfaces/entrypoint.interface.js +1 -2
- package/inspector/interfaces/extras.interface.d.ts +1 -1
- package/inspector/interfaces/extras.interface.js +1 -2
- package/inspector/interfaces/node.interface.d.ts +2 -2
- package/inspector/interfaces/node.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +6 -6
- package/inspector/interfaces/serialized-graph-json.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +1 -1
- package/inspector/interfaces/serialized-graph-metadata.interface.js +1 -2
- package/inspector/noop-graph-inspector.d.ts +1 -1
- package/inspector/noop-graph-inspector.js +2 -5
- package/inspector/partial-graph.host.d.ts +2 -2
- package/inspector/partial-graph.host.js +2 -5
- package/inspector/serialized-graph.d.ts +7 -7
- package/inspector/serialized-graph.js +35 -40
- package/inspector/uuid-factory.js +8 -12
- package/interceptors/index.d.ts +2 -2
- package/interceptors/index.js +2 -5
- package/interceptors/interceptors-consumer.d.ts +4 -3
- package/interceptors/interceptors-consumer.js +13 -17
- package/interceptors/interceptors-context-creator.d.ts +10 -9
- package/interceptors/interceptors-context-creator.js +18 -20
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +2 -2
- package/interfaces/module-definition.interface.js +1 -2
- package/interfaces/module-override.interface.d.ts +1 -1
- package/interfaces/module-override.interface.js +1 -2
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +1 -1
- package/metadata-scanner.js +8 -14
- package/middleware/builder.d.ts +4 -4
- package/middleware/builder.js +78 -76
- package/middleware/container.d.ts +4 -4
- package/middleware/container.js +10 -13
- package/middleware/index.d.ts +1 -1
- package/middleware/index.js +1 -4
- package/middleware/middleware-module.d.ts +8 -9
- package/middleware/middleware-module.js +47 -44
- package/middleware/resolver.d.ts +3 -3
- package/middleware/resolver.js +3 -5
- package/middleware/route-info-path-extractor.d.ts +2 -2
- package/middleware/route-info-path-extractor.js +26 -25
- package/middleware/routes-mapper.d.ts +4 -3
- package/middleware/routes-mapper.js +22 -24
- package/middleware/utils.d.ts +3 -2
- package/middleware/utils.js +34 -45
- package/nest-application-context.d.ts +10 -9
- package/nest-application-context.js +50 -47
- package/nest-application.d.ts +18 -10
- package/nest-application.js +87 -55
- package/nest-factory.d.ts +4 -5
- package/nest-factory.js +61 -68
- package/package.json +32 -3
- package/pipes/index.d.ts +3 -3
- package/pipes/index.js +3 -6
- package/pipes/params-token-factory.d.ts +2 -2
- package/pipes/params-token-factory.js +5 -9
- package/pipes/pipes-consumer.d.ts +3 -7
- package/pipes/pipes-consumer.js +17 -18
- package/pipes/pipes-context-creator.d.ts +10 -9
- package/pipes/pipes-context-creator.js +18 -20
- package/repl/assign-to-object.util.js +1 -4
- package/repl/constants.js +1 -4
- package/repl/index.d.ts +1 -1
- package/repl/index.js +1 -4
- package/repl/native-functions/debug-repl-fn.d.ts +2 -2
- package/repl/native-functions/debug-repl-fn.js +14 -21
- package/repl/native-functions/get-repl-fn.d.ts +2 -2
- package/repl/native-functions/get-repl-fn.js +8 -15
- package/repl/native-functions/help-repl-fn.d.ts +2 -2
- package/repl/native-functions/help-repl-fn.js +13 -20
- package/repl/native-functions/index.d.ts +6 -6
- package/repl/native-functions/index.js +6 -9
- package/repl/native-functions/methods-repl-fn.d.ts +2 -2
- package/repl/native-functions/methods-repl-fn.js +12 -19
- package/repl/native-functions/resolve-repl-fn.d.ts +2 -2
- package/repl/native-functions/resolve-repl-fn.js +7 -14
- package/repl/native-functions/select-relp-fn.d.ts +2 -2
- package/repl/native-functions/select-relp-fn.js +7 -14
- package/repl/repl-context.d.ts +3 -3
- package/repl/repl-context.js +21 -23
- package/repl/repl-function.d.ts +3 -3
- package/repl/repl-function.js +5 -7
- package/repl/repl-logger.js +10 -14
- package/repl/repl-native-commands.js +1 -4
- package/repl/repl.d.ts +1 -1
- package/repl/repl.interfaces.d.ts +2 -2
- package/repl/repl.interfaces.js +1 -2
- package/repl/repl.js +17 -20
- package/router/index.d.ts +3 -3
- package/router/index.js +3 -8
- package/router/interfaces/exceptions-filter.interface.d.ts +3 -3
- package/router/interfaces/exceptions-filter.interface.js +1 -2
- package/router/interfaces/exclude-route-metadata.interface.d.ts +1 -1
- package/router/interfaces/exclude-route-metadata.interface.js +1 -2
- package/router/interfaces/index.d.ts +1 -1
- package/router/interfaces/index.js +1 -4
- package/router/interfaces/resolver.interface.js +1 -2
- package/router/interfaces/route-params-factory.interface.d.ts +1 -1
- package/router/interfaces/route-params-factory.interface.js +1 -2
- package/router/interfaces/route-path-metadata.interface.d.ts +2 -2
- package/router/interfaces/route-path-metadata.interface.js +1 -2
- package/router/interfaces/routes.interface.d.ts +1 -1
- package/router/interfaces/routes.interface.js +1 -2
- package/router/legacy-route-converter.js +3 -7
- package/router/paths-explorer.d.ts +4 -5
- package/router/paths-explorer.js +11 -15
- package/router/request/index.d.ts +1 -1
- package/router/request/index.js +1 -5
- package/router/request/request-constants.js +2 -5
- package/router/request/request-providers.d.ts +1 -1
- package/router/request/request-providers.js +5 -8
- package/router/route-params-factory.d.ts +2 -2
- package/router/route-params-factory.js +15 -19
- package/router/route-path-factory.d.ts +4 -4
- package/router/route-path-factory.js +19 -22
- package/router/router-exception-filters.d.ts +9 -9
- package/router/router-exception-filters.js +15 -18
- package/router/router-execution-context.d.ts +17 -20
- package/router/router-execution-context.js +57 -49
- package/router/router-explorer.d.ts +14 -16
- package/router/router-explorer.js +55 -54
- package/router/router-module.d.ts +4 -4
- package/router/router-module.js +21 -23
- package/router/router-proxy.d.ts +1 -1
- package/router/router-proxy.js +4 -8
- package/router/router-response-controller.d.ts +2 -2
- package/router/router-response-controller.js +20 -23
- package/router/routes-resolver.d.ts +8 -9
- package/router/routes-resolver.js +36 -51
- package/router/sse-stream.d.ts +1 -1
- package/router/sse-stream.js +5 -9
- package/router/utils/exclude-route.util.d.ts +1 -1
- package/router/utils/exclude-route.util.js +7 -12
- package/router/utils/flatten-route-paths.util.d.ts +2 -2
- package/router/utils/flatten-route-paths.util.js +4 -7
- package/router/utils/index.d.ts +2 -2
- package/router/utils/index.js +2 -5
- package/scanner.d.ts +11 -11
- package/scanner.js +64 -65
- package/services/index.d.ts +1 -1
- package/services/index.js +1 -4
- package/services/reflector.service.d.ts +1 -1
- package/services/reflector.service.js +9 -13
- package/tsconfig.build.json +1 -9
package/nest-factory.js
CHANGED
|
@@ -1,47 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const uuid_factory_1 = require("./inspector/uuid-factory");
|
|
19
|
-
const metadata_scanner_1 = require("./metadata-scanner");
|
|
20
|
-
const nest_application_1 = require("./nest-application");
|
|
21
|
-
const nest_application_context_1 = require("./nest-application-context");
|
|
22
|
-
const scanner_1 = require("./scanner");
|
|
1
|
+
import { ApplicationConfig } from './application-config.js';
|
|
2
|
+
import { MESSAGES } from './constants.js';
|
|
3
|
+
import { ExceptionsZone } from './errors/exceptions-zone.js';
|
|
4
|
+
import { loadAdapter } from './helpers/load-adapter.js';
|
|
5
|
+
import { rethrow } from './helpers/rethrow.js';
|
|
6
|
+
import { NestContainer } from './injector/container.js';
|
|
7
|
+
import { Injector } from './injector/injector.js';
|
|
8
|
+
import { InstanceLoader } from './injector/instance-loader.js';
|
|
9
|
+
import { GraphInspector } from './inspector/graph-inspector.js';
|
|
10
|
+
import { NoopGraphInspector } from './inspector/noop-graph-inspector.js';
|
|
11
|
+
import { UuidFactory, UuidFactoryMode } from './inspector/uuid-factory.js';
|
|
12
|
+
import { MetadataScanner } from './metadata-scanner.js';
|
|
13
|
+
import { NestApplicationContext } from './nest-application-context.js';
|
|
14
|
+
import { NestApplication } from './nest-application.js';
|
|
15
|
+
import { DependenciesScanner } from './scanner.js';
|
|
16
|
+
import { loadPackage, isFunction, isNil, } from '@nestjs/common/internal';
|
|
17
|
+
import { ConsoleLogger, Logger, } from '@nestjs/common';
|
|
23
18
|
/**
|
|
24
19
|
* @publicApi
|
|
25
20
|
*/
|
|
26
|
-
class NestFactoryStatic {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.autoFlushLogs = false;
|
|
33
|
-
}
|
|
21
|
+
export class NestFactoryStatic {
|
|
22
|
+
logger = new Logger('NestFactory', {
|
|
23
|
+
timestamp: true,
|
|
24
|
+
});
|
|
25
|
+
abortOnError = true;
|
|
26
|
+
autoFlushLogs = false;
|
|
34
27
|
async create(moduleCls, serverOrOptions, options) {
|
|
35
28
|
const [httpServer, appOptions] = this.isHttpServer(serverOrOptions)
|
|
36
29
|
? [serverOrOptions, options]
|
|
37
|
-
: [this.createHttpAdapter(), serverOrOptions];
|
|
38
|
-
const applicationConfig = new
|
|
39
|
-
const container = new
|
|
30
|
+
: [await this.createHttpAdapter(), serverOrOptions];
|
|
31
|
+
const applicationConfig = new ApplicationConfig();
|
|
32
|
+
const container = new NestContainer(applicationConfig, appOptions);
|
|
40
33
|
const graphInspector = this.createGraphInspector(appOptions, container);
|
|
41
34
|
this.setAbortOnError(serverOrOptions, options);
|
|
42
35
|
this.registerLoggerConfiguration(appOptions);
|
|
43
36
|
await this.initialize(moduleCls, container, graphInspector, applicationConfig, appOptions, httpServer);
|
|
44
|
-
const instance = new
|
|
37
|
+
const instance = new NestApplication(container, httpServer, applicationConfig, graphInspector, appOptions);
|
|
38
|
+
await instance.preloadLazyPackages();
|
|
45
39
|
const target = this.createNestInstance(instance);
|
|
46
40
|
return this.createAdapterProxy(target, httpServer);
|
|
47
41
|
}
|
|
@@ -55,9 +49,9 @@ class NestFactoryStatic {
|
|
|
55
49
|
* contains a reference to the NestMicroservice instance.
|
|
56
50
|
*/
|
|
57
51
|
async createMicroservice(moduleCls, options) {
|
|
58
|
-
const { NestMicroservice } =
|
|
59
|
-
const applicationConfig = new
|
|
60
|
-
const container = new
|
|
52
|
+
const { NestMicroservice } = await loadPackage('@nestjs/microservices', 'NestFactory', () => import('@nestjs/microservices'));
|
|
53
|
+
const applicationConfig = new ApplicationConfig();
|
|
54
|
+
const container = new NestContainer(applicationConfig, options);
|
|
61
55
|
const graphInspector = this.createGraphInspector(options, container);
|
|
62
56
|
this.setAbortOnError(options);
|
|
63
57
|
this.registerLoggerConfiguration(options);
|
|
@@ -74,15 +68,15 @@ class NestFactoryStatic {
|
|
|
74
68
|
* contains a reference to the NestApplicationContext instance.
|
|
75
69
|
*/
|
|
76
70
|
async createApplicationContext(moduleCls, options) {
|
|
77
|
-
const applicationConfig = new
|
|
78
|
-
const container = new
|
|
71
|
+
const applicationConfig = new ApplicationConfig();
|
|
72
|
+
const container = new NestContainer(applicationConfig, options);
|
|
79
73
|
const graphInspector = this.createGraphInspector(options, container);
|
|
80
74
|
this.setAbortOnError(options);
|
|
81
75
|
this.registerLoggerConfiguration(options);
|
|
82
76
|
await this.initialize(moduleCls, container, graphInspector, applicationConfig, options);
|
|
83
77
|
const modules = container.getModules().values();
|
|
84
78
|
const root = modules.next().value;
|
|
85
|
-
const context = this.createNestInstance(new
|
|
79
|
+
const context = this.createNestInstance(new NestApplicationContext(container, options, root));
|
|
86
80
|
if (this.autoFlushLogs) {
|
|
87
81
|
context.flushLogsOnOverride();
|
|
88
82
|
}
|
|
@@ -91,23 +85,23 @@ class NestFactoryStatic {
|
|
|
91
85
|
createNestInstance(instance) {
|
|
92
86
|
return this.createProxy(instance);
|
|
93
87
|
}
|
|
94
|
-
async initialize(module, container, graphInspector, config = new
|
|
95
|
-
|
|
96
|
-
?
|
|
97
|
-
:
|
|
98
|
-
const injector = new
|
|
88
|
+
async initialize(module, container, graphInspector, config = new ApplicationConfig(), options = {}, httpServer = null) {
|
|
89
|
+
UuidFactory.mode = options.snapshot
|
|
90
|
+
? UuidFactoryMode.Deterministic
|
|
91
|
+
: UuidFactoryMode.Random;
|
|
92
|
+
const injector = new Injector({
|
|
99
93
|
preview: options.preview,
|
|
100
94
|
instanceDecorator: options.instrument?.instanceDecorator,
|
|
101
95
|
});
|
|
102
|
-
const instanceLoader = new
|
|
103
|
-
const metadataScanner = new
|
|
104
|
-
const dependenciesScanner = new
|
|
96
|
+
const instanceLoader = new InstanceLoader(container, injector, graphInspector);
|
|
97
|
+
const metadataScanner = new MetadataScanner();
|
|
98
|
+
const dependenciesScanner = new DependenciesScanner(container, metadataScanner, graphInspector, config);
|
|
105
99
|
container.setHttpAdapter(httpServer);
|
|
106
|
-
const teardown = this.abortOnError === false ?
|
|
100
|
+
const teardown = this.abortOnError === false ? rethrow : undefined;
|
|
107
101
|
await httpServer?.init?.();
|
|
108
102
|
try {
|
|
109
|
-
this.logger.log(
|
|
110
|
-
await
|
|
103
|
+
this.logger.log(MESSAGES.APPLICATION_START);
|
|
104
|
+
await ExceptionsZone.asyncRun(async () => {
|
|
111
105
|
await dependenciesScanner.scan(module);
|
|
112
106
|
await instanceLoader.createInstancesOfDependencies();
|
|
113
107
|
dependenciesScanner.applyApplicationProviders();
|
|
@@ -121,7 +115,7 @@ class NestFactoryStatic {
|
|
|
121
115
|
if (this.abortOnError) {
|
|
122
116
|
process.abort();
|
|
123
117
|
}
|
|
124
|
-
|
|
118
|
+
rethrow(err);
|
|
125
119
|
}
|
|
126
120
|
createProxy(target) {
|
|
127
121
|
const proxy = this.createExceptionProxy();
|
|
@@ -135,17 +129,17 @@ class NestFactoryStatic {
|
|
|
135
129
|
if (!(prop in receiver)) {
|
|
136
130
|
return;
|
|
137
131
|
}
|
|
138
|
-
if (
|
|
132
|
+
if (isFunction(receiver[prop])) {
|
|
139
133
|
return this.createExceptionZone(receiver, prop);
|
|
140
134
|
}
|
|
141
135
|
return receiver[prop];
|
|
142
136
|
};
|
|
143
137
|
}
|
|
144
138
|
createExceptionZone(receiver, prop) {
|
|
145
|
-
const teardown = this.abortOnError === false ?
|
|
139
|
+
const teardown = this.abortOnError === false ? rethrow : undefined;
|
|
146
140
|
return (...args) => {
|
|
147
141
|
let result;
|
|
148
|
-
|
|
142
|
+
ExceptionsZone.run(() => {
|
|
149
143
|
result = receiver[prop](...args);
|
|
150
144
|
}, teardown, this.autoFlushLogs);
|
|
151
145
|
return result;
|
|
@@ -156,22 +150,22 @@ class NestFactoryStatic {
|
|
|
156
150
|
return;
|
|
157
151
|
}
|
|
158
152
|
const { logger, bufferLogs, autoFlushLogs, forceConsole } = options;
|
|
159
|
-
if (logger !== true && !
|
|
160
|
-
|
|
153
|
+
if (logger !== true && !isNil(logger)) {
|
|
154
|
+
Logger.overrideLogger(logger);
|
|
161
155
|
}
|
|
162
156
|
else if (forceConsole) {
|
|
163
157
|
// If no custom logger is provided but forceConsole is true,
|
|
164
158
|
// create a ConsoleLogger with forceConsole option
|
|
165
|
-
const consoleLogger = new
|
|
166
|
-
|
|
159
|
+
const consoleLogger = new ConsoleLogger({ forceConsole: true });
|
|
160
|
+
Logger.overrideLogger(consoleLogger);
|
|
167
161
|
}
|
|
168
162
|
if (bufferLogs) {
|
|
169
|
-
|
|
163
|
+
Logger.attachBuffer();
|
|
170
164
|
}
|
|
171
165
|
this.autoFlushLogs = autoFlushLogs ?? true;
|
|
172
166
|
}
|
|
173
|
-
createHttpAdapter(httpServer) {
|
|
174
|
-
const { ExpressAdapter } =
|
|
167
|
+
async createHttpAdapter(httpServer) {
|
|
168
|
+
const { ExpressAdapter } = await loadAdapter('@nestjs/platform-express', 'HTTP', () => import('@nestjs/platform-express'));
|
|
175
169
|
return new ExpressAdapter(httpServer);
|
|
176
170
|
}
|
|
177
171
|
isHttpServer(serverOrOptions) {
|
|
@@ -188,7 +182,7 @@ class NestFactoryStatic {
|
|
|
188
182
|
const mapToProxy = (result) => {
|
|
189
183
|
return result instanceof Promise
|
|
190
184
|
? result.then(mapToProxy)
|
|
191
|
-
: result instanceof
|
|
185
|
+
: result instanceof NestApplication
|
|
192
186
|
? proxy
|
|
193
187
|
: result;
|
|
194
188
|
};
|
|
@@ -198,7 +192,7 @@ class NestFactoryStatic {
|
|
|
198
192
|
return mapToProxy(result);
|
|
199
193
|
};
|
|
200
194
|
}
|
|
201
|
-
if (
|
|
195
|
+
if (isFunction(receiver[prop])) {
|
|
202
196
|
return (...args) => {
|
|
203
197
|
const result = receiver[prop](...args);
|
|
204
198
|
return mapToProxy(result);
|
|
@@ -211,11 +205,10 @@ class NestFactoryStatic {
|
|
|
211
205
|
}
|
|
212
206
|
createGraphInspector(appOptions, container) {
|
|
213
207
|
return appOptions?.snapshot
|
|
214
|
-
? new
|
|
215
|
-
:
|
|
208
|
+
? new GraphInspector(container)
|
|
209
|
+
: NoopGraphInspector;
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
|
-
exports.NestFactoryStatic = NestFactoryStatic;
|
|
219
212
|
/**
|
|
220
213
|
* Use NestFactory to create an application instance.
|
|
221
214
|
*
|
|
@@ -229,4 +222,4 @@ exports.NestFactoryStatic = NestFactoryStatic;
|
|
|
229
222
|
*
|
|
230
223
|
* @publicApi
|
|
231
224
|
*/
|
|
232
|
-
|
|
225
|
+
export const NestFactory = new NestFactoryStatic();
|
package/package.json
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0-alpha.0",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./*.js": "./*.js",
|
|
12
|
+
"./*": "./*.js",
|
|
13
|
+
"./adapters": "./adapters/index.js",
|
|
14
|
+
"./discovery": "./discovery/index.js",
|
|
15
|
+
"./errors/exceptions": "./errors/exceptions/index.js",
|
|
16
|
+
"./exceptions": "./exceptions/index.js",
|
|
17
|
+
"./guards": "./guards/index.js",
|
|
18
|
+
"./helpers": "./helpers/index.js",
|
|
19
|
+
"./helpers/interfaces": "./helpers/interfaces/index.js",
|
|
20
|
+
"./hooks": "./hooks/index.js",
|
|
21
|
+
"./injector": "./injector/index.js",
|
|
22
|
+
"./injector/inquirer": "./injector/inquirer/index.js",
|
|
23
|
+
"./injector/internal-core-module": "./injector/internal-core-module/index.js",
|
|
24
|
+
"./inspector": "./inspector/index.js",
|
|
25
|
+
"./interceptors": "./interceptors/index.js",
|
|
26
|
+
"./middleware": "./middleware/index.js",
|
|
27
|
+
"./pipes": "./pipes/index.js",
|
|
28
|
+
"./repl": "./repl/index.js",
|
|
29
|
+
"./repl/native-functions": "./repl/native-functions/index.js",
|
|
30
|
+
"./router": "./router/index.js",
|
|
31
|
+
"./router/interfaces": "./router/interfaces/index.js",
|
|
32
|
+
"./router/request": "./router/request/index.js",
|
|
33
|
+
"./router/utils": "./router/utils/index.js",
|
|
34
|
+
"./services": "./services/index.js"
|
|
35
|
+
},
|
|
7
36
|
"homepage": "https://nestjs.com",
|
|
8
37
|
"funding": {
|
|
9
38
|
"type": "opencollective",
|
|
@@ -39,7 +68,7 @@
|
|
|
39
68
|
"uid": "2.0.2"
|
|
40
69
|
},
|
|
41
70
|
"devDependencies": {
|
|
42
|
-
"@nestjs/common": "
|
|
71
|
+
"@nestjs/common": "^12.0.0-alpha.0"
|
|
43
72
|
},
|
|
44
73
|
"peerDependencies": {
|
|
45
74
|
"@nestjs/common": "^11.0.0",
|
|
@@ -60,5 +89,5 @@
|
|
|
60
89
|
"optional": true
|
|
61
90
|
}
|
|
62
91
|
},
|
|
63
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "7035ecc828a2a9f752aad188871b1171663a20c2"
|
|
64
93
|
}
|
package/pipes/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './params-token-factory';
|
|
2
|
-
export * from './pipes-consumer';
|
|
3
|
-
export * from './pipes-context-creator';
|
|
1
|
+
export * from './params-token-factory.js';
|
|
2
|
+
export * from './pipes-consumer.js';
|
|
3
|
+
export * from './pipes-context-creator.js';
|
package/pipes/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./params-token-factory"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./pipes-consumer"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./pipes-context-creator"), exports);
|
|
1
|
+
export * from './params-token-factory.js';
|
|
2
|
+
export * from './pipes-consumer.js';
|
|
3
|
+
export * from './pipes-context-creator.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Paramtype } from '@nestjs/common';
|
|
2
|
-
import { RouteParamtypes } from '@nestjs/common/
|
|
1
|
+
import type { Paramtype } from '@nestjs/common';
|
|
2
|
+
import { RouteParamtypes } from '@nestjs/common/internal';
|
|
3
3
|
export declare class ParamsTokenFactory {
|
|
4
4
|
exchangeEnumForString(type: RouteParamtypes): Paramtype;
|
|
5
5
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ParamsTokenFactory = void 0;
|
|
4
|
-
const route_paramtypes_enum_1 = require("@nestjs/common/enums/route-paramtypes.enum");
|
|
5
|
-
class ParamsTokenFactory {
|
|
1
|
+
import { RouteParamtypes } from '@nestjs/common/internal';
|
|
2
|
+
export class ParamsTokenFactory {
|
|
6
3
|
exchangeEnumForString(type) {
|
|
7
4
|
switch (type) {
|
|
8
|
-
case
|
|
5
|
+
case RouteParamtypes.BODY:
|
|
9
6
|
return 'body';
|
|
10
|
-
case
|
|
7
|
+
case RouteParamtypes.PARAM:
|
|
11
8
|
return 'param';
|
|
12
|
-
case
|
|
9
|
+
case RouteParamtypes.QUERY:
|
|
13
10
|
return 'query';
|
|
14
11
|
default:
|
|
15
12
|
return 'custom';
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.ParamsTokenFactory = ParamsTokenFactory;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { ArgumentMetadata, PipeTransform } from '@nestjs/common
|
|
1
|
+
import type { ArgumentMetadata, PipeTransform } from '@nestjs/common';
|
|
2
2
|
export declare class PipesConsumer {
|
|
3
3
|
private readonly paramsTokenFactory;
|
|
4
|
-
apply<TInput = unknown>(value: TInput,
|
|
5
|
-
applyPipes<TInput = unknown>(value: TInput, { metatype, type, data }:
|
|
6
|
-
metatype: any;
|
|
7
|
-
type?: any;
|
|
8
|
-
data?: any;
|
|
9
|
-
}, transforms: PipeTransform[]): Promise<any>;
|
|
4
|
+
apply<TInput = unknown>(value: TInput, metadata: ArgumentMetadata, pipes: PipeTransform[]): Promise<unknown>;
|
|
5
|
+
applyPipes<TInput = unknown>(value: TInput, { metatype, type, data, schema }: ArgumentMetadata, transforms: PipeTransform[]): Promise<unknown>;
|
|
10
6
|
}
|
package/pipes/pipes-consumer.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ParamsTokenFactory } from './params-token-factory.js';
|
|
2
|
+
export class PipesConsumer {
|
|
3
|
+
paramsTokenFactory = new ParamsTokenFactory();
|
|
4
|
+
async apply(value, metadata, pipes) {
|
|
5
|
+
const token = this.paramsTokenFactory.exchangeEnumForString(metadata.type);
|
|
6
|
+
return this.applyPipes(value, {
|
|
7
|
+
metatype: metadata.metatype,
|
|
8
|
+
type: token,
|
|
9
|
+
data: metadata.data,
|
|
10
|
+
schema: metadata.schema,
|
|
11
|
+
}, pipes);
|
|
8
12
|
}
|
|
9
|
-
async
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
const val = await deferredValue;
|
|
16
|
-
const result = pipe.transform(val, { metatype, type, data });
|
|
17
|
-
return result;
|
|
18
|
-
}, Promise.resolve(value));
|
|
13
|
+
async applyPipes(value, { metatype, type, data, schema }, transforms) {
|
|
14
|
+
let result = value;
|
|
15
|
+
for (const pipe of transforms) {
|
|
16
|
+
result = await pipe.transform(result, { metatype, type, data, schema });
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.PipesConsumer = PipesConsumer;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { ApplicationConfig } from '../application-config.js';
|
|
2
|
+
import { ContextCreator } from '../helpers/context-creator.js';
|
|
3
|
+
import { NestContainer } from '../injector/container.js';
|
|
4
|
+
import { InstanceWrapper } from '../injector/instance-wrapper.js';
|
|
5
|
+
import { type Controller } from '@nestjs/common/internal';
|
|
6
|
+
import type { PipeTransform, Type } from '@nestjs/common';
|
|
6
7
|
export declare class PipesContextCreator extends ContextCreator {
|
|
7
8
|
private readonly container;
|
|
8
9
|
private readonly config?;
|
|
9
10
|
private moduleContext;
|
|
10
11
|
constructor(container: NestContainer, config?: ApplicationConfig | undefined);
|
|
11
|
-
create(instance: Controller, callback: (...args: unknown[]) => unknown, moduleKey: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): PipeTransform[];
|
|
12
|
-
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
|
|
13
|
-
getPipeInstance(pipe: Function | PipeTransform, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): PipeTransform | null;
|
|
12
|
+
create(instance: Controller, callback: (...args: unknown[]) => unknown, moduleKey: string, contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): PipeTransform[];
|
|
13
|
+
createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): R;
|
|
14
|
+
getPipeInstance(pipe: Function | PipeTransform, contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): PipeTransform | null;
|
|
14
15
|
getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
|
|
15
|
-
getGlobalMetadata<T extends unknown[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
|
|
16
|
+
getGlobalMetadata<T extends unknown[]>(contextId?: import("../injector/instance-wrapper.js").ContextId, inquirerId?: string): T;
|
|
16
17
|
setModuleContext(context: string): void;
|
|
17
18
|
}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class PipesContextCreator extends context_creator_1.ContextCreator {
|
|
1
|
+
import { iterate } from 'iterare';
|
|
2
|
+
import { ContextCreator } from '../helpers/context-creator.js';
|
|
3
|
+
import { STATIC_CONTEXT } from '../injector/constants.js';
|
|
4
|
+
import { PIPES_METADATA, isEmpty, isFunction, } from '@nestjs/common/internal';
|
|
5
|
+
export class PipesContextCreator extends ContextCreator {
|
|
6
|
+
container;
|
|
7
|
+
config;
|
|
8
|
+
moduleContext;
|
|
10
9
|
constructor(container, config) {
|
|
11
10
|
super();
|
|
12
11
|
this.container = container;
|
|
13
12
|
this.config = config;
|
|
14
13
|
}
|
|
15
|
-
create(instance, callback, moduleKey, contextId =
|
|
14
|
+
create(instance, callback, moduleKey, contextId = STATIC_CONTEXT, inquirerId) {
|
|
16
15
|
this.moduleContext = moduleKey;
|
|
17
|
-
return this.createContext(instance, callback,
|
|
16
|
+
return this.createContext(instance, callback, PIPES_METADATA, contextId, inquirerId);
|
|
18
17
|
}
|
|
19
|
-
createConcreteContext(metadata, contextId =
|
|
20
|
-
if (
|
|
18
|
+
createConcreteContext(metadata, contextId = STATIC_CONTEXT, inquirerId) {
|
|
19
|
+
if (isEmpty(metadata)) {
|
|
21
20
|
return [];
|
|
22
21
|
}
|
|
23
|
-
return
|
|
22
|
+
return iterate(metadata)
|
|
24
23
|
.filter((pipe) => pipe && (pipe.name || pipe.transform))
|
|
25
24
|
.map(pipe => this.getPipeInstance(pipe, contextId, inquirerId))
|
|
26
|
-
.filter(pipe => !!pipe && pipe.transform &&
|
|
25
|
+
.filter(pipe => !!pipe && pipe.transform && isFunction(pipe.transform))
|
|
27
26
|
.toArray();
|
|
28
27
|
}
|
|
29
|
-
getPipeInstance(pipe, contextId =
|
|
28
|
+
getPipeInstance(pipe, contextId = STATIC_CONTEXT, inquirerId) {
|
|
30
29
|
const isObject = !!pipe.transform;
|
|
31
30
|
if (isObject) {
|
|
32
31
|
return pipe;
|
|
@@ -49,16 +48,16 @@ class PipesContextCreator extends context_creator_1.ContextCreator {
|
|
|
49
48
|
}
|
|
50
49
|
return moduleRef.injectables.get(metatype);
|
|
51
50
|
}
|
|
52
|
-
getGlobalMetadata(contextId =
|
|
51
|
+
getGlobalMetadata(contextId = STATIC_CONTEXT, inquirerId) {
|
|
53
52
|
if (!this.config) {
|
|
54
53
|
return [];
|
|
55
54
|
}
|
|
56
55
|
const globalPipes = this.config.getGlobalPipes();
|
|
57
|
-
if (contextId ===
|
|
56
|
+
if (contextId === STATIC_CONTEXT && !inquirerId) {
|
|
58
57
|
return globalPipes;
|
|
59
58
|
}
|
|
60
59
|
const scopedPipeWrappers = this.config.getGlobalRequestPipes();
|
|
61
|
-
const scopedPipes =
|
|
60
|
+
const scopedPipes = iterate(scopedPipeWrappers)
|
|
62
61
|
.map(wrapper => wrapper.getInstanceByContextId(this.getContextId(contextId, wrapper), inquirerId))
|
|
63
62
|
.filter(host => !!host)
|
|
64
63
|
.map(host => host.instance)
|
|
@@ -69,4 +68,3 @@ class PipesContextCreator extends context_creator_1.ContextCreator {
|
|
|
69
68
|
this.moduleContext = context;
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
exports.PipesContextCreator = PipesContextCreator;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assignToObject = assignToObject;
|
|
4
1
|
/**
|
|
5
2
|
* Similar to `Object.assign` but copying properties descriptors from `source`
|
|
6
3
|
* as well.
|
|
7
4
|
*/
|
|
8
|
-
function assignToObject(target, source) {
|
|
5
|
+
export function assignToObject(target, source) {
|
|
9
6
|
Object.defineProperties(target, Object.keys(source).reduce((descriptors, key) => {
|
|
10
7
|
descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
|
|
11
8
|
return descriptors;
|
package/repl/constants.js
CHANGED
package/repl/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './repl';
|
|
1
|
+
export * from './repl.js';
|
package/repl/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Type } from '@nestjs/common';
|
|
2
|
-
import { ReplFunction } from '../repl-function';
|
|
3
|
-
import type { ReplFnDefinition } from '../repl.interfaces';
|
|
2
|
+
import { ReplFunction } from '../repl-function.js';
|
|
3
|
+
import type { ReplFnDefinition } from '../repl.interfaces.js';
|
|
4
4
|
export declare class DebugReplFn extends ReplFunction {
|
|
5
5
|
fnDefinition: ReplFnDefinition;
|
|
6
6
|
action(moduleCls?: Type<unknown> | string): void;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.fnDefinition = {
|
|
10
|
-
name: 'debug',
|
|
11
|
-
description: 'Print all registered modules as a list together with their controllers and providers.\nIf the argument is passed in, for example, "debug(MyModule)" then it will only print components of this specific module.',
|
|
12
|
-
signature: '(moduleCls?: ClassRef | string) => void',
|
|
13
|
-
};
|
|
14
|
-
}
|
|
1
|
+
import { ReplFunction } from '../repl-function.js';
|
|
2
|
+
import { clc } from '@nestjs/common/internal';
|
|
3
|
+
export class DebugReplFn extends ReplFunction {
|
|
4
|
+
fnDefinition = {
|
|
5
|
+
name: 'debug',
|
|
6
|
+
description: 'Print all registered modules as a list together with their controllers and providers.\nIf the argument is passed in, for example, "debug(MyModule)" then it will only print components of this specific module.',
|
|
7
|
+
signature: '(moduleCls?: ClassRef | string) => void',
|
|
8
|
+
};
|
|
15
9
|
action(moduleCls) {
|
|
16
10
|
this.ctx.writeToStdout('\n');
|
|
17
11
|
if (moduleCls) {
|
|
@@ -23,14 +17,14 @@ class DebugReplFn extends repl_function_1.ReplFunction {
|
|
|
23
17
|
this.printCtrlsAndProviders(token, moduleEntry);
|
|
24
18
|
}
|
|
25
19
|
else {
|
|
26
|
-
Object.
|
|
27
|
-
this.printCtrlsAndProviders(moduleKey,
|
|
28
|
-
}
|
|
20
|
+
for (const [moduleKey, entry] of Object.entries(this.ctx.debugRegistry)) {
|
|
21
|
+
this.printCtrlsAndProviders(moduleKey, entry);
|
|
22
|
+
}
|
|
29
23
|
}
|
|
30
24
|
this.ctx.writeToStdout('\n');
|
|
31
25
|
}
|
|
32
26
|
printCtrlsAndProviders(moduleName, moduleDebugEntry) {
|
|
33
|
-
this.ctx.writeToStdout(`${
|
|
27
|
+
this.ctx.writeToStdout(`${clc.green(moduleName)}:\n`);
|
|
34
28
|
this.printCollection('controllers', moduleDebugEntry['controllers']);
|
|
35
29
|
this.printCollection('providers', moduleDebugEntry['providers']);
|
|
36
30
|
}
|
|
@@ -39,8 +33,7 @@ class DebugReplFn extends repl_function_1.ReplFunction {
|
|
|
39
33
|
if (collectionEntries.length <= 0) {
|
|
40
34
|
return;
|
|
41
35
|
}
|
|
42
|
-
this.ctx.writeToStdout(` ${
|
|
43
|
-
collectionEntries.forEach(provider => this.ctx.writeToStdout(` ${
|
|
36
|
+
this.ctx.writeToStdout(` ${clc.yellow(`- ${title}`)}:\n`);
|
|
37
|
+
collectionEntries.forEach(provider => this.ctx.writeToStdout(` ${clc.green('◻')} ${provider}\n`));
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
|
-
exports.DebugReplFn = DebugReplFn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Type } from '@nestjs/common';
|
|
2
|
-
import { ReplFunction } from '../repl-function';
|
|
3
|
-
import type { ReplFnDefinition } from '../repl.interfaces';
|
|
2
|
+
import { ReplFunction } from '../repl-function.js';
|
|
3
|
+
import type { ReplFnDefinition } from '../repl.interfaces.js';
|
|
4
4
|
export declare class GetReplFn extends ReplFunction {
|
|
5
5
|
fnDefinition: ReplFnDefinition;
|
|
6
6
|
action(token: string | symbol | Function | Type<any>): any;
|