Skip to content

Improve various types #1919

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

flevi29
Copy link
Collaborator

@flevi29 flevi29 commented Apr 9, 2025

Pull Request

What does this PR do?

  • improved and/or documented various types and methods

Migration

  • type Health -> HealthResponse
  • type Version -> VersionResponse
- import { ErrorStatusCode } from "meilisearch";
- ErrorStatusCode.INVALID_API_KEY;
+ import type { Code } from "meilisearch";
+ const myErrorCode: Code = "invalid_api_key";

@flevi29 flevi29 mentioned this pull request Apr 9, 2025
8 tasks
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.15%. Comparing base (e11dfdb) to head (cc59dee).

Files with missing lines Patch % Lines
src/meilisearch.ts 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1919      +/-   ##
==========================================
+ Coverage   99.02%   99.15%   +0.13%     
==========================================
  Files          18       18              
  Lines        1435     1301     -134     
  Branches      303      303              
==========================================
- Hits         1421     1290     -131     
+ Misses         14       11       -3     

☔ 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 added the breaking-change The related changes are breaking for the users label Apr 9, 2025
@flevi29 flevi29 marked this pull request as ready for review April 9, 2025 20:36
@Strift Strift requested a review from Copilot April 21, 2025 06:20
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 improves and documents various types and methods, with a focus on renaming types (e.g. Health to HealthResponse and Version to VersionResponse) and replacing inline error code references with string literals.

  • Migrates error codes from ErrorStatusCode enums to inline string literals for improved type safety and clarity
  • Updates documentation comments in source files and refines type definitions
  • Adjusts tests accordingly to match the new error code format

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.

File Description
tests/* Replaces ErrorStatusCode with explicit string literals
src/types/* and src/errors/* Updates type names and documentation per migration requirements
src/meilisearch.ts and src/indexes.ts Migrates API responses and error handling to new type definitions
Comments suppressed due to low confidence (2)

tests/get_search.test.ts:551

  • [nitpick] Consider centralizing error code string literals into a shared constant or module rather than using inline strings throughout tests. This can help reduce duplication, avoid potential typos, and simplify future updates.
).rejects.toHaveProperty("cause.code", "index_not_found");

src/meilisearch.ts:187

  • [nitpick] Consider centralizing the error code string literals (e.g., "index_not_found") into a dedicated constants module to ensure consistency and maintainability across both production and test code.
if ((e as MeiliSearchApiError)?.cause?.code === "index_not_found") {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change The related changes are breaking for the users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant