Skip to content
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

feat(schema, api-client): Migrate workspace-role schemas and types to @keyshade/schema #568

Merged
merged 3 commits into from
Dec 1, 2024

Conversation

muntaxir4
Copy link
Contributor

@muntaxir4 muntaxir4 commented Nov 29, 2024

User description

Description

@keyshade/schema

  • Add schemas and types for workspace-role.
  • Add tests for workspace-role schemas.
  • Export workpsace-role schemas from index and its types from index.types .

@keyshade/api-client

  • Remove existing workspace-role.types.d.ts.
  • Change imports for workpsace-role types to @keyshade/schema.

Also fix lint error by upgrading eslint-config-turbo to 2.3.1

Related to #519

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

PR Type

enhancement, tests, other


Description

  • Migrated workspace-role schemas and types to @keyshade/schema.
  • Added comprehensive tests for workspace-role schemas, covering both valid and invalid scenarios.
  • Removed old workspace-role.types.d.ts and updated import paths to use new types from @keyshade/schema.
  • Updated eslint-config-turbo and turbo package versions, and removed @swc/helpers dependency.
  • Adjusted tsconfig base path for api-client.

Changes walkthrough 📝

Relevant files
Tests
2 files
workspace-role.spec.ts
Add tests for workspace role schemas and validations         

packages/schema/tests/workspace-role.spec.ts

  • Added comprehensive tests for various workspace role schemas.
  • Included validation tests for request and response schemas.
  • Ensured tests cover both valid and invalid scenarios.
  • +453/-15
    workspace-role.spec.ts
    Update workspace role type imports in tests                           

    packages/api-client/tests/workspace-role.spec.ts

  • Updated import paths for workspace role types.
  • Switched to using types from @keyshade/schema.
  • +1/-1     
    Enhancement
    4 files
    index.ts
    Define workspace role schemas using zod                                   

    packages/schema/src/workspace-role/index.ts

  • Introduced multiple schemas for workspace role operations.
  • Defined request and response schemas for CRUD operations.
  • Utilized zod for schema definitions and validations.
  • +77/-0   
    index.types.ts
    Add TypeScript types for workspace role schemas                   

    packages/schema/src/workspace-role/index.types.ts

  • Created TypeScript types inferred from workspace role schemas.
  • Exported types for use in other modules.
  • +67/-0   
    index.types.ts
    Update exports for workspace role types                                   

    packages/schema/src/index.types.ts

  • Removed old workspace role schema types.
  • Exported new workspace role types from updated schema.
  • +1/-9     
    workspace-role.ts
    Update imports for workspace role types in controller       

    packages/api-client/src/controllers/workspace-role.ts

  • Changed import paths for workspace role types.
  • Utilized types from @keyshade/schema.
  • +1/-1     
    Dependencies
    2 files
    package.json
    Update eslint-config-turbo version in package.json             

    packages/eslint-config-custom/package.json

  • Updated eslint-config-turbo dependency version.
  • Ensured package.json formatting consistency.
  • +10/-10 
    pnpm-lock.yaml
    Update package versions and remove `@swc/helpers` dependency

    pnpm-lock.yaml

  • Removed @swc/helpers from various package versions.
  • Updated turbo package versions from 1.13.4 to 2.3.3.
  • Adjusted dependencies to reflect the removal of @swc/helpers.
  • Updated eslint-config-turbo and eslint-plugin-turbo versions.
  • +140/-278
    Configuration changes
    1 files
    tsconfig.json
    Adjust tsconfig base path for api-client                                 

    packages/api-client/tsconfig.json

    • Modified the path for extending base tsconfig.
    +1/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @muntaxir4 muntaxir4 changed the title feat(schema, api-client): Migrate workpsace-role schemas and types to @keyshade/schema feat(schema, api-client): Migrate workspace-role schemas and types to @keyshade/schema Nov 29, 2024
    @codiumai-pr-agent-free codiumai-pr-agent-free bot changed the title feat(schema, api-client): Migrate workspace-role schemas and types to @keyshade/schema feat(schema, api-client): Migrate workpsace-role schemas and types to @keyshade/schema Nov 29, 2024
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    519 - Fully compliant

    Compliant requirements:

    • Created workspace-role folder in schema with proper structure
    • Added zod schemas in workspace-role.ts
    • Added type exports in workspace-role.types.ts
    • Updated api-client imports to use schema types
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Smell
    The WorkspaceRoleSchema has nested object structures that could be extracted into separate schemas for better reusability and maintainability

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Nov 29, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Add hex color code format validation to prevent invalid color values

    Add validation for color code format to ensure it's a valid hex color code.
    Currently the schema accepts any string as a color code.

    packages/schema/src/workspace-role/index.ts [12]

    -colorCode: z.string().nullable(),
    +colorCode: z.string().regex(/^#[0-9A-Fa-f]{6}$/).nullable(),
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding regex validation for hex color codes is important to prevent invalid color values that could cause UI issues or data inconsistency. The current implementation accepts any string format.

    8
    Add length constraints to text fields to ensure data quality

    Add validation for minimum and maximum length constraints on name and description
    fields to prevent overly long or empty values.

    packages/schema/src/workspace-role/index.ts [9-11]

    -name: z.string(),
    -description: z.string().nullable(),
    +name: z.string().min(1).max(100),
    +description: z.string().max(500).nullable(),
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding length constraints to name and description fields is valuable for preventing data quality issues and potential UI/storage problems from overly long or empty values.

    7
    Possible issue
    ✅ Fix incorrect path resolution for extending base TypeScript configuration

    The path to the base tsconfig should be relative to node_modules since tsconfig is a
    workspace package. Change the extends path to use the package name.

    packages/api-client/tsconfig.json [2]

     {
    -  "extends": "tsconfig/base.json",
    +  "extends": "../tsconfig/base.json",
       "compilerOptions": {
         "baseUrl": ".",
     }

    [Suggestion has been applied]

    Suggestion importance[1-10]: 8

    Why: The suggestion correctly identifies that using "tsconfig/base.json" will fail since TypeScript resolves paths relative to node_modules for workspace packages. Using "../tsconfig/base.json" ensures proper path resolution.

    8

    💡 Need additional feedback ? start a PR chat

    @muntaxir4 muntaxir4 requested a review from rajdip-b November 29, 2024 21:07
    @muntaxir4 muntaxir4 changed the title feat(schema, api-client): Migrate workpsace-role schemas and types to @keyshade/schema feat(schema, api-client): Migrate workspace-role schemas and types to @keyshade/schema Nov 30, 2024
    @rajdip-b rajdip-b merged commit 9efbf2d into keyshade-xyz:develop Dec 1, 2024
    7 checks passed
    @muntaxir4 muntaxir4 deleted the workspaceRole-schemas branch December 3, 2024 11:16
    rajdip-b pushed a commit that referenced this pull request Dec 3, 2024
    ## [2.8.0](v2.7.0...v2.8.0) (2024-12-03)
    
    ### 🚀 Features
    
    * **api:** Add workspace removal notification email template ([#476](#476)) ([40b754f](40b754f))
    * **cli:** Store `metrics_enabled` key in profile config ([#536](#536)) ([9283b22](9283b22))
    * **package, api, cli:** Add api-key schemas and types; Fix schema inconsistencies; Minor fix for CLI build errors  ([#557](#557)) ([126d024](126d024))
    * **platform:** Added screen for CREATE NEW PROJECT ([#540](#540)) ([b644633](b644633))
    * **platform:** Updated the empty state of dashboard ([#522](#522)) ([28739d9](28739d9))
    * **schema, api-client:** Migrate auth types to @keyshade/schema ([#532](#532)) ([d880098](d880098))
    * **schema, api-client:** Migrate event schemas and types to @keyshade/schema ([#546](#546)) ([a3267de](a3267de))
    * **schema, api-client:** Migrate integration schemas and types to @keyshade/schema ([#547](#547)) ([08868c3](08868c3))
    * **schema, api-client:** Migrate project schemas and environment schemas along with their types to @keyshade/schema ([#538](#538)) ([c468af0](c468af0))
    * **schema, api-client:** Migrate [secure] types and schemas to @keyshade/schema ([#539](#539)) ([bc3100b](bc3100b))
    * **schema, api-client:** Migrate user types and schemas to @keyshade/schema ([#535](#535)) ([c24695e](c24695e))
    * **schema, api-client:** Migrate variable schemas and types to @keyshade/schema ([#545](#545)) ([0ee8f9a](0ee8f9a))
    * **schema, api-client:** Migrate workspace-membership schemas and types to @keyshade/schema ([#569](#569)) ([4398969](4398969))
    * **schema, api-client:** Migrate workspace-role schemas and types to @keyshade/schema ([#568](#568)) ([9efbf2d](9efbf2d))
    * **schema:** Add User type inference from UserSchema ([#574](#574)) ([84c1db5](84c1db5))
    
    ### 🐛 Bug Fixes
    
    * **api:** Incorrect oauth redirect url ([58d96e5](58d96e5))
    * **platform:** Resolve loading SVG blocking input field interaction ([#571](#571)) ([30f4f65](30f4f65))
    
    ### 📚 Documentation
    
    * Add pictures to Bruno setup ([#541](#541)) ([210c0fd](210c0fd))
    * Migrate to Bruno ([#525](#525)) ([1793d92](1793d92))
    
    ### 🔧 Miscellaneous Chores
    
    * **ci:** Add script to validate schema package ([59e4280](59e4280))
    * Fixed codecov client version ([a998ae4](a998ae4))
    * **package:** Fixed tests and did housekeeping ([#544](#544)) ([40008e3](40008e3))
    * Update test coverage settings ([5b27e32](5b27e32))
    * Update Turbo to 2.3.1 ([#564](#564)) ([3a63823](3a63823))
    * **web:** Update dockerfile ([10d9cc5](10d9cc5))
    
    ### 🔨 Code Refactoring
    
    * **api-client, schema:** Add workspace's schemas and types in @keyshade/schema ([#520](#520)) ([7c8ee5d](7c8ee5d))
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants