-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
value.go
51 lines (39 loc) · 1.01 KB
/
value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package datamodel
import (
"cuelang.org/go/cue"
"github.com/hofstadter-io/hof/lib/hof"
)
type Value struct {
*hof.Node[Value]
// evaluated & concrete (for code gen, later)
cval cue.Value
data map[string]any
// If configured, order fields via CUE
// for stable code generation, but better ux
// $hof: datamodel: ordered: "path.to.struct"
// "." is this struct
// ... Do we even need to save this, or create on demand?
// ... users can always create it themselves in CUE
// ... this seems like the better way to go
// ... make DM concrete, then make Ordered*
// OrderedValues []cue.Value
// maybe we expose an iterator?
// curr & lineage
Snapshot *Snapshot
// history is only on the most current Value
history []*Snapshot
}
func (V *Value) Status() string {
if len(V.history) == 0 {
return "no-history"
}
// TODO... dirty or version
if V.hasDiffR() {
return "dirty"
}
return "ok"
}
// History returns the full history for a Value
func (V *Value) History() []*Snapshot {
return V.history
}