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

refactor: Initial implementation for dependency injection #17010

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

zomars
Copy link
Member

@zomars zomars commented Oct 9, 2024

What does this PR do?

  • Implements a Dependency Injection (DI) pattern for Cal.com
  • Adds a new @calcom/di package for managing dependencies
  • Refactors the feature flags system to use the new DI pattern
  • Updates the checkIfUserHasFeature functionality to use the new architecture

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Ensure all existing feature flag checks still work correctly throughout the application.
  2. Test the checkIfUserHasFeature function with various user IDs and feature slugs.
  3. Verify that the DI container is properly initialized in different environments (development, test, production).
  4. Run the new tests in check-if-user-has-feature.controller.test.ts and check-if-user-has-feature.use-case.test.ts.

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings

Copy link

vercel bot commented Oct 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Oct 9, 2024 4:23pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Oct 9, 2024 4:23pm

@@ -1,5 +1,3 @@
export interface IFeaturesRepository {
checkIfUserHasFeature(userId: number, slug: string): Promise<boolean>;
checkIfTeamHasFeature(teamId: number, slug: string): Promise<boolean>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified usage and cleaned up unused methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only foundation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants