cms

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

README

CMS Plugin for AuthSome

A comprehensive, headless Content Management System (CMS) plugin for the AuthSome authentication framework. This plugin provides a flexible, schema-based content management solution with multi-tenancy support, full-text search, revisions, and a complete dashboard UI.

Features

Core Features
  • Dynamic Content Types: Define content structures with customizable fields
  • JSONB Storage: Flexible schema-less data storage using PostgreSQL JSONB
  • Field Types: 20+ field types including text, rich text, numbers, dates, media, relations, and more
  • Entry Management: Full CRUD operations with draft/published/archived/scheduled workflows
  • Multi-tenancy: App and environment scoped content
Advanced Features
  • Relations: Support for one-to-one, one-to-many, many-to-one, and many-to-many relations
  • Revisions: Automatic version history with rollback capability
  • Full-text Search: PostgreSQL-powered search with highlighting
  • Aggregations: Count, sum, avg, min, max with grouping support
  • Query Language: URL and JSON-based query API with filtering, sorting, and pagination
Dashboard Integration
  • Content Types UI: Create and manage content type schemas
  • Entries UI: Dynamic form generation based on content type fields
  • Navigation: Integrated into AuthSome dashboard sidebar
  • Widgets: Dashboard statistics widget

Installation

The CMS plugin is included in AuthSome. Enable it in your configuration:

auth:
  plugins:
    cms:
      enabled: true
      features:
        enableRevisions: true
        enableDrafts: true
        enableSearch: true
        enableRelations: true
      limits:
        maxContentTypes: 50
        maxFieldsPerType: 100
        maxEntriesPerType: 10000
      revisions:
        maxRevisionsPerEntry: 50
        autoCleanup: true

API Reference

The CMS plugin provides two types of endpoints:

1. API Endpoints (JSON) - For Programmatic Access

Base URL: /api/identity/cms/*

These endpoints return JSON data and are designed for external/programmatic access.

Authentication:

  • Bearer token authentication required
  • API key authentication supported

Required Headers:

X-App-ID: {your-app-id}
X-Environment-ID: {your-environment-id}
Authorization: Bearer {your-token}
2. UI Endpoints (HTML) - For Dashboard Only

Base URL: /api/identity/ui/app/{appID}/cms/*

These endpoints return HTML pages for the AuthSome dashboard interface. They are not intended for programmatic access.


Content Type Endpoints

List Content Types
GET /api/identity/cms/types

Query Parameters:

  • search - Search by name or slug
  • page - Page number (default: 1)
  • pageSize - Items per page (default: 20)

Example Request:

curl -X GET "http://localhost:4000/api/identity/cms/types?page=1&pageSize=20" \
  -H "X-App-ID: d5a0ktoh1fg1tihi9c4g" \
  -H "X-Environment-ID: production" \
  -H "Authorization: Bearer your-token-here"

Example Response:

{
  "contentTypes": [
    {
      "id": "ck1234567890",
      "name": "blog-posts",
      "title": "Blog Posts",
      "description": "Blog post content",
      "icon": "📝",
      "fieldCount": 5,
      "entryCount": 42
    }
  ],
  "totalItems": 1,
  "page": 1,
  "pageSize": 20
}
Create Content Type
POST /api/identity/cms/types

Request Body:

{
  "name": "blog-posts",
  "title": "Blog Posts",
  "description": "Blog post content",
  "icon": "📝"
}
Get Content Type
GET /api/identity/cms/types/{slug}
Update Content Type
PUT /api/identity/cms/types/{slug}
Delete Content Type
DELETE /api/identity/cms/types/{slug}

Content Field Endpoints

Add Field to Content Type
POST /api/identity/cms/types/{slug}/fields

Request Body:

{
  "name": "Title",
  "slug": "title",
  "type": "text",
  "required": true,
  "unique": false,
  "indexed": true,
  "options": {
    "minLength": 1,
    "maxLength": 200
  }
}
Update Field
PUT /api/identity/cms/types/{slug}/fields/{fieldSlug}
Delete Field
DELETE /api/identity/cms/types/{slug}/fields/{fieldSlug}
Reorder Fields
POST /api/identity/cms/types/{slug}/fields/reorder

Request Body:

{
  "fieldOrder": ["field1", "field2", "field3"]
}

Content Entry Endpoints

All content entry endpoints follow the pattern: /api/identity/cms/{type}/*

List Entries
GET /api/identity/cms/{typeSlug}

Query Parameters:

  • search - Full-text search across content fields
  • status - Filter by status: draft, published, archived, scheduled
  • page - Page number (default: 1)
  • pageSize - Items per page (default: 20, max: 100)
  • sort - Sort field(s), prefix with - for descending (e.g., -createdAt)
  • filter[field] - Filter by field value using operators

Filter Syntax:

  • filter[_meta.status]=eq.published - Exact match
  • filter[title]=like.%hello% - Pattern match
  • filter[age]=gt.18 - Greater than
  • filter[price]=lte.100 - Less than or equal
  • filter[category]=in.tech,science - In array

Available Operators:

  • eq - Equal
  • ne - Not equal
  • gt - Greater than
  • gte - Greater than or equal
  • lt - Less than
  • lte - Less than or equal
  • like - Pattern match (use % as wildcard)
  • ilike - Case-insensitive pattern match
  • in - In array (comma-separated values)

Example: List Published Blog Posts

curl -X GET "http://localhost:4000/api/identity/cms/blog-posts?filter[_meta.status]=eq.published&page=1&pageSize=10&sort=-createdAt" \
  -H "X-App-ID: d5a0ktoh1fg1tihi9c4g" \
  -H "X-Environment-ID: production" \
  -H "Authorization: Bearer your-token-here"

Example Response:

{
  "entries": [
    {
      "id": "ck1234567890",
      "data": {
        "title": "My First Post",
        "content": "Hello, world!",
        "author": "John Doe"
      },
      "status": "published",
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z",
      "publishedAt": "2024-01-15T12:00:00Z"
    }
  ],
  "totalItems": 42,
  "page": 1,
  "pageSize": 10
}
Create Entry
POST /api/identity/cms/{typeSlug}

Request Body:

{
  "data": {
    "title": "My First Post",
    "content": "Hello, world!",
    "author": "John Doe"
  },
  "status": "draft"
}

Example:

curl -X POST "http://localhost:4000/api/identity/cms/blog-posts" \
  -H "X-App-ID: d5a0ktoh1fg1tihi9c4g" \
  -H "X-Environment-ID: production" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "title": "My First Post",
      "content": "Hello, world!"
    },
    "status": "draft"
  }'
Get Entry
GET /api/identity/cms/{typeSlug}/{entryId}

Example:

curl -X GET "http://localhost:4000/api/identity/cms/blog-posts/ck1234567890" \
  -H "X-App-ID: d5a0ktoh1fg1tihi9c4g" \
  -H "X-Environment-ID: production" \
  -H "Authorization: Bearer your-token-here"
Update Entry
PUT /api/identity/cms/{typeSlug}/{entryId}

Request Body:

{
  "data": {
    "title": "Updated Title",
    "content": "Updated content"
  }
}
Delete Entry
DELETE /api/identity/cms/{typeSlug}/{entryId}
Publish Entry
POST /api/identity/cms/{typeSlug}/{entryId}/publish

Optional Request Body:

{
  "publishAt": "2024-01-20T12:00:00Z"
}
Unpublish Entry
POST /api/identity/cms/{typeSlug}/{entryId}/unpublish
Archive Entry
POST /api/identity/cms/{typeSlug}/{entryId}/archive
Advanced Query
POST /api/identity/cms/{typeSlug}/query

Request Body:

{
  "filter": {
    "_meta.status": { "$eq": "published" },
    "title": { "$ilike": "%hello%" },
    "age": { "$gte": 18 }
  },
  "sort": ["-createdAt", "title"],
  "page": 1,
  "pageSize": 10,
  "populate": ["author", "category"]
}
Bulk Operations

Bulk Publish:

POST /api/identity/cms/{typeSlug}/bulk/publish

Request Body:

{
  "ids": ["ck001", "ck002", "ck003"]
}

Bulk Unpublish:

POST /api/identity/cms/{typeSlug}/bulk/unpublish

Bulk Delete:

POST /api/identity/cms/{typeSlug}/bulk/delete
Revisions
List Revisions
GET /api/cms/:typeSlug/entries/:entryId/revisions
Get Revision
GET /api/cms/:typeSlug/entries/:entryId/revisions/:version
Restore Revision
POST /api/cms/:typeSlug/entries/:entryId/revisions/:version/restore
Compare Revisions
GET /api/cms/:typeSlug/entries/:entryId/revisions/compare?from=1&to=2
Query API
Complex Query (POST)
POST /api/cms/:typeSlug/query

Request Body:

{
  "filters": {
    "$and": [
      {"status": {"$eq": "published"}},
      {"publishedAt": {"$gte": "2024-01-01"}}
    ]
  },
  "sort": ["-publishedAt", "title"],
  "select": ["title", "excerpt", "author"],
  "populate": ["author", "categories"],
  "page": 1,
  "pageSize": 10
}

Field Types

Type Description Options
text Short text minLength, maxLength, pattern
textarea Multiline text minLength, maxLength
richtext HTML formatted text -
markdown Markdown text -
number Numeric value min, max, step
integer Whole number min, max
float Decimal number min, max, step
decimal Precise decimal min, max, precision
boolean True/false defaultValue
date Date only minDate, maxDate
datetime Date and time minDate, maxDate
time Time only -
email Email address -
url Web URL -
phone Phone number -
slug URL-friendly string -
uuid Unique identifier -
color Color picker -
password Hashed password -
json Arbitrary JSON schema
select Single select choices
multiSelect Multi select choices
enumeration Predefined values choices
relation Reference to content relatedType, relationType
media File/image reference allowedTypes, maxSize

Query Operators

Comparison Operators
  • $eq - Equal
  • $ne - Not equal
  • $gt - Greater than
  • $gte - Greater than or equal
  • $lt - Less than
  • $lte - Less than or equal
String Operators
  • $like - Pattern match (case-sensitive)
  • $ilike - Pattern match (case-insensitive)
  • $startsWith - Starts with
  • $endsWith - Ends with
  • $contains - Contains substring
Array Operators
  • $in - Value in array
  • $nin - Value not in array
Null Operators
  • $null - Is null
  • $notNull - Is not null
Logical Operators
  • $and - All conditions must match
  • $or - Any condition must match
  • $not - Negate condition

Architecture

plugins/cms/
├── config.go           # Plugin configuration
├── plugin.go           # Main plugin entry point
├── dashboard_extension.go  # Dashboard UI integration
├── core/               # Core types and utilities
│   ├── types.go        # DTOs and enums
│   ├── field_types.go  # Field type definitions
│   ├── errors.go       # CMS-specific errors
│   └── validator.go    # Validation helpers
├── schema/             # Database models
│   ├── content_type.go
│   ├── content_field.go
│   ├── content_entry.go
│   ├── content_revision.go
│   └── content_relation.go
├── repository/         # Data access layer
│   ├── content_type.go
│   ├── content_field.go
│   ├── content_entry.go
│   ├── revision.go
│   └── relation.go
├── service/            # Business logic
│   ├── content_type.go
│   ├── content_field.go
│   ├── content_entry.go
│   ├── revision.go
│   ├── relation.go
│   └── validation.go
├── handlers/           # HTTP handlers
│   ├── content_type.go
│   ├── content_entry.go
│   └── revision.go
├── query/              # Query language
│   ├── types.go        # Query AST
│   ├── operators.go    # Filter operators
│   ├── url_parser.go   # URL query parser
│   ├── json_parser.go  # JSON query parser
│   ├── builder.go      # SQL builder
│   ├── executor.go     # Query executor
│   ├── populate.go     # Relation population
│   ├── search.go       # Full-text search
│   └── aggregate.go    # Aggregations
└── pages/              # Dashboard pages
    ├── common.go       # Shared components
    ├── content_types.go
    ├── content_type_detail.go
    └── entries.go

RBAC Permissions

The CMS plugin registers the following permissions:

Content Types
  • read on cms_content_types - View content types
  • create on cms_content_types - Create content types
  • update on cms_content_types - Update content types
  • delete on cms_content_types - Delete content types
Content Entries
  • read on cms_content_entries - View entries
  • create on cms_content_entries - Create entries
  • update on cms_content_entries - Update entries
  • delete on cms_content_entries - Delete entries
  • publish on cms_content_entries - Publish/unpublish entries
Revisions
  • read on cms_content_revisions - View revisions
  • rollback on cms_content_revisions - Restore revisions

Database Schema

The plugin creates the following tables:

  • cms_content_types - Content type definitions
  • cms_content_fields - Field definitions
  • cms_content_entries - Content entries with JSONB data
  • cms_content_revisions - Entry version history
  • cms_content_relations - Many-to-many relations
  • cms_content_type_relations - Type relation definitions

License

See the main AuthSome license.

Documentation

Overview

Package cms provides a content management system plugin for AuthSome. It allows defining custom content types with configurable fields and managing content entries through the dashboard UI and REST API.

Index

Constants

View Source
const (
	ServiceNamePlugin                 = "cms.plugin"
	ServiceNameContentTypeService     = "cms.content_type_service"
	ServiceNameFieldService           = "cms.field_service"
	ServiceNameEntryService           = "cms.entry_service"
	ServiceNameRevisionService        = "cms.revision_service"
	ServiceNameComponentSchemaService = "cms.component_schema_service"
)

Service name constants for DI container registration.

View Source
const (
	// PluginID is the unique identifier for the CMS plugin.
	PluginID = "cms"
	// PluginName is the human-readable name.
	PluginName = "Content Management System"
	// PluginVersion is the current version.
	PluginVersion = "1.0.0"
	// PluginDescription describes the plugin.
	PluginDescription = "Headless CMS with custom content types, dynamic forms, and full query language support"
)

Variables

This section is empty.

Functions

func ResolveComponentSchemaService

func ResolveComponentSchemaService(container forge.Container) (*service.ComponentSchemaService, error)

ResolveComponentSchemaService resolves the component schema service from the container.

func ResolveContentTypeService

func ResolveContentTypeService(container forge.Container) (*service.ContentTypeService, error)

ResolveContentTypeService resolves the content type service from the container.

func ResolveEntryService

func ResolveEntryService(container forge.Container) (*service.ContentEntryService, error)

ResolveEntryService resolves the content entry service from the container.

func ResolveFieldService

func ResolveFieldService(container forge.Container) (*service.ContentFieldService, error)

ResolveFieldService resolves the content field service from the container.

func ResolveRevisionService

func ResolveRevisionService(container forge.Container) (*service.RevisionService, error)

ResolveRevisionService resolves the revision service from the container.

Types

type APIConfig

type APIConfig struct {
	// EnablePublicAPI allows unauthenticated read access to published content
	// Default: false
	EnablePublicAPI bool `json:"enablePublicAPI" yaml:"enablePublicAPI"`

	// DefaultPageSize is the default page size for list endpoints
	// Default: 20
	DefaultPageSize int `json:"defaultPageSize" yaml:"defaultPageSize"`

	// MaxPageSize is the maximum page size for list endpoints
	// Default: 100
	MaxPageSize int `json:"maxPageSize" yaml:"maxPageSize"`

	// RateLimitPerMinute is the rate limit for API requests per minute
	// 0 means no rate limiting
	// Default: 0
	RateLimitPerMinute int `json:"rateLimitPerMinute" yaml:"rateLimitPerMinute"`

	// EnableGraphQL enables GraphQL API endpoint
	// Default: false
	EnableGraphQL bool `json:"enableGraphql" yaml:"enableGraphql"`
}

APIConfig holds API settings.

type BridgeBulkOperationInput added in v0.0.15

type BridgeBulkOperationInput struct {
	AppID    string   `json:"appId"    validate:"required"`
	TypeName string   `json:"typeName" validate:"required"`
	IDs      []string `json:"ids"      validate:"required"`
}

type BridgeComponentSchemaInput added in v0.0.15

type BridgeComponentSchemaInput struct {
	AppID string `json:"appId"          validate:"required"`
	Name  string `json:"name,omitempty"`
}

type BridgeContentTypeInput added in v0.0.15

type BridgeContentTypeInput struct {
	AppID string `json:"appId"          validate:"required"`
	Name  string `json:"name,omitempty"`
}

type BridgeCreateComponentSchemaInput added in v0.0.15

type BridgeCreateComponentSchemaInput struct {
	AppID       string                   `json:"appId"                 validate:"required"`
	Title       string                   `json:"title"                 validate:"required"`
	Name        string                   `json:"name"                  validate:"required"`
	Description string                   `json:"description,omitempty"`
	Icon        string                   `json:"icon,omitempty"`
	Fields      []core.NestedFieldDefDTO `json:"fields,omitempty"`
}

type BridgeCreateContentTypeInput added in v0.0.15

type BridgeCreateContentTypeInput struct {
	AppID       string `json:"appId"                 validate:"required"`
	Title       string `json:"title"                 validate:"required"`
	Name        string `json:"name"                  validate:"required"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
}

type BridgeCreateEntryInput added in v0.0.15

type BridgeCreateEntryInput struct {
	AppID    string         `json:"appId"            validate:"required"`
	TypeName string         `json:"typeName"         validate:"required"`
	Data     map[string]any `json:"data"             validate:"required"`
	Status   string         `json:"status,omitempty"`
}

type BridgeCreateFieldInput added in v0.0.15

type BridgeCreateFieldInput struct {
	AppID       string                `json:"appId"                 validate:"required"`
	TypeName    string                `json:"typeName"              validate:"required"`
	Title       string                `json:"title"                 validate:"required"`
	Name        string                `json:"name"                  validate:"required"`
	Type        string                `json:"type"                  validate:"required"`
	Description string                `json:"description,omitempty"`
	Required    bool                  `json:"required,omitempty"`
	Unique      bool                  `json:"unique,omitempty"`
	Indexed     bool                  `json:"indexed,omitempty"`
	Localized   bool                  `json:"localized,omitempty"`
	Options     *core.FieldOptionsDTO `json:"options,omitempty"`
}

type BridgeEntriesQueryInput added in v0.0.15

type BridgeEntriesQueryInput struct {
	AppID     string         `json:"appId"     validate:"required"`
	TypeName  string         `json:"typeName"  validate:"required"`
	Page      int            `json:"page"`
	PageSize  int            `json:"pageSize"`
	Search    string         `json:"search"`
	Status    string         `json:"status"`
	SortBy    string         `json:"sortBy"`
	SortOrder string         `json:"sortOrder"`
	Filters   map[string]any `json:"filters"`
	Select    []string       `json:"select"`
	Populate  []string       `json:"populate"`
}

type BridgeEntryInput added in v0.0.15

type BridgeEntryInput struct {
	AppID    string `json:"appId"             validate:"required"`
	TypeName string `json:"typeName"          validate:"required"`
	EntryID  string `json:"entryId,omitempty"`
}

type BridgeFieldInput added in v0.0.15

type BridgeFieldInput struct {
	AppID     string `json:"appId"               validate:"required"`
	TypeName  string `json:"typeName"            validate:"required"`
	FieldName string `json:"fieldName,omitempty"`
}

type BridgeReorderFieldsInput added in v0.0.15

type BridgeReorderFieldsInput struct {
	AppID      string   `json:"appId"      validate:"required"`
	TypeName   string   `json:"typeName"   validate:"required"`
	FieldOrder []string `json:"fieldOrder" validate:"required"`
}

type BridgeRevisionInput added in v0.0.15

type BridgeRevisionInput struct {
	AppID    string `json:"appId"              validate:"required"`
	EntryID  string `json:"entryId"            validate:"required"`
	Version  int    `json:"version,omitempty"`
	Page     int    `json:"page,omitempty"`
	PageSize int    `json:"pageSize,omitempty"`
}

type BridgeUpdateComponentSchemaInput added in v0.0.15

type BridgeUpdateComponentSchemaInput struct {
	AppID       string                   `json:"appId"                 validate:"required"`
	Name        string                   `json:"name"                  validate:"required"`
	Title       string                   `json:"title,omitempty"`
	Description string                   `json:"description,omitempty"`
	Icon        string                   `json:"icon,omitempty"`
	Fields      []core.NestedFieldDefDTO `json:"fields,omitempty"`
}

type BridgeUpdateContentTypeInput added in v0.0.15

type BridgeUpdateContentTypeInput struct {
	AppID       string                       `json:"appId"                 validate:"required"`
	Name        string                       `json:"name"                  validate:"required"`
	Title       string                       `json:"title,omitempty"`
	Description string                       `json:"description,omitempty"`
	Icon        string                       `json:"icon,omitempty"`
	Settings    *core.ContentTypeSettingsDTO `json:"settings,omitempty"`
}

type BridgeUpdateEntryInput added in v0.0.15

type BridgeUpdateEntryInput struct {
	AppID    string         `json:"appId"            validate:"required"`
	TypeName string         `json:"typeName"         validate:"required"`
	EntryID  string         `json:"entryId"          validate:"required"`
	Data     map[string]any `json:"data"             validate:"required"`
	Status   string         `json:"status,omitempty"`
}

type BridgeUpdateFieldInput added in v0.0.15

type BridgeUpdateFieldInput struct {
	AppID       string                `json:"appId"                 validate:"required"`
	TypeName    string                `json:"typeName"              validate:"required"`
	FieldName   string                `json:"fieldName"             validate:"required"`
	Title       string                `json:"title,omitempty"`
	Description string                `json:"description,omitempty"`
	Required    *bool                 `json:"required,omitempty"`
	Unique      *bool                 `json:"unique,omitempty"`
	Indexed     *bool                 `json:"indexed,omitempty"`
	Localized   *bool                 `json:"localized,omitempty"`
	Options     *core.FieldOptionsDTO `json:"options,omitempty"`
}

type Config

type Config struct {
	// Features
	Features FeaturesConfig `json:"features" yaml:"features"`

	// Limits
	Limits LimitsConfig `json:"limits" yaml:"limits"`

	// Revisions
	Revisions RevisionsConfig `json:"revisions" yaml:"revisions"`

	// Search
	Search SearchConfig `json:"search" yaml:"search"`

	// API
	API APIConfig `json:"api" yaml:"api"`

	// Dashboard
	Dashboard DashboardConfig `json:"dashboard" yaml:"dashboard"`
}

Config holds the CMS plugin configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func (*Config) Merge

func (c *Config) Merge(other *Config)

Merge merges another config into this one (non-zero values override).

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type DashboardConfig

type DashboardConfig struct {
	// EnableFieldDragDrop enables drag and drop field reordering
	// Default: true
	EnableFieldDragDrop bool `json:"enableFieldDragDrop" yaml:"enableFieldDragDrop"`

	// EnableBulkOperations enables bulk operations on entries
	// Default: true
	EnableBulkOperations bool `json:"enableBulkOperations" yaml:"enableBulkOperations"`

	// EnableImportExport enables import/export functionality
	// Default: false
	EnableImportExport bool `json:"enableImportExport" yaml:"enableImportExport"`

	// EntriesPerPage is the default number of entries per page in the dashboard
	// Default: 25
	EntriesPerPage int `json:"entriesPerPage" yaml:"entriesPerPage"`

	// ShowRevisionHistory shows revision history in entry detail
	// Default: true
	ShowRevisionHistory bool `json:"showRevisionHistory" yaml:"showRevisionHistory"`

	// ShowRelatedEntries shows related entries in entry detail
	// Default: true
	ShowRelatedEntries bool `json:"showRelatedEntries" yaml:"showRelatedEntries"`
}

DashboardConfig holds dashboard-specific settings.

type DashboardExtension

type DashboardExtension struct {
	// contains filtered or unexported fields
}

DashboardExtension implements ui.DashboardExtension for the CMS plugin.

func NewDashboardExtension

func NewDashboardExtension(plugin *Plugin) *DashboardExtension

NewDashboardExtension creates a new dashboard extension.

func (*DashboardExtension) BridgeFunctions added in v0.0.15

func (e *DashboardExtension) BridgeFunctions() []ui.BridgeFunction

BridgeFunctions returns bridge functions for CMS.

func (*DashboardExtension) DashboardWidgets

func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget

DashboardWidgets returns dashboard widgets.

func (*DashboardExtension) ExtensionID

func (e *DashboardExtension) ExtensionID() string

ExtensionID returns the unique identifier for this extension.

func (*DashboardExtension) HandleAddField

func (e *DashboardExtension) HandleAddField(ctx *router.PageContext) (g.Node, error)

HandleAddField handles adding a new field to a content type.

func (*DashboardExtension) HandleCreateComponentSchema

func (e *DashboardExtension) HandleCreateComponentSchema(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleCreateContentType

func (e *DashboardExtension) HandleCreateContentType(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleCreateEntry

func (e *DashboardExtension) HandleCreateEntry(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleDeleteComponentSchema

func (e *DashboardExtension) HandleDeleteComponentSchema(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleDeleteContentType

func (e *DashboardExtension) HandleDeleteContentType(ctx *router.PageContext) (g.Node, error)

HandleDeleteContentType handles deleting a content type.

func (*DashboardExtension) HandleDeleteEntry

func (e *DashboardExtension) HandleDeleteEntry(ctx *router.PageContext) (g.Node, error)

HandleDeleteEntry handles deleting a content entry.

func (*DashboardExtension) HandleDeleteField

func (e *DashboardExtension) HandleDeleteField(ctx *router.PageContext) (g.Node, error)

HandleDeleteField handles deleting a field from a content type.

func (*DashboardExtension) HandleUpdateComponentSchema

func (e *DashboardExtension) HandleUpdateComponentSchema(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleUpdateDisplaySettings added in v0.0.6

func (e *DashboardExtension) HandleUpdateDisplaySettings(ctx *router.PageContext) (g.Node, error)

HandleUpdateDisplaySettings handles updating content type display settings.

func (*DashboardExtension) HandleUpdateEntry

func (e *DashboardExtension) HandleUpdateEntry(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) HandleUpdateFeatureSettings added in v0.0.6

func (e *DashboardExtension) HandleUpdateFeatureSettings(ctx *router.PageContext) (g.Node, error)

HandleUpdateFeatureSettings handles updating content type feature settings.

func (*DashboardExtension) HandleUpdateField

func (e *DashboardExtension) HandleUpdateField(ctx *router.PageContext) (g.Node, error)

HandleUpdateField handles updating a field in a content type.

func (*DashboardExtension) NavigationItems

func (e *DashboardExtension) NavigationItems() []ui.NavigationItem

NavigationItems returns navigation items for the dashboard.

func (*DashboardExtension) Routes

func (e *DashboardExtension) Routes() []ui.Route

Routes returns dashboard routes.

func (*DashboardExtension) ServeCMSOverview

func (e *DashboardExtension) ServeCMSOverview(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeCMSSettings

func (e *DashboardExtension) ServeCMSSettings(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeComponentSchemaDetail

func (e *DashboardExtension) ServeComponentSchemaDetail(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeComponentSchemasList

func (e *DashboardExtension) ServeComponentSchemasList(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeContentTypeDetail

func (e *DashboardExtension) ServeContentTypeDetail(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeContentTypesList

func (e *DashboardExtension) ServeContentTypesList(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeCreateComponentSchema

func (e *DashboardExtension) ServeCreateComponentSchema(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeCreateContentType

func (e *DashboardExtension) ServeCreateContentType(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeCreateEntry

func (e *DashboardExtension) ServeCreateEntry(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeEditEntry

func (e *DashboardExtension) ServeEditEntry(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeEntriesList

func (e *DashboardExtension) ServeEntriesList(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) ServeEntryDetail

func (e *DashboardExtension) ServeEntryDetail(ctx *router.PageContext) (g.Node, error)

func (*DashboardExtension) SetRegistry

func (e *DashboardExtension) SetRegistry(registry any)

SetRegistry sets the extension registry reference (deprecated but kept for compatibility).

func (*DashboardExtension) SettingsPages

func (e *DashboardExtension) SettingsPages() []ui.SettingsPage

SettingsPages returns settings pages.

func (*DashboardExtension) SettingsSections

func (e *DashboardExtension) SettingsSections() []ui.SettingsSection

SettingsSections returns settings sections (deprecated).

type FeaturesConfig

type FeaturesConfig struct {
	// EnableRevisions enables content versioning
	// Default: true
	EnableRevisions bool `json:"enableRevisions" yaml:"enableRevisions"`

	// EnableDrafts enables draft/publish workflow
	// Default: true
	EnableDrafts bool `json:"enableDrafts" yaml:"enableDrafts"`

	// EnableScheduling enables scheduled publishing
	// Default: true
	EnableScheduling bool `json:"enableScheduling" yaml:"enableScheduling"`

	// EnableSearch enables full-text search
	// Default: false (requires PostgreSQL full-text search setup)
	EnableSearch bool `json:"enableSearch" yaml:"enableSearch"`

	// EnableRelations enables relations between content types
	// Default: true
	EnableRelations bool `json:"enableRelations" yaml:"enableRelations"`

	// EnableLocalization enables content localization
	// Default: false
	EnableLocalization bool `json:"enableLocalization" yaml:"enableLocalization"`

	// EnableSoftDelete enables soft delete for entries
	// Default: true
	EnableSoftDelete bool `json:"enableSoftDelete" yaml:"enableSoftDelete"`
}

FeaturesConfig holds feature toggles.

type LimitsConfig

type LimitsConfig struct {
	// MaxContentTypes is the maximum number of content types per app/environment
	// 0 means unlimited
	// Default: 100
	MaxContentTypes int `json:"maxContentTypes" yaml:"maxContentTypes"`

	// MaxFieldsPerType is the maximum number of fields per content type
	// Default: 50
	MaxFieldsPerType int `json:"maxFieldsPerType" yaml:"maxFieldsPerType"`

	// MaxEntriesPerType is the maximum number of entries per content type
	// 0 means unlimited (can be overridden per content type)
	// Default: 0
	MaxEntriesPerType int `json:"maxEntriesPerType" yaml:"maxEntriesPerType"`

	// MaxEntryDataSize is the maximum size of entry data in bytes
	// Default: 1MB
	MaxEntryDataSize int64 `json:"maxEntryDataSize" yaml:"maxEntryDataSize"`

	// MaxRelationsPerEntry is the maximum number of relations per entry
	// Default: 100
	MaxRelationsPerEntry int `json:"maxRelationsPerEntry" yaml:"maxRelationsPerEntry"`

	// MaxComponentSchemas is the maximum number of component schemas per app/environment
	// 0 means unlimited
	// Default: 100
	MaxComponentSchemas int `json:"maxComponentSchemas" yaml:"maxComponentSchemas"`
}

LimitsConfig holds resource limits.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements the CMS plugin for AuthSome.

func NewPlugin

func NewPlugin(opts ...PluginOption) *Plugin

NewPlugin creates a new CMS plugin instance.

func ResolveCMSPlugin

func ResolveCMSPlugin(container forge.Container) (*Plugin, error)

ResolveCMSPlugin resolves the CMS plugin from the container.

func (*Plugin) Config

func (p *Plugin) Config() *Config

Config returns the plugin configuration.

func (*Plugin) DB

func (p *Plugin) DB() *bun.DB

DB returns the database connection.

func (*Plugin) DashboardExtension

func (p *Plugin) DashboardExtension() ui.DashboardExtension

DashboardExtension returns the dashboard extension for the plugin Uses lazy initialization to ensure plugin is fully initialized before creating extension.

func (*Plugin) Dependencies

func (p *Plugin) Dependencies() []string

Dependencies returns the plugin dependencies.

func (*Plugin) Description

func (p *Plugin) Description() string

Description returns the plugin description.

func (*Plugin) GetComponentSchemaService

func (p *Plugin) GetComponentSchemaService() *service.ComponentSchemaService

GetComponentSchemaService returns the component schema service directly.

func (*Plugin) GetContentTypeService

func (p *Plugin) GetContentTypeService() *service.ContentTypeService

GetContentTypeService returns the content type service directly.

func (*Plugin) GetEntryService

func (p *Plugin) GetEntryService() *service.ContentEntryService

GetEntryService returns the content entry service directly.

func (*Plugin) GetFieldService

func (p *Plugin) GetFieldService() *service.ContentFieldService

GetFieldService returns the content field service directly.

func (*Plugin) GetRevisionService

func (p *Plugin) GetRevisionService() *service.RevisionService

GetRevisionService returns the revision service directly.

func (*Plugin) GetServices

func (p *Plugin) GetServices() map[string]any

GetServices returns a map of all available services for inspection.

func (*Plugin) ID

func (p *Plugin) ID() string

ID returns the unique plugin identifier.

func (*Plugin) Init

func (p *Plugin) Init(auth core.Authsome) error

Init initializes the plugin with dependencies from the Auth instance.

func (*Plugin) Logger

func (p *Plugin) Logger() forge.Logger

Logger returns the plugin logger.

func (*Plugin) Migrate

func (p *Plugin) Migrate() error

Migrate runs database migrations for the plugin.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the human-readable plugin name.

func (*Plugin) Priority

func (p *Plugin) Priority() int

Priority returns the plugin initialization priority.

func (*Plugin) RegisterHooks

func (p *Plugin) RegisterHooks(hookRegistry *hooks.HookRegistry) error

RegisterHooks registers the plugin's hooks.

func (*Plugin) RegisterRoles

func (p *Plugin) RegisterRoles(roleRegistry rbac.RoleRegistryInterface) error

RegisterRoles registers RBAC roles for the plugin.

func (*Plugin) RegisterRoutes

func (p *Plugin) RegisterRoutes(router forge.Router) error

RegisterRoutes registers the plugin's HTTP routes.

func (*Plugin) RegisterServiceDecorators

func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error

RegisterServiceDecorators allows the plugin to decorate core services.

func (*Plugin) RegisterServices

func (p *Plugin) RegisterServices(container forge.Container) error

RegisterServices registers all CMS services in the DI container Uses vessel.ProvideConstructor for type-safe, constructor-based dependency injection.

func (*Plugin) Version

func (p *Plugin) Version() string

Version returns the plugin version.

type PluginOption

type PluginOption func(*Plugin)

PluginOption is a functional option for configuring the plugin.

func WithDefaultConfig

func WithDefaultConfig(cfg *Config) PluginOption

WithDefaultConfig sets the default configuration.

func WithEnableDrafts

func WithEnableDrafts(enabled bool) PluginOption

WithEnableDrafts enables/disables draft workflow.

func WithEnableRelations

func WithEnableRelations(enabled bool) PluginOption

WithEnableRelations enables/disables content relations.

func WithEnableRevisions

func WithEnableRevisions(enabled bool) PluginOption

WithEnableRevisions enables/disables revision tracking.

func WithEnableScheduling

func WithEnableScheduling(enabled bool) PluginOption

WithEnableScheduling enables/disables scheduled publishing.

func WithEnableSearch

func WithEnableSearch(enabled bool) PluginOption

WithEnableSearch enables/disables full-text search.

func WithMaxContentTypes

func WithMaxContentTypes(max int) PluginOption

WithMaxContentTypes sets the maximum number of content types.

func WithMaxFieldsPerType

func WithMaxFieldsPerType(max int) PluginOption

WithMaxFieldsPerType sets the maximum fields per content type.

func WithMaxRevisionsPerEntry

func WithMaxRevisionsPerEntry(max int) PluginOption

WithMaxRevisionsPerEntry sets the maximum revisions per entry.

func WithPublicAPI

func WithPublicAPI(enabled bool) PluginOption

WithPublicAPI enables/disables public API access.

type RevisionsConfig

type RevisionsConfig struct {
	// MaxRevisionsPerEntry is the maximum number of revisions to keep per entry
	// When exceeded, oldest revisions are automatically deleted
	// Default: 50
	MaxRevisionsPerEntry int `json:"maxRevisionsPerEntry" yaml:"maxRevisionsPerEntry"`

	// RetentionDays is how long to keep old revisions in days
	// Revisions older than this are eligible for cleanup
	// Default: 90
	RetentionDays int `json:"retentionDays" yaml:"retentionDays"`

	// AutoCleanup enables automatic cleanup of old revisions
	// Default: true
	AutoCleanup bool `json:"autoCleanup" yaml:"autoCleanup"`

	// CleanupInterval is how often to run revision cleanup
	// Default: 24 hours
	CleanupInterval time.Duration `json:"cleanupInterval" yaml:"cleanupInterval"`
}

RevisionsConfig holds revision settings.

type SearchConfig

type SearchConfig struct {
	// Language is the PostgreSQL text search configuration
	// Default: "english"
	Language string `json:"language" yaml:"language"`

	// MinSearchLength is the minimum query length for search
	// Default: 2
	MinSearchLength int `json:"minSearchLength" yaml:"minSearchLength"`

	// MaxSearchResults is the maximum number of search results
	// Default: 100
	MaxSearchResults int `json:"maxSearchResults" yaml:"maxSearchResults"`

	// EnableHighlighting enables search result highlighting
	// Default: true
	EnableHighlighting bool `json:"enableHighlighting" yaml:"enableHighlighting"`
}

SearchConfig holds search settings.

Directories

Path Synopsis
Package core provides core types and utilities for the CMS plugin.
Package core provides core types and utilities for the CMS plugin.
Package handlers provides HTTP handlers for the CMS plugin.
Package handlers provides HTTP handlers for the CMS plugin.
Package pages provides gomponent-based page templates for the CMS dashboard.
Package pages provides gomponent-based page templates for the CMS dashboard.
Package query provides a query language parser and builder for the CMS plugin.
Package query provides a query language parser and builder for the CMS plugin.
Package repository implements the data access layer for the CMS plugin.
Package repository implements the data access layer for the CMS plugin.
Package schema defines the database schema for the CMS plugin.
Package schema defines the database schema for the CMS plugin.
Package service implements the business logic layer for the CMS plugin.
Package service implements the business logic layer for the CMS plugin.

Jump to

Keyboard shortcuts

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