class-transformer icon indicating copy to clipboard operation
class-transformer copied to clipboard

feat: exclude with groups and versions (closes typestack/class-transformer#202)

Open lucas-labs opened this issue 4 years ago • 10 comments
trafficstars

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Closes typestack/class-transformer#202 Right now using groups and version is only posible with @Expose decorator.

Issue Number: typestack/class-transformer#202

What is the new behavior?

It allows to use groups and version with the @Exclude decorator aswell. Now @Exclude and @Expose share a more similar API.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

lucas-labs avatar Nov 16 '21 21:11 lucas-labs

Using the opportunity, what is the plan with nestjs/class-transformer fork? Is it planned to be actively maintained within NestJS ecosystem (at the very least accepting PRs and making new released), or forked just for convenience? I've been struggling with the issue this PR solves as well as a few others for years, but with typestack ecosystem being unmaintained for years now, there was little chance of having PRs merged.

Aareksio avatar Nov 16 '21 21:11 Aareksio

Thanks for your contribution.

We decided to fork the original package to keep pushing security improvements, upgrading dependencies, and addressing potential vulnerabilities. We will also consider merging performance improvements and new features in case they could significantly improve the DX & make things way simpler. However, we won't be merging minor enhancements and improvements, nor extra decorators/things that are already doable with this package, especially if they introduce breaking changes (as we plan to introduce as few API breaking changes as we can).

This one doesn't introduce a breaking change + it looks like a useful improvement so we can consider merging it in.

kamilmysliwiec avatar Nov 17 '21 08:11 kamilmysliwiec

@kamilmysliwiec Do you think this can be merged soon?

oktapodia avatar Feb 17 '22 14:02 oktapodia

Watching this with care! Would be very useful!

stevenolay avatar Mar 04 '22 13:03 stevenolay

A great feature, surprisingly missing from the original package, thanks!

@lucas-labs and @Aareksio what's the reasoning behind pointing this PR to the https://github.com/@nestjs/class-transformer fork instead of the main package https://github.com/typestack/class-transformer? It seem like this fork in only kept for the nest team convenience and not intended to be used outside (starting with the readme still instructing users to download the original package).

I just happen to fall on a use case for this PR and would love to be able to remove the workaround. Any chance to retarget the main repo instead of this fork?

rgoupil avatar Mar 23 '22 14:03 rgoupil

Hi @rgoupil, I created this PR on this fork because the original project was no longer being actively maintained. When I created this PR the project seemed completly abandonded, last release had been like a year before that. Now they are releasing some updates, but from what I see, they are only merging security fixes, not new features or bugfixes.

lucas-labs avatar Mar 23 '22 19:03 lucas-labs

Oh, indeed, I hadn't noticed 😞 @kamilmysliwiec, I noticed you updated the README 3h hour ago, following the mention of the outdated installation instructions, maybe the NestJS team could be interested in this PR 😃 ?

rgoupil avatar Mar 24 '22 10:03 rgoupil

This would be a really useful feature for complex projects where base types and entities are used in multiple controllers in very different security contexts - and where Exclude() on the total entity isn't possible for legacy reasons. Is there any reason @kamilmysliwiec this can't be merged and versioned for us?

acuthbert avatar Aug 02 '22 09:08 acuthbert

This is a very useful feature. I just ran into a use case right now where I needed to exclude certain properties only from logs.

Any chance to get this merged?

MihaiVoinea avatar Oct 06 '22 17:10 MihaiVoinea

Are there any plans according this PR? I would love to see groups property in @Exclude decorator

dawid-jazdzewski-BO avatar Oct 31 '23 15:10 dawid-jazdzewski-BO