model

package
v0.0.0-...-ae31a8f Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ******************* GENERAL CONSTANTS *******************
	// Constants related to CLI and Config
	EnvPrefix                 = "EM_"
	EMAppName                 = "evermarkable"
	EMDefaultCacheDirModeSet  = 0700
	EMDTCacheFile             = "dt.cache"
	EMDefaultCacheFileModeSet = 0600
	EMCacheVersion            = 3

	// ******************* REMARKABLE SPECIFIC CONSTANTS *******************
	// URI's for remarkable cloud endpoints which can be overridden
	DocHost  = "https://document-storage-production-dot-remarkable-production.appspot.com"
	AuthHost = "https://webapp-prod.cloud.remarkable.engineering"
	SyncHost = "https://internal.cloud.remarkable.com"

	// Paths for requesting tokens
	//nolint:gosec // the following are not hardcoded credentials
	DeviceTokenPath = "/token/json/2/device/new"
	UserDevicePath  = "/token/json/2/user/new"

	// Paths for document storage
	ListDocsPath      = "/document-storage/json/2/docs"
	UpdateStatusPath  = "/document-storage/json/2/upload/update-status"
	UploadRequestPath = "/document-storage/json/2/upload/request"
	DeleteEntryPath   = "/document-storage/json/2/delete"

	// Paths for sync endpoints
	UploadBlobPath   = "/sync/v2/signed-urls/uploads"
	DownloadBlobPath = "/sync/v2/signed-urls/downloads"
	SyncCompletePath = "/sync/v2/sync-complete"

	// User agent used when making web requests
	EMUserAgent = "evermarkable"

	// Constants related to authentication to remarkable API
	DeviceTokenSecName = "device-token"
	UserTokenSecName   = "user-token"
	DefaultDeviceDesc  = "desktop-linux"

	// Constants related to remarkable nodes and documents
	DirectoryType = "CollectionType"
	DocumentType  = "DocumentType"

	// The root path name for the remarkable cloud
	RemRootPathName       = "root"
	RemDefaultConcurrency = 99
)

Variables

View Source
var (
	ContextConfigSet = EMContextKey{ContextKey: "config"}
)

Functions

This section is empty.

Types

type BlobRootStorageRequest

type BlobRootStorageRequest struct {
	Method       string `json:"http_method"`
	Initial      bool   `json:"initial_sync,omitempty"`
	RelativePath string `json:"relative_path"`
	RootSchema   string `json:"root_schema,omitempty"`
	Generation   int64  `json:"generation"`
}

type BlobStorageRequest

type BlobStorageRequest struct {
	Method       string `json:"http_method"`
	Initial      bool   `json:"initial_sync,omitempty"`
	RelativePath string `json:"relative_path"`
	ParentPath   string `json:"parent_path,omitempty"`
}

BlobStorageRequest request

type BlobStorageResponse

type BlobStorageResponse struct {
	Expires            string `json:"expires"`
	Method             string `json:"method"`
	RelativePath       string `json:"relative_path"`
	URL                string `json:"url"`
	MaxUploadSizeBytes int64  `json:"maxuploadsize_bytes,omitempty"`
}

BlobStorageResponse response

type ConcurrencyProvider

type ConcurrencyProvider interface {
	GetConcurrency() int
}

type DeleteDocument

type DeleteDocument struct {
	ID      string
	Version int
}

type Document

type Document struct {
	ID                string
	Version           int
	Message           string
	Success           bool
	BlobURLGet        string
	BlobURLGetExpires string
	ModifiedClient    string
	Type              string
	VissibleName      string
	CurrentPage       int
	Bookmarked        bool
	Parent            string
}

func (Document) ToDeleteDocument

func (doc Document) ToDeleteDocument() DeleteDocument

func (Document) ToMetaDocument

func (doc Document) ToMetaDocument() MetadataDocument

type EMConfig

type EMConfig struct {
	Remarkable EMRemarkableConfig
}

type EMConfigHolder

type EMConfigHolder interface {
	GetEMConfig() (*EMConfig, error)
}

type EMContextKey

type EMContextKey struct {
	ContextKey string
}

type EMRemarkableConfig

type EMRemarkableConfig struct {
	URLs        EMURLConfig `yaml:"urls"`
	Concurrency int
}

func (EMRemarkableConfig) GetConcurrency

func (e EMRemarkableConfig) GetConcurrency() int

func (EMRemarkableConfig) GetURLProvider

func (e EMRemarkableConfig) GetURLProvider() URLProvider

type EMRootConfig

type EMRootConfig struct {
	ConfigPath string
	Config     EMConfig
}

type EMURLConfig

type EMURLConfig struct {
	DocumentHost string `yaml:"documentHost"`
	AuthHost     string `yaml:"authHost"`
	SyncHost     string `yaml:"syncHost"`
}

func (EMURLConfig) AuthWithPath

func (e EMURLConfig) AuthWithPath(path string) string

func (EMURLConfig) DocWithPath

func (e EMURLConfig) DocWithPath(path string) string

func (EMURLConfig) SyncWithPath

func (e EMURLConfig) SyncWithPath(path string) string

type EMURLProvider

type EMURLProvider interface {
	DocWithPath(path string) string
	AuthWithPath(path string) string
	SyncWithPath(path string) string
}

type MetadataDocument

type MetadataDocument struct {
	ID             string
	Parent         string
	VissibleName   string
	Type           string
	Version        int
	ModifiedClient string
}

func CreateDirDocument

func CreateDirDocument(parent, name string) MetadataDocument

func CreateUploadDocumentMeta

func CreateUploadDocumentMeta(id string, entryType, parent, name string) MetadataDocument

func (MetadataDocument) ToDocument

func (meta MetadataDocument) ToDocument() Document

type Node

type Node struct {
	Document *Document
	Children map[string]*Node
	Parent   *Node
}

func CreateNode

func CreateNode(document Document) Node

func (*Node) EntyExists

func (node *Node) EntyExists(id string) bool

func (*Node) FindByName

func (node *Node) FindByName(name string) (*Node, error)

func (*Node) ID

func (node *Node) ID() string

func (*Node) IsDirectory

func (node *Node) IsDirectory() bool

func (*Node) IsFile

func (node *Node) IsFile() bool

func (*Node) IsRoot

func (node *Node) IsRoot() bool

func (*Node) LastModified

func (node *Node) LastModified() (time.Time, error)

func (*Node) Name

func (node *Node) Name() string

func (*Node) Version

func (node *Node) Version() int

type SyncCompletedRequest

type SyncCompletedRequest struct {
	Generation int64 `json:"generation"`
}

SyncCompleteRequest payload of the sync completion

type URLProvider

type URLProvider interface {
	DocWithPath(path string) string
	AuthWithPath(path string) string
	SyncWithPath(path string) string
}

type URLProviderHolder

type URLProviderHolder interface {
	GetURLProvider() (URLProvider, error)
}

type UploadDocumentRequest

type UploadDocumentRequest struct {
	ID      string
	Type    string
	Version int
}

func CreateUploadDocumentRequest

func CreateUploadDocumentRequest(id string, entryType string) UploadDocumentRequest

type UploadDocumentResponse

type UploadDocumentResponse struct {
	ID                string
	Version           int
	Message           string
	Success           bool
	BlobURLPut        string
	BlobURLPutExpires string
}

Jump to

Keyboard shortcuts

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