docs

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CollectionName         = "docs"
	VersionsCollectionName = "doc_versions"
	PinsCollectionName     = "doc_pins"
	FoldersCollectionName  = "doc_folders"

	// KindMarkdown documents use the BlockNote editing flow; KindHTML
	// documents hold a self-contained HTML artifact rendered in a sandboxed
	// preview. The kind is fixed at creation: content mutations validate
	// against the stored kind, never against caller input.
	KindMarkdown = "markdown"
	KindHTML     = "html"
)
View Source
const (
	AssetsCollectionName = "doc_assets"
)

Variables

View Source
var (
	ErrNotFound     = errors.New("document not found")
	ErrForbidden    = errors.New("document access denied")
	ErrConflict     = errors.New("document has a newer revision")
	ErrInvalidInput = errors.New("invalid document input")
	ErrPinLimit     = errors.New("you can pin at most 10 documents")
)

Functions

func Delete

func Delete(ctx context.Context, app core.App, actorID, id string) error

func Register

func Register(app core.App)

func SetPinned

func SetPinned(ctx context.Context, app core.App, actorID, id string, pinned bool) error

Types

type Asset added in v0.0.4

type Asset struct {
	ID        string `json:"id"`
	DocID     string `json:"docId"`
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	MediaType string `json:"mediaType"`
	Size      int64  `json:"size"`
	URL       string `json:"url"`
}

func UploadAsset added in v0.0.4

func UploadAsset(ctx context.Context, app core.App, actorID, docID string, file *filesystem.File) (Asset, error)

type CreateInput

type CreateInput struct {
	Title     string `json:"title"`
	Kind      string `json:"kind"`
	Content   string `json:"content"`
	ProjectID string `json:"projectId"`
	FolderID  string `json:"folderId"`
	Source    string `json:"-"`
}

type Document

type Document struct {
	ID           string `json:"id"`
	Title        string `json:"title"`
	Kind         string `json:"kind"`
	Content      string `json:"content"`
	OwnerID      string `json:"ownerId"`
	ProjectID    string `json:"projectId,omitempty"`
	ProjectName  string `json:"projectName,omitempty"`
	FolderID     string `json:"folderId,omitempty"`
	FolderName   string `json:"folderName,omitempty"`
	Status       string `json:"status"`
	Revision     int    `json:"revision"`
	LastEditedBy string `json:"lastEditedBy"`
	Created      string `json:"created"`
	Updated      string `json:"updated"`
}

func Create

func Create(ctx context.Context, app core.App, actorID string, input CreateInput) (Document, error)

func Get

func Get(ctx context.Context, app core.App, actorID, id string) (Document, error)

func Move added in v0.0.8

func Move(ctx context.Context, app core.App, actorID, id string, input MoveInput) (Document, error)

func MoveToProject

func MoveToProject(ctx context.Context, app core.App, actorID, id, projectID string) (Document, error)

func Replace

func Replace(ctx context.Context, app core.App, actorID, id string, input ReplaceInput) (Document, int, bool, error)

func Restore

func Restore(ctx context.Context, app core.App, actorID, id string, revision, baseRevision int) (Document, error)
func Search(ctx context.Context, app core.App, actorID string, options SearchOptions) ([]Document, error)

func SetArchived

func SetArchived(ctx context.Context, app core.App, actorID, id string, archived bool) (Document, error)

func Update

func Update(ctx context.Context, app core.App, actorID, id string, input UpdateInput) (Document, bool, error)

func WriteChunk added in v0.0.6

func WriteChunk(ctx context.Context, app core.App, actorID string, input WriteChunkInput) (Document, error)

WriteChunk writes long content in pieces, for callers (mainly AI tools) whose single-call output is limited. Mode "replace" starts a new chunked write: it bumps the revision and records one version. Mode "append" extends the same write: it keeps the revision and syncs that version's snapshot, so a whole chunked session leaves exactly one version entry. Both modes require the caller's baseRevision to match, and each call returns the revision to pass next.

type DocumentSummary added in v0.0.7

type DocumentSummary struct {
	ID           string `json:"id"`
	Title        string `json:"title"`
	Kind         string `json:"kind"`
	OwnerID      string `json:"ownerId"`
	ProjectID    string `json:"projectId,omitempty"`
	ProjectName  string `json:"projectName,omitempty"`
	FolderID     string `json:"folderId,omitempty"`
	FolderName   string `json:"folderName,omitempty"`
	Status       string `json:"status"`
	Revision     int    `json:"revision"`
	LastEditedBy string `json:"lastEditedBy"`
	Created      string `json:"created"`
	Updated      string `json:"updated"`
}

func ListPinned

func ListPinned(ctx context.Context, app core.App, actorID, query string) ([]DocumentSummary, error)

type Folder added in v0.0.8

type Folder struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	OwnerID string `json:"ownerId"`
	Created string `json:"created"`
	Updated string `json:"updated"`
}

func EnsureFolder added in v0.0.9

func EnsureFolder(ctx context.Context, app core.App, actorID, name string) (Folder, bool, error)

EnsureFolder resolves a personal folder by name, creating it only when no folder of that name exists. Matching is case-insensitive so "Reviews" and "reviews" cannot both exist.

The idempotent shape is deliberate: the assistant would otherwise have to list, compare, and then create, and a retried or repeated run would leave duplicate folders behind. Returns whether a folder was created so callers can report the difference.

func ListFolders added in v0.0.8

func ListFolders(ctx context.Context, app core.App, actorID string) ([]Folder, error)

type MoveInput added in v0.0.8

type MoveInput struct {
	Destination   string `json:"destination"`
	DestinationID string `json:"destinationId"`
}

type ReplaceInput

type ReplaceInput struct {
	ID           string `json:"id"`
	Find         string `json:"find"`
	Replace      string `json:"replace"`
	ReplaceAll   bool   `json:"replaceAll"`
	BaseRevision int    `json:"baseRevision"`
	Source       string `json:"-"`
}

type SearchOptions

type SearchOptions struct {
	Query     string
	Limit     int
	FolderID  string
	ProjectID string
	RootOnly  bool
}

type UpdateInput

type UpdateInput struct {
	Title        string `json:"title"`
	Content      string `json:"content"`
	BaseRevision int    `json:"baseRevision"`
	Source       string `json:"-"`
}

type Version

type Version struct {
	ID        string `json:"id"`
	Revision  int    `json:"revision"`
	Title     string `json:"title"`
	Content   string `json:"content,omitempty"`
	CreatedBy string `json:"createdBy"`
	Source    string `json:"source"`
	Created   string `json:"created"`
}

func GetVersion

func GetVersion(ctx context.Context, app core.App, actorID, id string, revision int) (Version, error)

func ListVersions

func ListVersions(ctx context.Context, app core.App, actorID, id string) ([]Version, error)

type WriteChunkInput added in v0.0.6

type WriteChunkInput struct {
	ID           string `json:"id"`
	Content      string `json:"content"`
	Mode         string `json:"mode"`
	BaseRevision int    `json:"baseRevision"`
	Source       string `json:"-"`
}

Jump to

Keyboard shortcuts

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