organization

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddTenantMemberCommand

type AddTenantMemberCommand struct {
	TenantID  string
	Email     string
	FullName  string
	Role      entity.TenantRole
	GrantedBy string
}

AddTenantMemberCommand contains data for adding a user to a tenant.

type CreateTenantCommand

type CreateTenantCommand struct {
	Code        string
	Name        string
	Description string
}

CreateTenantCommand represents the command to create a tenant.

type CreateWorkspaceCommand

type CreateWorkspaceCommand struct {
	TenantID  *string
	Code      string
	Name      string
	Type      entity.WorkspaceType
	CreatedBy string
}

CreateWorkspaceCommand represents the command to create a workspace.

type InviteMemberCommand

type InviteMemberCommand struct {
	WorkspaceID string
	Email       string
	FullName    string
	Role        entity.WorkspaceRole
	InvitedBy   string
}

InviteMemberCommand contains data for inviting a user to a workspace.

type RemoveMemberCommand

type RemoveMemberCommand struct {
	MemberID    string
	WorkspaceID string
	RemovedBy   string // The user performing the removal
}

RemoveMemberCommand contains data for removing a member.

type RemoveTenantMemberCommand

type RemoveTenantMemberCommand struct {
	MemberID  string
	TenantID  string
	RemovedBy string // The user performing the removal
}

RemoveTenantMemberCommand contains data for removing a tenant member.

type TenantMemberUseCase

type TenantMemberUseCase interface {
	// ListMembers lists all members of a tenant.
	ListMembers(ctx context.Context, tenantID string) ([]*entity.TenantMemberWithUser, error)

	// GetMember retrieves a specific tenant member by ID.
	GetMember(ctx context.Context, memberID string) (*entity.TenantMemberWithUser, error)

	// AddMember adds a user to a tenant.
	// Creates a shadow user if the email doesn't exist.
	AddMember(ctx context.Context, cmd AddTenantMemberCommand) (*entity.TenantMemberWithUser, error)

	// UpdateMemberRole updates a tenant member's role.
	UpdateMemberRole(ctx context.Context, cmd UpdateTenantMemberRoleCommand) (*entity.TenantMemberWithUser, error)

	// RemoveMember removes a member from the tenant.
	RemoveMember(ctx context.Context, cmd RemoveTenantMemberCommand) error

	// CountOwners counts the number of TENANT_OWNER members in a tenant.
	CountOwners(ctx context.Context, tenantID string) (int, error)
}

TenantMemberUseCase defines the interface for tenant member operations.

type TenantUseCase

type TenantUseCase interface {
	// CreateTenant creates a new tenant with its system workspace.
	CreateTenant(ctx context.Context, cmd CreateTenantCommand) (*entity.Tenant, error)

	// GetTenant retrieves a tenant by ID.
	GetTenant(ctx context.Context, id string) (*entity.Tenant, error)

	// GetTenantByCode retrieves a tenant by its code.
	GetTenantByCode(ctx context.Context, code string) (*entity.Tenant, error)

	// SearchTenants searches tenants by name or code similarity.
	SearchTenants(ctx context.Context, query string) ([]*entity.Tenant, error)

	// ListTenantsPaginated lists tenants with pagination.
	ListTenantsPaginated(ctx context.Context, filters port.TenantFilters) ([]*entity.Tenant, int64, error)

	// ListTenantWorkspaces lists workspaces for a tenant with optional search (system admin use).
	ListTenantWorkspaces(ctx context.Context, tenantID string, filters port.WorkspaceFilters) ([]*entity.Workspace, int64, error)

	// ListUserTenants lists all tenants a user belongs to with their roles.
	ListUserTenants(ctx context.Context, userID string) ([]*entity.TenantWithRole, error)

	// ListUserTenantsPaginated lists tenants a user belongs to with pagination and optional search.
	// When filters.Query is provided, orders by similarity. Otherwise, orders by access history.
	ListUserTenantsPaginated(ctx context.Context, userID string, filters port.TenantMemberFilters) ([]*entity.TenantWithRole, int64, error)

	// UpdateTenant updates a tenant's details.
	UpdateTenant(ctx context.Context, cmd UpdateTenantCommand) (*entity.Tenant, error)

	// UpdateTenantStatus updates a tenant's status (ACTIVE, SUSPENDED, ARCHIVED).
	UpdateTenantStatus(ctx context.Context, cmd UpdateTenantStatusCommand) (*entity.Tenant, error)

	// DeleteTenant deletes a tenant and all its data.
	DeleteTenant(ctx context.Context, id string) error
}

TenantUseCase defines the input port for tenant operations.

type UpdateMemberRoleCommand

type UpdateMemberRoleCommand struct {
	MemberID    string
	WorkspaceID string
	NewRole     entity.WorkspaceRole
	UpdatedBy   string // The user performing the update
}

UpdateMemberRoleCommand contains data for updating a member's role.

type UpdateTenantCommand

type UpdateTenantCommand struct {
	ID          string
	Name        string
	Description string
	Settings    map[string]any
}

UpdateTenantCommand represents the command to update a tenant.

type UpdateTenantMemberRoleCommand

type UpdateTenantMemberRoleCommand struct {
	MemberID  string
	TenantID  string
	NewRole   entity.TenantRole
	UpdatedBy string // The user performing the update
}

UpdateTenantMemberRoleCommand contains data for updating a tenant member's role.

type UpdateTenantStatusCommand

type UpdateTenantStatusCommand struct {
	ID     string
	Status entity.TenantStatus
}

UpdateTenantStatusCommand represents the command to update a tenant's status.

type UpdateWorkspaceCommand

type UpdateWorkspaceCommand struct {
	ID   string
	Code string
	Name string
}

UpdateWorkspaceCommand represents the command to update a workspace.

type UpdateWorkspaceStatusCommand

type UpdateWorkspaceStatusCommand struct {
	ID     string
	Status entity.WorkspaceStatus
}

UpdateWorkspaceStatusCommand represents the command to update a workspace's status.

type WorkspaceMemberUseCase

type WorkspaceMemberUseCase interface {
	// ListMembers lists all members of a workspace.
	ListMembers(ctx context.Context, workspaceID string) ([]*entity.MemberWithUser, error)

	// GetMember retrieves a specific member by ID.
	GetMember(ctx context.Context, memberID string) (*entity.MemberWithUser, error)

	// InviteMember invites a user to join a workspace.
	// Creates a shadow user if the email doesn't exist.
	InviteMember(ctx context.Context, cmd InviteMemberCommand) (*entity.MemberWithUser, error)

	// UpdateMemberRole updates a member's role within the workspace.
	UpdateMemberRole(ctx context.Context, cmd UpdateMemberRoleCommand) (*entity.MemberWithUser, error)

	// RemoveMember removes a member from the workspace.
	RemoveMember(ctx context.Context, cmd RemoveMemberCommand) error
}

WorkspaceMemberUseCase defines the interface for workspace member operations.

type WorkspaceUseCase

type WorkspaceUseCase interface {
	// CreateWorkspace creates a new workspace.
	CreateWorkspace(ctx context.Context, cmd CreateWorkspaceCommand) (*entity.Workspace, error)

	// GetWorkspace retrieves a workspace by ID.
	GetWorkspace(ctx context.Context, id string) (*entity.Workspace, error)

	// ListUserWorkspaces lists all workspaces a user has access to.
	ListUserWorkspaces(ctx context.Context, userID string) ([]*entity.WorkspaceWithRole, error)

	// ListWorkspacesPaginated lists workspaces for a tenant with pagination and optional search.
	// When filters.Query is provided, orders by similarity. Otherwise, orders by access history.
	ListWorkspacesPaginated(ctx context.Context, tenantID, userID string, filters port.WorkspaceFilters) ([]*entity.Workspace, int64, error)

	// UpdateWorkspace updates a workspace's details.
	UpdateWorkspace(ctx context.Context, cmd UpdateWorkspaceCommand) (*entity.Workspace, error)

	// ArchiveWorkspace archives a workspace (soft delete).
	ArchiveWorkspace(ctx context.Context, id string) error

	// ActivateWorkspace activates a workspace.
	ActivateWorkspace(ctx context.Context, id string) error

	// UpdateWorkspaceStatus updates a workspace's status (ACTIVE, SUSPENDED, ARCHIVED).
	UpdateWorkspaceStatus(ctx context.Context, cmd UpdateWorkspaceStatusCommand) (*entity.Workspace, error)

	// GetSystemWorkspace retrieves the system workspace for a tenant.
	GetSystemWorkspace(ctx context.Context, tenantID *string) (*entity.Workspace, error)
}

WorkspaceUseCase defines the input port for workspace operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL