pluginsdk/content/content.go
Alex Dunmow b6d40ed8ac feat: bootstrap block/pluginsdk — the proto-first plugin SDK (P1)
Bootstrap the plugin-facing SDK module so the fleet migration (P2) becomes a
mechanical block/core/X -> block/pluginsdk/X import rewrite.

- abi/proto/v1: the single source-of-truth ABI proto tree, copied from the cms
  authoring source (cms/backend/abi/proto/v1) with go_package retargeted to
  git.dev.alexdunmow.com/block/pluginsdk/abi/v1;abiv1. Kills the hand-kept
  cms/core proto duplication (audit gap 4).
- abi/v1: generated Go bindings (buf generate); byte-identical to core's abi/v1
  save the embedded go_package path.
- plugin/ (registration + DI surface), plugin/wasmguest/** (transport shim,
  caps stubs, bnwasm db driver, testdata fixtures + golden .pb), and the
  guest-facing type packages: blocks (+builtin/shared/tags), templates
  (+pongo/bn), auth, settings, content, gating, crypto, rbac, video, ai,
  subscriptions, menus, datasources. Internal imports rewritten core ->
  pluginsdk; zero block/core references remain.
- README/AGENTS(+CLAUDE symlink)/Makefile: proto is the contract, Go is one
  binding; no replace directives; templates/bn is a synced copy authored in cms.

Spec: cms docs/superpowers/specs/2026-07-07-proto-first-plugin-sdk-design.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 10:51:00 +08:00

69 lines
2.3 KiB
Go

package content
import (
"context"
"time"
"github.com/google/uuid"
)
// AuthorProfile is a simplified author representation for plugins.
type AuthorProfile struct {
ID uuid.UUID
Name string
Slug string
Bio string
AvatarURL string
Website string
SocialLinks map[string]string
}
// PageInfo is a simplified page representation for plugins.
type PageInfo struct {
ID uuid.UUID
Slug string
Title string
}
// PostInfo is a simplified post representation for plugins. It carries enough
// for both a blog index (title/slug/excerpt/author/date/featured image) and a
// post detail view (Body — the rendered HTML). Body is populated by GetPost and
// by ListPosts when ListPostsParams.IncludeBody is set; it is empty otherwise.
type PostInfo struct {
ID uuid.UUID
Slug string
Title string
Excerpt string
Body string // rendered HTML; populated by GetPost / ListPosts(IncludeBody)
FeaturedImageURL string
AuthorID uuid.UUID
AuthorName string
AuthorSlug string
PublishedAt time.Time
}
// ListPostsParams filters and shapes a ListPosts query. The zero value lists
// published posts from the start with no category filter, excerpts included and
// bodies omitted (the cheap blog-index shape).
type ListPostsParams struct {
Limit int // 0 = host default
Offset int // pagination offset
Category string // optional category slug filter ("" = all)
PublishedOnly bool // reserved: plugins only ever see published posts
IncludeBody bool // render each post's body to HTML (expensive)
IncludeExcerpt bool // include the post excerpt
}
// Content provides content access for plugins.
// The CMS implements this interface and wires it into CoreServices.
type Content interface {
GetAuthorProfile(ctx context.Context, id uuid.UUID) (*AuthorProfile, error)
GetPage(ctx context.Context, slug string) (*PageInfo, error)
GetPost(ctx context.Context, slug string) (*PostInfo, error)
ListPosts(ctx context.Context, params ListPostsParams) ([]PostInfo, error)
Slugify(text string) string
BlockNoteToHTML(ctx context.Context, doc map[string]any) string
GenerateExcerpt(html string, maxLen int) string
StripHTML(s string) string
}