Documentation
¶
Overview ¶
Package wm is the application layer shared by the CLI and the MCP server, so both expose identical semantics, safety checks and output shapes.
Index ¶
- Constants
- Variables
- func CheckBulk(n int, confirmed, dryRun bool) error
- func CleanURLs(raw []string) ([]string, error)
- func ParseLast(v string, now time.Time) (string, error)
- func ReadOnlyError() *apperr.Error
- func SeverityRank(s string) int
- func SiteFromWebserver(v string) string
- func SiteOf(ctx context.Context, c *api.Client) (string, error)
- func ValidateURL(raw string) (string, error)
- type BatchSummary
- type DocumentBatch
- type DocumentItem
- type Finding
- type MetricChange
- type ReindexData
- type ReindexItem
- type ReindexOptions
- type ReindexSummary
- type Report
- type Result
- type Service
- func (s *Service) CheckDocuments(ctx context.Context, urls []string, brief bool, onItem func(DocumentItem)) (Result, error)
- func (s *Service) DatabaseInfo(ctx context.Context) (Result, error)
- func (s *Service) Document(ctx context.Context, rawURL string, brief bool) (Result, error)
- func (s *Service) Documents(ctx context.Context, o ViewOptions) (Result, error)
- func (s *Service) History(ctx context.Context, from, to string) (Result, error)
- func (s *Service) Overview(ctx context.Context, o ViewOptions) (Result, error)
- func (s *Service) Reindex(ctx context.Context, o ReindexOptions) (Result, error)
- func (s *Service) Report(ctx context.Context, windowDays int) (Result, error)
- func (s *Service) Site(ctx context.Context) (string, error)
- type Trend
- type ViewOptions
Constants ¶
const ( StateIndexed = "indexed" StateNotIndexed = "not_indexed" StateError = "error" StateRedirect = "redirect" StateNotFound = "not_found" StateNoData = "no_data" StateForbidden = "forbidden" StateFailed = "failed" StateNotAttempted = "not_attempted" )
Page states reported by document lookups.
const ( ReindexSubmitted = "submitted" ReindexFailed = "failed" ReindexNotAttempted = "not_attempted" ReindexPlanned = "planned" )
Reindex item statuses.
const ( SeverityOK = "ok" SeverityInfo = "info" SeverityWarning = "warning" SeverityCritical = "critical" )
Finding severities, ordered from least to most serious.
const DefaultURLLimit = 100
DefaultURLLimit caps URLs per category unless the caller asks otherwise. The API returns up to 1,000 per category, too much for an agent's context window.
Variables ¶
var UntrustedDocumentFields = []string{"title", "meta", "openGraphData", "responseHeaders"}
UntrustedDocumentFields lists response fields copied from third-party pages. They may contain text written to manipulate an agent reading them.
Functions ¶
func CheckBulk ¶
CheckBulk requires explicit confirmation for writes touching several URLs. szwm never prompts, because a prompt would hang a non-interactive agent.
func CleanURLs ¶
CleanURLs validates everything up front and removes duplicates. Failing before the first call keeps a typo from burning half of a batch's quota.
func ReadOnlyError ¶
ReadOnlyError is returned when a write is blocked.
func SeverityRank ¶
SeverityRank orders severities; unknown values rank below everything.
func SiteFromWebserver ¶ added in v0.2.0
SiteFromWebserver converts the API's reversed form, such as com.example.!443, into a host name such as example.com.
func SiteOf ¶ added in v0.2.0
SiteOf is Site for a bare client, used to check a key before it is saved.
func ValidateURL ¶
ValidateURL checks that raw is an absolute http(s) page URL.
Types ¶
type BatchSummary ¶
type BatchSummary struct {
Total int `json:"total"`
OK int `json:"ok"`
Failed int `json:"failed"`
States map[string]int `json:"states"`
}
BatchSummary aggregates a lookup batch.
type DocumentBatch ¶
type DocumentBatch struct {
Summary BatchSummary `json:"summary"`
Items []DocumentItem `json:"items"`
}
DocumentBatch is the data of a multi-URL lookup.
type DocumentItem ¶
type DocumentItem struct {
URL string `json:"url"`
OK bool `json:"ok"`
State string `json:"state"`
DownloadedAt string `json:"downloaded_at,omitempty"`
IndexedAt string `json:"indexed_at,omitempty"`
Document any `json:"document,omitempty"`
Error *apperr.Error `json:"error,omitempty"`
}
DocumentItem is one page's lookup result.
type Finding ¶
type Finding struct {
Code string `json:"code"`
Severity string `json:"severity"`
Message string `json:"message"`
Metric string `json:"metric,omitempty"`
Value float64 `json:"value,omitempty"`
}
Finding is one deterministic observation with a stable code.
type MetricChange ¶
type MetricChange struct {
From int64 `json:"from"`
To int64 `json:"to"`
Delta int64 `json:"delta"`
Percent *float64 `json:"percent,omitempty"`
}
MetricChange compares a metric between two days.
type ReindexData ¶
type ReindexData struct {
DryRun bool `json:"dry_run"`
Summary ReindexSummary `json:"summary"`
Items []ReindexItem `json:"items"`
Quota ratelimit.Quota `json:"quota"`
EstimatedSeconds int `json:"estimated_seconds"`
}
ReindexData is the data of a reindex run or plan.
type ReindexItem ¶
type ReindexItem struct {
URL string `json:"url"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Error *apperr.Error `json:"error,omitempty"`
}
ReindexItem is the result for one URL.
type ReindexOptions ¶
type ReindexOptions struct {
URLs []string
DryRun bool
IgnoreQuota bool
OnItem func(ReindexItem)
}
ReindexOptions control a run.
type ReindexSummary ¶
type ReindexSummary struct {
Total int `json:"total"`
Submitted int `json:"submitted"`
Failed int `json:"failed"`
NotAttempted int `json:"not_attempted"`
Planned int `json:"planned,omitempty"`
}
ReindexSummary aggregates a run.
type Report ¶
type Report struct {
Severity string `json:"severity"`
Site string `json:"site,omitempty"`
GeneratedAt string `json:"generated_at"`
DataRelease string `json:"data_release,omitempty"`
Totals map[string]int64 `json:"totals"`
Ratios map[string]float64 `json:"ratios"`
Trend *Trend `json:"trend,omitempty"`
Findings []Finding `json:"findings"`
ErrorSample []any `json:"error_sample,omitempty"`
}
Report is the site health summary.
type Result ¶
type Result struct {
Data any
Raw []byte
Hints []string
Warnings []string
Untrusted []string
Truncated bool
// Err marks a failure that still produced data, such as a partial batch.
Err *apperr.Error
}
Result is the outcome of an operation.
type Service ¶
Service executes Webmaster operations.
func (*Service) CheckDocuments ¶
func (s *Service) CheckDocuments(ctx context.Context, urls []string, brief bool, onItem func(DocumentItem)) (Result, error)
CheckDocuments looks up many URLs sequentially, pacing itself through the limiter. A page Seznam does not know is a valid answer, not a failure; only transport, auth and access problems fail an item. onItem runs as each result arrives so a killed process still leaves partial output.
func (*Service) DatabaseInfo ¶
DatabaseInfo returns the release time of the data behind the API.
func (*Service) Reindex ¶
Reindex wraps POST /web/document/reindex. URLs must already be cleaned.
The URL list is cut to the estimated remaining quota before the first call, and each success is recorded immediately, so an interrupted batch leaves the ledger correct. Anything left over is reported as not_attempted with a reason, which makes resuming the next day a mechanical step.