Skip to content

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

Merged
merged 3 commits into from
May 19, 2025

Conversation

flevi29
Copy link
Collaborator

@flevi29 flevi29 commented Apr 25, 2025

Pull Request

What does this PR do?

  • adds experimental features methods getExperimentalFeatures and updateExperimentalFeatures
  • adds tests for these

Summary by CodeRabbit

  • New Features

    • Added support for retrieving and updating experimental features directly through the client.
    • Introduced a new type representing available experimental features that can be toggled at runtime.
  • Tests

    • Added dedicated tests to verify toggling of experimental features.
    • Refactored existing tests to use the new client methods for enabling experimental features, improving consistency and maintainability.

@flevi29 flevi29 added the enhancement New feature or request label Apr 25, 2025
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.03%. Comparing base (438da05) to head (e06ae73).
Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@flevi29 flevi29 mentioned this pull request Apr 25, 2025
@flevi29 flevi29 mentioned this pull request May 14, 2025
Copy link

coderabbitai bot commented May 15, 2025

Walkthrough

The changes introduce a new RuntimeTogglableFeatures type and add two experimental feature management methods to the MeiliSearch client. Existing tests are updated to use these new client methods instead of direct HTTP requests, and a dedicated test file is added to verify experimental feature toggling behavior.

Changes

File(s) Change Summary
src/meilisearch.ts Added getExperimentalFeatures and updateExperimentalFeatures async methods to manage runtime experimental features.
src/types/experimental-features.ts Introduced the RuntimeTogglableFeatures type with optional boolean/null properties for various experimental features.
src/types/index.ts Re-exported all exports from experimental-features.js for broader availability of the new type.
tests/documents.test.ts, tests/embedders.test.ts, tests/search.test.ts Refactored tests to use updateExperimentalFeatures client method instead of manual HTTP PATCH requests for toggling features.
tests/experimental-features.test.ts Added new tests for updateExperimentalFeatures and getExperimentalFeatures methods, including state reset after tests.

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
Loading

Poem

In the burrows of code, new toggles appear,
With features experimental, the future draws near.
No more PATCHing by paw, just call and you’ll see—
A client’s sweet method, as easy as can be!
Hopping through tests with a jubilant cheer,
The rabbit approves, for new features are here!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit 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.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit 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 Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Strift Strift requested a review from Copilot May 15, 2025 06:38
Copy link

@Copilot Copilot AI left a 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({

Copy link

@coderabbitai coderabbitai bot left a 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-structured

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between 438da05 and e06ae73.

📒 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 the RuntimeTogglableFeatures 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 imported masterClient. This approach is consistent with the pattern used in search.test.ts.

tests/experimental-features.test.ts (5)

1-3: Looks good, imports are appropriate

The imports include all necessary test utilities and type definitions needed for this test file.


5-5: LGTM - Client initialization is correctly set up

Using the Master client is appropriate for accessing the experimental features endpoints, which typically require admin privileges.


7-17: Well-structured cleanup with proper type safety

The 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 naming

Using 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 functionality

This 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 import

Adding the RuntimeTogglableFeatures type to the imports list is necessary for the new methods.


459-462: Clear section header consistent with codebase style

The 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 method

The 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 typing

The 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 links

The JSDoc includes a link to the official documentation and references the corresponding Rust backend structure, which is helpful for maintainers.

@flevi29 flevi29 added this pull request to the merge queue May 19, 2025
Merged via the queue into meilisearch:main with commit 77505c0 May 19, 2025
8 checks passed
@flevi29 flevi29 deleted the experimental-features branch May 19, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants