Documentation
¶
Index ¶
- Constants
- Variables
- func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) echo.HandlerFunc
- func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resource, r io.Reader) error
- type APIV1Service
- type Activity
- type ActivityCreate
- type ActivityLevel
- type ActivityMemoCreatePayload
- type ActivityResourceCreatePayload
- type ActivityServerStartPayload
- type ActivityShortcutCreatePayload
- type ActivityTagCreatePayload
- type ActivityType
- type ActivityUserAuthSignInPayload
- type ActivityUserAuthSignUpPayload
- type ActivityUserCreatePayload
- type Claims
- type CreateIdentityProviderRequest
- type CreateMemoRequest
- type CreateResourceRequest
- type CreateShortcutRequest
- type CreateStorageRequest
- type CreateUserRequest
- type CustomizedProfile
- type DeleteTagRequest
- type FieldMapping
- type FindMemoRequest
- type FindResourceRequest
- type IdentityProvider
- type IdentityProviderConfig
- type IdentityProviderOAuth2Config
- type IdentityProviderType
- type Memo
- type MemoOrganizer
- type MemoRelation
- type MemoRelationType
- type MemoResource
- type MemoResourceDelete
- type MemoResourceFind
- type OpenAIConfig
- type PatchMemoRequest
- type Resource
- type Role
- type RowStatus
- type SSOSignIn
- type Shortcut
- type ShortcutDelete
- type ShortcutFind
- type SignIn
- type SignUp
- type Storage
- type StorageConfig
- type StorageS3Config
- type StorageType
- type SystemSetting
- type SystemSettingName
- type SystemStatus
- type Tag
- type UpdateIdentityProviderRequest
- type UpdateResourceRequest
- type UpdateShortcutRequest
- type UpdateStorageRequest
- type UpdateUserRequest
- type UpsertMemoOrganizerRequest
- type UpsertMemoRelationRequest
- type UpsertMemoResourceRequest
- type UpsertSystemSettingRequest
- type UpsertTagRequest
- type UpsertUserSettingRequest
- type User
- type UserSetting
- type UserSettingKey
- type Visibility
Constants ¶
const ( // LocalStorage means the storage service is local file system. LocalStorage = -1 // DatabaseStorage means the storage service is database. DatabaseStorage = 0 )
const (
MebiByte = 1024 * 1024
)
const UnknownID = -1
UnknownID is the ID for unknowns.
Variables ¶
var ( UserSettingLocaleValue = []string{ "de", "en", "es", "fr", "hi", "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 ¶
func JWTMiddleware ¶
func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) echo.HandlerFunc
JWTMiddleware validates the access token. If the access token is about to expire or has expired and the request has a valid refresh token, it will try to generate new access token and refresh token.
func SaveResourceBlob ¶ added in v0.14.0
func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resource, r io.Reader) error
SaveResourceBlob save the blob of resource based on the storage config
Depend on the storage config, some fields of *store.ResourceCreate will be changed: 1. *DatabaseStorage*: `create.Blob`. 2. *LocalStorage*: `create.InternalPath`. 3. Others( external service): `create.ExternalLink`.
Types ¶
type APIV1Service ¶
func NewAPIV1Service ¶
func (*APIV1Service) Register ¶
func (s *APIV1Service) Register(rootGroup *echo.Group)
type Activity ¶
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 ¶
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 ¶
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" )
func (ActivityLevel) String ¶ added in v0.14.0
func (l ActivityLevel) String() string
type ActivityTagCreatePayload ¶
type ActivityTagCreatePayload struct {
TagName string `json:"tagName"`
}
type ActivityType ¶
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" )
func (ActivityType) String ¶ added in v0.14.0
func (t ActivityType) String() string
type Claims ¶
type Claims struct {
Name string `json:"name"`
jwt.RegisteredClaims
}
Claims creates a struct that will be encoded to a JWT. We add jwt.RegisteredClaims as an embedded type, to provide fields such as name.
type CreateIdentityProviderRequest ¶
type CreateIdentityProviderRequest struct {
Name string `json:"name"`
Type IdentityProviderType `json:"type"`
IdentifierFilter string `json:"identifierFilter"`
Config *IdentityProviderConfig `json:"config"`
}
type CreateMemoRequest ¶ added in v0.14.0
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 []*UpsertMemoRelationRequest `json:"relationList"`
}
type CreateResourceRequest ¶ added in v0.14.0
type CreateShortcutRequest ¶ added in v0.14.0
type CreateStorageRequest ¶ added in v0.14.0
type CreateStorageRequest struct {
Name string `json:"name"`
Type StorageType `json:"type"`
Config *StorageConfig `json:"config"`
}
type CreateUserRequest ¶ added in v0.14.0
type CreateUserRequest struct {
Username string `json:"username"`
Role Role `json:"role"`
Email string `json:"email"`
Nickname string `json:"nickname"`
Password string `json:"password"`
}
func (CreateUserRequest) Validate ¶ added in v0.14.0
func (create CreateUserRequest) Validate() error
type CustomizedProfile ¶
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 DeleteTagRequest ¶ added in v0.14.0
type DeleteTagRequest struct {
Name string `json:"name"`
}
type FieldMapping ¶
type FindMemoRequest ¶ added in v0.14.0
type FindResourceRequest ¶ added in v0.14.0
type IdentityProvider ¶
type IdentityProvider struct {
ID int `json:"id"`
Name string `json:"name"`
Type IdentityProviderType `json:"type"`
IdentifierFilter string `json:"identifierFilter"`
Config *IdentityProviderConfig `json:"config"`
}
type IdentityProviderConfig ¶
type IdentityProviderConfig struct {
OAuth2Config *IdentityProviderOAuth2Config `json:"oauth2Config"`
}
type IdentityProviderOAuth2Config ¶
type IdentityProviderOAuth2Config struct {
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret"`
AuthURL string `json:"authUrl"`
TokenURL string `json:"tokenUrl"`
UserInfoURL string `json:"userInfoUrl"`
Scopes []string `json:"scopes"`
FieldMapping *FieldMapping `json:"fieldMapping"`
}
type IdentityProviderType ¶
type IdentityProviderType string
const (
IdentityProviderOAuth2Type IdentityProviderType = "OAUTH2"
)
func (IdentityProviderType) String ¶ added in v0.14.0
func (t IdentityProviderType) String() string
type Memo ¶ added in v0.14.0
type Memo 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"`
CreatorUsername string `json:"creatorUsername"`
ResourceList []*Resource `json:"resourceList"`
RelationList []*MemoRelation `json:"relationList"`
}
type MemoOrganizer ¶ added in v0.14.0
type MemoRelation ¶ added in v0.14.0
type MemoRelation struct {
MemoID int `json:"memoId"`
RelatedMemoID int `json:"relatedMemoId"`
Type MemoRelationType `json:"type"`
}
type MemoRelationType ¶ added in v0.14.0
type MemoRelationType string
const ( MemoRelationReference MemoRelationType = "REFERENCE" MemoRelationAdditional MemoRelationType = "ADDITIONAL" )
type MemoResource ¶ added in v0.14.0
type MemoResourceDelete ¶ added in v0.14.0
type MemoResourceFind ¶ added in v0.14.0
type OpenAIConfig ¶
type PatchMemoRequest ¶ added in v0.14.0
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 []*UpsertMemoRelationRequest `json:"relationList"`
}
type Resource ¶ added in v0.14.0
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"`
// Related fields
LinkedMemoAmount int `json:"linkedMemoAmount"`
}
type ShortcutDelete ¶ added in v0.14.0
type ShortcutFind ¶ added in v0.14.0
type Storage ¶ added in v0.14.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.14.0
type StorageConfig struct {
S3Config *StorageS3Config `json:"s3Config"`
}
type StorageS3Config ¶ added in v0.14.0
type StorageType ¶ added in v0.14.0
type StorageType string
const (
StorageS3 StorageType = "S3"
)
func (StorageType) String ¶ added in v0.14.0
func (t StorageType) String() string
type SystemSetting ¶
type SystemSetting struct {
Name SystemSettingName `json:"name"`
// Value is a JSON string with basic value.
Value string `json:"value"`
Description string `json:"description"`
}
type SystemSettingName ¶
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" // SystemSettingTelegramBotToken is the name of Telegram Bot Token. SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token" // SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts. SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts" // SystemSettingOpenAIConfigName is the name of OpenAI config. SystemSettingOpenAIConfigName SystemSettingName = "openai-config" // SystemSettingAutoBackupIntervalName is the name of auto backup interval as seconds. SystemSettingAutoBackupIntervalName SystemSettingName = "auto-backup-interval" )
func (SystemSettingName) String ¶
func (key SystemSettingName) String() string
type SystemStatus ¶ added in v0.14.0
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"`
// Auto Backup Interval.
AutoBackupInterval int `json:"autoBackupInterval"`
// 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 UpdateIdentityProviderRequest ¶
type UpdateIdentityProviderRequest struct {
ID int `json:"-"`
Type IdentityProviderType `json:"type"`
Name *string `json:"name"`
IdentifierFilter *string `json:"identifierFilter"`
Config *IdentityProviderConfig `json:"config"`
}
type UpdateResourceRequest ¶ added in v0.14.0
type UpdateResourceRequest struct {
Filename *string `json:"filename"`
}
type UpdateShortcutRequest ¶ added in v0.14.0
type UpdateStorageRequest ¶ added in v0.14.0
type UpdateStorageRequest struct {
Type StorageType `json:"type"`
Name *string `json:"name"`
Config *StorageConfig `json:"config"`
}
type UpdateUserRequest ¶ added in v0.14.0
type UpdateUserRequest struct {
RowStatus *RowStatus `json:"rowStatus"`
Username *string `json:"username"`
Email *string `json:"email"`
Nickname *string `json:"nickname"`
Password *string `json:"password"`
ResetOpenID *bool `json:"resetOpenId"`
AvatarURL *string `json:"avatarUrl"`
}
func (UpdateUserRequest) Validate ¶ added in v0.14.0
func (update UpdateUserRequest) Validate() error
type UpsertMemoOrganizerRequest ¶ added in v0.14.0
type UpsertMemoOrganizerRequest struct {
Pinned bool `json:"pinned"`
}
type UpsertMemoRelationRequest ¶ added in v0.14.0
type UpsertMemoRelationRequest struct {
RelatedMemoID int `json:"relatedMemoId"`
Type MemoRelationType `json:"type"`
}
type UpsertMemoResourceRequest ¶ added in v0.14.0
type UpsertSystemSettingRequest ¶ added in v0.14.0
type UpsertSystemSettingRequest struct {
Name SystemSettingName `json:"name"`
Value string `json:"value"`
Description string `json:"description"`
}
func (UpsertSystemSettingRequest) Validate ¶ added in v0.14.0
func (upsert UpsertSystemSettingRequest) Validate() error
type UpsertTagRequest ¶ added in v0.14.0
type UpsertTagRequest struct {
Name string `json:"name"`
}
type UpsertUserSettingRequest ¶ added in v0.14.0
type UpsertUserSettingRequest struct {
UserID int `json:"-"`
Key UserSettingKey `json:"key"`
Value string `json:"value"`
}
func (UpsertUserSettingRequest) Validate ¶ added in v0.14.0
func (upsert UpsertUserSettingRequest) Validate() error
type User ¶ added in v0.14.0
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 UserSetting ¶
type UserSetting struct {
UserID int `json:"userId"`
Key UserSettingKey `json:"key"`
Value string `json:"value"`
}
type UserSettingKey ¶
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 ¶
func (key UserSettingKey) String() string
String returns the string format of UserSettingKey type.
type Visibility ¶
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 ¶
func (v Visibility) String() string