@powfix/core-js 0.13.1 → 0.13.3
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.
|
@@ -2,7 +2,7 @@ import { Transaction } from "sequelize";
|
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
3
|
import { TransactionManagerLogLevel, TransactionManagerTimeoutAction } from "../constants";
|
|
4
4
|
import { TransactionManagerAddOption, TransactionManagerEventTypes } from "./TransactionManager.types";
|
|
5
|
-
declare class TransactionManager {
|
|
5
|
+
export declare class TransactionManager {
|
|
6
6
|
static DEFAULT_TIMEOUT: number;
|
|
7
7
|
static DEFAULT_ACTION: TransactionManagerTimeoutAction;
|
|
8
8
|
private static instance;
|
|
@@ -25,4 +25,3 @@ declare class TransactionManager {
|
|
|
25
25
|
private timeout;
|
|
26
26
|
private afterCommit;
|
|
27
27
|
}
|
|
28
|
-
export default TransactionManager;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TransactionManager = void 0;
|
|
15
16
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
16
17
|
const constants_1 = require("../constants");
|
|
17
18
|
const LOG_TAG = '[TransactionManager]';
|
|
@@ -22,7 +23,7 @@ class TransactionManager {
|
|
|
22
23
|
this.transactionTimeoutMap = new Map();
|
|
23
24
|
// Emitter
|
|
24
25
|
this.emitter = new eventemitter3_1.default();
|
|
25
|
-
if (this.logLevel
|
|
26
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.VERBOSE) {
|
|
26
27
|
console.log(LOG_TAG, 'TransactionManager instance initialized');
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -35,7 +36,7 @@ class TransactionManager {
|
|
|
35
36
|
}
|
|
36
37
|
setLogLevel(logLevel) {
|
|
37
38
|
this.logLevel = logLevel;
|
|
38
|
-
if (this.logLevel
|
|
39
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.VERBOSE) {
|
|
39
40
|
console.log(LOG_TAG, 'log level changed to', logLevel);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -48,7 +49,7 @@ class TransactionManager {
|
|
|
48
49
|
add(transaction, option) {
|
|
49
50
|
var _a, _b;
|
|
50
51
|
if (this.transactionTimeoutMap.has(transaction)) {
|
|
51
|
-
if (this.logLevel
|
|
52
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.ERROR) {
|
|
52
53
|
console.error(LOG_TAG, 'transaction already exists');
|
|
53
54
|
}
|
|
54
55
|
return;
|
|
@@ -68,7 +69,7 @@ class TransactionManager {
|
|
|
68
69
|
if (transactionTimeout != null) {
|
|
69
70
|
clearTimeout(transactionTimeout.handler);
|
|
70
71
|
this.transactionTimeoutMap.delete(transaction);
|
|
71
|
-
if (this.logLevel
|
|
72
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.VERBOSE) {
|
|
72
73
|
console.log(LOG_TAG, this.getTransactionLogArg(transaction), 'removed');
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -88,7 +89,7 @@ class TransactionManager {
|
|
|
88
89
|
let handled = false;
|
|
89
90
|
const finished = transaction === null || transaction === void 0 ? void 0 : transaction.finished;
|
|
90
91
|
if (finished != null) {
|
|
91
|
-
if (this.logLevel
|
|
92
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.VERBOSE) {
|
|
92
93
|
console.log(LOG_TAG, this.getTransactionLogArg(transaction), `is already handled(${finished}) after`, reason);
|
|
93
94
|
}
|
|
94
95
|
this.remove(transaction);
|
|
@@ -108,7 +109,7 @@ class TransactionManager {
|
|
|
108
109
|
break;
|
|
109
110
|
}
|
|
110
111
|
default: {
|
|
111
|
-
if (this.logLevel
|
|
112
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.ERROR) {
|
|
112
113
|
console.error(LOG_TAG, `unknown action`, action);
|
|
113
114
|
}
|
|
114
115
|
break;
|
|
@@ -116,12 +117,12 @@ class TransactionManager {
|
|
|
116
117
|
}
|
|
117
118
|
handled = finished != null;
|
|
118
119
|
if (finished != null) {
|
|
119
|
-
if (this.logLevel
|
|
120
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.ERROR) {
|
|
120
121
|
console.error(LOG_TAG, this.getTransactionLogArg(transaction), `handled(${finished}) after`, reason);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
else {
|
|
124
|
-
if (this.logLevel
|
|
125
|
+
if (this.logLevel <= constants_1.TransactionManagerLogLevel.ERROR) {
|
|
125
126
|
console.error(LOG_TAG, this.getTransactionLogArg(transaction), `not handled 🚫`);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -145,6 +146,6 @@ class TransactionManager {
|
|
|
145
146
|
this.remove(transaction);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
149
|
+
exports.TransactionManager = TransactionManager;
|
|
148
150
|
TransactionManager.DEFAULT_TIMEOUT = 60 * 1000;
|
|
149
151
|
TransactionManager.DEFAULT_ACTION = constants_1.TransactionManagerTimeoutAction.ROLLBACK;
|
|
150
|
-
exports.default = TransactionManager;
|