models

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TwoFactorTypeNone  = TwoFactorType("none")
	TwoFactorTypeEmail = TwoFactorType("email")
)

Functions

func SpaceModels added in v0.11.1

func SpaceModels() []any

SpaceModels returns every Spaces persistence model. Keep this list as the single source of truth for production and test AutoMigrate calls.

Types

type Actor

type Actor struct {
	Did    string `gorm:"primaryKey"`
	Handle string `gorm:"uniqueIndex"`
}

type Blob

type Blob struct {
	ID        uint
	CreatedAt string `gorm:"index"`
	Did       string `gorm:"index;index:idx_blob_did_cid"`
	Cid       []byte `gorm:"index;index:idx_blob_did_cid"`
	MimeType  string
	Size      int64
	RefCount  int
	Storage   string `gorm:"default:sqlite"`
	// Bucket and ObjectKey are immutable S3 identity for this blob generation.
	// Empty ObjectKey is retained for legacy rows, which resolve to the original
	// blobs/{did}/{cid} location at read/deletion time.
	Bucket    string
	ObjectKey string
}

type BlobDeletion added in v0.11.1

type BlobDeletion struct {
	ID             uint   `gorm:"primaryKey"`
	IdempotencyKey string `gorm:"uniqueIndex"`
	Bucket         string
	ObjectKey      string
	Status         string `gorm:"index:idx_blob_deletions_status"`
	AttemptCount   int
	NextAttemptAt  *time.Time `gorm:"index"`
	LastError      string
	DeletedAt      *time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

BlobDeletion is durable work for removing an S3-backed blob after its account metadata has been deleted. ObjectKey and Bucket are snapshotted at enqueue time so retries do not depend on mutable server configuration.

type BlobPart

type BlobPart struct {
	Blob   Blob
	BlobID uint `gorm:"primaryKey"`
	Idx    int  `gorm:"primaryKey"`
	Data   []byte
}

type Block

type Block struct {
	Did   string `gorm:"primaryKey;index:idx_blocks_by_rev"`
	Cid   []byte `gorm:"primaryKey"`
	Rev   string `gorm:"index:idx_blocks_by_rev,sort:desc"`
	Value []byte
}

type EventRecord added in v0.8.4

type EventRecord struct {
	Seq       int64 `gorm:"primaryKey;autoIncrement:false"`
	CreatedAt time.Time
	Did       string `gorm:"index"`
	Type      string
	Data      []byte
}

type InviteCode

type InviteCode struct {
	Code              string `gorm:"primaryKey"`
	Did               string `gorm:"index"`
	RemainingUseCount int
}

type Record

type Record struct {
	Did       string `gorm:"primaryKey:idx_record_did_created_at;index:idx_record_did_nsid"`
	CreatedAt string `gorm:"index;index:idx_record_did_created_at,sort:desc"`
	Nsid      string `gorm:"primaryKey;index:idx_record_did_nsid"`
	Rkey      string `gorm:"primaryKey"`
	Cid       string
	Value     []byte
}

type RefreshToken

type RefreshToken struct {
	Token     string `gorm:"primaryKey"`
	Did       string `gorm:"index"`
	CreatedAt time.Time
	ExpiresAt time.Time `gorm:"index:,sort:asc"`
}

type Repo

type Repo struct {
	Did                            string `gorm:"primaryKey"`
	CreatedAt                      time.Time
	Email                          string `gorm:"uniqueIndex"`
	EmailConfirmedAt               *time.Time
	EmailVerificationCode          *string
	EmailVerificationCodeExpiresAt *time.Time
	EmailUpdateCode                *string
	EmailUpdateCodeExpiresAt       *time.Time
	PasswordResetCode              *string
	PasswordResetCodeExpiresAt     *time.Time
	PlcOperationCode               *string
	PlcOperationCodeExpiresAt      *time.Time
	AccountDeleteCode              *string
	AccountDeleteCodeExpiresAt     *time.Time
	Password                       string
	SigningKey                     []byte
	Rev                            string
	Root                           []byte
	Preferences                    []byte
	Deactivated                    bool
	Suspended                      bool
	Takendown                      bool
	TwoFactorCode                  *string
	TwoFactorCodeExpiresAt         *time.Time
	TwoFactorType                  TwoFactorType `gorm:"default:none"`
}

func (*Repo) Active

func (r *Repo) Active() bool

func (*Repo) SignFor

func (r *Repo) SignFor(ctx context.Context, did string, msg []byte) ([]byte, error)

func (*Repo) Status

func (r *Repo) Status() *string

type RepoActor

type RepoActor struct {
	Repo
	Actor
}

type ReservedKey added in v0.7.0

type ReservedKey struct {
	KeyDid     string  `gorm:"primaryKey"`
	Did        *string `gorm:"index"`
	PrivateKey []byte
	CreatedAt  time.Time `gorm:"index"`
}

type SimpleSpace added in v0.11.1

type SimpleSpace struct {
	URI              string `gorm:"primaryKey"`
	OwnerDID         string `gorm:"column:owner_did;index:idx_simple_spaces_owner"`
	Type             string
	SKey             string
	Policy           string
	ManagingApp      *string
	AppAccess        string
	AllowedClientIDs []byte

	Deleted   bool       `gorm:"index:idx_simple_spaces_deleted"`
	DeletedAt *time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

SimpleSpace stores host-local configuration for a managed space. Policy and AppAccess contain the discriminant (for example, "public" or "allowList"); ManagingApp and AllowedClientIDs hold the data for the variants that need it. AllowedClientIDs is canonical JSON so it remains portable across SQLite and Postgres without introducing a database-specific array type.

type SimpleSpaceMember added in v0.11.1

type SimpleSpaceMember struct {
	Space string `gorm:"primaryKey;index:idx_simple_space_members_space"`
	DID   string `gorm:"column:did;primaryKey;index:idx_simple_space_members_did"`

	CreatedAt time.Time
	UpdatedAt time.Time
	RemovedAt *time.Time `gorm:"index"`
}

SimpleSpaceMember is host-local membership state used by the member-list SimpleSpace policy. A member may belong to many spaces.

type SpaceBlobRef added in v0.11.1

type SpaceBlobRef struct {
	Space      string `gorm:"primaryKey;index:idx_space_blob_refs_record;index:idx_space_blob_refs_space_author_cid"`
	Author     string `gorm:"primaryKey;index:idx_space_blob_refs_record;index:idx_space_blob_refs_space_author_cid"`
	Collection string `gorm:"primaryKey;index:idx_space_blob_refs_record"`
	Rkey       string `gorm:"primaryKey;index:idx_space_blob_refs_record"`
	CID        string `gorm:"column:cid;primaryKey;index:idx_space_blob_refs_cid;index:idx_space_blob_refs_space_author_cid"`

	CreatedAt time.Time
	UpdatedAt time.Time
}

SpaceBlobRef links a blob CID to a record identity in a space. Keeping the full record identity in the key makes listBlobs authorization-scoped and lets callers enumerate all references without a global blob visibility leak.

type SpaceNotifyDelivery added in v0.11.1

type SpaceNotifyDelivery struct {
	ID             uint   `gorm:"primaryKey"`
	IdempotencyKey string `gorm:"uniqueIndex"`
	Kind           string `gorm:"index:idx_space_notify_deliveries_kind"`

	Space   string `gorm:"index:idx_space_notify_deliveries_space"`
	Service string `gorm:"index:idx_space_notify_deliveries_service"`
	Author  string
	Rev     string
	Hash    []byte
	Deleted bool
	Payload []byte

	Status        string `gorm:"index:idx_space_notify_deliveries_status"`
	AttemptCount  int
	NextAttemptAt *time.Time `gorm:"index"`
	ExpiresAt     time.Time  `gorm:"index"`
	DeliveredAt   *time.Time
	LastError     string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

SpaceNotifyDelivery is a durable best-effort notification outbox entry. Payload may contain the canonical request body; the individual fields make retry, inspection, and de-duplication possible without decoding it.

type SpaceNotifyRegistration added in v0.11.1

type SpaceNotifyRegistration struct {
	Space   string `gorm:"primaryKey;index:idx_space_notify_registrations_space"`
	Service string `gorm:"primaryKey;index:idx_space_notify_registrations_space"`

	ExpiresAt time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

SpaceNotifyRegistration is a service's write-notification subscription for a space. Re-registering the same service updates this row and its expiry.

type SpaceRecord added in v0.11.1

type SpaceRecord struct {
	Space         string `gorm:"primaryKey;index:idx_space_records_space_author"`
	Author        string `gorm:"primaryKey;index:idx_space_records_space_author"`
	Collection    string `gorm:"primaryKey;index:idx_space_records_record"`
	Rkey          string `gorm:"primaryKey;index:idx_space_records_record"`
	CID           string `gorm:"column:cid"`
	CanonicalCBOR []byte
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

SpaceRecord is the current value of a record in a permissioned repo. CanonicalCBOR is stored verbatim as the record's canonical DAG-CBOR bytes.

type SpaceReplay added in v0.11.1

type SpaceReplay = SpaceReplayJTI

SpaceReplay is retained as a concise compatibility alias for callers that refer to the record by its purpose rather than its storage key.

type SpaceReplayJTI added in v0.11.1

type SpaceReplayJTI struct {
	JTI       string    `gorm:"primaryKey"`
	TokenType string    `gorm:"index:idx_space_replay_jtis_type"`
	ExpiresAt time.Time `gorm:"index"`
	CreatedAt time.Time
}

SpaceReplayJTI is a durable single-use-token/DPoP replay record. JTI is globally unique because a token replay must be rejected regardless of which space or endpoint first consumed it.

type SpaceRepo added in v0.11.1

type SpaceRepo struct {
	Space  string `gorm:"primaryKey;index:idx_space_repos_space_author"`
	Author string `gorm:"primaryKey;index:idx_space_repos_space_author"`

	Rev    string `gorm:"index:idx_space_repos_rev,sort:desc"`
	LtHash []byte `gorm:"not null"`

	Status    string     `gorm:"index:idx_space_repos_status"`
	Deleted   bool       `gorm:"index:idx_space_repos_deleted"`
	DeletedAt *time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

SpaceRepo is the latest observed state of one author's repo in a space. Space and Author are the repo identity; Rev and LtHash describe its latest observed commit. LtHash contains the serialized 2,048-byte LtHash state, not the SHA-256 digest exposed by the wire API.

type SpaceRepoOp added in v0.11.1

type SpaceRepoOp struct {
	Space  string `gorm:"primaryKey;index:idx_space_repo_ops_repo"`
	Author string `gorm:"primaryKey;index:idx_space_repo_ops_repo"`
	Rev    string `gorm:"primaryKey;index:idx_space_repo_ops_repo,sort:asc"`
	Idx    int    `gorm:"primaryKey;index:idx_space_repo_ops_repo,sort:asc"`

	Collection  string
	Rkey        string
	CurrentCID  *string `gorm:"column:current_cid"`
	PreviousCID *string `gorm:"column:previous_cid"`
	CreatedAt   time.Time
}

SpaceRepoOp is one retained operation in a repo's append-only operation log. A nil CurrentCID means delete and a nil PreviousCID means create.

type SpaceTombstone added in v0.11.1

type SpaceTombstone struct {
	Space              string `gorm:"primaryKey"`
	OwnerDID           string `gorm:"column:owner_did"`
	SourceDID          string `gorm:"column:source_did"`
	SourceNotification string
	DeletedAt          time.Time `gorm:"index"`
	CreatedAt          time.Time
}

SpaceTombstone records deletion of a space. The space URI is the primary key so deletion notification and replay handling are idempotent.

type SpaceWriter added in v0.11.1

type SpaceWriter struct {
	Space  string `gorm:"primaryKey;index:idx_space_writers_space"`
	Author string `gorm:"primaryKey;index:idx_space_writers_space"`

	Host           string
	Rev            string
	Hash           []byte
	LastNotifiedAt *time.Time `gorm:"index"`
	Status         string     `gorm:"index:idx_space_writers_status"`
	DeletedAt      *time.Time `gorm:"index"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

SpaceWriter is the writer set for a space. It is deliberately separate from SpaceRepo so a host can retain writer registration/endpoint state even while a repo snapshot is being replaced or marked deleted.

type Token

type Token struct {
	Token        string `gorm:"primaryKey"`
	Did          string `gorm:"index"`
	RefreshToken string `gorm:"index"`
	CreatedAt    time.Time
	ExpiresAt    time.Time `gorm:"index:,sort:asc"`
}

type TwoFactorType added in v0.8.0

type TwoFactorType string

Jump to

Keyboard shortcuts

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