@autofleet/shtinker 1.1.8 → 1.1.10

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.
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const zehut_1 = require("@autofleet/zehut");
16
+ const lodash_1 = require("lodash");
16
17
  const const_1 = require("./const");
17
18
  const logger_1 = __importDefault(require("./logger"));
18
19
  const CUSTOM_FIELDS_PROPERTY = 'customFields';
@@ -54,7 +55,11 @@ const getChangedCustomFieldsRows = (instance) => {
54
55
  }
55
56
  const customFields = instance.get(CUSTOM_FIELDS_PROPERTY);
56
57
  const previousCustomFields = instance.previous(CUSTOM_FIELDS_PROPERTY);
57
- const changedCustomFields = Object.keys(customFields).filter((field) => !isEmpty(customFields === null || customFields === void 0 ? void 0 : customFields[field]) || !isEmpty(previousCustomFields === null || previousCustomFields === void 0 ? void 0 : previousCustomFields[field]));
58
+ const changedCustomFields = Object.keys(customFields).filter((field) => {
59
+ const newValue = customFields === null || customFields === void 0 ? void 0 : customFields[field];
60
+ const oldValue = previousCustomFields === null || previousCustomFields === void 0 ? void 0 : previousCustomFields[field];
61
+ return (!isEmpty(newValue) || !isEmpty(oldValue)) && !(0, lodash_1.isEqual)(newValue, oldValue);
62
+ });
58
63
  return changedCustomFields.map((changedCustomField) => ({
59
64
  property: `customFields.${changedCustomField}`,
60
65
  previousValue: previousCustomFields === null || previousCustomFields === void 0 ? void 0 : previousCustomFields[changedCustomField],
package/dist/types.d.ts CHANGED
@@ -38,7 +38,8 @@ export declare enum Action {
38
38
  BULK_UPSERT = "bulk-upsert",
39
39
  UPSERT = "upsert",
40
40
  JOIN = "join",
41
- MOVE = "move"
41
+ MOVE = "move",
42
+ REOPTIMIZATION = "reoptimization"
42
43
  }
43
44
  export declare enum EntityType {
44
45
  RIDE = "Ride",
package/dist/types.js CHANGED
@@ -19,6 +19,7 @@ var Action;
19
19
  Action["UPSERT"] = "upsert";
20
20
  Action["JOIN"] = "join";
21
21
  Action["MOVE"] = "move";
22
+ Action["REOPTIMIZATION"] = "reoptimization";
22
23
  })(Action = exports.Action || (exports.Action = {}));
23
24
  var EntityType;
24
25
  (function (EntityType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@
17
17
  "@autofleet/network": "^1.4.7",
18
18
  "@autofleet/rabbit": "^3.2.18",
19
19
  "@autofleet/zehut": "^3.0.10",
20
+ "lodash": "^4.17.21",
20
21
  "sequelize-typescript": "^2.1.5"
21
22
  },
22
23
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
  import { getCurrentPayload as getCurrentTrace } from '@autofleet/zehut';
2
2
  import { Sequelize } from 'sequelize';
3
+ import { isEqual } from 'lodash';
3
4
 
4
5
  import { AuditLogPayload, AuditLoggerOptions, AuditLogContext } from './types';
5
6
  import { AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUDIT_LOG_CONTEXT_KEY } from './const';
@@ -50,7 +51,11 @@ const getChangedCustomFieldsRows = (instance) => {
50
51
 
51
52
  const customFields = instance.get(CUSTOM_FIELDS_PROPERTY);
52
53
  const previousCustomFields = instance.previous(CUSTOM_FIELDS_PROPERTY);
53
- const changedCustomFields = Object.keys(customFields).filter((field) => !isEmpty(customFields?.[field]) || !isEmpty(previousCustomFields?.[field]));
54
+ const changedCustomFields = Object.keys(customFields).filter((field) => {
55
+ const newValue = customFields?.[field];
56
+ const oldValue = previousCustomFields?.[field];
57
+ return (!isEmpty(newValue) || !isEmpty(oldValue)) && !isEqual(newValue, oldValue);
58
+ });
54
59
  return changedCustomFields.map((changedCustomField) => ({
55
60
  property: `customFields.${changedCustomField}`,
56
61
  previousValue: previousCustomFields?.[changedCustomField],
package/src/types.ts CHANGED
@@ -45,6 +45,7 @@ export enum Action {
45
45
  UPSERT = 'upsert',
46
46
  JOIN = 'join',
47
47
  MOVE = 'move',
48
+ REOPTIMIZATION = 'reoptimization',
48
49
  }
49
50
 
50
51
  export enum EntityType {