@autofleet/shtinker 1.1.6-beta.12 → 1.1.6-beta.13
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 +3 -3
- package/package.json +1 -1
- package/src/audit-logger.ts +3 -3
package/dist/audit-logger.js
CHANGED
|
@@ -24,19 +24,19 @@ const getAuditContext = () => {
|
|
|
24
24
|
const isEmpty = (value) => {
|
|
25
25
|
return Array.isArray(value) ? value.length === 0 : value == null;
|
|
26
26
|
};
|
|
27
|
-
const
|
|
27
|
+
const filterOutEmptyFields = (fields, instance) => fields.filter(field => !isEmpty(instance.previous(field)) || !isEmpty(instance.get(field)));
|
|
28
28
|
const getChangedFields = (instance, options) => {
|
|
29
29
|
logger_1.default.info('START getChangedFields');
|
|
30
30
|
// When bulk updating in sequelize using the "returning" option, the instance.changed() stops working.
|
|
31
31
|
// It's a known issut with sequelize.
|
|
32
32
|
if (options.returning) {
|
|
33
|
-
const nonEmptyChangedFields = options.fields
|
|
33
|
+
const nonEmptyChangedFields = filterOutEmptyFields(options.fields, instance);
|
|
34
34
|
logger_1.default.info('BULK UPDATING', { options, nonEmptyChangedFields });
|
|
35
35
|
return nonEmptyChangedFields;
|
|
36
36
|
}
|
|
37
37
|
const changedProperties = instance.changed();
|
|
38
38
|
logger_1.default.info('changedProperties: ', { changedProperties });
|
|
39
|
-
const nonEmptyChangedProperties = changedProperties
|
|
39
|
+
const nonEmptyChangedProperties = filterOutEmptyFields(changedProperties, instance);
|
|
40
40
|
logger_1.default.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
|
|
41
41
|
return nonEmptyChangedProperties;
|
|
42
42
|
};
|
package/package.json
CHANGED
package/src/audit-logger.ts
CHANGED
|
@@ -16,20 +16,20 @@ const isEmpty = (value) => {
|
|
|
16
16
|
return Array.isArray(value) ? value.length === 0 : value == null;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const filterOutEmptyFields = (fields, instance) => fields.filter(field => !isEmpty(instance.previous(field)) || !isEmpty(instance.get(field)))
|
|
20
20
|
|
|
21
21
|
const getChangedFields = (instance, options) => {
|
|
22
22
|
logger.info('START getChangedFields');
|
|
23
23
|
// When bulk updating in sequelize using the "returning" option, the instance.changed() stops working.
|
|
24
24
|
// It's a known issut with sequelize.
|
|
25
25
|
if (options.returning) {
|
|
26
|
-
const nonEmptyChangedFields = options.fields
|
|
26
|
+
const nonEmptyChangedFields = filterOutEmptyFields(options.fields, instance);
|
|
27
27
|
logger.info('BULK UPDATING', { options, nonEmptyChangedFields });
|
|
28
28
|
return nonEmptyChangedFields;
|
|
29
29
|
}
|
|
30
30
|
const changedProperties = instance.changed();
|
|
31
31
|
logger.info('changedProperties: ', { changedProperties });
|
|
32
|
-
const nonEmptyChangedProperties = changedProperties
|
|
32
|
+
const nonEmptyChangedProperties = filterOutEmptyFields(changedProperties, instance);
|
|
33
33
|
logger.info('nonEmptyChangedProperties: ', { nonEmptyChangedProperties });
|
|
34
34
|
return nonEmptyChangedProperties;
|
|
35
35
|
};
|