feat: Added endpoint to list a users teams - #752
Open
wim07101993 wants to merge 4 commits into
Open
Conversation
# Conflicts: # api/generated/oas_router_gen.go
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
🦋 Changeset detectedLatest commit: aa9d402 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new user-facing API endpoint to list the teams a user belongs to, backed by a storage-level “roster read” join across all supported DB dialects, and updates the user payload to clearly separate lifecycle ownership from roster membership.
Changes:
- Add
GET /users/{user_id}/teamsOpenAPI contract + generated server/client code, with integration coverage. - Implement roster listing end-to-end (service + v2 storage statements) including filtering out removed memberships and keyset pagination.
- Extend user metadata with
metadata.lifecycleOwnerTeamIdto represent lifecycle ownership distinctly from roster membership.
Reviewed changes
Copilot reviewed 18 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/storage/v2/userteam/schema.go | Introduces a schema binding for joined membership+team roster reads (qualified SQL column names for joins). |
| internal/storage/v2/stmttest/team_membership_test.go | Adds statement-level cross-dialect tests for listing user teams (join, filtering, pagination, empty). |
| internal/storage/v2/dialect/sqlite/team_membership.go | Implements ListUserTeams query + row scanning for SQLite dialect. |
| internal/storage/v2/dialect/spanner/team_membership.go | Implements ListUserTeams query + row scanning for Spanner dialect. |
| internal/storage/v2/dialect/postgres/team_membership.go | Implements ListUserTeams query + row scanning for Postgres dialect. |
| internal/service/user.go | Adds UserService.ListUserTeams orchestration (status filtering, pagination, user existence check). |
| internal/service/statement.go | Extends TeamMembershipStatements interface with ListUserTeams. |
| internal/service/mocks/statement.mock.go | Updates generated mocks to include ListUserTeams on relevant statement interfaces. |
| internal/domain/user_team.go | Adds domain.UserTeam projection type + field enum used for list filtering/ordering. |
| internal/domain/team_membership.go | Defines RosterMembershipStatuses (excludes removed) for consistent roster filtering. |
| internal/api/user.go | Adds API handler ListUserTeams; augments user mapping with metadata.lifecycleOwnerTeamId. |
| internal/api/integration_test/user_test.go | Adds integration test for /users/{user_id}/teams and validates lifecycle-owner vs roster distinction. |
| internal/api/integration_test/helpers/team.go | Adds fixture helper to create team memberships in integration tests. |
| api/openapi/openapi-spec.yaml | Registers the new /users/{user_id}/teams path in the OpenAPI root spec. |
| api/openapi/endpoints/users/user-metadata.yaml | Extends User metadata schema with lifecycleOwnerTeamId (nullable). |
| api/openapi/endpoints/users/by_id/teams/user-team.yaml | Defines UserTeam schema returned by the roster endpoint. |
| api/openapi/endpoints/users/by_id/teams/methods.yaml | Defines the listUserTeams operation (params, auth scope, responses). |
| api/openapi/endpoints/users/by_id/teams/list-user-teams-response.yaml | Defines the paginated response envelope for listUserTeams. |
| api/generated/oas_validators_gen.go | Generated validators for UserTeam and ListUserTeamsResponse. |
| api/generated/oas_unimplemented_gen.go | Generated unimplemented handler stub for ListUserTeams. |
| api/generated/oas_server_gen.go | Generated server interface updated to include ListUserTeams. |
| api/generated/oas_security_gen.go | Generated OAuth2 scope mapping includes ListUserTeams -> user.read. |
| api/generated/oas_schemas_gen.go | Generated schema types for UserTeam, response/error variants, and user metadata field. |
| api/generated/oas_router_gen.go | Generated router updated to route GET /users/{user_id}/teams. |
| api/generated/oas_response_encoders_gen.go | Generated response encoder for ListUserTeams responses. |
| api/generated/oas_response_decoders_gen.go | Generated response decoder for ListUserTeams client calls. |
| api/generated/oas_parameters_gen.go | Generated parameter decoding for ListUserTeams (limit default, page_token, project_id, user_id). |
| api/generated/oas_operations_gen.go | Generated operation name constant for ListUserTeams. |
| api/generated/oas_json_gen.go | Generated JSON encode/decode for new endpoint types and new user metadata field. |
| api/generated/oas_interfaces_gen.go | Generated ListUserTeamsRes response interface. |
| api/generated/oas_handlers_gen.go | Generated HTTP handler glue for ListUserTeams. |
| api/generated/oas_client_gen.go | Generated client method ListUserTeams. |
| .changeset/list-user-teams-endpoint.md | Adds release notes + version bumps for @zitadel/server and @zitadel/api. |
Files not reviewed (1)
- internal/service/mocks/statement.mock.go: Generated file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
go test ./...go test -tags postgres_integration ./...go test -tags spanner_integration -parallel 1 ./...Release notes / changeset
Notes