changerator

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const NodeChannel string = "node-channel"

Variables

This section is empty.

Functions

func GetChangeHash

func GetChangeHash(change *model.Change) string

GetChangeHash is a public convenience function to generate a hash for a change.

func HandleExtensions

func HandleExtensions(ctx context.Context, v v3.Foundational, changes *model.ExtensionChanges)

func ProcessMaps

func ProcessMaps[T any, R v3.Companion](ctx context.Context,
	changes map[string]*T, obj *orderedmap.Map[string, R], tardis v3.Tardis)

func ProcessSlice

func ProcessSlice[C what_changed.Changed](ctx context.Context, ch C, t v3.Tardis)

func PushChanges

func PushChanges[N v3.Foundational, R what_changed.Changed](ctx context.Context, model N, r R)

func PushChangesFromSlice

func PushChangesFromSlice[N v3.Foundational, T what_changed.Changed](ctx context.Context, model N, _ []T, nType, nPath string)

func PushChangesWithOverride

func PushChangesWithOverride[N v3.Foundational, R what_changed.Changed](ctx context.Context, model N, y R, nType, nPath string)

Types

type ChangeDeduplicator

type ChangeDeduplicator struct {
	// contains filtered or unexported fields
}

ChangeDeduplicator provides deduplication services for Doctor's node-based graph visualization. It ensures that the same change is not reported multiple times when it appears at different levels of the document structure (e.g., at both the path level and operation level).

IMPORTANT: This deduplicator is used for node-based change tree visualization and graph generation. It is NOT used by the markdown report generator, which works directly with the already-deduplicated what-changed DocumentChanges model.

The what-changed library (libopenapi/what-changed) is the source of truth for change detection and deduplication. This deduplicator exists only to handle the Doctor's node tree representation, which can create duplicates when distributing changes from the what-changed model into the node hierarchy.

Note: Consider this component for deprecation once node-based visualization can be refactored to work directly with DocumentChanges instead of the node tree.

func NewChangeDeduplicator

func NewChangeDeduplicator() *ChangeDeduplicator

NewChangeDeduplicator creates a new deduplicator instance

func (*ChangeDeduplicator) BuildNodePath

func (d *ChangeDeduplicator) BuildNodePath(nodeId string) []string

BuildNodePath constructs the full path from root to the given node.

func (*ChangeDeduplicator) CalculateDepth

func (d *ChangeDeduplicator) CalculateDepth(nodeId string) int

CalculateDepth calculates the depth of a node in the hierarchy. Deeper nodes are more specific and preferred for change attribution.

func (*ChangeDeduplicator) DeduplicateNodeChanges

func (d *ChangeDeduplicator) DeduplicateNodeChanges(node *v3.Node)

DeduplicateNodeChanges removes duplicate changes from a node's change sets. This modifies the node in place, keeping only unique changes.

func (*ChangeDeduplicator) GenerateChangeHash

func (d *ChangeDeduplicator) GenerateChangeHash(change *model.Change) string

GenerateChangeHash creates a unique hash for a change based on its semantic content. This hash is used to identify duplicate changes across different nodes in the hierarchy.

func (*ChangeDeduplicator) GetAllUniqueChanges

func (d *ChangeDeduplicator) GetAllUniqueChanges() []*model.Change

GetAllUniqueChanges returns all unique changes across the entire document.

func (*ChangeDeduplicator) GetDuplicateCount

func (d *ChangeDeduplicator) GetDuplicateCount() int

GetDuplicateCount returns the total number of duplicate changes that were filtered out.

func (*ChangeDeduplicator) GetStatistics

func (d *ChangeDeduplicator) GetStatistics() *ChangeStatistics

GetStatistics returns statistics about deduplicated changes.

func (*ChangeDeduplicator) GetUniqueChangesForNode

func (d *ChangeDeduplicator) GetUniqueChangesForNode(nodeId string) []*model.Change

GetUniqueChangesForNode returns deduplicated changes for a specific node. This only includes changes that are uniquely attributed to this node (not duplicates).

func (*ChangeDeduplicator) ProcessChange

func (d *ChangeDeduplicator) ProcessChange(change *model.Change, nodeId string) bool

ProcessChange processes a single change for deduplication. Returns true if the change is unique (should be kept), false if it's a duplicate. When a duplicate is found at a more specific level, the tracking is updated to prefer the more specific node.

func (*ChangeDeduplicator) RegisterNode

func (d *ChangeDeduplicator) RegisterNode(nodeId, parentId string)

RegisterNode registers a node and its parent in the hierarchy map. This allows the deduplicator to understand the document structure.

func (*ChangeDeduplicator) Reset

func (d *ChangeDeduplicator) Reset()

Reset clears all deduplication state. Useful for reusing the same deduplicator instance.

type ChangeStatistics

type ChangeStatistics struct {
	Additions     int
	Modifications int
	Deletions     int
}

type Changerator

type Changerator struct {
	Config       *ChangeratorConfig
	NodeChan     chan *modelChange
	ChangedNodes []*v3.Node
	ChangedEdges []*v3.Edge
	Changes      []*whatChangedModel.Change

	// Deduplicator handles change deduplication across the hierarchy
	Deduplicator *ChangeDeduplicator
	// contains filtered or unexported fields
}

func NewChangerator

func NewChangerator(config *ChangeratorConfig) *Changerator

func (*Changerator) BuildNodeChangeTree

func (t *Changerator) BuildNodeChangeTree(root *v3.Node)

func (*Changerator) Calculatoratron

func (t *Changerator) Calculatoratron() *ChangeStatistics

func (*Changerator) Changerate

func (t *Changerator) Changerate() *whatChangedModel.DocumentChanges

func (*Changerator) Changerify

func (t *Changerator) Changerify(n any) []*v3.Node

func (*Changerator) Cleaneromatic

func (t *Changerator) Cleaneromatic(nodes []*v3.Node) []*v3.Node

func (*Changerator) ClearContextCache

func (c *Changerator) ClearContextCache()

ClearContextCache clears cached lines to free memory

func (*Changerator) DeduplicateAllNodes

func (t *Changerator) DeduplicateAllNodes(root *v3.Node)

DeduplicateAllNodes runs deduplication on all changed nodes in the tree. This is a convenience method that processes the entire node tree.

func (*Changerator) DeduplicateChanges

func (t *Changerator) DeduplicateChanges() []*whatChangedModel.Change

DeduplicateChanges removes duplicate changes using JSONPath + property as the unique key. This prevents the same change from appearing multiple times when a reference is used in multiple locations. Returns a deduplicated array of changes.

func (*Changerator) GenerateHTML

func (t *Changerator) GenerateHTML() (string, error)

GenerateHTML is a convenience method for generating HTML reports with the default renderer.

func (*Changerator) GenerateHTMLWithConfig

func (t *Changerator) GenerateHTMLWithConfig(config *renderer.RenderConfig) (string, error)

GenerateHTMLWithConfig is a convenience method for generating HTML with custom configuration.

func (*Changerator) GenerateMarkdownReport deprecated

func (t *Changerator) GenerateMarkdownReport() string

GenerateMarkdownReport creates a comprehensive markdown report from DocumentChanges.

Deprecated: use GenerateReport with renderer.NewMarkdownRenderer() instead. this method is maintained for backward compatibility but will be removed in a future version.

Usage:

cd := NewChangerator(config)
docChanges := cd.Changerate()
report := cd.GenerateMarkdownReport()

func (*Changerator) GenerateReport

func (t *Changerator) GenerateReport(r renderer.ChangeReportRenderer, outputFormat renderer.OutputFormat) (string, error)

GenerateReport generates a change report using the specified renderer.

func (*Changerator) GenerateReportWithConfig

func (t *Changerator) GenerateReportWithConfig(
	r renderer.ChangeReportRenderer,
	outputFormat renderer.OutputFormat,
	config *renderer.RenderConfig,
) (string, error)

GenerateReportWithConfig generates a change report with custom configuration.

func (*Changerator) GetDeduplicatedStatistics

func (t *Changerator) GetDeduplicatedStatistics() *ChangeStatistics

GetDeduplicatedStatistics returns change statistics based on deduplicated data.

func (*Changerator) GetDoctor

func (t *Changerator) GetDoctor() v3.Doctor

func (*Changerator) PrepareNodesForGraph

func (t *Changerator) PrepareNodesForGraph(root *v3.Node)

func (*Changerator) Prepareotron

func (t *Changerator) Prepareotron(nodes []*v3.Node)

func (*Changerator) Ruleify

func (t *Changerator) Ruleify(left *model.DrDocument)

Ruleify efficiently copies rule results from a left DrDocument to the ChangedNodes in the Changerator. It matches nodes by ID and transfers their rule results.

Parameters:

  • left: The source DrDocument containing nodes with RuleResults

The function modifies the ChangedNodes in-place.

func (*Changerator) TurnOnChangedTree

func (t *Changerator) TurnOnChangedTree(root *v3.Node)

func (*Changerator) Visit

func (t *Changerator) Visit(ctx context.Context, object any)

func (*Changerator) VisitCallback

func (t *Changerator) VisitCallback(ctx context.Context, obj *v3.Callback)

func (*Changerator) VisitComponents

func (t *Changerator) VisitComponents(ctx context.Context, obj *v3.Components)

func (*Changerator) VisitDocument

func (t *Changerator) VisitDocument(ctx context.Context, doc *v3.Document)

func (*Changerator) VisitEncoding

func (t *Changerator) VisitEncoding(ctx context.Context, obj *v3.Encoding)

func (*Changerator) VisitHeader

func (t *Changerator) VisitHeader(ctx context.Context, obj *v3.Header)

func (*Changerator) VisitInfo

func (t *Changerator) VisitInfo(ctx context.Context, obj *v3.Info)
func (t *Changerator) VisitLink(ctx context.Context, obj *v3.Link)

func (*Changerator) VisitMediaType

func (t *Changerator) VisitMediaType(ctx context.Context, obj *v3.MediaType)

func (*Changerator) VisitOAuthFlows

func (t *Changerator) VisitOAuthFlows(ctx context.Context, obj *v3.OAuthFlows)

func (*Changerator) VisitOperation

func (t *Changerator) VisitOperation(ctx context.Context, obj *v3.Operation)

func (*Changerator) VisitParameter

func (t *Changerator) VisitParameter(ctx context.Context, obj *v3.Parameter)

func (*Changerator) VisitPathItem

func (t *Changerator) VisitPathItem(ctx context.Context, obj *v3.PathItem)

func (*Changerator) VisitPaths

func (t *Changerator) VisitPaths(ctx context.Context, obj *v3.Paths)

func (*Changerator) VisitRequestBody

func (t *Changerator) VisitRequestBody(ctx context.Context, obj *v3.RequestBody)

func (*Changerator) VisitResponse

func (t *Changerator) VisitResponse(ctx context.Context, obj *v3.Response)

func (*Changerator) VisitResponses

func (t *Changerator) VisitResponses(ctx context.Context, obj *v3.Responses)

func (*Changerator) VisitSchema

func (t *Changerator) VisitSchema(ctx context.Context, schema *v3.Schema)

func (*Changerator) VisitSecurityScheme

func (t *Changerator) VisitSecurityScheme(ctx context.Context, obj *v3.SecurityScheme)

func (*Changerator) VisitServer

func (t *Changerator) VisitServer(ctx context.Context, obj *v3.Server)

func (*Changerator) VisitTag

func (t *Changerator) VisitTag(ctx context.Context, obj *v3.Tag)

func (*Changerator) VisitXML

func (t *Changerator) VisitXML(ctx context.Context, obj *v3.XML)

type ChangeratorChange

type ChangeratorChange whatChangedModel.Change

type ChangeratorConfig

type ChangeratorConfig struct {
	RightDrDoc      *v3.Document
	LeftDrDoc       *v3.Document
	Doctor          *model.DrDocument
	DocumentChanges *whatChangedModel.DocumentChanges
	Logger          *slog.Logger
	RightDocContent []byte // Raw document content for context extraction
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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