moost 0.2.19 → 0.2.21
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/index.cjs +47 -32
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +48 -34
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var mate = require('@prostojs/mate');
|
|
|
4
4
|
var infact = require('@prostojs/infact');
|
|
5
5
|
var eventCore = require('@wooksjs/event-core');
|
|
6
6
|
var valido$1 = require('@prostojs/valido');
|
|
7
|
+
var logger = require('@prostojs/logger');
|
|
7
8
|
|
|
8
9
|
/******************************************************************************
|
|
9
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -114,33 +115,18 @@ function getParentProps(constructor) {
|
|
|
114
115
|
return [];
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/* istanbul ignore file */
|
|
120
|
-
function log(text) {
|
|
121
|
-
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
122
|
-
}
|
|
123
|
-
function logError(error) {
|
|
124
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function panic(error) {
|
|
128
|
-
logError(error);
|
|
129
|
-
return new Error(error);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getCallableFn(targetInstance, fn, restoreCtx, pipes, silent) {
|
|
118
|
+
function getCallableFn(targetInstance, fn, restoreCtx, pipes, logger) {
|
|
133
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
120
|
const mate$1 = getMoostMate();
|
|
135
121
|
const meta = mate$1.read(fn);
|
|
136
122
|
if (meta === null || meta === void 0 ? void 0 : meta.injectable) {
|
|
137
123
|
const infact = getMoostInfact();
|
|
138
|
-
infact.silent(
|
|
124
|
+
infact.silent(true);
|
|
139
125
|
const instance = yield infact.getForInstance(targetInstance, fn, {
|
|
140
126
|
syncContextFn: () => { restoreCtx && restoreCtx(); },
|
|
141
127
|
customData: { pipes: [...(pipes || []), ...(meta.pipes || [])].sort((a, b) => a.priority - b.priority) },
|
|
142
128
|
});
|
|
143
|
-
infact.silent(
|
|
129
|
+
infact.silent(false);
|
|
144
130
|
return ((...args) => {
|
|
145
131
|
return instance.handler(...args);
|
|
146
132
|
});
|
|
@@ -148,7 +134,9 @@ function getCallableFn(targetInstance, fn, restoreCtx, pipes, silent) {
|
|
|
148
134
|
if (typeof fn === 'function') {
|
|
149
135
|
return fn;
|
|
150
136
|
}
|
|
151
|
-
|
|
137
|
+
const e = new Error(`getCallableFn failed for "${mate.getConstructor(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
138
|
+
logger.error(e);
|
|
139
|
+
throw e;
|
|
152
140
|
});
|
|
153
141
|
}
|
|
154
142
|
|
|
@@ -239,7 +227,7 @@ function bindControllerMethods(options) {
|
|
|
239
227
|
const { restoreCtx } = eventCore.useEventContext();
|
|
240
228
|
const targetInstance = yield getInstance();
|
|
241
229
|
restoreCtx();
|
|
242
|
-
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.
|
|
230
|
+
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.logger))(...args);
|
|
243
231
|
}));
|
|
244
232
|
}
|
|
245
233
|
else {
|
|
@@ -275,7 +263,6 @@ function bindControllerMethods(options) {
|
|
|
275
263
|
yield adapter.bindHandler({
|
|
276
264
|
prefix,
|
|
277
265
|
fakeInstance,
|
|
278
|
-
silent: opts.silent,
|
|
279
266
|
getInstance,
|
|
280
267
|
registerEventScope: (scopeId) => {
|
|
281
268
|
const infact = getMoostInfact();
|
|
@@ -286,7 +273,7 @@ function bindControllerMethods(options) {
|
|
|
286
273
|
handlers: methodMeta.handlers,
|
|
287
274
|
getIterceptorHandler,
|
|
288
275
|
resolveArgs,
|
|
289
|
-
logHandler:
|
|
276
|
+
logHandler: (eventName) => options.logger.info(`• ${eventName} ${'[0m' + '[2m' + '[32m'}→ ${classConstructor.name}.${'[36m'}${method}${'[32m'}()`),
|
|
290
277
|
});
|
|
291
278
|
}
|
|
292
279
|
}
|
|
@@ -368,6 +355,14 @@ function Const(value, label) {
|
|
|
368
355
|
function ConstFactory(factory, label) {
|
|
369
356
|
return Resolve(() => __awaiter(this, void 0, void 0, function* () { return yield factory(); }), label);
|
|
370
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Resolves event logger from event context
|
|
360
|
+
* @param topic
|
|
361
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
362
|
+
*/
|
|
363
|
+
function InjectEventLogger(topic) {
|
|
364
|
+
return Resolve(() => eventCore.useEventLogger(topic));
|
|
365
|
+
}
|
|
371
366
|
function fillLabel(target, key, index, name) {
|
|
372
367
|
if (name) {
|
|
373
368
|
const meta = getMoostMate().read(target, key);
|
|
@@ -563,6 +558,17 @@ function getMoostValido() {
|
|
|
563
558
|
return valido;
|
|
564
559
|
}
|
|
565
560
|
|
|
561
|
+
function getDefaultLogger(topic) {
|
|
562
|
+
return new logger.ProstoLogger({
|
|
563
|
+
level: 4,
|
|
564
|
+
transports: [
|
|
565
|
+
logger.createConsoleTransort({
|
|
566
|
+
format: logger.coloredConsole,
|
|
567
|
+
}),
|
|
568
|
+
],
|
|
569
|
+
}, topic);
|
|
570
|
+
}
|
|
571
|
+
|
|
566
572
|
class Moost {
|
|
567
573
|
constructor(options) {
|
|
568
574
|
this.options = options;
|
|
@@ -571,9 +577,16 @@ class Moost {
|
|
|
571
577
|
this.adapters = [];
|
|
572
578
|
this.provide = infact.createProvideRegistry([infact.Infact, getMoostInfact], [mate.Mate, getMoostMate], [valido$1.Valido, getMoostValido]);
|
|
573
579
|
this.unregisteredControllers = [];
|
|
574
|
-
|
|
575
|
-
|
|
580
|
+
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || getDefaultLogger('moost');
|
|
581
|
+
getMoostInfact().setLogger(this.getLogger('infact'));
|
|
582
|
+
// const mate = getMoostMate()
|
|
583
|
+
// Object.assign(mate, { logger: this.getLogger('mate') })
|
|
584
|
+
}
|
|
585
|
+
getLogger(topic) {
|
|
586
|
+
if (this.logger instanceof logger.ProstoLogger) {
|
|
587
|
+
return this.logger.createTopic(topic);
|
|
576
588
|
}
|
|
589
|
+
return this.logger;
|
|
577
590
|
}
|
|
578
591
|
adapter(a) {
|
|
579
592
|
this.adapters.push(a);
|
|
@@ -601,6 +614,8 @@ class Moost {
|
|
|
601
614
|
bindControllers() {
|
|
602
615
|
var _a;
|
|
603
616
|
return __awaiter(this, void 0, void 0, function* () {
|
|
617
|
+
const infact = getMoostInfact();
|
|
618
|
+
infact.setLogger(this.logger);
|
|
604
619
|
const meta = getMoostMate();
|
|
605
620
|
const thisMeta = meta.read(this);
|
|
606
621
|
const provide = Object.assign(Object.assign({}, ((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.provide) || {})), this.provide);
|
|
@@ -611,10 +626,10 @@ class Moost {
|
|
|
611
626
|
});
|
|
612
627
|
}
|
|
613
628
|
bindController(controller, provide, globalPrefix, replaceOwnPrefix) {
|
|
614
|
-
var _a
|
|
629
|
+
var _a;
|
|
615
630
|
return __awaiter(this, void 0, void 0, function* () {
|
|
616
|
-
const
|
|
617
|
-
const classMeta =
|
|
631
|
+
const mate$1 = getMoostMate();
|
|
632
|
+
const classMeta = mate$1.read(controller);
|
|
618
633
|
const infact = getMoostInfact();
|
|
619
634
|
const isControllerConsructor = mate.isConstructor(controller);
|
|
620
635
|
const pipes = [...this.pipes, ...((classMeta === null || classMeta === void 0 ? void 0 : classMeta.pipes) || [])].sort((a, b) => a.priority - b.priority);
|
|
@@ -629,12 +644,11 @@ class Moost {
|
|
|
629
644
|
}
|
|
630
645
|
// getInstance - instance factory for resolving SINGLETON and FOR_EVENT instance
|
|
631
646
|
const getInstance = instance ? () => Promise.resolve(instance) : () => __awaiter(this, void 0, void 0, function* () {
|
|
632
|
-
var _c, _d;
|
|
633
647
|
// if (!instance) {
|
|
634
|
-
infact.silent(
|
|
648
|
+
infact.silent(true);
|
|
635
649
|
const { restoreCtx } = eventCore.useEventContext();
|
|
636
650
|
const instance = yield infact.get(controller, Object.assign(Object.assign({}, infactOpts), { syncContextFn: restoreCtx }));
|
|
637
|
-
infact.silent(
|
|
651
|
+
infact.silent(false);
|
|
638
652
|
// }
|
|
639
653
|
return instance;
|
|
640
654
|
});
|
|
@@ -643,15 +657,15 @@ class Moost {
|
|
|
643
657
|
getInstance,
|
|
644
658
|
classConstructor,
|
|
645
659
|
adapters: this.adapters,
|
|
646
|
-
silent: !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.silent),
|
|
647
660
|
globalPrefix,
|
|
648
661
|
replaceOwnPrefix,
|
|
649
662
|
interceptors: [...this.interceptors],
|
|
650
663
|
pipes,
|
|
651
664
|
provide: (classMeta === null || classMeta === void 0 ? void 0 : classMeta.provide) || {},
|
|
665
|
+
logger: this.logger,
|
|
652
666
|
});
|
|
653
667
|
if (classMeta && classMeta.importController) {
|
|
654
|
-
const prefix = typeof replaceOwnPrefix === 'string' ? replaceOwnPrefix : (
|
|
668
|
+
const prefix = typeof replaceOwnPrefix === 'string' ? replaceOwnPrefix : (_a = classMeta === null || classMeta === void 0 ? void 0 : classMeta.controller) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
655
669
|
const mergedProvide = Object.assign(Object.assign({}, provide), ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.provide) || {}));
|
|
656
670
|
for (const ic of classMeta.importController) {
|
|
657
671
|
if (ic.typeResolver) {
|
|
@@ -830,6 +844,7 @@ exports.Id = Id;
|
|
|
830
844
|
exports.ImportController = ImportController;
|
|
831
845
|
exports.Inherit = Inherit;
|
|
832
846
|
exports.Inject = Inject;
|
|
847
|
+
exports.InjectEventLogger = InjectEventLogger;
|
|
833
848
|
exports.Injectable = Injectable;
|
|
834
849
|
exports.Intercept = Intercept;
|
|
835
850
|
exports.InterceptorHandler = InterceptorHandler;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Infact } from '@prostojs/infact';
|
|
2
2
|
import { Mate } from '@prostojs/mate';
|
|
3
|
+
import { TConsoleBase } from '@prostojs/logger';
|
|
3
4
|
import { TProvideFn } from '@prostojs/infact';
|
|
4
5
|
import { TProvideRegistry } from '@prostojs/infact';
|
|
5
6
|
import { TValidoDtoOptions } from '@prostojs/valido';
|
|
@@ -83,6 +84,13 @@ export declare function Inject(type: string | TClassConstructor): ParameterDecor
|
|
|
83
84
|
*/
|
|
84
85
|
export declare function Injectable(scope?: true | TInjectableScope): ClassDecorator;
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Resolves event logger from event context
|
|
89
|
+
* @param topic
|
|
90
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
91
|
+
*/
|
|
92
|
+
export declare function InjectEventLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
93
|
+
|
|
86
94
|
export declare function Intercept(handler: TCallableClassFunction<TInterceptorFn>, priority?: TInterceptorPriority): ClassDecorator & MethodDecorator;
|
|
87
95
|
|
|
88
96
|
export declare class InterceptorHandler {
|
|
@@ -113,12 +121,14 @@ export declare function Label(value: string): MethodDecorator & ClassDecorator &
|
|
|
113
121
|
|
|
114
122
|
export declare class Moost {
|
|
115
123
|
protected options?: TMoostOptions | undefined;
|
|
124
|
+
protected logger: TConsoleBase;
|
|
116
125
|
protected pipes: TPipeData[];
|
|
117
126
|
protected interceptors: TInterceptorData[];
|
|
118
127
|
protected adapters: TMoostAdapter<TAny>[];
|
|
119
128
|
protected provide: TProvideRegistry;
|
|
120
129
|
protected unregisteredControllers: (TObject | TFunction)[];
|
|
121
130
|
constructor(options?: TMoostOptions | undefined);
|
|
131
|
+
getLogger(topic: string): TConsoleBase;
|
|
122
132
|
adapter<T extends object, A extends TMoostAdapter<T>>(a: A): A;
|
|
123
133
|
init(): Promise<void>;
|
|
124
134
|
protected bindControllers(): Promise<void>;
|
|
@@ -267,7 +277,6 @@ export declare interface TMoostAdapterOptions<H extends object, T extends object
|
|
|
267
277
|
prefix: string;
|
|
268
278
|
fakeInstance: T;
|
|
269
279
|
getInstance: () => Promise<T>;
|
|
270
|
-
silent: boolean;
|
|
271
280
|
method: keyof T;
|
|
272
281
|
handlers: TMoostHandler<H>[];
|
|
273
282
|
getIterceptorHandler: () => Promise<InterceptorHandler>;
|
|
@@ -300,7 +309,7 @@ export declare interface TMoostMetadata extends TCommonMetaFields, TCommonMoostM
|
|
|
300
309
|
|
|
301
310
|
export declare interface TMoostOptions {
|
|
302
311
|
globalPrefix?: string;
|
|
303
|
-
|
|
312
|
+
logger?: TConsoleBase;
|
|
304
313
|
}
|
|
305
314
|
|
|
306
315
|
export declare interface TMoostParamsMetadata extends TCommonMetaFields, TCommonMoostMeta {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Mate, getConstructor, isConstructor } from '@prostojs/mate';
|
|
2
2
|
import { Infact, createProvideRegistry } from '@prostojs/infact';
|
|
3
|
-
import { useEventId, useEventContext, useRouteParams } from '@wooksjs/event-core';
|
|
3
|
+
import { useEventId, useEventContext, useRouteParams, useEventLogger } from '@wooksjs/event-core';
|
|
4
4
|
import { validoIsTypeOf, validoIsString, validoIsNumber, validoIsBoolean, Valido } from '@prostojs/valido';
|
|
5
|
+
import { ProstoLogger, createConsoleTransort, coloredConsole } from '@prostojs/logger';
|
|
5
6
|
|
|
6
7
|
/******************************************************************************
|
|
7
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -112,33 +113,18 @@ function getParentProps(constructor) {
|
|
|
112
113
|
return [];
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/* istanbul ignore file */
|
|
118
|
-
function log(text) {
|
|
119
|
-
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
120
|
-
}
|
|
121
|
-
function logError(error) {
|
|
122
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function panic(error) {
|
|
126
|
-
logError(error);
|
|
127
|
-
return new Error(error);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function getCallableFn(targetInstance, fn, restoreCtx, pipes, silent) {
|
|
116
|
+
function getCallableFn(targetInstance, fn, restoreCtx, pipes, logger) {
|
|
131
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
118
|
const mate = getMoostMate();
|
|
133
119
|
const meta = mate.read(fn);
|
|
134
120
|
if (meta === null || meta === void 0 ? void 0 : meta.injectable) {
|
|
135
121
|
const infact = getMoostInfact();
|
|
136
|
-
infact.silent(
|
|
122
|
+
infact.silent(true);
|
|
137
123
|
const instance = yield infact.getForInstance(targetInstance, fn, {
|
|
138
124
|
syncContextFn: () => { restoreCtx && restoreCtx(); },
|
|
139
125
|
customData: { pipes: [...(pipes || []), ...(meta.pipes || [])].sort((a, b) => a.priority - b.priority) },
|
|
140
126
|
});
|
|
141
|
-
infact.silent(
|
|
127
|
+
infact.silent(false);
|
|
142
128
|
return ((...args) => {
|
|
143
129
|
return instance.handler(...args);
|
|
144
130
|
});
|
|
@@ -146,7 +132,9 @@ function getCallableFn(targetInstance, fn, restoreCtx, pipes, silent) {
|
|
|
146
132
|
if (typeof fn === 'function') {
|
|
147
133
|
return fn;
|
|
148
134
|
}
|
|
149
|
-
|
|
135
|
+
const e = new Error(`getCallableFn failed for "${getConstructor(targetInstance).name}" because the passed arg is not a Function nor TClassFunction`);
|
|
136
|
+
logger.error(e);
|
|
137
|
+
throw e;
|
|
150
138
|
});
|
|
151
139
|
}
|
|
152
140
|
|
|
@@ -237,7 +225,7 @@ function bindControllerMethods(options) {
|
|
|
237
225
|
const { restoreCtx } = useEventContext();
|
|
238
226
|
const targetInstance = yield getInstance();
|
|
239
227
|
restoreCtx();
|
|
240
|
-
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.
|
|
228
|
+
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.logger))(...args);
|
|
241
229
|
}));
|
|
242
230
|
}
|
|
243
231
|
else {
|
|
@@ -273,7 +261,6 @@ function bindControllerMethods(options) {
|
|
|
273
261
|
yield adapter.bindHandler({
|
|
274
262
|
prefix,
|
|
275
263
|
fakeInstance,
|
|
276
|
-
silent: opts.silent,
|
|
277
264
|
getInstance,
|
|
278
265
|
registerEventScope: (scopeId) => {
|
|
279
266
|
const infact = getMoostInfact();
|
|
@@ -284,7 +271,7 @@ function bindControllerMethods(options) {
|
|
|
284
271
|
handlers: methodMeta.handlers,
|
|
285
272
|
getIterceptorHandler,
|
|
286
273
|
resolveArgs,
|
|
287
|
-
logHandler:
|
|
274
|
+
logHandler: (eventName) => options.logger.info(`• ${eventName} ${'[0m' + '[2m' + '[32m'}→ ${classConstructor.name}.${'[36m'}${method}${'[32m'}()`),
|
|
288
275
|
});
|
|
289
276
|
}
|
|
290
277
|
}
|
|
@@ -366,6 +353,14 @@ function Const(value, label) {
|
|
|
366
353
|
function ConstFactory(factory, label) {
|
|
367
354
|
return Resolve(() => __awaiter(this, void 0, void 0, function* () { return yield factory(); }), label);
|
|
368
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Resolves event logger from event context
|
|
358
|
+
* @param topic
|
|
359
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
360
|
+
*/
|
|
361
|
+
function InjectEventLogger(topic) {
|
|
362
|
+
return Resolve(() => useEventLogger(topic));
|
|
363
|
+
}
|
|
369
364
|
function fillLabel(target, key, index, name) {
|
|
370
365
|
if (name) {
|
|
371
366
|
const meta = getMoostMate().read(target, key);
|
|
@@ -561,6 +556,17 @@ function getMoostValido() {
|
|
|
561
556
|
return valido;
|
|
562
557
|
}
|
|
563
558
|
|
|
559
|
+
function getDefaultLogger(topic) {
|
|
560
|
+
return new ProstoLogger({
|
|
561
|
+
level: 4,
|
|
562
|
+
transports: [
|
|
563
|
+
createConsoleTransort({
|
|
564
|
+
format: coloredConsole,
|
|
565
|
+
}),
|
|
566
|
+
],
|
|
567
|
+
}, topic);
|
|
568
|
+
}
|
|
569
|
+
|
|
564
570
|
class Moost {
|
|
565
571
|
constructor(options) {
|
|
566
572
|
this.options = options;
|
|
@@ -569,9 +575,16 @@ class Moost {
|
|
|
569
575
|
this.adapters = [];
|
|
570
576
|
this.provide = createProvideRegistry([Infact, getMoostInfact], [Mate, getMoostMate], [Valido, getMoostValido]);
|
|
571
577
|
this.unregisteredControllers = [];
|
|
572
|
-
|
|
573
|
-
|
|
578
|
+
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || getDefaultLogger('moost');
|
|
579
|
+
getMoostInfact().setLogger(this.getLogger('infact'));
|
|
580
|
+
// const mate = getMoostMate()
|
|
581
|
+
// Object.assign(mate, { logger: this.getLogger('mate') })
|
|
582
|
+
}
|
|
583
|
+
getLogger(topic) {
|
|
584
|
+
if (this.logger instanceof ProstoLogger) {
|
|
585
|
+
return this.logger.createTopic(topic);
|
|
574
586
|
}
|
|
587
|
+
return this.logger;
|
|
575
588
|
}
|
|
576
589
|
adapter(a) {
|
|
577
590
|
this.adapters.push(a);
|
|
@@ -599,6 +612,8 @@ class Moost {
|
|
|
599
612
|
bindControllers() {
|
|
600
613
|
var _a;
|
|
601
614
|
return __awaiter(this, void 0, void 0, function* () {
|
|
615
|
+
const infact = getMoostInfact();
|
|
616
|
+
infact.setLogger(this.logger);
|
|
602
617
|
const meta = getMoostMate();
|
|
603
618
|
const thisMeta = meta.read(this);
|
|
604
619
|
const provide = Object.assign(Object.assign({}, ((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.provide) || {})), this.provide);
|
|
@@ -609,10 +624,10 @@ class Moost {
|
|
|
609
624
|
});
|
|
610
625
|
}
|
|
611
626
|
bindController(controller, provide, globalPrefix, replaceOwnPrefix) {
|
|
612
|
-
var _a
|
|
627
|
+
var _a;
|
|
613
628
|
return __awaiter(this, void 0, void 0, function* () {
|
|
614
|
-
const
|
|
615
|
-
const classMeta =
|
|
629
|
+
const mate = getMoostMate();
|
|
630
|
+
const classMeta = mate.read(controller);
|
|
616
631
|
const infact = getMoostInfact();
|
|
617
632
|
const isControllerConsructor = isConstructor(controller);
|
|
618
633
|
const pipes = [...this.pipes, ...((classMeta === null || classMeta === void 0 ? void 0 : classMeta.pipes) || [])].sort((a, b) => a.priority - b.priority);
|
|
@@ -627,12 +642,11 @@ class Moost {
|
|
|
627
642
|
}
|
|
628
643
|
// getInstance - instance factory for resolving SINGLETON and FOR_EVENT instance
|
|
629
644
|
const getInstance = instance ? () => Promise.resolve(instance) : () => __awaiter(this, void 0, void 0, function* () {
|
|
630
|
-
var _c, _d;
|
|
631
645
|
// if (!instance) {
|
|
632
|
-
infact.silent(
|
|
646
|
+
infact.silent(true);
|
|
633
647
|
const { restoreCtx } = useEventContext();
|
|
634
648
|
const instance = yield infact.get(controller, Object.assign(Object.assign({}, infactOpts), { syncContextFn: restoreCtx }));
|
|
635
|
-
infact.silent(
|
|
649
|
+
infact.silent(false);
|
|
636
650
|
// }
|
|
637
651
|
return instance;
|
|
638
652
|
});
|
|
@@ -641,15 +655,15 @@ class Moost {
|
|
|
641
655
|
getInstance,
|
|
642
656
|
classConstructor,
|
|
643
657
|
adapters: this.adapters,
|
|
644
|
-
silent: !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.silent),
|
|
645
658
|
globalPrefix,
|
|
646
659
|
replaceOwnPrefix,
|
|
647
660
|
interceptors: [...this.interceptors],
|
|
648
661
|
pipes,
|
|
649
662
|
provide: (classMeta === null || classMeta === void 0 ? void 0 : classMeta.provide) || {},
|
|
663
|
+
logger: this.logger,
|
|
650
664
|
});
|
|
651
665
|
if (classMeta && classMeta.importController) {
|
|
652
|
-
const prefix = typeof replaceOwnPrefix === 'string' ? replaceOwnPrefix : (
|
|
666
|
+
const prefix = typeof replaceOwnPrefix === 'string' ? replaceOwnPrefix : (_a = classMeta === null || classMeta === void 0 ? void 0 : classMeta.controller) === null || _a === void 0 ? void 0 : _a.prefix;
|
|
653
667
|
const mergedProvide = Object.assign(Object.assign({}, provide), ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.provide) || {}));
|
|
654
668
|
for (const ic of classMeta.importController) {
|
|
655
669
|
if (ic.typeResolver) {
|
|
@@ -819,4 +833,4 @@ const validatePipe = (opts) => {
|
|
|
819
833
|
return pipe;
|
|
820
834
|
};
|
|
821
835
|
|
|
822
|
-
export { Circular, Const, ConstFactory, Controller, Dto, Id, ImportController, Inherit, Inject, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Nullable, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostInfact, getMoostMate, getNewMoostInfact, resolvePipe, validatePipe };
|
|
836
|
+
export { Circular, Const, ConstFactory, Controller, Dto, Id, ImportController, Inherit, Inject, InjectEventLogger, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Nullable, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostInfact, getMoostMate, getNewMoostInfact, resolvePipe, validatePipe };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
"prostojs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@prostojs/infact": "^0.1.
|
|
26
|
-
"@prostojs/mate": "^0.1.
|
|
25
|
+
"@prostojs/infact": "^0.1.11",
|
|
26
|
+
"@prostojs/mate": "^0.1.14",
|
|
27
|
+
"@prostojs/logger": "^0.3.2",
|
|
27
28
|
"@prostojs/valido": "^0.0.2",
|
|
28
|
-
"@wooksjs/event-core": "^0.2.
|
|
29
|
-
"wooks": "^0.2.
|
|
29
|
+
"@wooksjs/event-core": "^0.2.14",
|
|
30
|
+
"wooks": "^0.2.14"
|
|
30
31
|
},
|
|
31
32
|
"author": "Artem Maltsev",
|
|
32
33
|
"license": "MIT",
|