@@ -10,28 +10,44 @@ export type KindLink = {}
10
10
export type KindUnion = { }
11
11
export type KindStruct = { }
12
12
export type KindEnum = { }
13
- export type TypeBool = { kind : "bool" }
14
- export type TypeString = { kind : "string" }
15
- export type TypeBytes = {
16
- kind : "bytes"
17
- representation ?: BytesRepresentation
13
+
14
+ export type TypeDefn =
15
+ { bool : TypeDefnBool }
16
+ | { string : TypeDefnString }
17
+ | { bytes : TypeDefnBytes }
18
+ | { int : TypeDefnInt }
19
+ | { float : TypeDefnFloat }
20
+ | { map : TypeDefnMap }
21
+ | { list : TypeDefnList }
22
+ | { link : TypeDefnLink }
23
+ | { union : TypeDefnUnion }
24
+ | { struct : TypeDefnStruct }
25
+ | { enum : TypeDefnEnum }
26
+ | { unit : TypeDefnUnit }
27
+ | { any : TypeDefnAny }
28
+ | { copy : TypeDefnCopy }
29
+ | { null : TypeDefnNull } // TODO: not in schema-schema, what do?
30
+
31
+ export type TypeDefnBool = { }
32
+ export type TypeDefnString = { }
33
+ export type TypeDefnBytes = {
34
+ representation ?: BytesRepresentation // TODO: not optional in schema-schema
18
35
}
19
36
export type BytesRepresentation =
20
37
{ bytes : BytesRepresentation_Bytes }
21
38
| { advanced : AdvancedDataLayoutName }
22
39
export type BytesRepresentation_Bytes = { }
23
- export type TypeInt = { kind : "int" }
24
- export type TypeFloat = { kind : "float" }
25
- export type TypeNull = { kind : "null" }
26
- export type TypeMap = {
27
- kind : "map"
40
+ export type TypeDefnInt = { }
41
+ export type TypeDefnFloat = { }
42
+ export type TypeDefnNull = { } // TODO: not in schema-schema, what do?
43
+ export type TypeDefnMap = {
28
44
keyType : TypeName
29
- valueType : TypeTerm
45
+ valueType : TypeNameOrInlineDefn
30
46
valueNullable ?: KindBool
31
47
representation ?: MapRepresentation
32
48
}
33
49
export type MapRepresentation =
34
- { map : MapRepresentation_Map }
50
+ { map : MapRepresentation_Map } // TODO: not in schema-schema - put it there
35
51
| { stringpairs : MapRepresentation_StringPairs }
36
52
| { listpairs : MapRepresentation_ListPairs }
37
53
| { advanced : AdvancedDataLayoutName }
@@ -41,63 +57,65 @@ export type MapRepresentation_StringPairs = {
41
57
entryDelim : KindString
42
58
}
43
59
export type MapRepresentation_ListPairs = { }
44
- export type TypeList = {
45
- kind : "list"
46
- valueType : TypeTerm
60
+ export type TypeDefnList = {
61
+ valueType : TypeNameOrInlineDefn
47
62
valueNullable ?: KindBool
48
63
representation ?: ListRepresentation
49
64
}
50
65
export type ListRepresentation =
51
- { list : ListRepresentation_List }
66
+ { list : ListRepresentation_List } // TODO: not in schema-schema - put it there?
52
67
| { advanced : AdvancedDataLayoutName }
53
68
export type ListRepresentation_List = { }
54
- export type TypeLink = {
55
- kind : "link"
69
+ export type TypeDefnLink = {
56
70
expectedType ?: KindString
57
71
}
58
- export type TypeUnion = {
59
- kind : "union"
72
+ export type TypeDefnUnion = {
73
+ members : UnionMember [ ]
60
74
representation : UnionRepresentation
61
75
}
76
+ export type UnionMember =
77
+ TypeName
78
+ | UnionMemberInlineDefn
79
+ export type UnionMemberInlineDefn =
80
+ { link : TypeDefnLink }
62
81
export type UnionRepresentation =
63
82
{ kinded : UnionRepresentation_Kinded }
64
83
| { keyed : UnionRepresentation_Keyed }
65
84
| { envelope : UnionRepresentation_Envelope }
66
85
| { inline : UnionRepresentation_Inline }
67
86
| { stringprefix : UnionRepresentation_StringPrefix }
68
87
| { bytesprefix : UnionRepresentation_BytesPrefix }
69
- export type UnionRepresentation_Kinded = { [ k in RepresentationKind ] ?: KindedType }
70
- export type KindedType = TypeName | TypeLink
71
- export type UnionRepresentation_Keyed = { [ k in KindString ] : TypeName }
88
+ export type UnionRepresentation_Kinded = { [ k in RepresentationKind ] ?: UnionMember }
89
+ export type UnionRepresentation_Keyed = { [ k in KindString ] : UnionMember }
72
90
export type UnionRepresentation_Envelope = {
73
91
discriminantKey : KindString
74
92
contentKey : KindString
75
- discriminantTable : { [ k in KindString ] : TypeName }
93
+ discriminantTable : { [ k in KindString ] : UnionMember }
76
94
}
77
95
export type UnionRepresentation_Inline = {
78
96
discriminantKey : KindString
79
- discriminantTable : { [ k in KindString ] : TypeName }
97
+ discriminantTable : { [ k in HexString ] : TypeName }
80
98
}
99
+ export type HexString = string
81
100
export type UnionRepresentation_StringPrefix = { [ k in KindString ] : TypeName }
82
101
export type UnionRepresentation_BytesPrefix = { [ k in KindString ] : TypeName }
83
- export type TypeStruct = {
84
- kind : "struct"
102
+ export type TypeDefnStruct = {
85
103
fields : { [ k in FieldName ] : StructField }
86
104
representation ?: StructRepresentation
87
105
}
88
106
export type FieldName = string
89
107
export type StructField = {
90
- type : TypeTerm
108
+ type : TypeNameOrInlineDefn
91
109
optional ?: KindBool
92
110
nullable ?: KindBool
93
111
}
94
- export type TypeTerm =
112
+ export type TypeNameOrInlineDefn =
95
113
TypeName
96
114
| InlineDefn
97
115
export type InlineDefn =
98
- TypeMap
99
- | TypeList
100
- | TypeLink
116
+ { map : TypeDefnMap }
117
+ | { list : TypeDefnList }
118
+ | { link : TypeDefnLink }
101
119
export type StructRepresentation =
102
120
{ map : StructRepresentation_Map }
103
121
| { tuple : StructRepresentation_Tuple }
@@ -123,41 +141,36 @@ export type StructRepresentation_StringJoin = {
123
141
fieldOrder ?: FieldName [ ]
124
142
}
125
143
export type StructRepresentation_ListPairs = { }
126
- export type TypeEnum = {
127
- kind : "enum"
128
- members : { [ k in EnumValue ] : KindNull }
144
+ export type TypeDefnEnum = {
145
+ members : EnumMember [ ]
129
146
representation : EnumRepresentation
130
147
}
131
- export type EnumValue = string
148
+ export type EnumMember = string
132
149
export type EnumRepresentation =
133
150
{ string : EnumRepresentation_String }
134
151
| { int : EnumRepresentation_Int }
135
- export type EnumRepresentation_String = { [ k in EnumValue ] : KindString }
136
- export type EnumRepresentation_Int = { [ k in EnumValue ] : KindInt }
137
- export type TypeCopy = {
138
- kind : "copy"
152
+ export type EnumRepresentation_String = { [ k in EnumMember ] : KindString }
153
+ export type EnumRepresentation_Int = { [ k in EnumMember ] : KindInt }
154
+ export type TypeDefnCopy = {
139
155
fromType : TypeName
140
156
}
157
+ export type TypeDefnUnit = {
158
+ representation : UnitRepresentation
159
+ }
160
+ export type UnitRepresentation =
161
+ "null"
162
+ | "true"
163
+ | "false"
164
+ | "emptymap"
165
+ export type TypeDefnAny = { }
141
166
export type TypeName = string
142
- export type SchemaMap = { [ k in TypeName ] : Type }
143
- export type AdvancedDataLayoutName = string
144
167
export type Schema = {
145
- types : SchemaMap
146
- }
147
- export type Type =
148
- TypeBool
149
- | TypeString
150
- | TypeBytes
151
- | TypeInt
152
- | TypeFloat
153
- | TypeNull
154
- | TypeMap
155
- | TypeList
156
- | TypeLink
157
- | TypeUnion
158
- | TypeStruct
159
- | TypeEnum
160
- | TypeCopy
168
+ types : { [ k in TypeName ] : TypeDefn }
169
+ advanced ?: AdvancedDataLayoutMap
170
+ }
171
+ export type AdvancedDataLayoutName = string
172
+ export type AdvancedDataLayoutMap = { [ k in AdvancedDataLayoutName ] : AdvancedDataLayout }
173
+ export type AdvancedDataLayout = { }
161
174
export type TypeKind =
162
175
KindBool
163
176
| KindString
@@ -176,7 +189,7 @@ export type RepresentationKind =
176
189
| "bytes"
177
190
| "int"
178
191
| "float"
179
- | "null"
192
+ | "null" // TODO: not in schema-schema, wot do?
180
193
| "map"
181
194
| "list"
182
195
| "link"
0 commit comments