package state import ( "time" "gitea.maximumdirect.net/eric/weatherreporter/internal/briefing" "gitea.maximumdirect.net/eric/weatherreporter/internal/report" "gitea.maximumdirect.net/eric/weatherreporter/internal/timeutil" "gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata" ) const MetadataSchemaVersion = "weatherreporter.metadata.v1" type Metadata struct { SchemaVersion string `json:"schemaVersion"` RunID string `json:"runId"` MetadataPath string `json:"-"` ReportID report.ID `json:"reportId"` Variant string `json:"variant,omitempty"` PromptID string `json:"promptId"` GeneratedAt time.Time `json:"generatedAt"` Timezone string `json:"timezone"` ValidPeriod timeutil.Period `json:"validPeriod"` Location *briefing.LocationContext `json:"location,omitempty"` SourceLocationID string `json:"sourceLocationId,omitempty"` SourceLocation string `json:"sourceLocation,omitempty"` Sources []briefing.SourceMetadata `json:"sources,omitempty"` SourceWarnings []weatherdata.SourceWarning `json:"sourceWarnings,omitempty"` ModuleSnapshotPath string `json:"moduleSnapshotPath"` DataPackagePath string `json:"dataPackagePath"` PreflightPath string `json:"preflightPath"` NotificationPath string `json:"notificationPath,omitempty"` RenderedReportPath string `json:"renderedReportPath,omitempty"` } func BuildMetadataFromBriefingMetadata(resolved report.Resolved, briefingMetadata briefing.Metadata, paths ArtifactPaths) Metadata { metadata := resolved.Metadata() return Metadata{ SchemaVersion: MetadataSchemaVersion, RunID: metadata.RunID, MetadataPath: paths.Metadata, ReportID: metadata.ReportID, Variant: briefingMetadata.Variant, PromptID: metadata.PromptID, GeneratedAt: metadata.GeneratedAt, Timezone: metadata.Timezone, ValidPeriod: metadata.ValidPeriod, Location: copyLocation(briefingMetadata.Location), SourceLocationID: briefingMetadata.SourceLocationID, SourceLocation: briefingMetadata.SourceLocation, Sources: briefingMetadata.Sources, SourceWarnings: briefingMetadata.SourceWarnings, ModuleSnapshotPath: paths.ModuleSnapshot, DataPackagePath: paths.DataPackage, PreflightPath: paths.Preflight, RenderedReportPath: paths.RenderedReport, } } func copyLocation(location *briefing.LocationContext) *briefing.LocationContext { if location == nil { return nil } copied := *location return &copied }