@rnw-community/nestjs-enterprise 1.14.0 → 2.0.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-tracking.d.ts +14 -0
- package/dist/cjs/decorator/histogram-metric/histogram-metric-tracking.d.ts.map +1 -0
- package/dist/cjs/decorator/histogram-metric/histogram-metric-tracking.js +58 -0
- package/dist/cjs/decorator/histogram-metric/histogram-metric-tracking.js.map +1 -0
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.d.ts +5 -2
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.js +58 -21
- package/dist/cjs/decorator/histogram-metric/histogram-metric.decorator.js.map +1 -1
- package/dist/cjs/decorator/lock/create-lock-service-store.d.ts +4 -0
- package/dist/cjs/decorator/lock/create-lock-service-store.d.ts.map +1 -0
- package/dist/cjs/decorator/lock/create-lock-service-store.js +22 -0
- package/dist/cjs/decorator/lock/create-lock-service-store.js.map +1 -0
- package/dist/cjs/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.d.ts +8 -3
- package/dist/cjs/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.js +75 -12
- package/dist/cjs/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.js.map +1 -1
- package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.d.ts +6 -3
- package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js +72 -12
- package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js.map +1 -1
- package/dist/cjs/decorator/lock/lock-observable/lock-observable.decorator.d.ts +3 -2
- 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.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.map +1 -1
- package/dist/cjs/decorator/lock/lock-service-not-injected-message.const.d.ts +2 -0
- package/dist/cjs/decorator/lock/lock-service-not-injected-message.const.d.ts.map +1 -0
- package/dist/cjs/decorator/lock/lock-service-not-injected-message.const.js +5 -0
- package/dist/cjs/decorator/lock/lock-service-not-injected-message.const.js.map +1 -0
- package/dist/cjs/decorator/lock/lockable.service.d.ts.map +1 -0
- package/dist/cjs/decorator/lock/lockable.service.js.map +1 -0
- package/dist/cjs/decorator/lock/resolve-resources.d.ts +3 -0
- package/dist/cjs/decorator/lock/resolve-resources.d.ts.map +1 -0
- package/dist/cjs/decorator/lock/resolve-resources.js +13 -0
- package/dist/cjs/decorator/lock/resolve-resources.js.map +1 -0
- package/dist/cjs/decorator/lock/resource-separator.const.d.ts +2 -0
- package/dist/cjs/decorator/lock/resource-separator.const.d.ts.map +1 -0
- package/dist/cjs/decorator/lock/resource-separator.const.js +5 -0
- package/dist/cjs/decorator/lock/resource-separator.const.js.map +1 -0
- package/dist/cjs/decorator/lock/util/execute-lock-observable.util.js +2 -2
- package/dist/cjs/decorator/lock/util/execute-lock-observable.util.js.map +1 -1
- package/dist/cjs/decorator/lock/util/execute-lock-promise.util.js +2 -2
- package/dist/cjs/decorator/lock/util/execute-lock-promise.util.js.map +1 -1
- package/dist/cjs/decorator/lock/util/run-pre-lock.util.d.ts.map +1 -1
- package/dist/cjs/decorator/lock/util/run-pre-lock.util.js +4 -10
- package/dist/cjs/decorator/lock/util/run-pre-lock.util.js.map +1 -1
- package/dist/cjs/decorator/lock/util/validate-redlock.util.d.ts +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 -8
- package/dist/cjs/decorator/log/log.decorator.d.ts.map +1 -1
- package/dist/cjs/decorator/log/log.decorator.js +11 -69
- package/dist/cjs/decorator/log/log.decorator.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric-tracking.d.ts +14 -0
- package/dist/esm/decorator/histogram-metric/histogram-metric-tracking.d.ts.map +1 -0
- package/dist/esm/decorator/histogram-metric/histogram-metric-tracking.js +55 -0
- package/dist/esm/decorator/histogram-metric/histogram-metric-tracking.js.map +1 -0
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.d.ts +5 -2
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.js +58 -21
- package/dist/esm/decorator/histogram-metric/histogram-metric.decorator.js.map +1 -1
- package/dist/esm/decorator/lock/create-lock-service-store.d.ts +4 -0
- package/dist/esm/decorator/lock/create-lock-service-store.d.ts.map +1 -0
- package/dist/esm/decorator/lock/create-lock-service-store.js +18 -0
- package/dist/esm/decorator/lock/create-lock-service-store.js.map +1 -0
- package/dist/esm/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.d.ts +8 -3
- package/dist/esm/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.d.ts.map +1 -1
- package/dist/esm/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.js +75 -12
- package/dist/esm/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.js.map +1 -1
- package/dist/esm/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.d.ts +6 -3
- package/dist/esm/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.d.ts.map +1 -1
- package/dist/esm/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js +72 -12
- package/dist/esm/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js.map +1 -1
- package/dist/esm/decorator/lock/lock-observable/lock-observable.decorator.d.ts +3 -2
- 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.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.map +1 -1
- package/dist/esm/decorator/lock/lock-service-not-injected-message.const.d.ts +2 -0
- package/dist/esm/decorator/lock/lock-service-not-injected-message.const.d.ts.map +1 -0
- package/dist/esm/decorator/lock/lock-service-not-injected-message.const.js +2 -0
- package/dist/esm/decorator/lock/lock-service-not-injected-message.const.js.map +1 -0
- package/dist/esm/decorator/lock/lockable.service.d.ts.map +1 -0
- package/dist/esm/decorator/lock/lockable.service.js.map +1 -0
- package/dist/esm/decorator/lock/resolve-resources.d.ts +3 -0
- package/dist/esm/decorator/lock/resolve-resources.d.ts.map +1 -0
- package/dist/esm/decorator/lock/resolve-resources.js +9 -0
- package/dist/esm/decorator/lock/resolve-resources.js.map +1 -0
- package/dist/esm/decorator/lock/resource-separator.const.d.ts +2 -0
- package/dist/esm/decorator/lock/resource-separator.const.d.ts.map +1 -0
- package/dist/esm/decorator/lock/resource-separator.const.js +2 -0
- package/dist/esm/decorator/lock/resource-separator.const.js.map +1 -0
- package/dist/esm/decorator/lock/util/execute-lock-observable.util.js +3 -3
- package/dist/esm/decorator/lock/util/execute-lock-observable.util.js.map +1 -1
- package/dist/esm/decorator/lock/util/execute-lock-promise.util.js +3 -3
- package/dist/esm/decorator/lock/util/execute-lock-promise.util.js.map +1 -1
- package/dist/esm/decorator/lock/util/run-pre-lock.util.d.ts.map +1 -1
- package/dist/esm/decorator/lock/util/run-pre-lock.util.js +5 -11
- package/dist/esm/decorator/lock/util/run-pre-lock.util.js.map +1 -1
- package/dist/esm/decorator/lock/util/validate-redlock.util.d.ts +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 -8
- package/dist/esm/decorator/log/log.decorator.d.ts.map +1 -1
- package/dist/esm/decorator/log/log.decorator.js +12 -69
- package/dist/esm/decorator/log/log.decorator.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/cjs/decorator/lock/service/lockable.service.d.ts.map +0 -1
- package/dist/cjs/decorator/lock/service/lockable.service.js.map +0 -1
- package/dist/cjs/decorator/lock/util/get-lock-service.util.d.ts +0 -3
- package/dist/cjs/decorator/lock/util/get-lock-service.util.d.ts.map +0 -1
- package/dist/cjs/decorator/lock/util/get-lock-service.util.js +0 -13
- package/dist/cjs/decorator/lock/util/get-lock-service.util.js.map +0 -1
- package/dist/cjs/decorator/lock/util/inject-lock-service.util.d.ts +0 -4
- package/dist/cjs/decorator/lock/util/inject-lock-service.util.d.ts.map +0 -1
- package/dist/cjs/decorator/lock/util/inject-lock-service.util.js +0 -9
- package/dist/cjs/decorator/lock/util/inject-lock-service.util.js.map +0 -1
- package/dist/cjs/decorator/log/type/error-log-function.type.d.ts +0 -2
- package/dist/cjs/decorator/log/type/error-log-function.type.d.ts.map +0 -1
- package/dist/cjs/decorator/log/type/error-log-function.type.js +0 -3
- package/dist/cjs/decorator/log/type/error-log-function.type.js.map +0 -1
- package/dist/cjs/decorator/log/type/post-log-function.type.d.ts +0 -2
- package/dist/cjs/decorator/log/type/post-log-function.type.d.ts.map +0 -1
- package/dist/cjs/decorator/log/type/post-log-function.type.js +0 -3
- package/dist/cjs/decorator/log/type/post-log-function.type.js.map +0 -1
- package/dist/esm/decorator/lock/service/lockable.service.d.ts.map +0 -1
- package/dist/esm/decorator/lock/service/lockable.service.js.map +0 -1
- package/dist/esm/decorator/lock/util/get-lock-service.util.d.ts +0 -3
- package/dist/esm/decorator/lock/util/get-lock-service.util.d.ts.map +0 -1
- package/dist/esm/decorator/lock/util/get-lock-service.util.js +0 -9
- package/dist/esm/decorator/lock/util/get-lock-service.util.js.map +0 -1
- package/dist/esm/decorator/lock/util/inject-lock-service.util.d.ts +0 -4
- package/dist/esm/decorator/lock/util/inject-lock-service.util.d.ts.map +0 -1
- package/dist/esm/decorator/lock/util/inject-lock-service.util.js +0 -5
- package/dist/esm/decorator/lock/util/inject-lock-service.util.js.map +0 -1
- package/dist/esm/decorator/log/type/error-log-function.type.d.ts +0 -2
- package/dist/esm/decorator/log/type/error-log-function.type.d.ts.map +0 -1
- package/dist/esm/decorator/log/type/error-log-function.type.js +0 -2
- package/dist/esm/decorator/log/type/error-log-function.type.js.map +0 -1
- package/dist/esm/decorator/log/type/post-log-function.type.d.ts +0 -2
- package/dist/esm/decorator/log/type/post-log-function.type.d.ts.map +0 -1
- package/dist/esm/decorator/log/type/post-log-function.type.js +0 -2
- package/dist/esm/decorator/log/type/post-log-function.type.js.map +0 -1
- /package/dist/cjs/decorator/lock/{service/lockable.service.d.ts → lockable.service.d.ts} +0 -0
- /package/dist/cjs/decorator/lock/{service/lockable.service.js → lockable.service.js} +0 -0
- /package/dist/esm/decorator/lock/{service/lockable.service.d.ts → lockable.service.d.ts} +0 -0
- /package/dist/esm/decorator/lock/{service/lockable.service.js → lockable.service.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Registry } from 'prom-client';
|
|
2
|
+
interface HistogramMetricTrackedConfig {
|
|
3
|
+
readonly buckets?: readonly number[];
|
|
4
|
+
readonly labelNames?: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
interface HistogramMetricTrackingApi {
|
|
7
|
+
readonly find: (registries: readonly Registry[], metricName: string) => HistogramMetricTrackedConfig | undefined;
|
|
8
|
+
readonly record: (registries: readonly Registry[], metricName: string, config: HistogramMetricTrackedConfig) => void;
|
|
9
|
+
readonly configsMatch: (previous: HistogramMetricTrackedConfig, next: HistogramMetricTrackedConfig) => boolean;
|
|
10
|
+
readonly reset: (registry: Registry) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const histogramMetricTracking: HistogramMetricTrackingApi;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=histogram-metric-tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram-metric-tracking.d.ts","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric-tracking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,UAAU,4BAA4B;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,UAAU,0BAA0B;IAChC,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,KAAK,4BAA4B,GAAG,SAAS,CAAC;IACjH,QAAQ,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,SAAS,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,4BAA4B,KAAK,IAAI,CAAC;IACrH,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,4BAA4B,EAAE,IAAI,EAAE,4BAA4B,KAAK,OAAO,CAAC;IAC/G,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAChD;AAkCD,eAAO,MAAM,uBAAuB,EAAE,0BA2BrC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.histogramMetricTracking = void 0;
|
|
4
|
+
const shared_1 = require("@rnw-community/shared");
|
|
5
|
+
const registryMap = new WeakMap();
|
|
6
|
+
const bucketsEqual = (first, second) => {
|
|
7
|
+
if (!(0, shared_1.isDefined)(first) && !(0, shared_1.isDefined)(second)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (!(0, shared_1.isDefined)(first) || !(0, shared_1.isDefined)(second)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (first.length !== second.length) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return first.every((value, index) => value === second[index]);
|
|
17
|
+
};
|
|
18
|
+
const labelNamesEqual = (first, second) => {
|
|
19
|
+
if (!(0, shared_1.isDefined)(first) && !(0, shared_1.isDefined)(second)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (!(0, shared_1.isDefined)(first) || !(0, shared_1.isDefined)(second)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (first.length !== second.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const sortedFirst = [...first].sort((left, right) => left.localeCompare(right));
|
|
29
|
+
const sortedSecond = [...second].sort((left, right) => left.localeCompare(right));
|
|
30
|
+
return sortedFirst.every((value, index) => value === sortedSecond[index]);
|
|
31
|
+
};
|
|
32
|
+
exports.histogramMetricTracking = {
|
|
33
|
+
find: (registries, metricName) => {
|
|
34
|
+
for (const registry of registries) {
|
|
35
|
+
const perRegistry = registryMap.get(registry);
|
|
36
|
+
const hit = perRegistry?.get(metricName);
|
|
37
|
+
if ((0, shared_1.isDefined)(hit)) {
|
|
38
|
+
return hit;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return void 0;
|
|
42
|
+
},
|
|
43
|
+
record: (registries, metricName, config) => {
|
|
44
|
+
for (const registry of registries) {
|
|
45
|
+
let perRegistry = registryMap.get(registry);
|
|
46
|
+
if (!(0, shared_1.isDefined)(perRegistry)) {
|
|
47
|
+
perRegistry = new Map();
|
|
48
|
+
registryMap.set(registry, perRegistry);
|
|
49
|
+
}
|
|
50
|
+
perRegistry.set(metricName, config);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
configsMatch: (previous, next) => bucketsEqual(previous.buckets, next.buckets) && labelNamesEqual(previous.labelNames, next.labelNames),
|
|
54
|
+
reset: (registry) => {
|
|
55
|
+
registryMap.delete(registry);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=histogram-metric-tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram-metric-tracking.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric-tracking.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAgBlD,MAAM,WAAW,GAAG,IAAI,OAAO,EAAuD,CAAC;AAEvF,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,MAAqC,EAAW,EAAE;IAC1G,IAAI,CAAC,IAAA,kBAAS,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,IAAA,kBAAS,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAAoC,EAAE,MAAqC,EAAW,EAA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CAAC,CAAC;IAClB,CAAC;IACD,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;QACvC,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAChC,IAAI,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,CAAC,IAAA,kBAAS,EAAC,WAAW,CAAC,EAAE,CAAC;gBAC1B,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;gBACxB,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;YACD,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IACD,YAAY,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAC7B,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IACzG,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE;QAChB,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACJ,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type HistogramConfiguration } from 'prom-client';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type HistogramMetricConfig<M extends string, TArgs extends readonly unknown[]> = Omit<HistogramConfiguration<M>, 'name'> & {
|
|
3
|
+
readonly labels?: (args: TArgs) => Readonly<Record<string, string>>;
|
|
4
|
+
};
|
|
5
|
+
export declare const HistogramMetric: <M extends string, TArgs extends readonly unknown[] = readonly unknown[]>(metricName: string, configuration?: HistogramMetricConfig<M, TArgs>) => import("@rnw-community/shared").MethodDecoratorType<import("@rnw-community/shared").AnyFn>;
|
|
6
|
+
export {};
|
|
4
7
|
//# 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,
|
|
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,EAA6C,MAAM,aAAa,CAAC;AAWhH,KAAK,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,SAAS,SAAS,OAAO,EAAE,IAAI,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IACvH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACvE,CAAC;AAwFF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,SAAS,SAAS,OAAO,EAAE,GAAG,SAAS,OAAO,EAAE,EACnG,YAAY,MAAM,EAClB,gBAAgB,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,+FAOlD,CAAC"}
|
|
@@ -2,31 +2,68 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HistogramMetric = void 0;
|
|
4
4
|
const prom_client_1 = require("prom-client");
|
|
5
|
+
const histogram_metric_decorator_1 = require("@rnw-community/histogram-metric-decorator");
|
|
5
6
|
const shared_1 = require("@rnw-community/shared");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const endHistogram = histogram.startTimer();
|
|
20
|
-
try {
|
|
21
|
-
// @ts-expect-error We need this to handle generic methods correctly
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
23
|
-
return originalMethod.apply(this, args);
|
|
7
|
+
const histogram_metric_tracking_1 = require("./histogram-metric-tracking");
|
|
8
|
+
const MS_PER_SECOND = 1000;
|
|
9
|
+
const throwMismatch = (metricName, previous, next) => {
|
|
10
|
+
throw new Error(`HistogramMetric "${metricName}" already registered with different buckets/labelNames. ` +
|
|
11
|
+
`Existing: ${JSON.stringify(previous)}. Requested: ${JSON.stringify(next)}. ` +
|
|
12
|
+
`Use a unique name or align configurations.`);
|
|
13
|
+
};
|
|
14
|
+
const resolveExistingHistogram = (metricName, configuration) => {
|
|
15
|
+
const registries = configuration?.registers ?? [prom_client_1.register];
|
|
16
|
+
for (const item of registries) {
|
|
17
|
+
const existing = item.getSingleMetric(metricName);
|
|
18
|
+
if (existing instanceof prom_client_1.Histogram) {
|
|
19
|
+
return existing;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
}
|
|
22
|
+
return void 0;
|
|
23
|
+
};
|
|
24
|
+
const createAndRecord = (metricName, configuration, registries, next) => {
|
|
25
|
+
const created = new prom_client_1.Histogram({
|
|
26
|
+
help: metricName,
|
|
27
|
+
...configuration,
|
|
28
|
+
name: metricName,
|
|
29
|
+
});
|
|
30
|
+
histogram_metric_tracking_1.histogramMetricTracking.record(registries, metricName, next);
|
|
31
|
+
return created;
|
|
32
|
+
};
|
|
33
|
+
const resolveHistogram = (metricName, configuration) => {
|
|
34
|
+
const registries = (configuration?.registers ?? [prom_client_1.register]);
|
|
35
|
+
const next = { buckets: configuration?.buckets, labelNames: configuration?.labelNames };
|
|
36
|
+
const prior = histogram_metric_tracking_1.histogramMetricTracking.find(registries, metricName);
|
|
37
|
+
if ((0, shared_1.isDefined)(prior) && !histogram_metric_tracking_1.histogramMetricTracking.configsMatch(prior, next)) {
|
|
38
|
+
throwMismatch(metricName, prior, next);
|
|
39
|
+
}
|
|
40
|
+
const existing = resolveExistingHistogram(metricName, configuration);
|
|
41
|
+
if ((0, shared_1.isDefined)(existing)) {
|
|
42
|
+
if (!(0, shared_1.isDefined)(prior)) {
|
|
43
|
+
histogram_metric_tracking_1.histogramMetricTracking.record(registries, metricName, next);
|
|
27
44
|
}
|
|
45
|
+
return existing;
|
|
46
|
+
}
|
|
47
|
+
return createAndRecord(metricName, configuration, registries, next);
|
|
48
|
+
};
|
|
49
|
+
const createPromClientTransport = (metricName, configuration) => {
|
|
50
|
+
const histogram = resolveHistogram(metricName, configuration);
|
|
51
|
+
return {
|
|
52
|
+
observe: (_name, durationMs, labelValues) => {
|
|
53
|
+
const seconds = durationMs / MS_PER_SECOND;
|
|
54
|
+
if ((0, shared_1.isDefined)(labelValues)) {
|
|
55
|
+
histogram.observe(labelValues, seconds);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
histogram.observe(seconds);
|
|
59
|
+
},
|
|
28
60
|
};
|
|
29
|
-
|
|
61
|
+
};
|
|
62
|
+
const HistogramMetric = (metricName, configuration) => {
|
|
63
|
+
const { labels, ...promConfig } = configuration ?? {};
|
|
64
|
+
return (0, histogram_metric_decorator_1.createHistogramMetricDecorator)({
|
|
65
|
+
transport: createPromClientTransport(metricName, promConfig),
|
|
66
|
+
})({ name: metricName, labels: labels });
|
|
30
67
|
};
|
|
31
68
|
exports.HistogramMetric = HistogramMetric;
|
|
32
69
|
//# sourceMappingURL=histogram-metric.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"histogram-metric.decorator.js","sourceRoot":"","sources":["../../../../src/decorator/histogram-metric/histogram-metric.decorator.ts"],"names":[],"mappings":";;;AAAA,6CAAgH;AAEhH,0FAA2F;AAC3F,kDAA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AAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEK,MAAM,eAAe,GAAG,CAC3B,UAAkB,EAClB,aAA+C,EACjD,EAAE;IACA,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,GAAG,aAAa,IAAI,EAAE,CAAC;IAEtD,OAAO,IAAA,2DAA8B,EAAC;QAClC,SAAS,EAAE,yBAAyB,CAAC,UAAU,EAAE,UAAqD,CAAC;KAC1G,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAiE,EAAE,CAAC,CAAC;AACxG,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type LockStoreInterface } from '@rnw-community/lock-decorator';
|
|
2
|
+
import type { LockServiceInterface } from './interface/lock-service.interface';
|
|
3
|
+
export declare const createLockServiceStore: (lockService: LockServiceInterface, duration: number) => LockStoreInterface;
|
|
4
|
+
//# sourceMappingURL=create-lock-service-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-lock-service-store.d.ts","sourceRoot":"","sources":["../../../../src/decorator/lock/create-lock-service-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,kBAAkB,EAC1B,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,eAAO,MAAM,sBAAsB,GAAI,aAAa,oBAAoB,EAAE,UAAU,MAAM,KAAG,kBAqB3F,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLockServiceStore = void 0;
|
|
4
|
+
const lock_decorator_1 = require("@rnw-community/lock-decorator");
|
|
5
|
+
const shared_1 = require("@rnw-community/shared");
|
|
6
|
+
const resource_separator_const_1 = require("./resource-separator.const");
|
|
7
|
+
const createLockServiceStore = (lockService, duration) => ({
|
|
8
|
+
acquire: async (key, mode, _options) => {
|
|
9
|
+
const resources = key.split(resource_separator_const_1.RESOURCE_SEPARATOR);
|
|
10
|
+
if (mode === 'exclusive') {
|
|
11
|
+
const handle = await lockService.tryAcquire(resources, duration);
|
|
12
|
+
if (!(0, shared_1.isDefined)(handle)) {
|
|
13
|
+
throw new lock_decorator_1.LockBusyError(key);
|
|
14
|
+
}
|
|
15
|
+
return { key, mode, release: () => handle.release() };
|
|
16
|
+
}
|
|
17
|
+
const handle = await lockService.acquire(resources, duration);
|
|
18
|
+
return { key, mode, release: () => handle.release() };
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
exports.createLockServiceStore = createLockServiceStore;
|
|
22
|
+
//# sourceMappingURL=create-lock-service-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-lock-service-store.js","sourceRoot":"","sources":["../../../../src/decorator/lock/create-lock-service-store.ts"],"names":[],"mappings":";;;AAAA,kEAMuC;AACvC,kDAAkD;AAElD,yEAAgE;AAIzD,MAAM,sBAAsB,GAAG,CAAC,WAAiC,EAAE,QAAgB,EAAsB,EAAE,CAAC,CAAC;IAChH,OAAO,EAAE,KAAK,EACV,GAAW,EACX,IAAkB,EAClB,QAAkC,EACN,EAAE;QAC9B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,6CAAkB,CAAC,CAAC;QAEhD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACjE,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;gBACrB,MAAM,IAAI,8BAAa,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;YAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC1D,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE9D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;IAC1D,CAAC;CACJ,CAAC,CAAC;AArBU,QAAA,sBAAsB,0BAqBhC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { type Observable } from 'rxjs';
|
|
1
2
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
2
3
|
import type { LockServiceInterface } from '../interface/lock-service.interface';
|
|
3
|
-
import type { AbstractConstructor,
|
|
4
|
+
import type { AbstractConstructor, MethodDecoratorType } from '@rnw-community/shared';
|
|
5
|
+
type ObservableReturningFn = (...args: readonly any[]) => Observable<unknown>;
|
|
6
|
+
type ObservableRecoveryType<TResult> = TResult extends Observable<infer TValue> ? TValue | Observable<TValue> : never;
|
|
7
|
+
type ObservableRecoveryFnType<K extends ObservableReturningFn> = (error: unknown) => ObservableRecoveryType<ReturnType<K>>;
|
|
4
8
|
export declare const createObservableLockDecorators: (serviceToken: AbstractConstructor<LockServiceInterface>, defaultDuration: number) => {
|
|
5
|
-
SequentialLock$: <K extends
|
|
6
|
-
ExclusiveLock$: <K extends
|
|
9
|
+
SequentialLock$: <K extends ObservableReturningFn, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], catchErrorFn$?: ObservableRecoveryFnType<K>, duration?: number) => MethodDecoratorType<K>;
|
|
10
|
+
ExclusiveLock$: <K extends ObservableReturningFn, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], catchErrorFn$?: ObservableRecoveryFnType<K>, duration?: number) => MethodDecoratorType<K>;
|
|
7
11
|
};
|
|
12
|
+
export {};
|
|
8
13
|
//# sourceMappingURL=create-observable-lock-decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-observable-lock-decorators.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-observable-lock-decorators.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,UAAU,EAAmD,MAAM,MAAM,CAAC;AAU/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,KAAK,qBAAqB,GAAG,CAAC,GAAG,IAAI,EAAE,SAAS,GAAG,EAAE,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC;AAE9E,KAAK,sBAAsB,CAAC,OAAO,IAAI,OAAO,SAAS,UAAU,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AACtH,KAAK,wBAAwB,CAAC,CAAC,SAAS,qBAAqB,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AA0C3H,eAAO,MAAM,8BAA8B,GACvC,cAAc,mBAAmB,CAAC,oBAAoB,CAAC,EACvD,iBAAiB,MAAM;sBAMlB,CAAC,SAAS,qBAAqB,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,WAChD,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,kBACzC,wBAAwB,CAAC,CAAC,CAAC,aAChC,MAAM,KAClB,mBAAmB,CAAC,CAAC,CAAC;qBAJxB,CAAC,SAAS,qBAAqB,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,WAChD,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,kBACzC,wBAAwB,CAAC,CAAC,CAAC,aAChC,MAAM,KAClB,mBAAmB,CAAC,CAAC,CAAC;CAoDhC,CAAC"}
|
|
@@ -1,22 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createObservableLockDecorators = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const lock_decorator_1 = require("@rnw-community/lock-decorator");
|
|
7
|
+
const shared_1 = require("@rnw-community/shared");
|
|
8
|
+
const create_lock_service_store_1 = require("../create-lock-service-store");
|
|
9
|
+
const lock_service_not_injected_message_const_1 = require("../lock-service-not-injected-message.const");
|
|
10
|
+
const resolve_resources_1 = require("../resolve-resources");
|
|
11
|
+
const resource_separator_const_1 = require("../resource-separator.const");
|
|
12
|
+
class MethodThrownError extends Error {
|
|
13
|
+
constructor(cause) {
|
|
14
|
+
super('method-thrown');
|
|
15
|
+
this.cause = cause;
|
|
16
|
+
this.name = 'MethodThrownError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const recoverFromAcquireError = (error, mode, catchErrorFn$) => {
|
|
20
|
+
let normalized = error;
|
|
21
|
+
if (error instanceof lock_decorator_1.LockBusyError) {
|
|
22
|
+
if (mode === 'exclusive' && !(0, shared_1.isDefined)(catchErrorFn$)) {
|
|
23
|
+
return rxjs_1.EMPTY;
|
|
24
|
+
}
|
|
25
|
+
const keys = error.key.split(resource_separator_const_1.RESOURCE_SEPARATOR).join(', ');
|
|
26
|
+
normalized = new Error(`Lock not acquired for keys: ${keys}`);
|
|
27
|
+
}
|
|
28
|
+
if ((0, shared_1.isDefined)(catchErrorFn$)) {
|
|
29
|
+
const recovery = catchErrorFn$(normalized);
|
|
30
|
+
return (0, rxjs_1.isObservable)(recovery) ? recovery : (0, rxjs_1.of)(recovery);
|
|
31
|
+
}
|
|
32
|
+
throw normalized;
|
|
33
|
+
};
|
|
34
|
+
const recoverFromMethodError = (error, catchErrorFn$) => {
|
|
35
|
+
if ((0, shared_1.isDefined)(catchErrorFn$)) {
|
|
36
|
+
const recovery = catchErrorFn$(error);
|
|
37
|
+
return (0, rxjs_1.isObservable)(recovery) ? recovery : (0, rxjs_1.of)(recovery);
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
};
|
|
8
41
|
const createObservableLockDecorators = (serviceToken, defaultDuration) => {
|
|
9
42
|
const serviceSymbol = Symbol('LockService');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
descriptor.value
|
|
43
|
+
const makeDecorator = (mode) => (preLock, catchErrorFn$, duration) => (target, propertyKey, descriptor) => {
|
|
44
|
+
(0, common_1.Inject)(serviceToken)(target, serviceSymbol);
|
|
45
|
+
const methodName = `${target.constructor.name}::${String(propertyKey)}`;
|
|
46
|
+
const originalMethod = descriptor.value;
|
|
47
|
+
const effectiveDuration = duration ?? defaultDuration;
|
|
48
|
+
descriptor.value = function observableLockDecorator(...args) {
|
|
49
|
+
return (0, rxjs_1.defer)(() => {
|
|
50
|
+
const lockService = this[serviceSymbol];
|
|
51
|
+
if (!(0, shared_1.isDefined)(lockService)) {
|
|
52
|
+
throw new Error(lock_service_not_injected_message_const_1.LOCK_SERVICE_NOT_INJECTED_MESSAGE);
|
|
53
|
+
}
|
|
54
|
+
const resources = (0, resolve_resources_1.resolveResources)(preLock, args);
|
|
55
|
+
const joinedKey = resources.join(resource_separator_const_1.RESOURCE_SEPARATOR);
|
|
56
|
+
const store = (0, create_lock_service_store_1.createLockServiceStore)(lockService, effectiveDuration);
|
|
57
|
+
const middleware = (0, lock_decorator_1.createLockMiddleware$)(store, mode, joinedKey);
|
|
58
|
+
const context = { className: '', methodName, args, logContext: methodName };
|
|
59
|
+
return middleware(context, () => {
|
|
60
|
+
let innerResult;
|
|
61
|
+
try {
|
|
62
|
+
innerResult = originalMethod.apply(this, args);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
return (0, rxjs_1.throwError)(() => new MethodThrownError(err));
|
|
66
|
+
}
|
|
67
|
+
if (!(0, rxjs_1.isObservable)(innerResult)) {
|
|
68
|
+
return (0, rxjs_1.throwError)(() => new MethodThrownError(new Error(`Method ${methodName} does not return an observable`)));
|
|
69
|
+
}
|
|
70
|
+
return innerResult.pipe((0, rxjs_1.catchError)((error) => (0, rxjs_1.throwError)(() => new MethodThrownError(error))));
|
|
71
|
+
})
|
|
72
|
+
.pipe((0, rxjs_1.catchError)((error) => error instanceof MethodThrownError
|
|
73
|
+
? recoverFromMethodError(error.cause, catchErrorFn$)
|
|
74
|
+
: recoverFromAcquireError(error, mode, catchErrorFn$)));
|
|
75
|
+
});
|
|
76
|
+
};
|
|
16
77
|
return descriptor;
|
|
17
78
|
};
|
|
18
|
-
|
|
19
|
-
|
|
79
|
+
return {
|
|
80
|
+
SequentialLock$: makeDecorator('sequential'),
|
|
81
|
+
ExclusiveLock$: makeDecorator('exclusive'),
|
|
82
|
+
};
|
|
20
83
|
};
|
|
21
84
|
exports.createObservableLockDecorators = createObservableLockDecorators;
|
|
22
85
|
//# sourceMappingURL=create-observable-lock-decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-observable-lock-decorators.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"create-observable-lock-decorators.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-observable-lock-decorators/create-observable-lock-decorators.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,+BAA+F;AAE/F,kE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CAAC,CAAC;IAEN,OAAO;QACH,eAAe,EAAE,aAAa,CAAC,YAAY,CAAC;QAC5C,cAAc,EAAE,aAAa,CAAC,WAAW,CAAC;KAC7C,CAAC;AACN,CAAC,CAAC;AAhEW,QAAA,8BAA8B,kCAgEzC"}
|
package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
2
2
|
import type { LockServiceInterface } from '../interface/lock-service.interface';
|
|
3
|
-
import type { AbstractConstructor,
|
|
3
|
+
import type { AbstractConstructor, MethodDecoratorType } from '@rnw-community/shared';
|
|
4
|
+
type PromiseRecoveryType<TResult> = TResult extends Promise<infer TValue> ? TValue | Promise<TValue> : never;
|
|
5
|
+
type PromiseRecoveryFnType<K extends (...args: any[]) => Promise<unknown>> = (error: unknown) => PromiseRecoveryType<ReturnType<K>>;
|
|
4
6
|
export declare const createPromiseLockDecorators: (serviceToken: AbstractConstructor<LockServiceInterface>, defaultDuration: number) => {
|
|
5
|
-
SequentialLock: <K extends
|
|
6
|
-
ExclusiveLock: <K extends
|
|
7
|
+
SequentialLock: <K extends (...args: any[]) => Promise<unknown>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], catchErrorFn?: PromiseRecoveryFnType<K>, duration?: number) => MethodDecoratorType<K>;
|
|
8
|
+
ExclusiveLock: <K extends (...args: any[]) => Promise<unknown>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], catchErrorFn?: PromiseRecoveryFnType<K>, duration?: number) => MethodDecoratorType<K>;
|
|
7
9
|
};
|
|
10
|
+
export {};
|
|
8
11
|
//# sourceMappingURL=create-promise-lock-decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-promise-lock-decorators.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-promise-lock-decorators.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEtF,KAAK,mBAAmB,CAAC,OAAO,IAAI,OAAO,SAAS,OAAO,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AAE7G,KAAK,qBAAqB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,IAAI,CACzE,KAAK,EAAE,OAAO,KACb,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AA6BxC,eAAO,MAAM,2BAA2B,GACpC,cAAc,mBAAmB,CAAC,oBAAoB,CAAC,EACvD,iBAAiB,MAAM;qBAOlB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,WAC/D,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,iBAC1C,qBAAqB,CAAC,CAAC,CAAC,aAC5B,MAAM,KAClB,mBAAmB,CAAC,CAAC,CAAC;oBAJxB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,WAC/D,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,iBAC1C,qBAAqB,CAAC,CAAC,CAAC,aAC5B,MAAM,KAClB,mBAAmB,CAAC,CAAC,CAAC;CAgDhC,CAAC"}
|
package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js
CHANGED
|
@@ -1,22 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPromiseLockDecorators = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const lock_decorator_1 = require("@rnw-community/lock-decorator");
|
|
6
|
+
const shared_1 = require("@rnw-community/shared");
|
|
7
|
+
const create_lock_service_store_1 = require("../create-lock-service-store");
|
|
8
|
+
const lock_service_not_injected_message_const_1 = require("../lock-service-not-injected-message.const");
|
|
9
|
+
const resolve_resources_1 = require("../resolve-resources");
|
|
10
|
+
const resource_separator_const_1 = require("../resource-separator.const");
|
|
11
|
+
const safeRelease = async (handle) => {
|
|
12
|
+
try {
|
|
13
|
+
await handle.release();
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
void 0;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const handleLockError = (error, mode, catchErrorFn) => {
|
|
20
|
+
const isExclusiveBusy = error instanceof lock_decorator_1.LockBusyError && mode === 'exclusive' && !(0, shared_1.isDefined)(catchErrorFn);
|
|
21
|
+
const normalized = error instanceof lock_decorator_1.LockBusyError
|
|
22
|
+
? new Error(`Lock not acquired for keys: ${error.key.split(resource_separator_const_1.RESOURCE_SEPARATOR).join(', ')}`)
|
|
23
|
+
: error;
|
|
24
|
+
if (isExclusiveBusy) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
if ((0, shared_1.isDefined)(catchErrorFn)) {
|
|
28
|
+
return catchErrorFn(normalized);
|
|
29
|
+
}
|
|
30
|
+
throw normalized;
|
|
31
|
+
};
|
|
8
32
|
const createPromiseLockDecorators = (serviceToken, defaultDuration) => {
|
|
9
33
|
const serviceSymbol = Symbol('LockService');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
descriptor.value
|
|
34
|
+
const makeDecorator = (mode) =>
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
(preLock, catchErrorFn, duration) => (target, propertyKey, descriptor) => {
|
|
37
|
+
(0, common_1.Inject)(serviceToken)(target, serviceSymbol);
|
|
38
|
+
const methodName = `${target.constructor.name}::${String(propertyKey)}`;
|
|
39
|
+
const originalMethod = descriptor.value;
|
|
40
|
+
const effectiveDuration = duration ?? defaultDuration;
|
|
41
|
+
// eslint-disable-next-line max-statements
|
|
42
|
+
descriptor.value = async function promiseLockDecorator(...args) {
|
|
43
|
+
const lockService = this[serviceSymbol];
|
|
44
|
+
if (!(0, shared_1.isDefined)(lockService)) {
|
|
45
|
+
throw new Error(lock_service_not_injected_message_const_1.LOCK_SERVICE_NOT_INJECTED_MESSAGE);
|
|
46
|
+
}
|
|
47
|
+
const resources = (0, resolve_resources_1.resolveResources)(preLock, args);
|
|
48
|
+
const joinedKey = resources.join(resource_separator_const_1.RESOURCE_SEPARATOR);
|
|
49
|
+
const store = (0, create_lock_service_store_1.createLockServiceStore)(lockService, effectiveDuration);
|
|
50
|
+
let handle;
|
|
51
|
+
try {
|
|
52
|
+
handle = await store.acquire(joinedKey, mode);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return await Promise.resolve(handleLockError(error, mode, catchErrorFn));
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const result = originalMethod.apply(this, args);
|
|
59
|
+
if (!(0, shared_1.isPromise)(result)) {
|
|
60
|
+
throw new Error(`Method ${methodName} does not return a promise`);
|
|
61
|
+
}
|
|
62
|
+
return await result;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if ((0, shared_1.isDefined)(catchErrorFn)) {
|
|
66
|
+
return await Promise.resolve(catchErrorFn(error));
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await safeRelease(handle);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
16
74
|
return descriptor;
|
|
17
75
|
};
|
|
18
|
-
|
|
19
|
-
|
|
76
|
+
return {
|
|
77
|
+
SequentialLock: makeDecorator('sequential'),
|
|
78
|
+
ExclusiveLock: makeDecorator('exclusive'),
|
|
79
|
+
};
|
|
20
80
|
};
|
|
21
81
|
exports.createPromiseLockDecorators = createPromiseLockDecorators;
|
|
22
82
|
//# sourceMappingURL=create-promise-lock-decorators.js.map
|
package/dist/cjs/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-promise-lock-decorators.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"create-promise-lock-decorators.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/create-promise-lock-decorators/create-promise-lock-decorators.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,kEAA8D;AAC9D,kDAA6D;AAE7D,4EAAsE;AACtE,wGAA+F;AAC/F,4DAAwD;AACxD,0EAAiE;AAajE,MAAM,WAAW,GAAG,KAAK,EAAE,MAA2B,EAAiB,EAAE;IACrE,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACL,KAAK,CAAC,CAAC;IACX,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CACpB,KAAc,EACd,IAAkB,EAClB,YAA0E,EACpC,EAAE;IACxC,MAAM,eAAe,GAAG,KAAK,YAAY,8BA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C,CAAC;IAEN,OAAO;QACH,cAAc,EAAE,aAAa,CAAC,YAAY,CAAC;QAC3C,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC;KAC5C,CAAC;AACN,CAAC,CAAC;AA7DW,QAAA,2BAA2B,+BA6DtC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { PreDecoratorFunction } from '../../../type/pre-decorator-function.type';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MethodDecoratorType } from '@rnw-community/shared';
|
|
3
|
+
import type { Observable } from 'rxjs';
|
|
3
4
|
/**
|
|
4
5
|
* @deprecated Use `createObservableLockDecorators` instead. This decorator requires class inheritance from `LockableService`.
|
|
5
6
|
* @see {@link createObservableLockDecorators} for the DI-based approach.
|
|
6
7
|
*/
|
|
7
|
-
export declare const LockObservable: <K extends
|
|
8
|
+
export declare const LockObservable: <K extends (...args: readonly any[]) => Observable<unknown>, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn$?: (error: unknown) => ReturnType<K>, retryCount?: number) => MethodDecoratorType<K>;
|
|
8
9
|
//# 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":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,cAAc,GAGnB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,SAAS,GAAG,EAAE,KAAK,UAAU,CAAC,OAAO,CAAC,EAC1D,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EAE3B,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,gBAAgB,CAAC,KAAK,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,EACjD,aAAa,MAAM,KACpB,mBAAmB,CAAC,CAAC,CAcvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":";;;AAAA,uFAA6E;AAC7E,uEAA6D;AAC7D,+EAAqE;
|
|
1
|
+
{"version":3,"file":"lock-observable.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-observable/lock-observable.decorator.ts"],"names":[],"mappings":";;;AAAA,uFAA6E;AAC7E,uEAA6D;AAC7D,+EAAqE;AAMrE;;;GAGG;AACI,MAAM,cAAc,GACvB,CAKI,OAAyD,EACzD,QAAgB,EAChB,aAAiD,EACjD,UAAmB,EACG,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,UAAU,CAAC,KAAK,GAAG,IAAA,oDAAqB,EACpC,4CAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU;IACV,oEAAoE;IACpE,UAAU,CAAC,KAAM,EACjB,IAAA,oCAAa,EAAC,MAAM,EAAE,WAAW,CAAC,EAClC,aAAa,CACA,CAAC;IAElB,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAxBO,QAAA,cAAc,kBAwBrB"}
|
|
@@ -4,5 +4,5 @@ import type { AnyFn, MethodDecoratorType } from '@rnw-community/shared';
|
|
|
4
4
|
* @deprecated Use `createPromiseLockDecorators` instead. This decorator requires class inheritance from `LockableService`.
|
|
5
5
|
* @see {@link createPromiseLockDecorators} for the DI-based approach.
|
|
6
6
|
*/
|
|
7
|
-
export declare const LockPromise: <K extends AnyFn,
|
|
7
|
+
export declare const LockPromise: <K extends AnyFn, TArgs extends Parameters<K>>(preLock: PreDecoratorFunction<TArgs, string[]> | string[], duration: number, catchErrorFn?: (error: unknown) => ReturnType<K>, retryCount?: number) => MethodDecoratorType<K>;
|
|
8
8
|
//# 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":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,WAAW,GACnB,CAAC,SAAS,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,WAAW,GACnB,CAAC,SAAS,KAAK,EAAE,KAAK,SAAS,UAAU,CAAC,CAAC,CAAC,EACzC,SAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,EACzD,UAAU,MAAM,EAChB,eAAe,CAAC,KAAK,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,EAChD,aAAa,MAAM,KACpB,mBAAmB,CAAC,CAAC,CAavB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":";;;AAAA,iFAAuE;AACvE,uEAA6D;AAC7D,+EAAqE;AAKrE;;;GAGG;AACI,MAAM,WAAW,GACpB,
|
|
1
|
+
{"version":3,"file":"lock-promise.decorator.js","sourceRoot":"","sources":["../../../../../src/decorator/lock/lock-promise/lock-promise.decorator.ts"],"names":[],"mappings":";;;AAAA,iFAAuE;AACvE,uEAA6D;AAC7D,+EAAqE;AAKrE;;;GAGG;AACI,MAAM,WAAW,GACpB,CACI,OAAyD,EACzD,QAAgB,EAChB,YAAgD,EAChD,UAAmB,EACG,EAAE,CAC5B,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IAChC,UAAU,CAAC,KAAK,GAAG,IAAA,8CAAkB,EACjC,4CAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,CAAC,KAAU,EACrB,IAAA,oCAAa,EAAC,MAAM,EAAE,WAAW,CAAC,EAClC,YAAY,CACC,CAAC;IAElB,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAnBO,QAAA,WAAW,eAmBlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-service-not-injected-message.const.d.ts","sourceRoot":"","sources":["../../../../src/decorator/lock/lock-service-not-injected-message.const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,uGAC0D,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LOCK_SERVICE_NOT_INJECTED_MESSAGE = void 0;
|
|
4
|
+
exports.LOCK_SERVICE_NOT_INJECTED_MESSAGE = 'LockService was not injected. Ensure the lock service provider is registered in the NestJS module.';
|
|
5
|
+
//# sourceMappingURL=lock-service-not-injected-message.const.js.map
|