@azure-tools/rlc-common 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierignore +1 -0
  3. package/.prettierrc +7 -0
  4. package/.rush/temp/package-deps_build.json +53 -0
  5. package/.rush/temp/shrinkwrap-deps.json +147 -0
  6. package/CHANGELOG.md +61 -0
  7. package/CONTRIBUTING.md +30 -0
  8. package/README.md +3 -0
  9. package/dist/buildClient.js +268 -0
  10. package/dist/buildClient.js.map +1 -0
  11. package/dist/buildClientDefinitions.js +160 -0
  12. package/dist/buildClientDefinitions.js.map +1 -0
  13. package/dist/buildIndexFile.js +170 -0
  14. package/dist/buildIndexFile.js.map +1 -0
  15. package/dist/buildIsUnexpectedHelper.js +220 -0
  16. package/dist/buildIsUnexpectedHelper.js.map +1 -0
  17. package/dist/buildMethodShortcuts.js +50 -0
  18. package/dist/buildMethodShortcuts.js.map +1 -0
  19. package/dist/buildObjectTypes.js +286 -0
  20. package/dist/buildObjectTypes.js.map +1 -0
  21. package/dist/buildPaginateHelper.js +30 -0
  22. package/dist/buildPaginateHelper.js.map +1 -0
  23. package/dist/buildParameterTypes.js +315 -0
  24. package/dist/buildParameterTypes.js.map +1 -0
  25. package/dist/buildPollingHelper.js +21 -0
  26. package/dist/buildPollingHelper.js.map +1 -0
  27. package/dist/buildResponseTypes.js +135 -0
  28. package/dist/buildResponseTypes.js.map +1 -0
  29. package/dist/buildSchemaType.js +65 -0
  30. package/dist/buildSchemaType.js.map +1 -0
  31. package/dist/buildSerializeHelper.js +35 -0
  32. package/dist/buildSerializeHelper.js.map +1 -0
  33. package/dist/buildTopLevelIndexFile.js +48 -0
  34. package/dist/buildTopLevelIndexFile.js.map +1 -0
  35. package/dist/helpers/nameConstructors.js +41 -0
  36. package/dist/helpers/nameConstructors.js.map +1 -0
  37. package/dist/helpers/nameUtils.js +196 -0
  38. package/dist/helpers/nameUtils.js.map +1 -0
  39. package/dist/helpers/operationHelpers.js +103 -0
  40. package/dist/helpers/operationHelpers.js.map +1 -0
  41. package/dist/helpers/pathUtils.js +13 -0
  42. package/dist/helpers/pathUtils.js.map +1 -0
  43. package/dist/helpers/schemaHelpers.js +27 -0
  44. package/dist/helpers/schemaHelpers.js.map +1 -0
  45. package/dist/helpers/shortcutMethods.js +46 -0
  46. package/dist/helpers/shortcutMethods.js.map +1 -0
  47. package/dist/index.js +45 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/interfaces.js +18 -0
  50. package/dist/interfaces.js.map +1 -0
  51. package/dist/metadata/buildApiExtractorConfig.js +56 -0
  52. package/dist/metadata/buildApiExtractorConfig.js.map +1 -0
  53. package/dist/metadata/buildESLintConfig.js +33 -0
  54. package/dist/metadata/buildESLintConfig.js.map +1 -0
  55. package/dist/metadata/buildLicenseFile.js +41 -0
  56. package/dist/metadata/buildLicenseFile.js.map +1 -0
  57. package/dist/metadata/buildPackageFile.js +274 -0
  58. package/dist/metadata/buildPackageFile.js.map +1 -0
  59. package/dist/metadata/buildReadmeFile.js +170 -0
  60. package/dist/metadata/buildReadmeFile.js.map +1 -0
  61. package/dist/metadata/buildRollupConfig.js +144 -0
  62. package/dist/metadata/buildRollupConfig.js.map +1 -0
  63. package/dist/metadata/buildTsConfig.js +72 -0
  64. package/dist/metadata/buildTsConfig.js.map +1 -0
  65. package/dist/package.json +1 -0
  66. package/dist/static/paginateContent.js +214 -0
  67. package/dist/static/paginateContent.js.map +1 -0
  68. package/dist/static/pollingContent.js +98 -0
  69. package/dist/static/pollingContent.js.map +1 -0
  70. package/dist/static/serializeHelper.js +30 -0
  71. package/dist/static/serializeHelper.js.map +1 -0
  72. package/dist/test/buildEnvFile.js +31 -0
  73. package/dist/test/buildEnvFile.js.map +1 -0
  74. package/dist/test/buildKarmaConfig.js +19 -0
  75. package/dist/test/buildKarmaConfig.js.map +1 -0
  76. package/dist/test/buildRecordedClient.js +22 -0
  77. package/dist/test/buildRecordedClient.js.map +1 -0
  78. package/dist/test/buildSampleTest.js +19 -0
  79. package/dist/test/buildSampleTest.js.map +1 -0
  80. package/dist/test/template.js +191 -0
  81. package/dist/test/template.js.map +1 -0
  82. package/dist-esm/buildClient.js +261 -0
  83. package/dist-esm/buildClient.js.map +1 -0
  84. package/dist-esm/buildClientDefinitions.js +155 -0
  85. package/dist-esm/buildClientDefinitions.js.map +1 -0
  86. package/dist-esm/buildIndexFile.js +165 -0
  87. package/dist-esm/buildIndexFile.js.map +1 -0
  88. package/dist-esm/buildIsUnexpectedHelper.js +216 -0
  89. package/dist-esm/buildIsUnexpectedHelper.js.map +1 -0
  90. package/dist-esm/buildMethodShortcuts.js +46 -0
  91. package/dist-esm/buildMethodShortcuts.js.map +1 -0
  92. package/dist-esm/buildObjectTypes.js +288 -0
  93. package/dist-esm/buildObjectTypes.js.map +1 -0
  94. package/dist-esm/buildPaginateHelper.js +26 -0
  95. package/dist-esm/buildPaginateHelper.js.map +1 -0
  96. package/dist-esm/buildParameterTypes.js +321 -0
  97. package/dist-esm/buildParameterTypes.js.map +1 -0
  98. package/dist-esm/buildPollingHelper.js +17 -0
  99. package/dist-esm/buildPollingHelper.js.map +1 -0
  100. package/dist-esm/buildResponseTypes.js +140 -0
  101. package/dist-esm/buildResponseTypes.js.map +1 -0
  102. package/dist-esm/buildSchemaType.js +60 -0
  103. package/dist-esm/buildSchemaType.js.map +1 -0
  104. package/dist-esm/buildSerializeHelper.js +31 -0
  105. package/dist-esm/buildSerializeHelper.js.map +1 -0
  106. package/dist-esm/buildTopLevelIndexFile.js +44 -0
  107. package/dist-esm/buildTopLevelIndexFile.js.map +1 -0
  108. package/dist-esm/helpers/nameConstructors.js +34 -0
  109. package/dist-esm/helpers/nameConstructors.js.map +1 -0
  110. package/dist-esm/helpers/nameUtils.js +187 -0
  111. package/dist-esm/helpers/nameUtils.js.map +1 -0
  112. package/dist-esm/helpers/operationHelpers.js +84 -0
  113. package/dist-esm/helpers/operationHelpers.js.map +1 -0
  114. package/dist-esm/helpers/pathUtils.js +9 -0
  115. package/dist-esm/helpers/pathUtils.js.map +1 -0
  116. package/dist-esm/helpers/schemaHelpers.js +21 -0
  117. package/dist-esm/helpers/schemaHelpers.js.map +1 -0
  118. package/dist-esm/helpers/shortcutMethods.js +42 -0
  119. package/dist-esm/helpers/shortcutMethods.js.map +1 -0
  120. package/dist-esm/index.js +29 -0
  121. package/dist-esm/index.js.map +1 -0
  122. package/dist-esm/interfaces.js +15 -0
  123. package/dist-esm/interfaces.js.map +1 -0
  124. package/dist-esm/metadata/buildApiExtractorConfig.js +51 -0
  125. package/dist-esm/metadata/buildApiExtractorConfig.js.map +1 -0
  126. package/dist-esm/metadata/buildESLintConfig.js +28 -0
  127. package/dist-esm/metadata/buildESLintConfig.js.map +1 -0
  128. package/dist-esm/metadata/buildLicenseFile.js +36 -0
  129. package/dist-esm/metadata/buildLicenseFile.js.map +1 -0
  130. package/dist-esm/metadata/buildPackageFile.js +276 -0
  131. package/dist-esm/metadata/buildPackageFile.js.map +1 -0
  132. package/dist-esm/metadata/buildReadmeFile.js +167 -0
  133. package/dist-esm/metadata/buildReadmeFile.js.map +1 -0
  134. package/dist-esm/metadata/buildRollupConfig.js +139 -0
  135. package/dist-esm/metadata/buildRollupConfig.js.map +1 -0
  136. package/dist-esm/metadata/buildTsConfig.js +67 -0
  137. package/dist-esm/metadata/buildTsConfig.js.map +1 -0
  138. package/dist-esm/package.json +1 -0
  139. package/dist-esm/static/paginateContent.js +211 -0
  140. package/dist-esm/static/paginateContent.js.map +1 -0
  141. package/dist-esm/static/pollingContent.js +95 -0
  142. package/dist-esm/static/pollingContent.js.map +1 -0
  143. package/dist-esm/static/serializeHelper.js +27 -0
  144. package/dist-esm/static/serializeHelper.js.map +1 -0
  145. package/dist-esm/test/buildEnvFile.js +24 -0
  146. package/dist-esm/test/buildEnvFile.js.map +1 -0
  147. package/dist-esm/test/buildKarmaConfig.js +14 -0
  148. package/dist-esm/test/buildKarmaConfig.js.map +1 -0
  149. package/dist-esm/test/buildRecordedClient.js +17 -0
  150. package/dist-esm/test/buildRecordedClient.js.map +1 -0
  151. package/dist-esm/test/buildSampleTest.js +14 -0
  152. package/dist-esm/test/buildSampleTest.js.map +1 -0
  153. package/dist-esm/test/template.js +188 -0
  154. package/dist-esm/test/template.js.map +1 -0
  155. package/package.json +46 -0
  156. package/publishPackage.js +11 -0
  157. package/rlc-common.build.log +2 -0
  158. package/src/buildClient.ts +353 -0
  159. package/src/buildClientDefinitions.ts +235 -0
  160. package/src/buildIndexFile.ts +202 -0
  161. package/src/buildIsUnexpectedHelper.ts +240 -0
  162. package/src/buildMethodShortcuts.ts +75 -0
  163. package/src/buildObjectTypes.ts +449 -0
  164. package/src/buildPaginateHelper.ts +33 -0
  165. package/src/buildParameterTypes.ts +477 -0
  166. package/src/buildPollingHelper.ts +18 -0
  167. package/src/buildResponseTypes.ts +186 -0
  168. package/src/buildSchemaType.ts +85 -0
  169. package/src/buildSerializeHelper.ts +42 -0
  170. package/src/buildTopLevelIndexFile.ts +52 -0
  171. package/src/helpers/nameConstructors.ts +93 -0
  172. package/src/helpers/nameUtils.ts +227 -0
  173. package/src/helpers/operationHelpers.ts +119 -0
  174. package/src/helpers/pathUtils.ts +9 -0
  175. package/src/helpers/schemaHelpers.ts +25 -0
  176. package/src/helpers/shortcutMethods.ts +60 -0
  177. package/src/index.ts +29 -0
  178. package/src/interfaces.ts +227 -0
  179. package/src/metadata/buildApiExtractorConfig.ts +59 -0
  180. package/src/metadata/buildESLintConfig.ts +34 -0
  181. package/src/metadata/buildLicenseFile.ts +39 -0
  182. package/src/metadata/buildPackageFile.ts +334 -0
  183. package/src/metadata/buildReadmeFile.ts +231 -0
  184. package/src/metadata/buildRollupConfig.ts +147 -0
  185. package/src/metadata/buildTsConfig.ts +79 -0
  186. package/src/static/paginateContent.ts +210 -0
  187. package/src/static/pollingContent.ts +94 -0
  188. package/src/static/serializeHelper.ts +29 -0
  189. package/src/test/buildEnvFile.ts +26 -0
  190. package/src/test/buildKarmaConfig.ts +15 -0
  191. package/src/test/buildRecordedClient.ts +18 -0
  192. package/src/test/buildSampleTest.ts +15 -0
  193. package/src/test/template.ts +191 -0
  194. package/tsconfig-cjs.json +9 -0
  195. package/tsconfig-common.json +13 -0
  196. package/tsconfig.json +13 -0
  197. package/types/buildClient.d.ts +2 -0
  198. package/types/buildClientDefinitions.d.ts +5 -0
  199. package/types/buildIndexFile.d.ts +5 -0
  200. package/types/buildIsUnexpectedHelper.d.ts +5 -0
  201. package/types/buildMethodShortcuts.d.ts +4 -0
  202. package/types/buildObjectTypes.d.ts +15 -0
  203. package/types/buildPaginateHelper.d.ts +5 -0
  204. package/types/buildParameterTypes.d.ts +13 -0
  205. package/types/buildPollingHelper.d.ts +5 -0
  206. package/types/buildResponseTypes.d.ts +5 -0
  207. package/types/buildSchemaType.d.ts +19 -0
  208. package/types/buildSerializeHelper.d.ts +5 -0
  209. package/types/buildTopLevelIndexFile.d.ts +5 -0
  210. package/types/helpers/nameConstructors.d.ts +28 -0
  211. package/types/helpers/nameUtils.d.ts +25 -0
  212. package/types/helpers/operationHelpers.d.ts +13 -0
  213. package/types/helpers/pathUtils.d.ts +1 -0
  214. package/types/helpers/schemaHelpers.d.ts +4 -0
  215. package/types/helpers/shortcutMethods.d.ts +3 -0
  216. package/types/index.d.ts +26 -0
  217. package/types/interfaces.d.ts +200 -0
  218. package/types/metadata/buildApiExtractorConfig.d.ts +5 -0
  219. package/types/metadata/buildESLintConfig.d.ts +5 -0
  220. package/types/metadata/buildLicenseFile.d.ts +5 -0
  221. package/types/metadata/buildPackageFile.d.ts +5 -0
  222. package/types/metadata/buildReadmeFile.d.ts +5 -0
  223. package/types/metadata/buildRollupConfig.d.ts +5 -0
  224. package/types/metadata/buildTsConfig.d.ts +5 -0
  225. package/types/static/paginateContent.d.ts +1 -0
  226. package/types/static/pollingContent.d.ts +1 -0
  227. package/types/static/serializeHelper.d.ts +4 -0
  228. package/types/test/buildEnvFile.d.ts +9 -0
  229. package/types/test/buildKarmaConfig.d.ts +5 -0
  230. package/types/test/buildRecordedClient.d.ts +5 -0
  231. package/types/test/buildSampleTest.d.ts +5 -0
  232. package/types/test/template.d.ts +5 -0
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ import {
5
+ OptionalKind,
6
+ MethodSignatureStructure,
7
+ InterfaceDeclarationStructure
8
+ } from "ts-morph";
9
+ import { PathMetadata, Paths } from "../interfaces.js";
10
+ import { buildMethodDefinitions } from "./operationHelpers.js";
11
+ import { NameType, normalizeName } from "./nameUtils.js";
12
+
13
+ export function generateMethodShortcuts(
14
+ paths: Paths
15
+ ): OptionalKind<InterfaceDeclarationStructure>[] {
16
+ const keys: Record<string, OptionalKind<MethodSignatureStructure>[]> = {};
17
+ for (const path in paths) {
18
+ const groupName = paths[path].operationGroupName;
19
+ const definitions = buildOperationDefinitions(paths[path]);
20
+ if (!keys[groupName]) {
21
+ keys[groupName] = definitions;
22
+ } else {
23
+ keys[groupName] = [...keys[groupName], ...definitions];
24
+ }
25
+ }
26
+
27
+ const interfaces: OptionalKind<InterfaceDeclarationStructure>[] = [];
28
+
29
+ for (const interfaceName in keys) {
30
+ const methods = keys[interfaceName];
31
+ interfaces.push({
32
+ name: `${interfaceName}Operations`,
33
+ methods: methods,
34
+ isExported: true,
35
+ docs: [`Contains operations for ${interfaceName} operations`]
36
+ });
37
+ }
38
+
39
+ return interfaces;
40
+ }
41
+
42
+ function buildOperationDefinitions(
43
+ path: PathMetadata
44
+ ): OptionalKind<MethodSignatureStructure>[] {
45
+ let ops: OptionalKind<MethodSignatureStructure>[] = [];
46
+
47
+ for (const verb in path.methods) {
48
+ const methods = path.methods[verb];
49
+ for (const method of methods) {
50
+ const name = normalizeName(method.operationName, NameType.Property);
51
+ const pathParams = path.pathParameters;
52
+ const methodDefinitions = buildMethodDefinitions(
53
+ { [name]: [method] },
54
+ pathParams
55
+ );
56
+ ops = [...ops, ...methodDefinitions];
57
+ }
58
+ }
59
+ return ops;
60
+ }
package/src/index.ts ADDED
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ export * from "./interfaces.js";
5
+ export * from "./buildClientDefinitions.js";
6
+ export * from "./buildSchemaType.js";
7
+ export * from "./buildClient.js";
8
+ export * from "./helpers/nameConstructors.js";
9
+ export * from "./buildResponseTypes.js";
10
+ export * from "./helpers/shortcutMethods.js";
11
+ export * from "./helpers/nameUtils.js";
12
+ export * from "./buildParameterTypes.js";
13
+ export * from "./buildIsUnexpectedHelper.js";
14
+ export * from "./buildTopLevelIndexFile.js";
15
+ export * from "./buildIndexFile.js";
16
+ export * from "./buildPaginateHelper.js";
17
+ export * from "./buildPollingHelper.js";
18
+ export * from "./test/buildKarmaConfig.js";
19
+ export * from "./test/buildEnvFile.js";
20
+ export * from "./test/buildRecordedClient.js";
21
+ export * from "./test/buildSampleTest.js";
22
+ export * from "./metadata/buildReadmeFile.js";
23
+ export * from "./metadata/buildApiExtractorConfig.js";
24
+ export * from "./metadata/buildPackageFile.js";
25
+ export * from "./metadata/buildRollupConfig.js";
26
+ export * from "./metadata/buildTsConfig.js";
27
+ export * from "./metadata/buildESLintConfig.js";
28
+ export * from "./metadata/buildLicenseFile.js";
29
+ export * from "./buildSerializeHelper.js";
@@ -0,0 +1,227 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export interface RLCModel {
4
+ libraryName: string;
5
+ srcPath: string;
6
+ paths: Paths;
7
+ options?: RLCOptions;
8
+ schemas: Schema[];
9
+ apiVersionInQueryParam?: Parameter;
10
+ parameters?: OperationParameter[];
11
+ responses?: OperationResponse[];
12
+ importSet?: Map<ImportKind, Set<string>>;
13
+ annotations?: AnnotationDetails;
14
+ urlInfo?: UrlInfo;
15
+ }
16
+
17
+ export interface PathTemplateApiVersion {
18
+ value: string;
19
+ templateName: string;
20
+ }
21
+
22
+ export interface UrlInfo {
23
+ endpoint?: string;
24
+ urlParameters?: PathParameter[];
25
+ pathTemplateApiVersion?: PathTemplateApiVersion;
26
+ }
27
+ export interface AnnotationDetails {
28
+ hasPaging?: boolean;
29
+ hasLongRunning?: boolean;
30
+ pageDetails?: PagingDetails;
31
+ hasMultiCollection?: boolean;
32
+ hasPipeCollection?: boolean;
33
+ hasSsvCollection?: boolean;
34
+ hasTsvCollection?: boolean;
35
+ }
36
+
37
+ export interface PagingDetails {
38
+ itemNames: string[];
39
+ nextLinkNames: string[];
40
+ isComplexPaging: boolean;
41
+ }
42
+
43
+ export type Methods = {
44
+ [key: string]: [OperationMethod];
45
+ };
46
+
47
+ export interface ResponseTypes {
48
+ success: string[];
49
+ error: string[];
50
+ }
51
+
52
+ export interface OperationMethod {
53
+ optionsName: string;
54
+ description: string;
55
+ hasOptionalOptions: boolean;
56
+ returnType: string;
57
+ successStatus: string[];
58
+ responseTypes: ResponseTypes;
59
+ operationName: string;
60
+ annotations?: OperationAnnotations;
61
+ }
62
+ export interface PathMetadata {
63
+ name: string;
64
+ pathParameters: PathParameter[];
65
+ methods: Methods;
66
+ operationGroupName: string;
67
+ description: string;
68
+ }
69
+
70
+ export type Paths = Record<string, PathMetadata>;
71
+
72
+ export type PathParameter = {
73
+ name: string;
74
+ type: string;
75
+ description?: string;
76
+ value?: string | number | boolean;
77
+ };
78
+
79
+ export interface OperationAnnotations {
80
+ isLongRunning?: boolean;
81
+ isPageable?: boolean;
82
+ }
83
+
84
+ export interface RLCOptions {
85
+ includeShortcuts?: boolean;
86
+ multiClient?: boolean;
87
+ batch?: any[];
88
+ packageDetails?: PackageDetails;
89
+ addCredentials?: boolean;
90
+ credentialScopes?: string[];
91
+ credentialKeyHeaderName?: string;
92
+ generateMetadata?: boolean;
93
+ generateTest?: boolean;
94
+ generateSample?: boolean;
95
+ azureSdkForJs?: boolean;
96
+ azureOutputDirectory?: string;
97
+ isCadlTest?: boolean;
98
+ title?: string;
99
+ dependencyInfo?: DependencyInfo;
100
+ productDocLink?: string;
101
+ serviceInfo?: ServiceInfo;
102
+ azureArm?: boolean;
103
+ sourceFrom?: "Cadl" | "Swagger";
104
+ }
105
+
106
+ export interface ServiceInfo {
107
+ title?: string;
108
+ description?: string;
109
+ }
110
+
111
+ export interface DependencyInfo {
112
+ link: string;
113
+ description: string;
114
+ }
115
+
116
+ export enum ImportKind {
117
+ ResponseOutput,
118
+ ParameterInput
119
+ }
120
+ export interface File {
121
+ path: string;
122
+ content: string;
123
+ }
124
+
125
+ export enum SchemaContext {
126
+ /** Schema is used as an input to an operation. */
127
+ Input = "input",
128
+ /** Schema is used as an output from an operation. */
129
+ Output = "output",
130
+ /** Schema is used as an exception from an operation. */
131
+ Exception = "exception"
132
+ }
133
+
134
+ export interface Schema {
135
+ name: string;
136
+ type: string;
137
+ typeName?: string;
138
+ outputTypeName?: string;
139
+ description?: string;
140
+ required?: boolean;
141
+ default?: any;
142
+ readOnly?: boolean;
143
+ usage?: SchemaContext[];
144
+ alias?: string;
145
+ outputAlias?: string;
146
+ fromCore?: boolean;
147
+ }
148
+
149
+ export interface ObjectSchema extends Schema {
150
+ properties?: Record<string, Schema>;
151
+ discriminatorValue?: string;
152
+ discriminator?: Schema;
153
+ isPolyParent?: boolean;
154
+ children?: {
155
+ all?: ObjectSchema[];
156
+ immediate?: ObjectSchema[];
157
+ };
158
+ parents?: {
159
+ all?: ObjectSchema[];
160
+ immediate?: ObjectSchema[];
161
+ };
162
+ }
163
+
164
+ export interface DictionarySchema extends Schema {
165
+ valueTypeName?: string;
166
+ outputValueTypeName?: string;
167
+ }
168
+
169
+ export interface Property extends Schema {}
170
+
171
+ export interface Parameter extends Schema {}
172
+
173
+ export interface PackageDetails {
174
+ name: string;
175
+ scopeName?: string;
176
+ nameWithoutScope?: string;
177
+ description?: string;
178
+ version: string;
179
+ }
180
+ export interface OperationParameter {
181
+ operationGroup: string;
182
+ operationName: string;
183
+ /**
184
+ * An operation with multiple request parameters means that
185
+ * the operation can get different values for content-type and each value
186
+ * may have a different type associated to it.
187
+ */
188
+ parameters: ParameterMetadatas[];
189
+ }
190
+
191
+ export interface ParameterMetadatas {
192
+ parameters?: ParameterMetadata[];
193
+ body?: ParameterBodyMetadata;
194
+ }
195
+
196
+ export interface ParameterBodyMetadata {
197
+ // In case of formData we'd get multiple properties in body marked as partialBody
198
+ isPartialBody?: boolean;
199
+ body?: ParameterBodySchema[];
200
+ }
201
+
202
+ export type ParameterBodySchema = Schema;
203
+ export interface ParameterMetadata {
204
+ type: "query" | "path" | "header";
205
+ name: string;
206
+ param: Schema;
207
+ }
208
+
209
+ export interface OperationResponse {
210
+ operationGroup: string;
211
+ operationName: string;
212
+ responses: ResponseMetadata[];
213
+ }
214
+ export interface ResponseMetadata {
215
+ statusCode: string;
216
+ description?: string;
217
+ headers?: ResponseHeaderSchema[];
218
+ body?: ResponseBodySchema;
219
+ }
220
+
221
+ export type ResponseHeaderSchema = Schema;
222
+ export type ResponseBodySchema = Schema;
223
+
224
+ export type ContentBuilder = {
225
+ (model: RLCModel): File | undefined;
226
+ (model: RLCModel, hasSampleGenerated?: boolean): File | undefined;
227
+ };
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ import { Project } from "ts-morph";
5
+ import { RLCModel } from "../interfaces.js";
6
+
7
+ export function buildApiExtractorConfig(model: RLCModel) {
8
+ const generateMetadata = Boolean(model.options?.generateMetadata);
9
+ if (!generateMetadata) {
10
+ return;
11
+ }
12
+ const { generateTest, packageDetails } = model.options || {};
13
+ const project = new Project();
14
+ const config = {
15
+ $schema:
16
+ "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
17
+ mainEntryPointFilePath: `./types${generateTest ? "/src" : ""}/index.d.ts`,
18
+ docModel: {
19
+ enabled: true
20
+ },
21
+ apiReport: {
22
+ enabled: true,
23
+ reportFolder: "./review"
24
+ },
25
+ dtsRollup: {
26
+ enabled: true,
27
+ untrimmedFilePath: "",
28
+ publicTrimmedFilePath: `./types/${packageDetails?.nameWithoutScope}.d.ts`
29
+ },
30
+ messages: {
31
+ tsdocMessageReporting: {
32
+ default: {
33
+ logLevel: "none"
34
+ }
35
+ },
36
+ extractorMessageReporting: {
37
+ "ae-missing-release-tag": {
38
+ logLevel: "none"
39
+ },
40
+ "ae-unresolved-link": {
41
+ logLevel: "none"
42
+ }
43
+ }
44
+ }
45
+ };
46
+
47
+ const filePath = "api-extractor.json";
48
+ const configFile = project.createSourceFile(
49
+ filePath,
50
+ JSON.stringify(config),
51
+ {
52
+ overwrite: true
53
+ }
54
+ );
55
+ return {
56
+ path: filePath,
57
+ content: configFile.getFullText()
58
+ };
59
+ }
@@ -0,0 +1,34 @@
1
+ import { Project } from "ts-morph";
2
+ import { RLCModel } from "../interfaces.js";
3
+
4
+ const esLintConfig = {
5
+ plugins: ["@azure/azure-sdk"],
6
+ extends: ["plugin:@azure/azure-sdk/azure-sdk-base"],
7
+ rules: {
8
+ "@azure/azure-sdk/ts-modules-only-named": "warn",
9
+ "@azure/azure-sdk/ts-apiextractor-json-types": "warn",
10
+ "@azure/azure-sdk/ts-package-json-types": "warn",
11
+ "@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
12
+ "tsdoc/syntax": "warn"
13
+ }
14
+ };
15
+
16
+ export function buildEsLintConfig(model: RLCModel) {
17
+ const generateMetadata = Boolean(model.options?.generateMetadata);
18
+ if (!generateMetadata) {
19
+ return;
20
+ }
21
+ const project = new Project();
22
+ const filePath = ".eslintrc.json";
23
+ const configFile = project.createSourceFile(
24
+ ".eslintrc.json",
25
+ JSON.stringify(esLintConfig),
26
+ {
27
+ overwrite: true
28
+ }
29
+ );
30
+ return {
31
+ path: filePath,
32
+ content: configFile.getFullText()
33
+ };
34
+ }
@@ -0,0 +1,39 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ import { RLCModel } from "../interfaces.js";
5
+
6
+ const mitLicenseText = `
7
+ The MIT License (MIT)
8
+
9
+ Copyright (c) ${new Date().getFullYear()} Microsoft
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ `;
29
+
30
+ export function buildLicenseFile(model: RLCModel) {
31
+ const generateMetadata = Boolean(model.options?.generateMetadata);
32
+ if (!generateMetadata) {
33
+ return;
34
+ }
35
+ return {
36
+ path: "LICENSE",
37
+ content: mitLicenseText.trim()
38
+ };
39
+ }