activitylog

package
v0.0.0-...-8bea463 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 19 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 RegisterTransformer

func RegisterTransformer(resourceType ActivityLogEntryResourceType, transformer Transformer)

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 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) (*ActivityLogEntryConnection, error)

func ListForTeam

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

type ActivityLogEntryEdge

type ActivityLogEntryEdge = pagination.Edge[ActivityLogEntry]

type ActivityLogEntryResourceType

type ActivityLogEntryResourceType string

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