-
Notifications
You must be signed in to change notification settings - Fork 61
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(auth-api-lib): add support for delegation types to api-scopes #14887
feat(auth-api-lib): add support for delegation types to api-scopes #14887
Conversation
WalkthroughThe updates primarily enhance the handling of delegation types across various modules, focusing on the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (10)
- apps/services/auth/admin-api/src/app/v2/scopes/test/me-scopes.spec.ts (13 hunks)
- libs/auth-api-lib/src/index.ts (1 hunks)
- libs/auth-api-lib/src/lib/clients/clients.module.ts (2 hunks)
- libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts (2 hunks)
- libs/auth-api-lib/src/lib/resources/admin/admin-scope.service.ts (10 hunks)
- libs/auth-api-lib/src/lib/resources/admin/dto/admin-create-scope.dto.ts (1 hunks)
- libs/auth-api-lib/src/lib/resources/admin/dto/admin-patch-scope.dto.ts (1 hunks)
- libs/auth-api-lib/src/lib/resources/dto/base/api-scope-base.dto.ts (2 hunks)
- libs/auth-api-lib/src/lib/resources/models/api-scope-delegation-type.model.ts (2 hunks)
- libs/auth-api-lib/src/lib/resources/models/api-scope.model.ts (4 hunks)
Files skipped from review due to trivial changes (2)
- libs/auth-api-lib/src/index.ts
- libs/auth-api-lib/src/lib/resources/models/api-scope-delegation-type.model.ts
Additional Context Used
Path-based Instructions (8)
libs/auth-api-lib/src/lib/resources/admin/dto/admin-create-scope.dto.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/resources/dto/base/api-scope-base.dto.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/resources/admin/dto/admin-patch-scope.dto.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/clients/clients.module.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/resources/models/api-scope.model.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/auth-api-lib/src/lib/resources/admin/admin-scope.service.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
apps/services/auth/admin-api/src/app/v2/scopes/test/me-scopes.spec.ts (2)
Pattern
apps/services/**/*
: "Confirm that the code adheres to the following:
- NestJS architecture, including modules, services, and controllers.
- Dependency injection patterns and service encapsulation.
- Integration and unit testing coverage and practices."
Pattern
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (18)
libs/auth-api-lib/src/lib/resources/admin/dto/admin-create-scope.dto.ts (2)
6-8
: The inheritance and property omission are correctly implemented for the creation DTO.
15-21
: ThesupportedDelegationTypes
property is well-defined with appropriate validation and documentation.libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts (1)
67-69
: The association betweenDelegationTypeModel
andApiScope
is correctly implemented for a many-to-many relationship.libs/auth-api-lib/src/lib/resources/dto/base/api-scope-base.dto.ts (1)
111-117
: ThesupportedDelegationTypes
property is correctly implemented with appropriate validation and documentation.libs/auth-api-lib/src/lib/resources/admin/dto/admin-patch-scope.dto.ts (1)
88-102
: The propertiesaddedDelegationTypes
andremovedDelegationTypes
are correctly implemented with appropriate validation and documentation.libs/auth-api-lib/src/lib/clients/clients.module.ts (1)
Line range hint
25-45
: The import and inclusion ofApiScopeDelegationType
in the module's imports are correctly implemented.libs/auth-api-lib/src/lib/resources/models/api-scope.model.ts (1)
260-271
: The associations forApiScopeDelegationType
andDelegationTypeModel
are correctly implemented, facilitating the intended many-to-many relationships.libs/auth-api-lib/src/lib/resources/admin/admin-scope.service.ts (7)
8-8
: Ensure proper usage of SequelizeOp
andTransaction
imports.These imports are correctly used for database operations within transactions, which is a best practice for ensuring data integrity.
42-45
: Check for correct dependency injection of new models.The models
ApiScopeDelegationType
andDelegationTypeModel
are correctly injected, which allows for their methods to be used within the service.
57-59
: Ensure that the newsupportedDelegationTypes
association is correctly configured.The inclusion of
supportedDelegationTypes
in theinclude
option of Sequelize queries is correct and ensures that delegation types are fetched along with API scopes.Also applies to: 94-96
Line range hint
162-195
: Review transaction handling and delegation type management increateScope
.The transaction ensures atomicity of operations, which is crucial when creating a scope and its associated delegation types. The method
addScopeDelegationTypes
is correctly called within the transaction.
Line range hint
336-485
: Examine updates inupdateScope
method for handling delegation types.The updates to handle delegation types within the
updateScope
method are correctly implemented. The methodaddScopeDelegationTypes
andremoveScopeDelegationTypes
are used to manage the delegation types, ensuring that changes are made atomically within a transaction.
395-487
: Check logic inaddScopeDelegationTypes
andremoveScopeDelegationTypes
methods.The logic to add and remove delegation types based on boolean flags and explicit types is correctly implemented. This allows for flexible management of delegation types based on different conditions.
28-30
: Verify correct integration of new models for delegation types.Verification successful
The new models
ApiScopeDelegationType
andDelegationTypeModel
are correctly integrated and used throughout the system. The search results show multiple instances where these models are imported and utilized in various files, confirming their integration.
libs/auth-api-lib/src/lib/resources/models/api-scope-delegation-type.model.ts
libs/auth-api-lib/src/lib/resources/models/api-scope.model.ts
libs/auth-api-lib/src/lib/resources/admin/admin-scope.service.ts
libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts
libs/auth-api-lib/src/lib/clients/clients.module.ts
libs/auth-api-lib/src/lib/clients/models/client.model.ts
apps/services/auth/admin-api/src/app/v2/scopes/test/me-scopes.spec.ts
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new models are correctly integrated and used throughout the system. # Test: Search for usage of `ApiScopeDelegationType` and `DelegationTypeModel`. rg --type typescript $'ApiScopeDelegationType|DelegationTypeModel'Length of output: 102
Script:
#!/bin/bash # Description: Verify that the new models are correctly integrated and used throughout the system. # Test: Search for usage of `ApiScopeDelegationType` and `DelegationTypeModel`. rg --type ts $'ApiScopeDelegationType|DelegationTypeModel'Length of output: 7687
apps/services/auth/admin-api/src/app/v2/scopes/test/me-scopes.spec.ts (4)
12-19
: Confirm correct imports for new delegation types in test cases.The imports for
ApiScopeDelegationType
,AdminPatchScopeDto
,AuthDelegationProvider
, andAuthDelegationType
are correctly added to support the new test cases involving delegation types.
113-134
: Review the setup of delegation types in test data creation.The setup for creating delegation types in the test data is correctly implemented, ensuring that various delegation types are available for the test cases.
Line range hint
271-308
: Examine the handling ofsupportedDelegationTypes
in test cases for creating scopes.The test cases correctly handle the
supportedDelegationTypes
field when creating scopes, ensuring that the field is tested for both presence and absence of delegation types.
Line range hint
430-487
: Ensure correct handling ofsupportedDelegationTypes
in patch test cases.The patch test cases correctly manipulate the
supportedDelegationTypes
field, testing both the addition and removal of delegation types, which aligns with the new functionality introduced in the API.
Datadog ReportAll test runs ✅ 13 Total Test Services: 0 Failed, 13 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (6)
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14887 +/- ##
==========================================
- Coverage 37.03% 37.02% -0.01%
==========================================
Files 6331 6331
Lines 129165 129155 -10
Branches 36869 36869
==========================================
- Hits 47831 47823 -8
+ Misses 81334 81332 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- libs/services/auth/testing/src/fixtures/fixture-factory.ts (1 hunks)
Additional Context Used
Path-based Instructions (1)
libs/services/auth/testing/src/fixtures/fixture-factory.ts (2)
Pattern
libs/services/**/*
: "Confirm that the code adheres to the following:
- Shared services and modules that can be utilized across NestJS apps.
- Proper implementation of NestJS providers, including custom providers.
- Adherence to NestJS module encapsulation and isolation principles."
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments, otherwise LGTM!
libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts (2 hunks)
- libs/services/auth/testing/src/fixtures/fixture-factory.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- libs/auth-api-lib/src/lib/delegations/models/delegation-type.model.ts
- libs/services/auth/testing/src/fixtures/fixture-factory.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Update admin api client patch endpoint to be able to accept delegation type
What
Start using the new delegation types db table in auth admin api.
When creating or updating supported delegation types for a api scope we now both update the old boolean fields in the api_scope table and create/remove rows from the new api_scope_delegation_types table.
Why
We want to move to using a new supportedDelegationType array field when retrieving supported delegation types for an api_scope.
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor