feat: Add `exposed` property to hook context
The idea is that unless a context object is returned from the call hooks that modify context returning properties other than result (like statusCode and dispatch or other custom ones) may be skipped as those properties will not be used outside of hooks of the call itself.
Possible alternative names: dispatching or public.
Last one of those closings. I will rebase it when asked. Assuming that the proposition is accepted.
Sounds good. Will definitely revisit this for the next version as well.
Rebased.
I'm going to close this one since it has now diverged quite a bit and I think this can also be handled by checking for params.provider.
I'm ok with closing, since the hooks functionality was moved to separate repository and it should be added there, not here.
But no, just checking params.provider is not an option here: As you can see in "Customizing and returning the context" section, you can call function just to get a context.result (in this case context will be internal and will not be exposed to the caller) or you can call it with a context as a last argument and in this case you will receive a full context with all info exposed. Params that are set on a context are irrelevant.
So if you want to provide some info by setting/changing props on context, you may want to skip this (especially if computations are expensivish) in case that context is not exposed since nobody will see the results and they are irrelevant.
I think then we should add it in https://github.com/feathersjs/hooks as a Symbol property you can read via context[RETURNED] (or EXPOSED or PUBLIC). From a Feathers perspective currently, I believe what is set in params.provider indicates if e.g. things context.http should be set.
No real objection to it being a symbol property, thought it will be the only one and it is kinda strange, but ok.
There is nothing stopping people from passing/setting provider param in internal calls. There are use cases for that. So as a library developer I cannot be sure that presence of provider means that dispatch/http or other properties are worth computing.