1
1
<# // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. #>
2
2
<#@ template debug="true" hostspecific="true" language="C#" #>
3
- <#@ include file="utils.tt" #>
4
3
<#@ output extension="\\" #>
5
4
<#
6
5
CustomT4Host host = (CustomT4Host) Host;
7
6
CodeWriterTypeScript writer = (CodeWriterTypeScript) host.CodeWriter;
8
7
9
8
var model = host.CurrentModel;
10
- var entityTypes = model.GetEntityTypes();
11
- var enumTypes = model.GetEnumTypes();
12
- var complexTypes = model.GetComplexTypes();
13
-
14
- var maxLineLength = 120;
9
+ var typeScriptNamespaces = model.GetTypeScriptNamespaces();
15
10
#>
16
11
// Project: https://github.com/microsoftgraph/msgraph-typescript-typings
17
12
// Definitions by: Microsoft Graph Team <https://github.com/microsoftgraph>
@@ -27,168 +22,13 @@ export as namespace microsoftgraph;
27
22
28
23
export type NullableOption<T> = T | null;
29
24
30
- <#
31
- foreach(var enumType in enumTypes) {
32
- var enumTypeName = enumType.Name.UpperCaseFirstChar();
33
- var enumValues = enumType.GetEnumValues();
34
- var exportTypeLength = "export type".Length + enumTypeName.Length + enumValues.Length + 3;
35
- if (exportTypeLength < maxLineLength) {
36
- #>
37
- export type <#= enumTypeName #> = <#= enumValues #>;
38
- <#
39
- } else {
40
- #>
41
- export type <#= enumTypeName #> =<#
42
- var enums = enumValues.Split('|');
43
- for(var i = 0; i < enums.Length; i++) {
44
- #>
45
-
46
- | <#= enums[i].Trim() #><#
47
- }
48
- #>;
49
- <#
50
- }
51
- }
25
+ <#=typeScriptNamespaces.MainNamespace.ToString()#>
52
26
53
- foreach(var entityType in entityTypes) {
54
- var propCount = entityType.Properties.ToList().Count;
55
- var entityTypeName = entityType.Name.UpperCaseFirstChar();
56
- if(propCount == 0 && entityTypeName[0] == 'I') {
57
- #>
58
- // tslint:disable-next-line: interface-name no-empty-interface
59
27
<#
60
- } else if (entityTypeName[0] == 'I') {
28
+ foreach (var subNamespace in typeScriptNamespaces.SubNamespaces)
29
+ {
61
30
#>
62
- // tslint:disable-next-line: interface-name
31
+ <#=subNamespace.Value.ToString()#>
63
32
<#
64
- } else if(propCount == 0) {
65
- #>
66
- // tslint:disable-next-line: no-empty-interface
67
- <#
68
- }
69
- #>
70
- export interface <#= entityTypeName #><#
71
- if (entityType.Base != null) {
72
- #>
73
- extends <#= entityType.Base.Name.UpperCaseFirstChar() #><#
74
- }
75
- #> {<#
76
- if(propCount == 0){
77
- #>}
78
- <#
79
- } else {
80
- #>
81
-
82
- <#
83
- foreach(var prop in entityType.Properties.ToList()) {
84
- if (prop.LongDescription != null || prop.Description != null) {
85
- List<string> multiLineDescriptions = Utils.splitString(prop.GetSanitizedLongDescription(), maxLineLength);
86
- if(multiLineDescriptions.Count() == 1) {
87
- #>
88
- // <#= multiLineDescriptions.First() #>
89
- <#
90
- } else {
91
- #>
92
- /**
93
- <#
94
- foreach(var descriptionLine in multiLineDescriptions) {
95
- #>
96
- * <#= descriptionLine #>
97
- <#
98
- }
99
- #>
100
- */
101
- <#
102
- }
103
- }
104
- #>
105
- <#
106
- if(prop.IsNullable) {
107
- #>
108
- <#= prop.Name #>?: NullableOption<<#= prop.GetTypeString() #>>;
109
- <#
110
- } else {
111
- #>
112
- <#= prop.Name #>?: <#= prop.GetTypeString() #>;
113
- <#
114
- }
115
- #>
116
- <#
117
- }
118
- #>
119
33
}
120
- <#
121
- }
122
- }
123
-
124
- foreach(var complexType in complexTypes) {
125
- var propCount = complexType.Properties.ToList().Count;
126
- var complexTypeName = complexType.Name.UpperCaseFirstChar();
127
- if(propCount == 0 && complexTypeName[0] == 'I') {
128
- #>
129
- // tslint:disable-next-line: interface-name no-empty-interface
130
- <#
131
- } else if (complexTypeName[0] == 'I') {
132
- #>
133
- // tslint:disable-next-line: interface-name
134
- <#
135
- } else if(propCount == 0) {
136
- #>
137
- // tslint:disable-next-line: no-empty-interface
138
- <#
139
- }
140
- #>
141
- export interface <#= complexTypeName #><#
142
- if (complexType.Base != null) {
143
- #>
144
- extends <#= complexType.Base.Name.UpperCaseFirstChar() #><#
145
- }
146
- #> {<#
147
- if(propCount == 0){
148
- #>}
149
- <#
150
- } else {
151
- #>
152
-
153
- <#
154
- foreach(var prop in complexType.Properties) {
155
- if (prop.LongDescription != null || prop.Description != null) {
156
- List<string> multiLineDescriptions = Utils.splitString(prop.GetSanitizedLongDescription(), maxLineLength);
157
- if(multiLineDescriptions.Count() == 1) {
158
- #>
159
- // <#= multiLineDescriptions.First() #>
160
- <#
161
- } else {
162
- #>
163
- /**
164
- <#
165
- foreach(var descriptionLine in multiLineDescriptions) {
166
- #>
167
- * <#= descriptionLine #>
168
- <#
169
- }
170
- #>
171
- */
172
- <#
173
- }
174
- }
175
- #>
176
- <#
177
- if(prop.IsNullable) {
178
- #>
179
- <#= prop.Name #>?: NullableOption<<#= prop.GetTypeString() #>>;
180
- <#
181
- } else {
182
- #>
183
- <#= prop.Name #>?: <#= prop.GetTypeString() #>;
184
- <#
185
- }
186
- #>
187
- <#
188
- }
189
- #>
190
- }
191
- <#
192
- }
193
- }
194
34
#>
0 commit comments