Documentation
¶
Overview ¶
Package memos implements the Memos provider for note-taking and knowledge management. It wraps the Memos REST API (https://usememos.com) using personal access tokens.
Package memos implements the Memos provider for note-taking and knowledge management.
Index ¶
- Constants
- type Attachment
- type CreateMemoRequest
- type LinkMetadata
- type ListMemosParams
- type ListMemosResponse
- type Location
- type Memo
- type MemoProperty
- type MemoRelation
- type MemoRelationMemo
- type MemoShare
- type Memos
- func (v *Memos) CreateMemo(ctx context.Context, content, visibility string) (*Memo, error)
- func (v *Memos) DeleteMemo(ctx context.Context, name string) error
- func (v *Memos) GetCurrentUser(ctx context.Context) (*User, error)
- func (v *Memos) GetMemo(ctx context.Context, name string) (*Memo, error)
- func (v *Memos) ListMemos(ctx context.Context, params ListMemosParams) (*ListMemosResponse, error)
- func (v *Memos) ListRawEvents(ctx context.Context, cursor string) ([]map[string]any, string, error)
- func (v *Memos) UpdateMemo(ctx context.Context, name, content, visibility string, pinned *bool, ...) (*Memo, error)
- type Reaction
- type UpdateMemoRequest
- type User
- type WebhookPayload
Constants ¶
const ( // ID is the provider identifier used in configuration and registration. ID = "memos" // EndpointKey is the config key for the Memos instance base URL. EndpointKey = "endpoint" // TokenKey is the config key for the personal access token or access token. TokenKey = "token" )
const MaxPageSize = 100
MaxPageSize is the maximum number of items per page for list requests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Size int64 `json:"size,omitempty"`
CreateTime *time.Time `json:"createTime,omitempty"`
URL string `json:"url,omitempty"`
}
Attachment represents a file attachment on a memo.
type CreateMemoRequest ¶
CreateMemoRequest is the request body for creating a memo.
type LinkMetadata ¶
type LinkMetadata struct {
URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Image string `json:"image,omitempty"`
}
LinkMetadata holds metadata for a link extracted by the server.
type ListMemosParams ¶
type ListMemosParams struct {
// PageSize is the maximum number of memos to return (default 50, max 1000).
PageSize int32
// PageToken is the token for the next page of results.
PageToken string
// State filters memos by state ("NORMAL" or "ARCHIVED").
State string
// OrderBy specifies sort order (e.g., "create_time desc").
OrderBy string
// Filter is a CEL expression to filter memos.
Filter string
}
ListMemosParams holds optional query parameters for listing memos.
type ListMemosResponse ¶
type ListMemosResponse struct {
Memos []Memo `json:"memos,omitempty"`
NextPageToken string `json:"nextPageToken,omitempty"`
}
ListMemosResponse is the paginated response from ListMemos.
type Location ¶
type Location struct {
Placeholder string `json:"placeholder,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
}
Location holds geolocation data for a memo.
type Memo ¶
type Memo struct {
Name string `json:"name,omitempty"`
State string `json:"state,omitempty"`
Creator string `json:"creator,omitempty"`
CreateTime *time.Time `json:"createTime,omitempty"`
UpdateTime *time.Time `json:"updateTime,omitempty"`
Content string `json:"content,omitempty"`
Visibility string `json:"visibility,omitempty"`
Tags []string `json:"tags,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
Relations []MemoRelation `json:"relations,omitempty"`
Reactions []Reaction `json:"reactions,omitempty"`
Property *MemoProperty `json:"property,omitempty"`
Parent *string `json:"parent,omitempty"`
Snippet string `json:"snippet,omitempty"`
Location *Location `json:"location,omitempty"`
}
Memo represents a memo in the Memos API.
type MemoProperty ¶
type MemoProperty struct {
HasLink bool `json:"hasLink,omitempty"`
HasTaskList bool `json:"hasTaskList,omitempty"`
HasCode bool `json:"hasCode,omitempty"`
HasIncompleteTasks bool `json:"hasIncompleteTasks,omitempty"`
Title string `json:"title,omitempty"`
}
MemoProperty holds computed properties of a memo.
type MemoRelation ¶
type MemoRelation struct {
Memo *MemoRelationMemo `json:"memo,omitempty"`
RelatedMemo *MemoRelationMemo `json:"relatedMemo,omitempty"`
Type string `json:"type,omitempty"`
}
MemoRelation represents a relation between two memos.
type MemoRelationMemo ¶
type MemoRelationMemo struct {
Name string `json:"name,omitempty"`
Snippet string `json:"snippet,omitempty"`
}
MemoRelationMemo is a lightweight memo reference inside a relation.
type Memos ¶
type Memos struct {
// contains filtered or unexported fields
}
Memos wraps the Memos REST API client.
func GetClient ¶
func GetClient() *Memos
GetClient reads provider config and returns a new Memos client. It returns nil when the endpoint is not configured.
func NewMemos ¶
NewMemos creates a Memos client with the given endpoint and access token. If endpoint is empty, it returns nil.
func (*Memos) CreateMemo ¶
CreateMemo creates a new memo via POST /api/v1/memos.
func (*Memos) DeleteMemo ¶
DeleteMemo deletes a memo via DELETE /api/v1/{name}. name is the resource name (e.g., "memos/123").
func (*Memos) GetCurrentUser ¶
GetCurrentUser retrieves the currently authenticated user via GET /api/v1/auth/me.
func (*Memos) GetMemo ¶
GetMemo retrieves a memo by its resource name (e.g., "memos/123") via GET /api/v1/{name}.
func (*Memos) ListMemos ¶
func (v *Memos) ListMemos(ctx context.Context, params ListMemosParams) (*ListMemosResponse, error)
ListMemos lists memos with pagination and filters via GET /api/v1/memos.
func (*Memos) ListRawEvents ¶
ListRawEvents lists memos as raw events for polling support. The cursor is used as the page token for pagination.
func (*Memos) UpdateMemo ¶
func (v *Memos) UpdateMemo(ctx context.Context, name, content, visibility string, pinned *bool, fields []string) (*Memo, error)
UpdateMemo updates a memo via PATCH /api/v1/{memo.name}. name is the resource name (e.g., "memos/123"). fields lists the field mask paths to update (e.g., ["content", "visibility"]).
type Reaction ¶
type Reaction struct {
Name string `json:"name,omitempty"`
Creator string `json:"creator,omitempty"`
ContentID string `json:"contentId,omitempty"`
ReactionType string `json:"reactionType,omitempty"`
CreateTime *time.Time `json:"createTime,omitempty"`
}
Reaction represents a reaction on a memo.
type UpdateMemoRequest ¶
type UpdateMemoRequest struct {
Memo Memo `json:"memo"`
UpdateMask []string `json:"updateMask,omitempty"`
}
UpdateMemoRequest is the request body for updating a memo.
type User ¶
type User struct {
Name string `json:"name,omitempty"`
Role string `json:"role,omitempty"`
Username string `json:"username,omitempty"`
Email string `json:"email,omitempty"`
DisplayName string `json:"displayName,omitempty"`
AvatarURL string `json:"avatarUrl,omitempty"`
Description string `json:"description,omitempty"`
State string `json:"state,omitempty"`
CreateTime *time.Time `json:"createTime,omitempty"`
UpdateTime *time.Time `json:"updateTime,omitempty"`
}
User represents a user in the Memos API.
type WebhookPayload ¶
type WebhookPayload struct {
URL string `json:"url"`
ActivityType string `json:"activityType"`
Creator string `json:"creator"`
Memo Memo `json:"memo"`
}
WebhookPayload is the request body sent by the Memos server to configured webhook URLs. The server sends a JSON POST with the activity type, creator, and full memo object.