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): Add workspace invitation schema #612

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

Souvik9205
Copy link
Contributor

@Souvik9205 Souvik9205 commented Jan 9, 2025

User description

Description

Schema and relevant tests for Workspace's invitation lists

Fixes #552


PR Type

Enhancement, Tests


Description

  • Added schemas for GetInvitationRequest and GetInvitationResponse.

  • Defined types for the new schemas in index.types.ts.

  • Implemented validation tests for the new schemas.

  • Enhanced workspace schema functionality with invitation-related features.


Changes walkthrough 📝

Relevant files
Enhancement
index.ts
Added schemas for workspace invitation handling                   

packages/schema/src/workspace/index.ts

  • Added GetInvitationRequestSchema and GetInvitationResponseSchema.
  • Defined WorkspaceInvitationDetailsSchema for invitation details.
  • Integrated schemas with existing pagination structures.
  • +24/-0   
    index.types.ts
    Defined types for new invitation schemas                                 

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

  • Added types for GetInvitationRequestSchema and
    GetInvitationResponseSchema.
  • Extended type definitions for workspace invitation handling.
  • +7/-1     
    Tests
    workspace.spec.ts
    Added tests for workspace invitation schemas                         

    packages/schema/tests/workspace.spec.ts

  • Added validation tests for GetInvitationRequestSchema.
  • Added validation tests for GetInvitationResponseSchema.
  • Included edge case tests for invalid inputs.
  • +68/-1   

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

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    552 - Fully compliant

    Compliant requirements:

    • Add GetWorkspaceInvitationsRequest schema (implemented as GetInvitationRequestSchema)
    • Add GetWorkspaceInvitationsResponse schema (implemented as GetInvitationResponseSchema)
    • Add inferred types for the schemas
    • Add relevant tests for the schemas
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Schema Naming

    Schema names differ from ticket requirements (GetInvitation vs GetWorkspaceInvitations). Consider aligning names for consistency.

    export const GetInvitationRequestSchema = PageRequestSchema

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Jan 9, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Enforce strict ISO 8601 datetime format validation for timestamp fields

    Add validation for the datetime string format to ensure it matches ISO 8601. The
    current z.string().datetime() allows any string that can be parsed as a date.

    packages/schema/src/workspace/index.ts [170]

    -invitedOn: z.string().datetime()
    +invitedOn: z.string().datetime().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:?\d{2})$/)
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding strict regex validation for ISO 8601 format is crucial for data consistency and prevents potential parsing issues. The test case shows this format is already in use, making this validation important for maintaining data integrity.

    8
    ✅ Validate hex color code format for color-related fields

    Add validation for the color code format to ensure it's a valid hex color code when
    provided.

    packages/schema/src/workspace/index.ts [166]

    -colorCode: z.string().nullable()
    +colorCode: z.string().regex(/^#[0-9A-Fa-f]{6}$/).nullable()

    [Suggestion has been applied]

    Suggestion importance[1-10]: 6

    Why: The regex validation ensures that color codes follow the standard hex format, preventing invalid color values. This is validated by the test case which uses '#FFFFFF', confirming the hex format is expected.

    6
    Security
    Enforce minimum length requirements for identifier fields

    Add minimum length validation for the workspace ID to ensure it meets security
    requirements.

    packages/schema/src/workspace/index.ts [157]

    -id: z.string(),
    +id: z.string().min(8),
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding minimum length validation for IDs is a good security practice to prevent weak or malformed identifiers. This is particularly important as the ID is part of the workspace object which appears to be a core entity.

    7

    @Souvik9205
    Copy link
    Contributor Author

    @rajdip-b please review WorkspaceInvitationDetailsSchema and if there is any more type error can you please suggest that? I already went through https://github.com/keyshade-xyz/keyshade/pull/586/files#diff-a92613f23cf2834d52eaedb87c4e8c460d48b6fca8df4ccc968b2a8af19a9c3fR432-R450

    packages/schema/src/workspace/index.ts Outdated Show resolved Hide resolved
    packages/schema/src/workspace/index.ts Show resolved Hide resolved
    @keyshade-xyz keyshade-xyz deleted a comment from codiumai-pr-agent-free bot Jan 9, 2025
    @rajdip-b rajdip-b merged commit 1a5721b into keyshade-xyz:develop Jan 9, 2025
    5 checks passed
    @rajdip-b
    Copy link
    Member

    rajdip-b commented Jan 9, 2025

    @Souvik9205 could you please ping me over discord? Here's my ID: _the_heisenberg.

    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.

    SCHEMA: Add "Get All Workspace Invitations" request and response types
    2 participants