/
model-types.d.ts
120 lines (93 loc) · 4.05 KB
/
model-types.d.ts
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
// Type definitions for code generators
interface IndexMap<T> {
[id: number]: T;
}
interface StringMap<T> {
[id: string]: T;
}
/** A simple type template, the type string contains an easy to parse type */
interface TypeTemplate {
/** the property's data type.
* If this is a string, the format must be 'typeName?[][]...' where typeName has no generic parameters, and the '?' (nullability) and '[][]...' (array dimensions) are optional
*/
type: string | CodeAst.Type;
/** true to require this property in models with optional properties, 'primaryKey' properties are implicitely required */
required?: boolean;
/** default value of the property */
defaultValue?: any;
}
/** Database column meta-data */
interface TypeMetaData {
/** true if this property should be automatically generated (only applies to 'primaryKey: true' properties), false or absent if not */
autoGenerate?: boolean;
/** true if this property is a primary key for the model, false or absent if not */
primaryKey?: boolean;
/** true if the property is const/final/readonly, default false */
readOnly?: boolean;
/** true to require this property in models with optional properties, 'primaryKey' properties are implicitely required */
required?: boolean;
}
/** Type information about a model property */
interface PropInfo {
/** the property's data type */
type: CodeAst.Type;
/** the name of the property */
propName: string;
/** the property's default value (e.g. null, 0, ""), defaults to data type default (i.e. null for objects, 0 for numeric types, false for boolean */
defaultValue?: any;
/** true if the property is const/final/readonly, default false */
readOnly?: boolean;
}
/** Type information about a method parameter */
interface ParameterInfo {
/** the parameter's data type */
type: CodeAst.Type;
/** the name of the parameter */
paramName: string;
/** the parameter's default value (e.g. null, 0, ""), defaults to data type default (i.e. null for objects, 0 for numeric types, false for boolean */
defaultValue?: any;
/** true if the parameter is const/final/readonly, default false */
readOnly?: boolean;
/** true to require this parameter in models with optional properties, 'primaryKey' properties are implicitely required */
required?: boolean;
}
/** Database column definition with meta-data */
interface TypeProperty extends TypeMetaData {
/** the property's data type */
type: CodeAst.Type;
/** default value of the property */
defaultValue?: any;
}
interface NamedProperty extends TypeProperty {
/** the name of the property */
name: string;
}
interface PropertyConversionTemplate {
/** template code can be used to get this property from another object and convert it to a valid value for this model */
toLocal?: string | null;
/** template code can be used to convert the property to a value that can be sent to a web service */
toService?: string | null;
}
/** A database column definition with meta-data paired with a 'server' database column definition with meta-data */
interface DtoProperty extends TypeProperty, PropertyConversionTemplate {
/** if not present, server property type data is copied from this DtoProperty */
server: TypeProperty & { name: string, toLocal?: string | null };
toLocal?: string | null;
toService?: string | null;
}
interface DtoPropertyNamed extends DtoProperty {
/** the name of the property */
name: string;
}
/** A type template and database column meta-data paired with a 'server' type template with database column meta-data and property name */
interface DtoPropertyTemplate extends TypeTemplate, TypeMetaData, PropertyConversionTemplate {
/** if not present, server property type data is copied from this DtoProperty */
server?: TypeTemplate & TypeMetaData & { name?: string, toLocal?: string | null };
}
interface DtoModel {
properties: StringMap<DtoProperty>;
}
interface DtoModelNamed extends DtoModel {
/** the name of the data model */
name: string;
}