keyops

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangedFile

type ChangedFile struct {
	Path    string `json:"path"`
	Diff    string `json:"diff,omitzero"`
	Changed bool   `json:"changed"`
	Written bool   `json:"written,omitzero"`
}

ChangedFile describes changes made or previewed for a locale file.

type Conflict

type Conflict struct {
	Locale    string `json:"locale,omitzero"`
	Namespace string `json:"namespace,omitzero"`
	FromKey   string `json:"fromKey,omitzero"`
	ToKey     string `json:"toKey,omitzero"`
	FilePath  string `json:"filePath,omitzero"`
	Reason    string `json:"reason"`
}

Conflict describes a reason a rename could not proceed.

type ConflictPolicy

type ConflictPolicy string

ConflictPolicy controls rename behavior when the destination exists.

const (
	ConflictReject    ConflictPolicy = "reject"
	ConflictOverwrite ConflictPolicy = "overwrite"
	ConflictSkip      ConflictPolicy = "skip"
)

Conflict policies for key rename operations.

type Notifier

type Notifier interface {
	Updated(ctx context.Context, uris ...string)
}

Notifier publishes resource update notifications.

type Plan

type Plan struct {
	Input        RenameInput
	Edits        []fileEdit
	StateUpdates []StateUpdate
	Conflicts    []Conflict
	Warnings     []string
}

Plan contains planned file edits and state updates for a rename.

type RenameInput

type RenameInput struct {
	Namespace      string         `json:"namespace" jsonschema:"namespace containing the key to rename"`
	FromKey        string         `json:"fromKey" jsonschema:"existing flattened key path"`
	ToKey          string         `json:"toKey" jsonschema:"new flattened key path"`
	Locales        []string       `json:"locales,omitzero" jsonschema:"locales to update; empty means all locales"`
	DryRun         *bool          `json:"dryRun,omitzero" jsonschema:"when true, preview changes without writing"`
	Apply          bool           `json:"apply,omitzero" jsonschema:"must be true to write locale files and state"`
	ConflictPolicy ConflictPolicy `json:"conflictPolicy,omitzero" jsonschema:"destination conflict policy: reject, overwrite, or skip"`
}

RenameInput configures a key rename operation.

func (RenameInput) DryRunValue

func (in RenameInput) DryRunValue() bool

DryRunValue returns the effective dry-run setting.

func (RenameInput) NormalizedConflictPolicy

func (in RenameInput) NormalizedConflictPolicy() ConflictPolicy

NormalizedConflictPolicy returns the requested policy or the default.

type RenameOutput

type RenameOutput struct {
	DryRun       bool          `json:"dryRun"`
	Planned      int           `json:"planned"`
	Renamed      int           `json:"renamed"`
	ChangedFiles []ChangedFile `json:"changedFiles"`
	StateUpdates []StateUpdate `json:"stateUpdates,omitzero"`
	Conflicts    []Conflict    `json:"conflicts,omitzero"`
	Warnings     []string      `json:"warnings,omitzero"`
}

RenameOutput describes the result of a key rename operation.

type Service

type Service struct {
	Notifier Notifier
	// contains filtered or unexported fields
}

Service performs key operations on locale files and state.

func NewService

func NewService(configService *config.Service, guard *fsutil.Guard, localeService *locale.Service, stateService *state.Service) *Service

NewService creates a key operations service.

func (*Service) PlanRename

func (s *Service) PlanRename(ctx context.Context, in RenameInput) (Plan, error)

PlanRename plans file edits and state updates for a key rename.

func (*Service) Rename

func (s *Service) Rename(ctx context.Context, in RenameInput) (RenameOutput, error)

Rename renames a translation key across locale files and state.

type StateUpdate

type StateUpdate struct {
	Locale    string `json:"locale"`
	Namespace string `json:"namespace"`
	FromKey   string `json:"fromKey"`
	ToKey     string `json:"toKey"`
}

StateUpdate describes a state entry key rename.

Jump to

Keyboard shortcuts

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