docs

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDocNotFound      = errors.New("doc not found")
	ErrDocAlreadyExists = errors.New("doc already exists")
	ErrDocPathConflict  = errors.New("doc path conflicts with another node")
	ErrInvalidDocID     = errors.New("invalid doc ID")
)

Sentinel errors for doc store operations.

Functions

func ValidateDocID

func ValidateDocID(id string) error

ValidateDocID validates that id is a safe, well-formed doc identifier.

Types

type DeleteError

type DeleteError struct {
	ID    string
	Error string
}

DeleteError represents a single item failure in a batch delete operation.

type Doc

type Doc struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Content     string `json:"content"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`
}

Doc is the domain entity for a markdown document.

type DocMetadata

type DocMetadata struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	ModTime     time.Time `json:"modTime"`
}

DocMetadata is a lightweight doc view excluding Content.

type DocSearchResult

type DocSearchResult struct {
	ID                string        `json:"id"`
	Title             string        `json:"title"`
	Description       string        `json:"description,omitempty"`
	ModTime           time.Time     `json:"modTime"`
	Matches           []*exec.Match `json:"matches"`
	HasMoreMatches    bool          `json:"hasMoreMatches"`
	NextMatchesCursor string        `json:"nextMatchesCursor,omitempty"`
}

DocSearchResult holds a doc ID/title and its grep matches.

type DocSortField

type DocSortField string

DocSortField defines the field to sort documents by.

const (
	DocSortFieldName  DocSortField = "name"
	DocSortFieldType  DocSortField = "type"
	DocSortFieldMTime DocSortField = "mtime"
)

type DocSortOrder

type DocSortOrder string

DocSortOrder defines the sort direction.

const (
	DocSortOrderAsc  DocSortOrder = "asc"
	DocSortOrderDesc DocSortOrder = "desc"
)

type DocStore

type DocStore interface {
	List(ctx context.Context, opts ListDocsOptions) (*exec.PaginatedResult[*DocTreeNode], error)
	ListFlat(ctx context.Context, opts ListDocsOptions) (*exec.PaginatedResult[DocMetadata], error)
	Get(ctx context.Context, id string) (*Doc, error)
	Create(ctx context.Context, id, content string) error
	Update(ctx context.Context, id, content string) error
	Delete(ctx context.Context, id string) error
	DeleteBatch(ctx context.Context, ids []string) (deleted []string, failed []DeleteError, err error)
	Rename(ctx context.Context, oldID, newID string) error
	Search(ctx context.Context, query string) ([]*DocSearchResult, error)
	SearchCursor(ctx context.Context, opts SearchDocsOptions) (*exec.CursorResult[DocSearchResult], error)
	SearchMatches(ctx context.Context, id string, opts SearchDocMatchesOptions) (*exec.CursorResult[*exec.Match], error)
}

DocStore defines the interface for doc persistence.

type DocTreeNode

type DocTreeNode struct {
	ID       string         `json:"id"`
	Name     string         `json:"name"`
	Title    string         `json:"title,omitempty"`
	Type     string         `json:"type"` // "file" or "directory"
	Children []*DocTreeNode `json:"children,omitempty"`
	ModTime  time.Time      `json:"modTime"`
}

DocTreeNode represents a file or directory in the doc tree.

type ListDocsOptions

type ListDocsOptions struct {
	Page             int
	PerPage          int
	Sort             DocSortField
	Order            DocSortOrder
	PathPrefix       string
	ExcludePathRoots []string
}

ListDocsOptions holds parameters for listing documents.

type SearchDocMatchesOptions

type SearchDocMatchesOptions struct {
	Cursor     string
	Limit      int
	Query      string
	PathPrefix string
}

SearchDocMatchesOptions configures cursor-based snippet loading for one document.

type SearchDocsOptions

type SearchDocsOptions struct {
	Cursor           string
	Limit            int
	Query            string
	MatchLimit       int
	PathPrefix       string
	FilterPrefix     string
	ExcludePathRoots []string
}

SearchDocsOptions configures a paginated document search query.

Jump to

Keyboard shortcuts

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