@autofleet/shtinker 1.1.7-beta.1 → 1.1.7-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit-logger.js +0 -4
- package/dist/index.js +4 -0
- package/package.json +1 -1
- package/src/audit-logger.ts +0 -4
- package/src/index.ts +5 -0
package/dist/audit-logger.js
CHANGED
|
@@ -18,9 +18,7 @@ const logger_1 = __importDefault(require("./logger"));
|
|
|
18
18
|
const getAuditContext = () => {
|
|
19
19
|
var _a;
|
|
20
20
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
21
|
-
logger_1.default.info('getAuditContext currentTrace', { currentTrace });
|
|
22
21
|
const auditContext = (_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get(const_1.AUDIT_LOG_CONTEXT_KEY);
|
|
23
|
-
logger_1.default.info('getAuditContext auditContext', { auditContext });
|
|
24
22
|
return auditContext;
|
|
25
23
|
};
|
|
26
24
|
const isEmpty = (field) => {
|
|
@@ -53,7 +51,6 @@ class AuditLogger {
|
|
|
53
51
|
modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
|
|
54
52
|
try {
|
|
55
53
|
const auditContext = getAuditContext();
|
|
56
|
-
logger_1.default.info('auditContext from shtinker', { auditContext });
|
|
57
54
|
if (auditContext) {
|
|
58
55
|
const changedProperties = getChangedFields(instance, options);
|
|
59
56
|
const payload = {
|
|
@@ -65,7 +62,6 @@ class AuditLogger {
|
|
|
65
62
|
newValue: instance.get(property),
|
|
66
63
|
})),
|
|
67
64
|
};
|
|
68
|
-
logger_1.default.info('sending audit log rows from shtinker', { payload });
|
|
69
65
|
this.sendAuditLogRows(payload);
|
|
70
66
|
}
|
|
71
67
|
}
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,10 @@ const enableAuditing = (options) => {
|
|
|
41
41
|
exports.enableAuditing = enableAuditing;
|
|
42
42
|
const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
|
+
const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
|
|
45
|
+
if (ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME)) {
|
|
46
|
+
return next();
|
|
47
|
+
}
|
|
44
48
|
const currentTrace = (0, zehut_1.getCurrentPayload)();
|
|
45
49
|
if (currentTrace && currentTrace.context && currentTrace.context.get) {
|
|
46
50
|
const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
|
package/package.json
CHANGED
package/src/audit-logger.ts
CHANGED
|
@@ -8,9 +8,7 @@ import logger from './logger';
|
|
|
8
8
|
|
|
9
9
|
const getAuditContext = () => {
|
|
10
10
|
const currentTrace = getCurrentTrace();
|
|
11
|
-
logger.info('getAuditContext currentTrace', { currentTrace });
|
|
12
11
|
const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
|
|
13
|
-
logger.info('getAuditContext auditContext', { auditContext });
|
|
14
12
|
return auditContext;
|
|
15
13
|
};
|
|
16
14
|
|
|
@@ -54,7 +52,6 @@ class AuditLogger {
|
|
|
54
52
|
modelType.addHook('afterSave', async (instance: any, options: any) => {
|
|
55
53
|
try {
|
|
56
54
|
const auditContext = getAuditContext();
|
|
57
|
-
logger.info('auditContext from shtinker', { auditContext });
|
|
58
55
|
if (auditContext) {
|
|
59
56
|
const changedProperties = getChangedFields(instance, options);
|
|
60
57
|
const payload: AuditLogPayload = {
|
|
@@ -66,7 +63,6 @@ class AuditLogger {
|
|
|
66
63
|
newValue: instance.get(property),
|
|
67
64
|
})),
|
|
68
65
|
};
|
|
69
|
-
logger.info('sending audit log rows from shtinker', { payload });
|
|
70
66
|
this.sendAuditLogRows(payload);
|
|
71
67
|
}
|
|
72
68
|
} catch (error) {
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,11 @@ export const setAuditContext = (
|
|
|
18
18
|
action: string,
|
|
19
19
|
) => async (req: any, res: any, next: any): Promise<any> => {
|
|
20
20
|
try {
|
|
21
|
+
const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
|
|
22
|
+
if (ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME)) {
|
|
23
|
+
return next();
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
const currentTrace = getCurrentTrace();
|
|
22
27
|
if (currentTrace && currentTrace.context && currentTrace.context.get) {
|
|
23
28
|
const user = currentTrace.context.get(USER_CONTEXT_KEY);
|