Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@golevelup/nestjs-discovery

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@golevelup/nestjs-discovery - npm Package Compare versions

Comparing version 2.3.2 to 3.0.0

13

CHANGELOG.md

@@ -6,2 +6,15 @@ # Change Log

# [3.0.0](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-discovery@2.3.2...@golevelup/nestjs-discovery@3.0.0) (2022-01-24)
- feat!: update libraries to support Nest 8 (#342) ([de7cd35](https://github.com/golevelup/nestjs/commit/de7cd35ac2e63d66af76b792d5bf99b4a2d82bb4)), closes [#342](https://github.com/golevelup/nestjs/issues/342)
### BREAKING CHANGES
- Nest dependencies have been bumped from 6.x -> 8.x and we will no longer be supporting versions older than 8.x for future development
Co-authored-by: Christophe BLIN <cblin@monkeyfactory.fr>
Co-authored-by: danocmx <glencocomaster@centrum.cz>
Co-authored-by: Rodrigo <monstawoodwow@gmail.com>
Co-authored-by: Jesse Carter <jesse.r.carter@gmail.com>
## [2.3.2](https://github.com/golevelup/nestjs/compare/@golevelup/nestjs-discovery@2.3.1...@golevelup/nestjs-discovery@2.3.2) (2022-01-19)

@@ -8,0 +21,0 @@

6

lib/discovery.interfaces.d.ts
import { Type } from '@nestjs/common';
export interface DiscoveredModule {
export interface DiscoveredModule<T = object> {
name: string;
instance: {};
instance: T;
injectType?: Function | Type<any>;
dependencyType: Type<{}>;
dependencyType: Type<T>;
}

@@ -8,0 +8,0 @@ export interface DiscoveredClass extends DiscoveredModule {

@@ -9,2 +9,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscoveryModule = void 0;
const common_1 = require("@nestjs/common");

@@ -22,4 +23,4 @@ const metadata_scanner_1 = require("@nestjs/core/metadata-scanner");

DiscoveryModule = __decorate([
common_1.Global(),
common_1.Module({
(0, common_1.Global)(),
(0, common_1.Module)({
providers: [discovery_service_1.DiscoveryService, metadata_scanner_1.MetadataScanner],

@@ -26,0 +27,0 @@ exports: [discovery_service_1.DiscoveryService],

@@ -24,3 +24,3 @@ import { ModulesContainer } from '@nestjs/core/injector/modules-container';

* Discovers all providers in a Nest App that match a filter
* @param providerFilter
* @param filter
*/

@@ -42,3 +42,3 @@ providers(filter: Filter<DiscoveredClass>): Promise<DiscoveredClass[]>;

* Discovers all controllers in a Nest App that match a filter
* @param providerFilter
* @param filter
*/

@@ -45,0 +45,0 @@ controllers(filter: Filter<DiscoveredClass>): Promise<DiscoveredClass[]>;

@@ -12,2 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscoveryService = exports.withMetaAtKey = exports.getComponentMetaAtKey = void 0;
const common_1 = require("@nestjs/common");

@@ -39,9 +40,12 @@ const constants_1 = require("@nestjs/common/constants");

*/
exports.withMetaAtKey = key => component => {
const withMetaAtKey = (key) => (component) => {
// eslint-disable-next-line @typescript-eslint/ban-types
const metaTargets = [
lodash_1.get(component, 'instance.constructor'),
component.injectType
].filter(x => x != null);
return lodash_1.some(metaTargets, x => Reflect.getMetadata(key, x));
(0, lodash_1.get)(component, 'instance.constructor'),
// eslint-disable-next-line @typescript-eslint/ban-types
component.injectType,
].filter((x) => x != null);
return (0, lodash_1.some)(metaTargets, (x) => Reflect.getMetadata(key, x));
};
exports.withMetaAtKey = withMetaAtKey;
let DiscoveryService = class DiscoveryService {

@@ -54,3 +58,3 @@ constructor(modulesContainer, metadataScanner) {

* Discovers all providers in a Nest App that match a filter
* @param providerFilter
* @param filter
*/

@@ -61,3 +65,3 @@ async providers(filter) {

}
return (await this.discoveredProviders).filter(x => filter(x));
return (await this.discoveredProviders).filter((x) => filter(x));
}

@@ -71,8 +75,8 @@ /**

async methodsAndControllerMethodsWithMetaAtKey(metaKey, metaFilter = () => true) {
const controllersWithMeta = (await this.controllersWithMetaAtKey(metaKey)).filter(x => metaFilter(x.meta));
const methodsFromDecoratedControllers = lodash_1.flatMap(controllersWithMeta, controller => {
const controllersWithMeta = (await this.controllersWithMetaAtKey(metaKey)).filter((x) => metaFilter(x.meta));
const methodsFromDecoratedControllers = (0, lodash_1.flatMap)(controllersWithMeta, (controller) => {
return this.classMethodsWithMetaAtKey(controller.discoveredClass, constants_1.PATH_METADATA);
});
const decoratedMethods = (await this.controllerMethodsWithMetaAtKey(metaKey)).filter(x => metaFilter(x.meta));
return lodash_1.uniqBy([...methodsFromDecoratedControllers, ...decoratedMethods], x => x.discoveredMethod.handler);
const decoratedMethods = (await this.controllerMethodsWithMetaAtKey(metaKey)).filter((x) => metaFilter(x.meta));
return (0, lodash_1.uniqBy)([...methodsFromDecoratedControllers, ...decoratedMethods], (x) => x.discoveredMethod.handler);
}

@@ -84,6 +88,6 @@ /**

async providersWithMetaAtKey(metaKey) {
const providers = await this.providers(exports.withMetaAtKey(metaKey));
return providers.map(x => ({
const providers = await this.providers((0, exports.withMetaAtKey)(metaKey));
return providers.map((x) => ({
meta: getComponentMetaAtKey(metaKey, x),
discoveredClass: x
discoveredClass: x,
}));

@@ -93,3 +97,3 @@ }

* Discovers all controllers in a Nest App that match a filter
* @param providerFilter
* @param filter
*/

@@ -100,3 +104,3 @@ async controllers(filter) {

}
return (await this.discoveredControllers).filter(x => filter(x));
return (await this.discoveredControllers).filter((x) => filter(x));
}

@@ -108,6 +112,6 @@ /**

async controllersWithMetaAtKey(metaKey) {
const controllers = await this.controllers(exports.withMetaAtKey(metaKey));
return controllers.map(x => ({
const controllers = await this.controllers((0, exports.withMetaAtKey)(metaKey));
return controllers.map((x) => ({
meta: getComponentMetaAtKey(metaKey, x),
discoveredClass: x
discoveredClass: x,
}));

@@ -127,4 +131,4 @@ }

return this.metadataScanner
.scanFromPrototype(instance, prototype, name => this.extractMethodMetaAtKey(metaKey, component, prototype, name))
.filter(x => !!x.meta);
.scanFromPrototype(instance, prototype, (name) => this.extractMethodMetaAtKey(metaKey, component, prototype, name))
.filter((x) => !!x.meta);
}

@@ -138,3 +142,3 @@ /**

const providers = await this.providers(providerFilter);
return lodash_1.flatMap(providers, provider => this.classMethodsWithMetaAtKey(provider, metaKey));
return (0, lodash_1.flatMap)(providers, (provider) => this.classMethodsWithMetaAtKey(provider, metaKey));
}

@@ -148,3 +152,3 @@ /**

const controllers = await this.controllers(controllerFilter);
return lodash_1.flatMap(controllers, controller => this.classMethodsWithMetaAtKey(controller, metaKey));
return (0, lodash_1.flatMap)(controllers, (controller) => this.classMethodsWithMetaAtKey(controller, metaKey));
}

@@ -160,3 +164,3 @@ async toDiscoveredClass(nestModule, wrapper) {

injectType: wrapper.metatype,
dependencyType: lodash_1.get(instanceHost, 'instance.constructor'),
dependencyType: (0, lodash_1.get)(instanceHost, 'instance.constructor'),
parentModule: {

@@ -166,4 +170,4 @@ name: nestModule.metatype.name,

injectType: nestModule.metatype,
dependencyType: nestModule.instance.constructor
}
dependencyType: nestModule.instance.constructor,
},
};

@@ -179,4 +183,4 @@ }

methodName,
parentClass: discoveredClass
}
parentClass: discoveredClass,
},
};

@@ -188,7 +192,7 @@ }

// eslint-disable-next-line @typescript-eslint/no-unused-vars
lodash_1.flatMap(modulesMap, ([key, nestModule]) => {
(0, lodash_1.flatMap)(modulesMap, ([key, nestModule]) => {
const components = [...nestModule[component].values()];
return components
.filter(component => component.scope !== common_1.Scope.REQUEST)
.map(component => this.toDiscoveredClass(nestModule, component));
.filter((component) => component.scope !== common_1.Scope.REQUEST)
.map((component) => this.toDiscoveredClass(nestModule, component));
}));

@@ -198,3 +202,3 @@ }

DiscoveryService = __decorate([
common_1.Injectable(),
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [modules_container_1.ModulesContainer,

@@ -201,0 +205,0 @@ metadata_scanner_1.MetadataScanner])

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./discovery.module"));
__export(require("./discovery.service"));
__exportStar(require("./discovery.interfaces"), exports);
__exportStar(require("./discovery.module"), exports);
__exportStar(require("./discovery.service"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@golevelup/nestjs-discovery",
"version": "2.3.2",
"version": "3.0.0",
"description": "A Badass NestJS module for querying your app's controllers, providers and handlers",

@@ -54,3 +54,3 @@ "keywords": [

},
"gitHead": "972c3aed4761eeae065c0f26e771590d24f6567a"
"gitHead": "94ca5b66d3377ebf69b6ff22c1f3f38197fc553d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc