moost 0.2.30 → 0.2.32
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 +28 -6
- package/dist/index.d.ts +18 -4
- package/dist/index.mjs +22 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -400,8 +400,14 @@ function Required() {
|
|
|
400
400
|
function Resolve(resolver, label) {
|
|
401
401
|
return (target, key, index) => {
|
|
402
402
|
const i = typeof index === 'number' ? index : undefined;
|
|
403
|
-
|
|
404
|
-
|
|
403
|
+
getMoostMate().decorate('resolver', (metas, level) => {
|
|
404
|
+
let newLabel = label;
|
|
405
|
+
if (!newLabel && level === 'PROP' && typeof metas.key === 'string') {
|
|
406
|
+
newLabel = metas.key;
|
|
407
|
+
}
|
|
408
|
+
fillLabel(target, key || '', i, newLabel);
|
|
409
|
+
return resolver(metas, level);
|
|
410
|
+
})(target, key, i);
|
|
405
411
|
};
|
|
406
412
|
}
|
|
407
413
|
/**
|
|
@@ -1076,7 +1082,7 @@ class Moost {
|
|
|
1076
1082
|
* Provides InterceptorHandler with global interceptors and pipes.
|
|
1077
1083
|
* Used to process interceptors when event handler was not found.
|
|
1078
1084
|
*
|
|
1079
|
-
* @returns
|
|
1085
|
+
* @returns IterceptorHandler
|
|
1080
1086
|
*/
|
|
1081
1087
|
getGlobalInterceptorHandler() {
|
|
1082
1088
|
if (!this.globalInterceptorHandler) {
|
|
@@ -1085,9 +1091,9 @@ class Moost {
|
|
|
1085
1091
|
const pipes = [...(this.pipes || []), ...((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.pipes) || [])].sort((a, b) => a.priority - b.priority);
|
|
1086
1092
|
const interceptors = [...this.interceptors, ...((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.interceptors) || [])]
|
|
1087
1093
|
.sort((a, b) => a.priority - b.priority);
|
|
1088
|
-
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger)
|
|
1094
|
+
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger);
|
|
1089
1095
|
}
|
|
1090
|
-
return this.globalInterceptorHandler;
|
|
1096
|
+
return this.globalInterceptorHandler();
|
|
1091
1097
|
}
|
|
1092
1098
|
applyGlobalInterceptors(...items) {
|
|
1093
1099
|
for (const item of items) {
|
|
@@ -1144,12 +1150,20 @@ function useControllerContext() {
|
|
|
1144
1150
|
// todo: add generic types to getControllerMeta
|
|
1145
1151
|
const getControllerMeta = () => getMoostMate().read(getController());
|
|
1146
1152
|
// todo: add generic types to getMethodMeta
|
|
1147
|
-
const getMethodMeta = () => getMoostMate().read(getController(), getMethod());
|
|
1153
|
+
const getMethodMeta = (name) => getMoostMate().read(getController(), name || getMethod());
|
|
1154
|
+
function instantiate(c) {
|
|
1155
|
+
return getMoostInfact().getForInstance(getController(), c);
|
|
1156
|
+
}
|
|
1148
1157
|
return {
|
|
1158
|
+
instantiate,
|
|
1149
1159
|
getController,
|
|
1150
1160
|
getMethod,
|
|
1151
1161
|
getControllerMeta,
|
|
1152
1162
|
getMethodMeta,
|
|
1163
|
+
getPropertiesList: () => { var _a; return ((_a = getControllerMeta()) === null || _a === void 0 ? void 0 : _a.properties) || []; },
|
|
1164
|
+
getScope: () => { var _a; return ((_a = getControllerMeta()) === null || _a === void 0 ? void 0 : _a.injectable) || 'SINGLETON'; },
|
|
1165
|
+
getParamsMeta: () => { var _a; return ((_a = getMethodMeta()) === null || _a === void 0 ? void 0 : _a.params) || []; },
|
|
1166
|
+
getPropMeta: (name) => getMethodMeta(name),
|
|
1153
1167
|
};
|
|
1154
1168
|
}
|
|
1155
1169
|
|
|
@@ -1267,6 +1281,14 @@ function defineMoostEventHandler(options) {
|
|
|
1267
1281
|
});
|
|
1268
1282
|
}
|
|
1269
1283
|
|
|
1284
|
+
Object.defineProperty(exports, 'createProvideRegistry', {
|
|
1285
|
+
enumerable: true,
|
|
1286
|
+
get: function () { return infact$1.createProvideRegistry; }
|
|
1287
|
+
});
|
|
1288
|
+
Object.defineProperty(exports, 'EventLogger', {
|
|
1289
|
+
enumerable: true,
|
|
1290
|
+
get: function () { return eventCore.EventLogger; }
|
|
1291
|
+
});
|
|
1270
1292
|
exports.Circular = Circular;
|
|
1271
1293
|
exports.Const = Const;
|
|
1272
1294
|
exports.ConstFactory = ConstFactory;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { createProvideRegistry } from '@prostojs/infact';
|
|
2
|
+
import { EventLogger } from '@wooksjs/event-core';
|
|
1
3
|
import { Infact } from '@prostojs/infact';
|
|
2
4
|
import { Mate } from '@prostojs/mate';
|
|
3
5
|
import { TConsoleBase } from '@prostojs/logger';
|
|
6
|
+
import { THook } from '@wooksjs/event-core';
|
|
4
7
|
import { TMateClassMeta } from '@prostojs/mate';
|
|
5
8
|
import { TMateParamMeta } from '@prostojs/mate';
|
|
6
9
|
import { TMatePropMeta } from '@prostojs/mate';
|
|
@@ -41,6 +44,8 @@ export declare function ConstFactory<T>(factory: () => T | Promise<T>, label?: s
|
|
|
41
44
|
*/
|
|
42
45
|
export declare function Controller(prefix?: string): ClassDecorator;
|
|
43
46
|
|
|
47
|
+
export { createProvideRegistry }
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* ### Define Interceptor Function
|
|
46
51
|
*
|
|
@@ -98,6 +103,8 @@ export declare function Description(value: string): MethodDecorator & ClassDecor
|
|
|
98
103
|
|
|
99
104
|
export declare function Dto(dtoOptions?: TValidoDtoOptions): ClassDecorator;
|
|
100
105
|
|
|
106
|
+
export { EventLogger }
|
|
107
|
+
|
|
101
108
|
export declare const genericTypesCastPipe: (strict?: boolean) => TPipeFn;
|
|
102
109
|
|
|
103
110
|
export declare function getMoostInfact(): Infact<TMoostMetadata, TMoostMetadata, TMoostParamsMetadata, TCustom>;
|
|
@@ -283,7 +290,7 @@ export declare class Moost {
|
|
|
283
290
|
* @returns
|
|
284
291
|
*/
|
|
285
292
|
getLogger(topic: string): TConsoleBase;
|
|
286
|
-
adapter<T
|
|
293
|
+
adapter<T extends TMoostAdapter<TAny>>(a: T): T;
|
|
287
294
|
/**
|
|
288
295
|
* ### init
|
|
289
296
|
* Ititializes adapter. Must be called after adapters are attached.
|
|
@@ -292,12 +299,12 @@ export declare class Moost {
|
|
|
292
299
|
protected bindControllers(): Promise<void>;
|
|
293
300
|
protected bindController(controller: TFunction | TObject, provide: TProvideRegistry, globalPrefix: string, replaceOwnPrefix?: string): Promise<void>;
|
|
294
301
|
applyGlobalPipes(...items: (TPipeFn | TPipeData)[]): this;
|
|
295
|
-
protected globalInterceptorHandler?: Promise<InterceptorHandler>;
|
|
302
|
+
protected globalInterceptorHandler?: () => Promise<InterceptorHandler>;
|
|
296
303
|
/**
|
|
297
304
|
* Provides InterceptorHandler with global interceptors and pipes.
|
|
298
305
|
* Used to process interceptors when event handler was not found.
|
|
299
306
|
*
|
|
300
|
-
* @returns
|
|
307
|
+
* @returns IterceptorHandler
|
|
301
308
|
*/
|
|
302
309
|
getGlobalInterceptorHandler(): Promise<InterceptorHandler>;
|
|
303
310
|
applyGlobalInterceptors(...items: (TInterceptorData['handler'] | TInterceptorData)[]): this;
|
|
@@ -429,6 +436,8 @@ declare interface TEmpty {
|
|
|
429
436
|
|
|
430
437
|
declare type TFunction = Function;
|
|
431
438
|
|
|
439
|
+
export { THook }
|
|
440
|
+
|
|
432
441
|
export declare type TInjectableScope = 'FOR_EVENT' | 'SINGLETON';
|
|
433
442
|
|
|
434
443
|
export declare type TInterceptorAfter = (response: TAny, reply: (response: TAny) => void) => void | Promise<void>;
|
|
@@ -586,10 +595,15 @@ declare interface TValidatePipeOptions {
|
|
|
586
595
|
}
|
|
587
596
|
|
|
588
597
|
export declare function useControllerContext<T extends object>(): {
|
|
598
|
+
instantiate: <T_1>(c: TClassConstructor<T_1>) => Promise<T_1>;
|
|
589
599
|
getController: () => T;
|
|
590
600
|
getMethod: () => keyof T;
|
|
591
601
|
getControllerMeta: () => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
592
|
-
getMethodMeta: () => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
602
|
+
getMethodMeta: (name?: string) => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
603
|
+
getPropertiesList: () => (string | symbol)[];
|
|
604
|
+
getScope: () => true | TInjectableScope;
|
|
605
|
+
getParamsMeta: () => (TMoostMetadata & TMoostParamsMetadata & TEmpty & TMateParamMeta)[];
|
|
606
|
+
getPropMeta: (name: string) => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
593
607
|
};
|
|
594
608
|
|
|
595
609
|
export declare function Validate<T = unknown>(validator: TValidoFn<T>): PropertyDecorator & ParameterDecorator;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Mate, getConstructor, isConstructor } from '@prostojs/mate';
|
|
2
2
|
import { Infact, createProvideRegistry } from '@prostojs/infact';
|
|
3
|
+
export { createProvideRegistry } from '@prostojs/infact';
|
|
3
4
|
import { useEventId, useEventContext, useRouteParams, useEventLogger } from '@wooksjs/event-core';
|
|
5
|
+
export { EventLogger } from '@wooksjs/event-core';
|
|
4
6
|
import { validoIsTypeOf, validoIsString, validoIsNumber, validoIsBoolean, Valido } from '@prostojs/valido';
|
|
5
7
|
import { ProstoLogger, createConsoleTransort, coloredConsole } from '@prostojs/logger';
|
|
6
8
|
|
|
@@ -398,8 +400,14 @@ function Required() {
|
|
|
398
400
|
function Resolve(resolver, label) {
|
|
399
401
|
return (target, key, index) => {
|
|
400
402
|
const i = typeof index === 'number' ? index : undefined;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
+
getMoostMate().decorate('resolver', (metas, level) => {
|
|
404
|
+
let newLabel = label;
|
|
405
|
+
if (!newLabel && level === 'PROP' && typeof metas.key === 'string') {
|
|
406
|
+
newLabel = metas.key;
|
|
407
|
+
}
|
|
408
|
+
fillLabel(target, key || '', i, newLabel);
|
|
409
|
+
return resolver(metas, level);
|
|
410
|
+
})(target, key, i);
|
|
403
411
|
};
|
|
404
412
|
}
|
|
405
413
|
/**
|
|
@@ -1074,7 +1082,7 @@ class Moost {
|
|
|
1074
1082
|
* Provides InterceptorHandler with global interceptors and pipes.
|
|
1075
1083
|
* Used to process interceptors when event handler was not found.
|
|
1076
1084
|
*
|
|
1077
|
-
* @returns
|
|
1085
|
+
* @returns IterceptorHandler
|
|
1078
1086
|
*/
|
|
1079
1087
|
getGlobalInterceptorHandler() {
|
|
1080
1088
|
if (!this.globalInterceptorHandler) {
|
|
@@ -1083,9 +1091,9 @@ class Moost {
|
|
|
1083
1091
|
const pipes = [...(this.pipes || []), ...((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.pipes) || [])].sort((a, b) => a.priority - b.priority);
|
|
1084
1092
|
const interceptors = [...this.interceptors, ...((thisMeta === null || thisMeta === void 0 ? void 0 : thisMeta.interceptors) || [])]
|
|
1085
1093
|
.sort((a, b) => a.priority - b.priority);
|
|
1086
|
-
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger)
|
|
1094
|
+
this.globalInterceptorHandler = getIterceptorHandlerFactory(interceptors, () => Promise.resolve(this), pipes, this.logger);
|
|
1087
1095
|
}
|
|
1088
|
-
return this.globalInterceptorHandler;
|
|
1096
|
+
return this.globalInterceptorHandler();
|
|
1089
1097
|
}
|
|
1090
1098
|
applyGlobalInterceptors(...items) {
|
|
1091
1099
|
for (const item of items) {
|
|
@@ -1142,12 +1150,20 @@ function useControllerContext() {
|
|
|
1142
1150
|
// todo: add generic types to getControllerMeta
|
|
1143
1151
|
const getControllerMeta = () => getMoostMate().read(getController());
|
|
1144
1152
|
// todo: add generic types to getMethodMeta
|
|
1145
|
-
const getMethodMeta = () => getMoostMate().read(getController(), getMethod());
|
|
1153
|
+
const getMethodMeta = (name) => getMoostMate().read(getController(), name || getMethod());
|
|
1154
|
+
function instantiate(c) {
|
|
1155
|
+
return getMoostInfact().getForInstance(getController(), c);
|
|
1156
|
+
}
|
|
1146
1157
|
return {
|
|
1158
|
+
instantiate,
|
|
1147
1159
|
getController,
|
|
1148
1160
|
getMethod,
|
|
1149
1161
|
getControllerMeta,
|
|
1150
1162
|
getMethodMeta,
|
|
1163
|
+
getPropertiesList: () => { var _a; return ((_a = getControllerMeta()) === null || _a === void 0 ? void 0 : _a.properties) || []; },
|
|
1164
|
+
getScope: () => { var _a; return ((_a = getControllerMeta()) === null || _a === void 0 ? void 0 : _a.injectable) || 'SINGLETON'; },
|
|
1165
|
+
getParamsMeta: () => { var _a; return ((_a = getMethodMeta()) === null || _a === void 0 ? void 0 : _a.params) || []; },
|
|
1166
|
+
getPropMeta: (name) => getMethodMeta(name),
|
|
1151
1167
|
};
|
|
1152
1168
|
}
|
|
1153
1169
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.32",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@prostojs/mate": "^0.1.14",
|
|
27
27
|
"@prostojs/logger": "^0.3.4",
|
|
28
28
|
"@prostojs/valido": "^0.0.2",
|
|
29
|
-
"@wooksjs/event-core": "^0.3.
|
|
30
|
-
"wooks": "^0.3.
|
|
29
|
+
"@wooksjs/event-core": "^0.3.3",
|
|
30
|
+
"wooks": "^0.3.3"
|
|
31
31
|
},
|
|
32
32
|
"author": "Artem Maltsev",
|
|
33
33
|
"license": "MIT",
|