db

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AuthorNotFoundError = "author not found"
View Source
const PadDoesNotExistError = "pad not found"
View Source
const PadReadOnlyIdNotFoundError = "pad read only id not found"
View Source
const PadRevisionNotFoundError = "pad revision not found"
View Source
const SessionNotFoundError = "session not found"
View Source
const SheetDoesNotExistError = "sheet does not exist"

Variables

View Source
var (
	// ErrAccountNotFound is returned for an unknown account id.
	ErrAccountNotFound = errors.New("account not found")
	// ErrRoleNotFound is returned for an unknown role id.
	ErrRoleNotFound = errors.New("role not found")
	// ErrAssignmentNotFound is returned for an unknown role assignment.
	ErrAssignmentNotFound = errors.New("role assignment not found")
)
View Source
var ErrAPIKeyNotFound = errors.New("api key not found")

ErrAPIKeyNotFound is returned for an unknown key id.

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

ErrConflict is returned by SaveRevision and SaveChatMessage when the revision or chat message number is already taken. Another writer (for instance another Etherpad instance on the same database) got there first; the caller must catch up and retry. It is never silently ignored, because that would drop a change the client was told was saved.

View Source
var ErrMapperTaken = errors.New("mapper belongs to another author")

ErrMapperTaken: another author already has the mapper (unique since migration 16, so two concurrent first uses cannot both get it).

View Source
var ErrTokenNotFound = errors.New("token not found")

ErrTokenNotFound is returned when a token does not exist.

View Source
var ErrTokenTransferNotFound = errors.New("token transfer not found")

ErrTokenTransferNotFound is returned for an unknown or redeemed code.

Functions

func CreateRandomPad added in v0.0.2

func CreateRandomPad() db2.PadDB

func RandomString added in v0.0.4

func RandomString(length int) string

func ReadToAuthorDB added in v0.0.4

func ReadToAuthorDB(reader Reader) (*db.AuthorDB, error)

func ReadToPadDB added in v0.0.4

func ReadToPadDB(reader Reader) (*db.PadDB, error)

Types

type APIKey added in v0.7.0

type APIKey struct {
	ID          string
	Description string
	// Prefix is the start of the key, to tell keys apart.
	Prefix    string
	Hash      string
	CreatedAt time.Time
	// LastUsed is nil for a key never used.
	LastUsed *time.Time
	Disabled bool
}

APIKey is a key for the HTTP API (/api), created in the admin UI. Only a hash of the key is stored; the key itself is shown once, when it is created.

type APIKeyMethods added in v0.7.0

type APIKeyMethods interface {
	CreateAPIKey(key APIKey) error
	// ListAPIKeys returns the keys, oldest first.
	ListAPIKeys() ([]APIKey, error)
	// GetAPIKeyByHash returns the key with this hash, or nil.
	GetAPIKeyByHash(hash string) (*APIKey, error)
	SetAPIKeyDisabled(id string, disabled bool) error
	DeleteAPIKey(id string) error
	// TouchAPIKey records that the key was used at.
	TouchAPIKey(id string, at time.Time) error
}

APIKeyMethods store the API keys.

type Account added in v0.7.0

type Account struct {
	ID          string
	Username    string
	DisplayName string
	Email       string
	// Kind is "human", "service" or "anonymous".
	Kind string
	// PasswordHash is empty for accounts without a password.
	PasswordHash       string
	MustChangePassword bool
	DisabledAt         *time.Time
	// AuthorID links the account to its pad author, "" until it wrote.
	AuthorID    string
	CreatedAt   time.Time
	LastLoginAt *time.Time
}

Account is a person who logs in, a service account that only owns tokens, or the built-in anonymous account of visitors who are not logged in (lib/accounts).

type AccountMethods added in v0.7.0

type AccountMethods interface {
	CreateAccount(a Account) error
	// GetAccount returns the account, or nil.
	GetAccount(id string) (*Account, error)
	// GetAccountByUsername returns the account, or nil.
	GetAccountByUsername(username string) (*Account, error)
	// ListAccounts returns all accounts, oldest first.
	ListAccounts() ([]Account, error)
	UpdateAccount(a Account) error
	// DeleteAccount removes the account and its assignments.
	DeleteAccount(id string) error

	CreateRole(r Role) error
	// GetRole returns the role, or nil.
	GetRole(id string) (*Role, error)
	// ListRoles returns all roles by name.
	ListRoles() ([]Role, error)
	UpdateRole(r Role) error
	// DeleteRole removes the role, its assignments and its inclusion in
	// other roles.
	DeleteRole(id string) error

	// AddRoleAssignment stores a; the same account, role and pattern
	// again is ErrConflict.
	AddRoleAssignment(a RoleAssignment) error
	RemoveRoleAssignment(accountID, roleID, padPattern string) error
	// ListRoleAssignments returns the assignments of the account, or of
	// all accounts for "".
	ListRoleAssignments(accountID string) ([]RoleAssignment, error)

	// TouchLogin sets only the last login time of an account.
	TouchLogin(id string, at time.Time) error

	// AppendAudit stores e; an id that exists is ErrConflict.
	AppendAudit(e AuditEntry) error
	// ListAudit returns the newest entries first, at most limit.
	ListAudit(limit int) ([]AuditEntry, error)
	// HasAuditEntry reports whether an entry with this id exists.
	HasAuditEntry(id string) (bool, error)
}

AccountMethods store accounts, roles, their assignments and the audit log. Create methods return ErrConflict for a taken id or username.

type AuditEntry added in v0.7.0

type AuditEntry struct {
	ID      string
	At      time.Time
	ActorID string
	Action  string
	Target  string
	Details string
}

AuditEntry records a change to accounts, roles or assignments.

type AuthorMethods

type AuthorMethods interface {
	GetAuthor(author string) (*db.AuthorDB, error)
	GetPadIdsOfAuthor(authorId string) (*[]string, error)
	GetAuthorByToken(token string) (*string, error)
	SetAuthorByToken(token string, author string) error
	SaveAuthor(author db.AuthorDB) error
	SaveAuthorName(authorId string, authorName string) error
	SaveAuthorColor(authorId string, authorColor string) error
	GetAuthors(ids []string) (*[]db.AuthorDB, error)
	// RemoveTokenOfAuthor severs the token binding that links a person to the
	// given author id (GDPR erasure). It is a no-op if the author does not
	// exist or has no token.
	RemoveTokenOfAuthor(authorId string) error
}

type AuthorPrivacyMethods added in v0.7.0

type AuthorPrivacyMethods interface {
	// GetAuthorByMapper returns the author created for mapper, or "".
	GetAuthorByMapper(mapper string) (string, error)
	SetAuthorMapper(authorId string, mapper string) error
	// RemoveMapperOfAuthor drops the mapper and reports whether there was one.
	RemoveMapperOfAuthor(authorId string) (bool, error)
	// TouchAuthor records that the author was seen at (ms).
	TouchAuthor(authorId string, at int64) error
	// GetAuthorRow returns the author, or nil.
	GetAuthorRow(authorId string) (*AuthorRow, error)
	MarkAuthorErased(authorId string, at int64) error
	CountChatMessagesOfAuthor(authorId string) (int, error)
	SearchAuthors(s AuthorSearch) ([]AuthorRow, error)

	CreateTokenTransfer(t TokenTransfer) error
	// TakeTokenTransfer removes and returns the transfer: it is redeemed at
	// most once, also by two requests at the same time.
	TakeTokenTransfer(id string) (*TokenTransfer, error)
	// RemoveTokenTransfersBefore drops transfers created before t.
	RemoveTokenTransfersBefore(t time.Time) error
}

AuthorPrivacyMethods are the author data of erasure (GDPR Art. 17), the admin's author list and the token transfer.

type AuthorRow added in v0.7.0

type AuthorRow struct {
	ID       string
	Name     *string
	ColorId  string
	Mapper   *string
	LastSeen int64 // ms, 0 unknown
	Erased   bool
	ErasedAt int64 // ms, 0 not erased
}

AuthorRow is an author as the admin's author list shows it.

type AuthorSearch added in v0.7.0

type AuthorSearch struct {
	// Pattern is matched, case-insensitively, against the id, name and
	// mapper; "" matches every author.
	Pattern       string
	IncludeErased bool
	// SortBy is "name" or "lastSeen".
	SortBy    string
	Ascending bool
	// Cap is the most rows returned.
	Cap int
}

AuthorSearch selects authors for the admin's list.

type ChatMethods

type ChatMethods interface {
	RemoveChat(padId string) error
	SaveChatMessage(padId string, head int, authorId *string, timestamp int64, text string) error
	GetChatsOfPad(padId string, start int, end int) (*[]db.ChatMessageDBWithDisplayName, error)
	GetAuthorIdsOfPadChats(id string) (*[]string, error)
	// ClearChatAuthorship nulls the authorship of all chat messages posted by
	// the given author while preserving the messages themselves (GDPR erasure).
	ClearChatAuthorship(authorId string) error
}

type ClusterMethods added in v0.7.0

type ClusterMethods interface {
	// HeartbeatClusterNode records the instance as alive at now, with its
	// connected users.
	HeartbeatClusterNode(id, address string, now time.Time, users int) error
	ListClusterNodes(aliveSince time.Time) ([]ClusterNode, error)
	RemoveClusterNode(id string) error
	// PruneClusterNodes removes instances not seen since before.
	PruneClusterNodes(before time.Time) error
}

ClusterMethods are the instance registry: every instance records its gossip address and refreshes it periodically; the others join it.

type ClusterNode added in v0.7.0

type ClusterNode struct {
	ID       string
	Address  string
	LastSeen time.Time
	// Users is the instance's connected users at its last heartbeat.
	Users int
}

ClusterNode is an Etherpad instance registered for discovery.

type ConsistencyMethods added in v0.7.0

type ConsistencyMethods interface {
	// GetPadVersion returns the highest stored revision and chat message.
	GetPadVersion(padID string) (*PadVersion, error)
	// GetRevisionDeltas returns the changesets of revisions fromRev..toRev
	// (inclusive, ascending).
	GetRevisionDeltas(padID string, fromRev, toRev int) ([]RevisionDelta, error)
	// GetRevisionPool returns the attribute pool stored with rev.
	GetRevisionPool(padID string, rev int) (*db.RevPool, error)
	// LockPadsExclusive takes the locks of all padIDs, which must be
	// sorted and unique, excluding every other holder on the same
	// database, also in other processes. It takes all or none: on error
	// nothing is held. Datastores that only one process uses lock within
	// the process.
	LockPadsExclusive(padIDs []string) (release func(), err error)
}

ConsistencyMethods let several Etherpad instances share one database. The revisions in padRev are the authoritative pad state; the pad row and each instance's cached pad are derived from them.

type GroupMethods

type GroupMethods interface {
	GetGroup(groupId string) (*string, error)
	GetGroups() (*[]string, error)
	SaveGroup(groupId string) error
	RemoveGroup(groupId string) error
}

type InstanceFlagMethods added in v0.7.0

type InstanceFlagMethods interface {
	// GetInstanceFlag returns the value of a flag, nil when it is not set.
	GetInstanceFlag(name string) (*string, error)
	// SetInstanceFlag sets a flag unless it is set; it reports whether
	// this call set it (false: it was set, also by another instance).
	SetInstanceFlag(name, value string) (bool, error)
}

InstanceFlagMethods store flags of the instance: steps that ran once for the whole database. A flag is set once and never changed.

type LeaderMethods added in v0.7.0

type LeaderMethods interface {
	// TryLeadership takes the named leader lock if it is free. It never
	// waits: ok is false when another instance holds it.
	TryLeadership(name string) (lease Leadership, ok bool, err error)
}

LeaderMethods elect one instance among those sharing a database to run a background job. The lock is tied to a database connection, so when an instance dies the database releases it and another instance takes over.

type Leadership added in v0.7.0

type Leadership interface {
	Alive() error
	Release()
}

Leadership is a held leader lock. Release gives it up; Alive reports an error once the lock may have been lost (for example because the database connection holding it broke), after which the holder must stop acting as leader.

type MemoryDataStore

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

func NewMemoryDataStore

func NewMemoryDataStore() *MemoryDataStore

func (*MemoryDataStore) AddOIDCStorageValue added in v0.7.0

func (m *MemoryDataStore) AddOIDCStorageValue(key string, payload string) (string, error)

func (*MemoryDataStore) AddRoleAssignment added in v0.7.0

func (m *MemoryDataStore) AddRoleAssignment(a RoleAssignment) error

func (*MemoryDataStore) AppendAudit added in v0.7.0

func (m *MemoryDataStore) AppendAudit(e AuditEntry) error

func (*MemoryDataStore) ClaimReadOnlyId added in v0.7.0

func (m *MemoryDataStore) ClaimReadOnlyId(padID string, candidate string) (string, error)

func (*MemoryDataStore) ClearChatAuthorship added in v0.6.3

func (m *MemoryDataStore) ClearChatAuthorship(authorId string) error

func (*MemoryDataStore) Close added in v0.0.2

func (m *MemoryDataStore) Close() error

func (*MemoryDataStore) ConsumeAuthCode added in v0.7.0

func (m *MemoryDataStore) ConsumeAuthCode(signature string) (bool, error)

func (*MemoryDataStore) CountChatMessagesOfAuthor added in v0.7.0

func (m *MemoryDataStore) CountChatMessagesOfAuthor(authorId string) (int, error)

func (*MemoryDataStore) CreateAPIKey added in v0.7.0

func (m *MemoryDataStore) CreateAPIKey(k APIKey) error

func (*MemoryDataStore) CreateAccessToken added in v0.5.0

func (m *MemoryDataStore) CreateAccessToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (*MemoryDataStore) CreateAccount added in v0.7.0

func (m *MemoryDataStore) CreateAccount(a Account) error

func (*MemoryDataStore) CreateAuthCode added in v0.5.0

func (m *MemoryDataStore) CreateAuthCode(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (*MemoryDataStore) CreateOIDCSession added in v0.5.0

func (m *MemoryDataStore) CreateOIDCSession(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (*MemoryDataStore) CreatePKCE added in v0.5.0

func (m *MemoryDataStore) CreatePKCE(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (*MemoryDataStore) CreatePad

func (m *MemoryDataStore) CreatePad(padID string, padDB db.PadDB) error

func (*MemoryDataStore) CreatePad2ReadOnly deprecated

func (m *MemoryDataStore) CreatePad2ReadOnly(padId string, readonlyId string) error

Deprecated: Use SetReadOnlyId instead

func (*MemoryDataStore) CreateReadOnly2Pad deprecated

func (m *MemoryDataStore) CreateReadOnly2Pad(padId string, readonlyId string) error

Deprecated: Use SetReadOnlyId instead - readonly2pad is derived from pad store

func (*MemoryDataStore) CreateRefreshToken added in v0.5.0

func (m *MemoryDataStore) CreateRefreshToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, active bool, accessTokenSignature string, requestedAt, expiresAt time.Time) error

func (*MemoryDataStore) CreateRole added in v0.7.0

func (m *MemoryDataStore) CreateRole(r Role) error

func (*MemoryDataStore) CreateToken added in v0.7.0

func (m *MemoryDataStore) CreateToken(t Token) error

func (*MemoryDataStore) CreateTokenTransfer added in v0.7.0

func (m *MemoryDataStore) CreateTokenTransfer(t TokenTransfer) error

func (*MemoryDataStore) DeleteAPIKey added in v0.7.0

func (m *MemoryDataStore) DeleteAPIKey(id string) error

func (*MemoryDataStore) DeleteAccessToken added in v0.5.0

func (m *MemoryDataStore) DeleteAccessToken(signature string) error

func (*MemoryDataStore) DeleteAccessTokensByRequestID added in v0.5.0

func (m *MemoryDataStore) DeleteAccessTokensByRequestID(requestID string) error

func (*MemoryDataStore) DeleteAccount added in v0.7.0

func (m *MemoryDataStore) DeleteAccount(id string) error

func (*MemoryDataStore) DeleteOIDCSession added in v0.5.0

func (m *MemoryDataStore) DeleteOIDCSession(signature string) error

func (*MemoryDataStore) DeleteOIDCStorageValue added in v0.5.0

func (m *MemoryDataStore) DeleteOIDCStorageValue(key string) error

func (*MemoryDataStore) DeletePKCE added in v0.5.0

func (m *MemoryDataStore) DeletePKCE(signature string) error

func (*MemoryDataStore) DeleteRefreshToken added in v0.5.0

func (m *MemoryDataStore) DeleteRefreshToken(signature string) error

func (*MemoryDataStore) DeleteRole added in v0.7.0

func (m *MemoryDataStore) DeleteRole(id string) error

func (*MemoryDataStore) DeleteSecretParams added in v0.6.5

func (m *MemoryDataStore) DeleteSecretParams(id string) error

func (*MemoryDataStore) DoesPadExist

func (m *MemoryDataStore) DoesPadExist(padID string) (*bool, error)

func (*MemoryDataStore) DoesSheetExist added in v0.6.5

func (m *MemoryDataStore) DoesSheetExist(padId string) (*bool, error)

func (*MemoryDataStore) GetAPIKeyByHash added in v0.7.0

func (m *MemoryDataStore) GetAPIKeyByHash(hash string) (*APIKey, error)

func (*MemoryDataStore) GetAccessToken added in v0.5.0

func (m *MemoryDataStore) GetAccessToken(signature string) (*OAuthTokenRow, error)

func (*MemoryDataStore) GetAccount added in v0.7.0

func (m *MemoryDataStore) GetAccount(id string) (*Account, error)

func (*MemoryDataStore) GetAccountByUsername added in v0.7.0

func (m *MemoryDataStore) GetAccountByUsername(u string) (*Account, error)

func (*MemoryDataStore) GetAuthCode added in v0.5.0

func (m *MemoryDataStore) GetAuthCode(signature string) (*OAuthTokenRow, error)

func (*MemoryDataStore) GetAuthor

func (m *MemoryDataStore) GetAuthor(authorId string) (*db.AuthorDB, error)

func (*MemoryDataStore) GetAuthorByMapper added in v0.7.0

func (m *MemoryDataStore) GetAuthorByMapper(mapper string) (string, error)

func (*MemoryDataStore) GetAuthorByToken

func (m *MemoryDataStore) GetAuthorByToken(token string) (*string, error)

func (*MemoryDataStore) GetAuthorIdsOfPadChats added in v0.0.4

func (m *MemoryDataStore) GetAuthorIdsOfPadChats(id string) (*[]string, error)

func (*MemoryDataStore) GetAuthorRow added in v0.7.0

func (m *MemoryDataStore) GetAuthorRow(authorId string) (*AuthorRow, error)

func (*MemoryDataStore) GetAuthors added in v0.0.4

func (m *MemoryDataStore) GetAuthors(ids []string) (*[]db.AuthorDB, error)

func (*MemoryDataStore) GetChatsOfPad added in v0.0.2

func (m *MemoryDataStore) GetChatsOfPad(
	padId string,
	start int,
	end int,
) (*[]db.ChatMessageDBWithDisplayName, error)

func (*MemoryDataStore) GetGroup

func (m *MemoryDataStore) GetGroup(groupId string) (*string, error)

func (*MemoryDataStore) GetGroups added in v0.6.3

func (m *MemoryDataStore) GetGroups() (*[]string, error)

func (*MemoryDataStore) GetInstanceFlag added in v0.7.0

func (m *MemoryDataStore) GetInstanceFlag(name string) (*string, error)

func (*MemoryDataStore) GetOIDCSession added in v0.5.0

func (m *MemoryDataStore) GetOIDCSession(signature string) (*OAuthTokenRow, error)

func (*MemoryDataStore) GetOIDCStorageValue added in v0.5.0

func (m *MemoryDataStore) GetOIDCStorageValue(key string) (*string, error)

func (*MemoryDataStore) GetPKCE added in v0.5.0

func (m *MemoryDataStore) GetPKCE(signature string) (*OAuthTokenRow, error)

func (*MemoryDataStore) GetPad

func (m *MemoryDataStore) GetPad(padID string) (*db.PadDB, error)

func (*MemoryDataStore) GetPadByReadOnlyId added in v0.0.4

func (m *MemoryDataStore) GetPadByReadOnlyId(readonlyId string) (*string, error)

func (*MemoryDataStore) GetPadIds

func (m *MemoryDataStore) GetPadIds() (*[]string, error)

func (*MemoryDataStore) GetPadIdsOfAuthor added in v0.0.4

func (m *MemoryDataStore) GetPadIdsOfAuthor(authorId string) (*[]string, error)

func (*MemoryDataStore) GetPadVersion added in v0.7.0

func (m *MemoryDataStore) GetPadVersion(padID string) (*PadVersion, error)

func (*MemoryDataStore) GetReadOnly2Pad deprecated

func (m *MemoryDataStore) GetReadOnly2Pad(id string) (*string, error)

Deprecated: Use GetPadByReadOnlyId instead

func (*MemoryDataStore) GetReadonlyPad

func (m *MemoryDataStore) GetReadonlyPad(padId string) (*string, error)

func (*MemoryDataStore) GetRefreshToken added in v0.5.0

func (m *MemoryDataStore) GetRefreshToken(signature string) (*OAuthRefreshTokenRow, error)

func (*MemoryDataStore) GetRevision

func (m *MemoryDataStore) GetRevision(padId string, rev int) (*db.PadSingleRevision, error)

func (*MemoryDataStore) GetRevisionDeltas added in v0.7.0

func (m *MemoryDataStore) GetRevisionDeltas(padID string, fromRev, toRev int) ([]RevisionDelta, error)

func (*MemoryDataStore) GetRevisionPool added in v0.7.0

func (m *MemoryDataStore) GetRevisionPool(padID string, rev int) (*db.RevPool, error)

func (*MemoryDataStore) GetRevisions added in v0.0.2

func (m *MemoryDataStore) GetRevisions(padId string, startRev int, endRev int) (*[]db.PadSingleRevision, error)

func (*MemoryDataStore) GetRole added in v0.7.0

func (m *MemoryDataStore) GetRole(id string) (*Role, error)

func (*MemoryDataStore) GetServerVersion added in v0.0.5

func (m *MemoryDataStore) GetServerVersion() (*db.ServerVersion, error)

func (*MemoryDataStore) GetSessionById

func (m *MemoryDataStore) GetSessionById(sessionID string) (*session2.Session, error)

func (*MemoryDataStore) GetSheet added in v0.6.5

func (m *MemoryDataStore) GetSheet(padId string) (*db.SheetDB, error)

func (*MemoryDataStore) GetSheetOpInfo added in v0.7.0

func (m *MemoryDataStore) GetSheetOpInfo(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (*MemoryDataStore) GetSheetOps added in v0.6.5

func (m *MemoryDataStore) GetSheetOps(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (*MemoryDataStore) GetSheetVersion added in v0.7.0

func (m *MemoryDataStore) GetSheetVersion(padId string) (*SheetVersion, error)

func (*MemoryDataStore) GetToken added in v0.7.0

func (m *MemoryDataStore) GetToken(id string) (*Token, error)

func (*MemoryDataStore) GetTokenByHash added in v0.7.0

func (m *MemoryDataStore) GetTokenByHash(hash string) (*Token, error)

func (*MemoryDataStore) HasAuditEntry added in v0.7.0

func (m *MemoryDataStore) HasAuditEntry(id string) (bool, error)

func (*MemoryDataStore) HeartbeatClusterNode added in v0.7.0

func (m *MemoryDataStore) HeartbeatClusterNode(id, address string, now time.Time, users int) error

func (*MemoryDataStore) InvalidateAuthCode added in v0.5.0

func (m *MemoryDataStore) InvalidateAuthCode(signature string) error

func (*MemoryDataStore) ListAPIKeys added in v0.7.0

func (m *MemoryDataStore) ListAPIKeys() ([]APIKey, error)

func (*MemoryDataStore) ListAccounts added in v0.7.0

func (m *MemoryDataStore) ListAccounts() ([]Account, error)

func (*MemoryDataStore) ListAudit added in v0.7.0

func (m *MemoryDataStore) ListAudit(limit int) ([]AuditEntry, error)

func (*MemoryDataStore) ListClusterNodes added in v0.7.0

func (m *MemoryDataStore) ListClusterNodes(aliveSince time.Time) ([]ClusterNode, error)

func (*MemoryDataStore) ListPadIDs added in v0.7.0

func (m *MemoryDataStore) ListPadIDs(l PadListing) ([]string, error)

func (*MemoryDataStore) ListRoleAssignments added in v0.7.0

func (m *MemoryDataStore) ListRoleAssignments(accountID string) ([]RoleAssignment, error)

func (*MemoryDataStore) ListRoles added in v0.7.0

func (m *MemoryDataStore) ListRoles() ([]Role, error)

func (*MemoryDataStore) ListSecretParams added in v0.6.5

func (m *MemoryDataStore) ListSecretParams(prefix string) (map[string]string, error)

func (*MemoryDataStore) ListTokens added in v0.7.0

func (m *MemoryDataStore) ListTokens(accountID string) ([]Token, error)

func (*MemoryDataStore) LockPadsExclusive added in v0.7.0

func (m *MemoryDataStore) LockPadsExclusive(padIDs []string) (func(), error)

LockPadsExclusive locks within this process: an in-memory store belongs to one process.

func (*MemoryDataStore) MarkAuthorErased added in v0.7.0

func (m *MemoryDataStore) MarkAuthorErased(authorId string, at int64) error

func (*MemoryDataStore) Ping added in v0.0.5

func (m *MemoryDataStore) Ping() error

func (*MemoryDataStore) PruneClusterNodes added in v0.7.0

func (m *MemoryDataStore) PruneClusterNodes(before time.Time) error

func (*MemoryDataStore) QueryPad added in v0.0.2

func (m *MemoryDataStore) QueryPad(
	offset int,
	limit int,
	sortBy string,
	ascending bool,
	pattern string,
) (*db.PadDBSearchResult, error)

func (*MemoryDataStore) RemoveChat

func (m *MemoryDataStore) RemoveChat(padId string) error

func (*MemoryDataStore) RemoveClusterNode added in v0.7.0

func (m *MemoryDataStore) RemoveClusterNode(id string) error

func (*MemoryDataStore) RemoveGroup added in v0.0.2

func (m *MemoryDataStore) RemoveGroup(groupId string) error

func (*MemoryDataStore) RemoveMapperOfAuthor added in v0.7.0

func (m *MemoryDataStore) RemoveMapperOfAuthor(authorId string) (bool, error)

func (*MemoryDataStore) RemovePad

func (m *MemoryDataStore) RemovePad(padID string) error

func (*MemoryDataStore) RemovePad2ReadOnly deprecated

func (m *MemoryDataStore) RemovePad2ReadOnly(id string) error

Deprecated: Handled by RemovePad

func (*MemoryDataStore) RemoveReadOnly2Pad deprecated

func (m *MemoryDataStore) RemoveReadOnly2Pad(id string) error

Deprecated: Handled by RemovePad

func (*MemoryDataStore) RemoveRevisionsOfPad

func (m *MemoryDataStore) RemoveRevisionsOfPad(padId string) error

func (*MemoryDataStore) RemoveRoleAssignment added in v0.7.0

func (m *MemoryDataStore) RemoveRoleAssignment(accountID, roleID, padPattern string) error

func (*MemoryDataStore) RemoveSessionById

func (m *MemoryDataStore) RemoveSessionById(sessionID string) error

func (*MemoryDataStore) RemoveSheet added in v0.6.5

func (m *MemoryDataStore) RemoveSheet(padId string) error

func (*MemoryDataStore) RemoveSheetOps added in v0.6.5

func (m *MemoryDataStore) RemoveSheetOps(padId string) error

func (*MemoryDataStore) RemoveTokenOfAuthor added in v0.6.3

func (m *MemoryDataStore) RemoveTokenOfAuthor(authorId string) error

func (*MemoryDataStore) RemoveTokenTransfersBefore added in v0.7.0

func (m *MemoryDataStore) RemoveTokenTransfersBefore(before time.Time) error

func (*MemoryDataStore) ReplaceRevisions added in v0.7.0

func (m *MemoryDataStore) ReplaceRevisions(padId string, pad db.PadDB, revisions []db.PadSingleRevision) error

func (*MemoryDataStore) ResetSheet added in v0.7.0

func (m *MemoryDataStore) ResetSheet(padId string, snapshot string) error

func (*MemoryDataStore) RevokeRefreshToken added in v0.5.0

func (m *MemoryDataStore) RevokeRefreshToken(signature string) error

func (*MemoryDataStore) RevokeRefreshTokensByRequestID added in v0.5.0

func (m *MemoryDataStore) RevokeRefreshTokensByRequestID(requestID string) error

func (*MemoryDataStore) SaveAuthor

func (m *MemoryDataStore) SaveAuthor(author db.AuthorDB) error

func (*MemoryDataStore) SaveAuthorColor

func (m *MemoryDataStore) SaveAuthorColor(authorId string, authorColor string) error

func (*MemoryDataStore) SaveAuthorName

func (m *MemoryDataStore) SaveAuthorName(authorId string, authorName string) error

func (*MemoryDataStore) SaveChatHeadOfPad added in v0.0.2

func (m *MemoryDataStore) SaveChatHeadOfPad(padId string, head int) error

func (*MemoryDataStore) SaveChatMessage added in v0.0.2

func (m *MemoryDataStore) SaveChatMessage(
	padId string,
	head int,
	authorId *string,
	timestamp int64,
	text string,
) error

func (*MemoryDataStore) SaveGroup added in v0.0.2

func (m *MemoryDataStore) SaveGroup(groupId string) error

func (*MemoryDataStore) SaveRevision

func (m *MemoryDataStore) SaveRevision(
	padId string,
	rev int,
	changeset string,
	text db.AText,
	pool db.RevPool,
	authorId *string,
	timestamp int64,
) error

func (*MemoryDataStore) SaveSecretParams added in v0.6.5

func (m *MemoryDataStore) SaveSecretParams(id string, prefix string, payload string) error

func (*MemoryDataStore) SaveServerVersion added in v0.0.5

func (m *MemoryDataStore) SaveServerVersion(version string) error

func (*MemoryDataStore) SaveSheet added in v0.6.5

func (m *MemoryDataStore) SaveSheet(padId string, head int, snapshot string) error

func (*MemoryDataStore) SaveSheetOp added in v0.6.5

func (m *MemoryDataStore) SaveSheetOp(padId string, rev int, op string, authorId *string, timestamp int64) error

func (*MemoryDataStore) SearchAuthors added in v0.7.0

func (m *MemoryDataStore) SearchAuthors(s AuthorSearch) ([]AuthorRow, error)

func (*MemoryDataStore) SetAPIKeyDisabled added in v0.7.0

func (m *MemoryDataStore) SetAPIKeyDisabled(id string, disabled bool) error

func (*MemoryDataStore) SetAuthorByToken

func (m *MemoryDataStore) SetAuthorByToken(token string, authorId string) error

func (*MemoryDataStore) SetAuthorMapper added in v0.7.0

func (m *MemoryDataStore) SetAuthorMapper(authorId, mapper string) error

func (*MemoryDataStore) SetInstanceFlag added in v0.7.0

func (m *MemoryDataStore) SetInstanceFlag(name, value string) (bool, error)

func (*MemoryDataStore) SetOIDCStorageValue added in v0.5.0

func (m *MemoryDataStore) SetOIDCStorageValue(key string, payload string) error

func (*MemoryDataStore) SetPadPublicStatus added in v0.7.0

func (m *MemoryDataStore) SetPadPublicStatus(padID string, public bool) error

func (*MemoryDataStore) SetPadSavedRevisions added in v0.7.0

func (m *MemoryDataStore) SetPadSavedRevisions(padID string, saved []db.SavedRevision) error

func (*MemoryDataStore) SetPadSettings added in v0.7.0

func (m *MemoryDataStore) SetPadSettings(padID string, settings string) error

func (*MemoryDataStore) SetReadOnlyId added in v0.0.4

func (m *MemoryDataStore) SetReadOnlyId(padId string, readonlyId string) error

func (*MemoryDataStore) SetSessionById

func (m *MemoryDataStore) SetSessionById(sessionID string, session session2.Session) error

func (*MemoryDataStore) TakeTokenTransfer added in v0.7.0

func (m *MemoryDataStore) TakeTokenTransfer(id string) (*TokenTransfer, error)

func (*MemoryDataStore) TouchAPIKey added in v0.7.0

func (m *MemoryDataStore) TouchAPIKey(id string, at time.Time) error

func (*MemoryDataStore) TouchAuthor added in v0.7.0

func (m *MemoryDataStore) TouchAuthor(authorId string, at int64) error

func (*MemoryDataStore) TouchLogin added in v0.7.0

func (m *MemoryDataStore) TouchLogin(id string, at time.Time) error

func (*MemoryDataStore) TouchToken added in v0.7.0

func (m *MemoryDataStore) TouchToken(id string, at time.Time, ip string) error

func (*MemoryDataStore) TryLeadership added in v0.7.0

func (m *MemoryDataStore) TryLeadership(name string) (Leadership, bool, error)

func (*MemoryDataStore) UpdateAccount added in v0.7.0

func (m *MemoryDataStore) UpdateAccount(a Account) error

func (*MemoryDataStore) UpdatePadHead added in v0.7.0

func (m *MemoryDataStore) UpdatePadHead(padID string, head int, pool db.RevPool) error

func (*MemoryDataStore) UpdatePadHeadText added in v0.7.0

func (m *MemoryDataStore) UpdatePadHeadText(padID string, head int, pool db.RevPool, text db.AText) error

func (*MemoryDataStore) UpdateRole added in v0.7.0

func (m *MemoryDataStore) UpdateRole(r Role) error

func (*MemoryDataStore) UpdateToken added in v0.7.0

func (m *MemoryDataStore) UpdateToken(t Token) error

type MySQLOptions added in v0.0.2

type MySQLOptions struct {
	Username string
	Password string
	Port     int
	Host     string
	Database string
	// MaxConns caps the connection pool; 0 means the default of 25.
	MaxConns int
}

type MysqlDB added in v0.0.2

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

func NewMySQLDB added in v0.0.2

func NewMySQLDB(options MySQLOptions) (*MysqlDB, error)

func (MysqlDB) AddOIDCStorageValue added in v0.7.0

func (d MysqlDB) AddOIDCStorageValue(key string, payload string) (string, error)

func (MysqlDB) AddRoleAssignment added in v0.7.0

func (d MysqlDB) AddRoleAssignment(a RoleAssignment) error

func (MysqlDB) AppendAudit added in v0.7.0

func (d MysqlDB) AppendAudit(e AuditEntry) error

func (MysqlDB) ClaimReadOnlyId added in v0.7.0

func (d MysqlDB) ClaimReadOnlyId(padID string, candidate string) (string, error)

func (MysqlDB) ClearChatAuthorship added in v0.6.3

func (d MysqlDB) ClearChatAuthorship(authorId string) error

func (MysqlDB) Close added in v0.0.2

func (d MysqlDB) Close() error

func (MysqlDB) ConsumeAuthCode added in v0.7.0

func (d MysqlDB) ConsumeAuthCode(signature string) (bool, error)

func (MysqlDB) CountChatMessagesOfAuthor added in v0.7.0

func (d MysqlDB) CountChatMessagesOfAuthor(id string) (int, error)

func (MysqlDB) CreateAPIKey added in v0.7.0

func (d MysqlDB) CreateAPIKey(k APIKey) error

func (MysqlDB) CreateAccessToken added in v0.5.0

func (d MysqlDB) CreateAccessToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (MysqlDB) CreateAccount added in v0.7.0

func (d MysqlDB) CreateAccount(a Account) error

func (MysqlDB) CreateAuthCode added in v0.5.0

func (d MysqlDB) CreateAuthCode(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (MysqlDB) CreateOIDCSession added in v0.5.0

func (d MysqlDB) CreateOIDCSession(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (MysqlDB) CreatePKCE added in v0.5.0

func (d MysqlDB) CreatePKCE(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (MysqlDB) CreatePad added in v0.0.2

func (d MysqlDB) CreatePad(padID string, padDB db.PadDB) error

func (MysqlDB) CreateRefreshToken added in v0.5.0

func (d MysqlDB) CreateRefreshToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, active bool, accessTokenSignature string, requestedAt, expiresAt time.Time) error

func (MysqlDB) CreateRole added in v0.7.0

func (d MysqlDB) CreateRole(r Role) error

func (MysqlDB) CreateToken added in v0.7.0

func (d MysqlDB) CreateToken(t Token) error

func (MysqlDB) CreateTokenTransfer added in v0.7.0

func (d MysqlDB) CreateTokenTransfer(t TokenTransfer) error

func (MysqlDB) DeleteAPIKey added in v0.7.0

func (d MysqlDB) DeleteAPIKey(id string) error

func (MysqlDB) DeleteAccessToken added in v0.5.0

func (d MysqlDB) DeleteAccessToken(signature string) error

func (MysqlDB) DeleteAccessTokensByRequestID added in v0.5.0

func (d MysqlDB) DeleteAccessTokensByRequestID(requestID string) error

func (MysqlDB) DeleteAccount added in v0.7.0

func (d MysqlDB) DeleteAccount(id string) error

func (MysqlDB) DeleteOIDCSession added in v0.5.0

func (d MysqlDB) DeleteOIDCSession(signature string) error

func (MysqlDB) DeleteOIDCStorageValue added in v0.5.0

func (d MysqlDB) DeleteOIDCStorageValue(key string) error

func (MysqlDB) DeletePKCE added in v0.5.0

func (d MysqlDB) DeletePKCE(signature string) error

func (MysqlDB) DeleteRefreshToken added in v0.5.0

func (d MysqlDB) DeleteRefreshToken(signature string) error

func (MysqlDB) DeleteRole added in v0.7.0

func (d MysqlDB) DeleteRole(id string) error

func (MysqlDB) DeleteSecretParams added in v0.6.5

func (d MysqlDB) DeleteSecretParams(id string) error

func (MysqlDB) DoesPadExist added in v0.0.2

func (d MysqlDB) DoesPadExist(padID string) (*bool, error)

func (MysqlDB) DoesSheetExist added in v0.6.5

func (d MysqlDB) DoesSheetExist(padId string) (*bool, error)

func (MysqlDB) GetAPIKeyByHash added in v0.7.0

func (d MysqlDB) GetAPIKeyByHash(h string) (*APIKey, error)

func (MysqlDB) GetAccessToken added in v0.5.0

func (d MysqlDB) GetAccessToken(signature string) (*OAuthTokenRow, error)

func (MysqlDB) GetAccount added in v0.7.0

func (d MysqlDB) GetAccount(id string) (*Account, error)

func (MysqlDB) GetAccountByUsername added in v0.7.0

func (d MysqlDB) GetAccountByUsername(u string) (*Account, error)

func (MysqlDB) GetAuthCode added in v0.5.0

func (d MysqlDB) GetAuthCode(signature string) (*OAuthTokenRow, error)

func (MysqlDB) GetAuthor added in v0.0.2

func (d MysqlDB) GetAuthor(authorId string) (*db.AuthorDB, error)

func (MysqlDB) GetAuthorByMapper added in v0.7.0

func (d MysqlDB) GetAuthorByMapper(m string) (string, error)

func (MysqlDB) GetAuthorByToken added in v0.0.2

func (d MysqlDB) GetAuthorByToken(token string) (*string, error)

func (MysqlDB) GetAuthorIdsOfPadChats added in v0.0.4

func (d MysqlDB) GetAuthorIdsOfPadChats(id string) (*[]string, error)

func (MysqlDB) GetAuthorRow added in v0.7.0

func (d MysqlDB) GetAuthorRow(id string) (*AuthorRow, error)

func (MysqlDB) GetAuthors added in v0.0.4

func (d MysqlDB) GetAuthors(ids []string) (*[]db.AuthorDB, error)

func (MysqlDB) GetChatsOfPad added in v0.0.2

func (d MysqlDB) GetChatsOfPad(
	padId string,
	start int,
	end int,
) (*[]db.ChatMessageDBWithDisplayName, error)

func (MysqlDB) GetGroup added in v0.0.2

func (d MysqlDB) GetGroup(groupId string) (*string, error)

func (MysqlDB) GetGroups added in v0.6.3

func (d MysqlDB) GetGroups() (*[]string, error)

func (MysqlDB) GetInstanceFlag added in v0.7.0

func (d MysqlDB) GetInstanceFlag(name string) (*string, error)

func (MysqlDB) GetOIDCSession added in v0.5.0

func (d MysqlDB) GetOIDCSession(signature string) (*OAuthTokenRow, error)

func (MysqlDB) GetOIDCStorageValue added in v0.5.0

func (d MysqlDB) GetOIDCStorageValue(key string) (*string, error)

func (MysqlDB) GetPKCE added in v0.5.0

func (d MysqlDB) GetPKCE(signature string) (*OAuthTokenRow, error)

func (MysqlDB) GetPad added in v0.0.2

func (d MysqlDB) GetPad(padID string) (*db.PadDB, error)

func (MysqlDB) GetPadByReadOnlyId added in v0.0.4

func (d MysqlDB) GetPadByReadOnlyId(readonlyId string) (*string, error)

func (MysqlDB) GetPadIds added in v0.0.2

func (d MysqlDB) GetPadIds() (*[]string, error)

func (MysqlDB) GetPadIdsOfAuthor added in v0.0.4

func (d MysqlDB) GetPadIdsOfAuthor(authorId string) (*[]string, error)

func (MysqlDB) GetPadVersion added in v0.7.0

func (d MysqlDB) GetPadVersion(padID string) (*PadVersion, error)

func (MysqlDB) GetReadonlyPad added in v0.0.2

func (d MysqlDB) GetReadonlyPad(padId string) (*string, error)

func (MysqlDB) GetRefreshToken added in v0.5.0

func (d MysqlDB) GetRefreshToken(signature string) (*OAuthRefreshTokenRow, error)

func (MysqlDB) GetRevision added in v0.0.2

func (d MysqlDB) GetRevision(padId string, rev int) (*db.PadSingleRevision, error)

func (MysqlDB) GetRevisionDeltas added in v0.7.0

func (d MysqlDB) GetRevisionDeltas(padID string, fromRev, toRev int) ([]RevisionDelta, error)

func (MysqlDB) GetRevisionPool added in v0.7.0

func (d MysqlDB) GetRevisionPool(padID string, rev int) (*db.RevPool, error)

func (MysqlDB) GetRevisions added in v0.0.2

func (d MysqlDB) GetRevisions(padId string, startRev int, endRev int) (*[]db.PadSingleRevision, error)

func (MysqlDB) GetRole added in v0.7.0

func (d MysqlDB) GetRole(id string) (*Role, error)

func (MysqlDB) GetServerVersion added in v0.0.5

func (d MysqlDB) GetServerVersion() (*db.ServerVersion, error)

func (MysqlDB) GetSessionById added in v0.0.2

func (d MysqlDB) GetSessionById(sessionID string) (*session2.Session, error)

func (MysqlDB) GetSheet added in v0.6.5

func (d MysqlDB) GetSheet(padId string) (*db.SheetDB, error)

func (MysqlDB) GetSheetOpInfo added in v0.7.0

func (d MysqlDB) GetSheetOpInfo(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (MysqlDB) GetSheetOps added in v0.6.5

func (d MysqlDB) GetSheetOps(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (MysqlDB) GetSheetVersion added in v0.7.0

func (d MysqlDB) GetSheetVersion(padId string) (*SheetVersion, error)

func (MysqlDB) GetToken added in v0.7.0

func (d MysqlDB) GetToken(id string) (*Token, error)

func (MysqlDB) GetTokenByHash added in v0.7.0

func (d MysqlDB) GetTokenByHash(h string) (*Token, error)

func (MysqlDB) HasAuditEntry added in v0.7.0

func (d MysqlDB) HasAuditEntry(id string) (bool, error)

func (MysqlDB) HeartbeatClusterNode added in v0.7.0

func (d MysqlDB) HeartbeatClusterNode(id, address string, now time.Time, users int) error

func (MysqlDB) InvalidateAuthCode added in v0.5.0

func (d MysqlDB) InvalidateAuthCode(signature string) error

func (MysqlDB) ListAPIKeys added in v0.7.0

func (d MysqlDB) ListAPIKeys() ([]APIKey, error)

func (MysqlDB) ListAccounts added in v0.7.0

func (d MysqlDB) ListAccounts() ([]Account, error)

func (MysqlDB) ListAudit added in v0.7.0

func (d MysqlDB) ListAudit(limit int) ([]AuditEntry, error)

func (MysqlDB) ListClusterNodes added in v0.7.0

func (d MysqlDB) ListClusterNodes(aliveSince time.Time) ([]ClusterNode, error)

func (MysqlDB) ListPadIDs added in v0.7.0

func (d MysqlDB) ListPadIDs(l PadListing) ([]string, error)

func (MysqlDB) ListRoleAssignments added in v0.7.0

func (d MysqlDB) ListRoleAssignments(accountID string) ([]RoleAssignment, error)

func (MysqlDB) ListRoles added in v0.7.0

func (d MysqlDB) ListRoles() ([]Role, error)

func (MysqlDB) ListSecretParams added in v0.6.5

func (d MysqlDB) ListSecretParams(prefix string) (map[string]string, error)

func (MysqlDB) ListTokens added in v0.7.0

func (d MysqlDB) ListTokens(accountID string) ([]Token, error)

func (MysqlDB) LockPadsExclusive added in v0.7.0

func (d MysqlDB) LockPadsExclusive(padIDs []string) (func(), error)

func (MysqlDB) MarkAuthorErased added in v0.7.0

func (d MysqlDB) MarkAuthorErased(id string, at int64) error

func (MysqlDB) Ping added in v0.0.5

func (d MysqlDB) Ping() error

func (MysqlDB) PruneClusterNodes added in v0.7.0

func (d MysqlDB) PruneClusterNodes(before time.Time) error

func (MysqlDB) QueryPad added in v0.0.2

func (d MysqlDB) QueryPad(
	offset int,
	limit int,
	sortBy string,
	ascending bool,
	pattern string,
) (*db.PadDBSearchResult, error)

func (MysqlDB) RemoveChat added in v0.0.2

func (d MysqlDB) RemoveChat(padId string) error

func (MysqlDB) RemoveClusterNode added in v0.7.0

func (d MysqlDB) RemoveClusterNode(id string) error

func (MysqlDB) RemoveGroup added in v0.0.2

func (d MysqlDB) RemoveGroup(groupId string) error

func (MysqlDB) RemoveMapperOfAuthor added in v0.7.0

func (d MysqlDB) RemoveMapperOfAuthor(id string) (bool, error)

func (MysqlDB) RemovePad added in v0.0.2

func (d MysqlDB) RemovePad(padID string) error

func (MysqlDB) RemoveRevisionsOfPad added in v0.0.2

func (d MysqlDB) RemoveRevisionsOfPad(padId string) error

func (MysqlDB) RemoveRoleAssignment added in v0.7.0

func (d MysqlDB) RemoveRoleAssignment(accountID, roleID, padPattern string) error

func (MysqlDB) RemoveSessionById added in v0.0.2

func (d MysqlDB) RemoveSessionById(sid string) error

func (MysqlDB) RemoveSheet added in v0.6.5

func (d MysqlDB) RemoveSheet(padId string) error

func (MysqlDB) RemoveSheetOps added in v0.6.5

func (d MysqlDB) RemoveSheetOps(padId string) error

func (MysqlDB) RemoveTokenOfAuthor added in v0.6.3

func (d MysqlDB) RemoveTokenOfAuthor(authorId string) error

func (MysqlDB) RemoveTokenTransfersBefore added in v0.7.0

func (d MysqlDB) RemoveTokenTransfersBefore(t time.Time) error

func (MysqlDB) ReplaceRevisions added in v0.7.0

func (d MysqlDB) ReplaceRevisions(padId string, pad db.PadDB, revisions []db.PadSingleRevision) error

func (MysqlDB) ResetSheet added in v0.7.0

func (d MysqlDB) ResetSheet(padId string, snapshot string) error

func (MysqlDB) RevokeRefreshToken added in v0.5.0

func (d MysqlDB) RevokeRefreshToken(signature string) error

func (MysqlDB) RevokeRefreshTokensByRequestID added in v0.5.0

func (d MysqlDB) RevokeRefreshTokensByRequestID(requestID string) error

func (MysqlDB) SaveAuthor added in v0.0.2

func (d MysqlDB) SaveAuthor(author db.AuthorDB) error

func (MysqlDB) SaveAuthorColor added in v0.0.2

func (d MysqlDB) SaveAuthorColor(authorId string, authorColor string) error

func (MysqlDB) SaveAuthorName added in v0.0.2

func (d MysqlDB) SaveAuthorName(authorId string, authorName string) error

func (MysqlDB) SaveChatHeadOfPad added in v0.0.2

func (d MysqlDB) SaveChatHeadOfPad(padId string, head int) error

func (MysqlDB) SaveChatMessage added in v0.0.2

func (d MysqlDB) SaveChatMessage(
	padId string,
	head int,
	authorId *string,
	timestamp int64,
	text string,
) error

func (MysqlDB) SaveGroup added in v0.0.2

func (d MysqlDB) SaveGroup(groupId string) error

func (MysqlDB) SaveRevision added in v0.0.2

func (d MysqlDB) SaveRevision(
	padId string,
	rev int,
	changeset string,
	text db.AText,
	pool db.RevPool,
	authorId *string,
	timestamp int64,
) error

func (MysqlDB) SaveSecretParams added in v0.6.5

func (d MysqlDB) SaveSecretParams(id string, prefix string, payload string) error

func (MysqlDB) SaveServerVersion added in v0.0.5

func (d MysqlDB) SaveServerVersion(version string) error

func (MysqlDB) SaveSheet added in v0.6.5

func (d MysqlDB) SaveSheet(padId string, head int, snapshot string) error

func (MysqlDB) SaveSheetOp added in v0.6.5

func (d MysqlDB) SaveSheetOp(padId string, rev int, op string, authorId *string, timestamp int64) error

func (MysqlDB) SearchAuthors added in v0.7.0

func (d MysqlDB) SearchAuthors(s AuthorSearch) ([]AuthorRow, error)

func (MysqlDB) SetAPIKeyDisabled added in v0.7.0

func (d MysqlDB) SetAPIKeyDisabled(id string, disabled bool) error

func (MysqlDB) SetAuthorByToken added in v0.0.2

func (d MysqlDB) SetAuthorByToken(token, authorId string) error

func (MysqlDB) SetAuthorMapper added in v0.7.0

func (d MysqlDB) SetAuthorMapper(id, m string) error

func (MysqlDB) SetInstanceFlag added in v0.7.0

func (d MysqlDB) SetInstanceFlag(name, value string) (bool, error)

func (MysqlDB) SetOIDCStorageValue added in v0.5.0

func (d MysqlDB) SetOIDCStorageValue(key string, payload string) error

func (MysqlDB) SetPadPublicStatus added in v0.7.0

func (d MysqlDB) SetPadPublicStatus(padID string, public bool) error

func (MysqlDB) SetPadSavedRevisions added in v0.7.0

func (d MysqlDB) SetPadSavedRevisions(padID string, saved []db.SavedRevision) error

func (MysqlDB) SetPadSettings added in v0.7.0

func (d MysqlDB) SetPadSettings(padID string, settings string) error

func (MysqlDB) SetReadOnlyId added in v0.0.4

func (d MysqlDB) SetReadOnlyId(padId string, readonlyId string) error

func (MysqlDB) SetSessionById added in v0.0.2

func (d MysqlDB) SetSessionById(sessionID string, session session2.Session) error

func (MysqlDB) TakeTokenTransfer added in v0.7.0

func (d MysqlDB) TakeTokenTransfer(id string) (*TokenTransfer, error)

func (MysqlDB) TouchAPIKey added in v0.7.0

func (d MysqlDB) TouchAPIKey(id string, at time.Time) error

func (MysqlDB) TouchAuthor added in v0.7.0

func (d MysqlDB) TouchAuthor(id string, at int64) error

func (MysqlDB) TouchLogin added in v0.7.0

func (d MysqlDB) TouchLogin(id string, at time.Time) error

func (MysqlDB) TouchToken added in v0.7.0

func (d MysqlDB) TouchToken(id string, at time.Time, ip string) error

func (MysqlDB) TryLeadership added in v0.7.0

func (d MysqlDB) TryLeadership(name string) (Leadership, bool, error)

func (MysqlDB) UpdateAccount added in v0.7.0

func (d MysqlDB) UpdateAccount(a Account) error

func (MysqlDB) UpdatePadHead added in v0.7.0

func (d MysqlDB) UpdatePadHead(padID string, head int, pool db.RevPool) error

func (MysqlDB) UpdatePadHeadText added in v0.7.0

func (d MysqlDB) UpdatePadHeadText(padID string, head int, pool db.RevPool, text db.AText) error

func (MysqlDB) UpdateRole added in v0.7.0

func (d MysqlDB) UpdateRole(r Role) error

func (MysqlDB) UpdateToken added in v0.7.0

func (d MysqlDB) UpdateToken(t Token) error

type OAuthRefreshTokenRow added in v0.5.0

type OAuthRefreshTokenRow struct {
	OAuthTokenRow
	AccessTokenSignature string
}

type OAuthTokenRow added in v0.5.0

type OAuthTokenRow struct {
	Signature     string
	ClientID      string
	RequestID     string
	Scopes        string
	GrantedScopes string
	FormData      string
	SessionData   string
	Active        bool
	RequestedAt   time.Time
	ExpiresAt     time.Time
}

type OIDCMethods added in v0.5.0

type OIDCMethods interface {
	// Existing key-value methods (keep for signing key storage)
	GetOIDCStorageValue(key string) (*string, error)
	SetOIDCStorageValue(key string, payload string) error
	// AddOIDCStorageValue stores payload under key only if the key is
	// unused, and returns the stored payload: the first writer's, when
	// several write at once.
	AddOIDCStorageValue(key string, payload string) (string, error)
	DeleteOIDCStorageValue(key string) error

	// Access tokens
	CreateAccessToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error
	GetAccessToken(signature string) (*OAuthTokenRow, error)
	DeleteAccessToken(signature string) error
	DeleteAccessTokensByRequestID(requestID string) error

	// Refresh tokens
	CreateRefreshToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, active bool, accessTokenSignature string, requestedAt, expiresAt time.Time) error
	GetRefreshToken(signature string) (*OAuthRefreshTokenRow, error)
	DeleteRefreshToken(signature string) error
	RevokeRefreshToken(signature string) error
	RevokeRefreshTokensByRequestID(requestID string) error

	// Auth codes
	CreateAuthCode(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error
	GetAuthCode(signature string) (*OAuthTokenRow, error)
	InvalidateAuthCode(signature string) error
	// ConsumeAuthCode deactivates an active code; true only for the one
	// call that did, so a code is used once also when callers race.
	ConsumeAuthCode(signature string) (bool, error)

	// PKCE
	CreatePKCE(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error
	GetPKCE(signature string) (*OAuthTokenRow, error)
	DeletePKCE(signature string) error

	// OIDC Sessions
	CreateOIDCSession(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error
	GetOIDCSession(signature string) (*OAuthTokenRow, error)
	DeleteOIDCSession(signature string) error
}

type PadHeadMethods added in v0.7.0

type PadHeadMethods interface {
	// UpdatePadHead records a new head revision and pool in the pad row.
	// It never moves the head back: another instance may have recorded a
	// newer one meanwhile.
	UpdatePadHead(padID string, head int, pool db.RevPool) error
	// UpdatePadHeadText is UpdatePadHead that also stores the text of a key
	// revision as the row's cached text.
	UpdatePadHeadText(padID string, head int, pool db.RevPool, text db.AText) error
	// SetPadPublicStatus changes only the public status.
	SetPadPublicStatus(padID string, public bool) error
	// SetPadSettings replaces only the pad-wide settings (JSON).
	SetPadSettings(padID string, settings string) error
	// SetPadSavedRevisions replaces only the saved revisions. Callers hold
	// the pad lock and have just reloaded them, so no change is lost.
	SetPadSavedRevisions(padID string, saved []db.SavedRevision) error
	// ClaimReadOnlyId stores candidate as the pad's read-only id unless it
	// has one already, and returns the stored id. Instances asking at the
	// same time thus all get the same id.
	ClaimReadOnlyId(padID string, candidate string) (string, error)
}

PadHeadMethods keep the pad row current. They change only the columns they name: the pad row is shared by every instance, and rewriting all of it from one instance's copy would undo what another instance changed.

type PadListing added in v0.7.0

type PadListing struct {
	// After: only ids after this one (the last id of the page before).
	After string
	// Prefix: only ids that start with it.
	Prefix string
	// Contains: only ids that contain it, case ignored.
	Contains string
	// DocumentType: only pads of this type ("text", "sheet"); "" for all.
	DocumentType string
	// Limit: at most this many ids (1 to 1000).
	Limit int
}

PadListing narrows ListPadIDs.

type PadListingMethods added in v0.7.0

type PadListingMethods interface {
	// ListPadIDs returns pad ids in order, at most l.Limit of them.
	ListPadIDs(l PadListing) ([]string, error)
}

PadListingMethods list pad ids page by page, in the database, so a caller never reads every pad of a large instance at once.

type PadMeta added in v0.7.0

type PadMeta struct {
	SavedRevisions []db.SavedRevision
	PublicStatus   bool
	ReadOnlyId     *string
	// Settings is the stored pad-wide settings JSON, "" for none.
	Settings string
}

PadMeta is the part of the pad row that is not derived from revisions.

type PadMethods

type PadMethods interface {
	DoesPadExist(padID string) (*bool, error)
	RemovePad(padID string) error
	CreatePad(padID string, padDB db.PadDB) error
	GetPadIds() (*[]string, error)
	SaveRevision(padId string, rev int, changeset string, text db.AText, pool db.RevPool, authorId *string, timestamp int64) error
	GetRevision(padId string, rev int) (*db.PadSingleRevision, error)
	RemoveRevisionsOfPad(padId string) error
	// ReplaceRevisions swaps the pad's whole revision history and its row
	// in one transaction: afterwards the pad has exactly revisions (numbered
	// from 0) and the row pad; on any error nothing changed. Used by
	// revision compaction, which must never leave a pad half rewritten.
	ReplaceRevisions(padId string, pad db.PadDB, revisions []db.PadSingleRevision) error
	GetRevisions(padId string, startRev int, endRev int) (*[]db.PadSingleRevision, error)
	GetPad(padID string) (*db.PadDB, error)
	GetReadonlyPad(padId string) (*string, error)
	SetReadOnlyId(padId string, readOnlyId string) error
	GetPadByReadOnlyId(id string) (*string, error)
	SaveChatHeadOfPad(padId string, head int) error
	QueryPad(offset int, limit int, sortBy string, ascending bool, pattern string) (*db.PadDBSearchResult, error)
}

type PadVersion added in v0.7.0

type PadVersion struct {
	Exists bool
	// Rev is the highest stored revision, -1 if there is none.
	Rev int
	// ChatHead is the highest stored chat message number, -1 if none.
	ChatHead int
	// Meta is the metadata in the pad row; nil if the pad does not exist.
	// It is read with the version so a writer holding the pad lock always
	// works on the current metadata, even if another instance changed it.
	Meta *PadMeta
}

PadVersion is what a pad's authoritative state in the database is at.

type PostgresDB added in v0.0.2

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

func NewPostgresDB added in v0.0.2

func NewPostgresDB(options PostgresOptions) (*PostgresDB, error)

func (PostgresDB) AddOIDCStorageValue added in v0.7.0

func (d PostgresDB) AddOIDCStorageValue(key string, payload string) (string, error)

func (PostgresDB) AddRoleAssignment added in v0.7.0

func (d PostgresDB) AddRoleAssignment(a RoleAssignment) error

func (PostgresDB) AppendAudit added in v0.7.0

func (d PostgresDB) AppendAudit(e AuditEntry) error

func (PostgresDB) ClaimReadOnlyId added in v0.7.0

func (d PostgresDB) ClaimReadOnlyId(padID string, candidate string) (string, error)

func (PostgresDB) ClearChatAuthorship added in v0.6.3

func (d PostgresDB) ClearChatAuthorship(authorId string) error

func (PostgresDB) Close added in v0.0.2

func (d PostgresDB) Close() error

func (PostgresDB) ConsumeAuthCode added in v0.7.0

func (d PostgresDB) ConsumeAuthCode(signature string) (bool, error)

func (PostgresDB) CountChatMessagesOfAuthor added in v0.7.0

func (d PostgresDB) CountChatMessagesOfAuthor(id string) (int, error)

func (PostgresDB) CreateAPIKey added in v0.7.0

func (d PostgresDB) CreateAPIKey(k APIKey) error

func (PostgresDB) CreateAccessToken added in v0.5.0

func (d PostgresDB) CreateAccessToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (PostgresDB) CreateAccount added in v0.7.0

func (d PostgresDB) CreateAccount(a Account) error

func (PostgresDB) CreateAuthCode added in v0.5.0

func (d PostgresDB) CreateAuthCode(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (PostgresDB) CreateOIDCSession added in v0.5.0

func (d PostgresDB) CreateOIDCSession(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (PostgresDB) CreatePKCE added in v0.5.0

func (d PostgresDB) CreatePKCE(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (PostgresDB) CreatePad added in v0.0.2

func (d PostgresDB) CreatePad(padID string, padDB db.PadDB) error

func (PostgresDB) CreateRefreshToken added in v0.5.0

func (d PostgresDB) CreateRefreshToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, active bool, accessTokenSignature string, requestedAt, expiresAt time.Time) error

func (PostgresDB) CreateRole added in v0.7.0

func (d PostgresDB) CreateRole(r Role) error

func (PostgresDB) CreateToken added in v0.7.0

func (d PostgresDB) CreateToken(t Token) error

func (PostgresDB) CreateTokenTransfer added in v0.7.0

func (d PostgresDB) CreateTokenTransfer(t TokenTransfer) error

func (PostgresDB) DeleteAPIKey added in v0.7.0

func (d PostgresDB) DeleteAPIKey(id string) error

func (PostgresDB) DeleteAccessToken added in v0.5.0

func (d PostgresDB) DeleteAccessToken(signature string) error

func (PostgresDB) DeleteAccessTokensByRequestID added in v0.5.0

func (d PostgresDB) DeleteAccessTokensByRequestID(requestID string) error

func (PostgresDB) DeleteAccount added in v0.7.0

func (d PostgresDB) DeleteAccount(id string) error

func (PostgresDB) DeleteOIDCSession added in v0.5.0

func (d PostgresDB) DeleteOIDCSession(signature string) error

func (PostgresDB) DeleteOIDCStorageValue added in v0.5.0

func (d PostgresDB) DeleteOIDCStorageValue(key string) error

func (PostgresDB) DeletePKCE added in v0.5.0

func (d PostgresDB) DeletePKCE(signature string) error

func (PostgresDB) DeleteRefreshToken added in v0.5.0

func (d PostgresDB) DeleteRefreshToken(signature string) error

func (PostgresDB) DeleteRole added in v0.7.0

func (d PostgresDB) DeleteRole(id string) error

func (PostgresDB) DeleteSecretParams added in v0.6.5

func (d PostgresDB) DeleteSecretParams(id string) error

func (PostgresDB) DoesPadExist added in v0.0.2

func (d PostgresDB) DoesPadExist(padID string) (*bool, error)

func (PostgresDB) DoesSheetExist added in v0.6.5

func (d PostgresDB) DoesSheetExist(padId string) (*bool, error)

func (PostgresDB) GetAPIKeyByHash added in v0.7.0

func (d PostgresDB) GetAPIKeyByHash(hash string) (*APIKey, error)

func (PostgresDB) GetAccessToken added in v0.5.0

func (d PostgresDB) GetAccessToken(signature string) (*OAuthTokenRow, error)

func (PostgresDB) GetAccount added in v0.7.0

func (d PostgresDB) GetAccount(id string) (*Account, error)

func (PostgresDB) GetAccountByUsername added in v0.7.0

func (d PostgresDB) GetAccountByUsername(u string) (*Account, error)

func (PostgresDB) GetAuthCode added in v0.5.0

func (d PostgresDB) GetAuthCode(signature string) (*OAuthTokenRow, error)

func (PostgresDB) GetAuthor added in v0.0.2

func (d PostgresDB) GetAuthor(authorId string) (*db.AuthorDB, error)

func (PostgresDB) GetAuthorByMapper added in v0.7.0

func (d PostgresDB) GetAuthorByMapper(m string) (string, error)

func (PostgresDB) GetAuthorByToken added in v0.0.2

func (d PostgresDB) GetAuthorByToken(token string) (*string, error)

func (PostgresDB) GetAuthorIdsOfPadChats added in v0.0.4

func (d PostgresDB) GetAuthorIdsOfPadChats(id string) (*[]string, error)

func (PostgresDB) GetAuthorRow added in v0.7.0

func (d PostgresDB) GetAuthorRow(id string) (*AuthorRow, error)

func (PostgresDB) GetAuthors added in v0.0.4

func (d PostgresDB) GetAuthors(
	ids []string,
) (*[]db.AuthorDB, error)

func (PostgresDB) GetChatsOfPad added in v0.0.2

func (d PostgresDB) GetChatsOfPad(
	padId string,
	start int,
	end int,
) (*[]db.ChatMessageDBWithDisplayName, error)

func (PostgresDB) GetGroup added in v0.0.2

func (d PostgresDB) GetGroup(groupId string) (*string, error)

func (PostgresDB) GetGroups added in v0.6.3

func (d PostgresDB) GetGroups() (*[]string, error)

func (PostgresDB) GetInstanceFlag added in v0.7.0

func (d PostgresDB) GetInstanceFlag(name string) (*string, error)

func (PostgresDB) GetOIDCSession added in v0.5.0

func (d PostgresDB) GetOIDCSession(signature string) (*OAuthTokenRow, error)

func (PostgresDB) GetOIDCStorageValue added in v0.5.0

func (d PostgresDB) GetOIDCStorageValue(key string) (*string, error)

func (PostgresDB) GetPKCE added in v0.5.0

func (d PostgresDB) GetPKCE(signature string) (*OAuthTokenRow, error)

func (PostgresDB) GetPad added in v0.0.2

func (d PostgresDB) GetPad(padID string) (*db.PadDB, error)

func (PostgresDB) GetPadByReadOnlyId added in v0.0.4

func (d PostgresDB) GetPadByReadOnlyId(readonlyId string) (*string, error)

func (PostgresDB) GetPadIds added in v0.0.2

func (d PostgresDB) GetPadIds() (*[]string, error)

func (PostgresDB) GetPadIdsOfAuthor added in v0.0.4

func (d PostgresDB) GetPadIdsOfAuthor(authorId string) (*[]string, error)

func (PostgresDB) GetPadVersion added in v0.7.0

func (d PostgresDB) GetPadVersion(padID string) (*PadVersion, error)

func (PostgresDB) GetReadonlyPad added in v0.0.2

func (d PostgresDB) GetReadonlyPad(padId string) (*string, error)

func (PostgresDB) GetRefreshToken added in v0.5.0

func (d PostgresDB) GetRefreshToken(signature string) (*OAuthRefreshTokenRow, error)

func (PostgresDB) GetRevision added in v0.0.2

func (d PostgresDB) GetRevision(padId string, rev int) (*db.PadSingleRevision, error)

func (PostgresDB) GetRevisionDeltas added in v0.7.0

func (d PostgresDB) GetRevisionDeltas(padID string, fromRev, toRev int) ([]RevisionDelta, error)

func (PostgresDB) GetRevisionPool added in v0.7.0

func (d PostgresDB) GetRevisionPool(padID string, rev int) (*db.RevPool, error)

func (PostgresDB) GetRevisions added in v0.0.2

func (d PostgresDB) GetRevisions(
	padId string,
	startRev int,
	endRev int,
) (*[]db.PadSingleRevision, error)

func (PostgresDB) GetRole added in v0.7.0

func (d PostgresDB) GetRole(id string) (*Role, error)

func (PostgresDB) GetServerVersion added in v0.0.5

func (d PostgresDB) GetServerVersion() (*db.ServerVersion, error)

func (PostgresDB) GetSessionById added in v0.0.2

func (d PostgresDB) GetSessionById(sessionID string) (*session2.Session, error)

func (PostgresDB) GetSheet added in v0.6.5

func (d PostgresDB) GetSheet(padId string) (*db.SheetDB, error)

func (PostgresDB) GetSheetOpInfo added in v0.7.0

func (d PostgresDB) GetSheetOpInfo(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (PostgresDB) GetSheetOps added in v0.6.5

func (d PostgresDB) GetSheetOps(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (PostgresDB) GetSheetVersion added in v0.7.0

func (d PostgresDB) GetSheetVersion(padId string) (*SheetVersion, error)

func (PostgresDB) GetToken added in v0.7.0

func (d PostgresDB) GetToken(id string) (*Token, error)

func (PostgresDB) GetTokenByHash added in v0.7.0

func (d PostgresDB) GetTokenByHash(h string) (*Token, error)

func (PostgresDB) HasAuditEntry added in v0.7.0

func (d PostgresDB) HasAuditEntry(id string) (bool, error)

func (PostgresDB) HeartbeatClusterNode added in v0.7.0

func (d PostgresDB) HeartbeatClusterNode(id, address string, now time.Time, users int) error

func (PostgresDB) InvalidateAuthCode added in v0.5.0

func (d PostgresDB) InvalidateAuthCode(signature string) error

func (PostgresDB) ListAPIKeys added in v0.7.0

func (d PostgresDB) ListAPIKeys() ([]APIKey, error)

func (PostgresDB) ListAccounts added in v0.7.0

func (d PostgresDB) ListAccounts() ([]Account, error)

func (PostgresDB) ListAudit added in v0.7.0

func (d PostgresDB) ListAudit(limit int) ([]AuditEntry, error)

func (PostgresDB) ListClusterNodes added in v0.7.0

func (d PostgresDB) ListClusterNodes(aliveSince time.Time) ([]ClusterNode, error)

func (PostgresDB) ListPadIDs added in v0.7.0

func (d PostgresDB) ListPadIDs(l PadListing) ([]string, error)

func (PostgresDB) ListRoleAssignments added in v0.7.0

func (d PostgresDB) ListRoleAssignments(accountID string) ([]RoleAssignment, error)

func (PostgresDB) ListRoles added in v0.7.0

func (d PostgresDB) ListRoles() ([]Role, error)

func (PostgresDB) ListSecretParams added in v0.6.5

func (d PostgresDB) ListSecretParams(prefix string) (map[string]string, error)

func (PostgresDB) ListTokens added in v0.7.0

func (d PostgresDB) ListTokens(accountID string) ([]Token, error)

func (PostgresDB) LockPadsExclusive added in v0.7.0

func (d PostgresDB) LockPadsExclusive(padIDs []string) (func(), error)

func (PostgresDB) MarkAuthorErased added in v0.7.0

func (d PostgresDB) MarkAuthorErased(id string, at int64) error

func (PostgresDB) Ping added in v0.0.5

func (d PostgresDB) Ping() error

func (PostgresDB) PruneClusterNodes added in v0.7.0

func (d PostgresDB) PruneClusterNodes(before time.Time) error

func (PostgresDB) QueryPad added in v0.0.2

func (d PostgresDB) QueryPad(
	offset int,
	limit int,
	sortBy string,
	ascending bool,
	pattern string,
) (*db.PadDBSearchResult, error)

func (PostgresDB) RemoveChat added in v0.0.2

func (d PostgresDB) RemoveChat(padId string) error

func (PostgresDB) RemoveClusterNode added in v0.7.0

func (d PostgresDB) RemoveClusterNode(id string) error

func (PostgresDB) RemoveGroup added in v0.0.2

func (d PostgresDB) RemoveGroup(groupId string) error

func (PostgresDB) RemoveMapperOfAuthor added in v0.7.0

func (d PostgresDB) RemoveMapperOfAuthor(id string) (bool, error)

func (PostgresDB) RemovePad added in v0.0.2

func (d PostgresDB) RemovePad(padID string) error

func (PostgresDB) RemoveRevisionsOfPad added in v0.0.2

func (d PostgresDB) RemoveRevisionsOfPad(padId string) error

func (PostgresDB) RemoveRoleAssignment added in v0.7.0

func (d PostgresDB) RemoveRoleAssignment(accountID, roleID, padPattern string) error

func (PostgresDB) RemoveSessionById added in v0.0.2

func (d PostgresDB) RemoveSessionById(sid string) error

func (PostgresDB) RemoveSheet added in v0.6.5

func (d PostgresDB) RemoveSheet(padId string) error

func (PostgresDB) RemoveSheetOps added in v0.6.5

func (d PostgresDB) RemoveSheetOps(padId string) error

func (PostgresDB) RemoveTokenOfAuthor added in v0.6.3

func (d PostgresDB) RemoveTokenOfAuthor(authorId string) error

func (PostgresDB) RemoveTokenTransfersBefore added in v0.7.0

func (d PostgresDB) RemoveTokenTransfersBefore(t time.Time) error

func (PostgresDB) ReplaceRevisions added in v0.7.0

func (d PostgresDB) ReplaceRevisions(padId string, pad db.PadDB, revisions []db.PadSingleRevision) error

func (PostgresDB) ResetSheet added in v0.7.0

func (d PostgresDB) ResetSheet(padId string, snapshot string) error

func (PostgresDB) RevokeRefreshToken added in v0.5.0

func (d PostgresDB) RevokeRefreshToken(signature string) error

func (PostgresDB) RevokeRefreshTokensByRequestID added in v0.5.0

func (d PostgresDB) RevokeRefreshTokensByRequestID(requestID string) error

func (PostgresDB) SaveAuthor added in v0.0.2

func (d PostgresDB) SaveAuthor(author db.AuthorDB) error

func (PostgresDB) SaveAuthorColor added in v0.0.2

func (d PostgresDB) SaveAuthorColor(authorId string, authorColor string) error

func (PostgresDB) SaveAuthorName added in v0.0.2

func (d PostgresDB) SaveAuthorName(authorId string, authorName string) error

func (PostgresDB) SaveChatHeadOfPad added in v0.0.2

func (d PostgresDB) SaveChatHeadOfPad(padId string, head int) error

func (PostgresDB) SaveChatMessage added in v0.0.2

func (d PostgresDB) SaveChatMessage(
	padId string,
	head int,
	authorId *string,
	timestamp int64,
	text string,
) error

func (PostgresDB) SaveGroup added in v0.0.2

func (d PostgresDB) SaveGroup(groupId string) error

func (PostgresDB) SaveRevision added in v0.0.2

func (d PostgresDB) SaveRevision(
	padId string,
	rev int,
	changeset string,
	text db.AText,
	pool db.RevPool,
	authorId *string,
	timestamp int64,
) error

func (PostgresDB) SaveSecretParams added in v0.6.5

func (d PostgresDB) SaveSecretParams(id string, prefix string, payload string) error

func (PostgresDB) SaveServerVersion added in v0.0.5

func (d PostgresDB) SaveServerVersion(version string) error

func (PostgresDB) SaveSheet added in v0.6.5

func (d PostgresDB) SaveSheet(padId string, head int, snapshot string) error

func (PostgresDB) SaveSheetOp added in v0.6.5

func (d PostgresDB) SaveSheetOp(padId string, rev int, op string, authorId *string, timestamp int64) error

func (PostgresDB) SearchAuthors added in v0.7.0

func (d PostgresDB) SearchAuthors(s AuthorSearch) ([]AuthorRow, error)

func (PostgresDB) SetAPIKeyDisabled added in v0.7.0

func (d PostgresDB) SetAPIKeyDisabled(id string, disabled bool) error

func (PostgresDB) SetAuthorByToken added in v0.0.2

func (d PostgresDB) SetAuthorByToken(token, authorId string) error

func (PostgresDB) SetAuthorMapper added in v0.7.0

func (d PostgresDB) SetAuthorMapper(id, m string) error

func (PostgresDB) SetInstanceFlag added in v0.7.0

func (d PostgresDB) SetInstanceFlag(name, value string) (bool, error)

func (PostgresDB) SetOIDCStorageValue added in v0.5.0

func (d PostgresDB) SetOIDCStorageValue(key string, payload string) error

func (PostgresDB) SetPadPublicStatus added in v0.7.0

func (d PostgresDB) SetPadPublicStatus(padID string, public bool) error

func (PostgresDB) SetPadSavedRevisions added in v0.7.0

func (d PostgresDB) SetPadSavedRevisions(padID string, saved []db.SavedRevision) error

func (PostgresDB) SetPadSettings added in v0.7.0

func (d PostgresDB) SetPadSettings(padID string, settings string) error

func (PostgresDB) SetReadOnlyId added in v0.0.4

func (d PostgresDB) SetReadOnlyId(padId string, readonlyId string) error

func (PostgresDB) SetSessionById added in v0.0.2

func (d PostgresDB) SetSessionById(sessionID string, session session2.Session) error

func (PostgresDB) TakeTokenTransfer added in v0.7.0

func (d PostgresDB) TakeTokenTransfer(id string) (*TokenTransfer, error)

func (PostgresDB) TouchAPIKey added in v0.7.0

func (d PostgresDB) TouchAPIKey(id string, at time.Time) error

func (PostgresDB) TouchAuthor added in v0.7.0

func (d PostgresDB) TouchAuthor(id string, at int64) error

func (PostgresDB) TouchLogin added in v0.7.0

func (d PostgresDB) TouchLogin(id string, at time.Time) error

func (PostgresDB) TouchToken added in v0.7.0

func (d PostgresDB) TouchToken(id string, at time.Time, ip string) error

func (PostgresDB) TryLeadership added in v0.7.0

func (d PostgresDB) TryLeadership(name string) (Leadership, bool, error)

func (PostgresDB) UpdateAccount added in v0.7.0

func (d PostgresDB) UpdateAccount(a Account) error

func (PostgresDB) UpdatePadHead added in v0.7.0

func (d PostgresDB) UpdatePadHead(padID string, head int, pool db.RevPool) error

func (PostgresDB) UpdatePadHeadText added in v0.7.0

func (d PostgresDB) UpdatePadHeadText(padID string, head int, pool db.RevPool, text db.AText) error

func (PostgresDB) UpdateRole added in v0.7.0

func (d PostgresDB) UpdateRole(r Role) error

func (PostgresDB) UpdateToken added in v0.7.0

func (d PostgresDB) UpdateToken(t Token) error

type PostgresOptions added in v0.0.2

type PostgresOptions struct {
	Username string
	Password string
	Port     int
	Host     string
	Database string
	// MaxConns caps the connection pool; 0 means the default of 25.
	MaxConns int
	// PgBouncer avoids named prepared statements, for PgBouncer (or a
	// similar pooler) in transaction mode.
	PgBouncer bool
}

type Reader added in v0.0.4

type Reader interface {
	Scan(dest ...any) error
}

type RevisionDelta added in v0.7.0

type RevisionDelta struct {
	Rev       int
	Changeset string
	AuthorId  *string
	Timestamp int64
}

RevisionDelta is a stored revision without its full text.

type Role added in v0.7.0

type Role struct {
	ID          string
	Name        string
	Description string
	Builtin     bool
	Scopes      []string
	// Includes are the ids of the roles this one includes.
	Includes []string
	// Limits by name (AI requests per day, ...).
	Limits map[string]int64
}

Role is a named set of scopes that can include other roles.

type RoleAssignment added in v0.7.0

type RoleAssignment struct {
	AccountID  string
	RoleID     string
	PadPattern string
	CreatedBy  string
	CreatedAt  time.Time
}

RoleAssignment gives an account a role, for all pads (PadPattern "") or the pads matching PadPattern.

type SQLiteDB

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

func NewSQLiteDB added in v0.0.2

func NewSQLiteDB(path string) (*SQLiteDB, error)

NewSQLiteDB creates a new SQLiteDB and returns a pointer to it.

func (SQLiteDB) AddOIDCStorageValue added in v0.7.0

func (d SQLiteDB) AddOIDCStorageValue(key string, payload string) (string, error)

func (SQLiteDB) AddRoleAssignment added in v0.7.0

func (d SQLiteDB) AddRoleAssignment(a RoleAssignment) error

func (SQLiteDB) AppendAudit added in v0.7.0

func (d SQLiteDB) AppendAudit(e AuditEntry) error

func (SQLiteDB) ClaimReadOnlyId added in v0.7.0

func (d SQLiteDB) ClaimReadOnlyId(padID string, candidate string) (string, error)

func (SQLiteDB) ClearChatAuthorship added in v0.6.3

func (d SQLiteDB) ClearChatAuthorship(authorId string) error

func (SQLiteDB) Close added in v0.0.2

func (d SQLiteDB) Close() error

func (SQLiteDB) ConsumeAuthCode added in v0.7.0

func (d SQLiteDB) ConsumeAuthCode(signature string) (bool, error)

func (SQLiteDB) CountChatMessagesOfAuthor added in v0.7.0

func (d SQLiteDB) CountChatMessagesOfAuthor(id string) (int, error)

func (SQLiteDB) CreateAPIKey added in v0.7.0

func (d SQLiteDB) CreateAPIKey(k APIKey) error

func (SQLiteDB) CreateAccessToken added in v0.5.0

func (d SQLiteDB) CreateAccessToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (SQLiteDB) CreateAccount added in v0.7.0

func (d SQLiteDB) CreateAccount(a Account) error

func (SQLiteDB) CreateAuthCode added in v0.5.0

func (d SQLiteDB) CreateAuthCode(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (SQLiteDB) CreateOIDCSession added in v0.5.0

func (d SQLiteDB) CreateOIDCSession(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (SQLiteDB) CreatePKCE added in v0.5.0

func (d SQLiteDB) CreatePKCE(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, requestedAt, expiresAt time.Time) error

func (SQLiteDB) CreatePad

func (d SQLiteDB) CreatePad(padID string, padDB db.PadDB) error

func (SQLiteDB) CreateRefreshToken added in v0.5.0

func (d SQLiteDB) CreateRefreshToken(signature, clientID, requestID, scopes, grantedScopes, formData, sessionData string, active bool, accessTokenSignature string, requestedAt, expiresAt time.Time) error

func (SQLiteDB) CreateRole added in v0.7.0

func (d SQLiteDB) CreateRole(r Role) error

func (SQLiteDB) CreateToken added in v0.7.0

func (d SQLiteDB) CreateToken(t Token) error

func (SQLiteDB) CreateTokenTransfer added in v0.7.0

func (d SQLiteDB) CreateTokenTransfer(t TokenTransfer) error

func (SQLiteDB) DeleteAPIKey added in v0.7.0

func (d SQLiteDB) DeleteAPIKey(id string) error

func (SQLiteDB) DeleteAccessToken added in v0.5.0

func (d SQLiteDB) DeleteAccessToken(signature string) error

func (SQLiteDB) DeleteAccessTokensByRequestID added in v0.5.0

func (d SQLiteDB) DeleteAccessTokensByRequestID(requestID string) error

func (SQLiteDB) DeleteAccount added in v0.7.0

func (d SQLiteDB) DeleteAccount(id string) error

func (SQLiteDB) DeleteOIDCSession added in v0.5.0

func (d SQLiteDB) DeleteOIDCSession(signature string) error

func (SQLiteDB) DeleteOIDCStorageValue added in v0.5.0

func (d SQLiteDB) DeleteOIDCStorageValue(key string) error

func (SQLiteDB) DeletePKCE added in v0.5.0

func (d SQLiteDB) DeletePKCE(signature string) error

func (SQLiteDB) DeleteRefreshToken added in v0.5.0

func (d SQLiteDB) DeleteRefreshToken(signature string) error

func (SQLiteDB) DeleteRole added in v0.7.0

func (d SQLiteDB) DeleteRole(id string) error

func (SQLiteDB) DeleteSecretParams added in v0.6.5

func (d SQLiteDB) DeleteSecretParams(id string) error

func (SQLiteDB) DoesPadExist

func (d SQLiteDB) DoesPadExist(padID string) (*bool, error)

func (SQLiteDB) DoesSheetExist added in v0.6.5

func (d SQLiteDB) DoesSheetExist(padId string) (*bool, error)

func (SQLiteDB) GetAPIKeyByHash added in v0.7.0

func (d SQLiteDB) GetAPIKeyByHash(h string) (*APIKey, error)

func (SQLiteDB) GetAccessToken added in v0.5.0

func (d SQLiteDB) GetAccessToken(signature string) (*OAuthTokenRow, error)

func (SQLiteDB) GetAccount added in v0.7.0

func (d SQLiteDB) GetAccount(id string) (*Account, error)

func (SQLiteDB) GetAccountByUsername added in v0.7.0

func (d SQLiteDB) GetAccountByUsername(u string) (*Account, error)

func (SQLiteDB) GetAuthCode added in v0.5.0

func (d SQLiteDB) GetAuthCode(signature string) (*OAuthTokenRow, error)

func (SQLiteDB) GetAuthor

func (d SQLiteDB) GetAuthor(authorId string) (*db.AuthorDB, error)

func (SQLiteDB) GetAuthorByMapper added in v0.7.0

func (d SQLiteDB) GetAuthorByMapper(m string) (string, error)

func (SQLiteDB) GetAuthorByToken

func (d SQLiteDB) GetAuthorByToken(token string) (*string, error)

func (SQLiteDB) GetAuthorIdsOfPadChats added in v0.0.4

func (d SQLiteDB) GetAuthorIdsOfPadChats(id string) (*[]string, error)

func (SQLiteDB) GetAuthorRow added in v0.7.0

func (d SQLiteDB) GetAuthorRow(id string) (*AuthorRow, error)

func (SQLiteDB) GetAuthors added in v0.0.4

func (d SQLiteDB) GetAuthors(
	ids []string,
) (*[]db.AuthorDB, error)

func (SQLiteDB) GetChatsOfPad added in v0.0.2

func (d SQLiteDB) GetChatsOfPad(
	padId string,
	start int,
	end int,
) (*[]db.ChatMessageDBWithDisplayName, error)

func (SQLiteDB) GetGroup

func (d SQLiteDB) GetGroup(groupId string) (*string, error)

func (SQLiteDB) GetGroups added in v0.6.3

func (d SQLiteDB) GetGroups() (*[]string, error)

func (SQLiteDB) GetInstanceFlag added in v0.7.0

func (d SQLiteDB) GetInstanceFlag(name string) (*string, error)

func (SQLiteDB) GetOIDCSession added in v0.5.0

func (d SQLiteDB) GetOIDCSession(signature string) (*OAuthTokenRow, error)

func (SQLiteDB) GetOIDCStorageValue added in v0.5.0

func (d SQLiteDB) GetOIDCStorageValue(key string) (*string, error)

func (SQLiteDB) GetPKCE added in v0.5.0

func (d SQLiteDB) GetPKCE(signature string) (*OAuthTokenRow, error)

func (SQLiteDB) GetPad

func (d SQLiteDB) GetPad(padID string) (*db.PadDB, error)

func (SQLiteDB) GetPadByReadOnlyId added in v0.0.4

func (d SQLiteDB) GetPadByReadOnlyId(readonlyId string) (*string, error)

func (SQLiteDB) GetPadIds

func (d SQLiteDB) GetPadIds() (*[]string, error)

func (SQLiteDB) GetPadIdsOfAuthor added in v0.0.4

func (d SQLiteDB) GetPadIdsOfAuthor(authorId string) (*[]string, error)

func (SQLiteDB) GetPadVersion added in v0.7.0

func (d SQLiteDB) GetPadVersion(padID string) (*PadVersion, error)

func (SQLiteDB) GetReadonlyPad

func (d SQLiteDB) GetReadonlyPad(padId string) (*string, error)

func (SQLiteDB) GetRefreshToken added in v0.5.0

func (d SQLiteDB) GetRefreshToken(signature string) (*OAuthRefreshTokenRow, error)

func (SQLiteDB) GetRevision

func (d SQLiteDB) GetRevision(padId string, rev int) (*db.PadSingleRevision, error)

func (SQLiteDB) GetRevisionDeltas added in v0.7.0

func (d SQLiteDB) GetRevisionDeltas(padID string, fromRev, toRev int) ([]RevisionDelta, error)

func (SQLiteDB) GetRevisionPool added in v0.7.0

func (d SQLiteDB) GetRevisionPool(padID string, rev int) (*db.RevPool, error)

func (SQLiteDB) GetRevisions added in v0.0.2

func (d SQLiteDB) GetRevisions(padId string, startRev int, endRev int) (*[]db.PadSingleRevision, error)

func (SQLiteDB) GetRole added in v0.7.0

func (d SQLiteDB) GetRole(id string) (*Role, error)

func (SQLiteDB) GetServerVersion added in v0.0.5

func (d SQLiteDB) GetServerVersion() (*db.ServerVersion, error)

func (SQLiteDB) GetSessionById

func (d SQLiteDB) GetSessionById(sessionID string) (*session2.Session, error)

func (SQLiteDB) GetSheet added in v0.6.5

func (d SQLiteDB) GetSheet(padId string) (*db.SheetDB, error)

func (SQLiteDB) GetSheetOpInfo added in v0.7.0

func (d SQLiteDB) GetSheetOpInfo(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (SQLiteDB) GetSheetOps added in v0.6.5

func (d SQLiteDB) GetSheetOps(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)

func (SQLiteDB) GetSheetVersion added in v0.7.0

func (d SQLiteDB) GetSheetVersion(padId string) (*SheetVersion, error)

func (SQLiteDB) GetToken added in v0.7.0

func (d SQLiteDB) GetToken(id string) (*Token, error)

func (SQLiteDB) GetTokenByHash added in v0.7.0

func (d SQLiteDB) GetTokenByHash(h string) (*Token, error)

func (SQLiteDB) HasAuditEntry added in v0.7.0

func (d SQLiteDB) HasAuditEntry(id string) (bool, error)

func (SQLiteDB) HeartbeatClusterNode added in v0.7.0

func (d SQLiteDB) HeartbeatClusterNode(id, address string, now time.Time, users int) error

func (SQLiteDB) InvalidateAuthCode added in v0.5.0

func (d SQLiteDB) InvalidateAuthCode(signature string) error

func (SQLiteDB) ListAPIKeys added in v0.7.0

func (d SQLiteDB) ListAPIKeys() ([]APIKey, error)

func (SQLiteDB) ListAccounts added in v0.7.0

func (d SQLiteDB) ListAccounts() ([]Account, error)

func (SQLiteDB) ListAudit added in v0.7.0

func (d SQLiteDB) ListAudit(limit int) ([]AuditEntry, error)

func (SQLiteDB) ListClusterNodes added in v0.7.0

func (d SQLiteDB) ListClusterNodes(aliveSince time.Time) ([]ClusterNode, error)

func (SQLiteDB) ListPadIDs added in v0.7.0

func (d SQLiteDB) ListPadIDs(l PadListing) ([]string, error)

func (SQLiteDB) ListRoleAssignments added in v0.7.0

func (d SQLiteDB) ListRoleAssignments(accountID string) ([]RoleAssignment, error)

func (SQLiteDB) ListRoles added in v0.7.0

func (d SQLiteDB) ListRoles() ([]Role, error)

func (SQLiteDB) ListSecretParams added in v0.6.5

func (d SQLiteDB) ListSecretParams(prefix string) (map[string]string, error)

func (SQLiteDB) ListTokens added in v0.7.0

func (d SQLiteDB) ListTokens(accountID string) ([]Token, error)

func (SQLiteDB) LockPadsExclusive added in v0.7.0

func (d SQLiteDB) LockPadsExclusive(padIDs []string) (func(), error)

LockPadsExclusive locks within this process: an SQLite database is used by one process.

func (SQLiteDB) MarkAuthorErased added in v0.7.0

func (d SQLiteDB) MarkAuthorErased(id string, at int64) error

func (SQLiteDB) Ping added in v0.0.5

func (d SQLiteDB) Ping() error

func (SQLiteDB) PruneClusterNodes added in v0.7.0

func (d SQLiteDB) PruneClusterNodes(before time.Time) error

func (SQLiteDB) QueryPad added in v0.0.2

func (d SQLiteDB) QueryPad(
	offset int,
	limit int,
	sortBy string,
	ascending bool,
	pattern string,
) (*db.PadDBSearchResult, error)

func (SQLiteDB) RemoveChat

func (d SQLiteDB) RemoveChat(padId string) error

func (SQLiteDB) RemoveClusterNode added in v0.7.0

func (d SQLiteDB) RemoveClusterNode(id string) error

func (SQLiteDB) RemoveGroup added in v0.0.2

func (d SQLiteDB) RemoveGroup(groupId string) error

func (SQLiteDB) RemoveMapperOfAuthor added in v0.7.0

func (d SQLiteDB) RemoveMapperOfAuthor(id string) (bool, error)

func (SQLiteDB) RemovePad

func (d SQLiteDB) RemovePad(padID string) error

func (SQLiteDB) RemoveRevisionsOfPad

func (d SQLiteDB) RemoveRevisionsOfPad(padId string) error

func (SQLiteDB) RemoveRoleAssignment added in v0.7.0

func (d SQLiteDB) RemoveRoleAssignment(accountID, roleID, padPattern string) error

func (SQLiteDB) RemoveSessionById

func (d SQLiteDB) RemoveSessionById(sid string) error

func (SQLiteDB) RemoveSheet added in v0.6.5

func (d SQLiteDB) RemoveSheet(padId string) error

func (SQLiteDB) RemoveSheetOps added in v0.6.5

func (d SQLiteDB) RemoveSheetOps(padId string) error

func (SQLiteDB) RemoveTokenOfAuthor added in v0.6.3

func (d SQLiteDB) RemoveTokenOfAuthor(authorId string) error

func (SQLiteDB) RemoveTokenTransfersBefore added in v0.7.0

func (d SQLiteDB) RemoveTokenTransfersBefore(t time.Time) error

func (SQLiteDB) ReplaceRevisions added in v0.7.0

func (d SQLiteDB) ReplaceRevisions(padId string, pad db.PadDB, revisions []db.PadSingleRevision) error

func (SQLiteDB) ResetSheet added in v0.7.0

func (d SQLiteDB) ResetSheet(padId string, snapshot string) error

func (SQLiteDB) RevokeRefreshToken added in v0.5.0

func (d SQLiteDB) RevokeRefreshToken(signature string) error

func (SQLiteDB) RevokeRefreshTokensByRequestID added in v0.5.0

func (d SQLiteDB) RevokeRefreshTokensByRequestID(requestID string) error

func (SQLiteDB) SaveAuthor

func (d SQLiteDB) SaveAuthor(author db.AuthorDB) error

func (SQLiteDB) SaveAuthorColor

func (d SQLiteDB) SaveAuthorColor(authorId string, authorColor string) error

func (SQLiteDB) SaveAuthorName

func (d SQLiteDB) SaveAuthorName(authorId string, authorName string) error

func (SQLiteDB) SaveChatHeadOfPad added in v0.0.2

func (d SQLiteDB) SaveChatHeadOfPad(padId string, head int) error

func (SQLiteDB) SaveChatMessage added in v0.0.2

func (d SQLiteDB) SaveChatMessage(
	padId string,
	head int,
	authorId *string,
	timestamp int64,
	text string,
) error

func (SQLiteDB) SaveGroup added in v0.0.2

func (d SQLiteDB) SaveGroup(groupId string) error

func (SQLiteDB) SaveRevision

func (d SQLiteDB) SaveRevision(
	padId string,
	rev int,
	changeset string,
	text db.AText,
	pool db.RevPool,
	authorId *string,
	timestamp int64,
) error

func (SQLiteDB) SaveSecretParams added in v0.6.5

func (d SQLiteDB) SaveSecretParams(id string, prefix string, payload string) error

func (SQLiteDB) SaveServerVersion added in v0.0.5

func (d SQLiteDB) SaveServerVersion(version string) error

func (SQLiteDB) SaveSheet added in v0.6.5

func (d SQLiteDB) SaveSheet(padId string, head int, snapshot string) error

func (SQLiteDB) SaveSheetOp added in v0.6.5

func (d SQLiteDB) SaveSheetOp(padId string, rev int, op string, authorId *string, timestamp int64) error

func (SQLiteDB) SearchAuthors added in v0.7.0

func (d SQLiteDB) SearchAuthors(s AuthorSearch) ([]AuthorRow, error)

func (SQLiteDB) SetAPIKeyDisabled added in v0.7.0

func (d SQLiteDB) SetAPIKeyDisabled(id string, disabled bool) error

func (SQLiteDB) SetAuthorByToken

func (d SQLiteDB) SetAuthorByToken(token, authorId string) error

func (SQLiteDB) SetAuthorMapper added in v0.7.0

func (d SQLiteDB) SetAuthorMapper(id, m string) error

func (SQLiteDB) SetInstanceFlag added in v0.7.0

func (d SQLiteDB) SetInstanceFlag(name, value string) (bool, error)

func (SQLiteDB) SetOIDCStorageValue added in v0.5.0

func (d SQLiteDB) SetOIDCStorageValue(key string, payload string) error

func (SQLiteDB) SetPadPublicStatus added in v0.7.0

func (d SQLiteDB) SetPadPublicStatus(padID string, public bool) error

func (SQLiteDB) SetPadSavedRevisions added in v0.7.0

func (d SQLiteDB) SetPadSavedRevisions(padID string, saved []db.SavedRevision) error

func (SQLiteDB) SetPadSettings added in v0.7.0

func (d SQLiteDB) SetPadSettings(padID string, settings string) error

func (SQLiteDB) SetReadOnlyId added in v0.0.4

func (d SQLiteDB) SetReadOnlyId(padId string, readonlyId string) error

func (SQLiteDB) SetSessionById

func (d SQLiteDB) SetSessionById(sessionID string, session session2.Session) error

func (SQLiteDB) TakeTokenTransfer added in v0.7.0

func (d SQLiteDB) TakeTokenTransfer(id string) (*TokenTransfer, error)

func (SQLiteDB) TouchAPIKey added in v0.7.0

func (d SQLiteDB) TouchAPIKey(id string, at time.Time) error

func (SQLiteDB) TouchAuthor added in v0.7.0

func (d SQLiteDB) TouchAuthor(id string, at int64) error

func (SQLiteDB) TouchLogin added in v0.7.0

func (d SQLiteDB) TouchLogin(id string, at time.Time) error

func (SQLiteDB) TouchToken added in v0.7.0

func (d SQLiteDB) TouchToken(id string, at time.Time, ip string) error

func (SQLiteDB) TryLeadership added in v0.7.0

func (d SQLiteDB) TryLeadership(name string) (Leadership, bool, error)

func (SQLiteDB) UpdateAccount added in v0.7.0

func (d SQLiteDB) UpdateAccount(a Account) error

func (SQLiteDB) UpdatePadHead added in v0.7.0

func (d SQLiteDB) UpdatePadHead(padID string, head int, pool db.RevPool) error

func (SQLiteDB) UpdatePadHeadText added in v0.7.0

func (d SQLiteDB) UpdatePadHeadText(padID string, head int, pool db.RevPool, text db.AText) error

func (SQLiteDB) UpdateRole added in v0.7.0

func (d SQLiteDB) UpdateRole(r Role) error

func (SQLiteDB) UpdateToken added in v0.7.0

func (d SQLiteDB) UpdateToken(t Token) error

type SecretMethods added in v0.6.5

type SecretMethods interface {
	// SaveSecretParams upserts one published parameter set.
	SaveSecretParams(id string, prefix string, payload string) error
	// ListSecretParams returns all parameter sets for the given prefix as a
	// map of id -> payload.
	ListSecretParams(prefix string) (map[string]string, error)
	// DeleteSecretParams removes a single parameter set by id.
	DeleteSecretParams(id string) error
}

SecretMethods back the SecretRotator. Each published parameter set is addressed by a random id within a rotator namespace (prefix), allowing several rotators (and several Etherpad instances) to coexist in one table.

type ServerMethods added in v0.0.5

type ServerMethods interface {
	GetServerVersion() (*db.ServerVersion, error)
	SaveServerVersion(version string) error
}

type SessionMethods

type SessionMethods interface {
	GetSessionById(sessionID string) (*session2.Session, error)
	SetSessionById(sessionID string, session session2.Session) error
	RemoveSessionById(sessionID string) error
}

type SheetMethods added in v0.6.5

type SheetMethods interface {
	SaveSheet(padId string, head int, snapshot string) error
	GetSheet(padId string) (*db.SheetDB, error)
	DoesSheetExist(padId string) (*bool, error)
	RemoveSheet(padId string) error
	// SaveSheetOp stores op as revision rev. Ops are write-once: if rev is
	// taken (another instance stored it first) it returns ErrConflict.
	SaveSheetOp(padId string, rev int, op string, authorId *string, timestamp int64) error
	// GetSheetVersion returns what the stored sheet is at, without its
	// snapshot.
	GetSheetVersion(padId string) (*SheetVersion, error)
	// ResetSheet replaces the workbook: it removes the ops, stores snapshot
	// at head 0 and starts a new epoch, all or nothing. snapshot is also
	// kept as the op row at rev 0, the base the history starts from.
	ResetSheet(padId string, snapshot string) error
	GetSheetOps(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)
	// GetSheetOpInfo is GetSheetOps without the ops themselves (Op is
	// empty): revision, author and time, for the version history.
	GetSheetOpInfo(padId string, startRev int, endRev int) (*[]db.SheetOpDB, error)
	RemoveSheetOps(padId string) error
}

SheetMethods persist spreadsheet documents (header snapshot + op-log), keyed by pad id (a sheet document is a pad with document_type "sheet").

type SheetVersion added in v0.7.0

type SheetVersion struct {
	Exists bool
	// Head is the revision the stored snapshot is at.
	Head int
	// OpHead is the highest stored op, 0 if none. The ops are the
	// authoritative history: an op is stored before the snapshot, so OpHead
	// can be ahead of Head.
	OpHead int
	// Epoch changes when the workbook is replaced and numbering restarts.
	Epoch int
}

SheetVersion is what a stored sheet document is at.

func (*SheetVersion) Latest added in v0.7.0

func (v *SheetVersion) Latest() int

Latest is the revision the sheet is at.

type Token added in v0.7.0

type Token struct {
	ID        string
	AccountID string
	Name      string
	// Hash is the SHA-256 of the key, hex; the key itself is not stored.
	Hash string
	// Prefix is the start of the key, to tell keys apart in a list.
	Prefix string
	// Scopes are the scopes the token may use; "*" means all of them.
	Scopes []string
	// PadPattern limits the token to matching pads; "" means all pads.
	PadPattern string
	// ExpiresAt nil: never.
	ExpiresAt *time.Time
	// MaxExpiresAt is the latest a replaced token may work: its expiry
	// before the rotation (nil: it had none). A grace period never goes
	// past it.
	MaxExpiresAt *time.Time
	RevokedAt    *time.Time
	// ReplacedBy is the token a rotation made from this one; Predecessor
	// the one it was made from.
	ReplacedBy  string
	Predecessor string
	// ClientID is the OAuth client of an OAuth token, "" for API keys.
	ClientID   string
	CreatedBy  string
	CreatedAt  time.Time
	LastUsedAt *time.Time
	LastUsedIP string
	// Limits are the token's own limits, on top of those of the roles.
	Limits map[string]int64
}

Token is an API key (and later an OAuth token) of an account. Its rights are those of the account, cut down to its scopes and pad pattern (lib/tokens).

type TokenMethods added in v0.7.0

type TokenMethods interface {
	CreateToken(t Token) error
	GetToken(id string) (*Token, error)
	GetTokenByHash(hash string) (*Token, error)
	// ListTokens lists the tokens of an account, or all with "", oldest
	// first.
	ListTokens(accountID string) ([]Token, error)
	// UpdateToken writes the changeable fields: name, scopes, pad pattern,
	// expiry and its cap, revocation, rotation and limits.
	UpdateToken(t Token) error
	// TouchToken records a use.
	TouchToken(id string, at time.Time, ip string) error
}

TokenMethods store tokens.

type TokenTransfer added in v0.7.0

type TokenTransfer struct {
	ID        string
	Token     string
	Prefs     string
	CreatedAt time.Time
}

TokenTransfer is a one-time code that moves an author's identity (its token cookie) and preferences to another browser.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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