feat(04-01): scaffold Winter-shaped plugins with generated registry

Render plugin.go, routes.go, leaf packages and go.mod from embedded
templates, emit empty registry accessors, and define job, admin, lang
and mail capability contracts so a new plugin compiles before artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-18 13:34:32 +02:00
parent 846e6d5b74
commit 1edf9d7e4c
6 changed files with 552 additions and 63 deletions

View File

@@ -1,6 +1,7 @@
package pact
import (
"context"
"io/fs"
"net/http"
@@ -53,6 +54,53 @@ type HasModels interface {
Models() []any
}
// JobArgs is the typed payload a job worker receives. Kind identifies the
// job so a worker can reject unexpected argument types.
type JobArgs interface {
Kind() string
}
// Job is a unit of background work. Phase 11 adapts this onto River; the
// interface itself must not import River.
type Job interface {
Work(ctx context.Context, args JobArgs) error
}
// HasJobs is implemented by plugins that register background jobs.
type HasJobs interface {
Jobs() []Job
}
// AdminController is the compile-time admin controller contract. Phase 9
// grows the schema pipeline; ID, model name and YAML config directory are
// enough for generated stubs to compile.
type AdminController interface {
ID() string
ModelName() string
ConfigDir() string
}
// HasAdminControllers is implemented by plugins that register admin controllers.
type HasAdminControllers interface {
AdminControllers() []AdminController
}
// HasLang is implemented by plugins that ship embedded translation YAML
// under lang/<locale>/<group>.yaml.
type HasLang interface {
LangFS() fs.FS
}
// HasMailTemplates is implemented by plugins that ship Winter-shaped mail
// templates and layout aliases. MailTemplatesFS contains views/mail assets;
// MailTemplates lists dotted template names; MailLayouts maps a short layout
// name to the full dotted layout name.
type HasMailTemplates interface {
MailTemplatesFS() fs.FS
MailTemplates() []string
MailLayouts() map[string]string
}
// OptionalMessage is a service an optional plugin may publish so other
// plugins can integrate without importing that plugin's package.
type OptionalMessage interface {
@@ -62,14 +110,10 @@ type OptionalMessage interface {
// Future capability families are type-asserted when their first consumer
// packages exist:
//
// HasJobs
// HasListeners
// HasAdminControllers
// HasNavigation
// HasPermissions
// HasSchedule
// HasMailTemplates
// HasLang
//
// The kernel type-asserts HasConfig (party, before Register), HasCommands
// (generated app main, after Boot), HasMigrations (lagoon migrate), and