models

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 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 AccountMemberModel

type AccountMemberModel struct {
	AccountID string    `gorm:"primaryKey"`
	AgentID   string    `gorm:"primaryKey;index:idx_account_member_agent"`
	RoleID    string    `gorm:"not null"`
	CreatedAt time.Time `gorm:"not null"`
}

AccountMemberModel is the GORM model for account membership (join table).

func AccountMemberModelFrom

func AccountMemberModelFrom(accountID, agentID, roleID string) *AccountMemberModel

AccountMemberModelFrom creates an AccountMemberModel from individual fields.

func (AccountMemberModel) TableName

func (AccountMemberModel) TableName() string

type AccountModel

type AccountModel struct {
	ID          string `gorm:"primaryKey"`
	Name        string `gorm:"not null"`
	AccountType string `gorm:"not null;default:personal"`
	Active      bool   `gorm:"not null;default:true"`
	CreatedAt   time.Time
}

AccountModel is the GORM model for the Account aggregate.

func AccountModelFromEntity

func AccountModelFromEntity(e *entities.Account) *AccountModel

AccountModelFromEntity converts an Account domain entity to a GORM model.

func (AccountModel) TableName

func (AccountModel) TableName() string

func (*AccountModel) ToEntity

func (m *AccountModel) ToEntity() (*entities.Account, error)

ToEntity converts the GORM model to an Account domain entity.

type AgentModel

type AgentModel struct {
	ID        string `gorm:"primaryKey"`
	Name      string `gorm:"not null"`
	AgentType string `gorm:"not null;default:foaf:Person"`
	Status    string `gorm:"not null;default:active"`
	CreatedAt time.Time
}

AgentModel is the GORM model for the Agent aggregate.

func AgentModelFromEntity

func AgentModelFromEntity(e *entities.Agent) *AgentModel

AgentModelFromEntity converts an Agent domain entity to a GORM model.

func (AgentModel) TableName

func (AgentModel) TableName() string

func (*AgentModel) ToEntity

func (m *AgentModel) ToEntity() (*entities.Agent, error)

ToEntity converts the GORM model to an Agent domain entity.

type AuthSessionModel

type AuthSessionModel struct {
	ID             string `gorm:"primaryKey"`
	AgentID        string `gorm:"not null;index"`
	AccountID      string
	CredentialID   string `gorm:"not null"`
	Active         bool   `gorm:"not null;default:true"`
	CreatedAt      time.Time
	ExpiresAt      time.Time
	LastAccessedAt time.Time
	IPAddress      string
	UserAgent      string
}

AuthSessionModel is the GORM model for the AuthSession aggregate.

func AuthSessionModelFromEntity

func AuthSessionModelFromEntity(e *entities.AuthSession) *AuthSessionModel

AuthSessionModelFromEntity converts an AuthSession domain entity to a GORM model.

func (AuthSessionModel) TableName

func (AuthSessionModel) TableName() string

func (*AuthSessionModel) ToEntity

func (m *AuthSessionModel) ToEntity() (*entities.AuthSession, error)

ToEntity converts the GORM model to an AuthSession domain entity.

type CredentialModel

type CredentialModel struct {
	ID             string `gorm:"primaryKey"`
	AgentID        string `gorm:"not null;index"`
	Provider       string `gorm:"not null;uniqueIndex:idx_provider_user"`
	ProviderUserID string `gorm:"not null;uniqueIndex:idx_provider_user"`
	Email          string `gorm:"index:idx_email"`
	DisplayName    string
	Active         bool `gorm:"not null;default:true"`
	CreatedAt      time.Time
	LastUsedAt     time.Time
}

CredentialModel is the GORM model for the Credential aggregate.

func CredentialModelFromEntity

func CredentialModelFromEntity(e *entities.Credential) *CredentialModel

CredentialModelFromEntity converts a Credential domain entity to a GORM model.

func (CredentialModel) TableName

func (CredentialModel) TableName() string

func (*CredentialModel) ToEntity

func (m *CredentialModel) ToEntity() (*entities.Credential, error)

ToEntity converts the GORM model to a Credential domain entity.

type InviteModel

type InviteModel struct {
	ID             string `gorm:"primaryKey"`
	AccountID      string `gorm:"not null;index"`
	Email          string `gorm:"not null;index"`
	RoleID         string `gorm:"not null"`
	InviterAgentID string `gorm:"not null"`
	InviteeAgentID string `gorm:"not null"`
	Status         string `gorm:"not null;index;default:pending"`
	ExpiresAt      time.Time
	AcceptedAt     time.Time
	CreatedAt      time.Time
}

InviteModel is the GORM model for the Invite aggregate.

func InviteModelFromEntity

func InviteModelFromEntity(e *entities.Invite) *InviteModel

InviteModelFromEntity converts an Invite domain entity to a GORM model.

func (InviteModel) TableName

func (InviteModel) TableName() string

func (*InviteModel) ToEntity

func (m *InviteModel) ToEntity() (*entities.Invite, error)

ToEntity converts the GORM model to an Invite domain entity.

type PasswordCredentialModel

type PasswordCredentialModel struct {
	ID           string `gorm:"primaryKey"`
	CredentialID string `gorm:"not null;uniqueIndex:idx_password_credential_id"`
	Algorithm    string `gorm:"not null"`
	Hash         string `gorm:"not null"`
	// Salt is a plaintext suffix appended to the user-supplied plaintext
	// before bcrypt comparison. Empty for credentials registered through
	// pericarp; non-empty only for legacy hashes imported via
	// ImportPasswordCredential with ImportWithSalt.
	Salt           string `gorm:"not null;default:'';size:64"`
	CreatedAt      time.Time
	RotatedAt      time.Time `gorm:"column:updated_at"`
	LastVerifiedAt time.Time
}

PasswordCredentialModel is the GORM model for the PasswordCredential aggregate. It is linked 1:1 to a Credential row of provider="password" by CredentialID; the bcrypt hash is stored only here, never on the CredentialModel.

The "updated_at" column carries the domain meaning of "password rotated at" (see PasswordCredential.UpdatedAt). The struct field is intentionally named RotatedAt, not UpdatedAt, so GORM's auto-update timestamp magic does not touch it on Saves that only change LastVerifiedAt (i.e. successful logins).

func PasswordCredentialModelFromEntity

func PasswordCredentialModelFromEntity(e *entities.PasswordCredential) *PasswordCredentialModel

PasswordCredentialModelFromEntity converts a PasswordCredential domain entity to a GORM model.

func (PasswordCredentialModel) GoString

func (m PasswordCredentialModel) GoString() string

GoString mirrors String so that %#v also redacts the hash.

func (PasswordCredentialModel) String

func (m PasswordCredentialModel) String() string

String redacts the Hash and Salt fields so the model is safe to log via %v / %+v. Salt is redacted because, paired with the hash, it is exactly what an offline attacker needs to brute-force the plaintext — keep the two out of the same log line.

func (PasswordCredentialModel) TableName

func (PasswordCredentialModel) TableName() string

func (*PasswordCredentialModel) ToEntity

ToEntity converts the GORM model to a PasswordCredential domain entity.

Jump to

Keyboard shortcuts

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