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: 10 Imported by: 0

Documentation

Overview

Package memos implements the Memos adapter for the memo capability.

Index

Constants

View Source
const (
	OpList   = "list"
	OpGet    = "get"
	OpCreate = "create"
	OpUpdate = "update"
	OpDelete = "delete"
	OpHealth = "health"
)

Variables

This section is empty.

Functions

func Register

func Register(app string, svc Service) error

Register registers the memos capability with hub and invoker registry. When svc is nil the provider is not configured and registration is skipped.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements Service using the Memos provider client.

func (*Adapter) Create

func (a *Adapter) Create(ctx context.Context, content, visibility string) (*capability.Memo, error)

Create creates a new memo with the given content and visibility.

func (*Adapter) Delete

func (a *Adapter) Delete(ctx context.Context, name string) error

Delete removes a memo by its resource name.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, name string) (*capability.Memo, error)

Get returns a single memo by its resource name.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)

HealthCheck reports whether the memo backend is reachable by querying the current user endpoint.

func (*Adapter) List

List returns a paginated list of memos.

func (*Adapter) ListRawEvents

func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)

ListRawEvents lists memos as raw events for polling support.

func (*Adapter) Update

func (a *Adapter) Update(ctx context.Context, name string, data map[string]any) (*capability.Memo, error)

Update updates a memo's fields identified by the data map. Supported keys: content, visibility, pinned.

type ListQuery

type ListQuery = capability.MemoListQuery

ListQuery wraps pagination for listing memos.

type Service

type Service interface {
	List(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.Memo], error)
	Get(ctx context.Context, name string) (*capability.Memo, error)
	Create(ctx context.Context, content, visibility string) (*capability.Memo, error)
	Update(ctx context.Context, name string, data map[string]any) (*capability.Memo, error)
	Delete(ctx context.Context, name string) error
	HealthCheck(ctx context.Context) (bool, error)
	ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}

Service defines the memo capability contract.

func New

func New() Service

New creates an Adapter using the default provider client (reads config from YAML). Returns nil when the provider is not configured.

func NewWithClient

func NewWithClient(c client) Service

NewWithClient creates an Adapter with a specific client, useful for testing.

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

Webhook implements capability.WebhookConverter for Memos. It validates a shared token (vendors.memos.webhook_token) from the URL query parameter. Memos can only attach credentials via the webhook URL, so configure the endpoint as /webhook/provider/memos/events?token=<token>.

func NewWebhook

func NewWebhook() *Webhook

NewWebhook creates a Webhook that reads the webhook token from provider config lazily at verification time.

func (*Webhook) Convert

func (*Webhook) Convert(body []byte, _ map[string]string) ([]types.DataEvent, error)

Convert transforms the raw Memos webhook body into DataEvent records.

func (*Webhook) VerifySignature

func (w *Webhook) VerifySignature(headers map[string]string, _ []byte) error

VerifySignature validates the webhook token from the query parameter. Memos passes the token as a URL query string parameter ?token=TOKEN. The eventsource webhook handler injects query params as X-Query-* headers. An empty webhook_token config rejects all deliveries (same as other providers).

func (*Webhook) WebhookPath

func (*Webhook) WebhookPath() string

WebhookPath returns the URL path segment for Memos webhooks. The full URL is /webhook/provider/memos/events?token=TOKEN.

Jump to

Keyboard shortcuts

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