Files
sm-seo-plugin/operations.go
Jakub Zych 17da132b00 feat: graph validation and custom JSON-LD
- seo_schema (seoschema, E8) with the C17 server rules: invalid JSON with
  line and column, non-objects, 16 KB, depth 8, a literal <script and a
  type outside the kind's list refused; the value re-serialised
- a custom node with a generated @id merges into it (schema.merged save
  notice), other nodes are appended to the graph
- seo_primary_parent (seoparent) for article types; both values stored
  in the entry data on every locale row
- the seo_graph widget action (E9 data), P1 primary_gone and the P2
  schema type and breadcrumb trail rows
- GET /_seo/api/v1/graph and MCP seo_get_graph; seo_set_url_seo and
  apply_batch accept primary_parent and schema

The graph tool lands with the validation: the operations parity test
binds the seo_graph widget action to its tool.
2026-11-04 14:33:10 +01:00

118 lines
5.6 KiB
Go

package seo
import "git.golem15.com/golem15/sm-seo-plugin/controllers"
// The kinds of an admin operation (AdminOperation.Kind). Record, bulk and
// widget actions add ":" and the action's name, and a widget action with
// several ops "#" and the op.
const (
// OpList is a controller's list.
OpList = "list"
// OpShow is a record's form or preview, or a singleton's form.
OpShow = "show"
// OpCreate is the create form's save (toolbar create).
OpCreate = "create"
// OpUpdate is the update form's save, or a singleton's save.
OpUpdate = "update"
// OpDelete is the form's and the list toolbar's delete.
OpDelete = "delete"
// OpExtensionSave is a form extension's save on the controller.
OpExtensionSave = "extension_save"
// OpUpload is a field type's upload.
OpUpload = "upload"
// OpRecordAction is a record action ("record_action:<name>").
OpRecordAction = "record_action"
// OpBulkAction is a bulk action ("bulk_action:<name>").
OpBulkAction = "bulk_action"
// OpWidgetAction is a widget action ("widget_action:<name>").
OpWidgetAction = "widget_action"
)
// ContentController stands for the form of every content type the SEO tab
// is added to (D-91): the operations of the tab are the same on all.
const ContentController = "*"
// AdminOperation is one operation of the SEO admin and the MCP tool that
// performs it (D-10): the controller, the kind of operation and the tool
// name without the seo_ prefix.
type AdminOperation struct {
Controller string
Kind string
Tool string
}
// AdminOperations maps every operation of the SEO admin to its MCP tool
// (D-10, SC-4). TestEveryAdminOperationHasTool derives the operations from
// the controllers, their configs, actions and form extensions, and fails
// when one is missing here, when a tool named here does not exist, or when
// a tool is not bound to a registered route.
var AdminOperations = []AdminOperation{
// The SEO tab of every content type.
{ContentController, OpShow, "get_url_seo"},
{ContentController, OpExtensionSave, "set_url_seo"},
{ContentController, OpWidgetAction + ":seo_snippet", "get_url_seo"},
{ContentController, OpWidgetAction + ":seo_graph", "get_graph"},
// The social image is set by URL through MCP (uploads are no tool).
{ContentController, OpUpload, "set_url_seo"},
// SEO settings and the per-type tabs.
{controllers.SettingsControllerID, OpShow, "show_settings"},
{controllers.SettingsControllerID, OpUpdate, "update_settings"},
{controllers.SettingsControllerID, OpExtensionSave, "update_settings"},
// Redirects.
{controllers.RedirectsControllerID, OpList, "list_redirects"},
{controllers.RedirectsControllerID, OpShow, "show_redirect"},
{controllers.RedirectsControllerID, OpCreate, "create_redirect"},
{controllers.RedirectsControllerID, OpUpdate, "update_redirect"},
{controllers.RedirectsControllerID, OpDelete, "delete_redirect"},
{controllers.RedirectsControllerID, OpExtensionSave, "update_redirect"},
// 404 log.
{controllers.NotFoundControllerID, OpList, "list_not_found"},
{controllers.NotFoundControllerID, OpShow, "list_not_found"},
{controllers.NotFoundControllerID, OpDelete, "delete_not_found"},
{controllers.NotFoundControllerID, OpRecordAction + ":" + controllers.NotFoundActionRedirect, "redirect_not_found"},
{controllers.NotFoundControllerID, OpRecordAction + ":" + controllers.NotFoundActionGone, "gone_not_found"},
{controllers.NotFoundControllerID, OpBulkAction + ":" + controllers.NotFoundActionGone, "gone_not_found"},
// URL rules.
{controllers.RulesControllerID, OpList, "list_rules"},
{controllers.RulesControllerID, OpShow, "show_rule"},
{controllers.RulesControllerID, OpCreate, "create_rule"},
{controllers.RulesControllerID, OpUpdate, "update_rule"},
{controllers.RulesControllerID, OpDelete, "delete_rule"},
{controllers.RulesControllerID, OpExtensionSave, "update_rule"},
{controllers.RulesControllerID, OpWidgetAction + ":seo_snippet", "get_url_seo"},
// Pages, the page registry; its own address-and-name extension saves
// with the form.
{controllers.PagesControllerID, OpList, "list_pages"},
{controllers.PagesControllerID, OpShow, "list_pages"},
{controllers.PagesControllerID, OpCreate, "create_page"},
{controllers.PagesControllerID, OpUpdate, "update_page"},
{controllers.PagesControllerID, OpDelete, "delete_page"},
{controllers.PagesControllerID, OpExtensionSave, "update_page"},
// robots.txt and AI bots.
{controllers.RobotsControllerID, OpShow, "show_robots"},
{controllers.RobotsControllerID, OpUpdate, "update_robots"},
{controllers.RobotsControllerID, OpExtensionSave, "update_robots"},
{controllers.RobotsControllerID, OpWidgetAction + ":" + RobotsTestAction, "test_robots"},
// History.
{controllers.HistoryControllerID, OpList, "list_history"},
{controllers.HistoryControllerID, OpShow, "show_history"},
{controllers.HistoryControllerID, OpRecordAction + ":" + controllers.HistoryActionUndo, "undo_change"},
{controllers.HistoryControllerID, OpRecordAction + ":" + controllers.HistoryActionUndoBatch, "undo_batch"},
// Import and export: the delimiter is a settings column; the files
// widget's ops export, preview and apply.
{controllers.TransferControllerID, OpShow, "show_settings"},
{controllers.TransferControllerID, OpUpdate, "update_settings"},
{controllers.TransferControllerID, OpWidgetAction + ":" + controllers.TransferAction, "import_csv"},
{controllers.TransferControllerID, OpWidgetAction + ":" + controllers.TransferAction + "#export", "export_csv"},
{controllers.TransferControllerID, OpWidgetAction + ":" + controllers.TransferAction + "#preview", "import_csv"},
{controllers.TransferControllerID, OpWidgetAction + ":" + controllers.TransferAction + "#apply", "import_csv"},
}