Table of Contents

Interface ITeamRepository<TTeamEntity, TMember>

Namespace
Tharga.Team.MongoDB
Assembly
Tharga.Team.MongoDB.dll
public interface ITeamRepository<TTeamEntity, TMember> : IRepository where TTeamEntity : TeamEntityBase<TMember> where TMember : TeamMemberBase

Type Parameters

TTeamEntity
TMember

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

teamKey string
request TeamAccessRequestEntity

Returns

Task

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

teamEntity TTeamEntity

Returns

Task

AddMemberAsync(string, TMember)

Task AddMemberAsync(string teamKey, TMember member)

Parameters

teamKey string
member TMember

Returns

Task

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

teamKey string
requestId string
decidedBy string
decidedAt DateTime
grantedUntil DateTime?
consentedRoles string[]
accessLevel AccessLevel
temporaryConsent TemporaryConsentEntity

Returns

Task<bool>

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

teamKey string
requestId string
status TeamAccessRequestStatus
decidedBy string
decidedAt DateTime

Returns

Task<bool>

DeleteAsync(string)

Task DeleteAsync(string teamKey)

Parameters

teamKey string

Returns

Task

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

teamKey string

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

inviteKey string

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

teamKey string

Returns

Task<TTeamEntity>

GetTeamsByConsentAsync(string[])

IAsyncEnumerable<TTeamEntity> GetTeamsByConsentAsync(string[] roles)

Parameters

roles string[]

Returns

IAsyncEnumerable<TTeamEntity>

GetTeamsByUserAsync(string)

IAsyncEnumerable<TTeamEntity> GetTeamsByUserAsync(string userKey)

Parameters

userKey string

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

userKeys IReadOnlyCollection<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

teamKey string
userKey string

Returns

Task

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

userKey string

Returns

Task<int>

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

teamKey string
userKey string
requireOtherAdministrator bool

Returns

Task<bool>

RenameAsync(string, string)

Task RenameAsync(string teamKey, string name)

Parameters

teamKey string
name string

Returns

Task

SetConsentAsync(string, string[], AccessLevel?)

Task SetConsentAsync(string teamKey, string[] consentedRoles, AccessLevel? accessLevel = null)

Parameters

teamKey string
consentedRoles string[]
accessLevel AccessLevel?

Returns

Task

SetCustomRolesAsync(string, IReadOnlyList<TenantRoleDefinition>)

Task SetCustomRolesAsync(string teamKey, IReadOnlyList<TenantRoleDefinition> customRoles)

Parameters

teamKey string
customRoles IReadOnlyList<TenantRoleDefinition>

Returns

Task

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

teamKey string
deletedAt DateTime?
deletedBy string

Returns

Task

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

teamKey string
reference string

Returns

Task

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

teamKey string
inviteKey string
expiresAt DateTime?

Returns

Task

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

teamKey string
userKey string
inviteKey string
accept bool

Returns

Task<ITeam>

SetLastSeenAsync(string, string, DateTime)

Task SetLastSeenAsync(string teamKey, string userKey, DateTime utcNow)

Parameters

teamKey string
userKey string
utcNow DateTime

Returns

Task

SetMemberNameAsync(string, string, string)

Task SetMemberNameAsync(string teamKey, string userKey, string name)

Parameters

teamKey string
userKey string
name string

Returns

Task

SetMemberRoleAsync(string, string, AccessLevel)

Task SetMemberRoleAsync(string teamKey, string userKey, AccessLevel accessLevel)

Parameters

teamKey string
userKey string
accessLevel AccessLevel

Returns

Task

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

teamKey string
userKey string
accessLevel AccessLevel

Returns

Task<bool>

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

teamKey string
userKey string
scopeOverrides string[]

Returns

Task

SetMemberSuspendedAsync(string, string, DateTime?, string)

Task SetMemberSuspendedAsync(string teamKey, string userKey, DateTime? suspendedAt, string suspendedBy)

Parameters

teamKey string
userKey string
suspendedAt DateTime?
suspendedBy string

Returns

Task

SetMemberTenantRolesAsync(string, string, string[])

Task SetMemberTenantRolesAsync(string teamKey, string userKey, string[] tenantRoles)

Parameters

teamKey string
userKey string
tenantRoles string[]

Returns

Task

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)

Parameters

teamKey string
currentOwnerKey string
newOwnerKey string

Returns

Task<bool>