package engine

type VulnerabilityBuilderTransition int

const (
	// YetToBeChecked is a query that has not been checked for transition type
	YetToBeChecked VulnerabilityBuilderTransition = iota
	// NonGracefullyTransition is a query that does not transition to the new version being able to get the old version
	NonGracefullyTransition VulnerabilityBuilderTransition = iota
	// TransitionWithoutChanges is a transition where no changes are made to the query
	TransitionWithoutChanges VulnerabilityBuilderTransition = iota
	// AddedSearchValue is a transition where only the search value is added to the query
	AddedSearchValue VulnerabilityBuilderTransition = iota
	// AddedSearchLine is a transition where only the search line is added the query
	AddedSearchLine VulnerabilityBuilderTransition = iota
	// AddedSearchValueAndAddedSearchLine is a transition where both the search value and search line are added to the query
	AddedSearchValueAndAddedSearchLine VulnerabilityBuilderTransition = iota
)

type TransitionQueryInfoChangeList struct {
	SimilarityIDChangeList []TransitionQueryInfo `yaml:"similarityIDChangeList"`
}

type TransitionQueryInfo struct {
	QueryID     string                         `yaml:"queryId"`
	QueryName   string                         `yaml:"queryName"`
	Transition  VulnerabilityBuilderTransition `yaml:"change"`
	Observation string                         `yaml:"observation"`
}

func checkQueryTransitionType(changeList map[string]TransitionQueryInfo, queryID string) VulnerabilityBuilderTransition {
	if change, ok := changeList[queryID]; ok {
		return change.Transition
	}
	return YetToBeChecked
}
