@autofleet/shtinker 1.1.6-beta.8 → 1.1.6-beta.9

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.
@@ -24,17 +24,18 @@ const getAuditContext = () => {
24
24
  const isEmpty = (value) => {
25
25
  return Array.isArray(value) ? value.length === 0 : !value;
26
26
  };
27
- const getChangedFields = (instance, options, loggerLocal) => {
27
+ const getChangedFields = (instance, options) => {
28
+ logger_1.default.info('START getChangedFields');
28
29
  // When bulk updating in sequelize using the "returning" option, the instance.changed() stops working.
29
30
  // It's a known issut with sequelize.
30
31
  if (options.returning) {
31
- loggerLocal.info('BULK UPDATING', { options });
32
+ logger_1.default.info('BULK UPDATING', { options });
32
33
  return options.fields;
33
34
  }
34
35
  const changedProperties = instance.changed();
35
- loggerLocal.info('changedProperties: ', { changedProperties });
36
+ logger_1.default.info('changedProperties: ', { changedProperties });
36
37
  const nonEmptyChangedProperties = changedProperties.filter((property) => isEmpty(instance.previous(property)) || isEmpty(instance.get(property)));
37
- loggerLocal.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
38
+ logger_1.default.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
38
39
  return nonEmptyChangedProperties;
39
40
  };
40
41
  class AuditLogger {
@@ -50,7 +51,7 @@ class AuditLogger {
50
51
  const auditContext = getAuditContext();
51
52
  this.logger.info('auditContext:', { auditContext });
52
53
  if (auditContext) {
53
- const changedProperties = getChangedFields(instance, options, this.logger);
54
+ const changedProperties = getChangedFields(instance, options);
54
55
  const payload = {
55
56
  entityType: modelName,
56
57
  entityId: instance.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.6-beta.8",
3
+ "version": "1.1.6-beta.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -16,17 +16,18 @@ const isEmpty = (value) => {
16
16
  return Array.isArray(value) ? value.length === 0 : !value;
17
17
  };
18
18
 
19
- const getChangedFields = (instance, options, loggerLocal) => {
19
+ const getChangedFields = (instance, options) => {
20
+ logger.info('START getChangedFields');
20
21
  // When bulk updating in sequelize using the "returning" option, the instance.changed() stops working.
21
22
  // It's a known issut with sequelize.
22
23
  if (options.returning) {
23
- loggerLocal.info('BULK UPDATING', { options });
24
+ logger.info('BULK UPDATING', { options });
24
25
  return options.fields;
25
26
  }
26
27
  const changedProperties = instance.changed();
27
- loggerLocal.info('changedProperties: ', { changedProperties });
28
+ logger.info('changedProperties: ', { changedProperties });
28
29
  const nonEmptyChangedProperties = changedProperties.filter((property) => isEmpty(instance.previous(property)) || isEmpty(instance.get(property)));
29
- loggerLocal.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
30
+ logger.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
30
31
  return nonEmptyChangedProperties;
31
32
  };
32
33
 
@@ -50,7 +51,7 @@ class AuditLogger {
50
51
  const auditContext = getAuditContext();
51
52
  this.logger.info('auditContext:', { auditContext });
52
53
  if (auditContext) {
53
- const changedProperties = getChangedFields(instance, options, this.logger);
54
+ const changedProperties = getChangedFields(instance, options);
54
55
  const payload: AuditLogPayload = {
55
56
  entityType: modelName,
56
57
  entityId: instance.id,