@punks/backend-entity-manager 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +90 -158
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/ioc/discovery/index.d.ts +17 -3
- package/dist/cjs/types/platforms/nest/processors/initializer/index.d.ts +2 -2
- package/dist/esm/index.js +90 -158
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/ioc/discovery/index.d.ts +17 -3
- package/dist/esm/types/platforms/nest/processors/initializer/index.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "@nestjs/common";
|
|
2
|
+
import { Module as NestModule } from "@nestjs/core/injector/module";
|
|
2
3
|
import { ModulesContainer } from "@nestjs/core/injector/modules-container";
|
|
3
4
|
import { MetadataScanner } from "@nestjs/core/metadata-scanner";
|
|
4
5
|
export interface DiscoveredModule<T = object> {
|
|
@@ -8,7 +9,7 @@ export interface DiscoveredModule<T = object> {
|
|
|
8
9
|
dependencyType: Type<T>;
|
|
9
10
|
}
|
|
10
11
|
export interface DiscoveredClass extends DiscoveredModule {
|
|
11
|
-
parentModule
|
|
12
|
+
parentModule?: DiscoveredModule;
|
|
12
13
|
}
|
|
13
14
|
export interface DiscoveredMethod {
|
|
14
15
|
handler: (...args: any[]) => any;
|
|
@@ -37,12 +38,17 @@ export declare function getComponentMetaAtKey<T>(key: MetaKey, component: Discov
|
|
|
37
38
|
* @param key The meta key to search for
|
|
38
39
|
*/
|
|
39
40
|
export declare const withMetaAtKey: (key: MetaKey) => Filter<DiscoveredClass>;
|
|
40
|
-
export declare class
|
|
41
|
+
export declare class ModulesContainerProvider {
|
|
42
|
+
private modulesContainer;
|
|
43
|
+
setModulesContainer(modulesContainer: ModulesContainer): void;
|
|
44
|
+
getModules(): [string, NestModule][];
|
|
45
|
+
}
|
|
46
|
+
export declare class CustomDiscoveryService {
|
|
41
47
|
private readonly modulesContainer;
|
|
42
48
|
private readonly metadataScanner;
|
|
43
49
|
private discoveredControllers?;
|
|
44
50
|
private discoveredProviders?;
|
|
45
|
-
constructor(modulesContainer:
|
|
51
|
+
constructor(modulesContainer: ModulesContainerProvider, metadataScanner: MetadataScanner);
|
|
46
52
|
/**
|
|
47
53
|
* Discovers all providers in a Nest App that match a filter
|
|
48
54
|
* @param filter
|
|
@@ -93,3 +99,11 @@ export declare class DiscoveryService {
|
|
|
93
99
|
private discover;
|
|
94
100
|
private getModuleEntries;
|
|
95
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Exposes a query API over top of the NestJS Module container
|
|
104
|
+
*
|
|
105
|
+
* @export
|
|
106
|
+
* @class DiscoveryModule
|
|
107
|
+
*/
|
|
108
|
+
export declare class CustomDiscoveryModule {
|
|
109
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { INestApplicationContext } from "@nestjs/common";
|
|
2
2
|
import { EntityManagerRegistry } from "../../ioc/registry";
|
|
3
|
-
import {
|
|
3
|
+
import { CustomDiscoveryService } from "../../ioc/discovery";
|
|
4
4
|
export declare class EntityManagerInitializer {
|
|
5
5
|
private readonly discover;
|
|
6
6
|
private readonly registry;
|
|
7
7
|
private readonly logger;
|
|
8
|
-
constructor(discover:
|
|
8
|
+
constructor(discover: CustomDiscoveryService, registry: EntityManagerRegistry);
|
|
9
9
|
initialize(app: INestApplicationContext): Promise<void>;
|
|
10
10
|
private discoverEntities;
|
|
11
11
|
private discoverRepositories;
|
package/dist/esm/index.js
CHANGED
|
@@ -168,7 +168,7 @@ function __rest(s, e) {
|
|
|
168
168
|
return t;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
function __decorate
|
|
171
|
+
function __decorate(decorators, target, key, desc) {
|
|
172
172
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
173
173
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
174
174
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -454,7 +454,7 @@ var tslib_es6 = {
|
|
|
454
454
|
__extends: __extends$1,
|
|
455
455
|
__assign: __assign$2,
|
|
456
456
|
__rest,
|
|
457
|
-
__decorate
|
|
457
|
+
__decorate,
|
|
458
458
|
__param,
|
|
459
459
|
__metadata,
|
|
460
460
|
__awaiter: __awaiter$1,
|
|
@@ -485,7 +485,7 @@ var tslib_es6$1 = /*#__PURE__*/Object.freeze({
|
|
|
485
485
|
__extends: __extends$1,
|
|
486
486
|
get __assign () { return __assign$2; },
|
|
487
487
|
__rest: __rest,
|
|
488
|
-
__decorate: __decorate
|
|
488
|
+
__decorate: __decorate,
|
|
489
489
|
__param: __param,
|
|
490
490
|
__esDecorate: __esDecorate,
|
|
491
491
|
__runInitializers: __runInitializers,
|
|
@@ -2056,7 +2056,7 @@ dist.uid = uid;
|
|
|
2056
2056
|
|
|
2057
2057
|
Object.defineProperty(injectable_decorator, "__esModule", { value: true });
|
|
2058
2058
|
injectable_decorator.mixin = injectable_decorator.Injectable = void 0;
|
|
2059
|
-
const uid_1$
|
|
2059
|
+
const uid_1$2 = dist;
|
|
2060
2060
|
const constants_1$e = constants$2;
|
|
2061
2061
|
/**
|
|
2062
2062
|
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
@@ -2098,7 +2098,7 @@ injectable_decorator.Injectable = Injectable;
|
|
|
2098
2098
|
*/
|
|
2099
2099
|
function mixin(mixinClass) {
|
|
2100
2100
|
Object.defineProperty(mixinClass, 'name', {
|
|
2101
|
-
value: (0, uid_1$
|
|
2101
|
+
value: (0, uid_1$2.uid)(21),
|
|
2102
2102
|
});
|
|
2103
2103
|
Injectable()(mixinClass);
|
|
2104
2104
|
return mixinClass;
|
|
@@ -2895,7 +2895,7 @@ assignCustomMetadata_util.assignCustomParameterMetadata = assignCustomParameterM
|
|
|
2895
2895
|
|
|
2896
2896
|
Object.defineProperty(createRouteParamMetadata_decorator, "__esModule", { value: true });
|
|
2897
2897
|
createRouteParamMetadata_decorator.createParamDecorator = void 0;
|
|
2898
|
-
const uid_1$
|
|
2898
|
+
const uid_1$1 = dist;
|
|
2899
2899
|
const constants_1$5 = constants$2;
|
|
2900
2900
|
const assign_custom_metadata_util_1 = assignCustomMetadata_util;
|
|
2901
2901
|
const shared_utils_1$f = shared_utils;
|
|
@@ -2907,7 +2907,7 @@ const shared_utils_1$f = shared_utils;
|
|
|
2907
2907
|
* @publicApi
|
|
2908
2908
|
*/
|
|
2909
2909
|
function createParamDecorator(factory, enhancers = []) {
|
|
2910
|
-
const paramtype = (0, uid_1$
|
|
2910
|
+
const paramtype = (0, uid_1$1.uid)(21);
|
|
2911
2911
|
return (data, ...pipes) => (target, key, index) => {
|
|
2912
2912
|
const args = Reflect.getMetadata(constants_1$5.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
2913
2913
|
const isPipe = (pipe) => pipe &&
|
|
@@ -5141,8 +5141,8 @@ var randomStringGenerator_util = {};
|
|
|
5141
5141
|
|
|
5142
5142
|
Object.defineProperty(randomStringGenerator_util, "__esModule", { value: true });
|
|
5143
5143
|
randomStringGenerator_util.randomStringGenerator = void 0;
|
|
5144
|
-
const uid_1
|
|
5145
|
-
const randomStringGenerator = () => (0, uid_1
|
|
5144
|
+
const uid_1 = dist;
|
|
5145
|
+
const randomStringGenerator = () => (0, uid_1.uid)(21);
|
|
5146
5146
|
randomStringGenerator_util.randomStringGenerator = randomStringGenerator;
|
|
5147
5147
|
|
|
5148
5148
|
var constants$1 = {};
|
|
@@ -5512,7 +5512,7 @@ httpErrorByCode_util.HttpErrorByCode = {
|
|
|
5512
5512
|
|
|
5513
5513
|
var validation_pipe = {};
|
|
5514
5514
|
|
|
5515
|
-
var lib
|
|
5515
|
+
var lib = {};
|
|
5516
5516
|
|
|
5517
5517
|
var iterate$1 = {};
|
|
5518
5518
|
|
|
@@ -5902,11 +5902,11 @@ function zip$2(a, b) {
|
|
|
5902
5902
|
iterate$1.zip = zip$2;
|
|
5903
5903
|
iterate$1.default = iterate;
|
|
5904
5904
|
|
|
5905
|
-
Object.defineProperty(lib
|
|
5905
|
+
Object.defineProperty(lib, "__esModule", { value: true });
|
|
5906
5906
|
const iterate_1 = iterate$1;
|
|
5907
|
-
lib
|
|
5908
|
-
lib
|
|
5909
|
-
lib
|
|
5907
|
+
lib.iterate = iterate_1.iterate;
|
|
5908
|
+
lib.zip = iterate_1.zip;
|
|
5909
|
+
lib.default = iterate_1.iterate;
|
|
5910
5910
|
|
|
5911
5911
|
var loadPackage_util = {};
|
|
5912
5912
|
|
|
@@ -21616,7 +21616,7 @@ var require$$7 = /*@__PURE__*/getAugmentedNamespace(esm5);
|
|
|
21616
21616
|
Object.defineProperty(validation_pipe, "__esModule", { value: true });
|
|
21617
21617
|
validation_pipe.ValidationPipe = void 0;
|
|
21618
21618
|
const tslib_1$8 = require$$0;
|
|
21619
|
-
const iterare_1 = lib
|
|
21619
|
+
const iterare_1 = lib;
|
|
21620
21620
|
const util_1 = require$$1$1;
|
|
21621
21621
|
const decorators_1$1 = decorators$1;
|
|
21622
21622
|
const core_1$4 = core;
|
|
@@ -31203,22 +31203,24 @@ let EntityManagerRegistry = class EntityManagerRegistry {
|
|
|
31203
31203
|
return this.container.getEntityServicesLocator(entityName);
|
|
31204
31204
|
}
|
|
31205
31205
|
};
|
|
31206
|
-
EntityManagerRegistry = __decorate
|
|
31206
|
+
EntityManagerRegistry = __decorate([
|
|
31207
31207
|
common.Injectable()
|
|
31208
31208
|
], EntityManagerRegistry);
|
|
31209
31209
|
|
|
31210
|
-
var
|
|
31211
|
-
|
|
31212
|
-
var discovery_interfaces = {};
|
|
31213
|
-
|
|
31214
|
-
Object.defineProperty(discovery_interfaces, "__esModule", { value: true });
|
|
31210
|
+
var constants = {};
|
|
31215
31211
|
|
|
31216
|
-
|
|
31212
|
+
Object.defineProperty(constants, "__esModule", { value: true });
|
|
31213
|
+
var STATIC_CONTEXT = constants.STATIC_CONTEXT = constants.CONTROLLER_ID_KEY = void 0;
|
|
31214
|
+
constants.CONTROLLER_ID_KEY = 'CONTROLLER_ID';
|
|
31215
|
+
const STATIC_CONTEXT_ID = 1;
|
|
31216
|
+
STATIC_CONTEXT = constants.STATIC_CONTEXT = Object.freeze({
|
|
31217
|
+
id: STATIC_CONTEXT_ID,
|
|
31218
|
+
});
|
|
31217
31219
|
|
|
31218
31220
|
var metadataScanner = {};
|
|
31219
31221
|
|
|
31220
31222
|
Object.defineProperty(metadataScanner, "__esModule", { value: true });
|
|
31221
|
-
metadataScanner.MetadataScanner = void 0;
|
|
31223
|
+
var MetadataScanner_1 = metadataScanner.MetadataScanner = void 0;
|
|
31222
31224
|
const shared_utils_1 = shared_utils;
|
|
31223
31225
|
class MetadataScanner {
|
|
31224
31226
|
constructor() {
|
|
@@ -31298,38 +31300,7 @@ class MetadataScanner {
|
|
|
31298
31300
|
return result;
|
|
31299
31301
|
}
|
|
31300
31302
|
}
|
|
31301
|
-
metadataScanner.MetadataScanner = MetadataScanner;
|
|
31302
|
-
|
|
31303
|
-
var discovery_service = {};
|
|
31304
|
-
|
|
31305
|
-
var constants = {};
|
|
31306
|
-
|
|
31307
|
-
Object.defineProperty(constants, "__esModule", { value: true });
|
|
31308
|
-
constants.STATIC_CONTEXT = constants.CONTROLLER_ID_KEY = void 0;
|
|
31309
|
-
constants.CONTROLLER_ID_KEY = 'CONTROLLER_ID';
|
|
31310
|
-
const STATIC_CONTEXT_ID = 1;
|
|
31311
|
-
constants.STATIC_CONTEXT = Object.freeze({
|
|
31312
|
-
id: STATIC_CONTEXT_ID,
|
|
31313
|
-
});
|
|
31314
|
-
|
|
31315
|
-
var modulesContainer = {};
|
|
31316
|
-
|
|
31317
|
-
Object.defineProperty(modulesContainer, "__esModule", { value: true });
|
|
31318
|
-
modulesContainer.ModulesContainer = void 0;
|
|
31319
|
-
const uid_1 = dist;
|
|
31320
|
-
class ModulesContainer extends Map {
|
|
31321
|
-
constructor() {
|
|
31322
|
-
super(...arguments);
|
|
31323
|
-
this._applicationId = (0, uid_1.uid)(21);
|
|
31324
|
-
}
|
|
31325
|
-
get applicationId() {
|
|
31326
|
-
return this._applicationId;
|
|
31327
|
-
}
|
|
31328
|
-
getById(id) {
|
|
31329
|
-
return Array.from(this.values()).find(moduleRef => moduleRef.id === id);
|
|
31330
|
-
}
|
|
31331
|
-
}
|
|
31332
|
-
modulesContainer.ModulesContainer = ModulesContainer;
|
|
31303
|
+
MetadataScanner_1 = metadataScanner.MetadataScanner = MetadataScanner;
|
|
31333
31304
|
|
|
31334
31305
|
var lodash = {exports: {}};
|
|
31335
31306
|
|
|
@@ -48532,24 +48503,6 @@ var lodash = {exports: {}};
|
|
|
48532
48503
|
}.call(commonjsGlobal));
|
|
48533
48504
|
}(lodash, lodash.exports));
|
|
48534
48505
|
|
|
48535
|
-
(function (exports) {
|
|
48536
|
-
var __decorate = (commonjsGlobal && commonjsGlobal.__decorate) || function (decorators, target, key, desc) {
|
|
48537
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
48538
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
48539
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
48540
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
48541
|
-
};
|
|
48542
|
-
var __metadata = (commonjsGlobal && commonjsGlobal.__metadata) || function (k, v) {
|
|
48543
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
48544
|
-
};
|
|
48545
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48546
|
-
exports.DiscoveryService = exports.withMetaAtKey = exports.getComponentMetaAtKey = void 0;
|
|
48547
|
-
const common_1 = common;
|
|
48548
|
-
const constants_1 = constants$2;
|
|
48549
|
-
const constants_2 = constants;
|
|
48550
|
-
const modules_container_1 = modulesContainer;
|
|
48551
|
-
const metadata_scanner_1 = metadataScanner;
|
|
48552
|
-
const lodash_1 = lodash.exports;
|
|
48553
48506
|
/**
|
|
48554
48507
|
* Attempts to retrieve meta information from a Nest DiscoveredClass component
|
|
48555
48508
|
* @param key The meta key to retrieve data from
|
|
@@ -48564,7 +48517,6 @@ function getComponentMetaAtKey(key, component) {
|
|
|
48564
48517
|
return Reflect.getMetadata(key, component.injectType);
|
|
48565
48518
|
}
|
|
48566
48519
|
}
|
|
48567
|
-
exports.getComponentMetaAtKey = getComponentMetaAtKey;
|
|
48568
48520
|
/**
|
|
48569
48521
|
* A filter that can be used to search for DiscoveredClasses in an App that contain meta attached to a
|
|
48570
48522
|
* certain key
|
|
@@ -48573,14 +48525,24 @@ exports.getComponentMetaAtKey = getComponentMetaAtKey;
|
|
|
48573
48525
|
const withMetaAtKey = (key) => (component) => {
|
|
48574
48526
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
48575
48527
|
const metaTargets = [
|
|
48576
|
-
|
|
48528
|
+
lodash.exports.get(component, "instance.constructor"),
|
|
48577
48529
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
48578
48530
|
component.injectType,
|
|
48579
|
-
].filter((x) => x
|
|
48580
|
-
return
|
|
48531
|
+
].filter((x) => !lodash.exports.isNil(x));
|
|
48532
|
+
return lodash.exports.some(metaTargets, (x) => Reflect.getMetadata(key, x));
|
|
48581
48533
|
};
|
|
48582
|
-
|
|
48583
|
-
|
|
48534
|
+
let ModulesContainerProvider = class ModulesContainerProvider {
|
|
48535
|
+
setModulesContainer(modulesContainer) {
|
|
48536
|
+
this.modulesContainer = modulesContainer;
|
|
48537
|
+
}
|
|
48538
|
+
getModules() {
|
|
48539
|
+
return [...this.modulesContainer.entries()];
|
|
48540
|
+
}
|
|
48541
|
+
};
|
|
48542
|
+
ModulesContainerProvider = __decorate([
|
|
48543
|
+
common.Injectable()
|
|
48544
|
+
], ModulesContainerProvider);
|
|
48545
|
+
let CustomDiscoveryService = class CustomDiscoveryService {
|
|
48584
48546
|
constructor(modulesContainer, metadataScanner) {
|
|
48585
48547
|
this.modulesContainer = modulesContainer;
|
|
48586
48548
|
this.metadataScanner = metadataScanner;
|
|
@@ -48591,7 +48553,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48591
48553
|
*/
|
|
48592
48554
|
async providers(filter) {
|
|
48593
48555
|
if (!this.discoveredProviders) {
|
|
48594
|
-
this.discoveredProviders = this.discover(
|
|
48556
|
+
this.discoveredProviders = this.discover("providers");
|
|
48595
48557
|
}
|
|
48596
48558
|
return (await this.discoveredProviders).filter((x) => filter(x));
|
|
48597
48559
|
}
|
|
@@ -48603,18 +48565,18 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48603
48565
|
*/
|
|
48604
48566
|
async methodsAndControllerMethodsWithMetaAtKey(metaKey, metaFilter = () => true) {
|
|
48605
48567
|
const controllersWithMeta = (await this.controllersWithMetaAtKey(metaKey)).filter((x) => metaFilter(x.meta));
|
|
48606
|
-
const methodsFromDecoratedControllers =
|
|
48607
|
-
return this.classMethodsWithMetaAtKey(controller.discoveredClass,
|
|
48568
|
+
const methodsFromDecoratedControllers = lodash.exports.flatMap(controllersWithMeta, (controller) => {
|
|
48569
|
+
return this.classMethodsWithMetaAtKey(controller.discoveredClass, constants$2.PATH_METADATA);
|
|
48608
48570
|
});
|
|
48609
48571
|
const decoratedMethods = (await this.controllerMethodsWithMetaAtKey(metaKey)).filter((x) => metaFilter(x.meta));
|
|
48610
|
-
return
|
|
48572
|
+
return lodash.exports.uniqBy([...methodsFromDecoratedControllers, ...decoratedMethods], (x) => x.discoveredMethod.handler);
|
|
48611
48573
|
}
|
|
48612
48574
|
/**
|
|
48613
48575
|
* Discovers all providers in an App that have meta at a specific key and returns the provider(s) and associated meta
|
|
48614
48576
|
* @param metaKey The metakey to scan for
|
|
48615
48577
|
*/
|
|
48616
48578
|
async providersWithMetaAtKey(metaKey) {
|
|
48617
|
-
const providers = await this.providers(
|
|
48579
|
+
const providers = await this.providers(withMetaAtKey(metaKey));
|
|
48618
48580
|
return providers.map((x) => ({
|
|
48619
48581
|
meta: getComponentMetaAtKey(metaKey, x),
|
|
48620
48582
|
discoveredClass: x,
|
|
@@ -48626,7 +48588,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48626
48588
|
*/
|
|
48627
48589
|
async controllers(filter) {
|
|
48628
48590
|
if (!this.discoveredControllers) {
|
|
48629
|
-
this.discoveredControllers = this.discover(
|
|
48591
|
+
this.discoveredControllers = this.discover("controllers");
|
|
48630
48592
|
}
|
|
48631
48593
|
return (await this.discoveredControllers).filter((x) => filter(x));
|
|
48632
48594
|
}
|
|
@@ -48635,7 +48597,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48635
48597
|
* @param metaKey The metakey to scan for
|
|
48636
48598
|
*/
|
|
48637
48599
|
async controllersWithMetaAtKey(metaKey) {
|
|
48638
|
-
const controllers = await this.controllers(
|
|
48600
|
+
const controllers = await this.controllers(withMetaAtKey(metaKey));
|
|
48639
48601
|
return controllers.map((x) => ({
|
|
48640
48602
|
meta: getComponentMetaAtKey(metaKey, x),
|
|
48641
48603
|
discoveredClass: x,
|
|
@@ -48654,7 +48616,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48654
48616
|
const prototype = Object.getPrototypeOf(instance);
|
|
48655
48617
|
return this.metadataScanner
|
|
48656
48618
|
.scanFromPrototype(instance, prototype, (name) => this.extractMethodMetaAtKey(metaKey, component, prototype, name))
|
|
48657
|
-
.filter((x) => !
|
|
48619
|
+
.filter((x) => !lodash.exports.isNil(x.meta));
|
|
48658
48620
|
}
|
|
48659
48621
|
/**
|
|
48660
48622
|
* Discovers all the methods that exist on providers in a Nest App that contain metadata under a specific key
|
|
@@ -48663,7 +48625,7 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48663
48625
|
*/
|
|
48664
48626
|
async providerMethodsWithMetaAtKey(metaKey, providerFilter = () => true) {
|
|
48665
48627
|
const providers = await this.providers(providerFilter);
|
|
48666
|
-
return
|
|
48628
|
+
return lodash.exports.flatMap(providers, (provider) => this.classMethodsWithMetaAtKey(provider, metaKey));
|
|
48667
48629
|
}
|
|
48668
48630
|
/**
|
|
48669
48631
|
* Discovers all the methods that exist on controllers in a Nest App that contain metadata under a specific key
|
|
@@ -48672,10 +48634,10 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48672
48634
|
*/
|
|
48673
48635
|
async controllerMethodsWithMetaAtKey(metaKey, controllerFilter = () => true) {
|
|
48674
48636
|
const controllers = await this.controllers(controllerFilter);
|
|
48675
|
-
return
|
|
48637
|
+
return lodash.exports.flatMap(controllers, (controller) => this.classMethodsWithMetaAtKey(controller, metaKey));
|
|
48676
48638
|
}
|
|
48677
48639
|
async toDiscoveredClass(nestModule, wrapper) {
|
|
48678
|
-
const instanceHost = wrapper.getInstanceByContextId(
|
|
48640
|
+
const instanceHost = wrapper.getInstanceByContextId(STATIC_CONTEXT, wrapper && wrapper.id ? wrapper.id : undefined);
|
|
48679
48641
|
if (instanceHost.isPending && !instanceHost.isResolved) {
|
|
48680
48642
|
await instanceHost.donePromise;
|
|
48681
48643
|
}
|
|
@@ -48683,13 +48645,15 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48683
48645
|
name: wrapper.name,
|
|
48684
48646
|
instance: instanceHost.instance,
|
|
48685
48647
|
injectType: wrapper.metatype,
|
|
48686
|
-
dependencyType:
|
|
48687
|
-
parentModule:
|
|
48688
|
-
|
|
48689
|
-
|
|
48690
|
-
|
|
48691
|
-
|
|
48692
|
-
|
|
48648
|
+
dependencyType: lodash.exports.get(instanceHost, "instance.constructor"),
|
|
48649
|
+
parentModule: nestModule
|
|
48650
|
+
? {
|
|
48651
|
+
name: nestModule.metatype.name,
|
|
48652
|
+
instance: nestModule.instance,
|
|
48653
|
+
injectType: nestModule.metatype,
|
|
48654
|
+
dependencyType: nestModule.instance.constructor,
|
|
48655
|
+
}
|
|
48656
|
+
: undefined,
|
|
48693
48657
|
};
|
|
48694
48658
|
}
|
|
48695
48659
|
extractMethodMetaAtKey(metaKey, discoveredClass, prototype, methodName) {
|
|
@@ -48705,71 +48669,45 @@ let DiscoveryService = class DiscoveryService {
|
|
|
48705
48669
|
};
|
|
48706
48670
|
}
|
|
48707
48671
|
async discover(component) {
|
|
48708
|
-
const modulesMap =
|
|
48672
|
+
const modulesMap = this.getModuleEntries();
|
|
48709
48673
|
return Promise.all(
|
|
48710
|
-
//
|
|
48711
|
-
|
|
48674
|
+
// @ts-ignore
|
|
48675
|
+
lodash.exports.flatMap(modulesMap, ([key, nestModule]) => {
|
|
48712
48676
|
const components = [...nestModule[component].values()];
|
|
48713
48677
|
return components
|
|
48714
|
-
.filter((component) => component.scope !==
|
|
48678
|
+
.filter((component) => component.scope !== common.Scope.REQUEST)
|
|
48715
48679
|
.map((component) => this.toDiscoveredClass(nestModule, component));
|
|
48716
48680
|
}));
|
|
48717
48681
|
}
|
|
48682
|
+
getModuleEntries() {
|
|
48683
|
+
return [...this.modulesContainer.getModules()];
|
|
48684
|
+
}
|
|
48718
48685
|
};
|
|
48719
|
-
|
|
48720
|
-
|
|
48721
|
-
|
|
48722
|
-
|
|
48723
|
-
]
|
|
48724
|
-
|
|
48725
|
-
|
|
48726
|
-
}(discovery_service));
|
|
48727
|
-
|
|
48728
|
-
var __decorate = (commonjsGlobal && commonjsGlobal.__decorate) || function (decorators, target, key, desc) {
|
|
48729
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
48730
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
48731
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
48732
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
48733
|
-
};
|
|
48734
|
-
Object.defineProperty(discovery_module, "__esModule", { value: true });
|
|
48735
|
-
discovery_module.DiscoveryModule = void 0;
|
|
48736
|
-
const common_1 = common;
|
|
48737
|
-
const metadata_scanner_1 = metadataScanner;
|
|
48738
|
-
const discovery_service_1 = discovery_service;
|
|
48686
|
+
CustomDiscoveryService = __decorate([
|
|
48687
|
+
common.Injectable(),
|
|
48688
|
+
__param(0, common.Inject("MODULES_CONTAINER")),
|
|
48689
|
+
__metadata("design:paramtypes", [ModulesContainerProvider,
|
|
48690
|
+
MetadataScanner_1])
|
|
48691
|
+
], CustomDiscoveryService);
|
|
48739
48692
|
/**
|
|
48740
48693
|
* Exposes a query API over top of the NestJS Module container
|
|
48741
48694
|
*
|
|
48742
48695
|
* @export
|
|
48743
48696
|
* @class DiscoveryModule
|
|
48744
48697
|
*/
|
|
48745
|
-
let
|
|
48698
|
+
let CustomDiscoveryModule = class CustomDiscoveryModule {
|
|
48746
48699
|
};
|
|
48747
|
-
|
|
48748
|
-
|
|
48749
|
-
|
|
48750
|
-
providers: [
|
|
48751
|
-
|
|
48700
|
+
CustomDiscoveryModule = __decorate([
|
|
48701
|
+
common.Global(),
|
|
48702
|
+
common.Module({
|
|
48703
|
+
providers: [
|
|
48704
|
+
CustomDiscoveryService,
|
|
48705
|
+
MetadataScanner_1,
|
|
48706
|
+
ModulesContainerProvider,
|
|
48707
|
+
],
|
|
48708
|
+
exports: [CustomDiscoveryService],
|
|
48752
48709
|
})
|
|
48753
|
-
],
|
|
48754
|
-
discovery_module.DiscoveryModule = DiscoveryModule;
|
|
48755
|
-
|
|
48756
|
-
(function (exports) {
|
|
48757
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
48758
|
-
if (k2 === undefined) k2 = k;
|
|
48759
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
48760
|
-
}) : (function(o, m, k, k2) {
|
|
48761
|
-
if (k2 === undefined) k2 = k;
|
|
48762
|
-
o[k2] = m[k];
|
|
48763
|
-
}));
|
|
48764
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
48765
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
48766
|
-
};
|
|
48767
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48768
|
-
__exportStar(discovery_interfaces, exports);
|
|
48769
|
-
__exportStar(discovery_module, exports);
|
|
48770
|
-
__exportStar(discovery_service, exports);
|
|
48771
|
-
|
|
48772
|
-
}(lib));
|
|
48710
|
+
], CustomDiscoveryModule);
|
|
48773
48711
|
|
|
48774
48712
|
const Services = [];
|
|
48775
48713
|
|
|
@@ -48839,9 +48777,9 @@ let EntityManagerInitializer = EntityManagerInitializer_1 = class EntityManagerI
|
|
|
48839
48777
|
return await this.discover.providersWithMetaAtKey(EntityManagerSymbols.EntityAuthMiddleware);
|
|
48840
48778
|
}
|
|
48841
48779
|
};
|
|
48842
|
-
EntityManagerInitializer = EntityManagerInitializer_1 = __decorate
|
|
48780
|
+
EntityManagerInitializer = EntityManagerInitializer_1 = __decorate([
|
|
48843
48781
|
common.Injectable(),
|
|
48844
|
-
__metadata("design:paramtypes", [
|
|
48782
|
+
__metadata("design:paramtypes", [CustomDiscoveryService,
|
|
48845
48783
|
EntityManagerRegistry])
|
|
48846
48784
|
], EntityManagerInitializer);
|
|
48847
48785
|
|
|
@@ -48851,16 +48789,10 @@ const IoC = [EntityManagerRegistry];
|
|
|
48851
48789
|
|
|
48852
48790
|
let EntityManagerModule = class EntityManagerModule {
|
|
48853
48791
|
};
|
|
48854
|
-
EntityManagerModule = __decorate
|
|
48792
|
+
EntityManagerModule = __decorate([
|
|
48855
48793
|
common.Module({
|
|
48856
|
-
imports: [
|
|
48857
|
-
providers: [
|
|
48858
|
-
...IoC,
|
|
48859
|
-
...Processors,
|
|
48860
|
-
...Services,
|
|
48861
|
-
// DiscoveryService,
|
|
48862
|
-
// MetadataScanner,
|
|
48863
|
-
],
|
|
48794
|
+
imports: [CustomDiscoveryModule],
|
|
48795
|
+
providers: [...IoC, ...Processors, ...Services],
|
|
48864
48796
|
exports: [EntityManagerRegistry, ...Services],
|
|
48865
48797
|
})
|
|
48866
48798
|
], EntityManagerModule);
|