-
Notifications
You must be signed in to change notification settings - Fork 92
Add experimental features methods #1928
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1928 +/- ##
=======================================
Coverage 99.02% 99.03%
=======================================
Files 18 18
Lines 1435 1449 +14
Branches 303 305 +2
=======================================
+ Hits 1421 1435 +14
Misses 14 14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Suite
participant Client as MeiliSearch Client
participant API as Meilisearch API
Test->>Client: updateExperimentalFeatures({ feature: true })
Client->>API: PATCH /experimental-features { feature: true }
API-->>Client: Updated features response
Client-->>Test: Promise resolves with updated features
Test->>Client: getExperimentalFeatures()
Client->>API: GET /experimental-features
API-->>Client: Current features response
Client-->>Test: Promise resolves with features state
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces experimental features methods to the MeiliSearch client along with corresponding tests. The key changes include:
- Adding new methods getExperimentalFeatures and updateExperimentalFeatures in the client.
- Updating tests to replace direct fetch calls with the new methods.
- Adding a new type definition for RuntimeTogglableFeatures.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/search.test.ts | Replaced fetch calls for experimental features with masterClient.updateExperimentalFeatures. |
tests/experimental-features.test.ts | Added new tests verifying the experimental features methods. |
tests/embedders.test.ts | Updated embedders tests to use the new experimental features API. |
tests/documents.test.ts | Converted fetch calls to updateExperimentalFeatures calls in documents tests. |
src/types/index.ts | Exported the new experimental-features types. |
src/types/experimental-features.ts | Introduced the RuntimeTogglableFeatures type. |
src/meilisearch.ts | Implemented getExperimentalFeatures and updateExperimentalFeatures methods. |
Comments suppressed due to low confidence (2)
tests/experimental-features.test.ts:19
- [nitpick] Consider adding tests for edge cases and failure scenarios (e.g., invalid configuration updates) for the experimental features API to improve test coverage.
test(`${ms.updateExperimentalFeatures.name} and ${ms.getExperimentalFeatures.name} methods`, async () => {
tests/documents.test.ts:687
- [nitpick] Consider abstracting the updateExperimentalFeatures call into a common helper to improve consistency and maintainability across tests.
await (await getClient("Master")).updateExperimentalFeatures({
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/types/experimental-features.ts (1)
6-14
: Type definition is complete and well-structuredThe RuntimeTogglableFeatures type properly defines all experimental features as optional boolean or null properties. This allows for partial updates and handling of unset values.
Consider adding a brief description for each feature to provide context on what they enable. This would help developers understand the purpose of each feature without having to reference external documentation.
export type RuntimeTogglableFeatures = { + /** Enables metrics collection */ metrics?: boolean | null; + /** Enables access to logs via API */ logsRoute?: boolean | null; + /** Enables document editing via function */ editDocumentsByFunction?: boolean | null; + /** Enables contains filter feature */ containsFilter?: boolean | null; + /** Enables network features */ network?: boolean | null; + /** Enables route for retrieving task documents */ getTaskDocumentsRoute?: boolean | null; + /** Enables composite embedders functionality */ compositeEmbedders?: boolean | null; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (7)
src/meilisearch.ts
(2 hunks)src/types/experimental-features.ts
(1 hunks)src/types/index.ts
(1 hunks)tests/documents.test.ts
(4 hunks)tests/embedders.test.ts
(2 hunks)tests/experimental-features.test.ts
(1 hunks)tests/search.test.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
tests/documents.test.ts (1)
tests/utils/meilisearch-test-utils.ts (1)
getClient
(258-258)
tests/experimental-features.test.ts (2)
tests/utils/meilisearch-test-utils.ts (2)
getClient
(258-258)assert
(131-134)src/types/experimental-features.ts (1)
RuntimeTogglableFeatures
(6-14)
src/meilisearch.ts (1)
src/types/experimental-features.ts (1)
RuntimeTogglableFeatures
(6-14)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: integration-tests (Node.js 22)
- GitHub Check: integration-tests (Node.js 20)
- GitHub Check: integration-tests (Node.js 18)
🔇 Additional comments (18)
src/types/index.ts (1)
1-1
: Clean addition of new module export.The code adds a new export statement for the
experimental-features.js
module, making theRuntimeTogglableFeatures
type accessible throughout the codebase.tests/search.test.ts (1)
237-242
: Refactored to use the new client method for experimental features.This change replaces a direct HTTP PATCH request with the newly introduced
updateExperimentalFeatures
client method, improving type safety and readability.tests/documents.test.ts (4)
686-690
: Replaced direct API call with client method for feature toggling.This change replaces a direct HTTP PATCH request with the new
updateExperimentalFeatures
client method, improving maintainability and type safety.
761-765
: Consistent use of the new client method for feature toggling.This section consistently applies the same pattern as the previous change, using the new client method to enable the experimental feature.
844-848
: Same pattern applied for the third test case.The refactoring consistently uses the new client method across all relevant test cases.
954-958
: Updated URL construction test to use the client method.The final occurrence of the experimental feature toggle is also updated to use the new client method, maintaining consistency throughout the test file.
tests/embedders.test.ts (2)
9-9
: Updated import to use masterClient directly.The import was modified to include the
masterClient
directly from the test utils, which is a cleaner approach than retrieving it in each test case.
242-244
: Used the masterClient to toggle experimental features.This change replaces a direct HTTP PATCH request with the new
updateExperimentalFeatures
client method, using the importedmasterClient
. This approach is consistent with the pattern used in search.test.ts.tests/experimental-features.test.ts (5)
1-3
: Looks good, imports are appropriateThe imports include all necessary test utilities and type definitions needed for this test file.
5-5
: LGTM - Client initialization is correctly set upUsing the Master client is appropriate for accessing the experimental features endpoints, which typically require admin privileges.
7-17
: Well-structured cleanup with proper type safetyThe afterAll hook ensures proper test cleanup by resetting all experimental features to false. The usage of
satisfies
with a mapped type is an excellent pattern to ensure all feature properties are accounted for.
19-29
: Good test design with dynamic method namingUsing template literals in the test name with
${ms.updateExperimentalFeatures.name}
is a nice touch that makes the test resilient to method name changes. The feature object declaration with mapped types ensures type safety.
30-34
: Test covers both update and get functionalityThis test appropriately verifies both the update response and the subsequent retrieval of features, ensuring that changes are properly persisted and can be retrieved.
src/meilisearch.ts (4)
31-31
: Appropriate type importAdding the RuntimeTogglableFeatures type to the imports list is necessary for the new methods.
459-462
: Clear section header consistent with codebase styleThe section header for experimental features follows the same pattern as other API sections in this file, which is good for consistency.
463-468
: Well-documented getter methodThe getExperimentalFeatures method is properly documented with a link to the official API reference and implements a straightforward GET request to the appropriate endpoint.
470-478
: Well-documented update method with proper typingThe updateExperimentalFeatures method is properly documented with a link to the official API reference. The parameter is correctly typed with RuntimeTogglableFeatures to ensure type safety, and the method returns the updated features object.
src/types/experimental-features.ts (1)
1-5
: Well-documented type with reference linksThe JSDoc includes a link to the official documentation and references the corresponding Rust backend structure, which is helpful for maintainers.
Pull Request
What does this PR do?
getExperimentalFeatures
andupdateExperimentalFeatures
Summary by CodeRabbit
New Features
Tests