keyshade-xyz / keyshade

Realtime secret and configuration management tool, with the best in class security and seamless integration support
https://keyshade.xyz
Mozilla Public License 2.0
208 stars 105 forks source link

fix(api): Replace the id with slug in the global-search service #455

Closed PriyobrotoKar closed 1 month ago

PriyobrotoKar commented 1 month ago

User description

Description

Updated the response of the global search API with slug instead of id.

Fixes #426

Dependencies

Mention any dependencies/packages used

Future Improvements

Mention any improvements to be done in future related to any file/feature

Mentions

Mention and tag the people

Screenshots of relevant screens

Add screenshots of relevant screens

Developer's checklist

If changes are made in the code:

Documentation Update


PR Type

Bug fix


Description


Changes walkthrough πŸ“

Relevant files
Bug fix
workspace.service.ts
Replace `id` with `slug` in global search queries               

apps/api/src/workspace/service/workspace.service.ts
  • Replaced id with slug in the selection fields of multiple query
    methods.
  • Updated the global search service to use slug instead of id.
  • +4/-4     

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-free[bot] commented 1 month ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review: 2 πŸ”΅πŸ”΅βšͺβšͺβšͺ
    πŸ§ͺ No relevant tests
    πŸ”’ No security concerns identified
    ⚑ Key issues to review

    API Change
    The PR changes the API response by replacing 'id' with 'slug'. This might break existing client implementations that rely on the 'id' field.
    codiumai-pr-agent-free[bot] commented 1 month ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    βœ… Extract common search logic into a separate method to reduce code duplication ___ **Consider extracting the common search logic into a separate method to reduce code
    duplication across similar queries.** [apps/api/src/workspace/service/workspace.service.ts [439-445]](https://github.com/keyshade-xyz/keyshade/pull/455/files#diff-a92613f23cf2834d52eaedb87c4e8c460d48b6fca8df4ccc968b2a8af19a9c3fR439-R445) ```diff -{ - where: { - id: { in: projectIds }, - OR: [ - { name: { contains: searchTerm, mode: 'insensitive' } }, - { description: { contains: searchTerm, mode: 'insensitive' } } - ] - }, - select: { slug: true, name: true, description: true } -} +this.createSearchQuery(projectIds, searchTerm, ['name', 'description']) ``` `[Suggestion has been applied]`
    Suggestion importance[1-10]: 8 Why: Extracting common logic into a separate method significantly improves maintainability by reducing code duplication and enhancing readability.
    8
    Type safety
    Add a type annotation to the query's select clause for improved type safety ___ **Consider adding a type annotation for the return value of the query to ensure type
    safety and improve code readability.** [apps/api/src/workspace/service/workspace.service.ts [445]](https://github.com/keyshade-xyz/keyshade/pull/455/files#diff-a92613f23cf2834d52eaedb87c4e8c460d48b6fca8df4ccc968b2a8af19a9c3fR445-R445) ```diff -select: { slug: true, name: true, description: true } +select: { slug: true, name: true, description: true } as const ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 5 Why: Adding a type annotation can improve type safety and readability, but the suggestion does not address a critical issue and the improvement is minor.
    5

    πŸ’‘ Need additional feedback ? start a PR chat

    PriyobrotoKar commented 1 month ago

    Oh ok. Like in that global search test, I have to create some dummy resources (projects, environments, secrets and variables) and then make sure that the response array's length for each matches. Right?

    rajdip-b commented 1 month ago

    All of that work is already done! You just need to update the response types both in the test and types file.

    rajdip-b commented 1 month ago

    @PriyobrotoKar can you please apply this suggestion? image

    PriyobrotoKar commented 1 month ago

    Yes sure! Doing it rn.

    rajdip-b commented 3 weeks ago

    :tada: This PR is included in version 2.6.0 :tada:

    The release is available on GitHub release

    Your semantic-release bot :package::rocket: