store

package
v0.31.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 31 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// MigrateFileNameSplit is the split character between the patch version and the description in the migration file name.
	// For example, "1__create_table.sql".
	MigrateFileNameSplit = "__"
	// LatestSchemaFileName is the name of the latest schema file.
	// This file is used to initialize fresh installations with the current schema.
	LatestSchemaFileName = "LATEST.sql"
)
View Source
const DefaultContentLengthLimit = 8 * 1024

DefaultContentLengthLimit is the default limit of content length in bytes. 8KB.

View Source
const (
	// DefaultDeploymentConfigurationDir is the directory scanned for runtime configuration files.
	DefaultDeploymentConfigurationDir = "/etc/secrets"
)

Variables

View Source
var DefaultReactions = []string{"👍", "👎", "❤️", "🎉", "😄", "😕", "😢", "😡"}

DefaultReactions is the default reactions for memo related setting.

View Source
var ErrCreateAttachmentPostCommitFailpoint = errors.New("create attachment post-commit failpoint")

ErrCreateAttachmentPostCommitFailpoint is returned after the test-only attachment create failpoint persists a row.

View Source
var ErrDeleteAttachmentStorageFailpoint = errors.New("delete attachment storage failpoint")

ErrDeleteAttachmentStorageFailpoint is returned by the test-only attachment storage failpoint.

View Source
var ErrLastSpaceAdmin = errors.New("cannot remove the last space admin")

ErrLastSpaceAdmin indicates that a membership mutation would leave an active space without an administrator.

View Source
var ErrMemoMutationConflict = errors.New("memo state changed")

ErrMemoMutationConflict indicates that memo or attachment state changed after an API request prepared its mutation.

View Source
var ErrMemoPermissionDenied = errors.New("memo mutation permission denied")

ErrMemoPermissionDenied indicates that the actor no longer owns the memo being mutated.

View Source
var ErrMemoShareConflict = errors.New("active memo share conflicts with audience")

ErrMemoShareConflict indicates that an active share conflicts with a SPACE audience transition.

View Source
var ErrMemoSpaceMembershipRequired = errors.New("active space membership required")

ErrMemoSpaceMembershipRequired indicates that the memo creator is not an active member of its assigned space.

View Source
var ErrMemoSpaceNotWritable = errors.New("memo space is not writable")

ErrMemoSpaceNotWritable indicates that a memo targets a missing or otherwise invalid Space.

View Source
var ErrReactionMemoNotFound = stderrors.New("reaction memo not found")

ErrReactionMemoNotFound indicates that a reaction's memo no longer exists.

View Source
var ErrReactionPermissionDenied = stderrors.New("reaction mutation permission denied")

ErrReactionPermissionDenied indicates that an actor cannot mutate the reaction.

View Source
var ErrSpaceAlreadyExists = errors.New("space already exists")

ErrSpaceAlreadyExists indicates a duplicate immutable space ID.

View Source
var ErrSpaceInvitationNotFound = errors.New("space invitation not found")

ErrSpaceInvitationNotFound indicates a missing pending invitation.

View Source
var ErrSpaceMemberAlreadyExists = errors.New("space member already exists")

ErrSpaceMemberAlreadyExists indicates an existing membership or invitation.

View Source
var ErrSpaceMemberNotActive = errors.New("space member user is not active")

ErrSpaceMemberNotActive indicates that a membership target is not an active user.

View Source
var ErrSpaceMemberNotFound = errors.New("space member not found")

ErrSpaceMemberNotFound indicates a missing membership mutation target.

View Source
var ErrSpaceNotFound = errors.New("space not found")

ErrSpaceNotFound indicates a missing mutation target.

View Source
var ErrSpacePermissionDenied = errors.New("space permission denied")

ErrSpacePermissionDenied indicates that the actor cannot perform a space mutation.

View Source
var ErrUnsafeAuthenticationConfiguration = errors.New("password authentication for regular users cannot be disabled without an effective identity provider")

ErrUnsafeAuthenticationConfiguration indicates a mutation would lock regular users out.

View Source
var ErrUserHasSpaceMembership = stderrors.New("user still has space memberships")

ErrUserHasSpaceMembership blocks account deletion until its Space lifecycle has been resolved explicitly.

Functions

func AttachmentNeedsInstanceStorageSetting added in v0.29.0

func AttachmentNeedsInstanceStorageSetting(attachment *Attachment) bool

AttachmentNeedsInstanceStorageSetting reports whether cleanup should load the configured storage registry for an S3 attachment.

func FindStorage added in v0.14.0

func FindStorage(setting *storepb.InstanceStorageSetting, storageID string) *storepb.Storage

FindStorage returns the configured storage with the given stable identifier.

func GetDefaultStorage added in v0.31.0

func GetDefaultStorage(setting *storepb.InstanceStorageSetting) *storepb.Storage

GetDefaultStorage returns the storage used for new attachments.

func MemoDeleteActorCanRead added in v0.31.0

func MemoDeleteActorCanRead(rowStatus RowStatus, visibility Visibility, spaceID *int32, spaceExists, actorMember bool) bool

MemoDeleteActorCanRead applies the memo-local audience matrix after the deletion transaction has established that the actor is the active author. Invalid lifecycle or audience state fails closed. Placement validity matters only for the Space audience; it is not an extra read gate for other values.

func NormalizeInstanceStorageSetting added in v0.31.0

func NormalizeInstanceStorageSetting(setting *storepb.InstanceStorageSetting)

NormalizeInstanceStorageSetting populates the named storage model from legacy fields and keeps the legacy fields synchronized for older clients.

func NullInt32Pointer added in v0.31.0

func NullInt32Pointer(value sql.NullInt64) *int32

NullInt32Pointer converts a nullable SQL integer to an optional int32.

func PrepareInstanceStorageSettingUpdate added in v0.31.0

func PrepareInstanceStorageSettingUpdate(incoming, existing *storepb.InstanceStorageSetting) error

PrepareInstanceStorageSettingUpdate preserves storages still referenced by existing attachments and assigns a new identity when a physical namespace changes.

func ResolveStorage added in v0.31.0

func ResolveStorage(
	setting *storepb.InstanceStorageSetting,
	storageID string,
	legacyS3Config *storepb.StorageS3Config,
) (*storepb.Storage, error)

ResolveStorage resolves the configured storage referenced by an attachment. It returns a registry entry when one matches — its Id is the stable identity — or a synthesized storage wrapping the legacy config otherwise (empty Id). legacyS3Config supports attachments written before storage IDs were introduced.

func StorageNamespaceEqual added in v0.31.0

func StorageNamespaceEqual(a, b *storepb.Storage) bool

StorageNamespaceEqual reports whether two configurations address the same physical storage namespace. Credentials and transport options are deliberately excluded so they can be rotated without changing storage identity.

func ValidateAttachmentDeletionMemoSnapshots added in v0.31.0

func ValidateAttachmentDeletionMemoSnapshots(memoIDs []int32, expectedMemoContents map[int32]string) error

ValidateAttachmentDeletionMemoSnapshots requires exactly one expected content snapshot for every memo currently bound to the selected attachments.

func ValidateAttachmentMutationTargets added in v0.31.0

func ValidateAttachmentMutationTargets(actorUserID int32, attachmentIDs []int32, attachments []*Attachment) ([]int32, error)

ValidateAttachmentMutationTargets verifies attachment rows used by a transport-facing mutation and returns their distinct memo bindings in ascending order.

func ValidateMemoCommentAuthorization added in v0.31.0

func ValidateMemoCommentAuthorization(snapshot *MemoCommentAuthorizationSnapshot) error

ValidateMemoCommentAuthorization validates participation in the context memo. The replying memo is authorized independently by the normal memo-create policy; no placement or audience is inherited from this snapshot.

func ValidateMemoRelationDelete added in v0.31.0

func ValidateMemoRelationDelete(delete *DeleteMemoRelation) error

ValidateMemoRelationDelete ensures the generic deletion path can only mutate reference relations. COMMENT relations are immutable context and are removed only as part of the lifecycle of an incident memo.

func ValidateMemoRelationEndpointRead added in v0.31.0

func ValidateMemoRelationEndpointRead(snapshot *MemoRelationEndpointSnapshot) error

ValidateMemoRelationEndpointRead applies authenticated memo-local read policy to an endpoint. Application roles are deliberately absent: an instance administrator has no relation-specific read bypass.

func ValidateMemoWriteSnapshot added in v0.31.0

func ValidateMemoWriteSnapshot(policy *MemoWritePolicy, update *UpdateMemo, snapshot *MemoWriteSnapshot) error

ValidateMemoWriteSnapshot applies the transport-independent write invariants to current database state.

func ValidateReactionWriteParticipation added in v0.31.0

func ValidateReactionWriteParticipation(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error

ValidateReactionWriteParticipation applies the reaction actor identity and memo-local participation rules to state loaded by the write transaction.

func WithCreateAttachmentPolicyFailpoint added in v0.31.0

func WithCreateAttachmentPolicyFailpoint(ctx context.Context) context.Context

WithCreateAttachmentPolicyFailpoint forces a policy-bearing attachment create to fail before its database insert.

func WithCreateAttachmentPostCommitFailpoint added in v0.31.0

func WithCreateAttachmentPostCommitFailpoint(ctx context.Context) context.Context

WithCreateAttachmentPostCommitFailpoint forces CreateAttachment to return an error after its database insert succeeds.

func WithDeleteAttachmentStorageFailpoint added in v0.28.0

func WithDeleteAttachmentStorageFailpoint(ctx context.Context) context.Context

WithDeleteAttachmentStorageFailpoint forces DeleteAttachmentStorage to return a failpoint error.

func WithDeleteUserFailpoint added in v0.28.0

func WithDeleteUserFailpoint(ctx context.Context, failpoint DeleteUserFailpoint) context.Context

WithDeleteUserFailpoint is a test-only helper that forces DeleteUser to roll back.

Types

type AcceptSpaceInvitation added in v0.31.0

type AcceptSpaceInvitation struct {
	SpaceID int32
	UserID  int32
}

AcceptSpaceInvitation identifies an invitation accepted by its invitee.

type Attachment added in v0.25.0

type Attachment struct {
	// ID is the system generated unique identifier for the attachment.
	ID int32
	// UID is the user defined unique identifier for the attachment.
	UID string

	// Standard fields
	CreatorID int32
	CreatedTs int64
	UpdatedTs int64

	// Domain specific fields
	Filename    string
	Blob        []byte
	Type        string
	Size        int64
	StorageType storepb.AttachmentStorageType
	Reference   string
	Payload     *storepb.AttachmentPayload

	// The related memo ID.
	MemoID *int32
	// Policy is present for transport-facing direct-link mutations. Drivers
	// revalidate it in the same transaction as the attachment insert.
	Policy *MemoWritePolicy

	// Composed field
	MemoUID *string
}

type AttachmentDeletionPolicy added in v0.31.0

type AttachmentDeletionPolicy struct {
	ActorUserID          int32
	ExpectedMemoContents map[int32]string
}

AttachmentDeletionPolicy captures the caller and the memo content observed while validating a transport-facing attachment deletion. Drivers compare the snapshots with current memo state in the deletion transaction.

type AuthenticationConfigMutation added in v0.30.0

type AuthenticationConfigMutation struct {
	UpsertGeneralSetting     *InstanceSetting
	DeleteIdentityProviderID *int32
	Validate                 func(*AuthenticationConfigState) error
}

AuthenticationConfigMutation validates and applies one stored authentication mutation atomically.

type AuthenticationConfigState added in v0.30.0

type AuthenticationConfigState struct {
	GeneralSetting    *InstanceSetting
	IdentityProviders []*IdentityProvider
}

AuthenticationConfigState is the stored authentication configuration read inside a transaction.

type DeclineSpaceInvitation added in v0.31.0

type DeclineSpaceInvitation struct {
	SpaceID int32
	UserID  int32
}

DeclineSpaceInvitation identifies an invitation declined by its invitee.

type DeleteAttachment added in v0.25.0

type DeleteAttachment struct {
	ID     int32
	MemoID *int32
}

type DeleteIdentityProvider added in v0.13.2

type DeleteIdentityProvider struct {
	ID int32
}

type DeleteInbox added in v0.17.0

type DeleteInbox struct {
	ID int32
}

DeleteInbox specifies which inbox item to delete.

type DeleteInstanceSetting added in v0.25.3

type DeleteInstanceSetting struct {
	Name string
}

type DeleteMemo added in v0.14.0

type DeleteMemo struct {
	ID int32
}

type DeleteMemoRelation added in v0.14.0

type DeleteMemoRelation struct {
	MemoID        *int32
	RelatedMemoID *int32
	Type          *MemoRelationType
}

type DeleteMemoShare added in v0.27.0

type DeleteMemoShare struct {
	ID     *int32
	UID    *string
	MemoID *int32
	// Policy is required for transport-facing revocation and is revalidated in
	// the same transaction as the delete.
	Policy *MemoWritePolicy
}

DeleteMemoShare identifies a share grant to remove.

type DeleteMemoWithPolicy added in v0.31.0

type DeleteMemoWithPolicy struct {
	MemoID      int32
	ActorUserID int32
}

DeleteMemoWithPolicy identifies one author-owned memo to delete atomically. Relations do not confer lifecycle authority, so no related memo is deleted.

type DeleteMemoWithPolicyResult added in v0.31.0

type DeleteMemoWithPolicyResult struct {
	ActorCanRead bool
	Attachments  []*Attachment
}

DeleteMemoWithPolicyResult contains authorization state captured by the deletion transaction.

type DeleteReaction added in v0.20.0

type DeleteReaction struct {
	ID          *int32
	MemoID      *int32
	ActorUserID *int32
	// Policy is required for transport-facing participation mutations. It is
	// revalidated in the same transaction before the reaction row is deleted.
	Policy *ReactionWritePolicy
}

type DeleteSpace added in v0.31.0

type DeleteSpace struct {
	ID          int32
	ActorUserID int32
}

DeleteSpace identifies a Space to hard-delete.

type DeleteSpaceMember added in v0.31.0

type DeleteSpaceMember struct {
	SpaceID int32
	UserID  int32
}

DeleteSpaceMember identifies a membership to delete.

type DeleteSpaceResult added in v0.31.0

type DeleteSpaceResult struct {
	Attachments []*Attachment
}

DeleteSpaceResult contains external resources to clean after commit.

type DeleteUser added in v0.14.0

type DeleteUser struct {
	ID int32
}

type DeleteUserFailpoint added in v0.28.0

type DeleteUserFailpoint string

DeleteUserFailpoint is a test-only hook for forcing a delete-user rollback.

const (
	// DeleteUserFailpointBeforeCommit aborts after all delete statements run but before commit.
	DeleteUserFailpointBeforeCommit DeleteUserFailpoint = "before_commit"
)

func GetDeleteUserFailpoint added in v0.29.0

func GetDeleteUserFailpoint(ctx context.Context) DeleteUserFailpoint

GetDeleteUserFailpoint returns the delete-user failpoint attached to ctx, if any.

type DeleteUserIdentity added in v0.28.0

type DeleteUserIdentity struct {
	ID       *int32
	UserID   *int32
	Provider *string
}

DeleteUserIdentity is used to delete user identity linkage rows.

type DeleteUserResult added in v0.29.0

type DeleteUserResult struct {
	Attachments     []*Attachment
	UserSettingKeys []storepb.UserSetting_Key
}

DeleteUserResult contains resources collected while deleting a user.

type DeleteUserSetting added in v0.28.0

type DeleteUserSetting struct {
	UserID *int32
	Key    storepb.UserSetting_Key
}

type Driver added in v0.16.0

type Driver interface {
	GetDB() *sql.DB
	Close() error

	IsInitialized(ctx context.Context) (bool, error)

	// GetDatabaseSize returns the database size in bytes, or -1 if unavailable.
	// A non-nil error indicates a hard failure; -1 with nil error means the
	// driver cannot report a size from the underlying database.
	GetDatabaseSize(ctx context.Context) (int64, error)

	// Attachment model related methods.
	CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)
	ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)
	UpdateAttachment(ctx context.Context, update *UpdateAttachment) error
	DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error
	DeleteAttachments(ctx context.Context, deletes []*DeleteAttachment) error
	DeleteAttachmentsWithPolicy(ctx context.Context, policy *AttachmentDeletionPolicy, attachmentIDs []int32) error
	ApplyMemoMutation(ctx context.Context, mutation *MemoMutation) error

	// Memo model related methods.
	CreateMemo(ctx context.Context, create *Memo) (*Memo, error)
	ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)
	UpdateMemo(ctx context.Context, update *UpdateMemo) error
	DeleteMemo(ctx context.Context, delete *DeleteMemo) error
	DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error)

	// Space model related methods.
	CreateSpace(ctx context.Context, create *Space, creatorID int32) (*Space, error)
	ListSpaces(ctx context.Context, find *FindSpace) ([]*Space, error)
	UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserID int32) (*Space, error)
	DeleteSpace(ctx context.Context, delete *DeleteSpace) (*DeleteSpaceResult, error)
	ListSpaceMembers(ctx context.Context, find *FindSpaceMember) ([]*SpaceMember, error)
	UpdateSpaceMember(ctx context.Context, update *UpdateSpaceMember, actorUserID int32) (*SpaceMember, error)
	DeleteSpaceMember(ctx context.Context, delete *DeleteSpaceMember, actorUserID int32) error
	CreateSpaceInvitation(ctx context.Context, create *SpaceInvitation, actorUserID int32) (*SpaceInvitation, error)
	ListSpaceInvitations(ctx context.Context, find *FindSpaceInvitation) ([]*SpaceInvitation, error)
	AcceptSpaceInvitation(ctx context.Context, accept *AcceptSpaceInvitation, actorUserID int32) (*SpaceMember, error)
	DeclineSpaceInvitation(ctx context.Context, decline *DeclineSpaceInvitation, actorUserID int32) error
	RevokeSpaceInvitation(ctx context.Context, revoke *RevokeSpaceInvitation, actorUserID int32) error

	// MemoRelation model related methods.
	UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)
	ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)
	DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error

	// InstanceSetting model related methods.
	// CreateInstanceSettingIfNotExists atomically creates the setting when its name is absent and reports whether it inserted the row.
	CreateInstanceSettingIfNotExists(ctx context.Context, create *InstanceSetting) (bool, error)
	UpsertInstanceSetting(ctx context.Context, upsert *InstanceSetting) (*InstanceSetting, error)
	ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*InstanceSetting, error)
	DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error

	// User model related methods.
	CreateUser(ctx context.Context, create *User) (*User, error)
	UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)
	ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
	DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error)

	// UserSetting model related methods.
	UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error)
	ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error)
	DeleteUserSettings(ctx context.Context, delete *DeleteUserSetting) error
	GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)

	// IdentityProvider model related methods.
	CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error)
	ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*IdentityProvider, error)
	UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProvider) (*IdentityProvider, error)
	DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error
	ApplyAuthenticationConfigMutation(ctx context.Context, mutation *AuthenticationConfigMutation) error
	IsRetryableAuthenticationMutationError(err error) bool

	// Inbox model related methods.
	CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)
	ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)
	UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)
	DeleteInbox(ctx context.Context, delete *DeleteInbox) error

	// Reaction model related methods.
	UpsertReaction(ctx context.Context, create *Reaction) (*Reaction, error)
	ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)
	GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)
	DeleteReaction(ctx context.Context, delete *DeleteReaction) error

	// MemoShare model related methods.
	CreateMemoShare(ctx context.Context, create *MemoShare) (*MemoShare, error)
	ListMemoShares(ctx context.Context, find *FindMemoShare) ([]*MemoShare, error)
	GetMemoShare(ctx context.Context, find *FindMemoShare) (*MemoShare, error)
	DeleteMemoShare(ctx context.Context, delete *DeleteMemoShare) error

	// UserIdentity model related methods.
	CreateUserIdentity(ctx context.Context, create *UserIdentity) (*UserIdentity, error)
	CreateUserWithIdentity(ctx context.Context, createUser *User, createIdentity *UserIdentity) (*User, error)
	ListUserIdentities(ctx context.Context, find *FindUserIdentity) ([]*UserIdentity, error)
	DeleteUserIdentities(ctx context.Context, delete *DeleteUserIdentity) error
}

Driver is an interface for store driver. It contains all methods that store database driver should implement.

type FindAttachment added in v0.25.0

type FindAttachment struct {
	GetBlob        bool
	ID             *int32
	UID            *string
	CreatorID      *int32
	Filename       *string
	FilenameSearch *string
	MemoID         *int32
	MemoIDList     []int32
	HasRelatedMemo bool
	Filters        []string
	// Access applies memo-local authorization to linked attachments
	// before pagination. Unlinked attachments are visible only to the active
	// matching creator. Nil is reserved for trusted internal callers.
	Access           *MemoAccessScope
	Limit            *int
	Offset           *int
	SkipDefaultLimit bool
}

type FindIdentityProvider added in v0.13.2

type FindIdentityProvider struct {
	ID  *int32
	UID *string
}

type FindInbox added in v0.17.0

type FindInbox struct {
	ID          *int32
	SenderID    *int32
	ReceiverID  *int32
	Status      *InboxStatus
	MessageType *storepb.InboxMessage_Type

	// Pagination
	Limit  *int
	Offset *int
}

FindInbox specifies filter criteria for querying inbox items.

type FindInstanceSetting added in v0.25.3

type FindInstanceSetting struct {
	Name string
}

type FindMemo added in v0.14.0

type FindMemo struct {
	ID  *int32
	UID *string

	IDList  []int32
	UIDList []string

	// Standard fields
	RowStatus *RowStatus
	CreatorID *int32

	// Domain specific fields
	VisibilityList       []Visibility
	CommentContextMemoID *int32
	Access               *MemoAccessScope
	ExcludeContent       bool
	ExcludeComments      bool
	Filters              []string

	// Pagination
	Limit  *int
	Offset *int

	// Ordering
	OrderByPinned    bool
	OrderByUpdatedTs bool
	OrderByTimeAsc   bool
}

type FindMemoPayload added in v0.22.0

type FindMemoPayload struct {
	Raw                *string
	TagSearch          []string
	HasLink            bool
	HasTaskList        bool
	HasCode            bool
	HasIncompleteTasks bool
}

type FindMemoRelation added in v0.14.0

type FindMemoRelation struct {
	MemoID        *int32
	RelatedMemoID *int32
	Type          *MemoRelationType
	MemoFilter    *string
	// SourceMemoRowStatus filters the relation source memo before pagination.
	SourceMemoRowStatus *RowStatus
	// MemoIDList matches relations where memo_id OR related_memo_id is in the list.
	MemoIDList []int32
	// SourceMemoIDList matches relations where memo_id is in the list.
	SourceMemoIDList []int32
	// RelatedMemoIDList matches relations where related_memo_id is in the list.
	RelatedMemoIDList []int32
	Limit             *int
	Offset            *int
}

type FindMemoShare added in v0.27.0

type FindMemoShare struct {
	ID        *int32
	UID       *string
	MemoID    *int32
	CreatorID *int32
}

FindMemoShare is used to filter memo shares in list/get queries.

type FindReaction added in v0.20.0

type FindReaction struct {
	ID         *int32
	CreatorID  *int32
	MemoID     *int32
	MemoIDList []int32
}

type FindSpace added in v0.31.0

type FindSpace struct {
	ID           *int32
	IDList       []int32
	UID          *string
	MemberUserID *int32
	Limit        *int
	Offset       *int
}

FindSpace selects spaces. MemberUserID restricts results to spaces where the user has a membership, populates the viewer summary, and is applied before pagination.

type FindSpaceInvitation added in v0.31.0

type FindSpaceInvitation struct {
	SpaceID      *int32
	UserID       *int32
	ViewerUserID *int32
	Limit        *int
	Offset       *int
}

FindSpaceInvitation selects pending invitations. ViewerUserID restricts results to invitations visible to that user: their own or those in a space they actively administer.

type FindSpaceMember added in v0.31.0

type FindSpaceMember struct {
	SpaceID      *int32
	UserID       *int32
	ViewerUserID *int32
	Limit        *int
	Offset       *int
}

FindSpaceMember selects memberships.

type FindUser added in v0.14.0

type FindUser struct {
	ID     *int32
	IDList []int32

	UsernameList []string

	RowStatus *RowStatus
	Username  *string
	Role      *Role
	Email     *string
	Nickname  *string
	Search    *string

	// Domain specific fields
	Filters []string

	// The maximum number of users to return.
	Limit *int
	// The offset of the returned users.
	Offset *int
}

type FindUserIdentity added in v0.28.0

type FindUserIdentity struct {
	ID        *int32
	UserID    *int32
	Provider  *string
	ExternUID *string
}

FindUserIdentity is used to filter user identities in list/get queries.

type FindUserSetting added in v0.13.2

type FindUserSetting struct {
	UserID *int32
	Key    storepb.UserSetting_Key
}

type IdentityProvider added in v0.13.2

type IdentityProvider struct {
	ID               int32
	UID              string
	Name             string
	Type             storepb.IdentityProvider_Type
	IdentifierFilter string
	Config           string
}

type Inbox added in v0.17.0

type Inbox struct {
	ID         int32
	CreatedTs  int64
	SenderID   int32                 // The user who triggered the notification
	ReceiverID int32                 // The user who receives the notification
	Status     InboxStatus           // Current status (unread/archived)
	Message    *storepb.InboxMessage // The notification message content
}

Inbox represents a notification in a user's inbox.

type InboxStatus added in v0.17.0

type InboxStatus string

InboxStatus represents the status of an inbox notification.

const (
	// UNREAD indicates the notification has not been read by the user.
	UNREAD InboxStatus = "UNREAD"
	// ARCHIVED indicates the notification has been archived/dismissed by the user.
	ARCHIVED InboxStatus = "ARCHIVED"
)

func (InboxStatus) String added in v0.17.0

func (s InboxStatus) String() string

type InstanceSetting added in v0.25.3

type InstanceSetting struct {
	Name        string
	Value       string
	Description string
}

type Memo added in v0.14.0

type Memo struct {
	// ID is the system generated unique identifier for the memo.
	ID int32
	// UID is the user defined unique identifier for the memo.
	UID string

	// Standard fields
	RowStatus RowStatus
	CreatorID int32
	CreatedTs int64
	UpdatedTs int64

	// Domain specific fields
	Content    string
	Visibility Visibility
	Pinned     bool
	Payload    *storepb.MemoPayload
	SpaceID    *int32

	// Composed fields
	ParentUID *string
}

type MemoAccessScope added in v0.31.0

type MemoAccessScope struct {
	UserID         *int32
	AllowPublic    bool
	AllowProtected bool
}

MemoAccessScope is a typed, fail-closed read authorization predicate. When present on FindMemo, drivers apply it in SQL before pagination.

type MemoAttachmentBinding added in v0.31.0

type MemoAttachmentBinding struct {
	ID             int32
	UID            string
	UpdatedTs      int64
	WasBoundToMemo bool
}

MemoAttachmentBinding describes one attachment that should be bound to a memo. WasBoundToMemo distinguishes an existing binding from a new one so the driver can reject ownership transfers while preserving legacy rows already attached to the memo.

type MemoCommentAuthorizationSnapshot added in v0.31.0

type MemoCommentAuthorizationSnapshot struct {
	ActorUserID int32
	ActorActive bool

	ContextID         int32
	ContextCreatorID  int32
	ContextRowStatus  RowStatus
	ContextVisibility Visibility
	ContextSpaceID    *int32

	ContextSpaceExists  bool
	ContextMemberActive bool
}

MemoCommentAuthorizationSnapshot is the memo-local database state read by a driver before it creates an immutable COMMENT relation.

type MemoMutation added in v0.31.0

type MemoMutation struct {
	// MemoCreate requests that the memo row be created in this same transaction
	// before attachments and relations are applied. CommentContextMemoID creates
	// one immutable COMMENT relation from the new memo to the named context memo.
	MemoCreate                *Memo
	CommentContextMemoID      *int32
	MemoID                    int32
	MemoCreatorID             int32
	ExpectedMemoContent       string
	MemoUpdate                *UpdateMemo
	Bindings                  []*MemoAttachmentBinding
	RemovedAttachmentIDs      []int32
	RequiredAttachmentIDs     []int32
	ReplaceReferenceRelations bool
	ReferenceRelations        []*MemoRelation
	Policy                    *MemoWritePolicy
}

MemoMutation atomically updates a memo, its attachment bindings, and its reference relations. Removed attachment rows are deleted in the same transaction; callers may clean up external objects after the commit.

type MemoRelation added in v0.14.0

type MemoRelation struct {
	MemoID        int32
	RelatedMemoID int32
	Type          MemoRelationType
}

type MemoRelationEndpointSnapshot added in v0.31.0

type MemoRelationEndpointSnapshot struct {
	ActorUserID int32
	ActorActive bool

	EndpointID         int32
	EndpointCreatorID  int32
	EndpointRowStatus  RowStatus
	EndpointVisibility Visibility
	EndpointSpaceID    *int32

	EndpointSpaceExists  bool
	EndpointMemberActive bool
}

MemoRelationEndpointSnapshot is the memo-local database state used to authorize one endpoint during a reference-relation mutation.

type MemoRelationType added in v0.13.0

type MemoRelationType string
const (
	// MemoRelationReference is the type for a reference memo relation.
	MemoRelationReference MemoRelationType = "REFERENCE"
	// MemoRelationComment is the type for a comment memo relation.
	MemoRelationComment MemoRelationType = "COMMENT"
)

type MemoShare added in v0.27.0

type MemoShare struct {
	ID        int32
	UID       string
	MemoID    int32
	CreatorID int32
	CreatedTs int64
	ExpiresTs *int64 // nil means the share never expires
	Policy    *MemoWritePolicy
}

MemoShare is an access grant that permits read-only access to a memo via a bearer token.

type MemoWritePolicy added in v0.31.0

type MemoWritePolicy struct {
	ActorUserID int32
	// LifecycleOnly permits an author who is no longer a member of the source
	// Space to move or withdraw the memo. It never permits content, metadata,
	// attachment, relation, or share mutations.
	LifecycleOnly bool
	// CreatingShare rejects a share if the memo's current audience is
	// SPACE. Share revocation deliberately leaves this false.
	CreatingShare bool
}

MemoWritePolicy identifies the actor and the intended kind of transport-facing mutation. Drivers discover and authorize the current memo, Space, membership, and share state in the write transaction.

type MemoWriteSnapshot added in v0.31.0

type MemoWriteSnapshot struct {
	CreatorID          int32
	RowStatus          RowStatus
	SpaceID            *int32
	Visibility         Visibility
	SourceSpaceExists  bool
	SourceMemberActive bool
	TargetSpaceExists  bool
	TargetMemberActive bool
	HasActiveShare     bool
}

MemoWriteSnapshot is the current database state used to validate a MemoWritePolicy. Driver packages populate it in the mutation transaction.

type PATQueryResult added in v0.26.0

type PATQueryResult struct {
	UserID int32
	User   *User
	PAT    *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken
}

PATQueryResult contains the result of querying a PAT by hash.

type Reaction added in v0.21.1

type Reaction struct {
	ID        int32
	CreatedTs int64
	CreatorID int32
	// MemoID is the ID of the memo that the reaction is for.
	MemoID       int32
	ReactionType string
	// Policy is required for transport-facing participation mutations. A nil
	// policy preserves trusted internal and migration callers.
	Policy *ReactionWritePolicy
}

Reaction is a reaction attached to a memo.

type ReactionWritePolicy added in v0.31.0

type ReactionWritePolicy struct {
	ActorUserID int32
}

ReactionWritePolicy identifies the actor for a transport-facing reaction mutation. Drivers authorize that actor against the memo's current state.

type RefreshTokenQueryResult added in v0.26.0

type RefreshTokenQueryResult struct {
	UserID       int32
	RefreshToken *storepb.RefreshTokensUserSetting_RefreshToken
}

RefreshTokenQueryResult contains the result of querying a refresh token.

type RevokeSpaceInvitation added in v0.31.0

type RevokeSpaceInvitation struct {
	SpaceID int32
	UserID  int32
}

RevokeSpaceInvitation identifies an invitation revoked by a space administrator.

type Role added in v0.13.2

type Role string

Role is the type of a role.

const (
	// RoleAdmin is the ADMIN role.
	RoleAdmin Role = "ADMIN"
	// RoleUser is the USER role.
	RoleUser Role = "USER"
)

func (Role) String added in v0.13.2

func (e Role) String() string

type RowStatus added in v0.13.1

type RowStatus string

RowStatus is the status for a row.

const (
	// Normal is the status for a normal row.
	Normal RowStatus = "NORMAL"
	// Archived is the status for an archived row.
	Archived RowStatus = "ARCHIVED"
)

func (RowStatus) String added in v0.13.1

func (r RowStatus) String() string

type Space added in v0.31.0

type Space struct {
	ID int32

	UID             string
	Title           string
	Description     string
	CurrentUserRole SpaceMemberRole
	MemberCount     int32
}

Space groups memos and memberships.

type SpaceInvitation added in v0.31.0

type SpaceInvitation struct {
	SpaceID int32
	UserID  int32
	Role    SpaceMemberRole
}

SpaceInvitation is a pending offer for an existing user to join a space.

type SpaceMember added in v0.31.0

type SpaceMember struct {
	SpaceID int32
	UserID  int32
	Role    SpaceMemberRole
}

SpaceMember associates a user with a space.

type SpaceMemberRole added in v0.31.0

type SpaceMemberRole string

SpaceMemberRole is the role of a user within a space.

const (
	// SpaceMemberRoleAdmin can manage the space and its membership.
	SpaceMemberRoleAdmin SpaceMemberRole = "ADMIN"
	// SpaceMemberRoleUser is a regular space member.
	SpaceMemberRoleUser SpaceMemberRole = "USER"
)

func (SpaceMemberRole) IsActiveMember added in v0.31.0

func (r SpaceMemberRole) IsActiveMember() bool

IsActiveMember reports whether the role can grant space membership. The relationship must separately be ACTIVE before the role grants access.

type SpaceMemberStatus added in v0.31.0

type SpaceMemberStatus string

SpaceMemberStatus is the state of a user's relationship with a space.

const (
	// SpaceMemberStatusInvited represents an invitation that the user has not accepted.
	SpaceMemberStatusInvited SpaceMemberStatus = "INVITED"
	// SpaceMemberStatusActive represents a membership that the user has accepted.
	SpaceMemberStatusActive SpaceMemberStatus = "ACTIVE"
)

func (SpaceMemberStatus) IsValid added in v0.31.0

func (s SpaceMemberStatus) IsValid() bool

IsValid reports whether the status is recognized.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store provides database access to all raw objects.

func New

func New(driver Driver, profile *profile.Profile) *Store

New creates a new instance of Store.

func (*Store) AcceptSpaceInvitation added in v0.31.0

func (s *Store) AcceptSpaceInvitation(ctx context.Context, accept *AcceptSpaceInvitation, actorUserID int32) (*SpaceMember, error)

AcceptSpaceInvitation activates a pending invitation only when the actor is the invitee.

func (*Store) AddUserMemoView added in v0.31.0

func (s *Store) AddUserMemoView(ctx context.Context, userID int32, memoView *storepb.MemoViewsUserSetting_MemoView) error

AddUserMemoView appends a new memo view for the user.

func (*Store) AddUserPersonalAccessToken added in v0.26.0

func (s *Store) AddUserPersonalAccessToken(ctx context.Context, userID int32, token *storepb.PersonalAccessTokensUserSetting_PersonalAccessToken) error

AddUserPersonalAccessToken adds a new PAT for the user.

func (*Store) AddUserRefreshToken added in v0.26.0

func (s *Store) AddUserRefreshToken(ctx context.Context, userID int32, token *storepb.RefreshTokensUserSetting_RefreshToken) error

AddUserRefreshToken adds a new refresh token for the user.

func (*Store) AddUserWebhook added in v0.25.0

func (s *Store) AddUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error

AddUserWebhook adds a new webhook for the user.

func (*Store) AllowsAnonymousAccess added in v0.31.0

func (s *Store) AllowsAnonymousAccess(ctx context.Context) (bool, error)

AllowsAnonymousAccess reports whether the effective instance access policy is public.

func (*Store) ApplyMemoMutation added in v0.31.0

func (s *Store) ApplyMemoMutation(ctx context.Context, mutation *MemoMutation) error

ApplyMemoMutation atomically applies memo fields, attachment bindings, and reference relations after rechecking the state used by API validation.

func (*Store) Close added in v0.16.0

func (s *Store) Close() error

func (*Store) CreateAttachment added in v0.25.0

func (s *Store) CreateAttachment(ctx context.Context, create *Attachment) (*Attachment, error)

func (*Store) CreateIdentityProvider added in v0.11.0

func (s *Store) CreateIdentityProvider(ctx context.Context, create *storepb.IdentityProvider) (*storepb.IdentityProvider, error)

func (*Store) CreateInbox added in v0.17.0

func (s *Store) CreateInbox(ctx context.Context, create *Inbox) (*Inbox, error)

CreateInbox creates a new inbox notification.

func (*Store) CreateMemo

func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error)

func (*Store) CreateMemoComment added in v0.31.0

func (s *Store) CreateMemoComment(ctx context.Context, create *Memo, contextMemoID, actorUserID int32) (*Memo, error)

CreateMemoComment atomically creates one independent memo and its immutable COMMENT relation to a context memo.

func (*Store) CreateMemoShare added in v0.27.0

func (s *Store) CreateMemoShare(ctx context.Context, create *MemoShare) (*MemoShare, error)

CreateMemoShare creates a new share grant.

func (*Store) CreateSpace added in v0.31.0

func (s *Store) CreateSpace(ctx context.Context, create *Space, creatorID int32) (*Space, error)

CreateSpace creates a space and its first ADMIN membership atomically.

func (*Store) CreateSpaceInvitation added in v0.31.0

func (s *Store) CreateSpaceInvitation(ctx context.Context, create *SpaceInvitation, actorUserID int32) (*SpaceInvitation, error)

CreateSpaceInvitation creates a pending invitation. It never creates an active membership; only the invitee can do that by accepting it.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error)

func (*Store) CreateUserIdentity added in v0.28.0

func (s *Store) CreateUserIdentity(ctx context.Context, create *UserIdentity) (*UserIdentity, error)

CreateUserIdentity creates a new external-identity linkage record. Returns the driver error on unique-constraint violation; callers are responsible for reconciling concurrent first-login races on (Provider, ExternUID).

func (*Store) CreateUserIfNoUsers added in v0.28.0

func (s *Store) CreateUserIfNoUsers(ctx context.Context, create *User) (*User, bool, error)

CreateUserIfNoUsers creates a user only when the instance has no users. The in-process lock prevents concurrent first-user setup requests from creating multiple admins in the same server process.

func (*Store) CreateUserWithIdentity added in v0.30.0

func (s *Store) CreateUserWithIdentity(ctx context.Context, createUser *User, createIdentity *UserIdentity) (*User, error)

CreateUserWithIdentity atomically creates a local user and its external identity linkage, returning the created user.

func (*Store) DeclineSpaceInvitation added in v0.31.0

func (s *Store) DeclineSpaceInvitation(ctx context.Context, decline *DeclineSpaceInvitation, actorUserID int32) error

DeclineSpaceInvitation deletes a pending invitation only when the actor is the invitee.

func (*Store) DeleteAttachment added in v0.25.0

func (s *Store) DeleteAttachment(ctx context.Context, delete *DeleteAttachment) error

func (*Store) DeleteAttachmentStorage added in v0.27.0

func (s *Store) DeleteAttachmentStorage(ctx context.Context, attachment *Attachment) error

func (*Store) DeleteAttachmentStorageWithInstanceSetting added in v0.29.0

func (s *Store) DeleteAttachmentStorageWithInstanceSetting(ctx context.Context, attachment *Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) error

DeleteAttachmentStorageWithInstanceSetting deletes attachment storage using a preloaded instance storage setting.

func (*Store) DeleteAttachments added in v0.27.0

func (s *Store) DeleteAttachments(ctx context.Context, attachments []*Attachment) error

func (*Store) DeleteAttachmentsWithPolicy added in v0.31.0

func (s *Store) DeleteAttachmentsWithPolicy(ctx context.Context, policy *AttachmentDeletionPolicy, attachmentIDs []int32) error

DeleteAttachmentsWithPolicy atomically authorizes and removes the selected attachment rows. External object cleanup remains the caller's responsibility after the transaction commits.

func (*Store) DeleteIdentityProvider added in v0.11.0

func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdentityProvider) error

func (*Store) DeleteIdentityProviderSafely added in v0.30.0

func (s *Store) DeleteIdentityProviderSafely(ctx context.Context, delete *DeleteIdentityProvider) error

DeleteIdentityProviderSafely validates and deletes an IdP as one serialized operation.

func (*Store) DeleteInbox added in v0.17.0

func (s *Store) DeleteInbox(ctx context.Context, delete *DeleteInbox) error

DeleteInbox permanently removes an inbox item.

func (*Store) DeleteInstanceSetting added in v0.31.0

func (s *Store) DeleteInstanceSetting(ctx context.Context, delete *DeleteInstanceSetting) error

DeleteInstanceSetting deletes a database-backed instance setting and clears cached state derived from it.

func (*Store) DeleteMemo

func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error

func (*Store) DeleteMemoRelation added in v0.13.0

func (s *Store) DeleteMemoRelation(ctx context.Context, delete *DeleteMemoRelation) error

func (*Store) DeleteMemoShare added in v0.27.0

func (s *Store) DeleteMemoShare(ctx context.Context, delete *DeleteMemoShare) error

DeleteMemoShare removes a share grant.

func (*Store) DeleteMemoWithPolicy added in v0.31.0

func (s *Store) DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error)

DeleteMemoWithPolicy atomically deletes exactly one memo, its owned database resources, and relations for which it is an endpoint.

func (*Store) DeleteReaction added in v0.20.0

func (s *Store) DeleteReaction(ctx context.Context, delete *DeleteReaction) error

func (*Store) DeleteSpace added in v0.31.0

func (s *Store) DeleteSpace(ctx context.Context, delete *DeleteSpace) (*DeleteSpaceResult, error)

DeleteSpace atomically deletes a Space, all directly assigned memos, and their owned database resources. Memo relations are not followed.

func (*Store) DeleteSpaceMember added in v0.31.0

func (s *Store) DeleteSpaceMember(ctx context.Context, delete *DeleteSpaceMember, actorUserID int32) error

DeleteSpaceMember deletes a membership after checking that the change keeps an active ADMIN.

func (*Store) DeleteUser added in v0.3.0

func (s *Store) DeleteUser(ctx context.Context, delete *DeleteUser) (*DeleteUserResult, error)

DeleteUser removes a user and returns cache invalidation state. Deleting an already-missing user is idempotent and returns an empty result.

func (*Store) DeleteUserIdentities added in v0.28.0

func (s *Store) DeleteUserIdentities(ctx context.Context, delete *DeleteUserIdentity) error

DeleteUserIdentities deletes all linkage records matching the filter.

func (*Store) DeleteUserSettings added in v0.28.0

func (s *Store) DeleteUserSettings(ctx context.Context, delete *DeleteUserSetting) error

func (*Store) GetAttachment added in v0.25.0

func (s *Store) GetAttachment(ctx context.Context, find *FindAttachment) (*Attachment, error)

func (*Store) GetCurrentSchemaVersion added in v0.22.5

func (s *Store) GetCurrentSchemaVersion() (string, error)

GetCurrentSchemaVersion returns the latest schema version available for the configured database driver.

func (*Store) GetDataDir added in v0.28.0

func (s *Store) GetDataDir() string

GetDataDir returns the store data directory.

func (*Store) GetDriver added in v0.24.0

func (s *Store) GetDriver() Driver

func (*Store) GetIdentityProvider added in v0.11.0

func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)

func (*Store) GetInstanceAISetting added in v0.27.0

func (s *Store) GetInstanceAISetting(ctx context.Context) (*storepb.InstanceAISetting, error)

GetInstanceAISetting gets the AI provider settings for the instance.

func (*Store) GetInstanceAccessSetting added in v0.31.0

func (s *Store) GetInstanceAccessSetting(ctx context.Context) (*storepb.InstanceAccessSetting, error)

GetInstanceAccessSetting gets the instance access policy, defaulting to private.

func (*Store) GetInstanceBasicSetting added in v0.25.3

func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error)

func (*Store) GetInstanceGeneralSetting added in v0.25.3

func (s *Store) GetInstanceGeneralSetting(ctx context.Context) (*storepb.InstanceGeneralSetting, error)

func (*Store) GetInstanceMemoRelatedSetting added in v0.25.3

func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.InstanceMemoRelatedSetting, error)

func (*Store) GetInstanceNotificationSetting added in v0.27.0

func (s *Store) GetInstanceNotificationSetting(ctx context.Context) (*storepb.InstanceNotificationSetting, error)

func (*Store) GetInstanceSetting added in v0.25.3

func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)

func (*Store) GetInstanceStorageSetting added in v0.25.3

func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error)

func (*Store) GetInstanceTagsSetting added in v0.27.0

func (s *Store) GetInstanceTagsSetting(ctx context.Context) (*storepb.InstanceTagsSetting, error)

func (*Store) GetMemo added in v0.13.1

func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error)

func (*Store) GetMemoShare added in v0.27.0

func (s *Store) GetMemoShare(ctx context.Context, find *FindMemoShare) (*MemoShare, error)

GetMemoShare returns the first share grant matching the filter, or nil if none found.

func (*Store) GetReaction added in v0.25.3

func (s *Store) GetReaction(ctx context.Context, find *FindReaction) (*Reaction, error)

func (*Store) GetSpace added in v0.31.0

func (s *Store) GetSpace(ctx context.Context, find *FindSpace) (*Space, error)

GetSpace returns the first matching space.

func (*Store) GetSpaceInvitation added in v0.31.0

func (s *Store) GetSpaceInvitation(ctx context.Context, find *FindSpaceInvitation) (*SpaceInvitation, error)

GetSpaceInvitation returns the first matching pending invitation.

func (*Store) GetSpaceMember added in v0.31.0

func (s *Store) GetSpaceMember(ctx context.Context, find *FindSpaceMember) (*SpaceMember, error)

GetSpaceMember returns the first matching membership.

func (*Store) GetStoredIdentityProvider added in v0.30.0

func (s *Store) GetStoredIdentityProvider(ctx context.Context, find *FindIdentityProvider) (*storepb.IdentityProvider, error)

GetStoredIdentityProvider returns a database-backed provider without deployment shadowing.

func (*Store) GetStoredInstanceSetting added in v0.30.0

func (s *Store) GetStoredInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error)

GetStoredInstanceSetting returns a database-backed setting without deployment shadowing.

func (*Store) GetUser added in v0.13.2

func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error)

func (*Store) GetUserByPATHash added in v0.26.0

func (s *Store) GetUserByPATHash(ctx context.Context, tokenHash string) (*PATQueryResult, error)

GetUserByPATHash finds a user by PAT hash.

func (*Store) GetUserIdentity added in v0.28.0

func (s *Store) GetUserIdentity(ctx context.Context, find *FindUserIdentity) (*UserIdentity, error)

GetUserIdentity returns the first linkage record matching the filter, or nil if none found.

func (*Store) GetUserMemoViews added in v0.31.0

func (s *Store) GetUserMemoViews(ctx context.Context, userID int32) ([]*storepb.MemoViewsUserSetting_MemoView, error)

GetUserMemoViews returns the memo views of the user.

func (*Store) GetUserPersonalAccessTokens added in v0.26.0

func (s *Store) GetUserPersonalAccessTokens(ctx context.Context, userID int32) ([]*storepb.PersonalAccessTokensUserSetting_PersonalAccessToken, error)

GetUserPersonalAccessTokens returns the PATs of the user.

func (*Store) GetUserRefreshTokenByID added in v0.26.0

func (s *Store) GetUserRefreshTokenByID(ctx context.Context, userID int32, tokenID string) (*storepb.RefreshTokensUserSetting_RefreshToken, error)

GetUserRefreshTokenByID returns a specific refresh token.

func (*Store) GetUserRefreshTokens added in v0.26.0

func (s *Store) GetUserRefreshTokens(ctx context.Context, userID int32) ([]*storepb.RefreshTokensUserSetting_RefreshToken, error)

GetUserRefreshTokens returns the refresh tokens of the user.

func (*Store) GetUserSetting added in v0.13.2

func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error)

func (*Store) GetUserWebhooks added in v0.25.0

func (s *Store) GetUserWebhooks(ctx context.Context, userID int32) ([]*storepb.WebhooksUserSetting_Webhook, error)

GetUserWebhooks returns the webhooks of the user.

func (*Store) IsIdentityProviderDeploymentConfigured added in v0.30.0

func (s *Store) IsIdentityProviderDeploymentConfigured(uid string) bool

IsIdentityProviderDeploymentConfigured reports whether uid is file-backed.

func (*Store) IsInstanceSettingDeploymentConfigured added in v0.30.0

func (s *Store) IsInstanceSettingDeploymentConfigured(key storepb.InstanceSettingKey) bool

IsInstanceSettingDeploymentConfigured reports whether key is file-backed.

func (*Store) ListAttachments added in v0.25.0

func (s *Store) ListAttachments(ctx context.Context, find *FindAttachment) ([]*Attachment, error)

func (*Store) ListIdentityProviders added in v0.11.0

func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProvider) ([]*storepb.IdentityProvider, error)

func (*Store) ListInboxes added in v0.17.0

func (s *Store) ListInboxes(ctx context.Context, find *FindInbox) ([]*Inbox, error)

ListInboxes retrieves inbox items matching the filter criteria.

func (*Store) ListInstanceSettings added in v0.25.3

func (s *Store) ListInstanceSettings(ctx context.Context, find *FindInstanceSetting) ([]*storepb.InstanceSetting, error)

func (*Store) ListMemoRelations added in v0.13.0

func (s *Store) ListMemoRelations(ctx context.Context, find *FindMemoRelation) ([]*MemoRelation, error)

func (*Store) ListMemoShares added in v0.27.0

func (s *Store) ListMemoShares(ctx context.Context, find *FindMemoShare) ([]*MemoShare, error)

ListMemoShares returns all share grants matching the filter.

func (*Store) ListMemos added in v0.13.1

func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)

func (*Store) ListReactions added in v0.20.0

func (s *Store) ListReactions(ctx context.Context, find *FindReaction) ([]*Reaction, error)

func (*Store) ListSpaceInvitations added in v0.31.0

func (s *Store) ListSpaceInvitations(ctx context.Context, find *FindSpaceInvitation) ([]*SpaceInvitation, error)

ListSpaceInvitations returns pending invitations matching find.

func (*Store) ListSpaceMembers added in v0.31.0

func (s *Store) ListSpaceMembers(ctx context.Context, find *FindSpaceMember) ([]*SpaceMember, error)

ListSpaceMembers returns memberships matching find.

func (*Store) ListSpaces added in v0.31.0

func (s *Store) ListSpaces(ctx context.Context, find *FindSpace) ([]*Space, error)

ListSpaces returns spaces matching find.

func (*Store) ListUserIdentities added in v0.28.0

func (s *Store) ListUserIdentities(ctx context.Context, find *FindUserIdentity) ([]*UserIdentity, error)

ListUserIdentities returns all linkage records matching the filter.

func (*Store) ListUserSettings added in v0.13.2

func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error)

func (*Store) ListUsers added in v0.13.2

func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)

func (*Store) LoadDeploymentConfiguration added in v0.30.0

func (s *Store) LoadDeploymentConfiguration(ctx context.Context) error

LoadDeploymentConfiguration loads the default runtime deployment configuration.

func (*Store) LoadDeploymentConfigurationDir added in v0.30.0

func (s *Store) LoadDeploymentConfigurationDir(ctx context.Context, dir string) error

LoadDeploymentConfigurationDir loads and atomically publishes runtime configuration from dir.

func (*Store) Migrate added in v0.22.5

func (s *Store) Migrate(ctx context.Context) error

Migrate migrates the database schema to the latest version. It checks the current schema version and applies any necessary migrations. It also seeds the database with initial data if in demo mode.

func (*Store) RemoveUserMemoView added in v0.31.0

func (s *Store) RemoveUserMemoView(ctx context.Context, userID int32, memoViewID string) (bool, error)

RemoveUserMemoView removes the memo view of the user. It reports whether a matching memo view was found.

func (*Store) RemoveUserPersonalAccessToken added in v0.26.0

func (s *Store) RemoveUserPersonalAccessToken(ctx context.Context, userID int32, tokenID string) error

RemoveUserPersonalAccessToken removes a PAT from the user.

func (*Store) RemoveUserRefreshToken added in v0.26.0

func (s *Store) RemoveUserRefreshToken(ctx context.Context, userID int32, tokenID string) error

RemoveUserRefreshToken removes a refresh token from the user.

func (*Store) RemoveUserWebhook added in v0.25.0

func (s *Store) RemoveUserWebhook(ctx context.Context, userID int32, webhookID string) error

RemoveUserWebhook removes the webhook of the user.

func (*Store) ResolveAttachmentS3Driver added in v0.31.0

func (s *Store) ResolveAttachmentS3Driver(ctx context.Context, attachment *Attachment) (storage.Driver, *storepb.AttachmentPayload_S3Object, error)

ResolveAttachmentS3Driver resolves the storage driver referenced by an S3 attachment payload, validating the payload and supplying the instance setting.

func (*Store) ResolveStorageDriver added in v0.31.0

func (s *Store) ResolveStorageDriver(
	ctx context.Context,
	setting *storepb.InstanceStorageSetting,
	storageID string,
	legacyS3Config *storepb.StorageS3Config,
) (storage.Driver, error)

ResolveStorageDriver resolves the configured storage referenced by an attachment and returns its driver, reusing the Store cache for named storage. legacyS3Config supports attachments written before storage IDs were introduced.

func (*Store) RevokeSpaceInvitation added in v0.31.0

func (s *Store) RevokeSpaceInvitation(ctx context.Context, revoke *RevokeSpaceInvitation, actorUserID int32) error

RevokeSpaceInvitation deletes a pending invitation after authorizing an active space administrator.

func (*Store) StorageDriver added in v0.31.0

func (s *Store) StorageDriver(ctx context.Context, resolvedStorage *storepb.Storage) (storage.Driver, error)

StorageDriver returns the driver for a resolved storage, reusing cached clients so request paths do not rebuild an S3 client (config load, HTTP transport) per call. ID-less legacy storages are not cached.

func (*Store) UpdateAttachment added in v0.25.0

func (s *Store) UpdateAttachment(ctx context.Context, update *UpdateAttachment) error

func (*Store) UpdateIdentityProvider added in v0.11.0

func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdentityProviderV1) (*storepb.IdentityProvider, error)

func (*Store) UpdateInbox added in v0.17.0

func (s *Store) UpdateInbox(ctx context.Context, update *UpdateInbox) (*Inbox, error)

UpdateInbox updates an existing inbox item.

func (*Store) UpdateMemo added in v0.13.1

func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error

func (*Store) UpdatePATLastUsed added in v0.26.0

func (s *Store) UpdatePATLastUsed(ctx context.Context, userID int32, tokenID string, lastUsed *timestamppb.Timestamp) error

UpdatePATLastUsed updates the last_used_at timestamp of a PAT.

func (*Store) UpdateSpace added in v0.31.0

func (s *Store) UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserID int32) (*Space, error)

UpdateSpace updates and returns a space.

func (*Store) UpdateSpaceMember added in v0.31.0

func (s *Store) UpdateSpaceMember(ctx context.Context, update *UpdateSpaceMember, actorUserID int32) (*SpaceMember, error)

UpdateSpaceMember updates and returns a membership after checking that the change keeps an active ADMIN.

func (*Store) UpdateUser added in v0.14.0

func (s *Store) UpdateUser(ctx context.Context, update *UpdateUser) (*User, error)

func (*Store) UpdateUserMemoView added in v0.31.0

func (s *Store) UpdateUserMemoView(
	ctx context.Context,
	userID int32,
	memoViewID string,
	title *string,
	filter *string,
) (*storepb.MemoViewsUserSetting_MemoView, error)

UpdateUserMemoView applies the non-nil field updates to the memo view carrying the same ID. It returns nil when no matching memo view is found.

func (*Store) UpdateUserWebhook added in v0.25.0

func (s *Store) UpdateUserWebhook(ctx context.Context, userID int32, webhook *storepb.WebhooksUserSetting_Webhook) error

UpdateUserWebhook updates an existing webhook for the user.

func (*Store) UpsertInstanceGeneralSettingSafely added in v0.30.0

func (s *Store) UpsertInstanceGeneralSettingSafely(ctx context.Context, setting *storepb.InstanceSetting) (*storepb.InstanceSetting, error)

UpsertInstanceGeneralSettingSafely validates and stores GENERAL as one serialized operation.

func (*Store) UpsertInstanceSetting added in v0.25.3

func (s *Store) UpsertInstanceSetting(ctx context.Context, upsert *storepb.InstanceSetting) (*storepb.InstanceSetting, error)

func (*Store) UpsertMemoRelation added in v0.13.0

func (s *Store) UpsertMemoRelation(ctx context.Context, create *MemoRelation) (*MemoRelation, error)

func (*Store) UpsertReaction added in v0.20.0

func (s *Store) UpsertReaction(ctx context.Context, upsert *Reaction) (*Reaction, error)

func (*Store) UpsertUserSetting added in v0.4.0

func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error)

type UpdateAttachment added in v0.25.0

type UpdateAttachment struct {
	ID        int32
	UID       *string
	UpdatedTs *int64
	Filename  *string
	MemoID    *int32
	Payload   *storepb.AttachmentPayload
	// Policy is present for transport-facing updates. Drivers discover the
	// current attachment binding and authorize any linked memo in the same
	// transaction as the update.
	Policy *MemoWritePolicy
}

type UpdateIdentityProvider added in v0.13.2

type UpdateIdentityProvider struct {
	ID               int32
	Name             *string
	IdentifierFilter *string
	Config           *string
}

type UpdateIdentityProviderV1 added in v0.21.1

type UpdateIdentityProviderV1 struct {
	ID               int32
	Type             storepb.IdentityProvider_Type
	Name             *string
	IdentifierFilter *string
	Config           *storepb.IdentityProviderConfig
}

type UpdateInbox added in v0.17.0

type UpdateInbox struct {
	ID     int32
	Status InboxStatus
}

UpdateInbox contains fields that can be updated for an inbox item.

type UpdateMemo added in v0.14.0

type UpdateMemo struct {
	ID         int32
	UID        *string
	CreatedTs  *int64
	UpdatedTs  *int64
	RowStatus  *RowStatus
	Content    *string
	Visibility *Visibility
	Pinned     *bool
	Payload    *storepb.MemoPayload
	SpaceID    *int32
	ClearSpace bool
	// Policy is set by transport-facing author mutations. Drivers revalidate it
	// in the same transaction as the update; nil preserves trusted internal and
	// migration callers.
	Policy *MemoWritePolicy
}

type UpdateSpace added in v0.31.0

type UpdateSpace struct {
	ID          int32
	Title       *string
	Description *string
}

UpdateSpace contains mutable space fields.

type UpdateSpaceMember added in v0.31.0

type UpdateSpaceMember struct {
	SpaceID int32
	UserID  int32
	Role    *SpaceMemberRole
}

UpdateSpaceMember contains mutable membership fields.

type UpdateUser added in v0.14.0

type UpdateUser struct {
	ID int32

	UpdatedTs    *int64
	RowStatus    *RowStatus
	Username     *string
	Role         *Role
	Email        *string
	Nickname     *string
	Password     *string
	AvatarURL    *string
	PasswordHash *string
	Description  *string
}

type User added in v0.14.0

type User struct {
	ID int32

	// Standard fields
	RowStatus RowStatus
	CreatedTs int64
	UpdatedTs int64

	// Domain specific fields
	Username     string
	Role         Role
	Email        string
	Nickname     string
	PasswordHash string
	AvatarURL    string
	Description  string
}

type UserIdentity added in v0.28.0

type UserIdentity struct {
	ID        int32
	UserID    int32
	Provider  string
	ExternUID string
	CreatedTs int64
	UpdatedTs int64
}

UserIdentity is the linkage between an external identity subject and a local user. Uniqueness is enforced on (Provider, ExternUID); one local user may have multiple identities across different providers.

type UserSetting added in v0.13.2

type UserSetting struct {
	UserID int32
	Key    storepb.UserSetting_Key
	Value  string
}

type Visibility added in v0.13.1

type Visibility string

Visibility is the type of a visibility.

const (
	// Public is the PUBLIC visibility.
	Public Visibility = "PUBLIC"
	// Protected is the PROTECTED visibility.
	Protected Visibility = "PROTECTED"
	// Private is the PRIVATE visibility.
	Private Visibility = "PRIVATE"
	// SpaceAudience is visible only to active members of its space.
	SpaceAudience Visibility = "SPACE"
)

func (Visibility) String added in v0.13.1

func (v Visibility) String() string

Directories

Path Synopsis
db
sqlite
Package sqlite provides SQLite driver implementation with custom functions.
Package sqlite provides SQLite driver implementation with custom functions.

Jump to

Keyboard shortcuts

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