-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add Limited Operators Support for Resource Filtering #155
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe changes introduce a new trait, Operatable, to manage and dynamically compute operator rules during REST requests. The trait is integrated into the main Resource class, replacing hardcoded operator lists in filtering logic within SearchRules. Additionally, new test cases validate resource filtering with both valid and invalid operators. New components for a limited model resource—including a dedicated controller, resource class, and API route—have been added to support a specific operator set. These updates enhance the flexibility of operator management and provide dedicated endpoints for limited model operations. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant Controller
participant Resource
participant SearchRules
Client->>API_Route: Send REST filter request
API_Route->>Controller: Route request to LimitedModelController
Controller->>Resource: Invoke getOperators(request)
Resource->>Resource: (Operatable trait) Compute operators
Resource->>SearchRules: Supply operator list for filtering
SearchRules->>Resource: Validate/filter using dynamic operators
Resource->>Controller: Return filtered data
Controller->>Client: Respond with filtered resource list
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code Definitions (1)tests/Feature/Controllers/SearchFilteringOperationsTest.php (3)
🔇 Additional comments (3)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The idea seems nice but this might need to think about what could be given because for "in" and "not in" i'm manually changing the query builder, why did you have this feature in mind ? This might also be the time to refactor "PerformSearch" and put Objects to handle these but i'll do it on my side |
I preserved the existing logic for operators like I added the PR to handle the If you plan to refactor Let me know if you need any changes. |
Description
This PR adds the ability to limit available filtering operators in a REST resource. This allows restricting search operations to a specific set of operators for security or performance reasons.
Main Changes
$operators
property in theResource
classSearchRequest
Technical Details
$operators
property is defined as an array of allowed operators$operators
is empty, all operators are allowed (default behavior)SearchRequest
before search executionTests
Added two new tests in
SearchFilteringOperationsTest.php
:test_getting_a_list_of_resources_filtered_by_limited_operators()
test_getting_a_list_of_resources_filtered_by_limited_operators_with_invalid_operator()
API Impact
This modification is backward compatible because:
Usage Example
resolve #154
Summary by CodeRabbit
New Features
Bug Fixes
Tests