feat(iam): add createTeam, editTeam, and listTeams#166
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 162b3c7. Configure here.
Greptile SummaryAdds
Confidence Score: 3/5The team management additions are largely consistent with existing IAM patterns, but the The
Important Files Changed
Reviews (1): Last reviewed commit: "feat(iam): add createTeam, editTeam, and..." | Re-trigger Greptile |
| description: string; | ||
| id: string; | ||
| members: string[]; | ||
| name: string; | ||
| updatedAt: Date; | ||
| }; |
There was a problem hiding this comment.
description typed as required string but it is optional in CreateTeamInput
Teams can be created without a description, so the API may return undefined (or omit the field) for those teams. The Team type declares description: string (non-optional), so callers will infer a string and won't add null guards, but at runtime team.description can be undefined. This is a type lie that will cause silent bugs downstream. It should match the optional shape: description?: string.
| const body = { | ||
| ...(team?.name && { name: team.name }), | ||
| ...(team?.description && { description: team.description }), | ||
| ...(team?.members && { | ||
| members: team.members.map((member) => ({ user_id: member })), | ||
| }), | ||
| }; |
There was a problem hiding this comment.
Falsy check on
description silently drops empty strings. Calling editTeam(id, { description: '' }) evaluates '' && { description: '' } to '', which spreads as nothing, so the description is never sent to the API and the caller gets a misleading No fields to update error instead. Checking !== undefined preserves the ability to clear or blank-out a description.
| const body = { | |
| ...(team?.name && { name: team.name }), | |
| ...(team?.description && { description: team.description }), | |
| ...(team?.members && { | |
| members: team.members.map((member) => ({ user_id: member })), | |
| }), | |
| }; | |
| const body = { | |
| ...(team?.name && { name: team.name }), | |
| ...(team?.description !== undefined && { description: team.description }), | |
| ...(team?.members && { | |
| members: team.members.map((member) => ({ user_id: member })), | |
| }), | |
| }; |
| path: IAM_ENDPOINTS.teams, | ||
| body: { | ||
| name: team.name, | ||
| ...(team.description && { description: team.description }), |
There was a problem hiding this comment.
Same falsy-check pattern: an explicitly passed empty-string
description is silently dropped. Using !== undefined is more precise — it excludes only truly absent values, not empty strings.
| ...(team.description && { description: team.description }), | |
| ...(team.description !== undefined && { description: team.description }), |
Add team management to @tigrisdata/iam for creating, editing, and listing teams within an organization. - createTeam(team, options?) creates a team from CreateTeamInput (name required, optional description and members) - editTeam(teamId, team, options?) applies a partial update and errors with "No fields to update" when no fields are provided - listTeams(options?) returns the organization's teams mapped to Team Add the /tigris-iam/teams endpoint and export the team functions and their option/response types. Assisted-by: Opus 4.8 via Claude Code
162b3c7 to
ac5f42e
Compare

Summary
Adds team management to
@tigrisdata/iamfor creating, editing, and listing teams within an organization.createTeam(team, options?)— creates a team fromCreateTeamInput(namerequired, optionaldescriptionandmembers) and returns the newteamId.editTeam(teamId, team, options?)— applies a partial update (Partial<CreateTeamInput>); errors withNo fields to updatewhen no fields are provided.listTeams(options?)— returns the organization's teams, each mapped to aTeam(id,name,description,members,createdAt,updatedAt).Adds the
/tigris-iam/teamsendpoint and exports the team functions plus their option/response/input types (CreateTeamInput,CreateTeamOptions,CreateTeamResponse,EditTeamOptions,EditTeamResponse,ListTeamsOptions,ListTeamsResponse,Team).Implementation notes
createIAMClientauth/guard, HTTP-level error check and body-levelstatus === 'error'check surfacing the APImessage.user_id,created_at, …).createTeam/editTeamshare a singleCreateTeamInputtype (edit usesPartial<CreateTeamInput>) for a symmetric API surface.Notes / follow-ups
deleteTeam/getTeamare intentionally not in this PR — planned as a follow-up.Release
Includes a changeset bumping
@tigrisdata/iam(minor).🤖 Generated with Claude Code
Note
Medium Risk
New IAM org membership APIs can affect access grouping if misused; behavior depends on the backend teams endpoint with no integration tests in this PR.
Overview
Adds organization team management to
@tigrisdata/iamvia three new public APIs wired to/tigris-iam/teams.createTeamPOSTs a team (nameplus optionaldescriptionandmembers), maps members touser_idin the request body, and returnsteamId.editTeamPATCHes/{teamId}with a partialCreateTeamInputand fails locally withNo fields to updatewhen the patch body would be empty.listTeamsGETs all teams and normalizes API snake_case fields into the exportedTeamshape (includingDatetimestamps and member user IDs).Package surface updates: new
lib/team/*modules,IAM_ENDPOINTS.teams, re-exports fromindex.ts, and a minor changeset for@tigrisdata/iam.Reviewed by Cursor Bugbot for commit ac5f42e. Bugbot is set up for automated code reviews on this repo. Configure here.