Feat v0.9.2 converter consolidation (#75)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #75.
This commit is contained in:
2026-04-03 14:32:14 +00:00
committed by xcaliber
parent d03dfe502f
commit 983d761bbe
24 changed files with 362 additions and 479 deletions

25
server/models/snapshot.go Normal file
View File

@@ -0,0 +1,25 @@
package models
import (
"encoding/json"
"fmt"
)
// ParseSnapshotStages parses a version snapshot into a slice of
// WorkflowStage. It handles both the wrapped format
// {"stages": [...], "workflow": {...}} and the legacy flat array [...].
func ParseSnapshotStages(raw json.RawMessage) ([]WorkflowStage, error) {
// Try wrapped format first
var wrapped struct {
Stages []WorkflowStage `json:"stages"`
}
if err := json.Unmarshal(raw, &wrapped); err == nil && len(wrapped.Stages) > 0 {
return wrapped.Stages, nil
}
// Fallback to flat array
var stages []WorkflowStage
if err := json.Unmarshal(raw, &stages); err != nil {
return nil, fmt.Errorf("corrupt version snapshot: %w", err)
}
return stages, nil
}