@iamnnort/nestjs-serializer 2.0.2 → 2.1.1

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/index.js CHANGED
@@ -9134,6 +9134,25 @@ var SerializerService = class {
9134
9134
  ...transformedEntity
9135
9135
  }, fieldName, fieldValue), transformedEntity);
9136
9136
  }));
9137
+ const fieldCountMap = serializerFieldConfigs.reduce((fieldCountMap2, fieldConfig) => {
9138
+ const fieldName = fieldConfig.fieldName || fieldConfig.name;
9139
+ const rootFieldName = fieldName.split(".")[0];
9140
+ return {
9141
+ ...fieldCountMap2,
9142
+ [rootFieldName]: _lodash.isNil.call(void 0, fieldCountMap2[rootFieldName]) ? 1 : fieldCountMap2[rootFieldName] + 1
9143
+ };
9144
+ }, {});
9145
+ Object.entries(transformedEntity).forEach(([rootFieldName, rootFieldValue]) => {
9146
+ if (!_lodash.isPlainObject.call(void 0, rootFieldValue)) {
9147
+ return;
9148
+ }
9149
+ const rootFieldCount = fieldCountMap[rootFieldName];
9150
+ const rootFieldChildrenCount = Object.keys(rootFieldValue).length;
9151
+ if (rootFieldCount < rootFieldChildrenCount) {
9152
+ return;
9153
+ }
9154
+ transformedEntity[rootFieldName] = null;
9155
+ });
9137
9156
  if (_lodash.isPlainObject.call(void 0, entity.relatedScope)) {
9138
9157
  const transformedRelatedScope = {};
9139
9158
  await Promise.all(Object.keys(entity.relatedScope).map(async (relaitedEntityKey) => {