api

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalStorage means the storage service is local file system.
	LocalStorage = -1
	// DatabaseStorage means the storage service is database.
	DatabaseStorage = 0
)
View Source
const UnknownID = -1

UnknownID is the ID for unknowns.

Variables

View Source
var (
	UserSettingLocaleValue = []string{
		"de",
		"en",
		"es",
		"fr",
		"hr",
		"it",
		"ja",
		"ko",
		"nl",
		"pl",
		"pt-BR",
		"ru",
		"sl",
		"sv",
		"tr",
		"uk",
		"vi",
		"zh-Hans",
		"zh-Hant",
	}
	UserSettingAppearanceValue     = []string{"system", "light", "dark"}
	UserSettingMemoVisibilityValue = []Visibility{Private, Protected, Public}
)

Functions

This section is empty.

Types

type Activity added in v0.10.0

type Activity struct {
	ID int `json:"id"`

	// Standard fields
	CreatorID int   `json:"creatorId"`
	CreatedTs int64 `json:"createdTs"`

	// Domain specific fields
	Type    ActivityType  `json:"type"`
	Level   ActivityLevel `json:"level"`
	Payload string        `json:"payload"`
}

type ActivityCreate added in v0.10.0

type ActivityCreate struct {
	// Standard fields
	CreatorID int

	// Domain specific fields
	Type    ActivityType `json:"type"`
	Level   ActivityLevel
	Payload string `json:"payload"`
}

ActivityCreate is the API message for creating an activity.

type ActivityLevel added in v0.10.0

type ActivityLevel string

ActivityLevel is the level of activities.

const (
	// ActivityInfo is the INFO level of activities.
	ActivityInfo ActivityLevel = "INFO"
	// ActivityWarn is the WARN level of activities.
	ActivityWarn ActivityLevel = "WARN"
	// ActivityError is the ERROR level of activities.
	ActivityError ActivityLevel = "ERROR"
)

type ActivityMemoCreatePayload added in v0.10.0

type ActivityMemoCreatePayload struct {
	Content    string `json:"content"`
	Visibility string `json:"visibility"`
}

type ActivityResourceCreatePayload added in v0.10.0

type ActivityResourceCreatePayload struct {
	Filename string `json:"filename"`
	Type     string `json:"type"`
	Size     int64  `json:"size"`
}

type ActivityServerStartPayload added in v0.10.0

type ActivityServerStartPayload struct {
	ServerID string           `json:"serverId"`
	Profile  *profile.Profile `json:"profile"`
}

type ActivityShortcutCreatePayload added in v0.10.0

type ActivityShortcutCreatePayload struct {
	Title   string `json:"title"`
	Payload string `json:"payload"`
}

type ActivityTagCreatePayload added in v0.10.0

type ActivityTagCreatePayload struct {
	TagName string `json:"tagName"`
}

type ActivityType added in v0.10.0

type ActivityType string

ActivityType is the type for an activity.

const (

	// ActivityUserCreate is the type for creating users.
	ActivityUserCreate ActivityType = "user.create"
	// ActivityUserUpdate is the type for updating users.
	ActivityUserUpdate ActivityType = "user.update"
	// ActivityUserDelete is the type for deleting users.
	ActivityUserDelete ActivityType = "user.delete"
	// ActivityUserAuthSignIn is the type for user signin.
	ActivityUserAuthSignIn ActivityType = "user.auth.signin"
	// ActivityUserAuthSignUp is the type for user signup.
	ActivityUserAuthSignUp ActivityType = "user.auth.signup"
	// ActivityUserSettingUpdate is the type for updating user settings.
	ActivityUserSettingUpdate ActivityType = "user.setting.update"

	// ActivityMemoCreate is the type for creating memos.
	ActivityMemoCreate ActivityType = "memo.create"
	// ActivityMemoUpdate is the type for updating memos.
	ActivityMemoUpdate ActivityType = "memo.update"
	// ActivityMemoDelete is the type for deleting memos.
	ActivityMemoDelete ActivityType = "memo.delete"

	// ActivityShortcutCreate is the type for creating shortcuts.
	ActivityShortcutCreate ActivityType = "shortcut.create"
	// ActivityShortcutUpdate is the type for updating shortcuts.
	ActivityShortcutUpdate ActivityType = "shortcut.update"
	// ActivityShortcutDelete is the type for deleting shortcuts.
	ActivityShortcutDelete ActivityType = "shortcut.delete"

	// ActivityResourceCreate is the type for creating resources.
	ActivityResourceCreate ActivityType = "resource.create"
	// ActivityResourceDelete is the type for deleting resources.
	ActivityResourceDelete ActivityType = "resource.delete"

	// ActivityTagCreate is the type for creating tags.
	ActivityTagCreate ActivityType = "tag.create"
	// ActivityTagDelete is the type for deleting tags.
	ActivityTagDelete ActivityType = "tag.delete"

	// ActivityServerStart is the type for starting server.
	ActivityServerStart ActivityType = "server.start"
)

type ActivityUserAuthSignInPayload added in v0.10.0

type ActivityUserAuthSignInPayload struct {
	UserID int    `json:"userId"`
	IP     string `json:"ip"`
}

type ActivityUserAuthSignUpPayload added in v0.10.0

type ActivityUserAuthSignUpPayload struct {
	Username string `json:"username"`
	IP       string `json:"ip"`
}

type ActivityUserCreatePayload added in v0.10.0

type ActivityUserCreatePayload struct {
	UserID   int    `json:"userId"`
	Username string `json:"username"`
	Role     Role   `json:"role"`
}

type CreateMemoRequest added in v0.13.1

type CreateMemoRequest struct {
	// Standard fields
	CreatorID int    `json:"-"`
	CreatedTs *int64 `json:"createdTs"`

	// Domain specific fields
	Visibility Visibility `json:"visibility"`
	Content    string     `json:"content"`

	// Related fields
	ResourceIDList []int                 `json:"resourceIdList"`
	RelationList   []*MemoRelationUpsert `json:"relationList"`
}

type CustomizedProfile added in v0.9.0

type CustomizedProfile struct {
	// Name is the server name, default is `memos`
	Name string `json:"name"`
	// LogoURL is the url of logo image.
	LogoURL string `json:"logoUrl"`
	// Description is the server description.
	Description string `json:"description"`
	// Locale is the server default locale.
	Locale string `json:"locale"`
	// Appearance is the server default appearance.
	Appearance string `json:"appearance"`
	// ExternalURL is the external url of server. e.g. https://usermemos.com
	ExternalURL string `json:"externalUrl"`
}

CustomizedProfile is the struct definition for SystemSettingCustomizedProfileName system setting item.

type FindMemoRequest added in v0.13.1

type FindMemoRequest struct {
	ID *int

	// Standard fields
	RowStatus *RowStatus
	CreatorID *int

	// Domain specific fields
	Pinned         *bool
	ContentSearch  []string
	VisibilityList []Visibility

	// Pagination
	Limit  *int
	Offset *int
}

type MemoOrganizer

type MemoOrganizer struct {
	// Domain specific fields
	MemoID int
	UserID int
	Pinned bool
}

type MemoOrganizerDelete added in v0.7.2

type MemoOrganizerDelete struct {
	MemoID *int
	UserID *int
}

type MemoOrganizerFind

type MemoOrganizerFind struct {
	MemoID int
	UserID int
}

type MemoOrganizerUpsert

type MemoOrganizerUpsert struct {
	MemoID int  `json:"-"`
	UserID int  `json:"-"`
	Pinned bool `json:"pinned"`
}

type MemoRelation added in v0.13.0

type MemoRelation struct {
	MemoID        int              `json:"memoId"`
	RelatedMemoID int              `json:"relatedMemoId"`
	Type          MemoRelationType `json:"type"`
}

type MemoRelationType added in v0.13.0

type MemoRelationType string
const (
	MemoRelationReference  MemoRelationType = "REFERENCE"
	MemoRelationAdditional MemoRelationType = "ADDITIONAL"
)

type MemoRelationUpsert added in v0.13.0

type MemoRelationUpsert struct {
	RelatedMemoID int              `json:"relatedMemoId"`
	Type          MemoRelationType `json:"type"`
}

type MemoResource added in v0.5.0

type MemoResource struct {
	MemoID     int
	ResourceID int
	CreatedTs  int64
	UpdatedTs  int64
}

type MemoResourceDelete added in v0.5.0

type MemoResourceDelete struct {
	MemoID     *int
	ResourceID *int
}

type MemoResourceFind added in v0.5.0

type MemoResourceFind struct {
	MemoID     *int
	ResourceID *int
}

type MemoResourceUpsert added in v0.5.0

type MemoResourceUpsert struct {
	MemoID     int `json:"-"`
	ResourceID int
	UpdatedTs  *int64
}

type MemoResponse added in v0.13.1

type MemoResponse struct {
	ID int `json:"id"`

	// Standard fields
	RowStatus RowStatus `json:"rowStatus"`
	CreatorID int       `json:"creatorId"`
	CreatedTs int64     `json:"createdTs"`
	UpdatedTs int64     `json:"updatedTs"`

	// Domain specific fields
	DisplayTs  int64      `json:"displayTs"`
	Content    string     `json:"content"`
	Visibility Visibility `json:"visibility"`
	Pinned     bool       `json:"pinned"`

	// Related fields
	CreatorName  string          `json:"creatorName"`
	ResourceList []*Resource     `json:"resourceList"`
	RelationList []*MemoRelation `json:"relationList"`
}

type OpenAIConfig added in v0.11.2

type OpenAIConfig struct {
	Key  string `json:"key"`
	Host string `json:"host"`
}

type PatchMemoRequest added in v0.13.1

type PatchMemoRequest struct {
	ID int `json:"-"`

	// Standard fields
	CreatedTs *int64 `json:"createdTs"`
	UpdatedTs *int64
	RowStatus *RowStatus `json:"rowStatus"`

	// Domain specific fields
	Content    *string     `json:"content"`
	Visibility *Visibility `json:"visibility"`

	// Related fields
	ResourceIDList []int                 `json:"resourceIdList"`
	RelationList   []*MemoRelationUpsert `json:"relationList"`
}

type Resource

type Resource struct {
	ID int `json:"id"`

	// Standard fields
	CreatorID int   `json:"creatorId"`
	CreatedTs int64 `json:"createdTs"`
	UpdatedTs int64 `json:"updatedTs"`

	// Domain specific fields
	Filename     string `json:"filename"`
	Blob         []byte `json:"-"`
	InternalPath string `json:"-"`
	ExternalLink string `json:"externalLink"`
	Type         string `json:"type"`
	Size         int64  `json:"size"`
	PublicID     string `json:"publicId"`

	// Related fields
	LinkedMemoAmount int `json:"linkedMemoAmount"`
}

type ResourceCreate

type ResourceCreate struct {
	// Standard fields
	CreatorID int `json:"-"`

	// Domain specific fields
	Filename        string `json:"filename"`
	Blob            []byte `json:"-"`
	InternalPath    string `json:"internalPath"`
	ExternalLink    string `json:"externalLink"`
	Type            string `json:"type"`
	Size            int64  `json:"-"`
	PublicID        string `json:"publicId"`
	DownloadToLocal bool   `json:"downloadToLocal"`
}

type ResourceDelete

type ResourceDelete struct {
	ID int
}

type ResourceFind

type ResourceFind struct {
	ID *int `json:"id"`

	// Standard fields
	CreatorID *int `json:"creatorId"`

	// Domain specific fields
	Filename *string `json:"filename"`
	MemoID   *int
	PublicID *string `json:"publicId"`
	GetBlob  bool

	// Pagination
	Limit  *int
	Offset *int
}

type ResourcePatch added in v0.7.0

type ResourcePatch struct {
	ID int `json:"-"`

	// Standard fields
	UpdatedTs *int64

	// Domain specific fields
	Filename      *string `json:"filename"`
	ResetPublicID *bool   `json:"resetPublicId"`
	PublicID      *string `json:"-"`
}

type Role

type Role string

Role is the type of a role.

const (
	// Host is the HOST role.
	Host Role = "HOST"
	// Admin is the ADMIN role.
	Admin Role = "ADMIN"
	// NormalUser is the USER role.
	NormalUser Role = "USER"
)

func (Role) String

func (e Role) String() string

type RowStatus

type RowStatus string

RowStatus is the status for a row.

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

func (RowStatus) String

func (e RowStatus) String() string

type Shortcut

type Shortcut struct {
	ID int `json:"id"`

	// Standard fields
	RowStatus RowStatus `json:"rowStatus"`
	CreatorID int       `json:"creatorId"`
	CreatedTs int64     `json:"createdTs"`
	UpdatedTs int64     `json:"updatedTs"`

	// Domain specific fields
	Title   string `json:"title"`
	Payload string `json:"payload"`
}

type ShortcutCreate

type ShortcutCreate struct {
	// Standard fields
	CreatorID int `json:"-"`

	// Domain specific fields
	Title   string `json:"title"`
	Payload string `json:"payload"`
}

type ShortcutDelete

type ShortcutDelete struct {
	ID *int

	// Standard fields
	CreatorID *int
}

type ShortcutFind

type ShortcutFind struct {
	ID *int

	// Standard fields
	CreatorID *int

	// Domain specific fields
	Title *string `json:"title"`
}

type ShortcutPatch

type ShortcutPatch struct {
	ID int `json:"-"`

	// Standard fields
	UpdatedTs *int64
	RowStatus *RowStatus `json:"rowStatus"`

	// Domain specific fields
	Title   *string `json:"title"`
	Payload *string `json:"payload"`
}

type Storage added in v0.11.0

type Storage struct {
	ID     int            `json:"id"`
	Name   string         `json:"name"`
	Type   StorageType    `json:"type"`
	Config *StorageConfig `json:"config"`
}

type StorageConfig added in v0.11.0

type StorageConfig struct {
	S3Config *StorageS3Config `json:"s3Config"`
}

type StorageCreate added in v0.11.0

type StorageCreate struct {
	Name   string         `json:"name"`
	Type   StorageType    `json:"type"`
	Config *StorageConfig `json:"config"`
}

type StorageDelete added in v0.11.0

type StorageDelete struct {
	ID int `json:"id"`
}

type StorageFind added in v0.11.0

type StorageFind struct {
	ID *int `json:"id"`
}

type StoragePatch added in v0.11.0

type StoragePatch struct {
	ID     int            `json:"id"`
	Type   StorageType    `json:"type"`
	Name   *string        `json:"name"`
	Config *StorageConfig `json:"config"`
}

type StorageS3Config added in v0.11.0

type StorageS3Config struct {
	EndPoint  string `json:"endPoint"`
	Path      string `json:"path"`
	Region    string `json:"region"`
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`
	Bucket    string `json:"bucket"`
	URLPrefix string `json:"urlPrefix"`
	URLSuffix string `json:"urlSuffix"`
}

type StorageType added in v0.11.0

type StorageType string
const (
	StorageS3 StorageType = "S3"
)

type SystemSetting added in v0.7.1

type SystemSetting struct {
	Name SystemSettingName `json:"name"`
	// Value is a JSON string with basic value.
	Value       string `json:"value"`
	Description string `json:"description"`
}

type SystemSettingFind added in v0.7.1

type SystemSettingFind struct {
	Name SystemSettingName `json:"name"`
}

type SystemSettingName added in v0.7.1

type SystemSettingName string
const (
	// SystemSettingServerIDName is the name of server id.
	SystemSettingServerIDName SystemSettingName = "server-id"
	// SystemSettingSecretSessionName is the name of secret session.
	SystemSettingSecretSessionName SystemSettingName = "secret-session"
	// SystemSettingAllowSignUpName is the name of allow signup setting.
	SystemSettingAllowSignUpName SystemSettingName = "allow-signup"
	// SystemSettingDisablePublicMemosName is the name of disable public memos setting.
	SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos"
	// SystemSettingMaxUploadSizeMiBName is the name of max upload size setting.
	SystemSettingMaxUploadSizeMiBName SystemSettingName = "max-upload-size-mib"
	// SystemSettingAdditionalStyleName is the name of additional style.
	SystemSettingAdditionalStyleName SystemSettingName = "additional-style"
	// SystemSettingAdditionalScriptName is the name of additional script.
	SystemSettingAdditionalScriptName SystemSettingName = "additional-script"
	// SystemSettingCustomizedProfileName is the name of customized server profile.
	SystemSettingCustomizedProfileName SystemSettingName = "customized-profile"
	// SystemSettingStorageServiceIDName is the name of storage service ID.
	SystemSettingStorageServiceIDName SystemSettingName = "storage-service-id"
	// SystemSettingLocalStoragePathName is the name of local storage path.
	SystemSettingLocalStoragePathName SystemSettingName = "local-storage-path"
	// SystemSettingOpenAIConfigName is the name of OpenAI config.
	SystemSettingOpenAIConfigName SystemSettingName = "openai-config"
	// SystemSettingTelegramBotToken is the name of Telegram Bot Token.
	SystemSettingTelegramBotTokenName         SystemSettingName = "telegram-bot-token"
	SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts"
)

func (SystemSettingName) String added in v0.7.1

func (key SystemSettingName) String() string

type SystemSettingUpsert added in v0.7.1

type SystemSettingUpsert struct {
	Name        SystemSettingName `json:"name"`
	Value       string            `json:"value"`
	Description string            `json:"description"`
}

func (SystemSettingUpsert) Validate added in v0.7.1

func (upsert SystemSettingUpsert) Validate() error

type SystemStatus

type SystemStatus struct {
	Host    *User           `json:"host"`
	Profile profile.Profile `json:"profile"`
	DBSize  int64           `json:"dbSize"`

	// System settings
	// Allow sign up.
	AllowSignUp bool `json:"allowSignUp"`
	// Disable public memos.
	DisablePublicMemos bool `json:"disablePublicMemos"`
	// Max upload size.
	MaxUploadSizeMiB int `json:"maxUploadSizeMiB"`
	// Additional style.
	AdditionalStyle string `json:"additionalStyle"`
	// Additional script.
	AdditionalScript string `json:"additionalScript"`
	// Customized server profile, including server name and external url.
	CustomizedProfile CustomizedProfile `json:"customizedProfile"`
	// Storage service ID.
	StorageServiceID int `json:"storageServiceId"`
	// Local storage path.
	LocalStoragePath string `json:"localStoragePath"`
	// Memo display with updated timestamp.
	MemoDisplayWithUpdatedTs bool `json:"memoDisplayWithUpdatedTs"`
}

type Tag added in v0.9.0

type Tag struct {
	Name      string
	CreatorID int
}

type TagDelete added in v0.9.0

type TagDelete struct {
	Name      string `json:"name"`
	CreatorID int
}

type TagFind added in v0.9.0

type TagFind struct {
	CreatorID int
}

type TagUpsert added in v0.9.0

type TagUpsert struct {
	Name      string
	CreatorID int `json:"-"`
}

type User

type User struct {
	ID int `json:"id"`

	// Standard fields
	RowStatus RowStatus `json:"rowStatus"`
	CreatedTs int64     `json:"createdTs"`
	UpdatedTs int64     `json:"updatedTs"`

	// Domain specific fields
	Username        string         `json:"username"`
	Role            Role           `json:"role"`
	Email           string         `json:"email"`
	Nickname        string         `json:"nickname"`
	PasswordHash    string         `json:"-"`
	OpenID          string         `json:"openId"`
	AvatarURL       string         `json:"avatarUrl"`
	UserSettingList []*UserSetting `json:"userSettingList"`
}

type UserCreate

type UserCreate struct {
	// Domain specific fields
	Username     string `json:"username"`
	Role         Role   `json:"role"`
	Email        string `json:"email"`
	Nickname     string `json:"nickname"`
	Password     string `json:"password"`
	PasswordHash string
	OpenID       string
}

func (UserCreate) Validate added in v0.4.1

func (create UserCreate) Validate() error

type UserDelete added in v0.3.0

type UserDelete struct {
	ID int
}

type UserFind

type UserFind struct {
	ID *int `json:"id"`

	// Standard fields
	RowStatus *RowStatus `json:"rowStatus"`

	// Domain specific fields
	Username *string `json:"username"`
	Role     *Role
	Email    *string `json:"email"`
	Nickname *string `json:"nickname"`
	OpenID   *string
}

type UserPatch

type UserPatch struct {
	ID int `json:"-"`

	// Standard fields
	UpdatedTs *int64
	RowStatus *RowStatus `json:"rowStatus"`

	// Domain specific fields
	Username     *string `json:"username"`
	Email        *string `json:"email"`
	Nickname     *string `json:"nickname"`
	Password     *string `json:"password"`
	ResetOpenID  *bool   `json:"resetOpenId"`
	AvatarURL    *string `json:"avatarUrl"`
	PasswordHash *string
	OpenID       *string
}

func (UserPatch) Validate added in v0.9.1

func (patch UserPatch) Validate() error

type UserSetting added in v0.4.0

type UserSetting struct {
	UserID int
	Key    UserSettingKey `json:"key"`
	// Value is a JSON string with basic value
	Value string `json:"value"`
}

type UserSettingDelete added in v0.7.2

type UserSettingDelete struct {
	UserID int
}

type UserSettingFind added in v0.4.0

type UserSettingFind struct {
	UserID *int

	Key UserSettingKey `json:"key"`
}

type UserSettingKey added in v0.4.0

type UserSettingKey string
const (
	// UserSettingLocaleKey is the key type for user locale.
	UserSettingLocaleKey UserSettingKey = "locale"
	// UserSettingAppearanceKey is the key type for user appearance.
	UserSettingAppearanceKey UserSettingKey = "appearance"
	// UserSettingMemoVisibilityKey is the key type for user preference memo default visibility.
	UserSettingMemoVisibilityKey UserSettingKey = "memo-visibility"
	// UserSettingTelegramUserID is the key type for telegram UserID of memos user.
	UserSettingTelegramUserIDKey UserSettingKey = "telegram-user-id"
)

func (UserSettingKey) String added in v0.4.0

func (key UserSettingKey) String() string

String returns the string format of UserSettingKey type.

type UserSettingUpsert added in v0.4.0

type UserSettingUpsert struct {
	UserID int            `json:"-"`
	Key    UserSettingKey `json:"key"`
	Value  string         `json:"value"`
}

func (UserSettingUpsert) Validate added in v0.4.1

func (upsert UserSettingUpsert) Validate() error

type Visibility added in v0.2.0

type Visibility string

Visibility is the type of a visibility.

const (
	// Public is the PUBLIC visibility.
	Public Visibility = "PUBLIC"
	// Protected is the PROTECTED visibility.
	Protected Visibility = "PROTECTED"
	// Private is the PRIVATE visibility.
	Private Visibility = "PRIVATE"
)

func (Visibility) String added in v0.2.0

func (v Visibility) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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