project

package
v0.0.0-...-1d800d4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessSourceToken  AccessSource = "token"
	AccessSourceInvite AccessSource = "invite"
	AccessSourceOwner  AccessSource = "owner"

	TokenBasedAccess PublicAccessLevel = "tokenBased"
	PrivateAccess    PublicAccessLevel = "private"
)
View Source
const (
	LinkedFileProviderURL               = "url"
	LinkedFileProviderProjectFile       = "project_file"
	LinkedFileProviderProjectOutputFile = "project_output_file"
)
View Source
const (
	DefaultCompiler = sharedTypes.PDFLaTeX
)

Variables

View Source
var ErrDuplicateNameInFolder = &errors.InvalidStateError{
	Msg: "folder already has entry with given name",
}
View Source
var ErrEpochIsNotStable = errors.New("epoch is not stable")
View Source
var ErrInvalidTokenFormat = &errors.ValidationError{Msg: "invalid token format"}

Functions

This section is empty.

Types

type AccessSource

type AccessSource string

func (AccessSource) Enum

func (a AccessSource) Enum() int8

type AccessToken

type AccessToken string

func (AccessToken) EqualsTimingSafe

func (t AccessToken) EqualsTimingSafe(other AccessToken) bool

func (AccessToken) ValidateReadAndWrite

func (t AccessToken) ValidateReadAndWrite() error

func (AccessToken) ValidateReadOnly

func (t AccessToken) ValidateReadOnly() error

type AuditLogEntry

type AuditLogEntry struct {
	CreatedAt   time.Time
	Info        interface{}
	InitiatorId sharedTypes.UUID
	Operation   string
}

type AuthorizationDetails

type AuthorizationDetails struct {
	Epoch          int64                      `json:"e"`
	PrivilegeLevel sharedTypes.PrivilegeLevel `json:"l"`
	AccessSource   AccessSource               `json:"s"`
}

func (*AuthorizationDetails) IsRestrictedUser

func (a *AuthorizationDetails) IsRestrictedUser() IsRestrictedUser

func (*AuthorizationDetails) IsTokenMember

func (a *AuthorizationDetails) IsTokenMember() bool

type CommonTreeFields

type CommonTreeFields struct {
	Id        sharedTypes.UUID     `json:"_id"`
	Name      sharedTypes.Filename `json:"name"`
	CreatedAt time.Time            `json:"created"`
}

func (CommonTreeFields) GetId

func (c CommonTreeFields) GetId() sharedTypes.UUID

type CompilerField

type CompilerField struct {
	Compiler sharedTypes.Compiler `json:"compiler"`
}

type ContentLockedAtField

type ContentLockedAtField struct {
	ContentLockedAt *time.Time `json:"contentLockedAt"`
}

type CreatedAtField

type CreatedAtField struct {
	CreatedAt time.Time
}

type DeletedAtField

type DeletedAtField struct {
	DeletedAt time.Time
}

type DeletedDocsField

type DeletedDocsField struct {
	DeletedDocs []CommonTreeFields `json:"deletedDocs"`
}

type Doc

type Doc struct {
	LeafFields
	Snapshot string              `json:"snapshot"`
	Version  sharedTypes.Version `json:"version"`
}

func NewDoc

func NewDoc(name sharedTypes.Filename) Doc

type DocWithParent

type DocWithParent struct {
	Doc
	Parent IdField
}

type DocsField

type DocsField struct {
	Docs []Doc
}

type EditableField

type EditableField struct {
	Editable bool `json:"editable"`
}

type EpochField

type EpochField struct {
	Epoch int64
}

type FileRef

type FileRef struct {
	LeafFields

	LinkedFileData *LinkedFileData  `json:"linkedFileData,omitempty"`
	Hash           sharedTypes.Hash `json:"hash,omitempty"`
	Size           int64            `json:"size"`
}

func NewFileRef

func NewFileRef(name sharedTypes.Filename, hash sharedTypes.Hash, size int64) FileRef

type FileWithParent

type FileWithParent struct {
	FileRef
	ParentId sharedTypes.UUID
}

type FilesField

type FilesField struct {
	Files []FileRef
}

type Folder

type Folder struct {
	CommonTreeFields
	Path sharedTypes.DirName `json:"-"`

	Docs     []Doc     `json:"docs"`
	FileRefs []FileRef `json:"fileRefs"`
	Folders  []Folder  `json:"folders"`
}

func NewFolder

func NewFolder(name sharedTypes.Filename) Folder

func (*Folder) CountNodes

func (t *Folder) CountNodes() int

func (*Folder) CreateParents

func (t *Folder) CreateParents(path sharedTypes.DirName) (*Folder, error)

func (*Folder) GetDoc

func (t *Folder) GetDoc(needle sharedTypes.Filename) *Doc

func (*Folder) GetEntry

func (t *Folder) GetEntry(needle sharedTypes.Filename) TreeElement

func (*Folder) GetFile

func (t *Folder) GetFile(needle sharedTypes.Filename) *FileRef

func (*Folder) HasEntry

func (t *Folder) HasEntry(needle sharedTypes.Filename) bool

func (*Folder) PopulateIds

func (t *Folder) PopulateIds(b *sharedTypes.UUIDBatch)

func (*Folder) WalkFolders

func (t *Folder) WalkFolders(fn func(*Folder) error) error

type FoldersField

type FoldersField struct {
	Folders []Folder `json:"-"`
}

type ForAuthorizationDetails

type ForAuthorizationDetails struct {
	Member
	EpochField
	PublicAccessLevelField
	TokensField
}

func (*ForAuthorizationDetails) GetPrivilegeLevel

func (p *ForAuthorizationDetails) GetPrivilegeLevel(userId sharedTypes.UUID, accessToken AccessToken) (*AuthorizationDetails, error)

func (*ForAuthorizationDetails) GetPrivilegeLevelAnonymous

func (p *ForAuthorizationDetails) GetPrivilegeLevelAnonymous(accessToken AccessToken) (*AuthorizationDetails, error)

func (*ForAuthorizationDetails) GetPrivilegeLevelAuthenticated

func (p *ForAuthorizationDetails) GetPrivilegeLevelAuthenticated() (*AuthorizationDetails, error)

type ForProjectEntries

type ForProjectEntries struct {
	DocsField
	FilesField
}

type ForProjectInvite

type ForProjectInvite struct {
	NameField
	ForAuthorizationDetails

	Sender user.WithPublicInfo
	User   user.WithPublicInfo
}

type ForProjectList

type ForProjectList struct {
	User          user.ProjectListViewCaller
	Tags          []tag.Full
	Notifications notification.Notifications
	Projects      List
}

type ForTokenAccessDetails

type ForTokenAccessDetails struct {
	IdField
	NameField
	ForAuthorizationDetails
}

type ForTree

type ForTree struct {
	RootFolderField
	// contains filtered or unexported fields
}

func (*ForTree) GetRootFolder

func (p *ForTree) GetRootFolder() *Folder

type ForZip

type ForZip struct {
	NameField
	ForTree
}

type IdField

type IdField struct {
	Id sharedTypes.UUID `json:"_id"`
}

type ImageNameField

type ImageNameField struct {
	ImageName sharedTypes.ImageName `json:"imageName"`
}

type IsRestrictedUser

type IsRestrictedUser bool

type LastOpenedField

type LastOpenedField struct {
	LastOpened time.Time
}

type LastUpdatedAtField

type LastUpdatedAtField struct {
	LastUpdatedAt time.Time
}

type LastUpdatedByField

type LastUpdatedByField struct {
	LastUpdatedBy sharedTypes.UUID
}

type LeafFields

type LeafFields struct {
	CommonTreeFields
	Path sharedTypes.PathName `json:"-"`
}

type LinkedFileData

type LinkedFileData struct {
	Provider             LinkedFileProvider   `json:"provider"`
	SourceProjectId      sharedTypes.UUID     `json:"source_project_id,omitempty"`
	SourceEntityPath     sharedTypes.PathName `json:"source_entity_path,omitempty"`
	SourceOutputFilePath sharedTypes.PathName `json:"source_output_file_path,omitempty"`
	URL                  string               `json:"url,omitempty"`
}

type LinkedFileProvider

type LinkedFileProvider string

func (LinkedFileProvider) Validate

func (p LinkedFileProvider) Validate() error

type List

type List []ListViewPrivate

type LoadEditorDetails

type LoadEditorDetails struct {
	Project LoadEditorViewPrivate
	User    user.WithLoadEditorInfo
}

type Manager

type Manager interface {
	PrepareProjectCreation(ctx context.Context, p *ForCreation) error
	FinalizeProjectCreation(ctx context.Context, p *ForCreation) error
	SoftDelete(ctx context.Context, projectIds sharedTypes.UUIDs, userId sharedTypes.UUID, ipAddress string) error
	HardDelete(ctx context.Context, projectId sharedTypes.UUID) error
	ProcessSoftDeleted(ctx context.Context, cutOff time.Time, fn func(projectId sharedTypes.UUID) bool) error
	GetDeletedProjectsName(ctx context.Context, projectId, userId sharedTypes.UUID) (Name, error)
	Restore(ctx context.Context, projectId, userId sharedTypes.UUID, name Name) error
	AddFolder(ctx context.Context, projectId, userId, parent sharedTypes.UUID, f *Folder) (sharedTypes.Version, error)
	DeleteDoc(ctx context.Context, projectId, userId, docId sharedTypes.UUID) (sharedTypes.Version, error)
	DeleteFile(ctx context.Context, projectId, userId, fileId sharedTypes.UUID) (sharedTypes.Version, error)
	DeleteFolder(ctx context.Context, projectId, userId, folderId sharedTypes.UUID) (sharedTypes.Version, error)
	RestoreDoc(ctx context.Context, projectId, userId, docId sharedTypes.UUID, name sharedTypes.Filename) (sharedTypes.Version, sharedTypes.UUID, error)
	MoveDoc(ctx context.Context, projectId, userId, folderId, docId sharedTypes.UUID) (sharedTypes.Version, sharedTypes.PathName, error)
	MoveFile(ctx context.Context, projectId, userId, folderId, fileId sharedTypes.UUID) (sharedTypes.Version, sharedTypes.PathName, error)
	MoveFolder(ctx context.Context, projectId, userId, targetFolderId, folderId sharedTypes.UUID) (sharedTypes.Version, []Doc, []FileRef, error)
	RenameDoc(ctx context.Context, projectId, userId sharedTypes.UUID, d *Doc) (sharedTypes.Version, sharedTypes.PathName, error)
	RenameFile(ctx context.Context, projectId, userId sharedTypes.UUID, f *FileRef) (sharedTypes.Version, sharedTypes.PathName, error)
	RenameFolder(ctx context.Context, projectId, userId sharedTypes.UUID, f *Folder) (sharedTypes.Version, []Doc, []FileRef, error)
	GetAuthorizationDetails(ctx context.Context, projectId, userId sharedTypes.UUID, accessToken AccessToken) (*AuthorizationDetails, error)
	GetForClone(ctx context.Context, projectId, userId sharedTypes.UUID) (*ForClone, error)
	GetForProjectInvite(ctx context.Context, projectId, actorId sharedTypes.UUID, email sharedTypes.Email) (*ForProjectInvite, error)
	GetForProjectJWT(ctx context.Context, projectId, userId sharedTypes.UUID, accessToken AccessToken) (*ForProjectJWT, int64, error)
	GetForZip(ctx context.Context, projectId sharedTypes.UUID, userId sharedTypes.UUID, accessToken AccessToken) (*ForZip, error)
	ValidateProjectJWTEpochs(ctx context.Context, projectId, userId sharedTypes.UUID, projectEpoch, userEpoch int64) error
	BumpLastOpened(ctx context.Context, projectId sharedTypes.UUID) error
	GetDoc(ctx context.Context, projectId, docId sharedTypes.UUID) (*time.Time, *Doc, error)
	GetFile(ctx context.Context, projectId, userId sharedTypes.UUID, accessToken AccessToken, fileId sharedTypes.UUID) (*FileWithParent, error)
	GetElementByPath(ctx context.Context, projectId, userId sharedTypes.UUID, path sharedTypes.PathName) (sharedTypes.UUID, bool, error)
	GetBootstrapWSDetails(ctx context.Context, projectId, userId sharedTypes.UUID, projectEpoch, userEpoch int64, source AccessSource, p *ForBootstrapWS, u *user.WithPublicInfo) error
	GetBootstrapWSUser(ctx context.Context, projectId, userId sharedTypes.UUID, projectEpoch, userEpoch int64, u *user.WithPublicInfo, treeVersion *sharedTypes.Version) error
	GetLastUpdatedAt(ctx context.Context, projectId sharedTypes.UUID) (time.Time, error)
	GetLoadEditorDetails(ctx context.Context, projectId, userId sharedTypes.UUID, accessToken AccessToken) (*LoadEditorDetails, error)
	GetProjectWithContent(ctx context.Context, projectId sharedTypes.UUID) ([]Doc, []FileRef, error)
	GetTokenAccessDetails(ctx context.Context, userId sharedTypes.UUID, privilegeLevel sharedTypes.PrivilegeLevel, accessToken AccessToken) (*ForTokenAccessDetails, *AuthorizationDetails, error)
	GetTreeEntities(ctx context.Context, projectId, userId sharedTypes.UUID) ([]TreeEntity, error)
	GetProjectMembers(ctx context.Context, projectId sharedTypes.UUID) ([]user.AsProjectMember, error)
	GrantTokenAccess(ctx context.Context, projectId, userId sharedTypes.UUID, accessToken AccessToken, privilegeLevel sharedTypes.PrivilegeLevel) error
	GrantMemberAccess(ctx context.Context, projectId, ownerId, userId sharedTypes.UUID, privilegeLevel sharedTypes.PrivilegeLevel) error
	GetAccessTokens(ctx context.Context, projectId, userId sharedTypes.UUID, tokens *Tokens) error
	PopulateTokens(ctx context.Context, projectId, userId sharedTypes.UUID) (*Tokens, error)
	GetProjectNames(ctx context.Context, userId sharedTypes.UUID) (Names, error)
	SetCompiler(ctx context.Context, projectId, userId sharedTypes.UUID, compiler sharedTypes.Compiler) error
	SetImageName(ctx context.Context, projectId, userId sharedTypes.UUID, imageName sharedTypes.ImageName) error
	SetSpellCheckLanguage(ctx context.Context, projectId, userId sharedTypes.UUID, spellCheckLanguage spellingTypes.SpellCheckLanguage) error
	SetRootDoc(ctx context.Context, projectId, userId, rooDocId sharedTypes.UUID) error
	SetPublicAccessLevel(ctx context.Context, projectId, userId sharedTypes.UUID, level PublicAccessLevel) error
	ArchiveForUser(ctx context.Context, projectId, userId sharedTypes.UUID) error
	UnArchiveForUser(ctx context.Context, projectId, userId sharedTypes.UUID) error
	TrashForUser(ctx context.Context, projectId, userId sharedTypes.UUID) error
	UnTrashForUser(ctx context.Context, projectId, userId sharedTypes.UUID) error
	Rename(ctx context.Context, projectId, userId sharedTypes.UUID, name Name) error
	RemoveMember(ctx context.Context, projectId sharedTypes.UUID, actor, userId sharedTypes.UUID) error
	TransferOwnership(ctx context.Context, projectId, previousOwnerId, newOwnerId sharedTypes.UUID) (*user.WithPublicInfo, *user.WithPublicInfo, Name, error)
	CreateDoc(ctx context.Context, projectId, userId, folderId sharedTypes.UUID, d *Doc) (sharedTypes.Version, error)
	EnsureIsDoc(ctx context.Context, projectId, userId, folderId sharedTypes.UUID, d *Doc) (sharedTypes.UUID, bool, sharedTypes.Version, error)
	PrepareFileCreation(ctx context.Context, projectId, userId, folderId sharedTypes.UUID, f *FileRef) error
	FinalizeFileCreation(ctx context.Context, projectId, userId sharedTypes.UUID, f *FileRef) (sharedTypes.UUID, bool, sharedTypes.Version, error)
	ProcessStaleFileUploads(ctx context.Context, cutOff time.Time, fn func(projectId, fileId sharedTypes.UUID) bool) error
	PurgeStaleFileUpload(ctx context.Context, projectId, fileId sharedTypes.UUID) error
	ListProjectsWithName(ctx context.Context, userId sharedTypes.UUID) ([]WithIdAndName, error)
	GetOwnedProjects(ctx context.Context, userId sharedTypes.UUID) ([]sharedTypes.UUID, error)
	GetProjectListDetails(ctx context.Context, userId sharedTypes.UUID, r *ForProjectList) error
	SetContentLockedAt(ctx context.Context, projectId, userId sharedTypes.UUID, contentLocked *time.Time) (bool, error)
}

func New

func New(db *pgxpool.Pool) Manager

type Member

type Member struct {
	AccessSource   AccessSource
	PrivilegeLevel sharedTypes.PrivilegeLevel
	Archived       bool
	Trashed        bool
}

type Name

type Name string

func (Name) Validate

func (n Name) Validate() error

type NameField

type NameField struct {
	Name Name `json:"name"`
}

type Names

type Names []Name

func (Names) MakeUnique

func (names Names) MakeUnique(source Name) Name

type OwnerFeaturesField

type OwnerFeaturesField struct {
	OwnerFeatures user.Features `json:"features"`
}

type OwnerField

type OwnerField struct {
	Owner user.WithPublicInfo `json:"owner"`
}

type OwnerIdField

type OwnerIdField struct {
	OwnerId sharedTypes.UUID `json:"owner_ref"`
}

type PublicAccessLevel

type PublicAccessLevel string

func (PublicAccessLevel) Validate

func (l PublicAccessLevel) Validate() error

type PublicAccessLevelField

type PublicAccessLevelField struct {
	PublicAccessLevel PublicAccessLevel `json:"publicAccessLevel"`
}

type RootDoc

type RootDoc struct {
	Doc
}

type RootDocField

type RootDocField struct {
	RootDoc RootDoc `json:"root_doc"`
}

type RootDocIdField

type RootDocIdField struct {
	RootDocId sharedTypes.UUID `json:"rootDoc_id"`
}

type RootFolderField

type RootFolderField struct {
	RootFolder Folder
}

type SpellCheckLanguageField

type SpellCheckLanguageField struct {
	SpellCheckLanguage spellingTypes.SpellCheckLanguage `json:"spellCheckLanguage"`
}

type TokenAccessDetails

type TokenAccessDetails struct {
	ProjectId sharedTypes.UUID
	Fresh     *AuthorizationDetails
	Existing  *AuthorizationDetails
}

func (*TokenAccessDetails) ShouldGrantHigherAccess

func (r *TokenAccessDetails) ShouldGrantHigherAccess() bool

type Tokens

type Tokens struct {
	ReadOnly           AccessToken `json:"readOnly"`
	ReadAndWrite       AccessToken `json:"readAndWrite"`
	ReadAndWritePrefix string      `json:"-"`
}

type TokensField

type TokensField struct {
	Tokens Tokens `json:"tokens"`
}

type TreeElement

type TreeElement interface {
	GetId() sharedTypes.UUID
}

type TreeEntity

type TreeEntity struct {
	Path string `json:"path"`
	Type string `json:"type"`
}

type TreeNodeKind

type TreeNodeKind string
const (
	TreeNodeKindDoc    TreeNodeKind = "doc"
	TreeNodeKindFile   TreeNodeKind = "file"
	TreeNodeKindFolder TreeNodeKind = "folder"
)

type VersionField

type VersionField struct {
	Version sharedTypes.Version `json:"version"`
}

type WithIdAndName

type WithIdAndName struct {
	IdField
	NameField
}

Jump to

Keyboard shortcuts

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