feat: new util passParams#42
Merged
Merged
Conversation
Deploying feathers-utils with
|
| Latest commit: |
de7792b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://356c3372.feathers-utils.pages.dev |
| Branch Preview URL: | https://feat-new-util-pass-params.feathers-utils.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new utility,
passParams, which provides a declarative and safe way to select or project relevantparamskeys for cache keys, and integrates it into thecachehook to prevent dangerous cache key collisions and wasteful misses. The documentation and tests for thecachehook have been significantly improved to guide users in safely choosing cache-relevant params. Additional improvements include upgrades to development dependencies and workspace configuration.Key changes:
New Utility:
passParamssrc/utils/pass-params/pass-params.util.ts: Implements thepassParamsfunction, allowing declarative selection and projection ofparamskeys using a schema, with support for whitelisting, blacklisting, and custom projection functions. Includes options for dropping or reporting unknown keys to prevent cache key mistakes.src/utils/pass-params/pass-params.util.test.ts) and type tests (src/utils/pass-params/pass-params.util.test-d.ts) to ensure correctness and type safety. [1] [2]passParamsfrom the main utils index for easy consumption.passParamsdescribing its usage and integration points.Integration with Cache Hook
src/hooks/cache/cache.hook.md:passParams.passParamsand explained how to use it in thetransformParamsoption for the cache hook. [1] [2]src/hooks/cache/cache.hook.test.tsto verify thatpassParamscorrectly prevents cross-user cache hits, strips transient keys, and handles function-valued params safely.Dependency and Workspace Updates
@feathers-community/eslint-configto version0.2.0inpackage.jsonand updated the workspace configuration to allow this version. [1] [2]package.jsonfor consistent formatting.These changes make caching safer and more predictable, and provide clear tools and guidance for developers to avoid subtle and dangerous cache bugs.