activitylog

package
v0.0.0-...-e5cc3ab Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, input CreateInput) error

func MarshalData

func MarshalData(input CreateInput) ([]byte, error)

func NewLoaderContext

func NewLoaderContext(ctx context.Context, dbConn *pgxpool.Pool) context.Context

func RegisterFilter

func RegisterFilter(activityType ActivityLogActivityType, action ActivityLogEntryAction, resourceType ActivityLogEntryResourceType)

func RegisterTransformer

func RegisterTransformer(resourceType ActivityLogEntryResourceType, transformer Transformer)

func RunRefresher

func RunRefresher(ctx context.Context, dbtx activitylogsql.DBTX, log logrus.FieldLogger)

func TransformData

func TransformData[T any](entry GenericActivityLogEntry, f func(*T) *T) (*T, error)

TransformData unmarshals activity log entry data and calls the provided transformer function with the data as argument.

func UnmarshalData

func UnmarshalData[T any](entry GenericActivityLogEntry) (*T, error)

UnmarshalData unmarshals activity log entry data. Its inverse is MarshalData.

Types

type ActivityLogActivityType

type ActivityLogActivityType string

func (ActivityLogActivityType) IsValid

func (e ActivityLogActivityType) IsValid() bool

func (ActivityLogActivityType) MarshalGQL

func (e ActivityLogActivityType) MarshalGQL(w io.Writer)

func (ActivityLogActivityType) String

func (e ActivityLogActivityType) String() string

func (*ActivityLogActivityType) UnmarshalGQL

func (e *ActivityLogActivityType) UnmarshalGQL(v any) error

type ActivityLogEntry

type ActivityLogEntry interface {
	model.Node
	GetUUID() uuid.UUID
	ID() ident.Ident
}

func Get

func Get(ctx context.Context, uid uuid.UUID) (ActivityLogEntry, error)

func GetByIdent

func GetByIdent(ctx context.Context, id ident.Ident) (ActivityLogEntry, error)

type ActivityLogEntryAction

type ActivityLogEntryAction string
const (
	ActivityLogEntryActionAdded   ActivityLogEntryAction = "ADDED"
	ActivityLogEntryActionCreated ActivityLogEntryAction = "CREATED"
	ActivityLogEntryActionDeleted ActivityLogEntryAction = "DELETED"
	ActivityLogEntryActionRemoved ActivityLogEntryAction = "REMOVED"
	ActivityLogEntryActionUpdated ActivityLogEntryAction = "UPDATED"
)

type ActivityLogEntryConnection

type ActivityLogEntryConnection = pagination.Connection[ActivityLogEntry]

func ListForResource

func ListForResource(ctx context.Context, resourceType ActivityLogEntryResourceType, resourceName string, page *pagination.Pagination, filter *ActivityLogFilter) (*ActivityLogEntryConnection, error)

func ListForResourceTeamAndEnvironment

func ListForResourceTeamAndEnvironment(ctx context.Context, resourceType ActivityLogEntryResourceType, teamSlug slug.Slug, resourceName, environmentName string, page *pagination.Pagination, filter *ActivityLogFilter) (*ActivityLogEntryConnection, error)

func ListForTeam

func ListForTeam(ctx context.Context, teamSlug slug.Slug, page *pagination.Pagination, filter *ActivityLogFilter) (*ActivityLogEntryConnection, error)

type ActivityLogEntryEdge

type ActivityLogEntryEdge = pagination.Edge[ActivityLogEntry]

type ActivityLogEntryResourceType

type ActivityLogEntryResourceType string

type ActivityLogFilter

type ActivityLogFilter struct {
	ActivityTypes []ActivityLogActivityType `json:"activityTypes,omitempty"`
}

type ActivityLogger

type ActivityLogger interface {
	IsActivityLogger()
}

type CreateInput

type CreateInput struct {
	Action       ActivityLogEntryAction
	Actor        authz.AuthenticatedUser
	ResourceType ActivityLogEntryResourceType
	ResourceName string

	Data            any        // optional
	EnvironmentName *string    // optional
	TeamSlug        *slug.Slug // optional
}

type GenericActivityLogEntry

type GenericActivityLogEntry struct {
	Actor           string                       `json:"actor"`
	CreatedAt       time.Time                    `json:"createdAt"`
	EnvironmentName *string                      `json:"environmentName,omitempty"`
	Message         string                       `json:"message"`
	ResourceType    ActivityLogEntryResourceType `json:"resourceType"`
	ResourceName    string                       `json:"resourceName"`
	TeamSlug        *slug.Slug                   `json:"teamSlug,omitempty"`
	Action          ActivityLogEntryAction       `json:"-"`
	UUID            uuid.UUID                    `json:"-"`
	Data            []byte                       `json:"-"`
}

func (GenericActivityLogEntry) GetUUID

func (a GenericActivityLogEntry) GetUUID() uuid.UUID

func (GenericActivityLogEntry) ID

func (GenericActivityLogEntry) IsNode

func (GenericActivityLogEntry) IsNode()

func (GenericActivityLogEntry) WithMessage

type Transformer

type Transformer = func(entry GenericActivityLogEntry) (ActivityLogEntry, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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