moost 0.5.2 → 0.5.4
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 +58 -40
- package/dist/index.d.ts +20 -1
- package/dist/index.mjs +56 -41
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -649,44 +649,6 @@ function Intercept(handler, priority, name) {
|
|
|
649
649
|
}, true);
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
exports.TPipePriority = void 0;
|
|
653
|
-
(function (TPipePriority) {
|
|
654
|
-
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
655
|
-
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
656
|
-
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
657
|
-
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
658
|
-
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
659
|
-
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
660
|
-
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
661
|
-
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
662
|
-
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
663
|
-
})(exports.TPipePriority || (exports.TPipePriority = {}));
|
|
664
|
-
|
|
665
|
-
function Pipe(handler, priority) {
|
|
666
|
-
if (typeof priority !== 'number') {
|
|
667
|
-
priority = typeof handler.priority === 'number' ? handler.priority : exports.TPipePriority.TRANSFORM;
|
|
668
|
-
}
|
|
669
|
-
return getMoostMate().decorate('pipes', { handler, priority }, true);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function Provide(type, fn) {
|
|
673
|
-
return getMoostMate().decorate(meta => {
|
|
674
|
-
meta.provide = meta.provide || {};
|
|
675
|
-
Object.assign(meta.provide, infact$1.createProvideRegistry([type, fn]));
|
|
676
|
-
return meta;
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
function Replace(type, newType) {
|
|
680
|
-
return getMoostMate().decorate(meta => {
|
|
681
|
-
meta.replace = meta.replace || {};
|
|
682
|
-
Object.assign(meta.replace, infact$1.createReplaceRegistry([type, newType]));
|
|
683
|
-
return meta;
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
function Inject(type) {
|
|
687
|
-
return getMoostMate().decorate('inject', type);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
652
|
function Resolve(resolver, label) {
|
|
691
653
|
return (target, key, index) => {
|
|
692
654
|
const i = typeof index === 'number' ? index : undefined;
|
|
@@ -726,6 +688,59 @@ function fillLabel(target, key, index, name) {
|
|
|
726
688
|
}
|
|
727
689
|
}
|
|
728
690
|
|
|
691
|
+
function InjectEventLogger(topic) {
|
|
692
|
+
return Resolve(() => eventCore.useEventLogger(topic));
|
|
693
|
+
}
|
|
694
|
+
function InjectMoostLogger(topic) {
|
|
695
|
+
return Resolve(async () => {
|
|
696
|
+
const { instantiate, getControllerMeta } = useControllerContext();
|
|
697
|
+
const moostApp = await instantiate(Moost);
|
|
698
|
+
const meta = getControllerMeta();
|
|
699
|
+
return moostApp.getLogger(meta?.loggerTopic || topic || meta?.id);
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function LoggerTopic(topic) {
|
|
703
|
+
return getMoostMate().decorate('loggerTopic', topic);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
exports.TPipePriority = void 0;
|
|
707
|
+
(function (TPipePriority) {
|
|
708
|
+
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
709
|
+
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
710
|
+
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
711
|
+
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
712
|
+
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
713
|
+
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
714
|
+
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
715
|
+
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
716
|
+
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
717
|
+
})(exports.TPipePriority || (exports.TPipePriority = {}));
|
|
718
|
+
|
|
719
|
+
function Pipe(handler, priority) {
|
|
720
|
+
if (typeof priority !== 'number') {
|
|
721
|
+
priority = typeof handler.priority === 'number' ? handler.priority : exports.TPipePriority.TRANSFORM;
|
|
722
|
+
}
|
|
723
|
+
return getMoostMate().decorate('pipes', { handler, priority }, true);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function Provide(type, fn) {
|
|
727
|
+
return getMoostMate().decorate(meta => {
|
|
728
|
+
meta.provide = meta.provide || {};
|
|
729
|
+
Object.assign(meta.provide, infact$1.createProvideRegistry([type, fn]));
|
|
730
|
+
return meta;
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
function Replace(type, newType) {
|
|
734
|
+
return getMoostMate().decorate(meta => {
|
|
735
|
+
meta.replace = meta.replace || {};
|
|
736
|
+
Object.assign(meta.replace, infact$1.createReplaceRegistry([type, newType]));
|
|
737
|
+
return meta;
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
function Inject(type) {
|
|
741
|
+
return getMoostMate().decorate('inject', type);
|
|
742
|
+
}
|
|
743
|
+
|
|
729
744
|
function defineInterceptorFn(fn, priority = exports.TInterceptorPriority.INTERCEPTOR) {
|
|
730
745
|
fn.priority = priority;
|
|
731
746
|
return fn;
|
|
@@ -944,8 +959,8 @@ class Moost extends hookable.Hookable {
|
|
|
944
959
|
return this;
|
|
945
960
|
}
|
|
946
961
|
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
947
|
-
const c = stroke ?
|
|
948
|
-
const coff = stroke ?
|
|
962
|
+
const c = stroke ? '\u001B[9m' : '';
|
|
963
|
+
const coff = stroke ? '\u001B[29m' : '';
|
|
949
964
|
this.logger.info(`${prefix || ''}${c}${eventName} ${'[0m' + '[2m' + '[32m' + c}→ ${classConstructor.name}.${'[36m' + c}${method}${'[32m'}()${coff}`);
|
|
950
965
|
}
|
|
951
966
|
}
|
|
@@ -1011,10 +1026,13 @@ exports.Id = Id;
|
|
|
1011
1026
|
exports.ImportController = ImportController;
|
|
1012
1027
|
exports.Inherit = Inherit;
|
|
1013
1028
|
exports.Inject = Inject;
|
|
1029
|
+
exports.InjectEventLogger = InjectEventLogger;
|
|
1030
|
+
exports.InjectMoostLogger = InjectMoostLogger;
|
|
1014
1031
|
exports.Injectable = Injectable;
|
|
1015
1032
|
exports.Intercept = Intercept;
|
|
1016
1033
|
exports.InterceptorHandler = InterceptorHandler;
|
|
1017
1034
|
exports.Label = Label;
|
|
1035
|
+
exports.LoggerTopic = LoggerTopic;
|
|
1018
1036
|
exports.Moost = Moost;
|
|
1019
1037
|
exports.Optional = Optional;
|
|
1020
1038
|
exports.Param = Param;
|
package/dist/index.d.ts
CHANGED
|
@@ -250,6 +250,25 @@ interface TCommonMoostMeta {
|
|
|
250
250
|
*/
|
|
251
251
|
declare function Injectable(scope?: true | TInjectableScope): ClassDecorator;
|
|
252
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Resolves event logger from event context
|
|
255
|
+
* @param topic
|
|
256
|
+
* @returns Resolver to '@wooksjs/event-core' (EventLogger)
|
|
257
|
+
*/
|
|
258
|
+
declare function InjectEventLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
259
|
+
/**
|
|
260
|
+
* Resolves app-level logger
|
|
261
|
+
* @param topic - logger topic (can be overrided by @LoggerTopic)
|
|
262
|
+
* @returns
|
|
263
|
+
*/
|
|
264
|
+
declare function InjectMoostLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
265
|
+
/**
|
|
266
|
+
* Sets logger topic (used in @InjectMoostLogger)
|
|
267
|
+
* @param topic - logger topic (banner)
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
declare function LoggerTopic(topic: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
271
|
+
|
|
253
272
|
/**
|
|
254
273
|
* ## Pipe
|
|
255
274
|
* ### @Decorator
|
|
@@ -640,4 +659,4 @@ type TInterceptorClass = TClassFunction<TInterceptorFn>;
|
|
|
640
659
|
*/
|
|
641
660
|
declare function definePipeFn<T extends TObject = TEmpty>(fn: TPipeFn<T>, priority?: TPipePriority): TPipeFn<T>;
|
|
642
661
|
|
|
643
|
-
export { Circular, Const, ConstFactory, Controller, Description, Id, ImportController, Inherit, Inject, Injectable, Intercept, InterceptorHandler, Label, Moost, Optional, Param, Params, Pipe, Provide, Replace, Required, Resolve, type TCallableClassFunction, type TClassConstructor, type TClassFunction, type TContextInjectorHook, type TControllerOverview, type TInjectableScope, type TInterceptorAfter, type TInterceptorBefore, type TInterceptorClass, type TInterceptorData, type TInterceptorFn, type TInterceptorOnError, TInterceptorPriority, type TMoostAdapter, type TMoostAdapterOptions, type TMoostEventHandlerHookOptions, type TMoostEventHandlerOptions, type TMoostHandler, type TMoostMetadata, type TMoostOptions, type TMoostParamsMetadata, type TPipeData, type TPipeFn, type TPipeMetas, TPipePriority, Value, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, registerEventScope, resolvePipe, setControllerContext, setInfactLoggingOptions, useControllerContext };
|
|
662
|
+
export { Circular, Const, ConstFactory, Controller, Description, Id, ImportController, Inherit, Inject, InjectEventLogger, InjectMoostLogger, Injectable, Intercept, InterceptorHandler, Label, LoggerTopic, Moost, Optional, Param, Params, Pipe, Provide, Replace, Required, Resolve, type TCallableClassFunction, type TClassConstructor, type TClassFunction, type TContextInjectorHook, type TControllerOverview, type TInjectableScope, type TInterceptorAfter, type TInterceptorBefore, type TInterceptorClass, type TInterceptorData, type TInterceptorFn, type TInterceptorOnError, TInterceptorPriority, type TMoostAdapter, type TMoostAdapterOptions, type TMoostEventHandlerHookOptions, type TMoostEventHandlerOptions, type TMoostHandler, type TMoostMetadata, type TMoostOptions, type TMoostParamsMetadata, type TPipeData, type TPipeFn, type TPipeMetas, TPipePriority, Value, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, registerEventScope, resolvePipe, setControllerContext, setInfactLoggingOptions, useControllerContext };
|
package/dist/index.mjs
CHANGED
|
@@ -651,44 +651,6 @@ function Intercept(handler, priority, name) {
|
|
|
651
651
|
}, true);
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
-
var TPipePriority;
|
|
655
|
-
(function (TPipePriority) {
|
|
656
|
-
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
657
|
-
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
658
|
-
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
659
|
-
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
660
|
-
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
661
|
-
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
662
|
-
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
663
|
-
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
664
|
-
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
665
|
-
})(TPipePriority || (TPipePriority = {}));
|
|
666
|
-
|
|
667
|
-
function Pipe(handler, priority) {
|
|
668
|
-
if (typeof priority !== 'number') {
|
|
669
|
-
priority = typeof handler.priority === 'number' ? handler.priority : TPipePriority.TRANSFORM;
|
|
670
|
-
}
|
|
671
|
-
return getMoostMate().decorate('pipes', { handler, priority }, true);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
function Provide(type, fn) {
|
|
675
|
-
return getMoostMate().decorate(meta => {
|
|
676
|
-
meta.provide = meta.provide || {};
|
|
677
|
-
Object.assign(meta.provide, createProvideRegistry([type, fn]));
|
|
678
|
-
return meta;
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
function Replace(type, newType) {
|
|
682
|
-
return getMoostMate().decorate(meta => {
|
|
683
|
-
meta.replace = meta.replace || {};
|
|
684
|
-
Object.assign(meta.replace, createReplaceRegistry([type, newType]));
|
|
685
|
-
return meta;
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
function Inject(type) {
|
|
689
|
-
return getMoostMate().decorate('inject', type);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
654
|
function Resolve(resolver, label) {
|
|
693
655
|
return (target, key, index) => {
|
|
694
656
|
const i = typeof index === 'number' ? index : undefined;
|
|
@@ -728,6 +690,59 @@ function fillLabel(target, key, index, name) {
|
|
|
728
690
|
}
|
|
729
691
|
}
|
|
730
692
|
|
|
693
|
+
function InjectEventLogger(topic) {
|
|
694
|
+
return Resolve(() => useEventLogger(topic));
|
|
695
|
+
}
|
|
696
|
+
function InjectMoostLogger(topic) {
|
|
697
|
+
return Resolve(async () => {
|
|
698
|
+
const { instantiate, getControllerMeta } = useControllerContext();
|
|
699
|
+
const moostApp = await instantiate(Moost);
|
|
700
|
+
const meta = getControllerMeta();
|
|
701
|
+
return moostApp.getLogger(meta?.loggerTopic || topic || meta?.id);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function LoggerTopic(topic) {
|
|
705
|
+
return getMoostMate().decorate('loggerTopic', topic);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
var TPipePriority;
|
|
709
|
+
(function (TPipePriority) {
|
|
710
|
+
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
711
|
+
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
712
|
+
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
713
|
+
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
714
|
+
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
715
|
+
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
716
|
+
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
717
|
+
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
718
|
+
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
719
|
+
})(TPipePriority || (TPipePriority = {}));
|
|
720
|
+
|
|
721
|
+
function Pipe(handler, priority) {
|
|
722
|
+
if (typeof priority !== 'number') {
|
|
723
|
+
priority = typeof handler.priority === 'number' ? handler.priority : TPipePriority.TRANSFORM;
|
|
724
|
+
}
|
|
725
|
+
return getMoostMate().decorate('pipes', { handler, priority }, true);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function Provide(type, fn) {
|
|
729
|
+
return getMoostMate().decorate(meta => {
|
|
730
|
+
meta.provide = meta.provide || {};
|
|
731
|
+
Object.assign(meta.provide, createProvideRegistry([type, fn]));
|
|
732
|
+
return meta;
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
function Replace(type, newType) {
|
|
736
|
+
return getMoostMate().decorate(meta => {
|
|
737
|
+
meta.replace = meta.replace || {};
|
|
738
|
+
Object.assign(meta.replace, createReplaceRegistry([type, newType]));
|
|
739
|
+
return meta;
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
function Inject(type) {
|
|
743
|
+
return getMoostMate().decorate('inject', type);
|
|
744
|
+
}
|
|
745
|
+
|
|
731
746
|
function defineInterceptorFn(fn, priority = TInterceptorPriority.INTERCEPTOR) {
|
|
732
747
|
fn.priority = priority;
|
|
733
748
|
return fn;
|
|
@@ -946,10 +961,10 @@ class Moost extends Hookable {
|
|
|
946
961
|
return this;
|
|
947
962
|
}
|
|
948
963
|
logMappedHandler(eventName, classConstructor, method, stroke, prefix) {
|
|
949
|
-
const c = stroke ?
|
|
950
|
-
const coff = stroke ?
|
|
964
|
+
const c = stroke ? '\u001B[9m' : '';
|
|
965
|
+
const coff = stroke ? '\u001B[29m' : '';
|
|
951
966
|
this.logger.info(`${prefix || ''}${c}${eventName} ${'[0m' + '[2m' + '[32m' + c}→ ${classConstructor.name}.${'[36m' + c}${method}${'[32m'}()${coff}`);
|
|
952
967
|
}
|
|
953
968
|
}
|
|
954
969
|
|
|
955
|
-
export { Circular, Const, ConstFactory, Controller, Description, Id, ImportController, Inherit, Inject, Injectable, Intercept, InterceptorHandler, Label, Moost, Optional, Param, Params, Pipe, Provide, Replace, Required, Resolve, TInterceptorPriority, TPipePriority, Value, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, registerEventScope, resolvePipe, setControllerContext, setInfactLoggingOptions, useControllerContext };
|
|
970
|
+
export { Circular, Const, ConstFactory, Controller, Description, Id, ImportController, Inherit, Inject, InjectEventLogger, InjectMoostLogger, Injectable, Intercept, InterceptorHandler, Label, LoggerTopic, Moost, Optional, Param, Params, Pipe, Provide, Replace, Required, Resolve, TInterceptorPriority, TPipePriority, Value, defineInterceptorFn, defineMoostEventHandler, definePipeFn, getInstanceOwnMethods, getInstanceOwnProps, getMoostInfact, getMoostMate, getNewMoostInfact, registerEventScope, resolvePipe, setControllerContext, setInfactLoggingOptions, useControllerContext };
|