Documentation
¶
Index ¶
- Constants
- Variables
- func Delete(ctx context.Context, app core.App, actorID, id string) error
- func PublicAsset(ctx context.Context, app core.App, slug, assetID string) (*core.Record, error)
- func Register(app core.App)
- func SetPinned(ctx context.Context, app core.App, actorID, id string, pinned bool) error
- func Unpublish(ctx context.Context, app core.App, actorID, id string) error
- type Asset
- type CreateInput
- type Document
- func Create(ctx context.Context, app core.App, actorID string, input CreateInput) (Document, error)
- func Get(ctx context.Context, app core.App, actorID, id string) (Document, error)
- func Move(ctx context.Context, app core.App, actorID, id string, input MoveInput) (Document, error)
- func MoveToProject(ctx context.Context, app core.App, actorID, id, projectID string) (Document, error)
- func Replace(ctx context.Context, app core.App, actorID, id string, input ReplaceInput) (Document, int, bool, error)
- func Restore(ctx context.Context, app core.App, actorID, id string, ...) (Document, error)
- func Search(ctx context.Context, app core.App, actorID string, options SearchOptions) ([]Document, error)
- func SetArchived(ctx context.Context, app core.App, actorID, id string, archived bool) (Document, error)
- func Update(ctx context.Context, app core.App, actorID, id string, input UpdateInput) (Document, bool, error)
- func WriteChunk(ctx context.Context, app core.App, actorID string, input WriteChunkInput) (Document, error)
- type DocumentSummary
- type Folder
- type MoveInput
- type PublicDocument
- type ReplaceInput
- type SearchOptions
- type Share
- type ShareInput
- type UpdateInput
- type Version
- type WriteChunkInput
Constants ¶
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" )
const (
AssetsCollectionName = "doc_assets"
)
const (
)
Variables ¶
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") )
ErrShareNotFound covers every reason a public link cannot be served: unknown slug, expired share, archived or deleted document, attachment outside the published snapshot. Public responses must not tell these apart.
Functions ¶
func PublicAsset ¶ added in v0.1.0
PublicAsset resolves an attachment referenced by a published snapshot. The content check keeps attachments uploaded after publishing out of the public link, the same way the pinned revision keeps later edits out.
Types ¶
type Asset ¶ added in v0.0.4
type CreateInput ¶
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 MoveToProject ¶
func SetArchived ¶
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 ¶
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
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.
type PublicDocument ¶ added in v0.1.0
type PublicDocument struct {
Title string `json:"title"`
Kind string `json:"kind"`
Content string `json:"content"`
Revision int `json:"revision"`
Published string `json:"published"`
}
PublicDocument is everything an anonymous reader receives. Owner, project, folder, and editor identities stay out of it.
type ReplaceInput ¶
type SearchOptions ¶
type Share ¶ added in v0.1.0
type Share struct {
}
func GetShare ¶ added in v0.1.0
GetShare reports the current share of a document, or ErrShareNotFound when it is not shared.
func Publish ¶ added in v0.1.0
func Publish(ctx context.Context, app core.App, actorID, id string, input ShareInput) (Share, error)
Publish exposes the document's current revision under a public slug, and on an existing share updates its expiry and, when asked, its published revision. Only the owner can publish, matching archive and delete.
type ShareInput ¶ added in v0.1.0
type ShareInput struct {
// Without it, changing the expiry of a share leaves the published
// snapshot where it is, so adjusting a date can never leak an unfinished
// draft.
Republish bool `json:"republish"`
}