package analytics

import "github.com/nexuscrm/shared/pkg/models"

// CRTWarningCode and CRTWarning are type aliases onto the shared models
// package. They live in models (not analytics) so models.ReportResult can
// carry a []CRTWarning without a models → analytics import cycle. The
// aliases keep the existing analytics-local call sites (synthesizer, tests)
// compiling unchanged.
type (
	CRTWarningCode = models.CRTWarningCode
	CRTWarning     = models.CRTWarning
)

const (
	WarnCRTNestedUnsupported   CRTWarningCode = "crt_nested_unsupported"
	WarnCRTJoinDepthExceeded   CRTWarningCode = "crt_join_depth_exceeded"
	WarnCRTJoinParseFailed     CRTWarningCode = "crt_join_parse_failed"
	WarnCRTSectionsParseFailed CRTWarningCode = "crt_sections_parse_failed"
	WarnCRTAnchorFKMissing     CRTWarningCode = "crt_anchor_fk_missing"
	WarnCRTAnchorObjectMissing CRTWarningCode = "crt_anchor_object_missing"
	WarnCRTColumnUnresolved    CRTWarningCode = "crt_column_unresolved"
	WarnCRTBaseObjectMissing   CRTWarningCode = "crt_base_object_missing"

	// Retry-path warning codes (populated when query retry logic drops fields/criteria)
	WarnReportSelectFieldsDropped CRTWarningCode = "report_select_fields_dropped"
	WarnReportCriterionDropped    CRTWarningCode = "report_criterion_dropped"
	WarnReportAllCriteriaDropped  CRTWarningCode = "report_all_criteria_dropped"

	// Lookup filter warning code (populated when lookup field resolution fails)
	WarnReportLookupFilterDropped CRTWarningCode = "report_lookup_filter_dropped"
)

// allCRTWarningCodes is used by property tests to assert that any emitted
// warning code is a member of the closed set declared above.
var allCRTWarningCodes = map[CRTWarningCode]struct{}{
	WarnCRTNestedUnsupported:      {},
	WarnCRTJoinDepthExceeded:      {},
	WarnCRTJoinParseFailed:        {},
	WarnCRTSectionsParseFailed:    {},
	WarnCRTAnchorFKMissing:        {},
	WarnCRTAnchorObjectMissing:    {},
	WarnCRTColumnUnresolved:       {},
	WarnCRTBaseObjectMissing:      {},
	WarnReportSelectFieldsDropped: {},
	WarnReportCriterionDropped:    {},
	WarnReportAllCriteriaDropped:  {},
	WarnReportLookupFilterDropped: {},
}

