/
types.go
428 lines (367 loc) · 8.56 KB
/
types.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
package relmod
type App struct {
AppName []string
AppLongName string
AppDocstring string
}
type Mixin struct {
AppName []string
MixinName []string
}
type Endpoint struct {
AppName []string
EpName string
EpLongName string
EpDocstring string
EpEvent EndpointEvent `arrai:",zeroempty"`
Rest Rest `arrai:",zeroempty"`
}
type EndpointEvent struct {
AppName EndpointEventAppName
EventName string
}
type EndpointEventAppName struct {
Part []string
}
type QueryParam struct {
Name string
Type interface{} // Type*
}
// Backwards compatible.
// TODO: Design new structure.
type Rest struct {
Method string // GET, PUT, POST, DELETE, PATCH
Path string
QueryParam []QueryParam `arrai:"query_param,omitempty"`
URLParam []QueryParam `arrai:"url_param,omitempty"`
}
type Param struct {
AppName []string
EpName string
ParamName string
ParamLoc string // enum
ParamIndex int
ParamType interface{} // Type*
ParamOpt bool
}
type Statement struct {
AppName []string
EpName string
StmtIndex []int
StmtParent StatementParent `arrai:",zeroempty"`
StmtAction string `arrai:",zeroempty"`
StmtCall map[string]interface{} `arrai:",zeroempty"`
StmtCond map[string]interface{} `arrai:",zeroempty"`
StmtLoop map[string]interface{} `arrai:",zeroempty"`
StmtLoopN map[string]interface{} `arrai:",zeroempty"`
StmtForeach map[string]interface{} `arrai:",zeroempty"`
StmtAlt map[string]interface{} `arrai:",zeroempty"`
StmtGroup map[string]interface{} `arrai:",zeroempty"`
StmtRet StatementReturn `arrai:",zeroempty"`
}
type StatementParent struct {
AppName []string
EpName string
StmtIndex int
}
type StatementReturn struct {
Status string
Attr StatementReturnAttrs
Type interface{} // Type*
}
type StatementReturnAttrs struct {
Modifier []string
Nvp map[string]interface{}
}
type Type struct {
AppName []string
TypeName string
TypeDocstring string
TypeOpt bool
}
type TypePrimitive struct {
Primitive string
}
type TypeTuple struct {
Tuple interface{} // TODO
}
type TypeRef struct {
AppName []string
TypePath []string
// TODO: Maybe add an optional fieldName field for field refs
}
type TypeSet struct {
Set interface{} // Type*
}
type TypeSequence struct {
Sequence interface{} // Type*
}
type Table struct {
AppName []string
TypeName string
Pk []string
}
type Enum struct {
AppName []string
EnumItems map[string]int64
TypeName string
}
type Alias struct {
AppName []string
TypeName string
AliasType interface{} // Type*
}
type Event struct {
AppName []string
EventName string
}
type Field struct {
AppName []string
TypeName string
FieldName string
FieldOpt bool
FieldType interface{} // Type*
FieldConstraint FieldConstraint `arrai:",zeroempty"`
}
type FieldConstraint struct {
Length FieldConstraintLength
Precision int32
Scale int32
}
type FieldConstraintLength struct {
Min int64
Max int64
}
type View struct {
AppName []string
ViewName string
ViewType interface{} // Type*
}
type SourceContext struct {
File string
Start Location
End Location
}
type Location struct {
Line int
Col int
}
// ANNOTATIONS
type AppAnnotation struct {
AppName []string
AppAnnoName string
AppAnnoValue interface{} // string, number, array of self
}
type MixinAnnotation struct {
AppName []string
MixinName []string
MixinAnnoName string
MixinAnnoValue interface{} // string, number, array of self
}
type EndpointAnnotation struct {
AppName []string
EpName string
EpAnnoName string
EpAnnoValue interface{} // string, number, array of self
}
type ParamAnnotation struct {
AppName []string
EpName string
ParamName string
ParamLoc string // enum
ParamIndex int
ParamAnnoName string
ParamAnnoValue interface{} // string, number, array of self
}
type StatementAnnotation struct {
AppName []string
EpName string
StmtAnnoName string
StmtAnnoValue interface{} // string, number, array of self
StmtIndex []int
}
type EventAnnotation struct {
AppName []string
EventName string
EventAnnoName string
EventAnnoValue interface{} // string, number, array of self
}
type TypeAnnotation struct {
AppName []string
TypeName string
TypeAnnoName string
TypeAnnoValue interface{} // string, number, array of self
}
type FieldAnnotation struct {
AppName []string
TypeName string
FieldName string
FieldAnnoName string
FieldAnnoValue interface{} // string, number, array of self
}
type ViewAnnotation struct {
AppName []string
ViewName string
ViewAnnoName string
ViewAnnoValue interface{} // string, number, array of self
}
// TAGS
type AppTag struct {
AppName []string
AppTag string
}
type MixinTag struct {
AppName []string
MixinName []string
MixinTag string
}
type EndpointTag struct {
AppName []string
EpName string
EpTag string
}
type ParamTag struct {
AppName []string
EpName string
ParamName string
ParamLoc string // enum
ParamIndex int
ParamTag string
}
type StatementTag struct {
AppName []string
EpName string
StmtIndex []int
StmtTag string
}
type EventTag struct {
AppName []string
EventName string
EventTag string
}
type TypeTag struct {
AppName []string
TypeName string
TypeTag string
}
type FieldTag struct {
AppName []string
TypeName string
FieldName string
FieldTag string
}
type ViewTag struct {
AppName []string
ViewName string
ViewTag string
}
// SOURCE CONTEXTS
type AppContext struct {
AppName []string
AppSrc SourceContext
AppSrcs []SourceContext
}
type MixinContext struct {
AppName []string
MixinName []string
MixinSrc SourceContext
MixinSrcs []SourceContext
}
type EndpointContext struct {
AppName []string
EpName string
EpSrc SourceContext
EpSrcs []SourceContext
}
type ParamContext struct {
AppName []string
EpName string
ParamName string
ParamLoc string // enum
ParamIndex int
ParamSrc SourceContext
ParamSrcs []SourceContext
}
type StatementContext struct {
AppName []string
EpName string
StmtIndex []int
StmtSrc SourceContext
StmtSrcs []SourceContext
}
type EventContext struct {
AppName []string
EventName string
EventSrc SourceContext
EventSrcs []SourceContext
}
type TypeContext struct {
AppName []string
TypeName string
TypeSrc SourceContext
TypeSrcs []SourceContext
}
type FieldContext struct {
AppName []string
TypeName string
FieldName string
FieldSrc SourceContext
FieldSrcs []SourceContext
}
type ViewContext struct {
AppName []string
ViewName string
ViewSrc SourceContext
ViewSrcs []SourceContext
}
// SCHEMA
type Annotations struct {
App []AppAnnotation `arrai:",unordered"`
Mixin []MixinAnnotation `arrai:",unordered"`
Ep []EndpointAnnotation `arrai:",unordered"`
Param []ParamAnnotation `arrai:",unordered"`
Stmt []StatementAnnotation `arrai:",unordered"`
Event []EventAnnotation `arrai:",unordered"`
Type []TypeAnnotation `arrai:",unordered"`
Field []FieldAnnotation `arrai:",unordered"`
View []ViewAnnotation `arrai:",unordered"`
}
type Tags struct {
App []AppTag `arrai:",unordered"`
Mixin []MixinTag `arrai:",unordered"`
Ep []EndpointTag `arrai:",unordered"`
Param []ParamTag `arrai:",unordered"`
Stmt []StatementTag `arrai:",unordered"`
Event []EventTag `arrai:",unordered"`
Type []TypeTag `arrai:",unordered"`
Field []FieldTag `arrai:",unordered"`
View []ViewTag `arrai:",unordered"`
}
type SourceContexts struct {
App []AppContext `arrai:",unordered"`
Mixin []MixinContext `arrai:",unordered"`
Ep []EndpointContext `arrai:",unordered"`
Param []ParamContext `arrai:",unordered"`
Stmt []StatementContext `arrai:",unordered"`
Event []EventContext `arrai:",unordered"`
Type []TypeContext `arrai:",unordered"`
Field []FieldContext `arrai:",unordered"`
View []ViewContext `arrai:",unordered"`
}
type Schema struct {
App []App `arrai:",unordered"`
Mixin []Mixin `arrai:",unordered"`
Ep []Endpoint `arrai:",unordered"`
Param []Param `arrai:",unordered"`
Stmt []Statement `arrai:",unordered"`
Event []Event `arrai:",unordered"`
Type []Type `arrai:",unordered"`
Field []Field `arrai:",unordered"`
Table []Table `arrai:",unordered"`
Alias []Alias `arrai:",unordered"`
Enum []Enum `arrai:",unordered"`
View []View `arrai:",unordered"`
Anno Annotations
Tag Tags
Src SourceContexts
}