storage

package
v0.0.0-...-04334a3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 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 ConnectionHealth

type ConnectionHealth struct {
	TotalConns    int32 `json:"total_conns"`
	IdleConns     int32 `json:"idle_conns"`
	AcquiredConns int32 `json:"acquired_conns"`
	MaxConns      int32 `json:"max_conns"`
}

type CreateDeviceParams

type CreateDeviceParams struct {
	ID   uuid.UUID
	Name string
}

type CreatePermissionParams

type CreatePermissionParams struct {
	ID          uuid.UUID
	Name        string
	Description string
	Action      string
	RoleLevel   RoleType
}

type CreateSessionParams

type CreateSessionParams struct {
	ID               uuid.UUID
	UserID           uuid.UUID
	AccessToken      string
	RefreshToken     string
	DeviceID         uuid.UUID
	Type             SessionType
	Status           SessionStatusType
	IpAddress        string
	UserAgent        string
	AccessExpiresAt  int64
	RefreshExpiresAt int64
}

type CreateUserActionParams

type CreateUserActionParams struct {
	ID     uuid.UUID
	Name   string
	UserID uuid.UUID
}

type CreateUserDeviceParams

type CreateUserDeviceParams struct {
	UserID   uuid.UUID
	DeviceID uuid.UUID
}

type CreateUserParams

type CreateUserParams struct {
	ID           uuid.UUID
	Username     string
	Email        string
	PasswordHash string
	Role         RoleType
}

type CreateUserPermissionParams

type CreateUserPermissionParams struct {
	PermissionID uuid.UUID
	UserID       uuid.UUID
	GrantedBy    *uuid.UUID
	Granted      bool
	ExpiresAt    *int64
}

type CreateUserPreferencesParams

type CreateUserPreferencesParams struct {
	ID                  uuid.UUID
	UserID              uuid.UUID
	Theme               ThemeType
	OnboardingCompleted bool
	Language            string
}

type CreateUserProfileParams

type CreateUserProfileParams struct {
	UserID    uuid.UUID
	FirstName string
	LastName  string
	BirthDate *int64
	Alias     string
	Bio       string
}

type CreateUserStateParams

type CreateUserStateParams struct {
	UserID   uuid.UUID
	Verified bool
	Status   UserStatusType
}

type CreateUserVerificationParams

type CreateUserVerificationParams struct {
	ActionID  uuid.UUID
	Token     string
	ExpiresAt int64
}

type DatabaseHealth

type DatabaseHealth struct {
	IsConnected  bool          `json:"is_connected"`
	LastPing     time.Time     `json:"last_ping"`
	PingDuration time.Duration `json:"ping_duration"`
	ErrorMessage string        `json:"error_message,omitempty"`
}

type DeleteUserPermissionParams

type DeleteUserPermissionParams struct {
	PermissionID uuid.UUID
	UserID       uuid.UUID
}

type DeviceStore

type DeviceStore interface {
	CreateDevice(ctx context.Context, arg *CreateDeviceParams) error
	GetDeviceByName(ctx context.Context, name string) (*DivaDevice, error)
	GetDeviceByID(ctx context.Context, id uuid.UUID) (*DivaDevice, error)
	ListAllDevices(ctx context.Context) ([]DivaDevice, error)
	CreateUserDevice(ctx context.Context, arg *CreateUserDeviceParams) error
	GetUserDevice(ctx context.Context, userID uuid.UUID, deviceID uuid.UUID) (*DivaUserDevice, error)
	ListUserDevices(ctx context.Context, userID uuid.UUID) ([]DivaUserDevice, error)
	DeleteUserDevice(ctx context.Context, userID uuid.UUID, deviceID uuid.UUID) error
}

type DivaAction

type DivaAction struct {
	ID     uuid.UUID
	Name   string
	UserID uuid.UUID
}

type DivaActionVerification

type DivaActionVerification struct {
	ActionID  uuid.UUID
	Token     string
	Verified  bool
	ExpiresAt int64
	UsedAt    *int64
}

type DivaDevice

type DivaDevice struct {
	ID        uuid.UUID
	Name      string
	CreatedAt int64
	UpdatedAt int64
}

type DivaPermission

type DivaPermission struct {
	ID          uuid.UUID
	Name        string
	Description string
	Action      string
	RoleLevel   RoleType
	CreatedAt   int64
	UpdatedAt   int64
	DeletedAt   *int64
}

type DivaSession

type DivaSession struct {
	ID               uuid.UUID
	UserID           uuid.UUID
	AccessToken      string
	RefreshToken     string
	DeviceID         uuid.UUID
	Type             SessionType
	Status           SessionStatusType
	IpAddress        string
	UserAgent        string
	AccessExpiresAt  int64
	RefreshExpiresAt int64
	CreatedAt        int64
	UpdatedAt        int64
	DeletedAt        *int64
}

type DivaUser

type DivaUser struct {
	ID           uuid.UUID
	Username     string
	Email        string
	PhoneNumber  string
	PasswordHash string
	Role         RoleType
	CreatedAt    int64
	UpdatedAt    int64
	DeletedAt    *int64
}

type DivaUserDevice

type DivaUserDevice struct {
	UserID    uuid.UUID
	DeviceID  uuid.UUID
	CreatedAt int64
	UpdatedAt int64
}

type DivaUserPermission

type DivaUserPermission struct {
	PermissionID uuid.UUID
	UserID       uuid.UUID
	GrantedBy    *uuid.UUID
	Granted      bool
	GrantedAt    int64
	ExpiresAt    *int64
	UpdatedAt    int64
}

type DivaUserPreference

type DivaUserPreference struct {
	ID                  uuid.UUID
	UserID              uuid.UUID
	Theme               ThemeType
	OnboardingCompleted bool
	Language            string
	LastSyncAt          int64
	CreatedAt           int64
	UpdatedAt           int64
}

type DivaUserProfile

type DivaUserProfile struct {
	UserID    uuid.UUID
	FirstName string
	LastName  string
	BirthDate *int64
	Alias     string
	Bio       string
	Avatar    string
	UpdatedAt int64
}

type DivaUserState

type DivaUserState struct {
	UserID       uuid.UUID
	Verified     bool
	Status       UserStatusType
	LastActiveAt int64
	UpdatedAt    int64
}

type GetUserActionByUserAndNameParams

type GetUserActionByUserAndNameParams struct {
	UserID uuid.UUID
	Name   string
}

type GetUserPermissionByNameParams

type GetUserPermissionByNameParams struct {
	UserID uuid.UUID
	Name   string
}

type GetUserPermissionParams

type GetUserPermissionParams struct {
	PermissionID uuid.UUID
	UserID       uuid.UUID
}

type HealthResult

type HealthResult struct {
	Status       string            `json:"status"`
	Message      string            `json:"message"`
	Timestamp    time.Time         `json:"timestamp"`
	ResponseTime time.Duration     `json:"response_time"`
	Database     DatabaseHealth    `json:"database"`
	Connection   ConnectionHealth  `json:"connection"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

type ListPermissionsParams

type ListPermissionsParams struct {
	Limit  int64
	Offset int64
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int64
	Offset int64
}

type MediaType

type MediaType string
const (
	MediaTypeTypeAUDIO       MediaType = "AUDIO"
	MediaTypeTypeIMAGE       MediaType = "IMAGE"
	MediaTypeTypeVIDEO       MediaType = "VIDEO"
	MediaTypeTypeUNSPECIFIED MediaType = "UNSPECIFIED"
)

type PermissionStore

type PermissionStore interface {
	CreatePermission(ctx context.Context, arg *CreatePermissionParams) error
	GetPermissionByID(ctx context.Context, id uuid.UUID) (*DivaPermission, error)
	GetPermissionByName(ctx context.Context, action string) (*DivaPermission, error)
	ListPermissions(ctx context.Context, arg *ListPermissionsParams) ([]DivaPermission, error)
	CountPermissions(ctx context.Context) (int64, error)
	UpdatePermission(ctx context.Context, arg *UpdatePermissionParams) error
	UpdatePermissionAction(ctx context.Context, arg *UpdatePermissionActionParams) error
	UpdatePermissionRoleLevel(ctx context.Context, arg *UpdatePermissionRoleLevelParams) error
	DeletePermission(ctx context.Context, id uuid.UUID) error
	SoftDeletePermission(ctx context.Context, id uuid.UUID) error
	RestorePermission(ctx context.Context, id uuid.UUID) error
}

type RoleType

type RoleType string
const (
	RoleTypeUSER      RoleType = "USER"
	RoleTypeMODERATOR RoleType = "MODERATOR"
	RoleTypeADMIN     RoleType = "ADMIN"
)

type SessionStatusType

type SessionStatusType string
const (
	SessionStatusTypeACTIVE  SessionStatusType = "ACTIVE"
	SessionStatusTypeEXPIRED SessionStatusType = "EXPIRED"
	SessionStatusTypeCLOSED  SessionStatusType = "CLOSED"
)

type SessionStore

type SessionStore interface {
	CreateSession(ctx context.Context, arg *CreateSessionParams) error
	ListSessions(ctx context.Context) ([]DivaSession, error)
	GetSessionByID(ctx context.Context, id uuid.UUID) (*DivaSession, error)
	UpdateSession(ctx context.Context, arg *UpdateSessionParams) error
	UpdateSessionStatus(ctx context.Context, arg *UpdateSessionStatusParams) error
	CloseExpiredSessions(ctx context.Context) error
	SoftDeleteSession(ctx context.Context, id uuid.UUID) error
	// deletes soft deleted
	DeleteSessionsForever(ctx context.Context) error

	ListSessionsByUser(ctx context.Context, userID uuid.UUID) ([]DivaSession, error)
	CloseAllByUser(ctx context.Context, userID uuid.UUID) error
}

type SessionType

type SessionType string
const (
	SessionTypeNORMAL   SessionType = "NORMAL"
	SessionTypeTEMPORAL SessionType = "TEMPORAL"
)

type Storage

type Storage interface {
	Close() error
	Health(ctx context.Context) HealthResult
	UserStore() UserStore
	PermissionStore() PermissionStore
	DeviceStore() DeviceStore
	SessionStore() SessionStore
	UserStateStore() UserStateStore
	UserProfileStore() UserProfileStore
	UserPreferenceStore() UserPreferenceStore
	UserPermissionStore() UserPermissionStore
	UserActionStore() UserActionStore
	UserVerificationStore() UserVerificationStore
}

type ThemeType

type ThemeType string
const (
	ThemeTypeLIGHT  ThemeType = "LIGHT"
	ThemeTypeDARK   ThemeType = "DARK"
	ThemeTypeSYSTEM ThemeType = "SYSTEM"
)

type UpdateEmailParams

type UpdateEmailParams struct {
	Email string
	ID    uuid.UUID
}

type UpdatePasswordParams

type UpdatePasswordParams struct {
	PasswordHash string
	ID           uuid.UUID
}

type UpdatePermissionActionParams

type UpdatePermissionActionParams struct {
	Action string
	ID     uuid.UUID
}

type UpdatePermissionParams

type UpdatePermissionParams struct {
	ID          uuid.UUID
	Name        string
	Description string
}

type UpdatePermissionRoleLevelParams

type UpdatePermissionRoleLevelParams struct {
	RoleLevel RoleType
	ID        uuid.UUID
}

type UpdatePhoneNumberParams

type UpdatePhoneNumberParams struct {
	PhoneNumber string
	ID          uuid.UUID
}

type UpdateRoleParams

type UpdateRoleParams struct {
	Role RoleType
	ID   uuid.UUID
}

type UpdateSessionParams

type UpdateSessionParams struct {
	ID               uuid.UUID
	AccessToken      string
	RefreshToken     string
	IpAddress        string
	AccessExpiresAt  int64
	RefreshExpiresAt int64
}

type UpdateSessionStatusParams

type UpdateSessionStatusParams struct {
	Status SessionStatusType
	ID     uuid.UUID
}

type UpdateUserPermissionParams

type UpdateUserPermissionParams struct {
	PermissionID uuid.UUID
	UserID       uuid.UUID
	Granted      bool
	ExpiresAt    *int64
}

type UpdateUserPreferencesParams

type UpdateUserPreferencesParams struct {
	ID       uuid.UUID
	Theme    ThemeType
	Language string
}

type UpdateUserProfileAvatarParams

type UpdateUserProfileAvatarParams struct {
	Avatar string
	UserID uuid.UUID
}

type UpdateUserProfileParams

type UpdateUserProfileParams struct {
	UserID    uuid.UUID
	FirstName string
	LastName  string
	BirthDate *int64
	Alias     string
	Bio       string
}

type UpdateUserStatusParams

type UpdateUserStatusParams struct {
	Status UserStatusType
	UserID uuid.UUID
}

type UpdateUserVerificationParams

type UpdateUserVerificationParams struct {
	Verified bool
	ActionID uuid.UUID
}

type UpdateUserVerifiedParams

type UpdateUserVerifiedParams struct {
	Verified bool
	UserID   uuid.UUID
}

type UpdateUsernameParams

type UpdateUsernameParams struct {
	Username string
	ID       uuid.UUID
}

type UserActionStore

type UserActionStore interface {
	CreateUserAction(ctx context.Context, arg *CreateUserActionParams) error
	GetUserActionByID(ctx context.Context, id uuid.UUID) (*DivaAction, error)
	GetUserActionByUserAndName(ctx context.Context, arg *GetUserActionByUserAndNameParams) (*DivaAction, error)
	ListActionsByUser(ctx context.Context, userID uuid.UUID) ([]DivaAction, error)
	DeleteUserAction(ctx context.Context, id uuid.UUID) error
	DeleteUserActionByUser(ctx context.Context, userID uuid.UUID) error
	DeleteExpiredActions(ctx context.Context) error
}

type UserPermissionStore

type UserPermissionStore interface {
	CreateUserPermission(ctx context.Context, arg *CreateUserPermissionParams) error
	GetUserPermission(ctx context.Context, arg *GetUserPermissionParams) (*DivaUserPermission, error)
	GetUserPermissionByName(ctx context.Context, arg *GetUserPermissionByNameParams) (*DivaUserPermission, error)
	GetUserPermissions(ctx context.Context, userID uuid.UUID) ([]DivaUserPermission, error)
	UpdateUserPermission(ctx context.Context, arg *UpdateUserPermissionParams) error
	DeleteUserPermission(ctx context.Context, arg *DeleteUserPermissionParams) error
	DeleteExpiredUserPermissions(ctx context.Context) error
}

type UserPreferenceStore

type UserPreferenceStore interface {
	CreateUserPreferences(ctx context.Context, arg *CreateUserPreferencesParams) error
	GetPreferencesByID(ctx context.Context, id uuid.UUID) (*DivaUserPreference, error)
	GetPreferencesByUser(ctx context.Context, userID uuid.UUID) ([]DivaUserPreference, error)
	UpdateUserPreferences(ctx context.Context, arg *UpdateUserPreferencesParams) error
}

type UserProfileStore

type UserProfileStore interface {
	CreateUserProfile(ctx context.Context, arg *CreateUserProfileParams) error
	GetUserProfileByUserID(ctx context.Context, userID uuid.UUID) (*DivaUserProfile, error)
	UpdateUserProfile(ctx context.Context, arg *UpdateUserProfileParams) error
	UpdateUserProfileAvatar(ctx context.Context, arg *UpdateUserProfileAvatarParams) error
}

type UserStateStore

type UserStateStore interface {
	CreateUserState(ctx context.Context, arg *CreateUserStateParams) error
	GetUserStateByUserID(ctx context.Context, userID uuid.UUID) (*DivaUserState, error)
	UpdateLastActiveAt(ctx context.Context, userID uuid.UUID) error
	UpdateUserStatus(ctx context.Context, arg *UpdateUserStatusParams) error
	UpdateUserVerified(ctx context.Context, arg *UpdateUserVerifiedParams) error
}

type UserStatusType

type UserStatusType string
const (
	UserStatusTypeACTIVE    UserStatusType = "ACTIVE"
	UserStatusTypeSUSPENDED UserStatusType = "SUSPENDED"
	UserStatusTypeINACTIVE  UserStatusType = "INACTIVE"
)

type UserStore

type UserStore interface {
	CreateUser(ctx context.Context, arg *CreateUserParams) error
	GetUserByID(ctx context.Context, id uuid.UUID) (*DivaUser, error)
	GetUserByEmail(ctx context.Context, email string) (*DivaUser, error)
	GetUserByUsername(ctx context.Context, username string) (*DivaUser, error)
	GetUserByUsernameOrEmail(ctx context.Context, identifier string) (*DivaUser, error)
	ListUsers(ctx context.Context, arg *ListUsersParams) ([]DivaUser, error)
	CountUsers(ctx context.Context) (int64, error)
	UpdateUsername(ctx context.Context, arg *UpdateUsernameParams) error
	UpdateEmail(ctx context.Context, arg *UpdateEmailParams) error
	UpdatePassword(ctx context.Context, arg *UpdatePasswordParams) error
	UpdatePhoneNumber(ctx context.Context, arg *UpdatePhoneNumberParams) error
	UpdateRole(ctx context.Context, arg *UpdateRoleParams) error
	DeleteUser(ctx context.Context, id uuid.UUID) error
	SoftDeleteUser(ctx context.Context, id uuid.UUID) error
	RestoreUser(ctx context.Context, id uuid.UUID) error
}

type UserVerificationStore

type UserVerificationStore interface {
	CreateUserVerification(ctx context.Context, arg *CreateUserVerificationParams) error
	GetUserVerification(ctx context.Context, actionID uuid.UUID) (*DivaActionVerification, error)
	UpdateUserVerification(ctx context.Context, arg *UpdateUserVerificationParams) error
	DeleteUserVerification(ctx context.Context, actionID uuid.UUID) error
}

Directories

Path Synopsis
db
db

Jump to

Keyboard shortcuts

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