feat: batches with dry run, undo, and CSV import and export

- POST /_seo/api/v1/batch runs changes in one transaction: dry_run
  answers the diff and the conflicts (loops, chains, noindex on a
  published record, canonicals to redirected or noindex addresses) and
  rolls back; a refused change refuses the batch (D-12)
- undo of a change or a whole batch from History and through MCP, with
  the undo_stale, undo_loop and undo_gone refusals (D-13)
- CSV export and import of redirects, rules and records by URL: BOM,
  comma or semicolon, formula cells escaped, a dry-run preview, all or
  nothing with via import; the screen's apply token is HMAC-SHA256 over
  the file and a fingerprint of the data (transfer.stale)
- Import and export singleton with the seo_transfer widget action,
  History record actions undo and undo_batch, navigation entry
- MCP tools undo_change, undo_batch, apply_batch, export_csv, import_csv
- TestBatch, TestUndo, TestCSVTransfer, TestLoopRefused mcp and import
This commit is contained in:
2026-10-27 12:35:26 +01:00
parent aa0c3bcacf
commit ab3b219fec
27 changed files with 3319 additions and 96 deletions

View File

@@ -3,7 +3,8 @@ 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.
// 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"
@@ -92,4 +93,15 @@ var AdminOperations = []AdminOperation{
// 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"},
}