Initial commit - Event Planner application
This commit is contained in:
46
node_modules/@nestjs/core/discovery/discoverable-meta-host-collection.d.ts
generated
vendored
Normal file
46
node_modules/@nestjs/core/discovery/discoverable-meta-host-collection.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Type } from '@nestjs/common';
|
||||
import { InstanceWrapper } from '../injector/instance-wrapper';
|
||||
import { ModulesContainer } from '../injector/modules-container';
|
||||
export declare class DiscoverableMetaHostCollection {
|
||||
/**
|
||||
* A map of class references to metadata keys.
|
||||
*/
|
||||
static readonly metaHostLinks: Map<Function | Type<any>, string>;
|
||||
/**
|
||||
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
|
||||
* The map is weakly referenced by the modules container (unique per application).
|
||||
*/
|
||||
private static readonly providersByMetaKey;
|
||||
/**
|
||||
* A map of metadata keys to instance wrappers (controllers) with the corresponding metadata key.
|
||||
* The map is weakly referenced by the modules container (unique per application).
|
||||
*/
|
||||
private static readonly controllersByMetaKey;
|
||||
/**
|
||||
* Adds a link between a class reference and a metadata key.
|
||||
* @param target The class reference.
|
||||
* @param metadataKey The metadata key.
|
||||
*/
|
||||
static addClassMetaHostLink(target: Type | Function, metadataKey: string): void;
|
||||
/**
|
||||
* Inspects a provider instance wrapper and adds it to the collection of providers
|
||||
* if it has a metadata key.
|
||||
* @param hostContainerRef A reference to the modules container.
|
||||
* @param instanceWrapper A provider instance wrapper.
|
||||
* @returns void
|
||||
*/
|
||||
static inspectProvider(hostContainerRef: ModulesContainer, instanceWrapper: InstanceWrapper): void;
|
||||
/**
|
||||
* Inspects a controller instance wrapper and adds it to the collection of controllers
|
||||
* if it has a metadata key.
|
||||
* @param hostContainerRef A reference to the modules container.
|
||||
* @param instanceWrapper A controller's instance wrapper.
|
||||
* @returns void
|
||||
*/
|
||||
static inspectController(hostContainerRef: ModulesContainer, instanceWrapper: InstanceWrapper): void;
|
||||
static insertByMetaKey(metaKey: string, instanceWrapper: InstanceWrapper, collection: Map<string, Set<InstanceWrapper>>): void;
|
||||
static getProvidersByMetaKey(hostContainerRef: ModulesContainer, metaKey: string): Set<InstanceWrapper>;
|
||||
static getControllersByMetaKey(hostContainerRef: ModulesContainer, metaKey: string): Set<InstanceWrapper>;
|
||||
private static inspectInstanceWrapper;
|
||||
private static getMetaKeyByInstanceWrapper;
|
||||
}
|
||||
98
node_modules/@nestjs/core/discovery/discoverable-meta-host-collection.js
generated
vendored
Normal file
98
node_modules/@nestjs/core/discovery/discoverable-meta-host-collection.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiscoverableMetaHostCollection = void 0;
|
||||
class DiscoverableMetaHostCollection {
|
||||
/**
|
||||
* Adds a link between a class reference and a metadata key.
|
||||
* @param target The class reference.
|
||||
* @param metadataKey The metadata key.
|
||||
*/
|
||||
static addClassMetaHostLink(target, metadataKey) {
|
||||
this.metaHostLinks.set(target, metadataKey);
|
||||
}
|
||||
/**
|
||||
* Inspects a provider instance wrapper and adds it to the collection of providers
|
||||
* if it has a metadata key.
|
||||
* @param hostContainerRef A reference to the modules container.
|
||||
* @param instanceWrapper A provider instance wrapper.
|
||||
* @returns void
|
||||
*/
|
||||
static inspectProvider(hostContainerRef, instanceWrapper) {
|
||||
return this.inspectInstanceWrapper(hostContainerRef, instanceWrapper, this.providersByMetaKey);
|
||||
}
|
||||
/**
|
||||
* Inspects a controller instance wrapper and adds it to the collection of controllers
|
||||
* if it has a metadata key.
|
||||
* @param hostContainerRef A reference to the modules container.
|
||||
* @param instanceWrapper A controller's instance wrapper.
|
||||
* @returns void
|
||||
*/
|
||||
static inspectController(hostContainerRef, instanceWrapper) {
|
||||
return this.inspectInstanceWrapper(hostContainerRef, instanceWrapper, this.controllersByMetaKey);
|
||||
}
|
||||
static insertByMetaKey(metaKey, instanceWrapper, collection) {
|
||||
if (collection.has(metaKey)) {
|
||||
const wrappers = collection.get(metaKey);
|
||||
wrappers.add(instanceWrapper);
|
||||
}
|
||||
else {
|
||||
const wrappers = new Set();
|
||||
wrappers.add(instanceWrapper);
|
||||
collection.set(metaKey, wrappers);
|
||||
}
|
||||
}
|
||||
static getProvidersByMetaKey(hostContainerRef, metaKey) {
|
||||
const wrappersByMetaKey = this.providersByMetaKey.get(hostContainerRef);
|
||||
return wrappersByMetaKey?.get(metaKey) ?? new Set();
|
||||
}
|
||||
static getControllersByMetaKey(hostContainerRef, metaKey) {
|
||||
const wrappersByMetaKey = this.controllersByMetaKey.get(hostContainerRef);
|
||||
return wrappersByMetaKey?.get(metaKey) ?? new Set();
|
||||
}
|
||||
static inspectInstanceWrapper(hostContainerRef, instanceWrapper, wrapperByMetaKeyMap) {
|
||||
const metaKey = DiscoverableMetaHostCollection.getMetaKeyByInstanceWrapper(instanceWrapper);
|
||||
if (!metaKey) {
|
||||
return;
|
||||
}
|
||||
let collection;
|
||||
if (wrapperByMetaKeyMap.has(hostContainerRef)) {
|
||||
collection = wrapperByMetaKeyMap.get(hostContainerRef);
|
||||
}
|
||||
else {
|
||||
collection = new Map();
|
||||
wrapperByMetaKeyMap.set(hostContainerRef, collection);
|
||||
}
|
||||
this.insertByMetaKey(metaKey, instanceWrapper, collection);
|
||||
}
|
||||
static getMetaKeyByInstanceWrapper(instanceWrapper) {
|
||||
return this.metaHostLinks.get(
|
||||
// NOTE: Regarding the ternary statement below,
|
||||
// - The condition `!wrapper.metatype` is needed because when we use `useValue`
|
||||
// the value of `wrapper.metatype` will be `null`.
|
||||
// - The condition `wrapper.inject` is needed here because when we use
|
||||
// `useFactory`, the value of `wrapper.metatype` will be the supplied
|
||||
// factory function.
|
||||
// For both cases, we should use `wrapper.instance.constructor` instead
|
||||
// of `wrapper.metatype` to resolve processor's class properly.
|
||||
// But since calling `wrapper.instance` could degrade overall performance
|
||||
// we must defer it as much we can.
|
||||
instanceWrapper.metatype || instanceWrapper.inject
|
||||
? (instanceWrapper.instance?.constructor ?? instanceWrapper.metatype)
|
||||
: instanceWrapper.metatype);
|
||||
}
|
||||
}
|
||||
exports.DiscoverableMetaHostCollection = DiscoverableMetaHostCollection;
|
||||
/**
|
||||
* A map of class references to metadata keys.
|
||||
*/
|
||||
DiscoverableMetaHostCollection.metaHostLinks = new Map();
|
||||
/**
|
||||
* A map of metadata keys to instance wrappers (providers) with the corresponding metadata key.
|
||||
* The map is weakly referenced by the modules container (unique per application).
|
||||
*/
|
||||
DiscoverableMetaHostCollection.providersByMetaKey = new WeakMap();
|
||||
/**
|
||||
* A map of metadata keys to instance wrappers (controllers) with the corresponding metadata key.
|
||||
* The map is weakly referenced by the modules container (unique per application).
|
||||
*/
|
||||
DiscoverableMetaHostCollection.controllersByMetaKey = new WeakMap();
|
||||
5
node_modules/@nestjs/core/discovery/discovery-module.d.ts
generated
vendored
Normal file
5
node_modules/@nestjs/core/discovery/discovery-module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export declare class DiscoveryModule {
|
||||
}
|
||||
19
node_modules/@nestjs/core/discovery/discovery-module.js
generated
vendored
Normal file
19
node_modules/@nestjs/core/discovery/discovery-module.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiscoveryModule = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const metadata_scanner_1 = require("../metadata-scanner");
|
||||
const discovery_service_1 = require("./discovery-service");
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
let DiscoveryModule = class DiscoveryModule {
|
||||
};
|
||||
exports.DiscoveryModule = DiscoveryModule;
|
||||
exports.DiscoveryModule = DiscoveryModule = tslib_1.__decorate([
|
||||
(0, common_1.Module)({
|
||||
providers: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
|
||||
exports: [metadata_scanner_1.MetadataScanner, discovery_service_1.DiscoveryService],
|
||||
})
|
||||
], DiscoveryModule);
|
||||
76
node_modules/@nestjs/core/discovery/discovery-service.d.ts
generated
vendored
Normal file
76
node_modules/@nestjs/core/discovery/discovery-service.d.ts
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import { CustomDecorator } from '@nestjs/common';
|
||||
import { InstanceWrapper } from '../injector/instance-wrapper';
|
||||
import { Module } from '../injector/module';
|
||||
import { ModulesContainer } from '../injector/modules-container';
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export interface FilterByInclude {
|
||||
/**
|
||||
* List of modules to include (whitelist) into the discovery process.
|
||||
*/
|
||||
include?: Function[];
|
||||
}
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export interface FilterByMetadataKey {
|
||||
/**
|
||||
* A key to filter controllers and providers by.
|
||||
* Only instance wrappers with the specified metadata key will be returned.
|
||||
*/
|
||||
metadataKey?: string;
|
||||
}
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export type DiscoveryOptions = FilterByInclude | FilterByMetadataKey;
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export type DiscoverableDecorator<T> = ((opts?: T) => CustomDecorator) & {
|
||||
KEY: string;
|
||||
};
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export declare class DiscoveryService {
|
||||
private readonly modulesContainer;
|
||||
constructor(modulesContainer: ModulesContainer);
|
||||
/**
|
||||
* Creates a decorator that can be used to decorate classes and methods with metadata.
|
||||
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
|
||||
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
|
||||
* @returns A decorator function.
|
||||
*/
|
||||
static createDecorator<T>(): DiscoverableDecorator<T>;
|
||||
/**
|
||||
* Returns an array of instance wrappers (providers).
|
||||
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
|
||||
* @param options Discovery options.
|
||||
* @param modules A list of modules to filter by.
|
||||
* @returns An array of instance wrappers (providers).
|
||||
*/
|
||||
getProviders(options?: DiscoveryOptions, modules?: Module[]): InstanceWrapper[];
|
||||
/**
|
||||
* Returns an array of instance wrappers (controllers).
|
||||
* Depending on the options, the array will contain either all controllers or only controllers with the specified metadata key.
|
||||
* @param options Discovery options.
|
||||
* @param modules A list of modules to filter by.
|
||||
* @returns An array of instance wrappers (controllers).
|
||||
*/
|
||||
getControllers(options?: DiscoveryOptions, modules?: Module[]): InstanceWrapper[];
|
||||
/**
|
||||
* Retrieves metadata from the specified instance wrapper.
|
||||
* @param decorator The decorator to retrieve metadata of.
|
||||
* @param instanceWrapper Reference to the instance wrapper.
|
||||
* @param methodKey An optional method key to retrieve metadata from.
|
||||
* @returns Discovered metadata.
|
||||
*/
|
||||
getMetadataByDecorator<T extends DiscoverableDecorator<any>>(decorator: T, instanceWrapper: InstanceWrapper, methodKey?: string): T extends DiscoverableDecorator<infer R> ? R | undefined : T | undefined;
|
||||
/**
|
||||
* Returns a list of modules to be used for discovery.
|
||||
*/
|
||||
protected getModules(options?: DiscoveryOptions): Module[];
|
||||
private includeWhitelisted;
|
||||
}
|
||||
98
node_modules/@nestjs/core/discovery/discovery-service.js
generated
vendored
Normal file
98
node_modules/@nestjs/core/discovery/discovery-service.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiscoveryService = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const uid_1 = require("uid");
|
||||
const modules_container_1 = require("../injector/modules-container");
|
||||
const discoverable_meta_host_collection_1 = require("./discoverable-meta-host-collection");
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
let DiscoveryService = class DiscoveryService {
|
||||
constructor(modulesContainer) {
|
||||
this.modulesContainer = modulesContainer;
|
||||
}
|
||||
/**
|
||||
* Creates a decorator that can be used to decorate classes and methods with metadata.
|
||||
* The decorator will also add the class to the collection of discoverable classes (by metadata key).
|
||||
* Decorated classes can be discovered using the `getProviders` and `getControllers` methods.
|
||||
* @returns A decorator function.
|
||||
*/
|
||||
static createDecorator() {
|
||||
const metadataKey = (0, uid_1.uid)(21);
|
||||
const decoratorFn = (opts) => (target, key, descriptor) => {
|
||||
if (!descriptor) {
|
||||
discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.addClassMetaHostLink(target, metadataKey);
|
||||
}
|
||||
(0, common_1.SetMetadata)(metadataKey, opts ?? {})(target, key, descriptor);
|
||||
};
|
||||
decoratorFn.KEY = metadataKey;
|
||||
return decoratorFn;
|
||||
}
|
||||
/**
|
||||
* Returns an array of instance wrappers (providers).
|
||||
* Depending on the options, the array will contain either all providers or only providers with the specified metadata key.
|
||||
* @param options Discovery options.
|
||||
* @param modules A list of modules to filter by.
|
||||
* @returns An array of instance wrappers (providers).
|
||||
*/
|
||||
getProviders(options = {}, modules = this.getModules(options)) {
|
||||
if ('metadataKey' in options) {
|
||||
const providers = discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.getProvidersByMetaKey(this.modulesContainer, options.metadataKey);
|
||||
return Array.from(providers);
|
||||
}
|
||||
const providers = modules.map(item => [...item.providers.values()]);
|
||||
return (0, common_1.flatten)(providers);
|
||||
}
|
||||
/**
|
||||
* Returns an array of instance wrappers (controllers).
|
||||
* Depending on the options, the array will contain either all controllers or only controllers with the specified metadata key.
|
||||
* @param options Discovery options.
|
||||
* @param modules A list of modules to filter by.
|
||||
* @returns An array of instance wrappers (controllers).
|
||||
*/
|
||||
getControllers(options = {}, modules = this.getModules(options)) {
|
||||
if ('metadataKey' in options) {
|
||||
const controllers = discoverable_meta_host_collection_1.DiscoverableMetaHostCollection.getControllersByMetaKey(this.modulesContainer, options.metadataKey);
|
||||
return Array.from(controllers);
|
||||
}
|
||||
const controllers = modules.map(item => [...item.controllers.values()]);
|
||||
return (0, common_1.flatten)(controllers);
|
||||
}
|
||||
/**
|
||||
* Retrieves metadata from the specified instance wrapper.
|
||||
* @param decorator The decorator to retrieve metadata of.
|
||||
* @param instanceWrapper Reference to the instance wrapper.
|
||||
* @param methodKey An optional method key to retrieve metadata from.
|
||||
* @returns Discovered metadata.
|
||||
*/
|
||||
getMetadataByDecorator(decorator, instanceWrapper, methodKey) {
|
||||
if (methodKey) {
|
||||
return Reflect.getMetadata(decorator.KEY, instanceWrapper.instance[methodKey]);
|
||||
}
|
||||
const clsRef = instanceWrapper.instance?.constructor ?? instanceWrapper.metatype;
|
||||
return Reflect.getMetadata(decorator.KEY, clsRef);
|
||||
}
|
||||
/**
|
||||
* Returns a list of modules to be used for discovery.
|
||||
*/
|
||||
getModules(options = {}) {
|
||||
const includeInOpts = 'include' in options;
|
||||
if (!includeInOpts) {
|
||||
const moduleRefs = [...this.modulesContainer.values()];
|
||||
return moduleRefs;
|
||||
}
|
||||
const whitelisted = this.includeWhitelisted(options.include);
|
||||
return whitelisted;
|
||||
}
|
||||
includeWhitelisted(include) {
|
||||
const moduleRefs = [...this.modulesContainer.values()];
|
||||
return moduleRefs.filter(({ metatype }) => include.some(item => item === metatype));
|
||||
}
|
||||
};
|
||||
exports.DiscoveryService = DiscoveryService;
|
||||
exports.DiscoveryService = DiscoveryService = tslib_1.__decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
tslib_1.__metadata("design:paramtypes", [modules_container_1.ModulesContainer])
|
||||
], DiscoveryService);
|
||||
2
node_modules/@nestjs/core/discovery/index.d.ts
generated
vendored
Normal file
2
node_modules/@nestjs/core/discovery/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './discovery-module';
|
||||
export * from './discovery-service';
|
||||
5
node_modules/@nestjs/core/discovery/index.js
generated
vendored
Normal file
5
node_modules/@nestjs/core/discovery/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./discovery-module"), exports);
|
||||
tslib_1.__exportStar(require("./discovery-service"), exports);
|
||||
Reference in New Issue
Block a user