memos

package
v0.97.8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

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

View Source
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"
	// WebhookTokenKey is the config key for the inbound webhook query token.
	WebhookTokenKey = "webhook_token"
)
View Source
const MaxPageSize = 100

MaxPageSize is the maximum number of items per page for list requests.

Variables

This section is empty.

Functions

func GetWebhookToken added in v0.97.8

func GetWebhookToken() string

GetWebhookToken reads the webhook query token from the memos provider config.

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

type CreateMemoRequest struct {
	Memo   Memo   `json:"memo"`
	MemoID string `json:"memoId,omitempty"`
}

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.

func (*Memo) UnmarshalJSON added in v0.97.8

func (m *Memo) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both REST (protojson string enums) and webhook (encoding/json numeric enums) payloads from Memos.

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 MemoShare

type MemoShare struct {
	Name       string     `json:"name,omitempty"`
	CreateTime *time.Time `json:"createTime,omitempty"`
	ExpireTime *time.Time `json:"expireTime,omitempty"`
}

MemoShare represents a share link for a memo.

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

func NewMemos(endpoint, token string) *Memos

NewMemos creates a Memos client with the given endpoint and access token. If endpoint is empty, it returns nil.

func (*Memos) CreateMemo

func (v *Memos) CreateMemo(ctx context.Context, content, visibility string) (*Memo, error)

CreateMemo creates a new memo via POST /api/v1/memos.

func (*Memos) DeleteMemo

func (v *Memos) DeleteMemo(ctx context.Context, name string) error

DeleteMemo deletes a memo via DELETE /api/v1/{name}. name is the resource name (e.g., "memos/123").

func (*Memos) GetCurrentUser

func (v *Memos) GetCurrentUser(ctx context.Context) (*User, error)

GetCurrentUser retrieves the currently authenticated user via GET /api/v1/auth/me.

func (*Memos) GetMemo

func (v *Memos) GetMemo(ctx context.Context, name string) (*Memo, error)

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

func (v *Memos) ListRawEvents(ctx context.Context, cursor string) ([]map[string]any, string, error)

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.

Jump to

Keyboard shortcuts

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