@autofleet/shtinker 1.1.5-beta.4 → 1.1.5-beta.6

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.
@@ -18,6 +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('MATAN getAuditContext currentTrace: ', { currentTrace });
21
22
  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);
22
23
  return auditContext;
23
24
  };
@@ -40,6 +41,7 @@ class AuditLogger {
40
41
  modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
41
42
  try {
42
43
  const auditContext = getAuditContext();
44
+ logger_1.default.info('MATAN auditContext: ', { auditContext });
43
45
  if (auditContext) {
44
46
  const changedProperties = getChangedFields(instance, options);
45
47
  logger_1.default.info('MATAN changedProperties from shtinker:', { changedProperties });
@@ -52,6 +54,8 @@ class AuditLogger {
52
54
  newValue: instance.get(property),
53
55
  })),
54
56
  };
57
+ const entityId = instance.id;
58
+ logger_1.default.info('MATAN entityId from shtinker:', { entityId });
55
59
  this.sendAuditLogRows(payload);
56
60
  }
57
61
  }
package/dist/index.js CHANGED
@@ -44,7 +44,6 @@ const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(vo
44
44
  const currentTrace = (0, zehut_1.getCurrentPayload)();
45
45
  logger_1.default.info('currentTrace: ', { currentTrace });
46
46
  if (currentTrace && currentTrace.context && currentTrace.context.get) {
47
- logger_1.default.info('inside if currentTrace:');
48
47
  const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
49
48
  const auditLogContext = {
50
49
  entityType,
@@ -68,7 +67,6 @@ const setRabbitAuditContext = (entityType, action) => (endpoint) => __awaiter(vo
68
67
  const currentTrace = (0, zehut_1.getCurrentPayload)();
69
68
  logger_1.default.info('MATAN currentTrace: ', currentTrace);
70
69
  if ((_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get) {
71
- logger_1.default.info('MATAN setRabbitAuditContext inside if currentTrace:');
72
70
  const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
73
71
  const auditLogContext = {
74
72
  entityType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.5-beta.4",
3
+ "version": "1.1.5-beta.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@ import logger from './logger';
8
8
 
9
9
  const getAuditContext = () => {
10
10
  const currentTrace = getCurrentTrace();
11
+ logger.info('MATAN getAuditContext currentTrace: ', { currentTrace });
11
12
  const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
12
13
  return auditContext;
13
14
  };
@@ -39,6 +40,7 @@ class AuditLogger {
39
40
  modelType.addHook('afterSave', async (instance: any, options: any) => {
40
41
  try {
41
42
  const auditContext = getAuditContext();
43
+ logger.info('MATAN auditContext: ', { auditContext });
42
44
  if (auditContext) {
43
45
  const changedProperties = getChangedFields(instance, options);
44
46
  logger.info('MATAN changedProperties from shtinker:', { changedProperties });
@@ -51,6 +53,8 @@ class AuditLogger {
51
53
  newValue: instance.get(property),
52
54
  })),
53
55
  };
56
+ const entityId = instance.id;
57
+ logger.info('MATAN entityId from shtinker:', { entityId });
54
58
  this.sendAuditLogRows(payload);
55
59
  }
56
60
  } catch (error) {
package/src/index.ts CHANGED
@@ -21,7 +21,6 @@ export const setAuditContext = (
21
21
  const currentTrace = getCurrentTrace();
22
22
  logger.info('currentTrace: ', { currentTrace });
23
23
  if (currentTrace && currentTrace.context && currentTrace.context.get) {
24
- logger.info('inside if currentTrace:');
25
24
  const user = currentTrace.context.get(USER_CONTEXT_KEY);
26
25
  const auditLogContext: AuditLogContext = {
27
26
  entityType,
@@ -46,7 +45,6 @@ export const setRabbitAuditContext = (
46
45
  const currentTrace = getCurrentTrace();
47
46
  logger.info('MATAN currentTrace: ', currentTrace);
48
47
  if (currentTrace?.context?.get) {
49
- logger.info('MATAN setRabbitAuditContext inside if currentTrace:');
50
48
  const user = currentTrace.context.get(USER_CONTEXT_KEY);
51
49
  const auditLogContext: AuditLogContext = {
52
50
  entityType,