domain

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventTypeNotFound                       = errors.New("event_type not found")
	ErrEventTypeActionNotFound                 = errors.New("event type action not found")
	ErrSourceNotFound                          = errors.New("source not found")
	ErrSourceWithProvidedNameExists            = errors.New("the source with the name provided already exists")
	ErrEventTypeExists                         = errors.New("the action specified for the event type already exists")
	ErrEventTypeVersionExists                  = errors.New("the event_type_version already exists")
	ErrVersionOneOfEventTypeCannotBeRolledBack = errors.New("version 1 of event type cannot be rolledback")
	ErrEventNotFound                           = errors.New("event not found")
)
View Source
var (
	ErrUserNotFound                            = errors.New("user not found")
	ErrAuthenticationFailedCredentialsMismatch = errors.New("authentication failed due to credentials mismatch")
)
View Source
var (
	UserRoleAdmin  = UserRole("admin")
	UserRoleMember = UserRole("member")
)
View Source
var (
	ErrSourceNotFoundWhileSavingEvent = errors.New("source not found while saving event")
)
View Source
var ErrTokenNotFound = errors.New("token not found")

Functions

This section is empty.

Types

type Actor

type Actor struct {
	ID        string
	ActorType string
	Name      *string
	Metadata  *Metadata
}

type Context

type Context struct {
	Location  string
	UserAgent *string
}

type Email

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

func NewEmail

func NewEmail(email string) (Email, error)

func (Email) Empty

func (e Email) Empty() bool

func (Email) String

func (e Email) String() string

type Event

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

func MarshallToEvent

func MarshallToEvent(
	id, sourceID, action string,
	version int,
	actor Actor,
	targets []Target,
	ctx Context,
	metadata *Metadata,
	occurredAt time.Time,
) Event

func NewEvent

func NewEvent(
	sourceID ID,
	version int,
	action string,
	actor Actor,
	targets []Target,
	context Context,
	metadata *Metadata,
	occurredAt time.Time,
) (Event, error)

func (*Event) Action

func (e *Event) Action() string

func (*Event) Actor

func (e *Event) Actor() Actor

func (*Event) Context

func (e *Event) Context() Context

func (*Event) ID

func (e *Event) ID() ID

func (*Event) Metadata

func (e *Event) Metadata() *Metadata

func (*Event) OccurredAt

func (e *Event) OccurredAt() time.Time

func (*Event) SourceID

func (e *Event) SourceID() ID

func (*Event) Targets

func (e *Event) Targets() []Target

func (*Event) Version

func (e *Event) Version() int

type EventRepository

type EventRepository interface {
	FindByID(ctx context.Context, id ID) (Event, error)
	Save(ctx context.Context, evt Event, token TokenValue) error
}

type EventType

type EventType struct {
	Action                       string
	ShouldValidateMetadataSchema bool
	LastVersion                  EventTypeVersion
	CreatedAt                    time.Time
	UpdatedAt                    time.Time
}

type EventTypeRepository

type EventTypeRepository interface {
	Delete(ctx context.Context, action string) error
	Save(ctx context.Context, eventType EventType) error
	RollbackVersion(ctx context.Context, action string) error
	SaveVersion(ctx context.Context, action string, targetTypes []string, schema Schema) error
}

type EventTypeVersion

type EventTypeVersion struct {
	Version     int
	TargetTypes []string
	Schema      Schema
	CreatedAt   time.Time
}

func NewEventTypeVersion

func NewEventTypeVersion(targetTypes []string, schema Schema) EventTypeVersion

type Export

type Export struct {
	ID        string
	State     string
	Url       string
	Targets   []string
	Actors    []string
	Actions   []string
	RangeFrom time.Time
	RangeTo   time.Time
	CreatedAt time.Time
}

type ID

type ID string

func NewID

func NewID() ID

func (ID) Empty

func (i ID) Empty() bool

func (ID) String

func (i ID) String() string

type Metadata

type Metadata = map[string]interface{}

type Password

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

func NewPassword

func NewPassword(plainTextPassword string) (Password, error)

func (Password) Empty

func (p Password) Empty() bool

func (Password) IsEqual

func (p Password) IsEqual(plainTextPassword string) bool

func (Password) String

func (p Password) String() string

type Schema

type Schema []byte

type Source

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

func MarshallToSource

func MarshallToSource(id, name string, createdAt, updatedAt time.Time) Source

func NewSource

func NewSource(name string) (*Source, error)

func (Source) CreatedAt

func (s Source) CreatedAt() time.Time

func (Source) ID

func (s Source) ID() ID

func (Source) Name

func (s Source) Name() string

func (Source) UpdatedAt

func (s Source) UpdatedAt() time.Time

type SourceRepository

type SourceRepository interface {
	Save(ctx context.Context, s *Source) error
}

type Target

type Target struct {
	ID         string
	Name       *string
	TargetType string
	Metadata   *Metadata
}

type Token

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

func MarshallToToken

func MarshallToToken(id, sourceID, value, name string, createdAt time.Time) *Token

func NewToken

func NewToken(sourceID ID, name string) (*Token, error)

func (*Token) CreatedAt

func (t *Token) CreatedAt() time.Time

func (*Token) ID

func (t *Token) ID() ID

func (*Token) MaskedValue

func (t *Token) MaskedValue() string

func (*Token) Name

func (t *Token) Name() string

func (*Token) SourceID

func (t *Token) SourceID() ID

func (*Token) Value

func (t *Token) Value() TokenValue

type TokenRepository

type TokenRepository interface {
	Save(ctx context.Context, token *Token) error
	Delete(ctx context.Context, id, sourceID ID) error
	QueryAll(ctx context.Context, sourceID ID) ([]*Token, error)
}

type TokenValue

type TokenValue string

func NewTokenValue

func NewTokenValue() TokenValue

func (TokenValue) String

func (t TokenValue) String() string

type User

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

func MarshallToUser

func MarshallToUser(id, email, password, role string, createdAt time.Time) *User

func NewUser

func NewUser(email Email, password Password, role UserRole) (*User, error)

func (*User) CreatedAt

func (u *User) CreatedAt() time.Time

func (*User) Email

func (u *User) Email() Email

func (*User) ID

func (u *User) ID() ID

func (*User) Password

func (u *User) Password() Password

func (*User) Role

func (u *User) Role() UserRole

type UserRepository

type UserRepository interface {
	FindByEmail(ctx context.Context, email Email) (*User, error)
	FindByID(ctx context.Context, id ID) (*User, error)
	Save(ctx context.Context, user *User) error
}

type UserRole

type UserRole string

func (UserRole) String

func (r UserRole) String() string

func (UserRole) Valid

func (r UserRole) Valid() bool

Jump to

Keyboard shortcuts

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