@iamnnort/nestjs-serializer 2.2.4 → 2.2.5
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.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9086,18 +9086,18 @@ var SerializerService = class {
|
|
|
9086
9086
|
const transformedEntity = await this.transformEntity(response, config);
|
|
9087
9087
|
return transformedEntity;
|
|
9088
9088
|
}
|
|
9089
|
-
async transformRelationEntity(fieldValue, fieldConfig) {
|
|
9089
|
+
async transformRelationEntity(fieldValue, fieldConfig, entity) {
|
|
9090
9090
|
const fieldTransform = isFunction(fieldConfig.fieldTransform) ? fieldConfig.fieldTransform : (_) => _;
|
|
9091
9091
|
if (isArray(fieldValue)) {
|
|
9092
9092
|
return fieldTransform(await Promise.all(fieldValue.map(async (relationEntity) => {
|
|
9093
9093
|
return this.transformEntity(relationEntity, {
|
|
9094
9094
|
scopes: fieldConfig.relationScopes
|
|
9095
9095
|
});
|
|
9096
|
-
})));
|
|
9096
|
+
})), entity);
|
|
9097
9097
|
}
|
|
9098
9098
|
return fieldTransform(await this.transformEntity(fieldValue, {
|
|
9099
9099
|
scopes: fieldConfig.relationScopes
|
|
9100
|
-
}));
|
|
9100
|
+
}), entity);
|
|
9101
9101
|
}
|
|
9102
9102
|
async transformEntity(entity, config) {
|
|
9103
9103
|
if (!entity) {
|
|
@@ -9130,10 +9130,10 @@ var SerializerService = class {
|
|
|
9130
9130
|
const fieldName = fieldConfig.fieldName || fieldConfig.name;
|
|
9131
9131
|
let fieldValue = await entity[fieldConfig.name];
|
|
9132
9132
|
if (!isNil(fieldConfig.relationScopes)) {
|
|
9133
|
-
fieldValue = await this.transformRelationEntity(fieldValue, fieldConfig);
|
|
9133
|
+
fieldValue = await this.transformRelationEntity(fieldValue, fieldConfig, entity);
|
|
9134
9134
|
} else {
|
|
9135
9135
|
if (isFunction(fieldConfig.fieldTransform)) {
|
|
9136
|
-
fieldValue = await fieldConfig.fieldTransform(fieldValue);
|
|
9136
|
+
fieldValue = await fieldConfig.fieldTransform(fieldValue, entity);
|
|
9137
9137
|
}
|
|
9138
9138
|
}
|
|
9139
9139
|
transformedEntity = merge(set({
|