@depup/nestjs__core 11.1.17-depup.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/LICENSE +22 -0
- package/PACKAGE.md +1 -0
- package/README.md +25 -0
- package/Readme.md +146 -0
- package/adapters/http-adapter.d.ts +80 -0
- package/adapters/http-adapter.js +90 -0
- package/adapters/index.d.ts +1 -0
- package/adapters/index.js +4 -0
- package/application-config.d.ts +47 -0
- package/application-config.js +107 -0
- package/changes.json +5 -0
- package/constants.d.ts +14 -0
- package/constants.js +21 -0
- package/discovery/discoverable-meta-host-collection.d.ts +46 -0
- package/discovery/discoverable-meta-host-collection.js +98 -0
- package/discovery/discovery-module.d.ts +5 -0
- package/discovery/discovery-module.js +19 -0
- package/discovery/discovery-service.d.ts +76 -0
- package/discovery/discovery-service.js +98 -0
- package/discovery/index.d.ts +2 -0
- package/discovery/index.js +5 -0
- package/errors/exception-handler.d.ts +4 -0
- package/errors/exception-handler.js +11 -0
- package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
- package/errors/exceptions/circular-dependency.exception.js +11 -0
- package/errors/exceptions/index.d.ts +8 -0
- package/errors/exceptions/index.js +11 -0
- package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class-module.exception.js +11 -0
- package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
- package/errors/exceptions/invalid-class-scope.exception.js +16 -0
- package/errors/exceptions/invalid-class.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class.exception.js +11 -0
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
- package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.js +11 -0
- package/errors/exceptions/invalid-middleware.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware.exception.js +11 -0
- package/errors/exceptions/invalid-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-module.exception.js +11 -0
- package/errors/exceptions/runtime.exception.d.ts +4 -0
- package/errors/exceptions/runtime.exception.js +12 -0
- package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
- package/errors/exceptions/undefined-dependency.exception.js +11 -0
- package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
- package/errors/exceptions/undefined-forwardref.exception.js +11 -0
- package/errors/exceptions/undefined-module.exception.d.ts +4 -0
- package/errors/exceptions/undefined-module.exception.js +11 -0
- package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
- package/errors/exceptions/unknown-dependencies.exception.js +15 -0
- package/errors/exceptions/unknown-element.exception.d.ts +4 -0
- package/errors/exceptions/unknown-element.exception.js +11 -0
- package/errors/exceptions/unknown-export.exception.d.ts +4 -0
- package/errors/exceptions/unknown-export.exception.js +11 -0
- package/errors/exceptions/unknown-module.exception.d.ts +4 -0
- package/errors/exceptions/unknown-module.exception.js +10 -0
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +5 -0
- package/errors/exceptions/unknown-request-mapping.exception.js +11 -0
- package/errors/exceptions-zone.d.ts +5 -0
- package/errors/exceptions-zone.js +34 -0
- package/errors/messages.d.ts +17 -0
- package/errors/messages.js +174 -0
- package/exceptions/base-exception-filter-context.d.ts +14 -0
- package/exceptions/base-exception-filter-context.js +56 -0
- package/exceptions/base-exception-filter.d.ts +20 -0
- package/exceptions/base-exception-filter.js +72 -0
- package/exceptions/exceptions-handler.d.ts +10 -0
- package/exceptions/exceptions-handler.js +34 -0
- package/exceptions/external-exception-filter-context.d.ts +12 -0
- package/exceptions/external-exception-filter-context.js +42 -0
- package/exceptions/external-exception-filter.d.ts +5 -0
- package/exceptions/external-exception-filter.js +15 -0
- package/exceptions/external-exceptions-handler.d.ts +9 -0
- package/exceptions/external-exceptions-handler.js +34 -0
- package/exceptions/index.d.ts +1 -0
- package/exceptions/index.js +4 -0
- package/guards/constants.d.ts +1 -0
- package/guards/constants.js +4 -0
- package/guards/guards-consumer.d.ts +9 -0
- package/guards/guards-consumer.js +39 -0
- package/guards/guards-context-creator.d.ts +17 -0
- package/guards/guards-context-creator.js +70 -0
- package/guards/index.d.ts +3 -0
- package/guards/index.js +6 -0
- package/helpers/barrier.d.ts +30 -0
- package/helpers/barrier.js +46 -0
- package/helpers/context-creator.d.ts +10 -0
- package/helpers/context-creator.js +33 -0
- package/helpers/context-id-factory.d.ts +41 -0
- package/helpers/context-id-factory.js +67 -0
- package/helpers/context-utils.d.ts +23 -0
- package/helpers/context-utils.js +55 -0
- package/helpers/execution-context-host.d.ts +19 -0
- package/helpers/execution-context-host.js +50 -0
- package/helpers/external-context-creator.d.ts +51 -0
- package/helpers/external-context-creator.js +166 -0
- package/helpers/external-proxy.d.ts +5 -0
- package/helpers/external-proxy.js +19 -0
- package/helpers/get-class-scope.d.ts +3 -0
- package/helpers/get-class-scope.js +8 -0
- package/helpers/handler-metadata-storage.d.ts +27 -0
- package/helpers/handler-metadata-storage.js +26 -0
- package/helpers/http-adapter-host.d.ts +51 -0
- package/helpers/http-adapter-host.js +73 -0
- package/helpers/index.d.ts +3 -0
- package/helpers/index.js +6 -0
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +11 -0
- package/helpers/interfaces/external-handler-metadata.interface.js +2 -0
- package/helpers/interfaces/index.d.ts +2 -0
- package/helpers/interfaces/index.js +5 -0
- package/helpers/interfaces/params-metadata.interface.d.ts +6 -0
- package/helpers/interfaces/params-metadata.interface.js +2 -0
- package/helpers/is-durable.d.ts +2 -0
- package/helpers/is-durable.js +8 -0
- package/helpers/load-adapter.d.ts +1 -0
- package/helpers/load-adapter.js +15 -0
- package/helpers/messages.d.ts +7 -0
- package/helpers/messages.js +29 -0
- package/helpers/optional-require.d.ts +1 -0
- package/helpers/optional-require.js +11 -0
- package/helpers/rethrow.d.ts +1 -0
- package/helpers/rethrow.js +7 -0
- package/helpers/router-method-factory.d.ts +23 -0
- package/helpers/router-method-factory.js +33 -0
- package/hooks/before-app-shutdown.hook.d.ts +9 -0
- package/hooks/before-app-shutdown.hook.js +51 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +8 -0
- package/hooks/on-app-bootstrap.hook.d.ts +8 -0
- package/hooks/on-app-bootstrap.hook.js +53 -0
- package/hooks/on-app-shutdown.hook.d.ts +9 -0
- package/hooks/on-app-shutdown.hook.js +54 -0
- package/hooks/on-module-destroy.hook.d.ts +8 -0
- package/hooks/on-module-destroy.hook.js +53 -0
- package/hooks/on-module-init.hook.d.ts +8 -0
- package/hooks/on-module-init.hook.js +53 -0
- 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 +17 -0
- package/index.js +32 -0
- package/injector/abstract-instance-resolver.d.ts +16 -0
- package/injector/abstract-instance-resolver.js +49 -0
- package/injector/compiler.d.ts +18 -0
- package/injector/compiler.js +35 -0
- package/injector/constants.d.ts +3 -0
- package/injector/constants.js +8 -0
- package/injector/container.d.ts +67 -0
- package/injector/container.js +233 -0
- package/injector/helpers/provider-classifier.d.ts +4 -0
- package/injector/helpers/provider-classifier.js +16 -0
- package/injector/helpers/silent-logger.d.ts +10 -0
- package/injector/helpers/silent-logger.js +18 -0
- package/injector/helpers/transient-instances.d.ts +12 -0
- package/injector/helpers/transient-instances.js +28 -0
- package/injector/index.d.ts +6 -0
- package/injector/index.js +8 -0
- package/injector/injector.d.ts +104 -0
- package/injector/injector.js +554 -0
- package/injector/inquirer/index.d.ts +1 -0
- package/injector/inquirer/index.js +4 -0
- package/injector/inquirer/inquirer-constants.d.ts +1 -0
- package/injector/inquirer/inquirer-constants.js +4 -0
- package/injector/inquirer/inquirer-providers.d.ts +2 -0
- package/injector/inquirer/inquirer-providers.js +11 -0
- package/injector/instance-links-host.d.ts +22 -0
- package/injector/instance-links-host.js +56 -0
- package/injector/instance-loader.d.ts +23 -0
- package/injector/instance-loader.js +88 -0
- package/injector/instance-wrapper.d.ts +99 -0
- package/injector/instance-wrapper.js +350 -0
- package/injector/internal-core-module/index.d.ts +1 -0
- package/injector/internal-core-module/index.js +4 -0
- package/injector/internal-core-module/internal-core-module-factory.d.ts +9 -0
- package/injector/internal-core-module/internal-core-module-factory.js +52 -0
- package/injector/internal-core-module/internal-core-module.d.ts +5 -0
- package/injector/internal-core-module/internal-core-module.js +40 -0
- package/injector/internal-providers-storage.d.ts +9 -0
- package/injector/internal-providers-storage.js +19 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.d.ts +6 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +2 -0
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +20 -0
- package/injector/lazy-module-loader/lazy-module-loader.js +49 -0
- package/injector/module-ref.d.ts +106 -0
- package/injector/module-ref.js +66 -0
- package/injector/module.d.ts +82 -0
- package/injector/module.js +432 -0
- package/injector/modules-container.d.ts +27 -0
- package/injector/modules-container.js +42 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +41 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +83 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +18 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +2 -0
- package/injector/settlement-signal.d.ts +37 -0
- package/injector/settlement-signal.js +55 -0
- package/injector/topology-tree/topology-tree.d.ts +8 -0
- package/injector/topology-tree/topology-tree.js +51 -0
- package/injector/topology-tree/tree-node.d.ts +14 -0
- package/injector/topology-tree/tree-node.js +54 -0
- package/inspector/deterministic-uuid-registry.d.ts +6 -0
- package/inspector/deterministic-uuid-registry.js +24 -0
- package/inspector/graph-inspector.d.ts +26 -0
- package/inspector/graph-inspector.js +166 -0
- package/inspector/index.d.ts +4 -0
- package/inspector/index.js +7 -0
- package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
- package/inspector/initialize-on-preview.allowlist.js +13 -0
- package/inspector/interfaces/edge.interface.d.ts +28 -0
- package/inspector/interfaces/edge.interface.js +2 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
- package/inspector/interfaces/entrypoint.interface.d.ts +23 -0
- package/inspector/interfaces/entrypoint.interface.js +2 -0
- package/inspector/interfaces/extras.interface.d.ts +18 -0
- package/inspector/interfaces/extras.interface.js +2 -0
- package/inspector/interfaces/node.interface.d.ts +48 -0
- package/inspector/interfaces/node.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
- package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
- package/inspector/noop-graph-inspector.d.ts +2 -0
- package/inspector/noop-graph-inspector.js +8 -0
- package/inspector/partial-graph.host.d.ts +7 -0
- package/inspector/partial-graph.host.js +15 -0
- package/inspector/serialized-graph.d.ts +52 -0
- package/inspector/serialized-graph.js +124 -0
- package/inspector/uuid-factory.d.ts +9 -0
- package/inspector/uuid-factory.js +22 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +5 -0
- package/interceptors/interceptors-consumer.d.ts +9 -0
- package/interceptors/interceptors-consumer.js +37 -0
- package/interceptors/interceptors-context-creator.d.ts +16 -0
- package/interceptors/interceptors-context-creator.js +69 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +3 -0
- package/interfaces/module-definition.interface.js +2 -0
- package/interfaces/module-override.interface.d.ts +5 -0
- package/interfaces/module-override.interface.js +2 -0
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +17 -0
- package/metadata-scanner.js +83 -0
- package/middleware/builder.d.ts +15 -0
- package/middleware/builder.js +91 -0
- package/middleware/container.d.ts +14 -0
- package/middleware/container.js +49 -0
- package/middleware/index.d.ts +1 -0
- package/middleware/index.js +4 -0
- package/middleware/middleware-module.d.ts +33 -0
- package/middleware/middleware-module.js +208 -0
- package/middleware/resolver.d.ts +10 -0
- package/middleware/resolver.js +18 -0
- package/middleware/route-info-path-extractor.d.ts +15 -0
- package/middleware/route-info-path-extractor.js +81 -0
- package/middleware/routes-mapper.d.ts +19 -0
- package/middleware/routes-mapper.js +117 -0
- package/middleware/utils.d.ts +8 -0
- package/middleware/utils.js +106 -0
- package/nest-application-context.d.ts +173 -0
- package/nest-application-context.js +327 -0
- package/nest-application.d.ts +64 -0
- package/nest-application.js +328 -0
- package/nest-factory.d.ts +83 -0
- package/nest-factory.js +232 -0
- package/package.json +73 -0
- package/pipes/index.d.ts +3 -0
- package/pipes/index.js +6 -0
- package/pipes/params-token-factory.d.ts +5 -0
- package/pipes/params-token-factory.js +19 -0
- package/pipes/pipes-consumer.d.ts +10 -0
- package/pipes/pipes-consumer.js +21 -0
- package/pipes/pipes-context-creator.d.ts +17 -0
- package/pipes/pipes-context-creator.js +72 -0
- package/repl/assign-to-object.util.d.ts +5 -0
- package/repl/assign-to-object.util.js +14 -0
- package/repl/constants.d.ts +1 -0
- package/repl/constants.js +4 -0
- package/repl/index.d.ts +1 -0
- package/repl/index.js +4 -0
- package/repl/native-functions/debug-repl-fn.d.ts +9 -0
- package/repl/native-functions/debug-repl-fn.js +46 -0
- package/repl/native-functions/get-repl-fn.d.ts +7 -0
- package/repl/native-functions/get-repl-fn.js +19 -0
- package/repl/native-functions/help-repl-fn.d.ts +7 -0
- package/repl/native-functions/help-repl-fn.js +29 -0
- package/repl/native-functions/index.d.ts +6 -0
- package/repl/native-functions/index.js +9 -0
- package/repl/native-functions/methods-repl-fn.d.ts +8 -0
- package/repl/native-functions/methods-repl-fn.js +28 -0
- package/repl/native-functions/resolve-repl-fn.d.ts +7 -0
- package/repl/native-functions/resolve-repl-fn.js +18 -0
- package/repl/native-functions/select-relp-fn.d.ts +7 -0
- package/repl/native-functions/select-relp-fn.js +18 -0
- package/repl/repl-context.d.ts +26 -0
- package/repl/repl-context.js +126 -0
- package/repl/repl-function.d.ts +18 -0
- package/repl/repl-function.js +19 -0
- package/repl/repl-logger.d.ts +5 -0
- package/repl/repl-logger.js +22 -0
- package/repl/repl-native-commands.d.ts +2 -0
- package/repl/repl-native-commands.js +46 -0
- package/repl/repl.d.ts +3 -0
- package/repl/repl.interfaces.d.ts +16 -0
- package/repl/repl.interfaces.js +2 -0
- package/repl/repl.js +32 -0
- package/router/index.d.ts +3 -0
- package/router/index.js +8 -0
- package/router/interfaces/exceptions-filter.interface.d.ts +6 -0
- package/router/interfaces/exceptions-filter.interface.js +2 -0
- package/router/interfaces/exclude-route-metadata.interface.d.ts +15 -0
- package/router/interfaces/exclude-route-metadata.interface.js +2 -0
- package/router/interfaces/index.d.ts +1 -0
- package/router/interfaces/index.js +4 -0
- package/router/interfaces/resolver.interface.d.ts +5 -0
- package/router/interfaces/resolver.interface.js +2 -0
- package/router/interfaces/route-params-factory.interface.d.ts +8 -0
- package/router/interfaces/route-params-factory.interface.js +2 -0
- package/router/interfaces/route-path-metadata.interface.d.ts +32 -0
- package/router/interfaces/route-path-metadata.interface.js +2 -0
- package/router/interfaces/routes.interface.d.ts +7 -0
- package/router/interfaces/routes.interface.js +2 -0
- package/router/legacy-route-converter.d.ts +16 -0
- package/router/legacy-route-converter.js +61 -0
- package/router/paths-explorer.d.ts +18 -0
- package/router/paths-explorer.js +45 -0
- package/router/request/index.d.ts +1 -0
- package/router/request/index.js +5 -0
- package/router/request/request-constants.d.ts +2 -0
- package/router/request/request-constants.js +5 -0
- package/router/request/request-providers.d.ts +2 -0
- package/router/request/request-providers.js +11 -0
- package/router/route-params-factory.d.ts +9 -0
- package/router/route-params-factory.js +41 -0
- package/router/route-path-factory.d.ts +14 -0
- package/router/route-path-factory.js +101 -0
- package/router/router-exception-filters.d.ts +14 -0
- package/router/router-exception-filters.js +40 -0
- package/router/router-execution-context.d.ts +54 -0
- package/router/router-execution-context.js +186 -0
- package/router/router-explorer.d.ts +47 -0
- package/router/router-explorer.js +234 -0
- package/router/router-module.d.ts +19 -0
- package/router/router-module.js +80 -0
- package/router/router-proxy.d.ts +6 -0
- package/router/router-proxy.js +31 -0
- package/router/router-response-controller.d.ts +28 -0
- package/router/router-response-controller.js +98 -0
- package/router/routes-resolver.d.ts +27 -0
- package/router/routes-resolver.js +129 -0
- package/router/sse-stream.d.ts +43 -0
- package/router/sse-stream.js +83 -0
- package/router/utils/exclude-route.util.d.ts +4 -0
- package/router/utils/exclude-route.util.js +19 -0
- package/router/utils/flatten-route-paths.util.d.ts +6 -0
- package/router/utils/flatten-route-paths.util.js +25 -0
- package/router/utils/index.d.ts +2 -0
- package/router/utils/index.js +5 -0
- package/scanner.d.ts +89 -0
- package/scanner.js +416 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +4 -0
- package/services/reflector.service.d.ts +111 -0
- package/services/reflector.service.js +100 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MessageEvent } from '@nestjs/common/interfaces';
|
|
2
|
+
import { IncomingMessage, OutgoingHttpHeaders } from 'http';
|
|
3
|
+
import { Transform } from 'stream';
|
|
4
|
+
export type AdditionalHeaders = Record<string, string[] | string | number | undefined>;
|
|
5
|
+
interface ReadHeaders {
|
|
6
|
+
getHeaders?(): AdditionalHeaders;
|
|
7
|
+
}
|
|
8
|
+
interface WriteHeaders {
|
|
9
|
+
writableEnded?: boolean;
|
|
10
|
+
writeHead?(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
|
|
11
|
+
writeHead?(statusCode: number, headers?: OutgoingHttpHeaders): void;
|
|
12
|
+
flushHeaders?(): void;
|
|
13
|
+
}
|
|
14
|
+
export type WritableHeaderStream = NodeJS.WritableStream & WriteHeaders;
|
|
15
|
+
export type HeaderStream = WritableHeaderStream & ReadHeaders;
|
|
16
|
+
/**
|
|
17
|
+
* Adapted from https://raw.githubusercontent.com/EventSource/node-ssestream
|
|
18
|
+
* Transforms "messages" to W3C event stream content.
|
|
19
|
+
* See https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
20
|
+
* A message is an object with one or more of the following properties:
|
|
21
|
+
* - data (String or object, which gets turned into JSON)
|
|
22
|
+
* - type
|
|
23
|
+
* - id
|
|
24
|
+
* - retry
|
|
25
|
+
*
|
|
26
|
+
* If constructed with a HTTP Request, it will optimise the socket for streaming.
|
|
27
|
+
* If this stream is piped to an HTTP Response, it will set appropriate headers.
|
|
28
|
+
*/
|
|
29
|
+
export declare class SseStream extends Transform {
|
|
30
|
+
private lastEventId;
|
|
31
|
+
constructor(req?: IncomingMessage);
|
|
32
|
+
pipe<T extends WritableHeaderStream>(destination: T, options?: {
|
|
33
|
+
additionalHeaders?: AdditionalHeaders;
|
|
34
|
+
statusCode?: number;
|
|
35
|
+
end?: boolean;
|
|
36
|
+
}): T;
|
|
37
|
+
_transform(message: MessageEvent, encoding: string, callback: (error?: Error | null, data?: any) => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Calls `.write` but handles the drain if needed
|
|
40
|
+
*/
|
|
41
|
+
writeMessage(message: MessageEvent, cb: (error: Error | null | undefined) => void): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SseStream = void 0;
|
|
4
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
function toDataString(data) {
|
|
7
|
+
if ((0, shared_utils_1.isObject)(data)) {
|
|
8
|
+
return toDataString(JSON.stringify(data));
|
|
9
|
+
}
|
|
10
|
+
return data
|
|
11
|
+
.split(/\r\n|\r|\n/)
|
|
12
|
+
.map(line => `data: ${line}\n`)
|
|
13
|
+
.join('');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Adapted from https://raw.githubusercontent.com/EventSource/node-ssestream
|
|
17
|
+
* Transforms "messages" to W3C event stream content.
|
|
18
|
+
* See https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
19
|
+
* A message is an object with one or more of the following properties:
|
|
20
|
+
* - data (String or object, which gets turned into JSON)
|
|
21
|
+
* - type
|
|
22
|
+
* - id
|
|
23
|
+
* - retry
|
|
24
|
+
*
|
|
25
|
+
* If constructed with a HTTP Request, it will optimise the socket for streaming.
|
|
26
|
+
* If this stream is piped to an HTTP Response, it will set appropriate headers.
|
|
27
|
+
*/
|
|
28
|
+
class SseStream extends stream_1.Transform {
|
|
29
|
+
constructor(req) {
|
|
30
|
+
super({ objectMode: true });
|
|
31
|
+
this.lastEventId = null;
|
|
32
|
+
if (req && req.socket) {
|
|
33
|
+
req.socket.setKeepAlive(true);
|
|
34
|
+
req.socket.setNoDelay(true);
|
|
35
|
+
req.socket.setTimeout(0);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
pipe(destination, options) {
|
|
39
|
+
if (destination.writeHead) {
|
|
40
|
+
const statusCode = options?.statusCode ?? 200;
|
|
41
|
+
destination.writeHead(statusCode, {
|
|
42
|
+
...options?.additionalHeaders,
|
|
43
|
+
// See https://github.com/dunglas/mercure/blob/master/hub/subscribe.go#L124-L130
|
|
44
|
+
'Content-Type': 'text/event-stream',
|
|
45
|
+
Connection: 'keep-alive',
|
|
46
|
+
// Disable cache, even for old browsers and proxies
|
|
47
|
+
'Cache-Control': 'private, no-cache, no-store, must-revalidate, max-age=0, no-transform',
|
|
48
|
+
Pragma: 'no-cache',
|
|
49
|
+
Expire: '0',
|
|
50
|
+
// NGINX support https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-buffering
|
|
51
|
+
'X-Accel-Buffering': 'no',
|
|
52
|
+
});
|
|
53
|
+
destination.flushHeaders?.();
|
|
54
|
+
}
|
|
55
|
+
destination.write('\n');
|
|
56
|
+
return super.pipe(destination, options);
|
|
57
|
+
}
|
|
58
|
+
_transform(message, encoding, callback) {
|
|
59
|
+
let data = message.type ? `event: ${message.type}\n` : '';
|
|
60
|
+
data += message.id ? `id: ${message.id}\n` : '';
|
|
61
|
+
data += message.retry ? `retry: ${message.retry}\n` : '';
|
|
62
|
+
data += message.data ? toDataString(message.data) : '';
|
|
63
|
+
data += '\n';
|
|
64
|
+
this.push(data);
|
|
65
|
+
callback();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Calls `.write` but handles the drain if needed
|
|
69
|
+
*/
|
|
70
|
+
writeMessage(message, cb) {
|
|
71
|
+
if (!message.id) {
|
|
72
|
+
this.lastEventId++;
|
|
73
|
+
message.id = this.lastEventId.toString();
|
|
74
|
+
}
|
|
75
|
+
if (!this.write(message, 'utf-8')) {
|
|
76
|
+
this.once('drain', cb);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
process.nextTick(cb);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.SseStream = SseStream;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RequestMethod } from '@nestjs/common';
|
|
2
|
+
import { ExcludeRouteMetadata } from '../interfaces/exclude-route-metadata.interface';
|
|
3
|
+
export declare const isRequestMethodAll: (method: RequestMethod) => boolean;
|
|
4
|
+
export declare function isRouteExcluded(excludedRoutes: ExcludeRouteMetadata[], path: string, requestMethod?: RequestMethod): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRequestMethodAll = void 0;
|
|
4
|
+
exports.isRouteExcluded = isRouteExcluded;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
|
+
const isRequestMethodAll = (method) => {
|
|
8
|
+
return common_1.RequestMethod.ALL === method || method === -1;
|
|
9
|
+
};
|
|
10
|
+
exports.isRequestMethodAll = isRequestMethodAll;
|
|
11
|
+
function isRouteExcluded(excludedRoutes, path, requestMethod) {
|
|
12
|
+
return excludedRoutes.some(route => {
|
|
13
|
+
if ((0, exports.isRequestMethodAll)(route.requestMethod) ||
|
|
14
|
+
route.requestMethod === requestMethod) {
|
|
15
|
+
return route.pathRegex.exec((0, shared_utils_1.addLeadingSlash)(path));
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenRoutePaths = flattenRoutePaths;
|
|
4
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
|
+
function flattenRoutePaths(routes) {
|
|
6
|
+
const result = [];
|
|
7
|
+
routes.forEach(item => {
|
|
8
|
+
if (item.module && item.path) {
|
|
9
|
+
result.push({ module: item.module, path: item.path });
|
|
10
|
+
}
|
|
11
|
+
if (item.children) {
|
|
12
|
+
const childrenRef = item.children;
|
|
13
|
+
childrenRef.forEach(child => {
|
|
14
|
+
if (!(0, shared_utils_1.isString)(child) && (0, shared_utils_1.isString)(child.path)) {
|
|
15
|
+
child.path = (0, shared_utils_1.normalizePath)((0, shared_utils_1.normalizePath)(item.path) + (0, shared_utils_1.normalizePath)(child.path));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
result.push({ path: item.path, module: child });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
result.push(...flattenRoutePaths(childrenRef));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
}
|
package/scanner.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DynamicModule, ForwardReference, Provider } from '@nestjs/common';
|
|
2
|
+
import { EnhancerSubtype } from '@nestjs/common/constants';
|
|
3
|
+
import { ClassProvider, Controller, ExistingProvider, FactoryProvider, Injectable, Type, ValueProvider } from '@nestjs/common/interfaces';
|
|
4
|
+
import { ApplicationConfig } from './application-config';
|
|
5
|
+
import { NestContainer } from './injector/container';
|
|
6
|
+
import { InstanceWrapper } from './injector/instance-wrapper';
|
|
7
|
+
import { Module } from './injector/module';
|
|
8
|
+
import { GraphInspector } from './inspector/graph-inspector';
|
|
9
|
+
import { ModuleDefinition } from './interfaces/module-definition.interface';
|
|
10
|
+
import { ModuleOverride } from './interfaces/module-override.interface';
|
|
11
|
+
import { MetadataScanner } from './metadata-scanner';
|
|
12
|
+
interface ModulesScanParameters {
|
|
13
|
+
moduleDefinition: ModuleDefinition;
|
|
14
|
+
scope?: Type<unknown>[];
|
|
15
|
+
ctxRegistry?: (ForwardReference | DynamicModule | Type<unknown>)[];
|
|
16
|
+
overrides?: ModuleOverride[];
|
|
17
|
+
lazy?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class DependenciesScanner {
|
|
20
|
+
private readonly container;
|
|
21
|
+
private readonly metadataScanner;
|
|
22
|
+
private readonly graphInspector;
|
|
23
|
+
private readonly applicationConfig;
|
|
24
|
+
private readonly applicationProvidersApplyMap;
|
|
25
|
+
constructor(container: NestContainer, metadataScanner: MetadataScanner, graphInspector: GraphInspector, applicationConfig?: ApplicationConfig);
|
|
26
|
+
scan(module: Type<any>, options?: {
|
|
27
|
+
overrides?: ModuleOverride[];
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
scanForModules({ moduleDefinition, lazy, scope, ctxRegistry, overrides, }: ModulesScanParameters): Promise<Module[]>;
|
|
30
|
+
insertModule(moduleDefinition: any, scope: Type<unknown>[]): Promise<{
|
|
31
|
+
moduleRef: Module;
|
|
32
|
+
inserted: boolean;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
scanModulesForDependencies(modules?: Map<string, Module>): Promise<void>;
|
|
35
|
+
reflectImports(module: Type<unknown>, token: string, context: string): Promise<void>;
|
|
36
|
+
reflectProviders(module: Type<any>, token: string): void;
|
|
37
|
+
reflectControllers(module: Type<any>, token: string): void;
|
|
38
|
+
reflectDynamicMetadata(cls: Type<Injectable>, token: string): void;
|
|
39
|
+
reflectExports(module: Type<unknown>, token: string): void;
|
|
40
|
+
reflectInjectables(component: Type<Injectable>, token: string, metadataKey: string): void;
|
|
41
|
+
reflectParamInjectables(component: Type<Injectable>, token: string, metadataKey: string): void;
|
|
42
|
+
reflectKeyMetadata(component: Type<Injectable>, key: string, methodKey: string): {
|
|
43
|
+
methodKey: string;
|
|
44
|
+
metadata: any;
|
|
45
|
+
} | undefined;
|
|
46
|
+
calculateModulesDistance(): void;
|
|
47
|
+
insertImport(related: any, token: string, context: string): Promise<void>;
|
|
48
|
+
isCustomProvider(provider: Provider): provider is ClassProvider | ValueProvider | FactoryProvider | ExistingProvider;
|
|
49
|
+
insertProvider(provider: Provider, token: string): string | symbol | Function | InstanceWrapper<unknown> | undefined;
|
|
50
|
+
insertInjectable(injectable: Type<Injectable> | object, token: string, host: Type<Injectable>, subtype: EnhancerSubtype, methodKey?: string): InstanceWrapper<any> | undefined;
|
|
51
|
+
insertExportedProviderOrModule(toExport: ForwardReference | DynamicModule | Type<unknown>, token: string): void;
|
|
52
|
+
insertController(controller: Type<Controller>, token: string): void;
|
|
53
|
+
private insertOrOverrideModule;
|
|
54
|
+
private getOverrideModuleByModule;
|
|
55
|
+
private overrideModule;
|
|
56
|
+
reflectMetadata<T = any>(metadataKey: string, metatype: Type<any>): T[];
|
|
57
|
+
registerCoreModule(overrides?: ModuleOverride[]): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Add either request or transient globally scoped enhancers
|
|
60
|
+
* to all controllers metadata storage
|
|
61
|
+
*/
|
|
62
|
+
addScopedEnhancersMetadata(): void;
|
|
63
|
+
applyApplicationProviders(): void;
|
|
64
|
+
getApplyProvidersMap(): {
|
|
65
|
+
[type: string]: Function;
|
|
66
|
+
};
|
|
67
|
+
getApplyRequestProvidersMap(): {
|
|
68
|
+
[type: string]: Function;
|
|
69
|
+
};
|
|
70
|
+
isDynamicModule(module: Type<any> | DynamicModule): module is DynamicModule;
|
|
71
|
+
/**
|
|
72
|
+
* @param metatype
|
|
73
|
+
* @returns `true` if `metatype` is annotated with the `@Injectable()` decorator.
|
|
74
|
+
*/
|
|
75
|
+
private isInjectable;
|
|
76
|
+
/**
|
|
77
|
+
* @param metatype
|
|
78
|
+
* @returns `true` if `metatype` is annotated with the `@Controller()` decorator.
|
|
79
|
+
*/
|
|
80
|
+
private isController;
|
|
81
|
+
/**
|
|
82
|
+
* @param metatype
|
|
83
|
+
* @returns `true` if `metatype` is annotated with the `@Catch()` decorator.
|
|
84
|
+
*/
|
|
85
|
+
private isExceptionFilter;
|
|
86
|
+
private isForwardReference;
|
|
87
|
+
private isRequestOrTransient;
|
|
88
|
+
}
|
|
89
|
+
export {};
|