Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support package visibility for @BrowserCallable services #2843

Open
peholmst opened this issue Oct 17, 2024 · 5 comments
Open

Support package visibility for @BrowserCallable services #2843

peholmst opened this issue Oct 17, 2024 · 5 comments
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@peholmst
Copy link
Member

Describe your motivation

The visibility of an annotated class should not affect whether the annotation is applied or ignored. Furthermore, Spring REST controllers can be package-private. Since @BrowserCallable services is our alternative to them, they should behave in a similar manner.

Describe the solution you'd like

Make it possible to use @BrowserCallable on package-private services. When put on a class, this would expose all public methods of the class.

Consider making it possible to add the annotation to individual methods as well. This would make it possible to expose methods with other visibilities. If the method is annotated, it can be called from the browser, regardless of whether it is public, package-private, protected, or even private.

For the DTO:s, consider relying on Jackson annotations. What ends up in the JSON would end up in the generated TypeScript data type.

Describe alternatives you've considered

No response

Additional context

Please see this forum discussion: https://vaadin.com/forum/t/thoughts-on-non-public-browsercallable-services/167535

@peholmst peholmst added enhancement New feature or request hilla Issues related to Hilla labels Oct 17, 2024
@Legioth
Copy link
Member

Legioth commented Oct 17, 2024

I would see it as as separate feature to annotate individual methods. That's useful when you have a service that is used by different parts of the application (e.g. also a Flow UI) and only want to make some specific parts of it available to the Hilla client. Currently, you have to create a separate class for to make that possible.

@cromoteca
Copy link
Contributor

For the DTO:s, consider relying on Jackson annotations. What ends up in the JSON would end up in the generated TypeScript data type.

Isn't that already the case? We ask Jackson which properties a class has.

@Legioth
Copy link
Member

Legioth commented Oct 17, 2024

I guess the point is that we shouldn't try to change Jackson to also consider package-private members by default but instead just stick to the existing defaults there.

@cromoteca
Copy link
Contributor

This is also related to #2616, since loading services from Spring would automatically delegate to Spring which services are available.

@platosha
Copy link
Contributor

platosha commented Oct 29, 2024

Would make sense to do this together with or after #2616.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

4 participants