feat: CheckSnapshots y UpdateSnapshot en fn_operations library

Añade UpdateTypeSnapshot al store, CheckSnapshots para comparar snapshots
locales vs registry (up_to_date/outdated/missing), y UpdateSnapshot para
re-snapshot con retorno de old/new para diffing.
This commit is contained in:
2026-03-28 13:41:35 +01:00
parent 762fcbeb58
commit 0095de2ce7
2 changed files with 102 additions and 0 deletions
+14
View File
@@ -58,6 +58,20 @@ func (db *DB) InsertTypeSnapshot(ts *TypeSnapshot) error {
return err
}
// UpdateTypeSnapshot replaces an existing snapshot with a new version.
func (db *DB) UpdateTypeSnapshot(ts *TypeSnapshot) error {
if ts.SnappedAt.IsZero() {
ts.SnappedAt = time.Now().UTC()
}
_, err := db.conn.Exec(`
UPDATE types_snapshot SET version=?, lang=?, algebraic=?, definition=?, description=?, snapped_at=?
WHERE id=?`,
ts.Version, ts.Lang, ts.Algebraic, ts.Definition, ts.Description,
ts.SnappedAt.Format(time.RFC3339), ts.ID,
)
return err
}
// GetTypeSnapshot returns a type snapshot by ID.
func (db *DB) GetTypeSnapshot(id string) (*TypeSnapshot, error) {
row := db.conn.QueryRow("SELECT id, version, lang, algebraic, definition, description, snapped_at FROM types_snapshot WHERE id = ?", id)