@rnw-community/nestjs-enterprise 0.69.0
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/LICENSE.md +21 -0
- package/dist/cjs/decorator/log/log.decorator.d.ts +9 -0
- package/dist/cjs/decorator/log/log.decorator.d.ts.map +1 -0
- package/dist/cjs/decorator/log/log.decorator.js +55 -0
- package/dist/cjs/decorator/log/log.decorator.js.map +1 -0
- package/dist/cjs/decorator/log/type/decorated-method.type.d.ts +2 -0
- package/dist/cjs/decorator/log/type/decorated-method.type.d.ts.map +1 -0
- package/dist/cjs/decorator/log/type/decorated-method.type.js +3 -0
- package/dist/cjs/decorator/log/type/decorated-method.type.js.map +1 -0
- package/dist/cjs/decorator/log/type/error-log-function.type.d.ts +2 -0
- package/dist/cjs/decorator/log/type/error-log-function.type.d.ts.map +1 -0
- package/dist/cjs/decorator/log/type/error-log-function.type.js +3 -0
- package/dist/cjs/decorator/log/type/error-log-function.type.js.map +1 -0
- package/dist/cjs/decorator/log/type/method-decorator.type.d.ts +3 -0
- package/dist/cjs/decorator/log/type/method-decorator.type.d.ts.map +1 -0
- package/dist/cjs/decorator/log/type/method-decorator.type.js +3 -0
- package/dist/cjs/decorator/log/type/method-decorator.type.js.map +1 -0
- package/dist/cjs/decorator/log/type/post-log-function.type.d.ts +2 -0
- package/dist/cjs/decorator/log/type/post-log-function.type.d.ts.map +1 -0
- package/dist/cjs/decorator/log/type/post-log-function.type.js +3 -0
- package/dist/cjs/decorator/log/type/post-log-function.type.js.map +1 -0
- package/dist/cjs/decorator/log/type/pre-log-function.type.d.ts +2 -0
- package/dist/cjs/decorator/log/type/pre-log-function.type.d.ts.map +1 -0
- package/dist/cjs/decorator/log/type/pre-log-function.type.js +3 -0
- package/dist/cjs/decorator/log/type/pre-log-function.type.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/decorator/log/log.decorator.d.ts +9 -0
- package/dist/esm/decorator/log/log.decorator.d.ts.map +1 -0
- package/dist/esm/decorator/log/log.decorator.js +51 -0
- package/dist/esm/decorator/log/log.decorator.js.map +1 -0
- package/dist/esm/decorator/log/type/decorated-method.type.d.ts +2 -0
- package/dist/esm/decorator/log/type/decorated-method.type.d.ts.map +1 -0
- package/dist/esm/decorator/log/type/decorated-method.type.js +2 -0
- package/dist/esm/decorator/log/type/decorated-method.type.js.map +1 -0
- package/dist/esm/decorator/log/type/error-log-function.type.d.ts +2 -0
- package/dist/esm/decorator/log/type/error-log-function.type.d.ts.map +1 -0
- package/dist/esm/decorator/log/type/error-log-function.type.js +2 -0
- package/dist/esm/decorator/log/type/error-log-function.type.js.map +1 -0
- package/dist/esm/decorator/log/type/method-decorator.type.d.ts +3 -0
- package/dist/esm/decorator/log/type/method-decorator.type.d.ts.map +1 -0
- package/dist/esm/decorator/log/type/method-decorator.type.js +2 -0
- package/dist/esm/decorator/log/type/method-decorator.type.js.map +1 -0
- package/dist/esm/decorator/log/type/post-log-function.type.d.ts +2 -0
- package/dist/esm/decorator/log/type/post-log-function.type.d.ts.map +1 -0
- package/dist/esm/decorator/log/type/post-log-function.type.js +2 -0
- package/dist/esm/decorator/log/type/post-log-function.type.js.map +1 -0
- package/dist/esm/decorator/log/type/pre-log-function.type.d.ts +2 -0
- package/dist/esm/decorator/log/type/pre-log-function.type.d.ts.map +1 -0
- package/dist/esm/decorator/log/type/pre-log-function.type.js +2 -0
- package/dist/esm/decorator/log/type/pre-log-function.type.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +58 -0
- package/readme.md +22 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2024 Vitalii Yehorov and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Observable } from 'rxjs';
|
|
2
|
+
import type { ErrorLogFunction } from './type/error-log-function.type';
|
|
3
|
+
import type { MethodDecoratorType } from './type/method-decorator.type';
|
|
4
|
+
import type { PostLogFunction } from './type/post-log-function.type';
|
|
5
|
+
import type { PreLogFunction } from './type/pre-log-function.type';
|
|
6
|
+
type GetResultType<T> = T extends Promise<infer U> ? U : T extends Observable<infer U> ? U : T;
|
|
7
|
+
export declare const Log: <TResult, TArgs extends unknown[] = unknown[]>(preLog: string | PreLogFunction<TArgs>, postLog?: string | PostLogFunction<GetResultType<TResult>, TArgs> | undefined, errorLog?: string | ErrorLogFunction<TArgs> | undefined) => MethodDecoratorType<TResult, TArgs>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=log.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAC;AAI/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE/F,eAAO,MAAM,GAAG,uQAyDX,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Log = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const shared_1 = require("@rnw-community/shared");
|
|
7
|
+
const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) => {
|
|
8
|
+
const logContext = `${target.constructor.name}::${String(propertyKey)}`;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
+
const originalMethod = descriptor.value;
|
|
11
|
+
// eslint-disable-next-line max-statements,func-names
|
|
12
|
+
descriptor.value = function (...args) {
|
|
13
|
+
try {
|
|
14
|
+
if ((0, shared_1.isNotEmptyString)(preLog)) {
|
|
15
|
+
common_1.Logger.log(preLog, logContext);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
common_1.Logger.log(preLog(args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
19
|
+
}
|
|
20
|
+
const result = originalMethod.apply(this, args);
|
|
21
|
+
let observableResult = result;
|
|
22
|
+
if (result instanceof Promise) {
|
|
23
|
+
observableResult = (0, rxjs_1.from)(result);
|
|
24
|
+
}
|
|
25
|
+
else if (!(0, rxjs_1.isObservable)(result)) {
|
|
26
|
+
observableResult = (0, rxjs_1.of)(result);
|
|
27
|
+
}
|
|
28
|
+
if ((0, shared_1.isDefined)(postLog)) {
|
|
29
|
+
observableResult.subscribe(res => {
|
|
30
|
+
if ((0, shared_1.isNotEmptyString)(postLog)) {
|
|
31
|
+
common_1.Logger.debug(postLog, logContext);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
common_1.Logger.debug(postLog(res, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if ((0, shared_1.isDefined)(errorLog)) {
|
|
42
|
+
if ((0, shared_1.isNotEmptyString)(errorLog)) {
|
|
43
|
+
common_1.Logger.error(errorLog, logContext);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
common_1.Logger.error(errorLog(error, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return descriptor;
|
|
53
|
+
};
|
|
54
|
+
exports.Log = Log;
|
|
55
|
+
//# sourceMappingURL=log.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,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AAC,EAAE;oBAC7B,IAAI,IAAA,yBAAgB,EAAC,OAAO,CAAC,EAAE,CAAC;wBAC5B,eAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBACtC,CAAC;yBAAM,CAAC;wBACJ,eAAM,CAAC,KAAK,CACR,OAAO,CAAC,GAA6B,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EACnF,UAAU,CACb,CAAC;oBACN,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,IAAA,kBAAS,EAAC,QAAQ,CAAC,EAAE,CAAC;gBACtB,IAAI,IAAA,yBAAgB,EAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7B,eAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;gBACvC,CAAC;qBAAM,CAAC;oBACJ,eAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBAC3F,CAAC;YACL,CAAC;YAED,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAzDO,QAAA,GAAG,OAyDV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-method.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/decorated-method.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-method.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/decorated-method.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/error-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,CACpD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/error-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DecoratedMethodType } from './decorated-method.type';
|
|
2
|
+
export type MethodDecoratorType<TResult, TArgs extends unknown[]> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>>) => TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>> | void;
|
|
3
|
+
//# sourceMappingURL=method-decorator.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/method-decorator.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CAChE,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,KAEvE,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-decorator.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/method-decorator.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/post-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CACtD,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/post-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/pre-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,CAClD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/pre-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Log = void 0;
|
|
4
|
+
var log_decorator_1 = require("./decorator/log/log.decorator");
|
|
5
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return log_decorator_1.Log; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,+DAAoD;AAA3C,oGAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Observable } from 'rxjs';
|
|
2
|
+
import type { ErrorLogFunction } from './type/error-log-function.type';
|
|
3
|
+
import type { MethodDecoratorType } from './type/method-decorator.type';
|
|
4
|
+
import type { PostLogFunction } from './type/post-log-function.type';
|
|
5
|
+
import type { PreLogFunction } from './type/pre-log-function.type';
|
|
6
|
+
type GetResultType<T> = T extends Promise<infer U> ? U : T extends Observable<infer U> ? U : T;
|
|
7
|
+
export declare const Log: <TResult, TArgs extends unknown[] = unknown[]>(preLog: string | PreLogFunction<TArgs>, postLog?: string | PostLogFunction<GetResultType<TResult>, TArgs> | undefined, errorLog?: string | ErrorLogFunction<TArgs> | undefined) => MethodDecoratorType<TResult, TArgs>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=log.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,MAAM,CAAC;AAI/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE/F,eAAO,MAAM,GAAG,uQAyDX,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { from, isObservable, of } from 'rxjs';
|
|
3
|
+
import { isDefined, isNotEmptyString } from '@rnw-community/shared';
|
|
4
|
+
export const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) => {
|
|
5
|
+
const logContext = `${target.constructor.name}::${String(propertyKey)}`;
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
|
+
const originalMethod = descriptor.value;
|
|
8
|
+
// eslint-disable-next-line max-statements,func-names
|
|
9
|
+
descriptor.value = function (...args) {
|
|
10
|
+
try {
|
|
11
|
+
if (isNotEmptyString(preLog)) {
|
|
12
|
+
Logger.log(preLog, logContext);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
Logger.log(preLog(args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
16
|
+
}
|
|
17
|
+
const result = originalMethod.apply(this, args);
|
|
18
|
+
let observableResult = result;
|
|
19
|
+
if (result instanceof Promise) {
|
|
20
|
+
observableResult = from(result);
|
|
21
|
+
}
|
|
22
|
+
else if (!isObservable(result)) {
|
|
23
|
+
observableResult = of(result);
|
|
24
|
+
}
|
|
25
|
+
if (isDefined(postLog)) {
|
|
26
|
+
observableResult.subscribe(res => {
|
|
27
|
+
if (isNotEmptyString(postLog)) {
|
|
28
|
+
Logger.debug(postLog, logContext);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
Logger.debug(postLog(res, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (isDefined(errorLog)) {
|
|
39
|
+
if (isNotEmptyString(errorLog)) {
|
|
40
|
+
Logger.error(errorLog, logContext);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
Logger.error(errorLog(error, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return descriptor;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=log.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAmB,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AASpE,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EAAE,CAAC;wBAC5B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBACtC,CAAC;yBAAM,CAAC;wBACJ,MAAM,CAAC,KAAK,CACR,OAAO,CAAC,GAA6B,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EACnF,UAAU,CACb,CAAC;oBACN,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7B,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;gBACvC,CAAC;qBAAM,CAAC;oBACJ,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBAC3F,CAAC;YACL,CAAC;YAED,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-method.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/decorated-method.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorated-method.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/decorated-method.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/error-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,CACpD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/error-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DecoratedMethodType } from './decorated-method.type';
|
|
2
|
+
export type MethodDecoratorType<TResult, TArgs extends unknown[]> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>>) => TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>> | void;
|
|
3
|
+
//# sourceMappingURL=method-decorator.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/method-decorator.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CAChE,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,KAEvE,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-decorator.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/method-decorator.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/post-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,KAAK,SAAS,OAAO,EAAE,IAAI,CACtD,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/post-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-log-function.type.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/log/type/pre-log-function.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,CAClD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KACb,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-log-function.type.js","sourceRoot":"","sources":["../../../../../src/decorator/log/type/pre-log-function.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rnw-community/nestjs-enterprise",
|
|
3
|
+
"version": "0.69.0",
|
|
4
|
+
"description": "NestJS Enterprise is a collection of enterprise-grade modules for NestJS.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nestjs",
|
|
7
|
+
"nestjs decorator",
|
|
8
|
+
"nestjs log decorator",
|
|
9
|
+
"nestjs metrics",
|
|
10
|
+
"nestjs metrics decorator"
|
|
11
|
+
],
|
|
12
|
+
"repository": "https://github.com/rnw-community/rnw-community/tree/master/packages/nestjs-enterprise",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/esm/index.js",
|
|
17
|
+
"require": "./dist/cjs/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "dist/cjs/index.js",
|
|
21
|
+
"module": "dist/esm/index.js",
|
|
22
|
+
"types": "dist/esm/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": "false",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"ts": "run -T tsc --pretty -p tsconfig.json",
|
|
32
|
+
"build:esm": "run -T tsc --pretty -p tsconfig.build-cjs.json",
|
|
33
|
+
"build:cjs": "run -T tsc --pretty -p tsconfig.build-esm.json",
|
|
34
|
+
"build": "yarn build:esm && yarn build:cjs && rm -rf ./dist/*/*.tsbuildinfo",
|
|
35
|
+
"lint": "run -T eslint src",
|
|
36
|
+
"lint:fix": "run -T eslint --fix src",
|
|
37
|
+
"test": "run -T jest",
|
|
38
|
+
"test:coverage": "run -T jest --coverage",
|
|
39
|
+
"format": "run -T prettier --write \"./src/**/*.{ts,tsx}\"",
|
|
40
|
+
"clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo",
|
|
41
|
+
"clear:deps": "rm -rf ./node_modules && rm -rf ./dist"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "e28d949b1de59f475d59f19f7d87613552b78d1a",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@rnw-community/shared": "0.69.0"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@nestjs/common": "^10.2.7",
|
|
52
|
+
"rxjs": "^7.8.1"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@nestjs/common": "^10.2.7",
|
|
56
|
+
"rxjs": "^7.8.1"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# NestJS Enterprise
|
|
2
|
+
|
|
3
|
+
NestJS enterprise is a collection of tools and utilities to help you build enterprise-grade applications with NestJS.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/%40rnw-community%2Fnestjs-enterprise)
|
|
6
|
+
[](https://www.npmjs.com/package/%40rnw-community%2Fnestjs-enterprise)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add `@rnw-community/nestjs-enterprise` to your project using you package manager of choice.
|
|
12
|
+
|
|
13
|
+
## Contents
|
|
14
|
+
- [Log Decorator](./src/decorator/log/log-decorator.md)
|
|
15
|
+
|
|
16
|
+
## TODO
|
|
17
|
+
|
|
18
|
+
- [ ] Implement POC for metrics decorator
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
This library is licensed under The [MIT License](./LICENSE.md).
|