feat(32.2-01): per-item rows and item actions on My account contributions

- pact: AccountContribution.Items/ItemActions/ItemsEmpty, AccountItem,
  AccountItemAction, AccountItemActionInput, ErrAccountItemNotFound
- cabana: the list sends items (null without Items), permitted item actions
  and the empty line; boot refuses item actions without Items
- cabana: POST {api}/account/contribution-items/{name}/{item}/actions/{action}
  runs only for an item the administrator's own Items listed, in a transaction
  (path outside /account/contributions/ to avoid a ServeMux overlap)
- swag views; admin.json and schema.d.ts regenerated; route inventories
This commit is contained in:
Jakub Zych
2026-11-21 00:22:13 +01:00
parent 97d7ee0586
commit 3f7ce6020d
16 changed files with 706 additions and 30 deletions

View File

@@ -341,11 +341,32 @@ type AccountContributionView struct {
// section has none or its status could not be loaded.
Status string `json:"status"`
Actions []AccountContributionActionView `json:"actions"`
// Error is true when the section's status or one of its actions could
// not be loaded (the plugin's Status or an action's Applies failed; that
// action is left out); the other sections are answered as usual. Absent
// otherwise.
// Error is true when the section's status, its items or one of its
// actions could not be loaded (the plugin's Status, Items or an action's
// Applies failed; that action is left out); the other sections are
// answered as usual. Absent otherwise.
Error bool `json:"error,omitempty"`
// Items are the signed-in admin's rows of a section with an Items
// function: an array, possibly empty. null for a section without Items
// and when the section's Items failed.
Items []AccountItemView `json:"items"`
// ItemActions are the buttons of each row the admin holds the
// permissions for; null for a section without Items. Confirm may hold
// :title, which the admin fills with the row's title.
ItemActions []AccountContributionActionView `json:"item_actions"`
// ItemsEmpty is the translated line for a section with no rows; "" means
// the admin's own empty line.
ItemsEmpty string `json:"items_empty"`
}
// AccountItemView is one row of a contributed section: the id the item
// action route names, a title, an optional subtitle and meta lines, all
// plain text.
type AccountItemView struct {
ID string `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Meta []string `json:"meta"`
}
// AccountContributionActionView is one button of a contributed section: the
@@ -478,6 +499,24 @@ func AdminMCPConsentShow() {}
// @Router /mcp/consent/{request} [post]
func AdminMCPConsentDecide() {}
// AdminAccountContributionItemAction documents POST /account/contribution-items/{name}/{item}/actions/{action}.
//
// @Summary Run a My account item action
// @Description Runs one item action of a contributed section on one of the signed-in admin's rows. The action's permissions are checked (403); an item the section's Items does not list for this admin, or one that is gone, is 404. The answer is the action's message and an optional URL to open. Personal API tokens are refused (403 interactive_only).
// @Tags admin
// @Produce json
// @Security BackendBearer
// @Param name path string true "Section name"
// @Param item path string true "Item id"
// @Param action path string true "Item action name"
// @Success 200 {object} Envelope[AccountActionResultView]
// @Failure 401 {object} ErrorEnvelope
// @Failure 403 {object} ErrorEnvelope
// @Failure 404 {object} ErrorEnvelope
// @Failure 422 {object} ErrorEnvelope
// @Router /account/contribution-items/{name}/{item}/actions/{action} [post]
func AdminAccountContributionItemAction() {}
// AdminAccountTokenScopes documents GET /account/tokens/scopes.
//
// @Summary List available API token scopes