@azure-tools/rlc-common 1.0.0-beta.1

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 (209) hide show
  1. package/.rush/temp/package-deps_build.json +45 -0
  2. package/.rush/temp/shrinkwrap-deps.json +72 -0
  3. package/CHANGELOG.md +3 -0
  4. package/dist/buildClient.js +198 -0
  5. package/dist/buildClient.js.map +1 -0
  6. package/dist/buildClientDefinitions.js +160 -0
  7. package/dist/buildClientDefinitions.js.map +1 -0
  8. package/dist/buildIndexFile.js +150 -0
  9. package/dist/buildIndexFile.js.map +1 -0
  10. package/dist/buildIsUnexpectedHelper.js +219 -0
  11. package/dist/buildIsUnexpectedHelper.js.map +1 -0
  12. package/dist/buildMethodShortcuts.js +50 -0
  13. package/dist/buildMethodShortcuts.js.map +1 -0
  14. package/dist/buildObjectTypes.js +250 -0
  15. package/dist/buildObjectTypes.js.map +1 -0
  16. package/dist/buildPaginateHelper.js +30 -0
  17. package/dist/buildPaginateHelper.js.map +1 -0
  18. package/dist/buildParameterTypes.js +287 -0
  19. package/dist/buildParameterTypes.js.map +1 -0
  20. package/dist/buildPollingHelper.js +21 -0
  21. package/dist/buildPollingHelper.js.map +1 -0
  22. package/dist/buildResponseTypes.js +122 -0
  23. package/dist/buildResponseTypes.js.map +1 -0
  24. package/dist/buildSchemaType.js +44 -0
  25. package/dist/buildSchemaType.js.map +1 -0
  26. package/dist/buildTopLevelIndexFile.js +45 -0
  27. package/dist/buildTopLevelIndexFile.js.map +1 -0
  28. package/dist/helpers/nameConstructors.js +41 -0
  29. package/dist/helpers/nameConstructors.js.map +1 -0
  30. package/dist/helpers/nameUtils.js +196 -0
  31. package/dist/helpers/nameUtils.js.map +1 -0
  32. package/dist/helpers/operationHelpers.js +83 -0
  33. package/dist/helpers/operationHelpers.js.map +1 -0
  34. package/dist/helpers/schemaHelpers.js +27 -0
  35. package/dist/helpers/schemaHelpers.js.map +1 -0
  36. package/dist/helpers/shortcutMethods.js +46 -0
  37. package/dist/helpers/shortcutMethods.js.map +1 -0
  38. package/dist/index.js +44 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/interfaces.js +18 -0
  41. package/dist/interfaces.js.map +1 -0
  42. package/dist/metadata/buildApiExtractorConfig.js +56 -0
  43. package/dist/metadata/buildApiExtractorConfig.js.map +1 -0
  44. package/dist/metadata/buildESLintConfig.js +33 -0
  45. package/dist/metadata/buildESLintConfig.js.map +1 -0
  46. package/dist/metadata/buildLicenseFile.js +41 -0
  47. package/dist/metadata/buildLicenseFile.js.map +1 -0
  48. package/dist/metadata/buildPackageFile.js +232 -0
  49. package/dist/metadata/buildPackageFile.js.map +1 -0
  50. package/dist/metadata/buildReadmeFile.js +170 -0
  51. package/dist/metadata/buildReadmeFile.js.map +1 -0
  52. package/dist/metadata/buildRollupConfig.js +144 -0
  53. package/dist/metadata/buildRollupConfig.js.map +1 -0
  54. package/dist/metadata/buildTsConfig.js +72 -0
  55. package/dist/metadata/buildTsConfig.js.map +1 -0
  56. package/dist/package.json +1 -0
  57. package/dist/static/paginateContent.js +214 -0
  58. package/dist/static/paginateContent.js.map +1 -0
  59. package/dist/static/pollingContent.js +78 -0
  60. package/dist/static/pollingContent.js.map +1 -0
  61. package/dist/test/buildEnvFile.js +31 -0
  62. package/dist/test/buildEnvFile.js.map +1 -0
  63. package/dist/test/buildKarmaConfig.js +19 -0
  64. package/dist/test/buildKarmaConfig.js.map +1 -0
  65. package/dist/test/buildRecordedClient.js +22 -0
  66. package/dist/test/buildRecordedClient.js.map +1 -0
  67. package/dist/test/buildSampleTest.js +19 -0
  68. package/dist/test/buildSampleTest.js.map +1 -0
  69. package/dist/test/template.js +192 -0
  70. package/dist/test/template.js.map +1 -0
  71. package/dist-esm/buildClient.js +191 -0
  72. package/dist-esm/buildClient.js.map +1 -0
  73. package/dist-esm/buildClientDefinitions.js +155 -0
  74. package/dist-esm/buildClientDefinitions.js.map +1 -0
  75. package/dist-esm/buildIndexFile.js +145 -0
  76. package/dist-esm/buildIndexFile.js.map +1 -0
  77. package/dist-esm/buildIsUnexpectedHelper.js +215 -0
  78. package/dist-esm/buildIsUnexpectedHelper.js.map +1 -0
  79. package/dist-esm/buildMethodShortcuts.js +46 -0
  80. package/dist-esm/buildMethodShortcuts.js.map +1 -0
  81. package/dist-esm/buildObjectTypes.js +249 -0
  82. package/dist-esm/buildObjectTypes.js.map +1 -0
  83. package/dist-esm/buildPaginateHelper.js +26 -0
  84. package/dist-esm/buildPaginateHelper.js.map +1 -0
  85. package/dist-esm/buildParameterTypes.js +288 -0
  86. package/dist-esm/buildParameterTypes.js.map +1 -0
  87. package/dist-esm/buildPollingHelper.js +17 -0
  88. package/dist-esm/buildPollingHelper.js.map +1 -0
  89. package/dist-esm/buildResponseTypes.js +127 -0
  90. package/dist-esm/buildResponseTypes.js.map +1 -0
  91. package/dist-esm/buildSchemaType.js +39 -0
  92. package/dist-esm/buildSchemaType.js.map +1 -0
  93. package/dist-esm/buildTopLevelIndexFile.js +41 -0
  94. package/dist-esm/buildTopLevelIndexFile.js.map +1 -0
  95. package/dist-esm/helpers/nameConstructors.js +34 -0
  96. package/dist-esm/helpers/nameConstructors.js.map +1 -0
  97. package/dist-esm/helpers/nameUtils.js +187 -0
  98. package/dist-esm/helpers/nameUtils.js.map +1 -0
  99. package/dist-esm/helpers/operationHelpers.js +72 -0
  100. package/dist-esm/helpers/operationHelpers.js.map +1 -0
  101. package/dist-esm/helpers/schemaHelpers.js +21 -0
  102. package/dist-esm/helpers/schemaHelpers.js.map +1 -0
  103. package/dist-esm/helpers/shortcutMethods.js +42 -0
  104. package/dist-esm/helpers/shortcutMethods.js.map +1 -0
  105. package/dist-esm/index.js +28 -0
  106. package/dist-esm/index.js.map +1 -0
  107. package/dist-esm/interfaces.js +15 -0
  108. package/dist-esm/interfaces.js.map +1 -0
  109. package/dist-esm/metadata/buildApiExtractorConfig.js +51 -0
  110. package/dist-esm/metadata/buildApiExtractorConfig.js.map +1 -0
  111. package/dist-esm/metadata/buildESLintConfig.js +28 -0
  112. package/dist-esm/metadata/buildESLintConfig.js.map +1 -0
  113. package/dist-esm/metadata/buildLicenseFile.js +36 -0
  114. package/dist-esm/metadata/buildLicenseFile.js.map +1 -0
  115. package/dist-esm/metadata/buildPackageFile.js +234 -0
  116. package/dist-esm/metadata/buildPackageFile.js.map +1 -0
  117. package/dist-esm/metadata/buildReadmeFile.js +167 -0
  118. package/dist-esm/metadata/buildReadmeFile.js.map +1 -0
  119. package/dist-esm/metadata/buildRollupConfig.js +139 -0
  120. package/dist-esm/metadata/buildRollupConfig.js.map +1 -0
  121. package/dist-esm/metadata/buildTsConfig.js +67 -0
  122. package/dist-esm/metadata/buildTsConfig.js.map +1 -0
  123. package/dist-esm/package.json +1 -0
  124. package/dist-esm/static/paginateContent.js +211 -0
  125. package/dist-esm/static/paginateContent.js.map +1 -0
  126. package/dist-esm/static/pollingContent.js +75 -0
  127. package/dist-esm/static/pollingContent.js.map +1 -0
  128. package/dist-esm/test/buildEnvFile.js +24 -0
  129. package/dist-esm/test/buildEnvFile.js.map +1 -0
  130. package/dist-esm/test/buildKarmaConfig.js +14 -0
  131. package/dist-esm/test/buildKarmaConfig.js.map +1 -0
  132. package/dist-esm/test/buildRecordedClient.js +17 -0
  133. package/dist-esm/test/buildRecordedClient.js.map +1 -0
  134. package/dist-esm/test/buildSampleTest.js +14 -0
  135. package/dist-esm/test/buildSampleTest.js.map +1 -0
  136. package/dist-esm/test/template.js +189 -0
  137. package/dist-esm/test/template.js.map +1 -0
  138. package/package.json +40 -0
  139. package/publishPackage.js +11 -0
  140. package/rlc-common.build.log +2 -0
  141. package/src/buildClient.ts +251 -0
  142. package/src/buildClientDefinitions.ts +231 -0
  143. package/src/buildIndexFile.ts +172 -0
  144. package/src/buildIsUnexpectedHelper.ts +240 -0
  145. package/src/buildMethodShortcuts.ts +75 -0
  146. package/src/buildObjectTypes.ts +393 -0
  147. package/src/buildPaginateHelper.ts +33 -0
  148. package/src/buildParameterTypes.ts +435 -0
  149. package/src/buildPollingHelper.ts +18 -0
  150. package/src/buildResponseTypes.ts +169 -0
  151. package/src/buildSchemaType.ts +56 -0
  152. package/src/buildTopLevelIndexFile.ts +46 -0
  153. package/src/helpers/nameConstructors.ts +93 -0
  154. package/src/helpers/nameUtils.ts +227 -0
  155. package/src/helpers/operationHelpers.ts +103 -0
  156. package/src/helpers/schemaHelpers.ts +25 -0
  157. package/src/helpers/shortcutMethods.ts +60 -0
  158. package/src/index.ts +28 -0
  159. package/src/interfaces.ts +212 -0
  160. package/src/metadata/buildApiExtractorConfig.ts +59 -0
  161. package/src/metadata/buildESLintConfig.ts +34 -0
  162. package/src/metadata/buildLicenseFile.ts +39 -0
  163. package/src/metadata/buildPackageFile.ts +271 -0
  164. package/src/metadata/buildReadmeFile.ts +231 -0
  165. package/src/metadata/buildRollupConfig.ts +147 -0
  166. package/src/metadata/buildTsConfig.ts +79 -0
  167. package/src/static/paginateContent.ts +210 -0
  168. package/src/static/pollingContent.ts +74 -0
  169. package/src/test/buildEnvFile.ts +26 -0
  170. package/src/test/buildKarmaConfig.ts +15 -0
  171. package/src/test/buildRecordedClient.ts +18 -0
  172. package/src/test/buildSampleTest.ts +15 -0
  173. package/src/test/template.ts +192 -0
  174. package/tsconfig-cjs.json +9 -0
  175. package/tsconfig-common.json +13 -0
  176. package/tsconfig.json +13 -0
  177. package/types/buildClient.d.ts +2 -0
  178. package/types/buildClientDefinitions.d.ts +5 -0
  179. package/types/buildIndexFile.d.ts +5 -0
  180. package/types/buildIsUnexpectedHelper.d.ts +5 -0
  181. package/types/buildMethodShortcuts.d.ts +4 -0
  182. package/types/buildObjectTypes.d.ts +14 -0
  183. package/types/buildPaginateHelper.d.ts +5 -0
  184. package/types/buildParameterTypes.d.ts +5 -0
  185. package/types/buildPollingHelper.d.ts +5 -0
  186. package/types/buildResponseTypes.d.ts +5 -0
  187. package/types/buildSchemaType.d.ts +19 -0
  188. package/types/buildTopLevelIndexFile.d.ts +5 -0
  189. package/types/helpers/nameConstructors.d.ts +28 -0
  190. package/types/helpers/nameUtils.d.ts +25 -0
  191. package/types/helpers/operationHelpers.d.ts +9 -0
  192. package/types/helpers/schemaHelpers.d.ts +4 -0
  193. package/types/helpers/shortcutMethods.d.ts +3 -0
  194. package/types/index.d.ts +25 -0
  195. package/types/interfaces.d.ts +186 -0
  196. package/types/metadata/buildApiExtractorConfig.d.ts +5 -0
  197. package/types/metadata/buildESLintConfig.d.ts +5 -0
  198. package/types/metadata/buildLicenseFile.d.ts +5 -0
  199. package/types/metadata/buildPackageFile.d.ts +5 -0
  200. package/types/metadata/buildReadmeFile.d.ts +5 -0
  201. package/types/metadata/buildRollupConfig.d.ts +5 -0
  202. package/types/metadata/buildTsConfig.d.ts +5 -0
  203. package/types/static/paginateContent.d.ts +1 -0
  204. package/types/static/pollingContent.d.ts +1 -0
  205. package/types/test/buildEnvFile.d.ts +9 -0
  206. package/types/test/buildKarmaConfig.d.ts +5 -0
  207. package/types/test/buildRecordedClient.d.ts +5 -0
  208. package/types/test/buildSampleTest.d.ts +5 -0
  209. package/types/test/template.d.ts +5 -0
@@ -0,0 +1,249 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { StructureKind } from "ts-morph";
4
+ import { NameType, normalizeName } from "./helpers/nameUtils.js";
5
+ import { isDictionarySchema, isObjectSchema } from "./helpers/schemaHelpers.js";
6
+ import { SchemaContext } from "./interfaces.js";
7
+ /**
8
+ * Generates interfaces for ObjectSchemas
9
+ */
10
+ export function buildObjectInterfaces(model, importedModels, schemaUsage) {
11
+ const objectSchemas = (model.schemas ?? []).filter((o) => isObjectSchema(o) &&
12
+ o.usage?.some((u) => schemaUsage.includes(u)));
13
+ const objectInterfaces = [];
14
+ for (const objectSchema of objectSchemas) {
15
+ const baseName = getObjectBaseName(objectSchema, schemaUsage);
16
+ const interfaceDeclaration = getObjectInterfaceDeclaration(baseName, objectSchema, schemaUsage, importedModels);
17
+ objectInterfaces.push(interfaceDeclaration);
18
+ }
19
+ return objectInterfaces;
20
+ }
21
+ export function buildPolymorphicAliases(model, schemaUsage) {
22
+ // We'll add aliases for polymorphic objects
23
+ const objectAliases = [];
24
+ const objectSchemas = (model.schemas ?? []).filter((o) => isObjectSchema(o) &&
25
+ o.usage?.some((u) => schemaUsage.includes(u)));
26
+ for (const objectSchema of objectSchemas) {
27
+ const baseName = getObjectBaseName(objectSchema, schemaUsage);
28
+ const typeAlias = getPolymorphicTypeAlias(baseName, objectSchema, schemaUsage);
29
+ if (typeAlias) {
30
+ objectAliases.push(typeAlias);
31
+ }
32
+ }
33
+ return objectAliases;
34
+ }
35
+ /**
36
+ * Gets a base name for an object schema this is tipically used with suffixes when building interface or type names
37
+ */
38
+ function getObjectBaseName(objectSchema, schemaUsage) {
39
+ const nameSuffix = schemaUsage.includes(SchemaContext.Output) ? "Output" : "";
40
+ const name = normalizeName(objectSchema.name, NameType.Interface, true /** guard name */);
41
+ return `${name}${nameSuffix}`;
42
+ }
43
+ /**
44
+ * If the current object is a Polymorphic parent, we need to create
45
+ * a type alias with the union of its children to enable polymorphism
46
+ */
47
+ function getPolymorphicTypeAlias(baseName, objectSchema, schemaUsage) {
48
+ if (!isPolymorphicParent(objectSchema)) {
49
+ return undefined;
50
+ }
51
+ const unionTypes = [];
52
+ // If the object itself has a discriminatorValue add its base to the union
53
+ if (objectSchema.discriminatorValue) {
54
+ unionTypes.push(`${baseName}Parent`);
55
+ }
56
+ for (const child of objectSchema.children?.all ?? []) {
57
+ const nameSuffix = schemaUsage.includes(SchemaContext.Output)
58
+ ? "Output"
59
+ : "";
60
+ const name = normalizeName(child.name, NameType.Interface, true /** shouldGuard */);
61
+ unionTypes.push(`${name}${nameSuffix}`);
62
+ }
63
+ const description = objectSchema.description;
64
+ return {
65
+ kind: StructureKind.TypeAlias,
66
+ ...(description && { docs: [{ description }] }),
67
+ name: `${baseName}`,
68
+ type: unionTypes.join(" | "),
69
+ isExported: true
70
+ };
71
+ }
72
+ /**
73
+ * Builds the interface for the current object schema. If it is a polymorphic
74
+ * root node it will suffix it with Base.
75
+ */
76
+ function getObjectInterfaceDeclaration(baseName, objectSchema, schemaUsage, importedModels) {
77
+ let interfaceName = `${baseName}`;
78
+ if (isPolymorphicParent(objectSchema)) {
79
+ interfaceName = `${baseName}Parent`;
80
+ }
81
+ const properties = objectSchema.properties ?? {};
82
+ let propertySignatures = getPropertySignatures(properties, schemaUsage, importedModels);
83
+ // Add the polymorphic property if exists
84
+ propertySignatures = addDiscriminatorProperty(objectSchema, propertySignatures);
85
+ // Calculate the parents of the current object
86
+ const extendFrom = getImmediateParentsNames(objectSchema, schemaUsage);
87
+ const description = objectSchema.description;
88
+ return {
89
+ kind: StructureKind.Interface,
90
+ ...(description && { docs: [{ description }] }),
91
+ name: interfaceName,
92
+ isExported: true,
93
+ properties: propertySignatures,
94
+ ...(extendFrom && { extends: extendFrom })
95
+ };
96
+ }
97
+ function isPolymorphicParent(objectSchema) {
98
+ return objectSchema.isPolyParent ? true : false;
99
+ }
100
+ function addDiscriminatorProperty(objectSchema, properties) {
101
+ const polymorphicProperty = getDiscriminatorProperty(objectSchema);
102
+ if (polymorphicProperty) {
103
+ // It is possible that the polymorphic property needs to override an existing property.
104
+ // This is usually the case on the top level parent where the property already has a type of string
105
+ // we need to replace it with the polymorphic values of its children
106
+ const filteredProperties = properties.filter((p) => p.name !== polymorphicProperty.name);
107
+ return [...filteredProperties, polymorphicProperty];
108
+ }
109
+ return properties;
110
+ }
111
+ /**
112
+ * Finds the name of the property used as discriminator and the discriminator value.
113
+ */
114
+ function getDiscriminatorProperty(objectSchema) {
115
+ const discriminatorValue = objectSchema.discriminatorValue;
116
+ if (!discriminatorValue && !objectSchema.discriminator) {
117
+ return undefined;
118
+ }
119
+ const discriminators = getDiscriminatorValue(objectSchema);
120
+ const discriminatorPropertyName = getDiscriminatorPropertyName(objectSchema);
121
+ if (discriminators) {
122
+ if (discriminatorPropertyName === undefined) {
123
+ throw new Error(`getDiscriminatorProperty: Expected object ${objectSchema.name} to have a discriminator in its hierarchy but found none`);
124
+ }
125
+ return {
126
+ kind: StructureKind.PropertySignature,
127
+ name: `"${discriminatorPropertyName}"`,
128
+ type: discriminators
129
+ };
130
+ }
131
+ return undefined;
132
+ }
133
+ /**
134
+ * Finds the closest discriminator property
135
+ */
136
+ function getDiscriminatorPropertyName(objectSchema) {
137
+ if (objectSchema.discriminator !== undefined) {
138
+ return objectSchema.discriminator.name;
139
+ }
140
+ const allParents = objectSchema.parents?.all ?? [];
141
+ for (const parent of allParents) {
142
+ if (isObjectSchema(parent) && parent.discriminator) {
143
+ return parent.discriminator.name;
144
+ }
145
+ }
146
+ return undefined;
147
+ }
148
+ /**
149
+ * Calculates the discriminator values that a given object needs
150
+ */
151
+ function getDiscriminatorValue(objectSchema) {
152
+ const discriminatorValue = objectSchema.discriminatorValue
153
+ ? objectSchema.discriminatorValue
154
+ : objectSchema.discriminator
155
+ ? objectSchema.name
156
+ : undefined;
157
+ const children = objectSchema.children?.immediate ?? [];
158
+ // If the current object has a discriminatorValue but doesn't have any children
159
+ // it is a leaf node and the only discriminator value needed is itself
160
+ if (discriminatorValue && !children.length) {
161
+ return `"${discriminatorValue}"`;
162
+ }
163
+ // when the current object has both discriminator and discriminatorValue
164
+ if (children) {
165
+ const discriminatorProperty = objectSchema.discriminator;
166
+ // Even when there are children, if no discriminatorProperty is present this is a leaf in the polymorphism tree
167
+ if (!discriminatorProperty) {
168
+ return `"${discriminatorValue}"`;
169
+ }
170
+ // the current object has discriminated children we need to find all the discriminatorValues for each of its children
171
+ const allChildren = objectSchema.children?.all ?? [];
172
+ // Top level parents may not have a discriminator of their own.
173
+ const selfDiscriminator = discriminatorValue
174
+ ? [`"${discriminatorValue}"`]
175
+ : [];
176
+ const childValues = getChildDiscriminatorValues(allChildren).map((v) => `"${v}"`);
177
+ return [...selfDiscriminator, ...childValues].join(" | ");
178
+ }
179
+ return undefined;
180
+ }
181
+ /**
182
+ * Looks into the children and grabs all possible discriminatorValues
183
+ */
184
+ function getChildDiscriminatorValues(children) {
185
+ const discriminatorValues = new Set();
186
+ for (const child of children) {
187
+ if (isObjectSchema(child) && child.discriminatorValue) {
188
+ discriminatorValues.add(child.discriminatorValue);
189
+ }
190
+ }
191
+ return [...discriminatorValues];
192
+ }
193
+ /**
194
+ * Gets a list of types a given object may extend from
195
+ */
196
+ function getImmediateParentsNames(objectSchema, schemaUsage) {
197
+ if (!objectSchema.parents?.immediate) {
198
+ return [];
199
+ }
200
+ let extendFrom = [];
201
+ // If an immediate parent is a DictionarySchema, that means that the object has been marked
202
+ // with additional properties. We need to add Record<string, unknown> to the extend list and
203
+ if (objectSchema.parents.immediate.find(isDictionarySchema)) {
204
+ extendFrom.push("Record<string, unknown>");
205
+ }
206
+ // Get the rest of the parents excluding any DictionarySchemas
207
+ const parents = objectSchema.parents.immediate
208
+ .filter((p) => !isDictionarySchema(p))
209
+ .map((parent) => {
210
+ const nameSuffix = schemaUsage.includes(SchemaContext.Output)
211
+ ? "Output"
212
+ : "";
213
+ const name = `${normalizeName(parent.name, NameType.Interface, true /** shouldGuard */)}${nameSuffix}`;
214
+ return isObjectSchema(parent) && isPolymorphicParent(parent)
215
+ ? `${name}Parent`
216
+ : name;
217
+ });
218
+ return [...parents, ...extendFrom];
219
+ }
220
+ function getPropertySignatures(properties, schemaUsage, importedModels) {
221
+ return Object.keys(properties).map((p) => getPropertySignature({ ...properties[p], name: p }, schemaUsage, importedModels));
222
+ }
223
+ /**
224
+ * Builds a Typescript property or parameter signature
225
+ * @param property - Property or parameter to get the Typescript signature for
226
+ * @param importedModels - Set to track the models that need to be imported
227
+ * @returns a PropertySignatureStructure for the property.
228
+ */
229
+ export function getPropertySignature(property, schemaUsage, importedModels = new Set()) {
230
+ const propertyName = property.name;
231
+ const description = property.description;
232
+ const type = ((schemaUsage.includes(SchemaContext.Output) &&
233
+ property.usage?.includes(SchemaContext.Output)) ||
234
+ (schemaUsage.includes(SchemaContext.Exception) &&
235
+ property.usage?.includes(SchemaContext.Exception))) &&
236
+ property.outputTypeName
237
+ ? property.outputTypeName
238
+ : property.typeName
239
+ ? property.typeName
240
+ : property.type;
241
+ return {
242
+ name: propertyName,
243
+ ...(description && { docs: [{ description }] }),
244
+ hasQuestionToken: !property.required,
245
+ type,
246
+ kind: StructureKind.PropertySignature
247
+ };
248
+ }
249
+ //# sourceMappingURL=buildObjectTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildObjectTypes.js","sourceRoot":"","sources":["../src/buildObjectTypes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAKL,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAe,EACf,cAA2B,EAC3B,WAA4B;IAE5B,MAAM,aAAa,GAAmB,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAChE,CAAC,CAAC,EAAE,EAAE,CACJ,cAAc,CAAC,CAAC,CAAC;QAChB,CAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;IACF,MAAM,gBAAgB,GAAoC,EAAE,CAAC;IAE7D,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAC9D,MAAM,oBAAoB,GAAG,6BAA6B,CACxD,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,cAAc,CACf,CAAC;QAEF,gBAAgB,CAAC,IAAI,CAAC,oBAAoB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,EACX,cAAc,CACf,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA8B,EAC9B,WAA4B,EAC5B,iBAAiB,IAAI,GAAG,EAAU;IAElC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;IAEnC,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;IACzC,MAAM,IAAI,GACR,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;QAC1C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC;YAC5C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;QACvD,QAAQ,CAAC,cAAc;QACrB,CAAC,CAAC,QAAQ,CAAC,cAAc;QACzB,CAAC,CAAC,QAAQ,CAAC,QAAQ;YACnB,CAAC,CAAC,QAAQ,CAAC,QAAQ;YACnB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;IACpB,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,GAAG,CAAC,WAAW,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAC/C,gBAAgB,EAAE,CAAC,QAAQ,CAAC,QAAQ;QACpC,IAAI;QACJ,IAAI,EAAE,aAAa,CAAC,iBAAiB;KACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import * as path from "path";
2
+ // @ts-ignore: to fix the handlebars issue
3
+ import hbs from "handlebars";
4
+ import { paginateContent } from "./static/paginateContent.js";
5
+ export function buildPaginateHelper(model) {
6
+ const pagingInfo = model.annotations;
7
+ // return directly if no paging info
8
+ if (!pagingInfo || pagingInfo.hasPaging !== true || !pagingInfo.pageDetails) {
9
+ return;
10
+ }
11
+ hbs.registerHelper("quoteWrap", function (value) {
12
+ if (Array.isArray(value)) {
13
+ return value.map((element) => `"${element}"`).join();
14
+ }
15
+ return `"${value}"`;
16
+ });
17
+ const { srcPath } = model;
18
+ const paginateHelperContents = hbs.compile(paginateContent, {
19
+ noEscape: true
20
+ });
21
+ return {
22
+ path: path.join(srcPath, "paginateHelper.ts"),
23
+ content: paginateHelperContents(pagingInfo.pageDetails)
24
+ };
25
+ }
26
+ //# sourceMappingURL=buildPaginateHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPaginateHelper.js","sourceRoot":"","sources":["../src/buildPaginateHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,0CAA0C;AAC1C,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;IACrC,oCAAoC;IACpC,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE;QAC3E,OAAO;KACR;IAED,GAAG,CAAC,cAAc,CAChB,WAAW,EACX,UAAU,KAA2C;QACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;SACtD;QAED,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC,CACF,CAAC;IAEF,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE;QAC1D,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC;QAC7C,OAAO,EAAE,sBAAsB,CAAC,UAAU,CAAC,WAAW,CAAC;KACxD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,288 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { Project, StructureKind } from "ts-morph";
4
+ import * as path from "path";
5
+ import { ImportKind } from "./interfaces.js";
6
+ import { getParameterBaseName, getParameterTypeName } from "./helpers/nameConstructors.js";
7
+ export function buildParameterTypes(model) {
8
+ const project = new Project();
9
+ const srcPath = model.srcPath;
10
+ const filePath = path.join(srcPath, `parameters.ts`);
11
+ const parametersFile = project.createSourceFile(filePath, undefined, {
12
+ overwrite: true
13
+ });
14
+ let hasHeaders = false;
15
+ if (!model.parameters) {
16
+ return;
17
+ }
18
+ for (const requestParameter of model.parameters) {
19
+ const baseParameterName = getParameterBaseName(requestParameter.operationGroup, requestParameter.operationName);
20
+ const requestCount = requestParameter?.parameters?.length ?? 0;
21
+ const topParamName = getParameterTypeName(baseParameterName);
22
+ const subParamNames = [];
23
+ // We need to loop the requests. An operation with multiple requests means that
24
+ // the operation can get different values for content-type and each value may
25
+ // have a different type associated to it.
26
+ for (let i = 0; i < requestCount; i++) {
27
+ const parameter = requestParameter.parameters[i];
28
+ const internalReferences = new Set();
29
+ // In case we have more than one request to model we need to add a suffix to differentiate
30
+ const nameSuffix = i > 0 ? `${i}` : "";
31
+ const parameterInterfaceName = requestCount > 1
32
+ ? `${baseParameterName}RequestParameters${nameSuffix}`
33
+ : topParamName;
34
+ const queryParameterDefinitions = buildQueryParameterDefinition(parameter, baseParameterName, internalReferences, i);
35
+ const pathParameterDefinitions = buildPathParameterDefinitions(parameter, baseParameterName, parametersFile, internalReferences, i);
36
+ const headerParameterDefinitions = buildHeaderParameterDefinitions(parameter, baseParameterName, parametersFile, internalReferences, i);
37
+ const contentTypeParameterDefinition = buildContentTypeParametersDefinition(parameter, baseParameterName, internalReferences, i);
38
+ const bodyParameterDefinition = buildBodyParametersDefinition(parameter, baseParameterName, internalReferences, i);
39
+ // Add interfaces for body and query parameters
40
+ parametersFile.addInterfaces([
41
+ ...(bodyParameterDefinition ?? []),
42
+ ...(queryParameterDefinitions ?? []),
43
+ ...(pathParameterDefinitions ? [pathParameterDefinitions] : []),
44
+ ...(headerParameterDefinitions ? [headerParameterDefinitions] : []),
45
+ ...(contentTypeParameterDefinition
46
+ ? [contentTypeParameterDefinition]
47
+ : [])
48
+ ]);
49
+ // Add Operation parameters type alias which is composed of the types we generated above
50
+ // plus the common type RequestParameters
51
+ parametersFile.addTypeAlias({
52
+ name: parameterInterfaceName,
53
+ isExported: true,
54
+ type: [...internalReferences, "RequestParameters"].join(" & ")
55
+ });
56
+ subParamNames.push(parameterInterfaceName);
57
+ if (headerParameterDefinitions !== undefined) {
58
+ hasHeaders = true;
59
+ }
60
+ }
61
+ // Add Operation parameters type alias which is composed of the types we generated above
62
+ // plus the common type RequestParameters
63
+ if (requestCount > 1) {
64
+ parametersFile.addTypeAlias({
65
+ name: topParamName,
66
+ isExported: true,
67
+ type: [...subParamNames].join(" | ")
68
+ });
69
+ }
70
+ }
71
+ if (hasHeaders) {
72
+ parametersFile.addImportDeclarations([
73
+ {
74
+ namedImports: ["RawHttpHeadersInput"],
75
+ moduleSpecifier: "@azure/core-rest-pipeline"
76
+ }
77
+ ]);
78
+ }
79
+ parametersFile.addImportDeclarations([
80
+ {
81
+ namedImports: ["RequestParameters"],
82
+ moduleSpecifier: "@azure-rest/core-client"
83
+ }
84
+ ]);
85
+ if (model.importSet?.has(ImportKind.ParameterInput)) {
86
+ parametersFile.addImportDeclarations([
87
+ {
88
+ namedImports: [
89
+ ...Array.from(model.importSet?.get(ImportKind.ParameterInput) || [])
90
+ ],
91
+ moduleSpecifier: "./models"
92
+ }
93
+ ]);
94
+ }
95
+ return { path: filePath, content: parametersFile.getFullText() };
96
+ }
97
+ function buildQueryParameterDefinition(parameters, baseName, internalReferences, requestIndex) {
98
+ const queryParameters = (parameters?.parameters || []).filter((p) => p.type === "query");
99
+ if (!queryParameters.length) {
100
+ return undefined;
101
+ }
102
+ const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
103
+ const queryParameterInterfaceName = `${baseName}QueryParam${nameSuffix}`;
104
+ const queryParameterPropertiesName = `${baseName}QueryParamProperties`;
105
+ // Get the property signature for each query parameter
106
+ const propertiesDefinition = queryParameters.map((qp) => getPropertyFromSchema(qp.param));
107
+ const hasRequiredParameters = propertiesDefinition.some((p) => !p.hasQuestionToken);
108
+ const propertiesInterface = {
109
+ kind: StructureKind.Interface,
110
+ isExported: true,
111
+ name: queryParameterPropertiesName,
112
+ properties: propertiesDefinition
113
+ };
114
+ const parameterInterface = {
115
+ kind: StructureKind.Interface,
116
+ isExported: true,
117
+ name: queryParameterInterfaceName,
118
+ properties: [
119
+ {
120
+ name: "queryParameters",
121
+ type: queryParameterPropertiesName,
122
+ // Mark as optional if there are no required parameters
123
+ hasQuestionToken: !hasRequiredParameters
124
+ }
125
+ ]
126
+ };
127
+ // Mark the queryParameter interface for importing
128
+ internalReferences.add(queryParameterInterfaceName);
129
+ return [propertiesInterface, parameterInterface];
130
+ }
131
+ function getPropertyFromSchema(schema) {
132
+ const description = schema.description;
133
+ return {
134
+ name: schema.name,
135
+ ...(description && { docs: [{ description }] }),
136
+ type: schema.type,
137
+ hasQuestionToken: !Boolean(schema.required),
138
+ kind: StructureKind.PropertySignature
139
+ };
140
+ }
141
+ function buildPathParameterDefinitions(parameters, baseName, parametersFile, internalReferences, requestIndex) {
142
+ const pathParameters = (parameters.parameters || []).filter((p) => p.type === "path");
143
+ if (!pathParameters.length) {
144
+ return undefined;
145
+ }
146
+ const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
147
+ const pathParameterInterfaceName = `${baseName}PathParam${nameSuffix}`;
148
+ const pathInterface = getPathInterfaceDefinition(pathParameters, baseName);
149
+ if (pathInterface) {
150
+ parametersFile.addInterface(pathInterface);
151
+ }
152
+ internalReferences.add(pathParameterInterfaceName);
153
+ return {
154
+ isExported: true,
155
+ kind: StructureKind.Interface,
156
+ name: pathParameterInterfaceName,
157
+ properties: [
158
+ {
159
+ name: "pathParameters",
160
+ type: `${baseName}PathParameters`,
161
+ kind: StructureKind.PropertySignature
162
+ }
163
+ ]
164
+ };
165
+ }
166
+ function getPathInterfaceDefinition(pathParameters, baseName) {
167
+ const pathInterfaceName = `${baseName}PathParameters`;
168
+ return {
169
+ kind: StructureKind.Interface,
170
+ isExported: true,
171
+ name: pathInterfaceName,
172
+ properties: pathParameters.map((p) => getPropertyFromSchema(p.param))
173
+ };
174
+ }
175
+ function buildHeaderParameterDefinitions(parameters, baseName, parametersFile, internalReferences, requestIndex) {
176
+ const headerParameters = (parameters.parameters || []).filter((p) => p.type === "header" && p.name !== "contentType");
177
+ if (!headerParameters.length) {
178
+ return undefined;
179
+ }
180
+ const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
181
+ const headerParameterInterfaceName = `${baseName}HeaderParam${nameSuffix}`;
182
+ const headersInterface = getRequestHeaderInterfaceDefinition(headerParameters, baseName);
183
+ if (headersInterface) {
184
+ parametersFile.addInterface(headersInterface);
185
+ }
186
+ internalReferences.add(headerParameterInterfaceName);
187
+ return {
188
+ isExported: true,
189
+ kind: StructureKind.Interface,
190
+ name: headerParameterInterfaceName,
191
+ properties: [
192
+ {
193
+ name: "headers",
194
+ type: `RawHttpHeadersInput & ${baseName}Headers`,
195
+ kind: StructureKind.PropertySignature
196
+ }
197
+ ]
198
+ };
199
+ }
200
+ function getRequestHeaderInterfaceDefinition(headerParameters, baseName) {
201
+ const headersInterfaceName = `${baseName}Headers`;
202
+ return {
203
+ kind: StructureKind.Interface,
204
+ isExported: true,
205
+ name: headersInterfaceName,
206
+ properties: headerParameters.map((h) => getPropertyFromSchema(h.param))
207
+ };
208
+ }
209
+ function buildContentTypeParametersDefinition(parameters, baseName, internalReferences, requestIndex) {
210
+ const mediaTypeParameters = (parameters.parameters || []).filter((p) => p.type === "header" && p.name === "contentType");
211
+ if (!mediaTypeParameters.length) {
212
+ return undefined;
213
+ }
214
+ const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
215
+ const mediaTypesParameterInterfaceName = `${baseName}MediaTypesParam${nameSuffix}`;
216
+ // Mark the queryParameter interface for importing
217
+ internalReferences.add(mediaTypesParameterInterfaceName);
218
+ const mediaParam = mediaTypeParameters[0].param;
219
+ return {
220
+ isExported: true,
221
+ kind: StructureKind.Interface,
222
+ name: mediaTypesParameterInterfaceName,
223
+ properties: [getPropertyFromSchema(mediaParam)]
224
+ };
225
+ }
226
+ function buildBodyParametersDefinition(parameters, baseName, internalReferences, requestIndex) {
227
+ const bodyParameters = parameters.body;
228
+ if (!bodyParameters ||
229
+ !bodyParameters?.body ||
230
+ !bodyParameters?.body.length) {
231
+ return [];
232
+ }
233
+ const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
234
+ const bodyParameterInterfaceName = `${baseName}BodyParam${nameSuffix}`;
235
+ internalReferences.add(bodyParameterInterfaceName);
236
+ // In case of formData we'd get multiple properties in body marked as partialBody
237
+ if (bodyParameters.isPartialBody) {
238
+ let allOptionalParts = true;
239
+ const propertiesDefinitions = [];
240
+ for (const param of bodyParameters.body) {
241
+ if (param.required) {
242
+ allOptionalParts = false;
243
+ }
244
+ propertiesDefinitions.push(getPropertyFromSchema(param));
245
+ }
246
+ const formBodyName = `${baseName}FormBody`;
247
+ const formBodyInterface = {
248
+ isExported: true,
249
+ kind: StructureKind.Interface,
250
+ name: formBodyName,
251
+ properties: propertiesDefinitions
252
+ };
253
+ return [
254
+ {
255
+ isExported: true,
256
+ kind: StructureKind.Interface,
257
+ name: bodyParameterInterfaceName,
258
+ properties: [
259
+ {
260
+ name: "body",
261
+ type: formBodyName,
262
+ hasQuestionToken: allOptionalParts
263
+ }
264
+ ]
265
+ },
266
+ formBodyInterface
267
+ ];
268
+ }
269
+ else {
270
+ const bodySignature = getPropertyFromSchema(bodyParameters.body[0]);
271
+ return [
272
+ {
273
+ isExported: true,
274
+ kind: StructureKind.Interface,
275
+ name: bodyParameterInterfaceName,
276
+ properties: [
277
+ {
278
+ docs: bodySignature.docs,
279
+ name: "body",
280
+ type: bodySignature.type,
281
+ hasQuestionToken: bodySignature.hasQuestionToken
282
+ }
283
+ ]
284
+ }
285
+ ];
286
+ }
287
+ }
288
+ //# sourceMappingURL=buildParameterTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildParameterTypes.js","sourceRoot":"","sources":["../src/buildParameterTypes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAEL,OAAO,EAGP,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,UAAU,EAKX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE;QACnE,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IACH,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACrB,OAAO;KACR;IACD,KAAK,MAAM,gBAAgB,IAAI,KAAK,CAAC,UAAU,EAAE;QAC/C,MAAM,iBAAiB,GAAG,oBAAoB,CAC5C,gBAAgB,CAAC,cAAc,EAC/B,gBAAgB,CAAC,aAAa,CAC/B,CAAC;QACF,MAAM,YAAY,GAA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1,17 @@
1
+ import * as path from "path";
2
+ // @ts-ignore: to fix the handlebars issue
3
+ import hbs from "handlebars";
4
+ import { hasPollingOperations } from "./helpers/operationHelpers.js";
5
+ import { pollingContent } from "./static/pollingContent.js";
6
+ export function buildPollingHelper(model) {
7
+ if (!hasPollingOperations(model)) {
8
+ return;
9
+ }
10
+ const readmeFileContents = hbs.compile(pollingContent, { noEscape: true });
11
+ const { srcPath } = model;
12
+ return {
13
+ path: path.join(srcPath, "pollingHelper.ts"),
14
+ content: readmeFileContents({})
15
+ };
16
+ }
17
+ //# sourceMappingURL=buildPollingHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPollingHelper.js","sourceRoot":"","sources":["../src/buildPollingHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,0CAA0C;AAC1C,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO;KACR;IACD,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC;QAC5C,OAAO,EAAE,kBAAkB,CAAC,EAAE,CAAC;KAChC,CAAC;AACJ,CAAC"}