Documentation
¶
Overview ¶
Package sdk defines the contract between the Gophenberg core and its plugins. It is the only Gophenberg package a plugin may import.
Index ¶
- func WithSession(ctx context.Context, session Session) context.Context
- type ContentReader
- type Deps
- type FieldDeclaration
- type GroupDeclaration
- type Item
- type Migrator
- type Plugin
- type PublicPathProvider
- type RouteProvider
- type Rule
- type Session
- type TypeDeclaration
- type TypeDeclarer
- type TypeRegistrar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContentReader ¶ added in v0.4.0
type ContentReader interface {
ListPublished(ctx context.Context, contentType string, limit int) ([]Item, error)
}
ContentReader gives plugins read access to published content.
type Deps ¶
type Deps struct {
DatabaseURL string
Content ContentReader
Getenv func(string) string
}
Deps carries the host-provided dependencies a plugin's Register function receives at registration.
type FieldDeclaration ¶ added in v0.11.0
type FieldDeclaration struct {
Key string
Label string
Kind string
RelatesTo string
Many bool
Required bool
Listed bool
Conditions [][]Rule
Settings map[string]any
Fields []FieldDeclaration
}
FieldDeclaration is a field as a plugin declares it, holding the fields a container declares inside.
type GroupDeclaration ¶ added in v0.11.0
type GroupDeclaration struct {
Key string
Title string
Location [][]Rule
Fields []FieldDeclaration
}
GroupDeclaration is a field group as a plugin declares it, with the fields it holds.
type Item ¶ added in v0.4.0
type Item struct {
ID uuid.UUID
Type string
Path string
Slug string
Title string
Excerpt string
Content string
Fields map[string]any
PublishedAt time.Time
UpdatedAt time.Time
}
Item is a published content item as plugins see it: the Content field holds Gutenberg-serialized block HTML, sanitized for public delivery.
type Migrator ¶
Migrator is implemented by plugins that own database schema, which the host migrates before starting any plugin.
type PublicPathProvider ¶
type PublicPathProvider = pluginkit.PublicPathProvider
PublicPathProvider is implemented by plugins declaring session-exempt public paths.
type RouteProvider ¶
type RouteProvider = pluginkit.RouteProvider
RouteProvider is implemented by plugins that expose HTTP endpoints under their own namespace.
type Session ¶ added in v0.7.0
type Session struct {
ID uuid.UUID
Email string
Name string
Role string
// contains filtered or unexported fields
}
Session is the account a request is made by, as a plugin reads it.
func NewSession ¶ added in v0.7.0
NewSession returns the session a host files for a request.
func SessionFrom ¶ added in v0.7.0
SessionFrom returns the session a request was made by, reporting whether one was filed.
type TypeDeclaration ¶ added in v0.11.0
type TypeDeclaration struct {
Key string
SingularLabel string
PluralLabel string
RouteWord string
Hierarchical bool
Revisions bool
RevisionCap int
PageKind string
}
TypeDeclaration is a content type as a plugin declares it.
type TypeDeclarer ¶ added in v0.11.0
type TypeDeclarer interface {
DeclareTypes(ctx context.Context, types TypeRegistrar) error
}
TypeDeclarer is implemented by plugins that declare content types, groups or fields.
type TypeRegistrar ¶ added in v0.11.0
type TypeRegistrar interface {
DeclareType(ctx context.Context, declared TypeDeclaration) error
DeclareGroup(ctx context.Context, declared GroupDeclaration) error
DeclareField(ctx context.Context, groupKey string, declared FieldDeclaration) error
}
TypeRegistrar takes the definitions a plugin declares, once per boot.