moost 0.2.26 → 0.2.27
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 +24 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +23 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -314,7 +314,7 @@ function Required() {
|
|
|
314
314
|
function Resolve(resolver, label) {
|
|
315
315
|
return (target, key, index) => {
|
|
316
316
|
const i = typeof index === 'number' ? index : undefined;
|
|
317
|
-
fillLabel(target, key, i, label);
|
|
317
|
+
fillLabel(target, key || '', i, label);
|
|
318
318
|
getMoostMate().decorate('resolver', resolver)(target, key, i);
|
|
319
319
|
};
|
|
320
320
|
}
|
|
@@ -835,6 +835,27 @@ const validatePipe = (opts) => {
|
|
|
835
835
|
return pipe;
|
|
836
836
|
};
|
|
837
837
|
|
|
838
|
+
function setControllerContext(controller, method) {
|
|
839
|
+
const { store } = eventCore.useEventContext();
|
|
840
|
+
const { set } = store('controller');
|
|
841
|
+
set('instance', controller);
|
|
842
|
+
set('method', method);
|
|
843
|
+
}
|
|
844
|
+
function useControllerContext() {
|
|
845
|
+
const { store } = eventCore.useEventContext();
|
|
846
|
+
const { get } = store('controller');
|
|
847
|
+
const getController = () => get('instance');
|
|
848
|
+
const getMethod = () => get('method');
|
|
849
|
+
const getControllerMeta = () => getMoostMate().read(getController());
|
|
850
|
+
const getMethodMeta = () => getMoostMate().read(getController(), getMethod());
|
|
851
|
+
return {
|
|
852
|
+
getController,
|
|
853
|
+
getMethod,
|
|
854
|
+
getControllerMeta,
|
|
855
|
+
getMethodMeta,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
838
859
|
exports.Circular = Circular;
|
|
839
860
|
exports.Const = Const;
|
|
840
861
|
exports.ConstFactory = ConstFactory;
|
|
@@ -868,4 +889,6 @@ exports.getMoostInfact = getMoostInfact;
|
|
|
868
889
|
exports.getMoostMate = getMoostMate;
|
|
869
890
|
exports.getNewMoostInfact = getNewMoostInfact;
|
|
870
891
|
exports.resolvePipe = resolvePipe;
|
|
892
|
+
exports.setControllerContext = setControllerContext;
|
|
893
|
+
exports.useControllerContext = useControllerContext;
|
|
871
894
|
exports.validatePipe = validatePipe;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Infact } from '@prostojs/infact';
|
|
2
2
|
import { Mate } from '@prostojs/mate';
|
|
3
3
|
import { TConsoleBase } from '@prostojs/logger';
|
|
4
|
+
import { TMateClassMeta } from '@prostojs/mate';
|
|
5
|
+
import { TMateParamMeta } from '@prostojs/mate';
|
|
6
|
+
import { TMatePropMeta } from '@prostojs/mate';
|
|
4
7
|
import { TProvideFn } from '@prostojs/infact';
|
|
5
8
|
import { TProvideRegistry } from '@prostojs/infact';
|
|
6
9
|
import { TValidoDtoOptions } from '@prostojs/valido';
|
|
@@ -193,6 +196,8 @@ export declare function Resolve<T extends TObject = TEmpty>(resolver: (metas: TP
|
|
|
193
196
|
|
|
194
197
|
export declare const resolvePipe: TPipeFn;
|
|
195
198
|
|
|
199
|
+
export declare function setControllerContext<T>(controller: T, method: keyof T): void;
|
|
200
|
+
|
|
196
201
|
declare type TAny = any;
|
|
197
202
|
|
|
198
203
|
declare type TAnyFn = {
|
|
@@ -363,6 +368,13 @@ declare interface TValidatePipeOptions {
|
|
|
363
368
|
errorCb?: (message: string, details: string | TObject) => unknown;
|
|
364
369
|
}
|
|
365
370
|
|
|
371
|
+
export declare function useControllerContext<T extends object>(): {
|
|
372
|
+
getController: () => T;
|
|
373
|
+
getMethod: () => keyof T;
|
|
374
|
+
getControllerMeta: () => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
375
|
+
getMethodMeta: () => Partial<TMoostMetadata & TEmpty & TMateClassMeta & TMatePropMeta<TMoostMetadata & TMoostParamsMetadata & TEmpty> & TMoostParamsMetadata & TMateParamMeta> | undefined;
|
|
376
|
+
};
|
|
377
|
+
|
|
366
378
|
export declare function Validate<T = unknown>(validator: TValidoFn<T>): PropertyDecorator & ParameterDecorator;
|
|
367
379
|
|
|
368
380
|
export declare const validatePipe: (opts?: TValidatePipeOptions) => TPipeFn;
|
package/dist/index.mjs
CHANGED
|
@@ -312,7 +312,7 @@ function Required() {
|
|
|
312
312
|
function Resolve(resolver, label) {
|
|
313
313
|
return (target, key, index) => {
|
|
314
314
|
const i = typeof index === 'number' ? index : undefined;
|
|
315
|
-
fillLabel(target, key, i, label);
|
|
315
|
+
fillLabel(target, key || '', i, label);
|
|
316
316
|
getMoostMate().decorate('resolver', resolver)(target, key, i);
|
|
317
317
|
};
|
|
318
318
|
}
|
|
@@ -833,4 +833,25 @@ const validatePipe = (opts) => {
|
|
|
833
833
|
return pipe;
|
|
834
834
|
};
|
|
835
835
|
|
|
836
|
-
|
|
836
|
+
function setControllerContext(controller, method) {
|
|
837
|
+
const { store } = useEventContext();
|
|
838
|
+
const { set } = store('controller');
|
|
839
|
+
set('instance', controller);
|
|
840
|
+
set('method', method);
|
|
841
|
+
}
|
|
842
|
+
function useControllerContext() {
|
|
843
|
+
const { store } = useEventContext();
|
|
844
|
+
const { get } = store('controller');
|
|
845
|
+
const getController = () => get('instance');
|
|
846
|
+
const getMethod = () => get('method');
|
|
847
|
+
const getControllerMeta = () => getMoostMate().read(getController());
|
|
848
|
+
const getMethodMeta = () => getMoostMate().read(getController(), getMethod());
|
|
849
|
+
return {
|
|
850
|
+
getController,
|
|
851
|
+
getMethod,
|
|
852
|
+
getControllerMeta,
|
|
853
|
+
getMethodMeta,
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
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, setControllerContext, useControllerContext, validatePipe };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
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.2.
|
|
30
|
-
"wooks": "^0.2.
|
|
29
|
+
"@wooksjs/event-core": "^0.2.18",
|
|
30
|
+
"wooks": "^0.2.18"
|
|
31
31
|
},
|
|
32
32
|
"author": "Artem Maltsev",
|
|
33
33
|
"license": "MIT",
|