Documentation
¶
Overview ¶
Package differ provides functionality for comparing catalogs and detecting changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyStrategy ¶
type ApplyStrategy string
ApplyStrategy represents how to apply changes.
const ( // ApplyAll applies all changes including removals. ApplyAll ApplyStrategy = "all" // ApplyAdditive only applies additions and updates, never removes. ApplyAdditive ApplyStrategy = "additive" // ApplyUpdatesOnly only applies updates to existing items. ApplyUpdatesOnly ApplyStrategy = "updates-only" // ApplyAdditionsOnly only applies new additions. ApplyAdditionsOnly ApplyStrategy = "additions-only" )
type AuthorChangeset ¶
type AuthorChangeset struct {
Added []catalogs.Author // New authors
Updated []AuthorUpdate // Updated authors
Removed []catalogs.Author // Removed authors
}
AuthorChangeset represents changes to authors.
func (*AuthorChangeset) HasChanges ¶
func (a *AuthorChangeset) HasChanges() bool
HasChanges returns true if the author changeset contains any changes.
func (*AuthorChangeset) Print ¶
func (a *AuthorChangeset) Print()
Print outputs author changes in a human-readable format.
type AuthorUpdate ¶
type AuthorUpdate struct {
ID catalogs.AuthorID // ID of the author being updated
Existing catalogs.Author // Current author
New catalogs.Author // New author
Changes []FieldChange // Detailed list of field changes
}
AuthorUpdate represents an update to an existing author.
type ChangeType ¶
type ChangeType string
ChangeType represents the type of change.
const ( // ChangeTypeAdd indicates an item was added. ChangeTypeAdd ChangeType = "add" // ChangeTypeUpdate indicates an item was updated. ChangeTypeUpdate ChangeType = "update" // ChangeTypeRemove indicates an item was removed. ChangeTypeRemove ChangeType = "remove" )
type Changeset ¶
type Changeset struct {
Models *ModelChangeset // Model changes
Providers *ProviderChangeset // Provider changes
Authors *AuthorChangeset // Author changes
Summary ChangesetSummary // Summary statistics
}
Changeset represents all changes between two catalogs.
func (*Changeset) Filter ¶
func (c *Changeset) Filter(strategy ApplyStrategy) *Changeset
Filter filters the changeset based on the apply strategy.
func (*Changeset) HasChanges ¶
HasChanges returns true if the changeset contains any changes.
type ChangesetSummary ¶
type ChangesetSummary struct {
ModelsAdded int
ModelsUpdated int
ModelsRemoved int
ProvidersAdded int
ProvidersUpdated int
ProvidersRemoved int
AuthorsAdded int
AuthorsUpdated int
AuthorsRemoved int
TotalChanges int
}
ChangesetSummary provides summary statistics for a changeset.
type Differ ¶
type Differ interface {
// Models compares two sets of models and returns changes
Models(existing, updated []catalogs.Model) *ModelChangeset
// Providers compares two sets of providers and returns changes
Providers(existing, updated []catalogs.Provider) *ProviderChangeset
// Authors compares two sets of authors and returns changes
Authors(existing, updated []catalogs.Author) *AuthorChangeset
// Catalogs compares two complete catalogs
// Both catalogs only need to be readable
Catalogs(existing, updated catalogs.Reader) *Changeset
}
Differ handles change detection between resources.
type FieldChange ¶
type FieldChange struct {
Path string // Field path (e.g., "pricing.input")
OldValue string // Previous value (string representation)
NewValue string // New value (string representation)
Type ChangeType // Type of change
Source sources.Type // Source that caused the change (for provenance)
}
FieldChange represents a change to a specific field.
type ModelChangeset ¶
type ModelChangeset struct {
Added []catalogs.Model // New models
Updated []ModelUpdate // Updated models
Removed []catalogs.Model // Removed models
}
ModelChangeset represents changes to models.
func (*ModelChangeset) HasChanges ¶
func (m *ModelChangeset) HasChanges() bool
HasChanges returns true if the model changeset contains any changes.
func (*ModelChangeset) Print ¶
func (m *ModelChangeset) Print()
Print outputs model changes in a human-readable format.
type ModelUpdate ¶
type ModelUpdate struct {
ID string // ID of the model being updated
Existing catalogs.Model // Current model
New catalogs.Model // New model
Changes []FieldChange // Detailed list of field changes
}
ModelUpdate represents an update to an existing model.
type Option ¶
type Option func(*differ)
Option is a functional option for configuring Differ.
func WithDeepComparison ¶
WithDeepComparison enables/disables deep structural comparison.
func WithIgnoredFields ¶
WithIgnoredFields sets fields to ignore during comparison.
func WithTracking ¶
WithTracking enables provenance tracking in diffs.
type ProviderChangeset ¶
type ProviderChangeset struct {
Added []catalogs.Provider // New providers
Updated []ProviderUpdate // Updated providers
Removed []catalogs.Provider // Removed providers
}
ProviderChangeset represents changes to providers.
func (*ProviderChangeset) HasChanges ¶
func (p *ProviderChangeset) HasChanges() bool
HasChanges returns true if the provider changeset contains any changes.
func (*ProviderChangeset) Print ¶
func (p *ProviderChangeset) Print()
Print outputs provider changes in a human-readable format.
type ProviderUpdate ¶
type ProviderUpdate struct {
ID catalogs.ProviderID // ID of the provider being updated
Existing catalogs.Provider // Current provider
New catalogs.Provider // New provider
Changes []FieldChange // Detailed list of field changes
}
ProviderUpdate represents an update to an existing provider.