domain

package
v0.0.0-...-52092a1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountAggregateType = eventing.AggregateType("account")

	AccountEmailUniqueConstraint = "account_email"
	AccountLookupEmail           = "account_email"
)
View Source
const (
	AccountCreatedEventType    = eventing.EventType("account_created")
	AccountCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	AccountLinkedToPersonEventType    = eventing.EventType("account_linked_to_person")
	AccountLinkedToPersonEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	RootAccountCreatedEventType    = eventing.EventType("root_account_created")
	RootAccountCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	ClubAggregateType = eventing.AggregateType("club")

	ClubNameUniqueConstraint = "club_name"
	ClubSlugUniqueConstraint = "club_slug"

	ClubLookupSlug = "slug"
	ClubLookupName = "name"
)
View Source
const (
	ClubCreatedEventType    = eventing.EventType("club_created")
	ClubCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	PersonAggregateType = eventing.AggregateType("person")

	PersonMaxPendingLinks = 5
)
View Source
const (
	PersonCreatedEventType    = eventing.EventType("person_created")
	PersonCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	PersonLinkClaimedEventType    = eventing.EventType("person_link_claimed")
	PersonLinkClaimedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	PersonLinkInitiatedEventType    = eventing.EventType("person_link_initiated")
	PersonLinkInitiatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	SessionAggregateType = eventing.AggregateType("session")

	// SessionLookupToken is the key used to look up a session by the session token.
	SessionLookupToken = "session_token"

	SessionIDUniqueConstraint = "session_id"
)
View Source
const (
	SessionCreatedEventType    = eventing.EventType("session_created")
	SessionCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	TeamAggregateType = eventing.AggregateType("team")

	TeamNameUniqueConstraint = "team_name"
	TeamSlugUniqueConstraint = "team_slug"

	TeamLookupSlug       = eventing.LookupFieldName("slug")
	TeamLookupName       = eventing.LookupFieldName("name")
	TeamLookupOwningClub = eventing.LookupFieldName("owning_club")
)
View Source
const (
	TeamCreatedEventType    = eventing.EventType("team_created")
	TeamCreatedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	TeamDeletedEventType    = eventing.EventType("team_deleted")
	TeamDeletedEventVersion = eventing.EventVersion("v1")
)
View Source
const (
	TeamMemberAggregateType = eventing.AggregateType("team_member")

	// TeamMembershipUniqueConstraint guarantees that a person with a given ID cannot be added twice to a team.
	TeamMembershipUniqueConstraint = "team_membership"

	// TeamMembershipLookup allows looking up the owner ID of a membership by team ID + person ID.
	TeamMembershipLookup = "team_membership"
)
View Source
const (
	PersonInvitedToTeamEventType    = eventing.EventType("person_invited_to_team")
	PersonInvitedToTeamEventVersion = eventing.EventVersion("v1")
)
View Source
const RedactedString = "**********"

RedactedString is used when an event was crypto shredded, and we need a placeholder value.

Variables

View Source
var (
	ErrAccountNotFound               = errors.New("account not found")
	ErrRootAccountAlreadyInitialized = errors.New("root account already initialized")
	ErrWrongCredentials              = errors.New("wrong credentials")
	ErrAccountAlreadyLinkedToPerson  = errors.New("already linked to person")
	ErrAccountAlreadyHasSelfLink     = errors.New("already has self link")
)
View Source
var (
	PersonMaxBirthdate = time.Now()
	PersonMinBirthdate = time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)

	ErrOwningClubNotFound           = errors.New("owning club not found")
	ErrPersonNotFound               = errors.New("person not found")
	ErrPersonAlreadySelfLinked      = errors.New("person already self linked")
	ErrPersonHasTooManyPendingLinks = errors.New("too many pending links for person")
	ErrPersonInvalidLinkToken       = errors.New("invalid link token")
	ErrPersonLinkTokenExpired       = errors.New("link token has expired")
)
View Source
var (
	ErrPrincipalNotFound = errors.New("principal not found")
	ErrUnauthenticated   = errors.New("unauthenticated")
	ErrMissingSubject    = errors.New("the subject of the action was not specified")
)
View Source
var (
	ErrTeamOwningClubNotFound = errors.New("owning club not found")
	ErrTeamNotFound           = errors.New("team not found")
)
View Source
var (
	ErrSessionNotFound = errors.New("session not found")
)
View Source
var (
	ErrTeamMemberNotFound = errors.New("team member not found")
)

Functions

func NewContextWithPrincipal

func NewContextWithPrincipal(ctx context.Context, p *Principal) context.Context

NewContextWithPrincipal adds the Principal to the context.

func Slugify

func Slugify(input string) string

Slugify converts a string to a slug including a random suffix.

Types

type Account

type Account struct {
	eventing.BaseWriter

	State AccountState

	ID            AccountID
	FirstName     string
	LastName      string
	LinkedPersons []*AccountLinkedPerson
	Password      HashedPassword

	// IsRoot specifies if this the base service account.
	IsRoot bool
}

func NewAccount

func NewAccount(accountID AccountID) *Account

func (*Account) Init

func (a *Account) Init(firstName, lastName, email string, password HashedPassword) error

func (*Account) InitAsRoot

func (a *Account) InitAsRoot(email string, password HashedPassword, firstName, lastName string) error
func (a *Account) Link(id PersonID, linkAs AccountLink, linkedBy *Operator, clubID ClubID) error

func (*Account) Query

func (a *Account) Query() eventing.JournalQuery

func (*Account) Reduce

func (a *Account) Reduce(events []*eventing.JournalEvent)

func (*Account) VerifyPassword

func (a *Account) VerifyPassword(password string, verifier PasswordVerifier) (bool, error)

type AccountCreatedEvent

type AccountCreatedEvent struct {
	*eventing.EventBase

	FirstName eventing.EncryptedString `json:"first_name"`
	LastName  eventing.EncryptedString `json:"last_name"`

	Email          eventing.EncryptedString `json:"email"`
	HashedPassword eventing.EncryptedString `json:"hashed_password"`
}

func NewAccountCreatedEvent

func NewAccountCreatedEvent(id AccountID, firstName, lastName, email string, hashedPassword HashedPassword) *AccountCreatedEvent

func (*AccountCreatedEvent) AcceptCrypto

func (r *AccountCreatedEvent) AcceptCrypto(transformer eventing.CryptoTransformer) error

func (*AccountCreatedEvent) DeclareOwners

func (r *AccountCreatedEvent) DeclareOwners() []eventing.AggregateID

func (*AccountCreatedEvent) IsShredded

func (r *AccountCreatedEvent) IsShredded() bool

func (*AccountCreatedEvent) LookupValues

func (r *AccountCreatedEvent) LookupValues() eventing.LookupMap

func (*AccountCreatedEvent) UniqueConstraintsToAdd

func (r *AccountCreatedEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type AccountID

type AccountID string
type AccountLink string
const (
	AccountLinkParent AccountLink = "parent"
	AccountLinkSelf   AccountLink = "self"
)

type AccountLinkedPerson

type AccountLinkedPerson struct {
	ID       PersonID
	LinkedAs AccountLink
	// Only set if someone other than themselves linked the person.
	LinkedBy *Operator
}

type AccountLinkedToPersonEvent

type AccountLinkedToPersonEvent struct {
	*eventing.EventBase

	PersonID     PersonID    `json:"person_id"`
	LinkedAs     AccountLink `json:"linked_as"`
	LinkedBy     *Operator   `json:"linked_by"`
	OwningClubID ClubID      `json:"owning_club_id"`
}

func NewAccountLinkedToPersonEvent

func NewAccountLinkedToPersonEvent(id AccountID, personID PersonID, linkAs AccountLink, linkedBy *Operator, clubID ClubID) *AccountLinkedToPersonEvent

func (*AccountLinkedToPersonEvent) IsShredded

func (l *AccountLinkedToPersonEvent) IsShredded() bool

type AccountRepository

type AccountRepository interface {
	FindByID(ctx context.Context, id AccountID) (*Account, error)
	FindByEmail(ctx context.Context, email string) (*Account, error)

	Save(ctx context.Context, account *Account) error

	ExistsByEmail(ctx context.Context, email string) (bool, error)
}

type AccountState

type AccountState int
const (
	AccountStateUnspecified AccountState = iota
	AccountStateActive
)

type Club

type Club struct {
	eventing.BaseWriter

	State ClubState

	ID   ClubID
	Name string
	Slug string
}

func NewClub

func NewClub(id ClubID) *Club

func (*Club) Init

func (a *Club) Init(name, slug string) error

func (*Club) Query

func (a *Club) Query() eventing.JournalQuery

func (*Club) Reduce

func (a *Club) Reduce(events []*eventing.JournalEvent)

type ClubCreatedEvent

type ClubCreatedEvent struct {
	*eventing.EventBase

	Name string `json:"name"`
	Slug string `json:"slug"`
}

func NewClubCreatedEvent

func NewClubCreatedEvent(clubID ClubID, name, slug string) *ClubCreatedEvent

func (*ClubCreatedEvent) IsShredded

func (e *ClubCreatedEvent) IsShredded() bool

func (*ClubCreatedEvent) LookupValues

func (e *ClubCreatedEvent) LookupValues() eventing.LookupMap

func (*ClubCreatedEvent) UniqueConstraintsToAdd

func (e *ClubCreatedEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type ClubID

type ClubID string

type ClubRepository

type ClubRepository interface {
	FindByID(ctx context.Context, id ClubID) (*Club, error)

	Save(ctx context.Context, club *Club) error

	ExistsByName(ctx context.Context, name string) (bool, error)
	ExistsByID(ctx context.Context, id ClubID) (bool, error)
}

type ClubState

type ClubState int
const (
	ClubStateUnspecified ClubState = iota
	ClubStateActive
)

type EventSourcedAccountRepository

type EventSourcedAccountRepository struct {
	// contains filtered or unexported fields
}

func NewEventSourcedAccountRepository

func NewEventSourcedAccountRepository(es eventing.EventStore) *EventSourcedAccountRepository

func (*EventSourcedAccountRepository) ExistsByEmail

func (e *EventSourcedAccountRepository) ExistsByEmail(ctx context.Context, email string) (bool, error)

func (*EventSourcedAccountRepository) FindByEmail

func (e *EventSourcedAccountRepository) FindByEmail(ctx context.Context, email string) (*Account, error)

func (*EventSourcedAccountRepository) FindByID

func (*EventSourcedAccountRepository) Save

type EventSourcedClubRepository

type EventSourcedClubRepository struct {
	// contains filtered or unexported fields
}

func NewEventSourcedClubRepository

func NewEventSourcedClubRepository(es eventing.EventStore) *EventSourcedClubRepository

func (*EventSourcedClubRepository) ExistsByID

func (e *EventSourcedClubRepository) ExistsByID(ctx context.Context, id ClubID) (bool, error)

func (*EventSourcedClubRepository) ExistsByName

func (e *EventSourcedClubRepository) ExistsByName(ctx context.Context, name string) (bool, error)

func (*EventSourcedClubRepository) FindByID

func (e *EventSourcedClubRepository) FindByID(ctx context.Context, id ClubID) (*Club, error)

func (*EventSourcedClubRepository) Save

func (e *EventSourcedClubRepository) Save(ctx context.Context, club *Club) error

type EventSourcedPersonRepository

type EventSourcedPersonRepository struct {
	// contains filtered or unexported fields
}

func NewEventSourcedPersonRepository

func NewEventSourcedPersonRepository(es eventing.EventStore) *EventSourcedPersonRepository

func (*EventSourcedPersonRepository) ExistsByID

func (e *EventSourcedPersonRepository) ExistsByID(ctx context.Context, id PersonID) (bool, error)

func (*EventSourcedPersonRepository) FindByID

func (*EventSourcedPersonRepository) Save

type EventSourcedSessionRepository

type EventSourcedSessionRepository struct {
	// contains filtered or unexported fields
}

func NewEventSourcedSessionRepository

func NewEventSourcedSessionRepository(es eventing.EventStore) *EventSourcedSessionRepository

func (*EventSourcedSessionRepository) FindByID

func (*EventSourcedSessionRepository) FindByToken

func (e *EventSourcedSessionRepository) FindByToken(ctx context.Context, token SessionToken) (*Session, error)

func (*EventSourcedSessionRepository) Save

type EventSourcedTeamMemberRepository

type EventSourcedTeamMemberRepository struct {
	// contains filtered or unexported fields
}

func (*EventSourcedTeamMemberRepository) FindByID

func (*EventSourcedTeamMemberRepository) FindByTeamAndPerson

func (e *EventSourcedTeamMemberRepository) FindByTeamAndPerson(ctx context.Context, teamID TeamID, personID PersonID) (*TeamMember, error)

func (*EventSourcedTeamMemberRepository) Save

type EventSourcedTeamRepository

type EventSourcedTeamRepository struct {
	// contains filtered or unexported fields
}

func NewEventSourcedTeamRepository

func NewEventSourcedTeamRepository(es eventing.EventStore) *EventSourcedTeamRepository

func (*EventSourcedTeamRepository) ExistsByID

func (e *EventSourcedTeamRepository) ExistsByID(ctx context.Context, id TeamID) (bool, error)

func (*EventSourcedTeamRepository) ExistsByName

func (e *EventSourcedTeamRepository) ExistsByName(ctx context.Context, name string) (bool, error)

func (*EventSourcedTeamRepository) FindByID

func (e *EventSourcedTeamRepository) FindByID(ctx context.Context, id TeamID) (*Team, error)

func (*EventSourcedTeamRepository) Save

func (e *EventSourcedTeamRepository) Save(ctx context.Context, team *Team) error

type HashedPassword

type HashedPassword string

func Argon2idHashPassword

func Argon2idHashPassword(password string) (HashedPassword, error)

Argon2idHashPassword hashes a password using Argon2id.

type InvalidAggregateStateError

type InvalidAggregateStateError struct {
	Aggregate     *eventing.Aggregate
	ExpectedState int
	ActualState   int
}

func NewInvalidAggregateStateError

func NewInvalidAggregateStateError(aggregate *eventing.Aggregate, expectedState, actualState int) *InvalidAggregateStateError

func (InvalidAggregateStateError) Error

type Operator

type Operator struct {
	ActorID AccountID `json:"actor_id"`

	// OnBehalfOf is only set if the operator is acting on behalf of another person.
	// E.g., the system admin is not associated with a person.
	OnBehalfOf *PersonID `json:"on_behalf_of"`
}

Operator is a value object that specifies who operated an event.

func NewOperator

func NewOperator(actorID AccountID, onBehalfOf *PersonID) Operator

NewOperator creates a new Operator.

type PasswordVerifier

type PasswordVerifier interface {
	Verify(password string, hashed HashedPassword) (bool, error)
}

PasswordVerifier compares a password with a hashed password.

type PasswordVerifierFunc

type PasswordVerifierFunc func(password string, hashed HashedPassword) (bool, error)
var Argon2idVerifyPassword PasswordVerifierFunc = argon2idVerifyPassword

Argon2idVerifyPassword implements PasswordVerifier.

func (PasswordVerifierFunc) Verify

func (f PasswordVerifierFunc) Verify(password string, hashed HashedPassword) (bool, error)
type PendingLink struct {
	LinkAs    AccountLink
	Token     PersonLinkToken
	ExpiresAt time.Time
}

type Person

type Person struct {
	eventing.BaseWriter

	ID             PersonID
	Firstname      string
	Lastname       string
	Birthdate      time.Time
	State          PersonState
	OwningClubID   ClubID
	LinkedAccounts []PersonLinkedAccount
	PendingLinks   map[PersonLinkToken]PendingLink
	Creator        Operator
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func NewPerson

func NewPerson(id PersonID) *Person

func (*Person) Claim

func (p *Person) Claim(token PersonLinkToken, id AccountID) error
func (p *Person) FindPendingLink(token PersonLinkToken) (PendingLink, error)

func (*Person) Init

func (p *Person) Init(firstName, lastName string, birthdate time.Time, creator Operator, owningClubID ClubID)
func (p *Person) InitiateNewLink(operator Operator, linkAs AccountLink, token PersonLinkToken, expiresAt time.Time) error

func (*Person) Query

func (p *Person) Query() eventing.JournalQuery

func (*Person) Reduce

func (p *Person) Reduce(events []*eventing.JournalEvent)

type PersonCreatedEvent

type PersonCreatedEvent struct {
	*eventing.EventBase

	FirstName eventing.EncryptedString `json:"firstname"`
	LastName  eventing.EncryptedString `json:"lastname"`
	Birthdate eventing.EncryptedString `json:"birthdate"`

	Creator      Operator `json:"creator"`
	OwningClubID ClubID   `json:"owning_club_id"`
}

func NewPersonCreatedEvent

func NewPersonCreatedEvent(id PersonID, firstName, lastName string, birthdate time.Time, creator Operator, owningClubID ClubID) *PersonCreatedEvent

func (*PersonCreatedEvent) AcceptCrypto

func (p *PersonCreatedEvent) AcceptCrypto(transformer eventing.CryptoTransformer) error

func (*PersonCreatedEvent) DeclareOwners

func (p *PersonCreatedEvent) DeclareOwners() []eventing.AggregateID

func (*PersonCreatedEvent) IsShredded

func (p *PersonCreatedEvent) IsShredded() bool

type PersonID

type PersonID string

type PersonInvitedToTeamEvent

type PersonInvitedToTeamEvent struct {
	*eventing.EventBase

	TeamID       TeamID             `json:"team_id"`
	PersonID     PersonID           `json:"person_id"`
	AssignedRole TeamMemberRoleRole `json:"assigned_role"`
	InvitedBy    Operator           `json:"invited_by"`
}

func NewPersonInvitedToTeamEvent

func NewPersonInvitedToTeamEvent(id TeamMemberID, personID PersonID, teamID TeamID, invitedBy Operator, assignedRole TeamMemberRoleRole) *PersonInvitedToTeamEvent

func (*PersonInvitedToTeamEvent) IsShredded

func (p *PersonInvitedToTeamEvent) IsShredded() bool

func (*PersonInvitedToTeamEvent) LookupValues

func (p *PersonInvitedToTeamEvent) LookupValues() eventing.LookupMap

func (*PersonInvitedToTeamEvent) UniqueConstraintsToAdd

func (p *PersonInvitedToTeamEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type PersonLinkClaimedEvent

type PersonLinkClaimedEvent struct {
	*eventing.EventBase

	AccountID AccountID       `json:"account_id"`
	LinkedAs  AccountLink     `json:"linked_as"`
	UsedToken PersonLinkToken `json:"used_token"`
}

func NewPersonLinkClaimedEvent

func NewPersonLinkClaimedEvent(id PersonID, accountID AccountID, as AccountLink, usedToken PersonLinkToken) *PersonLinkClaimedEvent

func (*PersonLinkClaimedEvent) IsShredded

func (l *PersonLinkClaimedEvent) IsShredded() bool

type PersonLinkInitiatedEvent

type PersonLinkInitiatedEvent struct {
	*eventing.EventBase

	LinkAs    AccountLink     `json:"link_as"`
	Token     PersonLinkToken `json:"token"`
	ExpiresAt time.Time       `json:"expires_at"`
	InvitedBy Operator        `json:"invited_by"`
}

func NewPersonLinkInitiatedEvent

func NewPersonLinkInitiatedEvent(id PersonID, invitedBy Operator, linkAs AccountLink, token PersonLinkToken, expiresAt time.Time) *PersonLinkInitiatedEvent

func (*PersonLinkInitiatedEvent) IsShredded

func (l *PersonLinkInitiatedEvent) IsShredded() bool

type PersonLinkToken

type PersonLinkToken string

type PersonLinkedAccount

type PersonLinkedAccount struct {
	AccountID AccountID
	LinkedAs  AccountLink
	LinkedAt  time.Time
}

type PersonRepository

type PersonRepository interface {
	FindByID(ctx context.Context, id PersonID) (*Person, error)

	Save(ctx context.Context, person *Person) error

	ExistsByID(ctx context.Context, id PersonID) (bool, error)
}

type PersonState

type PersonState int
const (
	PersonStateUnspecified PersonState = iota
	PersonStateActive
)

type Principal

type Principal struct {
	AccountID    AccountID
	SessionToken SessionToken
	Role         PrincipalRole
}

Principal is the authenticated principal of a request.

func NewPrincipal

func NewPrincipal(accountID AccountID, sessionToken SessionToken, role PrincipalRole) *Principal

func PrincipalFromContext

func PrincipalFromContext(ctx context.Context) (*Principal, bool)

PrincipalFromContext extracts the Principal from the context.

type PrincipalRole

type PrincipalRole int

PrincipalRole specifies the type of principal that is accessing the system.

const (
	PrincipalRoleUnspecified PrincipalRole = iota

	// PrincipalRoleRoot is allowed to skip subject verification.
	PrincipalRoleRoot

	// PrincipalRoleRegular will always require subject verification is necessary.
	PrincipalRoleRegular
)

type Repositories

type Repositories interface {
	Account() AccountRepository
	Club() ClubRepository
	Person() PersonRepository
	Session() SessionRepository
	Team() TeamRepository
	TeamMember() TeamMemberRepository
}

type RootAccountCreatedEvent

type RootAccountCreatedEvent struct {
	*eventing.EventBase

	Email          string         `json:"email"`
	HashedPassword HashedPassword `json:"hashed_password"`
	FirstName      string         `json:"first_name"`
	LastName       string         `json:"last_name"`
}

func NewRootAccountCreatedEvent

func NewRootAccountCreatedEvent(id AccountID, email string, hashedPassword HashedPassword, firstName, lastName string) *RootAccountCreatedEvent

func (*RootAccountCreatedEvent) IsShredded

func (r *RootAccountCreatedEvent) IsShredded() bool

func (*RootAccountCreatedEvent) LookupValues

func (r *RootAccountCreatedEvent) LookupValues() eventing.LookupMap

func (*RootAccountCreatedEvent) UniqueConstraintsToAdd

func (r *RootAccountCreatedEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type Session

type Session struct {
	eventing.BaseWriter

	State SessionState

	ID        SessionID
	AccountID AccountID
	Role      PrincipalRole
	Token     SessionToken
}

func NewSession

func NewSession(id SessionID) *Session

func (*Session) Init

func (s *Session) Init(
	token SessionToken,
	accountID AccountID,
	userAgent, ipAddress string,
	validUntil time.Time,
	role PrincipalRole,
) error

func (*Session) Query

func (s *Session) Query() eventing.JournalQuery

func (*Session) Reduce

func (s *Session) Reduce(events []*eventing.JournalEvent)

type SessionCreatedEvent

type SessionCreatedEvent struct {
	*eventing.EventBase

	Token      SessionToken  `json:"token"`
	AccountID  AccountID     `json:"account_id"`
	UserAgent  string        `json:"user_agent"`
	IPAddress  string        `json:"ip_address"`
	ValidUntil time.Time     `json:"valid_until"`
	Role       PrincipalRole `json:"role"`
}

func NewSessionCreatedEvent

func NewSessionCreatedEvent(
	id SessionID,
	token SessionToken,
	accountID AccountID,
	userAgent, ipAddress string,
	validUntil time.Time,
	role PrincipalRole,
) *SessionCreatedEvent

func (*SessionCreatedEvent) IsShredded

func (c *SessionCreatedEvent) IsShredded() bool

func (*SessionCreatedEvent) LookupValues

func (c *SessionCreatedEvent) LookupValues() eventing.LookupMap

func (*SessionCreatedEvent) UniqueConstraintsToAdd

func (c *SessionCreatedEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type SessionID

type SessionID string

SessionID is the unique identifier for a session, distributed to the client.

type SessionRepository

type SessionRepository interface {
	FindByID(ctx context.Context, id SessionID) (*Session, error)
	FindByToken(ctx context.Context, token SessionToken) (*Session, error)

	Save(ctx context.Context, session *Session) error
}

type SessionState

type SessionState int
const (
	SessionStateUnspecified SessionState = iota
	SessionStateActive
)

type SessionToken

type SessionToken string

type Team

type Team struct {
	eventing.BaseWriter

	ID           TeamID
	Name         string
	Slug         string
	OwningClubID ClubID
	CreatedAt    time.Time
	CreatedBy    Operator
	UpdatedAt    time.Time
	State        TeamState
}

func NewTeam

func NewTeam(id TeamID) *Team

func (*Team) Delete

func (t *Team) Delete(deletedBy Operator) error

func (*Team) Init

func (t *Team) Init(name, slug string, owningClubID ClubID, createdBy Operator) error

func (*Team) Query

func (t *Team) Query() eventing.JournalQuery

func (*Team) Reduce

func (t *Team) Reduce(events []*eventing.JournalEvent)

type TeamCreatedEvent

type TeamCreatedEvent struct {
	*eventing.EventBase

	Name         string   `json:"name"`
	Slug         string   `json:"slug"`
	CreatedBy    Operator `json:"created_by"`
	OwningClubID ClubID   `json:"club_id"`
}

func NewTeamCreatedEvent

func NewTeamCreatedEvent(id TeamID, name, slug string, owningClubID ClubID, createdBy Operator) *TeamCreatedEvent

func (*TeamCreatedEvent) IsShredded

func (t *TeamCreatedEvent) IsShredded() bool

func (*TeamCreatedEvent) LookupValues

func (t *TeamCreatedEvent) LookupValues() eventing.LookupMap

func (*TeamCreatedEvent) UniqueConstraintsToAdd

func (t *TeamCreatedEvent) UniqueConstraintsToAdd() []eventing.UniqueConstraint

type TeamDeletedEvent

type TeamDeletedEvent struct {
	*eventing.EventBase

	OwningClubID ClubID   `json:"owning_club_id"`
	DeletedBy    Operator `json:"deleted_by"`
}

func NewTeamDeletedEvent

func NewTeamDeletedEvent(id TeamID, owningClubID ClubID, deletedBy Operator) *TeamDeletedEvent

func (*TeamDeletedEvent) IsShredded

func (t *TeamDeletedEvent) IsShredded() bool

func (*TeamDeletedEvent) LookupRemoves

func (t *TeamDeletedEvent) LookupRemoves() []eventing.LookupFieldName

func (*TeamDeletedEvent) UniqueConstraintsToRemove

func (t *TeamDeletedEvent) UniqueConstraintsToRemove() []eventing.UniqueConstraint

type TeamID

type TeamID string

type TeamMember

type TeamMember struct {
	eventing.BaseWriter

	State     TeamMemberState
	ID        TeamMemberID
	PersonID  PersonID
	TeamID    TeamID
	InvitedBy Operator
	JoinedAt  time.Time
}

func NewTeamMember

func NewTeamMember(id TeamMemberID, teamID TeamID, personID PersonID) *TeamMember

func NewTeamMemberByID

func NewTeamMemberByID(id TeamMemberID) *TeamMember

func (*TeamMember) Invite

func (m *TeamMember) Invite(operator Operator, assignedRole TeamMemberRoleRole) error

func (*TeamMember) Query

func (m *TeamMember) Query() eventing.JournalQuery

func (*TeamMember) Reduce

func (m *TeamMember) Reduce(events []*eventing.JournalEvent)

type TeamMemberID

type TeamMemberID string

type TeamMemberRepository

type TeamMemberRepository interface {
	FindByID(ctx context.Context, id TeamMemberID) (*TeamMember, error)
	FindByTeamAndPerson(ctx context.Context, teamID TeamID, person PersonID) (*TeamMember, error)

	Save(ctx context.Context, member *TeamMember) error
}

type TeamMemberRoleRole

type TeamMemberRoleRole string

TeamMemberRoleRole is the function of the team member (e.g. coach, player, etc.).

type TeamMemberState

type TeamMemberState int
const (
	TeamMemberStateUnspecified TeamMemberState = iota
	TeamMemberStateActive
)

type TeamRepository

type TeamRepository interface {
	FindByID(ctx context.Context, id TeamID) (*Team, error)

	Save(ctx context.Context, team *Team) error

	ExistsByName(ctx context.Context, name string) (bool, error)
	ExistsByID(ctx context.Context, id TeamID) (bool, error)
}

type TeamState

type TeamState int
const (
	TeamStateUnspecified TeamState = iota
	TeamStateActive
	TeamStateDeleted
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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