@rnw-community/nestjs-enterprise 1.3.0 → 1.6.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/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.d.ts +1 -1
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.js +5 -1
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.js.map +1 -1
- package/dist/cjs/decorator/lock/lock-observable/lock-observable.decorator.d.ts +1 -1
- package/dist/cjs/decorator/lock/lock-observable/lock-observable.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/lock-observable/lock-observable.decorator.js +10 -2
- package/dist/cjs/decorator/lock/lock-observable/lock-observable.decorator.js.map +1 -1
- package/dist/cjs/decorator/lock/lock-promise/lock-promise.decorator.d.ts +1 -1
- package/dist/cjs/decorator/lock/lock-promise/lock-promise.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/lock-promise/lock-promise.decorator.js +4 -1
- package/dist/cjs/decorator/lock/lock-promise/lock-promise.decorator.js.map +1 -1
- package/dist/cjs/decorator/lock/util/is-promise.util.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/util/run-pre-lock.util.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/util/validate-redlock.util.d.ts.map +1 -1
- package/dist/cjs/decorator/log/log.decorator.d.ts +1 -1
- package/dist/cjs/decorator/log/log.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/log/log.decorator.js +12 -1
- package/dist/cjs/decorator/log/log.decorator.js.map +1 -1
- package/dist/cjs/type/method-decorator.type.d.ts +1 -2
- package/dist/cjs/type/method-decorator.type.d.ts.map +1 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.d.ts +1 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.js +5 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.js.map +1 -1
- package/dist/esm/decorator/lock/lock-observable/lock-observable.decorator.d.ts +1 -1
- package/dist/esm/decorator/lock/lock-observable/lock-observable.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/lock/lock-observable/lock-observable.decorator.js +10 -2
- package/dist/esm/decorator/lock/lock-observable/lock-observable.decorator.js.map +1 -1
- package/dist/esm/decorator/lock/lock-promise/lock-promise.decorator.d.ts +1 -1
- package/dist/esm/decorator/lock/lock-promise/lock-promise.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/lock/lock-promise/lock-promise.decorator.js +4 -1
- package/dist/esm/decorator/lock/lock-promise/lock-promise.decorator.js.map +1 -1
- package/dist/esm/decorator/lock/util/is-promise.util.d.ts.map +1 -1
- package/dist/esm/decorator/lock/util/run-pre-lock.util.d.ts.map +1 -1
- package/dist/esm/decorator/lock/util/validate-redlock.util.d.ts.map +1 -1
- package/dist/esm/decorator/log/log.decorator.d.ts +1 -1
- package/dist/esm/decorator/log/log.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/log/log.decorator.js +12 -1
- package/dist/esm/decorator/log/log.decorator.js.map +1 -1
- package/dist/esm/type/method-decorator.type.d.ts +1 -2
- package/dist/esm/type/method-decorator.type.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/type/decorated-method.type.d.ts +0 -2
- package/dist/cjs/type/decorated-method.type.d.ts.map +0 -1
- package/dist/cjs/type/decorated-method.type.js +0 -3
- package/dist/cjs/type/decorated-method.type.js.map +0 -1
- package/dist/esm/type/decorated-method.type.d.ts +0 -2
- package/dist/esm/type/decorated-method.type.d.ts.map +0 -1
- package/dist/esm/type/decorated-method.type.js +0 -2
- package/dist/esm/type/decorated-method.type.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type HistogramConfiguration } from 'prom-client';
|
|
2
2
|
import type { MethodDecoratorType } from '../../type/method-decorator.type';
|
|
3
|
-
export declare const HistogramMetric: <M extends string,
|
|
3
|
+
export declare const HistogramMetric: <M extends string, K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(metricName: string, configuration?: Omit<HistogramConfiguration<M>, "name">) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=histogram-metric.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-metric.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,sBAAsB,EAAY,MAAM,aAAa,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"histogram-metric.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,sBAAsB,EAAY,MAAM,aAAa,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,eAAO,MAAM,eAAe,GAEvB,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACtG,YAAY,MAAM,EAClB,gBAAgB,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KACxD,mBAAmB,CAAC,CAAC,CA6BvB,CAAC"}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HistogramMetric = void 0;
|
|
4
4
|
const prom_client_1 = require("prom-client");
|
|
5
5
|
const shared_1 = require("@rnw-community/shared");
|
|
6
|
-
const HistogramMetric =
|
|
6
|
+
const HistogramMetric =
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
(metricName, configuration) => (_target, _propertyKey, descriptor) => {
|
|
7
9
|
let histogram = prom_client_1.register.getSingleMetric(metricName);
|
|
8
10
|
if (!(0, shared_1.isDefined)(histogram)) {
|
|
9
11
|
histogram = new prom_client_1.Histogram({
|
|
@@ -18,6 +20,8 @@ const HistogramMetric = (metricName, configuration) => (_target, _propertyKey, d
|
|
|
18
20
|
descriptor.value = function (...args) {
|
|
19
21
|
const endHistogram = histogram.startTimer();
|
|
20
22
|
try {
|
|
23
|
+
// @ts-expect-error We need this to handle generic methods correctly
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,no-invalid-this,@typescript-eslint/no-invalid-this
|
|
21
25
|
return originalMethod.apply(this, args);
|
|
22
26
|
}
|
|
23
27
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":";;;AAAA,6CAA+E;AAE/E,kDAAkD;AAI3C,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":";;;AAAA,6CAA+E;AAE/E,kDAAkD;AAI3C,MAAM,eAAe;AACxB,8DAA8D;AAC9D,CACQ,UAAkB,EAClB,aAAuD,EACjC,EAAE,CAC5B,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE;IAClC,IAAI,SAAS,GAAG,sBAAQ,CAAC,eAAe,CAAC,UAAU,CAA6B,CAAC;IAEjF,IAAI,CAAC,IAAA,kBAAS,EAAC,SAAS,CAAC,EAAE,CAAC;QACxB,SAAS,GAAG,IAAI,uBAAS,CAAC;YACtB,IAAI,EAAE,UAAU;YAChB,GAAG,aAAa;YAChB,IAAI,EAAE,UAAU;SACnB,CAAC,CAAC;IACP,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,qDAAqD;IACrD,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;QACvC,MAAM,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;QAE5C,IAAI,CAAC;YACD,oEAAoE;YACpE,kHAAkH;YAClH,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;gBAAS,CAAC;YACP,YAAY,EAAE,CAAC;QACnB,CAAC;IACL,CAAM,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAlCG,QAAA,eAAe,mBAkClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MethodDecoratorType } from '../../../type/method-decorator.type';
|
|
2
2
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
3
|
-
export declare const LockObservable: <
|
|
3
|
+
export declare const LockObservable: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn$?: (error: unknown) => TResult) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=lock-observable.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-observable.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,cAAc,GAEtB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,gBAAgB,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,KAC5C,mBAAmB,CAAC,CAAC,CA0CvB,CAAC"}
|
|
@@ -5,12 +5,20 @@ const rxjs_1 = require("rxjs");
|
|
|
5
5
|
const shared_1 = require("@rnw-community/shared");
|
|
6
6
|
const run_pre_lock_util_1 = require("../util/run-pre-lock.util");
|
|
7
7
|
const validate_redlock_util_1 = require("../util/validate-redlock.util");
|
|
8
|
-
const LockObservable =
|
|
8
|
+
const LockObservable =
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
(preLock, duration, catchErrorFn$) => (target, propertyKey, descriptor) => {
|
|
9
11
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
12
|
const originalMethod = descriptor.value;
|
|
11
13
|
// eslint-disable-next-line max-statements,func-names
|
|
12
14
|
descriptor.value = function (...args) {
|
|
13
|
-
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
16
|
+
return (0, rxjs_1.of)(true).pipe(
|
|
17
|
+
// eslint-disable-next-line no-invalid-this
|
|
18
|
+
(0, rxjs_1.tap)(() => void (0, validate_redlock_util_1.validateRedlock)(this)), (0, rxjs_1.map)(() => (0, run_pre_lock_util_1.runPreLock)(preLock, ...args)), (0, rxjs_1.concatMap)(lockKeys =>
|
|
19
|
+
// eslint-disable-next-line no-invalid-this
|
|
20
|
+
(0, rxjs_1.from)(this.redlock.acquire(lockKeys, duration)).pipe((0, rxjs_1.concatMap)(currentLock => {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-invalid-this
|
|
14
22
|
const result = originalMethod.apply(this, args);
|
|
15
23
|
if (!(0, rxjs_1.isObservable)(result)) {
|
|
16
24
|
void currentLock.release().catch(() => void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":";;;AAAA,+BAA0G;AAE1G,kDAAkD;AAElD,iEAAuD;AACvD,yEAAgE;AAMzD,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":";;;AAAA,+BAA0G;AAE1G,kDAAkD;AAElD,iEAAuD;AACvD,yEAAgE;AAMzD,MAAM,cAAc;AACvB,8DAA8D;AAC9D,CACQ,OAAyD,EACzD,QAAgB,EAChB,aAA2C,EACrB,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,qDAAqD;IACrD,UAAU,CAAC,KAAK,GAAG,UAAiC,GAAG,IAAW;QAC9D,+DAA+D;QAC/D,OAAO,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC,IAAI;QAChB,2CAA2C;QAC3C,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,KAAK,IAAA,uCAAe,EAAC,IAAI,CAAC,CAAC,EACrC,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,IAAA,8BAAU,EAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,EACvC,IAAA,gBAAS,EAAC,QAAQ,CAAC,EAAE;QACjB,2CAA2C;QAC3C,IAAA,WAAI,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAC/C,IAAA,gBAAS,EAAC,WAAW,CAAC,EAAE;YACpB,uFAAuF;YACvF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAwB,CAAC;YAEvE,IAAI,CAAC,IAAA,mBAAY,EAAC,MAAM,CAAC,EAAE,CAAC;gBACxB,KAAK,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBAE/C,MAAM,IAAI,KAAK,CACX,UAAU,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC,WAAW,CAAC,gCAAgC,CAC5F,CAAC;YACN,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,CACd,IAAA,eAAQ,EAAC,GAAG,EAAE;gBACV,KAAK,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC,CACL,CAAC;QACN,CAAC,CAAC,EACF,IAAA,kBAAS,EAAC,aAAa,CAAC;YACpB,CAAC,CAAC,IAAA,iBAAU,EAAC,CAAC,GAAY,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAwB,CAAC;YACzE,CAAC,CAAC,IAAA,UAAG,GAAE,CACd,CACJ,CACO,CAAC;IACjB,CAAM,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAhDG,QAAA,cAAc,kBAgDjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MethodDecoratorType } from '../../../type/method-decorator.type';
|
|
2
2
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
3
|
-
export declare const LockPromise: <
|
|
3
|
+
export declare const LockPromise: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn?: (error: unknown) => TResult) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=lock-promise.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-promise.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,WAAW,GAEnB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,eAAe,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,KAC3C,mBAAmB,CAAC,CAAC,CA8CvB,CAAC"}
|
|
@@ -4,7 +4,9 @@ exports.LockPromise = void 0;
|
|
|
4
4
|
const shared_1 = require("@rnw-community/shared");
|
|
5
5
|
const run_pre_lock_util_1 = require("../util/run-pre-lock.util");
|
|
6
6
|
const validate_redlock_util_1 = require("../util/validate-redlock.util");
|
|
7
|
-
const LockPromise =
|
|
7
|
+
const LockPromise =
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
(preLock, duration, catchErrorFn) => (target, propertyKey, descriptor) => {
|
|
8
10
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
11
|
const originalMethod = descriptor.value;
|
|
10
12
|
// @ts-expect-error TODO: Provide proper types
|
|
@@ -22,6 +24,7 @@ const LockPromise = (preLock, duration, catchErrorFn) => (target, propertyKey, d
|
|
|
22
24
|
return this.redlock
|
|
23
25
|
.acquire(lockKeys, duration)
|
|
24
26
|
.then(currentLock => {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
25
28
|
const originalResult = originalMethod.apply(this, args);
|
|
26
29
|
if (!(0, shared_1.isPromise)(originalResult)) {
|
|
27
30
|
// HINT: https://github.com/mike-marcacci/node-redlock/issues/168
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":";;;AAAA,kDAA6D;AAE7D,iEAAuD;AACvD,yEAAgE;AAMzD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":";;;AAAA,kDAA6D;AAE7D,iEAAuD;AACvD,yEAAgE;AAMzD,MAAM,WAAW;AACpB,8DAA8D;AAC9D,CACQ,OAAyD,EACzD,QAAgB,EAChB,YAA0C,EACpB,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,8CAA8C;IAC9C,sCAAsC;IACtC,UAAU,CAAC,KAAK,GAAG,UAAiC,GAAG,IAAW;QAC9D,IAAI,QAAQ,GAAa,EAAE,CAAC;QA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AAA,WAAW,eAoDd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-promise.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/is-promise.util.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"is-promise.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/is-promise.util.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAI/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-pre-lock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/run-pre-lock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run-pre-lock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/run-pre-lock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAC1D,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,GAAG,MAAM,KAAK,KACf,MAAM,EAQR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-redlock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/validate-redlock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"validate-redlock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/validate-redlock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,GAAI,MAAM,eAAe,KAAG,IAMvD,CAAC"}
|
|
@@ -4,6 +4,6 @@ import type { PostLogFunction } from './type/post-log-function.type';
|
|
|
4
4
|
import type { MethodDecoratorType } from '../../type/method-decorator.type';
|
|
5
5
|
import type { PreDecoratorFunction } from '../../type/pre-decorator-function.type';
|
|
6
6
|
type GetResultType<T> = T extends Promise<infer U> ? U : T extends Observable<infer U> ? U : T;
|
|
7
|
-
export declare const Log: <
|
|
7
|
+
export declare const Log: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLog: PreDecoratorFunction<TArgs> | string, postLog?: PostLogFunction<GetResultType<TResult>, TArgs> | string, errorLog?: ErrorLogFunction<TArgs> | string) => MethodDecoratorType<K>;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=log.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,MAAM,CAAC;AAIlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,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,
|
|
1
|
+
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,MAAM,CAAC;AAIlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,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,GAEX,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,QAAQ,oBAAoB,CAAC,KAAK,CAAC,GAAG,MAAM,EAC5C,UAAU,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EACjE,WAAW,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,KAC5C,mBAAmB,CAAC,CAAC,CAgFvB,CAAC"}
|
|
@@ -4,7 +4,9 @@ exports.Log = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
6
|
const shared_1 = require("@rnw-community/shared");
|
|
7
|
-
const Log =
|
|
7
|
+
const Log =
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
(preLog, postLog, errorLog) => (target, propertyKey, descriptor) => {
|
|
8
10
|
const logContext = `${target.constructor.name}::${String(propertyKey)}`;
|
|
9
11
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
12
|
const originalMethod = descriptor.value;
|
|
@@ -15,6 +17,7 @@ const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) =>
|
|
|
15
17
|
common_1.Logger.log(preLog, logContext);
|
|
16
18
|
}
|
|
17
19
|
else if ((0, shared_1.isDefined)(preLog)) {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
18
21
|
common_1.Logger.log(preLog(args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
19
22
|
}
|
|
20
23
|
};
|
|
@@ -23,8 +26,10 @@ const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) =>
|
|
|
23
26
|
common_1.Logger.debug(postLog, logContext);
|
|
24
27
|
}
|
|
25
28
|
else if ((0, shared_1.isDefined)(postLog)) {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
26
30
|
common_1.Logger.debug(postLog(res, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
27
31
|
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
28
33
|
return res;
|
|
29
34
|
};
|
|
30
35
|
const runErrorLog = (error) => {
|
|
@@ -32,20 +37,25 @@ const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) =>
|
|
|
32
37
|
common_1.Logger.error(errorLog, logContext);
|
|
33
38
|
}
|
|
34
39
|
else if ((0, shared_1.isDefined)(errorLog)) {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
35
41
|
common_1.Logger.error(errorLog(error, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
44
|
try {
|
|
39
45
|
runPreLog();
|
|
46
|
+
// @ts-expect-error We need this to handle generic methods correctly
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,@typescript-eslint/no-unsafe-assignment,no-invalid-this,@typescript-eslint/no-invalid-this
|
|
40
48
|
const result = originalMethod.apply(this, args);
|
|
41
49
|
if ((0, shared_1.isDefined)(postLog)) {
|
|
42
50
|
if ((0, rxjs_1.isObservable)(result)) {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
43
52
|
return result.pipe((0, rxjs_1.tap)(runPostLog), (0, rxjs_1.catchError)((error) => {
|
|
44
53
|
runErrorLog(error);
|
|
45
54
|
return (0, rxjs_1.throwError)(() => error);
|
|
46
55
|
}));
|
|
47
56
|
}
|
|
48
57
|
else if ((0, shared_1.isPromise)(result)) {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
49
59
|
return result.then(runPostLog).catch((error) => {
|
|
50
60
|
runErrorLog(error);
|
|
51
61
|
throw error;
|
|
@@ -53,6 +63,7 @@ const Log = (preLog, postLog, errorLog) => (target, propertyKey, descriptor) =>
|
|
|
53
63
|
}
|
|
54
64
|
runPostLog(result);
|
|
55
65
|
}
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
56
67
|
return result;
|
|
57
68
|
}
|
|
58
69
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,+BAAkF;AAElF,kDAA+E;AASxE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"log.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,+BAAkF;AAElF,kDAA+E;AASxE,MAAM,GAAG;AACZ,8DAA8D;AAC9D,CACQ,MAA4C,EAC5C,OAAiE,EACjE,QAA2C,EACrB,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE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AAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;wBACpD,WAAW,CAAC,KAAK,CAAC,CAAC;wBAEnB,MAAM,KAAK,CAAC;oBAChB,CAAC,CAAuB,CAAC;gBAC7B,CAAC;gBAED,UAAU,CAAC,MAAW,CAAC,CAAC;YAC5B,CAAC;YAED,+DAA+D;YAC/D,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,WAAW,CAAC,KAAK,CAAC,CAAC;YAEnB,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAM,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAtFG,QAAA,GAAG,OAsFN"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export type MethodDecoratorType<TResult, TArgs extends unknown[]> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>>) => TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>> | void;
|
|
1
|
+
export type MethodDecoratorType<K extends (...args: any) => any> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<K>) => TypedPropertyDescriptor<K> | void;
|
|
3
2
|
//# sourceMappingURL=method-decorator.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../src/type/method-decorator.type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../src/type/method-decorator.type.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,CAC/D,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAErC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type HistogramConfiguration } from 'prom-client';
|
|
2
2
|
import type { MethodDecoratorType } from '../../type/method-decorator.type';
|
|
3
|
-
export declare const HistogramMetric: <M extends string,
|
|
3
|
+
export declare const HistogramMetric: <M extends string, K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(metricName: string, configuration?: Omit<HistogramConfiguration<M>, "name">) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=histogram-metric.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-metric.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,sBAAsB,EAAY,MAAM,aAAa,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"histogram-metric.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,sBAAsB,EAAY,MAAM,aAAa,CAAC;AAI/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,eAAO,MAAM,eAAe,GAEvB,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACtG,YAAY,MAAM,EAClB,gBAAgB,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KACxD,mBAAmB,CAAC,CAAC,CA6BvB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Histogram, register } from 'prom-client';
|
|
2
2
|
import { isDefined } from '@rnw-community/shared';
|
|
3
|
-
export const HistogramMetric =
|
|
3
|
+
export const HistogramMetric =
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
(metricName, configuration) => (_target, _propertyKey, descriptor) => {
|
|
4
6
|
let histogram = register.getSingleMetric(metricName);
|
|
5
7
|
if (!isDefined(histogram)) {
|
|
6
8
|
histogram = new Histogram({
|
|
@@ -15,6 +17,8 @@ export const HistogramMetric = (metricName, configuration) => (_target, _propert
|
|
|
15
17
|
descriptor.value = function (...args) {
|
|
16
18
|
const endHistogram = histogram.startTimer();
|
|
17
19
|
try {
|
|
20
|
+
// @ts-expect-error We need this to handle generic methods correctly
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,no-invalid-this,@typescript-eslint/no-invalid-this
|
|
18
22
|
return originalMethod.apply(this, args);
|
|
19
23
|
}
|
|
20
24
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,MAAM,CAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,MAAM,CAAC,MAAM,eAAe;AACxB,8DAA8D;AAC9D,CACQ,UAAkB,EAClB,aAAuD,EACjC,EAAE,CAC5B,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE;IAClC,IAAI,SAAS,GAAG,QAAQ,CAAC,eAAe,CAAC,UAAU,CAA6B,CAAC;IAEjF,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QACxB,SAAS,GAAG,IAAI,SAAS,CAAC;YACtB,IAAI,EAAE,UAAU;YAChB,GAAG,aAAa;YAChB,IAAI,EAAE,UAAU;SACnB,CAAC,CAAC;IACP,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,qDAAqD;IACrD,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;QACvC,MAAM,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;QAE5C,IAAI,CAAC;YACD,oEAAoE;YACpE,kHAAkH;YAClH,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;gBAAS,CAAC;YACP,YAAY,EAAE,CAAC;QACnB,CAAC;IACL,CAAM,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MethodDecoratorType } from '../../../type/method-decorator.type';
|
|
2
2
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
3
|
-
export declare const LockObservable: <
|
|
3
|
+
export declare const LockObservable: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn$?: (error: unknown) => TResult) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=lock-observable.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-observable.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,cAAc,GAEtB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,gBAAgB,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,KAC5C,mBAAmB,CAAC,CAAC,CA0CvB,CAAC"}
|
|
@@ -2,12 +2,20 @@ import { catchError, concatMap, finalize, from, isObservable, map, of, tap } fro
|
|
|
2
2
|
import { isDefined } from '@rnw-community/shared';
|
|
3
3
|
import { runPreLock } from '../util/run-pre-lock.util';
|
|
4
4
|
import { validateRedlock } from '../util/validate-redlock.util';
|
|
5
|
-
export const LockObservable =
|
|
5
|
+
export const LockObservable =
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
(preLock, duration, catchErrorFn$) => (target, propertyKey, descriptor) => {
|
|
6
8
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
9
|
const originalMethod = descriptor.value;
|
|
8
10
|
// eslint-disable-next-line max-statements,func-names
|
|
9
11
|
descriptor.value = function (...args) {
|
|
10
|
-
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
13
|
+
return of(true).pipe(
|
|
14
|
+
// eslint-disable-next-line no-invalid-this
|
|
15
|
+
tap(() => void validateRedlock(this)), map(() => runPreLock(preLock, ...args)), concatMap(lockKeys =>
|
|
16
|
+
// eslint-disable-next-line no-invalid-this
|
|
17
|
+
from(this.redlock.acquire(lockKeys, duration)).pipe(concatMap(currentLock => {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-invalid-this
|
|
11
19
|
const result = originalMethod.apply(this, args);
|
|
12
20
|
if (!isObservable(result)) {
|
|
13
21
|
void currentLock.release().catch(() => void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1G,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,CAAC,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1G,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,CAAC,MAAM,cAAc;AACvB,8DA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;QACN,CAAC,CAAC,EACF,SAAS,CAAC,aAAa,CAAC;YACpB,CAAC,CAAC,UAAU,CAAC,CAAC,GAAY,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAwB,CAAC;YACzE,CAAC,CAAC,GAAG,EAAE,CACd,CACJ,CACO,CAAC;IACjB,CAAM,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MethodDecoratorType } from '../../../type/method-decorator.type';
|
|
2
2
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
3
|
-
export declare const LockPromise: <
|
|
3
|
+
export declare const LockPromise: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn?: (error: unknown) => TResult) => MethodDecoratorType<K>;
|
|
4
4
|
//# sourceMappingURL=lock-promise.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-promise.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,eAAO,MAAM,WAAW,GAEnB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,eAAe,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,KAC3C,mBAAmB,CAAC,CAAC,CA8CvB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isDefined, isPromise } from '@rnw-community/shared';
|
|
2
2
|
import { runPreLock } from '../util/run-pre-lock.util';
|
|
3
3
|
import { validateRedlock } from '../util/validate-redlock.util';
|
|
4
|
-
export const LockPromise =
|
|
4
|
+
export const LockPromise =
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
(preLock, duration, catchErrorFn) => (target, propertyKey, descriptor) => {
|
|
5
7
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
6
8
|
const originalMethod = descriptor.value;
|
|
7
9
|
// @ts-expect-error TODO: Provide proper types
|
|
@@ -19,6 +21,7 @@ export const LockPromise = (preLock, duration, catchErrorFn) => (target, propert
|
|
|
19
21
|
return this.redlock
|
|
20
22
|
.acquire(lockKeys, duration)
|
|
21
23
|
.then(currentLock => {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22
25
|
const originalResult = originalMethod.apply(this, args);
|
|
23
26
|
if (!isPromise(originalResult)) {
|
|
24
27
|
// HINT: https://github.com/mike-marcacci/node-redlock/issues/168
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,CAAC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,MAAM,CAAC,MAAM,WAAW;AACpB,8DAA8D;AAC9D,CACQ,OAAyD,EACzD,QAAgB,EAChB,YAA0C,EACpB,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,8CAA8C;IAC9C,sCAAsC;IACtC,UAAU,CAAC,KAAK,GAAG,UAAiC,GAAG,IAAW;QAC9D,IAAI,QAAQ,GAAa,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,CAAC;YACtB,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,2EAA2E;YAC3E,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,IAAI,CAAC,OAAO;aACd,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;aAC3B,IAAI,CAAC,WAAW,CAAC,EAAE;YAChB,mEAAmE;YACnE,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;gBAC7B,iEAAiE;gBACjE,KAAK,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBAE/C,MAAM,IAAI,KAAK,CACX,UAAU,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC,WAAW,CAAC,4BAA4B,CACxF,CAAC;YACN,CAAC;YAED,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC/B,iEAAiE;gBACjE,KAAK,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;YACpB,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC1B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC;YAED,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,CAAC;IACX,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-promise.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/is-promise.util.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"is-promise.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/is-promise.util.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAI/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-pre-lock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/run-pre-lock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run-pre-lock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/run-pre-lock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAC1D,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,GAAG,MAAM,KAAK,KACf,MAAM,EAQR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-redlock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/validate-redlock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"validate-redlock.util.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/util/validate-redlock.util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,GAAI,MAAM,eAAe,KAAG,IAMvD,CAAC"}
|
|
@@ -4,6 +4,6 @@ import type { PostLogFunction } from './type/post-log-function.type';
|
|
|
4
4
|
import type { MethodDecoratorType } from '../../type/method-decorator.type';
|
|
5
5
|
import type { PreDecoratorFunction } from '../../type/pre-decorator-function.type';
|
|
6
6
|
type GetResultType<T> = T extends Promise<infer U> ? U : T extends Observable<infer U> ? U : T;
|
|
7
|
-
export declare const Log: <
|
|
7
|
+
export declare const Log: <K extends (...args: any) => any, TResult extends ReturnType<K>, TArgs extends Parameters<K>>(preLog: PreDecoratorFunction<TArgs> | string, postLog?: PostLogFunction<GetResultType<TResult>, TArgs> | string, errorLog?: ErrorLogFunction<TArgs> | string) => MethodDecoratorType<K>;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=log.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,MAAM,CAAC;AAIlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,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,
|
|
1
|
+
{"version":3,"file":"log.decorator.d.ts","sourceRoot":"","sources":["../../../../src/decorator/log/log.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,MAAM,CAAC;AAIlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,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,GAEX,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EAAE,OAAO,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACpF,QAAQ,oBAAoB,CAAC,KAAK,CAAC,GAAG,MAAM,EAC5C,UAAU,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EACjE,WAAW,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,KAC5C,mBAAmB,CAAC,CAAC,CAgFvB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
2
|
import { catchError, isObservable, tap, throwError } from 'rxjs';
|
|
3
3
|
import { isDefined, isNotEmptyString, isPromise } from '@rnw-community/shared';
|
|
4
|
-
export const Log =
|
|
4
|
+
export const Log =
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
(preLog, postLog, errorLog) => (target, propertyKey, descriptor) => {
|
|
5
7
|
const logContext = `${target.constructor.name}::${String(propertyKey)}`;
|
|
6
8
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7
9
|
const originalMethod = descriptor.value;
|
|
@@ -12,6 +14,7 @@ export const Log = (preLog, postLog, errorLog) => (target, propertyKey, descript
|
|
|
12
14
|
Logger.log(preLog, logContext);
|
|
13
15
|
}
|
|
14
16
|
else if (isDefined(preLog)) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
15
18
|
Logger.log(preLog(args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
16
19
|
}
|
|
17
20
|
};
|
|
@@ -20,8 +23,10 @@ export const Log = (preLog, postLog, errorLog) => (target, propertyKey, descript
|
|
|
20
23
|
Logger.debug(postLog, logContext);
|
|
21
24
|
}
|
|
22
25
|
else if (isDefined(postLog)) {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
23
27
|
Logger.debug(postLog(res, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
24
28
|
}
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
25
30
|
return res;
|
|
26
31
|
};
|
|
27
32
|
const runErrorLog = (error) => {
|
|
@@ -29,20 +34,25 @@ export const Log = (preLog, postLog, errorLog) => (target, propertyKey, descript
|
|
|
29
34
|
Logger.error(errorLog, logContext);
|
|
30
35
|
}
|
|
31
36
|
else if (isDefined(errorLog)) {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
32
38
|
Logger.error(errorLog(error, args[0], args[1], args[2], args[3], args[4]), logContext);
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
try {
|
|
36
42
|
runPreLog();
|
|
43
|
+
// @ts-expect-error We need this to handle generic methods correctly
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,@typescript-eslint/no-unsafe-assignment,no-invalid-this,@typescript-eslint/no-invalid-this
|
|
37
45
|
const result = originalMethod.apply(this, args);
|
|
38
46
|
if (isDefined(postLog)) {
|
|
39
47
|
if (isObservable(result)) {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
40
49
|
return result.pipe(tap(runPostLog), catchError((error) => {
|
|
41
50
|
runErrorLog(error);
|
|
42
51
|
return throwError(() => error);
|
|
43
52
|
}));
|
|
44
53
|
}
|
|
45
54
|
else if (isPromise(result)) {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
46
56
|
return result.then(runPostLog).catch((error) => {
|
|
47
57
|
runErrorLog(error);
|
|
48
58
|
throw error;
|
|
@@ -50,6 +60,7 @@ export const Log = (preLog, postLog, errorLog) => (target, propertyKey, descript
|
|
|
50
60
|
}
|
|
51
61
|
runPostLog(result);
|
|
52
62
|
}
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
53
64
|
return result;
|
|
54
65
|
}
|
|
55
66
|
catch (error) {
|
|
@@ -1 +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,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAS/E,MAAM,CAAC,MAAM,GAAG,
|
|
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,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAS/E,MAAM,CAAC,MAAM,GAAG;AACZ,8DAA8D;AAC9D,CACQ,MAA4C,EAC5C,OAAiE,EACjE,QAA2C,EACrB,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;IACxE,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IAEzC,qDAAqD;IACrD,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;QAGvC,MAAM,SAAS,GAAG,GAAS,EAAE;YACzB,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACnC,CA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orType<TResult, TArgs extends unknown[]> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>>) => TypedPropertyDescriptor<DecoratedMethodType<TResult, TArgs>> | void;
|
|
1
|
+
export type MethodDecoratorType<K extends (...args: any) => any> = (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<K>) => TypedPropertyDescriptor<K> | void;
|
|
3
2
|
//# sourceMappingURL=method-decorator.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../src/type/method-decorator.type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-decorator.type.d.ts","sourceRoot":"","sources":["../../../src/type/method-decorator.type.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,CAC/D,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAErC,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnw-community/nestjs-enterprise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "NestJS Enterprise is a collection of enterprise-grade modules for NestJS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo",
|
|
62
62
|
"clear:deps": "rm -rf ./node_modules && rm -rf ./dist"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "7c4cbf2c970b80935d75b4b5019dccf53e47cdc6",
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@rnw-community/shared": "1.3.0"
|
|
67
67
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorated-method.type.d.ts","sourceRoot":"","sources":["../../../src/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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorated-method.type.js","sourceRoot":"","sources":["../../../src/type/decorated-method.type.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorated-method.type.d.ts","sourceRoot":"","sources":["../../../src/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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorated-method.type.js","sourceRoot":"","sources":["../../../src/type/decorated-method.type.ts"],"names":[],"mappings":""}
|