Interface ITeamRepository<TTeamEntity, TMember>
The team store behind TeamServiceRepositoryBase<TTeamEntity, TMember>.
public interface ITeamRepository<TTeamEntity, TMember> : IRepository where TTeamEntity : TeamEntityBase<TMember> where TMember : TeamMemberBase
Type Parameters
TTeamEntityTMember
Remarks
A member write changes that member alone. The built-in implementation sends one update per write — a
positional update of the member's fields, or a $pull to remove one — and never reads the member list
and writes it back. A replacement should do the same. Written back whole, the second of two overlapping edits
to one team undoes the first, and the undone edit can be a removal or a suspension (Tharga/Team#338).
Methods
AddAccessRequestAsync(string, TeamAccessRequestEntity)
Adds an access request, cancelling the requester's other pending requests on the team and keeping the HistoryLimit most recent.
Task AddAccessRequestAsync(string teamKey, TeamAccessRequestEntity request)
Parameters
teamKeystringrequestTeamAccessRequestEntity
Returns
Remarks
A default interface method that throws, so a host with its own repository keeps compiling and learns at the point of use that access requests need implementing — a request silently dropped would leave the requester waiting.
AddAsync(TTeamEntity)
Task AddAsync(TTeamEntity teamEntity)
Parameters
teamEntityTTeamEntity
Returns
AddMemberAsync(string, TMember)
Task AddMemberAsync(string teamKey, TMember member)
Parameters
teamKeystringmemberTMember
Returns
ApproveAccessRequestAsync(string, string, string, DateTime, DateTime?, string[], AccessLevel, TemporaryConsentEntity)
Approves a pending request and sets the team's consent in one update. False when the request was no longer pending.
Task<bool> ApproveAccessRequestAsync(string teamKey, string requestId, string decidedBy, DateTime decidedAt, DateTime? grantedUntil, string[] consentedRoles, AccessLevel accessLevel, TemporaryConsentEntity temporaryConsent)
Parameters
teamKeystringrequestIdstringdecidedBystringdecidedAtDateTimegrantedUntilDateTime?consentedRolesstring[]accessLevelAccessLeveltemporaryConsentTemporaryConsentEntity
Returns
DecideAccessRequestAsync(string, string, TeamAccessRequestStatus, string, DateTime)
Marks a request decided, only if still pending. False when it was not.
Task<bool> DecideAccessRequestAsync(string teamKey, string requestId, TeamAccessRequestStatus status, string decidedBy, DateTime decidedAt)
Parameters
teamKeystringrequestIdstringstatusTeamAccessRequestStatusdecidedBystringdecidedAtDateTime
Returns
DeleteAsync(string)
Task DeleteAsync(string teamKey)
Parameters
teamKeystring
Returns
GetAllTeamsAsync()
Every team, regardless of membership — backs the cross-team discovery path authorized by Read.
IAsyncEnumerable<TTeamEntity> GetAllTeamsAsync()
Returns
- IAsyncEnumerable<TTeamEntity>
Remarks
Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than returning empty: a silently empty cross-team list is indistinguishable from a working feature that happens to have nothing to show, which hides the missing implementation.
GetAllTeamsIncludingDeletedAsync()
Every team including soft-deleted ones — the only read that sees them, for restore and purge surfaces.
IAsyncEnumerable<TTeamEntity> GetAllTeamsIncludingDeletedAsync()
Returns
- IAsyncEnumerable<TTeamEntity>
Remarks
Deliberately a separate method rather than a flag on GetAllTeamsAsync(). A boolean parameter defaulting to "exclude" is one forgotten argument away from leaking deleted teams into an ordinary list; a distinct name has to be chosen on purpose.
GetAsync(string)
Task<TTeamEntity> GetAsync(string teamKey)
Parameters
teamKeystring
Returns
- Task<TTeamEntity>
GetByInviteKeyAsync(string)
The single live team holding an outstanding invitation with this code, or null when none or more than
one does. Backed by the Members.Invitation.InviteKey index.
Task<TTeamEntity> GetByInviteKeyAsync(string inviteKey)
Parameters
inviteKeystring
Returns
- Task<TTeamEntity>
Remarks
The default returns null so a host with its own repository keeps compiling, but every invitation link
the toolkit mints needs this to resolve, so left at the default none of them does. Reported at startup
by InvitationRepositoryCheck (Tharga/Team#286).
GetIncludingDeletedAsync(string)
A team by key whether or not it is deleted — for restore, purge and key reservation.
Task<TTeamEntity> GetIncludingDeletedAsync(string teamKey)
Parameters
teamKeystring
Returns
- Task<TTeamEntity>
GetTeamsByConsentAsync(string[])
IAsyncEnumerable<TTeamEntity> GetTeamsByConsentAsync(string[] roles)
Parameters
rolesstring[]
Returns
- IAsyncEnumerable<TTeamEntity>
GetTeamsByUserAsync(string)
IAsyncEnumerable<TTeamEntity> GetTeamsByUserAsync(string userKey)
Parameters
userKeystring
Returns
- IAsyncEnumerable<TTeamEntity>
GetTeamsByUsersAsync(IReadOnlyCollection<string>)
The live teams any of these users has accepted membership of, each once.
Task<TTeamEntity[]> GetTeamsByUsersAsync(IReadOnlyCollection<string> userKeys)
Parameters
userKeysIReadOnlyCollection<string>
Returns
- Task<TTeamEntity[]>
Remarks
A default interface method that asks per user, so a host's own repository keeps compiling; the built-in one asks the database once.
RemoveMemberAsync(string, string)
Task RemoveMemberAsync(string teamKey, string userKey)
Parameters
Returns
RemoveMemberFromAllTeamsAsync(string)
Removes the user's member entries from every team they appear in, regardless of membership state. Backs user deletion. Returns the number of teams the user was removed from.
Task<int> RemoveMemberFromAllTeamsAsync(string userKey)
Parameters
userKeystring
Returns
Remarks
Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than returning 0: a silent no-op on a deletion path would leave memberships behind while reporting success.
RemoveMemberGuardedAsync(string, string, bool)
Removes the member unless they are the Owner and, when requireOtherAdministrator, unless no
other active administrator or owner would remain, as one write. False when refused. See SetMemberRoleUnlessOwnerAsync(string, string, AccessLevel).
Task<bool> RemoveMemberGuardedAsync(string teamKey, string userKey, bool requireOtherAdministrator)
Parameters
Returns
RenameAsync(string, string)
Task RenameAsync(string teamKey, string name)
Parameters
Returns
SetConsentAsync(string, string[], AccessLevel?)
Task SetConsentAsync(string teamKey, string[] consentedRoles, AccessLevel? accessLevel = null)
Parameters
teamKeystringconsentedRolesstring[]accessLevelAccessLevel?
Returns
SetCustomRolesAsync(string, IReadOnlyList<TenantRoleDefinition>)
Task SetCustomRolesAsync(string teamKey, IReadOnlyList<TenantRoleDefinition> customRoles)
Parameters
teamKeystringcustomRolesIReadOnlyList<TenantRoleDefinition>
Returns
SetDeletedAsync(string, DateTime?, string)
Marks a team deleted, or clears the mark when deletedAt is null.
Task SetDeletedAsync(string teamKey, DateTime? deletedAt, string deletedBy)
Parameters
Returns
Remarks
Declared with a default implementation so existing custom repositories keep compiling — and it throws rather than no-opping, because a soft delete that silently does nothing reports success while leaving the team live and readable, which is worse than refusing.
A repository that does not implement this makes its service report
SupportsSoftDelete = false, so the throw is unreachable through the normal path: the delete
resolves to the irreversible one the store already had.
SetIconAsync(string, string)
Task SetIconAsync(string teamKey, string reference)
Parameters
Returns
SetInvitationExpiryAsync(string, string, DateTime?)
Sets the expiry of the invitation matching inviteKey, leaving the code itself
untouched so an already-mailed link keeps working.
Task SetInvitationExpiryAsync(string teamKey, string inviteKey, DateTime? expiresAt)
Parameters
Returns
Remarks
A default interface method that throws, so a host with its own repository keeps compiling and the gap
surfaces as an error at the point of use rather than as an extension that reports success and changes
nothing. With Lifetime set, InvitationRepositoryCheck also
reports it at startup.
SetInvitationResponseAsync(string, string, string, bool)
Task<ITeam> SetInvitationResponseAsync(string teamKey, string userKey, string inviteKey, bool accept)
Parameters
Returns
SetLastSeenAsync(string, string, DateTime)
Task SetLastSeenAsync(string teamKey, string userKey, DateTime utcNow)
Parameters
Returns
SetMemberNameAsync(string, string, string)
Task SetMemberNameAsync(string teamKey, string userKey, string name)
Parameters
Returns
SetMemberRoleAsync(string, string, AccessLevel)
Task SetMemberRoleAsync(string teamKey, string userKey, AccessLevel accessLevel)
Parameters
teamKeystringuserKeystringaccessLevelAccessLevel
Returns
SetMemberRoleUnlessOwnerAsync(string, string, AccessLevel)
Sets the access level unless the member is the Owner, as one write that checks that itself. False when refused.
Task<bool> SetMemberRoleUnlessOwnerAsync(string teamKey, string userKey, AccessLevel accessLevel)
Parameters
teamKeystringuserKeystringaccessLevelAccessLevel
Returns
Remarks
A default interface method doing the unconditional write, so a host's own repository keeps compiling and behaving as before. The built-in one puts the condition in the update's filter (Tharga/Team#342).
SetMemberScopeOverridesAsync(string, string, string[])
Task SetMemberScopeOverridesAsync(string teamKey, string userKey, string[] scopeOverrides)
Parameters
Returns
SetMemberSuspendedAsync(string, string, DateTime?, string)
Task SetMemberSuspendedAsync(string teamKey, string userKey, DateTime? suspendedAt, string suspendedBy)
Parameters
Returns
SetMemberTenantRolesAsync(string, string, string[])
Task SetMemberTenantRolesAsync(string teamKey, string userKey, string[] tenantRoles)
Parameters
Returns
TransferOwnershipAsync(string, string, string)
Promotes the new owner and demotes the current one together, only while the current one is still the Owner. False when refused. See SetMemberRoleUnlessOwnerAsync(string, string, AccessLevel).
Task<bool> TransferOwnershipAsync(string teamKey, string currentOwnerKey, string newOwnerKey)