Documentation
¶
Index ¶
- Constants
- Variables
- type Auditor
- type Clock
- type EmailSender
- type Invitation
- type InvitationWithWorkspace
- type Member
- type Page
- type PoolDeps
- type Repo
- type ShareLink
- type Workspace
- type WorkspaceConfig
- type WorkspaceMembership
- type WorkspaceService
- func (s *WorkspaceService) AcceptInvitation(ctx context.Context, p *webx.Principal, invID string) (Workspace, error)
- func (s *WorkspaceService) Create(ctx context.Context, p *webx.Principal, slug, name string) (Workspace, error)
- func (s *WorkspaceService) CreateShareLink(ctx context.Context, actor *webx.Principal, wsID, role string, maxUses int, ...) (ShareLink, string, error)
- func (s *WorkspaceService) DeclineInvitation(ctx context.Context, p *webx.Principal, invID string) error
- func (s *WorkspaceService) DeleteWorkspace(ctx context.Context, p *webx.Principal, workspaceID string) error
- func (s *WorkspaceService) Invite(ctx context.Context, actor *webx.Principal, wsID, rawEmail, role string) (Invitation, error)
- func (s *WorkspaceService) Leave(ctx context.Context, p *webx.Principal, wsID string) error
- func (s *WorkspaceService) ListInvitations(ctx context.Context, _ *webx.Principal, wsID string, page, pageSize int) (Page[Invitation], error)
- func (s *WorkspaceService) ListMembers(ctx context.Context, wsID string, page, pageSize int) (Page[Member], error)
- func (s *WorkspaceService) ListMine(ctx context.Context, p *webx.Principal) ([]WorkspaceMembership, error)
- func (s *WorkspaceService) ListShareLinks(ctx context.Context, _ *webx.Principal, wsID string, page, pageSize int) (Page[ShareLink], error)
- func (s *WorkspaceService) MyInvitations(ctx context.Context, p *webx.Principal) ([]InvitationWithWorkspace, error)
- func (s *WorkspaceService) RedeemShareLink(ctx context.Context, p *webx.Principal, code string) (Workspace, error)
- func (s *WorkspaceService) RemoveMember(ctx context.Context, actor *webx.Principal, wsID, targetUserID string) error
- func (s *WorkspaceService) RenameWorkspace(ctx context.Context, p *webx.Principal, workspaceID, name string) (Workspace, error)
- func (s *WorkspaceService) RevokeInvitation(ctx context.Context, actor *webx.Principal, wsID, invID string) error
- func (s *WorkspaceService) RevokeShareLink(ctx context.Context, actor *webx.Principal, wsID, linkID string) error
- func (s *WorkspaceService) TransferOwnership(ctx context.Context, actor *webx.Principal, wsID, newOwnerUserID string) error
- func (s *WorkspaceService) UpdateMemberRole(ctx context.Context, actor *webx.Principal, wsID, targetUserID, newRole string) error
- func (s *WorkspaceService) WithHooks(h workspace.WorkspaceHooks) *WorkspaceService
Constants ¶
View Source
const ( DefaultPageSize = 50 MaxPageSize = 200 )
Variables ¶
View Source
var ErrDuplicate = errors.New("duplicate")
View Source
var ErrLastOwner = errors.New("last active owner protected")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type EmailSender ¶
type Invitation ¶
type InvitationWithWorkspace ¶
type InvitationWithWorkspace struct {
Invitation
WorkspaceName string `json:"workspace_name"`
WorkspaceSlug string `json:"workspace_slug"`
}
type Repo ¶
type Repo interface {
CreateWorkspaceWithOwner(ctx context.Context, slug, name, ownerUserID string, now time.Time) (Workspace, error)
ListWorkspacesByUser(ctx context.Context, userID string) ([]WorkspaceMembership, error)
GetWorkspace(ctx context.Context, id string) (Workspace, bool, error)
CountWorkspacesByUser(ctx context.Context, userID string) (int, error)
GetMember(ctx context.Context, workspaceID, userID string) (Member, bool, error)
IsMemberByEmail(ctx context.Context, workspaceID, email string) (bool, error)
ListMembers(ctx context.Context, workspaceID string, page, pageSize int) (Page[Member], error)
CountActiveOwners(ctx context.Context, workspaceID string) (int, error)
UpdateMemberRole(ctx context.Context, workspaceID, userID, newRole string, now time.Time) error
SoftRemoveMember(ctx context.Context, workspaceID, userID, removedBy string, now time.Time) error
CreateInvitation(ctx context.Context, workspaceID, email, role, createdBy string, expiresAt time.Time) (Invitation, error)
ListInvitations(ctx context.Context, workspaceID string, page, pageSize int) (Page[Invitation], error)
RevokeInvitation(ctx context.Context, workspaceID, invitationID string, now time.Time) error
HasPendingInvitation(ctx context.Context, workspaceID, email string) (bool, error)
PendingInvitationsByEmail(ctx context.Context, email string) ([]InvitationWithWorkspace, error)
AcceptInvitation(ctx context.Context, invitationID, userID, email string, now time.Time) (Workspace, error)
DeclineInvitation(ctx context.Context, invitationID, email string, now time.Time) error
RunInTx(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error
CountWorkspacesByUserForCreateTx(ctx context.Context, tx pgx.Tx, userID string) (int, error)
CreateWorkspaceWithOwnerTx(ctx context.Context, tx pgx.Tx, slug, name, ownerUserID string, now time.Time) (Workspace, error)
AcceptInvitationTx(ctx context.Context, tx pgx.Tx, invitationID, userID, email string, now time.Time) (Workspace, error)
UpdateWorkspaceName(ctx context.Context, id, name string, now time.Time) error
DeleteWorkspaceCascade(ctx context.Context, tx pgx.Tx, workspaceID string) error
GetMemberUserStatus(ctx context.Context, workspaceID, userID string) (Member, string, bool, error)
OldestActiveOwner(ctx context.Context, workspaceID string) (Member, bool, error)
TransferOwnershipTx(ctx context.Context, tx pgx.Tx, workspaceID, fromUserID, toUserID string) error
}
type WorkspaceConfig ¶
type WorkspaceConfig struct {
MaxPerUser int
}
type WorkspaceMembership ¶
type WorkspaceService ¶
type WorkspaceService struct {
// contains filtered or unexported fields
}
func NewWorkspaceService ¶
func NewWorkspaceService(repo Repo, az *authz.Authorizer, mail EmailSender, auditor Auditor, cfg WorkspaceConfig, now Clock) *WorkspaceService
func (*WorkspaceService) AcceptInvitation ¶
func (*WorkspaceService) CreateShareLink ¶
func (*WorkspaceService) DeclineInvitation ¶
func (*WorkspaceService) DeleteWorkspace ¶
func (*WorkspaceService) Invite ¶
func (s *WorkspaceService) Invite(ctx context.Context, actor *webx.Principal, wsID, rawEmail, role string) (Invitation, error)
func (*WorkspaceService) ListInvitations ¶
func (s *WorkspaceService) ListInvitations(ctx context.Context, _ *webx.Principal, wsID string, page, pageSize int) (Page[Invitation], error)
func (*WorkspaceService) ListMembers ¶
func (*WorkspaceService) ListMine ¶
func (s *WorkspaceService) ListMine(ctx context.Context, p *webx.Principal) ([]WorkspaceMembership, error)
func (*WorkspaceService) ListShareLinks ¶
func (*WorkspaceService) MyInvitations ¶
func (s *WorkspaceService) MyInvitations(ctx context.Context, p *webx.Principal) ([]InvitationWithWorkspace, error)
func (*WorkspaceService) RedeemShareLink ¶
func (*WorkspaceService) RemoveMember ¶
func (*WorkspaceService) RenameWorkspace ¶
func (*WorkspaceService) RevokeInvitation ¶
func (*WorkspaceService) RevokeShareLink ¶
func (*WorkspaceService) TransferOwnership ¶
func (*WorkspaceService) UpdateMemberRole ¶
func (*WorkspaceService) WithHooks ¶
func (s *WorkspaceService) WithHooks(h workspace.WorkspaceHooks) *WorkspaceService
Click to show internal directories.
Click to hide internal directories.