Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
ValidateDocID validates that id is a safe, well-formed doc identifier.
Types ¶
type DeleteError ¶
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 ¶
SearchDocMatchesOptions configures cursor-based snippet loading for one document.