scratchpad

package
v1.30.1-0...-0373fe4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Scheme                 = "scratchpad"
	DefaultRootURITemplate = "mem://localhost/scratchpad/${userID}"
)

Variables

This section is empty.

Functions

func AppendNoteBody

func AppendNoteBody(existing, addition string) string

func ArtifactKey

func ArtifactKey(artifactID string) string

func ArtifactSourceURL

func ArtifactSourceURL(artifact Artifact) string

func ContextWithUserID

func ContextWithUserID(ctx context.Context, userID string) context.Context

func NoteURL

func NoteURL(root, key string) string

func ObjectForURL

func ObjectForURL(url string) storage.Object

func Provider

func Provider(options ...storage.Option) (storage.Manager, error)

func Register

func Register(opts ...Option)

func ResolveRootURI

func ResolveRootURI(template, userID, basePath string, macros map[string]string) (string, string, error)

func SanitizePathComponent

func SanitizePathComponent(value string) string

func UserIDFromContext

func UserIDFromContext(ctx context.Context) string

Types

type AppendInput

type AppendInput struct {
	Key         string `json:"key" description:"Exact scratchpad key to append to."`
	Body        string `json:"body" description:"Scratchpad note body to append."`
	Description string `` /* 148-byte string literal not displayed */
}

type AppendOutput

type AppendOutput struct {
	Key         string `json:"key,omitempty"`
	Description string `json:"description,omitempty"`
	UpdatedAt   string `json:"updatedAt,omitempty"`
	Created     bool   `json:"created,omitempty"`
	Status      string `json:"status,omitempty"`
	Error       string `json:"error,omitempty"`
}

type Artifact

type Artifact struct {
	Kind        string `json:"kind,omitempty"`
	ArtifactID  string `json:"artifactId,omitempty"`
	Name        string `json:"name,omitempty"`
	ContentType string `json:"contentType,omitempty"`
	SourceURL   string `json:"sourceURL"`
	ExpiresAt   string `json:"expiresAt,omitempty"`
}

type Config

type Config struct {
	FS                   afs.Service
	RootURITemplate      string
	UserID               string
	UserIDProvider       UserIDProvider
	BasePath             string
	Macros               map[string]string
	AllowedTargetSchemes []string
	Now                  func() time.Time
}

type Entry

type Entry struct {
	Key         string `json:"key"`
	Description string `json:"description"`
	UpdatedAt   string `json:"updatedAt,omitempty"`
}

type FetchInput

type FetchInput struct {
	Key string `json:"key" description:"Exact scratchpad key to fetch."`
}

type FetchOutput

type FetchOutput struct {
	Key         string `json:"key,omitempty"`
	Description string `json:"description,omitempty"`
	Body        string `json:"body,omitempty"`
	UpdatedAt   string `json:"updatedAt,omitempty"`
	Status      string `json:"status,omitempty"`
	Error       string `json:"error,omitempty"`
}

type ListInput

type ListInput struct{}

type ListOutput

type ListOutput struct {
	Entries []Entry `json:"entries"`
	Status  string  `json:"status,omitempty"`
	Error   string  `json:"error,omitempty"`
}

type MemorizeInput

type MemorizeInput struct {
	Key         string `json:"key" description:"Exact scratchpad key to create or replace."`
	Description string `json:"description" description:"Short description shown by list."`
	Body        string `json:"body" description:"Scratchpad note body."`
}

type MemorizeOutput

type MemorizeOutput struct {
	Key         string `json:"key,omitempty"`
	Description string `json:"description,omitempty"`
	UpdatedAt   string `json:"updatedAt,omitempty"`
	Status      string `json:"status,omitempty"`
	Error       string `json:"error,omitempty"`
}

type Note

type Note struct {
	Key         string `json:"key"`
	Description string `json:"description"`
	Body        string `json:"body"`
	UserID      string `json:"userId"`
	UpdatedAt   string `json:"updatedAt"`
}

type Option

type Option func(*Config)

func WithAFS

func WithAFS(fs afs.Service) Option

func WithAllowedTargetSchemes

func WithAllowedTargetSchemes(schemes ...string) Option

func WithBasePath

func WithBasePath(basePath string) Option

func WithConfig

func WithConfig(config Config) Option

func WithMacros

func WithMacros(macros map[string]string) Option

func WithNow

func WithNow(now func() time.Time) Option

func WithRootURI

func WithRootURI(template string) Option

func WithUserID

func WithUserID(userID string) Option

func WithUserIDProvider

func WithUserIDProvider(provider UserIDProvider) Option

type Service

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

func New

func New(opts ...Option) *Service

func (*Service) Append

func (s *Service) Append(ctx context.Context, input *AppendInput) (*AppendOutput, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, key string) error

func (*Service) Fetch

func (s *Service) Fetch(ctx context.Context, key string) (*FetchOutput, error)

func (*Service) FetchArtifact

func (s *Service) FetchArtifact(ctx context.Context, artifactID string) (*Artifact, error)

func (*Service) List

func (s *Service) List(ctx context.Context) (*ListOutput, error)

func (*Service) Memorize

func (s *Service) Memorize(ctx context.Context, input *MemorizeInput) (*MemorizeOutput, error)

func (*Service) OpenArtifact

func (s *Service) OpenArtifact(ctx context.Context, artifactID string) (*Artifact, io.ReadCloser, error)

func (*Service) ResolveRootURI

func (s *Service) ResolveRootURI() (string, string, error)

func (*Service) ResolveRootURIContext

func (s *Service) ResolveRootURIContext(ctx context.Context) (string, string, error)

type UserIDProvider

type UserIDProvider func(context.Context) string

Jump to

Keyboard shortcuts

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