From 8728e7a5f1e39ad647b73493e0871c5db424ad36 Mon Sep 17 00:00:00 2001 From: PS Date: Fri, 15 Mar 2024 13:43:10 +0100 Subject: [PATCH 1/3] filter entity mapping --- packages/plugin-http-client/src/rest/BaseEntity.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/plugin-http-client/src/rest/BaseEntity.ts b/packages/plugin-http-client/src/rest/BaseEntity.ts index fd08e663..49379773 100644 --- a/packages/plugin-http-client/src/rest/BaseEntity.ts +++ b/packages/plugin-http-client/src/rest/BaseEntity.ts @@ -46,6 +46,7 @@ export class BaseEntity { * * @param data, which will be directly * assigned to the entity's fields. + * @param data */ constructor(data: object) { const entityData = this.deserialize(data); @@ -64,6 +65,7 @@ export class BaseEntity { * The default implementation of this method implements a mapping based on * the {@linkcode dataFieldMapping} property's value. * + * @param data */ serialize(data: any = this): any { const mapping = this.#getDataFieldMapping(); @@ -103,7 +105,12 @@ export class BaseEntity { const processedDataFieldMapping: { [key: string]: MapperItem } = {}; Object.entries(dataFieldMapping).forEach(([key, value]) => { - processedDataFieldMapping[key] = BaseMapper.createMapperItem(value, key); + if (value) { + processedDataFieldMapping[key] = BaseMapper.createMapperItem( + value, + key + ); + } }); return processedDataFieldMapping; @@ -122,6 +129,7 @@ export class BaseEntity { * The default implementation of this method implements a mapping based on * the {@linkcode dataFieldMapping} property's value. * + * @param data */ deserialize(data: object): any { const mapping = this.#getDataFieldMapping(); @@ -154,6 +162,7 @@ export class BaseEntity { /** * Creates a clone of this entity with its state patched using the provided * state patch object. + * @param statePatch */ cloneAndPatch(statePatch: any) { const data = this.serialize(); From ef6eb3e479ff3c77fef22181546bb9274db33276 Mon Sep 17 00:00:00 2001 From: PS Date: Fri, 15 Mar 2024 13:45:07 +0100 Subject: [PATCH 2/3] filter entity mapping --- packages/plugin-http-client/src/rest/BaseEntity.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/plugin-http-client/src/rest/BaseEntity.ts b/packages/plugin-http-client/src/rest/BaseEntity.ts index 49379773..ed3e8ac8 100644 --- a/packages/plugin-http-client/src/rest/BaseEntity.ts +++ b/packages/plugin-http-client/src/rest/BaseEntity.ts @@ -46,7 +46,6 @@ export class BaseEntity { * * @param data, which will be directly * assigned to the entity's fields. - * @param data */ constructor(data: object) { const entityData = this.deserialize(data); @@ -65,7 +64,6 @@ export class BaseEntity { * The default implementation of this method implements a mapping based on * the {@linkcode dataFieldMapping} property's value. * - * @param data */ serialize(data: any = this): any { const mapping = this.#getDataFieldMapping(); @@ -129,7 +127,6 @@ export class BaseEntity { * The default implementation of this method implements a mapping based on * the {@linkcode dataFieldMapping} property's value. * - * @param data */ deserialize(data: object): any { const mapping = this.#getDataFieldMapping(); @@ -162,7 +159,6 @@ export class BaseEntity { /** * Creates a clone of this entity with its state patched using the provided * state patch object. - * @param statePatch */ cloneAndPatch(statePatch: any) { const data = this.serialize(); From 600dcabe1aea42c90a48d00466f694f4d4857413 Mon Sep 17 00:00:00 2001 From: PS Date: Fri, 15 Mar 2024 13:50:23 +0100 Subject: [PATCH 3/3] chs --- .changeset/hungry-wombats-sparkle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hungry-wombats-sparkle.md diff --git a/.changeset/hungry-wombats-sparkle.md b/.changeset/hungry-wombats-sparkle.md new file mode 100644 index 00000000..40d59d73 --- /dev/null +++ b/.changeset/hungry-wombats-sparkle.md @@ -0,0 +1,5 @@ +--- +"@ima/plugin-http-client": minor +--- + +Added filter to data field mapping