-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom_gen.go
76 lines (65 loc) · 1.99 KB
/
dom_gen.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// generated code
package dom
import (
"github.com/mb0/xelf/lit"
"github.com/mb0/xelf/typ"
)
// Bit is a bit set used for a number of field options.
type Bit uint64
const (
BitOpt Bit = 1 << iota
BitPK
BitIdx
BitUniq
BitOrdr
BitAuto
BitRO
)
// Elem holds additional information for either constants or type paramters.
type Elem struct {
Bits Bit `json:"bits,omitempty"`
Extra *lit.Dict `json:"extra,omitempty"`
Ref string `json:"ref,omitempty"`
}
// Index represents a record model index, mainly used for databases.
type Index struct {
Name string `json:"name,omitempty"`
Keys []string `json:"keys"`
Unique bool `json:"unique,omitempty"`
}
// Common represents the common name and version of model, schema or project nodes.
type Common struct {
Name string `json:"name,omitempty"`
Extra *lit.Dict `json:"extra,omitempty"`
}
// Object holds data specific to object types for grouping.
type Object struct {
Indices []*Index `json:"indices,omitempty"`
OrderBy []string `json:"orderby,omitempty"`
}
// Model represents either a bits, enum or record type and has extra domain information.
type Model struct {
Common
Type typ.Type `json:"type"`
Elems []*Elem `json:"elems,omitempty"`
Object *Object `json:"object,omitempty"`
Schema string `json:"schema,omitempty"`
}
// Schema is a namespace for models.
type Schema struct {
Common
Path string `json:"path,omitempty"`
Use []string `json:"use,omitempty"`
Models []*Model `json:"models"`
}
// Project is a collection of schemas and is the central place for any extra project configuration.
//
// The schema definition can either be declared as part of the project file, or included from an
// external schema file. Includes should have syntax to filtering the included schema definition.
//
// Extra setting, usually include, but are not limited to, targets and output paths for code
// generation, paths to look for the project's manifest and history.
type Project struct {
Common
Schemas []*Schema `json:"schemas"`
}