Skip to content

Sdbv rbac changes - #267

Merged
Shubham4026 merged 14 commits into
release-1.0.1from
sdbv_rbac_changes
May 5, 2025
Merged

Shubham4026 merged 14 commits into
release-1.0.1from
sdbv_rbac_changes

Conversation

@Shubham4026

@Shubham4026 Shubham4026 commented May 5, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Integrated Kafka event publishing for user creation, update, and deletion events.
    • Added support for sending OTP emails during signup and password reset.
    • Introduced a new content filter field for tenants.
    • Added a new Kafka configuration and service for message publishing.
    • Increased the maximum allowed size for bulk cohort member operations from 10 to 1000 items.
    • Enhanced OTP validation to support dynamic OTP lengths based on environment settings.
  • Improvements

    • Tenant roles now have a fallback mechanism if no roles are found for a specific tenant.
    • Custom field validation and mapping logic simplified for consistency.
  • Chores

    • Added kafkajs dependency to the project.

@coderabbitai

coderabbitai Bot commented May 5, 2025 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces Kafka integration across the application, adding a Kafka service, configuration, and module, and wiring Kafka event publishing into user lifecycle operations. The main application and user modules are updated to import the Kafka module. The Postgres user service now publishes Kafka events for user creation, update, and deletion, and includes a new method for sending OTP emails. Tenant and field attribute logic is simplified by removing tenant-specific attribute selection. Validation constraints on cohort member DTOs are relaxed to allow larger arrays. A custom OTP validator is implemented to support dynamic OTP lengths. The Tenant entity gains a new JSON column for content filtering.

Changes

File(s) Change Summary
package.json Added kafkajs dependency (^2.2.4).
src/kafka/kafka.config.ts New Kafka configuration module for toggling and host setup via environment variables.
src/kafka/kafka.module.ts, src/kafka/kafka.service.ts Introduced KafkaModule and KafkaService with producer lifecycle management and message/event publishing.
src/app.module.ts, src/user/user.module.ts, src/adapters/postgres/postgres-module.ts Imported and integrated KafkaModule into application, user, and postgres modules. Updated config loading in app module for Kafka.
src/adapters/postgres/user-adapter.ts Injected KafkaService; publishes Kafka events on user create, update, delete; added OTP email method; removed tenant-specific field attribute selection in validation.
src/adapters/postgres/fields-adapter.ts Removed tenant-specific field attribute selection; now assigns full attribute object directly.
src/cohortMembers/dto/bulkMember-create.dto.ts Increased @ArrayMaxSize on userId, cohortId, removeCohortId from 10 to 1000 in DTO.
src/forms/forms.service.ts Now merges validation property into custom field data in form mapping. Added commented-out debug log.
src/tenant/entities/tenent.entity.ts Added nullable JSON column contentFilter to Tenant entity.
src/tenant/tenant.service.ts Changed role assignment logic to provide fallback and set role to null if no roles found.
src/user/dto/otpVerify.dto.ts Added custom IsValidOtp validator for OTP field with dynamic length from environment.

Sequence Diagram(s)

sequenceDiagram
    participant API_Client
    participant PostgresUserService
    participant KafkaService
    participant Database

    API_Client->>PostgresUserService: createUser/updateUser/deleteUserById
    PostgresUserService->>Database: Perform user operation
    Database-->>PostgresUserService: Result
    PostgresUserService-->>API_Client: Send HTTP response
    Note right of PostgresUserService: After response, asynchronously:
    PostgresUserService->>KafkaService: publishUserEvent(eventType, userData, userId)
    KafkaService->>Kafka: Produce event message (if enabled)
Loading
sequenceDiagram
    participant UserService
    participant KafkaService
    participant Kafka

    UserService->>KafkaService: publishUserEvent(eventType, userData, userId)
    KafkaService->>Kafka: Send message to topic (if enabled)
    Kafka-->>KafkaService: Ack/Error
    KafkaService-->>UserService: Log result
Loading
sequenceDiagram
    participant User
    participant OtpVerifyDTO

    User->>OtpVerifyDTO: Submit OTP
    OtpVerifyDTO->>IsValidOtp: Validate OTP (length from env)
    IsValidOtp-->>OtpVerifyDTO: Pass/Fail
    OtpVerifyDTO-->>User: Validation result
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 106baa4 and ce0f477.

📒 Files selected for processing (14)
  • package.json (1 hunks)
  • src/adapters/postgres/fields-adapter.ts (3 hunks)
  • src/adapters/postgres/postgres-module.ts (1 hunks)
  • src/adapters/postgres/user-adapter.ts (12 hunks)
  • src/app.module.ts (2 hunks)
  • src/cohortMembers/dto/bulkMember-create.dto.ts (3 hunks)
  • src/forms/forms.service.ts (2 hunks)
  • src/kafka/kafka.config.ts (1 hunks)
  • src/kafka/kafka.module.ts (1 hunks)
  • src/kafka/kafka.service.ts (1 hunks)
  • src/tenant/entities/tenent.entity.ts (1 hunks)
  • src/tenant/tenant.service.ts (1 hunks)
  • src/user/dto/otpVerify.dto.ts (1 hunks)
  • src/user/user.module.ts (2 hunks)
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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.

@Shubham4026
Shubham4026 merged commit 3ab7e22 into release-1.0.1 May 5, 2025
@sonarqubecloud

sonarqubecloud Bot commented May 5, 2025

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants