@autorest/powershell 4.0.0-dev.8 → 4.0.617

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 (316) hide show
  1. package/.rush/temp/operation/build/state.json +3 -0
  2. package/.rush/temp/package-deps_build.json +106 -103
  3. package/.rush/temp/shrinkwrap-deps.json +182 -234
  4. package/dist/cmdlets/class.d.ts +12 -1
  5. package/dist/cmdlets/class.d.ts.map +1 -1
  6. package/dist/cmdlets/class.js +693 -532
  7. package/dist/cmdlets/class.js.map +1 -1
  8. package/dist/cmdlets/namespace.d.ts.map +1 -1
  9. package/dist/cmdlets/namespace.js +38 -5
  10. package/dist/cmdlets/namespace.js.map +1 -1
  11. package/dist/enums/namespace.js +5 -5
  12. package/dist/enums/namespace.js.map +1 -1
  13. package/dist/generators/psm1.custom.js +2 -2
  14. package/dist/generators/psm1.custom.js.map +1 -1
  15. package/dist/generators/psm1.internal.js +2 -2
  16. package/dist/generators/psm1.internal.js.map +1 -1
  17. package/dist/generators/psm1.js +1 -1
  18. package/dist/generators/psm1.js.map +1 -1
  19. package/dist/generators/script-cmdlet.js +18 -18
  20. package/dist/generators/script-cmdlet.js.map +1 -1
  21. package/dist/internal/name-inferrer.d.ts +1 -1
  22. package/dist/internal/name-inferrer.d.ts.map +1 -1
  23. package/dist/internal/name-inferrer.js +12 -12
  24. package/dist/internal/name-inferrer.js.map +1 -1
  25. package/dist/internal/powershell-declarations.d.ts +2 -0
  26. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  27. package/dist/internal/powershell-declarations.js +4 -2
  28. package/dist/internal/powershell-declarations.js.map +1 -1
  29. package/dist/internal/project.d.ts +3 -5
  30. package/dist/internal/project.d.ts.map +1 -1
  31. package/dist/internal/project.js +14 -18
  32. package/dist/internal/project.js.map +1 -1
  33. package/dist/internal/state.d.ts +1 -1
  34. package/dist/internal/state.d.ts.map +1 -1
  35. package/dist/llcsharp/clientruntime.d.ts +1 -0
  36. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  37. package/dist/llcsharp/clientruntime.js +12 -11
  38. package/dist/llcsharp/clientruntime.js.map +1 -1
  39. package/dist/llcsharp/code-model.d.ts +7 -7
  40. package/dist/llcsharp/code-model.d.ts.map +1 -1
  41. package/dist/llcsharp/enums/enum.d.ts +1 -1
  42. package/dist/llcsharp/enums/enum.d.ts.map +1 -1
  43. package/dist/llcsharp/enums/enum.js +42 -42
  44. package/dist/llcsharp/enums/enum.js.map +1 -1
  45. package/dist/llcsharp/exports.js +5 -1
  46. package/dist/llcsharp/exports.js.map +1 -1
  47. package/dist/llcsharp/generator.d.ts +1 -1
  48. package/dist/llcsharp/generator.d.ts.map +1 -1
  49. package/dist/llcsharp/model/idictionary.js +16 -16
  50. package/dist/llcsharp/model/idictionary.js.map +1 -1
  51. package/dist/llcsharp/model/interface.d.ts +1 -1
  52. package/dist/llcsharp/model/interface.d.ts.map +1 -1
  53. package/dist/llcsharp/model/interface.js +25 -11
  54. package/dist/llcsharp/model/interface.js.map +1 -1
  55. package/dist/llcsharp/model/model-class-dictionary.js +18 -18
  56. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  57. package/dist/llcsharp/model/model-class-json.js +19 -19
  58. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  59. package/dist/llcsharp/model/model-class-serializer.d.ts +1 -1
  60. package/dist/llcsharp/model/model-class-serializer.d.ts.map +1 -1
  61. package/dist/llcsharp/model/model-class-serializer.js +6 -6
  62. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  63. package/dist/llcsharp/model/model-class.d.ts +1 -1
  64. package/dist/llcsharp/model/model-class.d.ts.map +1 -1
  65. package/dist/llcsharp/model/model-class.js +97 -89
  66. package/dist/llcsharp/model/model-class.js.map +1 -1
  67. package/dist/llcsharp/model/namespace.d.ts +1 -1
  68. package/dist/llcsharp/model/namespace.d.ts.map +1 -1
  69. package/dist/llcsharp/model/namespace.js +4 -12
  70. package/dist/llcsharp/model/namespace.js.map +1 -1
  71. package/dist/llcsharp/model/property.d.ts +1 -1
  72. package/dist/llcsharp/model/property.d.ts.map +1 -1
  73. package/dist/llcsharp/model/property.js +20 -20
  74. package/dist/llcsharp/model/property.js.map +1 -1
  75. package/dist/llcsharp/operation/api-class.d.ts.map +1 -1
  76. package/dist/llcsharp/operation/api-class.js +26 -1
  77. package/dist/llcsharp/operation/api-class.js.map +1 -1
  78. package/dist/llcsharp/operation/method.d.ts +10 -5
  79. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  80. package/dist/llcsharp/operation/method.js +276 -134
  81. package/dist/llcsharp/operation/method.js.map +1 -1
  82. package/dist/llcsharp/operation/parameter.d.ts +1 -1
  83. package/dist/llcsharp/operation/parameter.d.ts.map +1 -1
  84. package/dist/llcsharp/operation/parameter.js +10 -10
  85. package/dist/llcsharp/operation/parameter.js.map +1 -1
  86. package/dist/llcsharp/project.d.ts +4 -2
  87. package/dist/llcsharp/project.d.ts.map +1 -1
  88. package/dist/llcsharp/project.js +11 -3
  89. package/dist/llcsharp/project.js.map +1 -1
  90. package/dist/llcsharp/schema/Uuid.d.ts +1 -1
  91. package/dist/llcsharp/schema/Uuid.d.ts.map +1 -1
  92. package/dist/llcsharp/schema/Uuid.js +2 -2
  93. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  94. package/dist/llcsharp/schema/array.d.ts +1 -1
  95. package/dist/llcsharp/schema/array.d.ts.map +1 -1
  96. package/dist/llcsharp/schema/array.js +45 -43
  97. package/dist/llcsharp/schema/array.js.map +1 -1
  98. package/dist/llcsharp/schema/binary.d.ts +1 -1
  99. package/dist/llcsharp/schema/binary.d.ts.map +1 -1
  100. package/dist/llcsharp/schema/binary.js +9 -9
  101. package/dist/llcsharp/schema/binary.js.map +1 -1
  102. package/dist/llcsharp/schema/boolean.d.ts +1 -1
  103. package/dist/llcsharp/schema/boolean.d.ts.map +1 -1
  104. package/dist/llcsharp/schema/byte-array.d.ts +1 -1
  105. package/dist/llcsharp/schema/byte-array.d.ts.map +1 -1
  106. package/dist/llcsharp/schema/byte-array.js +24 -24
  107. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  108. package/dist/llcsharp/schema/char.d.ts +1 -1
  109. package/dist/llcsharp/schema/char.d.ts.map +1 -1
  110. package/dist/llcsharp/schema/char.js +1 -1
  111. package/dist/llcsharp/schema/char.js.map +1 -1
  112. package/dist/llcsharp/schema/date-time.d.ts +1 -1
  113. package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
  114. package/dist/llcsharp/schema/date-time.js +45 -41
  115. package/dist/llcsharp/schema/date-time.js.map +1 -1
  116. package/dist/llcsharp/schema/date.d.ts +1 -1
  117. package/dist/llcsharp/schema/date.d.ts.map +1 -1
  118. package/dist/llcsharp/schema/duration.d.ts +1 -1
  119. package/dist/llcsharp/schema/duration.d.ts.map +1 -1
  120. package/dist/llcsharp/schema/duration.js +9 -7
  121. package/dist/llcsharp/schema/duration.js.map +1 -1
  122. package/dist/llcsharp/schema/enum.d.ts +6 -2
  123. package/dist/llcsharp/schema/enum.d.ts.map +1 -1
  124. package/dist/llcsharp/schema/enum.js +13 -4
  125. package/dist/llcsharp/schema/enum.js.map +1 -1
  126. package/dist/llcsharp/schema/extended-type-declaration.d.ts +1 -1
  127. package/dist/llcsharp/schema/extended-type-declaration.d.ts.map +1 -1
  128. package/dist/llcsharp/schema/fixed-array.d.ts +1 -1
  129. package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -1
  130. package/dist/llcsharp/schema/fixed-array.js +44 -42
  131. package/dist/llcsharp/schema/fixed-array.js.map +1 -1
  132. package/dist/llcsharp/schema/integer.d.ts +1 -1
  133. package/dist/llcsharp/schema/integer.d.ts.map +1 -1
  134. package/dist/llcsharp/schema/integer.js +5 -5
  135. package/dist/llcsharp/schema/integer.js.map +1 -1
  136. package/dist/llcsharp/schema/object.d.ts +1 -1
  137. package/dist/llcsharp/schema/object.d.ts.map +1 -1
  138. package/dist/llcsharp/schema/object.js +28 -28
  139. package/dist/llcsharp/schema/object.js.map +1 -1
  140. package/dist/llcsharp/schema/password.d.ts +1 -1
  141. package/dist/llcsharp/schema/password.d.ts.map +1 -1
  142. package/dist/llcsharp/schema/password.js +13 -13
  143. package/dist/llcsharp/schema/password.js.map +1 -1
  144. package/dist/llcsharp/schema/primitive.d.ts +1 -1
  145. package/dist/llcsharp/schema/primitive.d.ts.map +1 -1
  146. package/dist/llcsharp/schema/primitive.js +40 -37
  147. package/dist/llcsharp/schema/primitive.js.map +1 -1
  148. package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
  149. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  150. package/dist/llcsharp/schema/schema-resolver.js +4 -9
  151. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  152. package/dist/llcsharp/schema/string.d.ts +1 -1
  153. package/dist/llcsharp/schema/string.d.ts.map +1 -1
  154. package/dist/llcsharp/schema/string.js +48 -44
  155. package/dist/llcsharp/schema/string.js.map +1 -1
  156. package/dist/llcsharp/schema/uri.d.ts +1 -1
  157. package/dist/llcsharp/schema/uri.d.ts.map +1 -1
  158. package/dist/llcsharp/schema/uri.js +2 -2
  159. package/dist/llcsharp/schema/uri.js.map +1 -1
  160. package/dist/llcsharp/validations.js +2 -2
  161. package/dist/llcsharp/validations.js.map +1 -1
  162. package/dist/main.js +2 -2
  163. package/dist/main.js.map +1 -1
  164. package/dist/models/model-extensions.d.ts +1 -1
  165. package/dist/models/model-extensions.d.ts.map +1 -1
  166. package/dist/models/model-extensions.js +39 -39
  167. package/dist/models/model-extensions.js.map +1 -1
  168. package/dist/module/module-class.js +8 -8
  169. package/dist/module/module-class.js.map +1 -1
  170. package/dist/module/module-namespace.js +3 -3
  171. package/dist/module/module-namespace.js.map +1 -1
  172. package/dist/plugins/add-azure-completers-v2.d.ts +1 -1
  173. package/dist/plugins/add-azure-completers-v2.d.ts.map +1 -1
  174. package/dist/plugins/add-azure-completers-v2.js +3 -3
  175. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  176. package/dist/plugins/create-commands-v2.d.ts +9 -7
  177. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  178. package/dist/plugins/create-commands-v2.js +233 -62
  179. package/dist/plugins/create-commands-v2.js.map +1 -1
  180. package/dist/plugins/cs-namer-v2.d.ts +1 -1
  181. package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
  182. package/dist/plugins/cs-namer-v2.js +40 -40
  183. package/dist/plugins/cs-namer-v2.js.map +1 -1
  184. package/dist/plugins/llcsharp-v2.d.ts +1 -1
  185. package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
  186. package/dist/plugins/llcsharp-v2.js +12 -7
  187. package/dist/plugins/llcsharp-v2.js.map +1 -1
  188. package/dist/plugins/modifiers-v2.d.ts +1 -1
  189. package/dist/plugins/modifiers-v2.d.ts.map +1 -1
  190. package/dist/plugins/modifiers-v2.js +109 -78
  191. package/dist/plugins/modifiers-v2.js.map +1 -1
  192. package/dist/plugins/plugin-create-inline-properties.d.ts +1 -1
  193. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  194. package/dist/plugins/plugin-create-inline-properties.js +42 -31
  195. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  196. package/dist/plugins/plugin-tweak-m4-model.d.ts +1 -1
  197. package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
  198. package/dist/plugins/plugin-tweak-m4-model.js +19 -7
  199. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  200. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts +1 -1
  201. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts.map +1 -1
  202. package/dist/plugins/plugin-tweak-model-azure-v2.js +17 -17
  203. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  204. package/dist/plugins/plugin-tweak-model.d.ts +1 -1
  205. package/dist/plugins/plugin-tweak-model.d.ts.map +1 -1
  206. package/dist/plugins/plugin-tweak-model.js +31 -31
  207. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  208. package/dist/plugins/powershell-v2.d.ts +1 -1
  209. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  210. package/dist/plugins/powershell-v2.js +26 -26
  211. package/dist/plugins/powershell-v2.js.map +1 -1
  212. package/dist/plugins/ps-namer-v2.d.ts +1 -1
  213. package/dist/plugins/ps-namer-v2.d.ts.map +1 -1
  214. package/dist/plugins/ps-namer-v2.js +31 -31
  215. package/dist/plugins/ps-namer-v2.js.map +1 -1
  216. package/dist/plugins/sdk-create-inline-properties.d.ts +1 -1
  217. package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
  218. package/dist/plugins/sdk-create-inline-properties.js +37 -37
  219. package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
  220. package/dist/plugins/sdk-cs-namer.d.ts +1 -1
  221. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
  222. package/dist/plugins/sdk-cs-namer.js +21 -21
  223. package/dist/plugins/sdk-cs-namer.js.map +1 -1
  224. package/dist/plugins/sdk-cs-simplifier.d.ts +1 -1
  225. package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -1
  226. package/dist/plugins/sdk-cs-simplifier.js +3 -3
  227. package/dist/plugins/sdk-cs-simplifier.js.map +1 -1
  228. package/dist/plugins/sdk-generate.d.ts +1 -1
  229. package/dist/plugins/sdk-generate.d.ts.map +1 -1
  230. package/dist/plugins/sdk-generate.js +14 -14
  231. package/dist/plugins/sdk-generate.js.map +1 -1
  232. package/dist/plugins/sdk-tweak-model.d.ts +1 -1
  233. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
  234. package/dist/plugins/sdk-tweak-model.js +23 -23
  235. package/dist/plugins/sdk-tweak-model.js.map +1 -1
  236. package/dist/sdk/project.d.ts +2 -2
  237. package/dist/sdk/project.d.ts.map +1 -1
  238. package/dist/sdk/project.js +8 -8
  239. package/dist/sdk/project.js.map +1 -1
  240. package/dist/sdk/state.d.ts +2 -2
  241. package/dist/sdk/state.d.ts.map +1 -1
  242. package/dist/sdk/utility.d.ts +1 -1
  243. package/dist/sdk/utility.d.ts.map +1 -1
  244. package/dist/sdk/utility.js +17 -16
  245. package/dist/sdk/utility.js.map +1 -1
  246. package/dist/utils/PwshModel.d.ts +1 -1
  247. package/dist/utils/PwshModel.d.ts.map +1 -1
  248. package/dist/utils/PwshModel.js +1 -1
  249. package/dist/utils/PwshModel.js.map +1 -1
  250. package/dist/utils/SdkModel.d.ts +1 -1
  251. package/dist/utils/SdkModel.d.ts.map +1 -1
  252. package/dist/utils/SdkModel.js +1 -1
  253. package/dist/utils/SdkModel.js.map +1 -1
  254. package/dist/utils/command-operation.d.ts +9 -3
  255. package/dist/utils/command-operation.d.ts.map +1 -1
  256. package/dist/utils/command-operation.js +24 -4
  257. package/dist/utils/command-operation.js.map +1 -1
  258. package/dist/utils/components.d.ts +1 -1
  259. package/dist/utils/components.d.ts.map +1 -1
  260. package/dist/utils/components.js +2 -2
  261. package/dist/utils/components.js.map +1 -1
  262. package/dist/utils/http-operation.d.ts +2 -0
  263. package/dist/utils/http-operation.d.ts.map +1 -1
  264. package/dist/utils/http-operation.js +16 -12
  265. package/dist/utils/http-operation.js.map +1 -1
  266. package/dist/utils/model-state.d.ts +1 -1
  267. package/dist/utils/model-state.d.ts.map +1 -1
  268. package/dist/utils/model-state.js +20 -20
  269. package/dist/utils/model-state.js.map +1 -1
  270. package/dist/utils/programatic-operation.d.ts +1 -1
  271. package/dist/utils/programatic-operation.d.ts.map +1 -1
  272. package/dist/utils/programatic-operation.js +1 -1
  273. package/dist/utils/programatic-operation.js.map +1 -1
  274. package/dist/utils/resolve-conflicts.js +8 -8
  275. package/dist/utils/resolve-conflicts.js.map +1 -1
  276. package/dist/utils/resourceName.d.ts +3 -0
  277. package/dist/utils/resourceName.d.ts.map +1 -0
  278. package/dist/utils/resourceName.js +29 -0
  279. package/dist/utils/resourceName.js.map +1 -0
  280. package/dist/utils/schema.d.ts +1 -1
  281. package/dist/utils/schema.d.ts.map +1 -1
  282. package/dist/utils/schema.js +11 -11
  283. package/dist/utils/schema.js.map +1 -1
  284. package/dist/utils/security-scheme.d.ts +2 -2
  285. package/dist/utils/security-scheme.d.ts.map +1 -1
  286. package/dist/utils/security-scheme.js +2 -2
  287. package/dist/utils/security-scheme.js.map +1 -1
  288. package/dist/utils/sort-parameters.d.ts +3 -0
  289. package/dist/utils/sort-parameters.d.ts.map +1 -0
  290. package/dist/utils/sort-parameters.js +33 -0
  291. package/dist/utils/sort-parameters.js.map +1 -0
  292. package/package.json +7 -7
  293. package/resources/assets/build-module.ps1 +9 -4
  294. package/resources/assets/check-dependencies.ps1 +3 -3
  295. package/resources/assets/create-model-cmdlets.ps1 +33 -5
  296. package/resources/assets/export-surface.ps1 +3 -3
  297. package/resources/assets/generate-help.ps1 +5 -5
  298. package/resources/assets/generate-portal-ux.ps1 +3 -3
  299. package/resources/assets/run-module.ps1 +4 -4
  300. package/resources/assets/test-module.ps1 +5 -5
  301. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
  302. package/resources/psruntime/Attributes/PSArgumentCompleterAttribute.cs +52 -0
  303. package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
  304. package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +4 -1
  305. package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +6 -4
  306. package/resources/psruntime/BuildTime/MarkdownRenderer.cs +16 -8
  307. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +20 -3
  308. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +28 -2
  309. package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
  310. package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
  311. package/resources/psruntime/MessageAttribute.cs +23 -52
  312. package/resources/psruntime/MessageAttributeHelper.cs +5 -1
  313. package/resources/psruntime/Properties/Resources.Designer.cs +15 -2
  314. package/resources/psruntime/Properties/Resources.resx +4 -1
  315. package/resources/runtime/csharp/pipeline/ISendAsync.cs +113 -0
  316. package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
@@ -5,10 +5,10 @@
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createCommandsV2 = exports.Inferrer = exports.titleToAzureServiceName = void 0;
8
- const codemodel_1 = require("@azure-tools/codemodel");
8
+ const codemodel_1 = require("@autorest/codemodel");
9
9
  const codegen_1 = require("@azure-tools/codegen");
10
10
  const linq_1 = require("@azure-tools/linq");
11
- const autorest_extension_base_1 = require("@azure-tools/autorest-extension-base");
11
+ const extension_base_1 = require("@autorest/extension-base");
12
12
  const linq_2 = require("@azure-tools/linq");
13
13
  const verbs_1 = require("../internal/verbs");
14
14
  const components_1 = require("../utils/components");
@@ -16,10 +16,14 @@ const model_state_1 = require("../utils/model-state");
16
16
  //import { Schema as SchemaV3 } from '../utils/schema';
17
17
  const command_operation_1 = require("../utils/command-operation");
18
18
  const command_operation_2 = require("../utils/command-operation");
19
+ const codemodel_2 = require("@autorest/codemodel");
20
+ const resourceName_1 = require("../utils/resourceName");
21
+ const http_operation_1 = require("../utils/http-operation");
22
+ const specialWords = { in: ['sign'] };
19
23
  // UNUSED: Moved to plugin-tweak-model.ts in remodeler
20
24
  // For now, we are not dynamically changing the service-name. Instead, we would figure out a method to change it during the creation of service readme's.
21
25
  function titleToAzureServiceName(title) {
22
- const titleCamelCase = codegen_1.pascalCase(codegen_1.deconstruct(title)).trim();
26
+ const titleCamelCase = (0, codegen_1.pascalCase)((0, codegen_1.deconstruct)(title)).trim();
23
27
  const serviceName = titleCamelCase
24
28
  // Remove: !StartsWith(Management)AndContains(Management), Client, Azure, Microsoft, APIs, API, REST
25
29
  .replace(/(?!^Management)(?=.*)Management|Client|Azure|Microsoft|APIs|API|REST/g, '')
@@ -34,8 +38,8 @@ pluralizationService.addWord('database', 'databases');
34
38
  pluralizationService.addWord('Premise', 'Premises');
35
39
  pluralizationService.addWord('premise', 'premises');
36
40
  function fn(active, remaining, result) {
37
- if (linq_1.length(active) || linq_1.length(remaining)) {
38
- if (linq_1.length(remaining)) {
41
+ if ((0, linq_1.length)(active) || (0, linq_1.length)(remaining)) {
42
+ if ((0, linq_1.length)(remaining)) {
39
43
  fn([...active, remaining[0]], remaining.slice(1), result);
40
44
  fn(active, remaining.slice(1), result);
41
45
  }
@@ -48,8 +52,25 @@ function fn(active, remaining, result) {
48
52
  function combinations(elements) {
49
53
  return fn([], elements, []);
50
54
  }
55
+ function filterSpecialWords(preposition, parts) {
56
+ let start = 0;
57
+ let idx = -1;
58
+ if (specialWords[preposition] !== undefined) {
59
+ do {
60
+ idx = parts.indexOf(preposition, start);
61
+ if (idx <= 0 || !specialWords[preposition].includes(parts[idx - 1])) {
62
+ return idx;
63
+ }
64
+ else {
65
+ start = idx + 1;
66
+ }
67
+ // eslint-disable-next-line no-constant-condition
68
+ } while (true);
69
+ }
70
+ return parts.indexOf(preposition);
71
+ }
51
72
  function splitOnPreposition(preposition, parts) {
52
- const i = parts.indexOf(preposition);
73
+ const i = filterSpecialWords(preposition, parts);
53
74
  if (i > 0) {
54
75
  return [
55
76
  parts.slice(0, i),
@@ -83,6 +104,7 @@ class Inferrer {
83
104
  // }
84
105
  // for tracking unique operation identities
85
106
  this.operationIdentities = new Set();
107
+ this.reservedPathParam = new Set(['SubscriptionId', 'resourceGroupName']);
86
108
  }
87
109
  async init() {
88
110
  this.commonParameters = await this.state.getValue('azure', false) ? [
@@ -93,37 +115,80 @@ class Inferrer {
93
115
  this.isAzure = await this.state.getValue('azure', false);
94
116
  this.prefix = await this.state.getValue('prefix');
95
117
  this.serviceName = titleToAzureServiceName(await this.state.getValue('service-name'));
118
+ if (this.isAzure) {
119
+ this.supportJsonInput = await this.state.getValue('support-json-input', true);
120
+ }
121
+ else {
122
+ this.supportJsonInput = await this.state.getValue('support-json-input', false);
123
+ }
96
124
  this.state.setValue('service-name', this.serviceName);
97
125
  this.subjectPrefix = await this.state.getValue('subject-prefix');
98
126
  this.state.setValue('isAzure', this.isAzure);
99
127
  this.state.setValue('prefix', this.prefix);
100
128
  const model = this.state.model;
101
129
  this.state.message({
102
- Channel: autorest_extension_base_1.Channel.Debug, Text: `[CMDLET-PREFIX] => '${model.language.default.prefix}'`
130
+ Channel: extension_base_1.Channel.Debug, Text: `[CMDLET-PREFIX] => '${model.language.default.prefix}'`
103
131
  });
104
132
  model.language.default.serviceName = this.serviceName;
105
133
  this.state.message({
106
- Channel: autorest_extension_base_1.Channel.Debug, Text: `[SERVICE-NAME] => '${model.language.default.serviceName}'`
134
+ Channel: extension_base_1.Channel.Debug, Text: `[SERVICE-NAME] => '${model.language.default.serviceName}'`
107
135
  });
108
136
  model.language.default.subjectPrefix = this.subjectPrefix;
109
137
  this.state.message({
110
- Channel: autorest_extension_base_1.Channel.Debug, Text: `[SUBJECT-PREFIX] => '${model.language.default.subjectPrefix}'`
138
+ Channel: extension_base_1.Channel.Debug, Text: `[SUBJECT-PREFIX] => '${model.language.default.subjectPrefix}'`
111
139
  });
112
140
  return this;
113
141
  }
114
142
  async createCommands() {
143
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
115
144
  const model = this.state.model;
116
145
  this.state.model.commands = {
117
146
  operations: new linq_1.Dictionary(),
118
147
  parameters: new linq_1.Dictionary(),
119
148
  };
120
- this.state.message({ Channel: autorest_extension_base_1.Channel.Debug, Text: 'detecting high level commands...' });
121
- for (const operationGroup of linq_1.values(model.operationGroups)) {
122
- for (const operation of linq_1.values(operationGroup.operations)) {
149
+ const disableGetPut = await this.state.getValue('disable-getput', false);
150
+ this.state.message({ Channel: extension_base_1.Channel.Debug, Text: 'detecting high level commands...' });
151
+ for (const operationGroup of (0, linq_1.values)(model.operationGroups)) {
152
+ let hasPatch = false;
153
+ const getOperations = [];
154
+ let putOperation;
155
+ for (const operation of (0, linq_1.values)(operationGroup.operations)) {
156
+ if (((_d = (_c = (_b = (_a = operation.requests) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.protocol) === null || _c === void 0 ? void 0 : _c.http) === null || _d === void 0 ? void 0 : _d.method.toLowerCase()) === 'patch') {
157
+ hasPatch = true;
158
+ }
159
+ else if (((_h = (_g = (_f = (_e = operation.requests) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.protocol) === null || _g === void 0 ? void 0 : _g.http) === null || _h === void 0 ? void 0 : _h.method.toLowerCase()) === 'get') {
160
+ getOperations.push(operation);
161
+ }
162
+ else if (((_m = (_l = (_k = (_j = operation.requests) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.protocol) === null || _l === void 0 ? void 0 : _l.http) === null || _m === void 0 ? void 0 : _m.method.toLowerCase()) === 'put') {
163
+ putOperation = operation;
164
+ }
123
165
  for (const variant of await this.inferCommandNames(operation, operationGroup.$key, this.state)) {
124
166
  await this.addVariants(operation.parameters, operation, variant, '', this.state);
125
167
  }
126
168
  }
169
+ /*
170
+ generate variants for Update(Get+Put) for subjects only if:
171
+ - there is no patch operation
172
+ - there is a get operation
173
+ - there is a put operation
174
+ - get operation path is the same as put operation path
175
+ - there is only one put reqeust schema
176
+ - get operation response schema type is the same as put operation request schema type
177
+ */
178
+ if (this.isAzure
179
+ && !disableGetPut
180
+ && !hasPatch
181
+ && getOperations
182
+ && putOperation
183
+ && ((_o = putOperation.requests) === null || _o === void 0 ? void 0 : _o.length) == 1) {
184
+ const getOperation = getOperations.find(getOperation => { var _a, _b, _c, _d, _e, _f, _g, _h; return ((_d = (_c = (_b = (_a = getOperation.requests) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.protocol) === null || _c === void 0 ? void 0 : _c.http) === null || _d === void 0 ? void 0 : _d.path) === ((_h = (_g = (_f = (_e = putOperation === null || putOperation === void 0 ? void 0 : putOperation.requests) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.protocol) === null || _g === void 0 ? void 0 : _g.http) === null || _h === void 0 ? void 0 : _h.path); });
185
+ const hasQueryParameter = (_p = getOperation === null || getOperation === void 0 ? void 0 : getOperation.parameters) === null || _p === void 0 ? void 0 : _p.find(p => { var _a; return ((_a = p.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === 'query' && p.language.default.name !== 'apiVersion'; });
186
+ //parameter.protocal.http.in === 'body' probably only applies to open api 2.0
187
+ const schema = (_t = (_s = (_r = (_q = putOperation === null || putOperation === void 0 ? void 0 : putOperation.requests) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.parameters) === null || _s === void 0 ? void 0 : _s.find(p => { var _a; return ((_a = p.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === 'body'; })) === null || _t === void 0 ? void 0 : _t.schema;
188
+ if (getOperation && !hasQueryParameter && schema && [...(0, linq_1.values)(getOperation === null || getOperation === void 0 ? void 0 : getOperation.responses), ...(0, linq_1.values)(getOperation === null || getOperation === void 0 ? void 0 : getOperation.exceptions)].filter(each => { var _a, _b; return ((_b = (_a = each.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]) !== 'default' && each.schema !== schema; }).length === 0) {
189
+ await this.addVariants(putOperation.parameters, putOperation, this.createCommandVariant('create', [operationGroup.$key], [], this.state.model), '', this.state, [getOperation], command_operation_1.CommandType.GetPut);
190
+ }
191
+ }
127
192
  }
128
193
  // for (const operation of values(model.http.operations)) {
129
194
  // for (const variant of await this.inferCommandNames(operation, this.state)) {
@@ -136,34 +201,34 @@ class Inferrer {
136
201
  inferCommand(operation, group, suffix = []) {
137
202
  operation = operation.filter(each => each !== 'all');
138
203
  // no instant match
139
- switch (linq_1.length(operation)) {
204
+ switch ((0, linq_1.length)(operation)) {
140
205
  case 0:
141
206
  throw new Error('Missing operation id?');
142
207
  case 1:
143
208
  // simple operation, just an id with a single value
144
209
  // OPERATION => OPERATION-GROUP
145
210
  return [
146
- this.createCommandVariant(operation[0], codegen_1.deconstruct(group), suffix, this.state.model)
211
+ this.createCommandVariant(operation[0], [group], suffix, this.state.model)
147
212
  ];
148
213
  case 2:
149
214
  // should try to infer [SUBJECT] and [ACTION] from operation
150
215
  if (verbs_1.verbs.has(operation[0])) {
151
216
  // [ACTION][SUBJECT]
152
217
  return [
153
- this.createCommandVariant(operation[0], [...codegen_1.deconstruct(group), operation[1]], suffix, this.state.model)
218
+ this.createCommandVariant(operation[0], [group, operation[1]], suffix, this.state.model)
154
219
  ];
155
220
  }
156
221
  if (verbs_1.verbs.has(operation[1])) {
157
222
  // [SUBJECT][ACTION]
158
223
  return [
159
- this.createCommandVariant(operation[1], [...codegen_1.deconstruct(group), operation[0]], suffix, this.state.model)
224
+ this.createCommandVariant(operation[1], [group, operation[0]], suffix, this.state.model)
160
225
  ];
161
226
  }
162
227
  // can't tell which is the [ACTION] -- let's return it the way we used to,
163
228
  // but now let's mention that we are doing that.
164
229
  this.state.warning(`Operation ${operation[0]}/${operation[1]} is inferred without finding action.`, [], {});
165
230
  return [
166
- this.createCommandVariant(operation[0], [...codegen_1.deconstruct(group), operation[1]], suffix, this.state.model)
231
+ this.createCommandVariant(operation[0], [group, operation[1]], suffix, this.state.model)
167
232
  ];
168
233
  }
169
234
  // three or more words.
@@ -183,27 +248,27 @@ class Inferrer {
183
248
  return [...this.inferCommand(parts[0], group, parts[1])];
184
249
  }
185
250
  // if not, then seek out a verb from there.
186
- for (let i = 0; i < linq_1.length(operation); i++) {
251
+ for (let i = 0; i < (0, linq_1.length)(operation); i++) {
187
252
  if (verbs_1.verbs.has(operation[i])) {
188
253
  // if the action is first
189
254
  if (i === 0) {
190
255
  // everything else is the subject
191
- return [this.createCommandVariant(operation[i], group ? [...codegen_1.deconstruct(group), ...operation.slice(i + 1)] : operation.slice(i + 1), suffix, this.state.model)];
256
+ return [this.createCommandVariant(operation[i], group ? [group, ...operation.slice(i + 1)] : operation.slice(i + 1), suffix, this.state.model)];
192
257
  }
193
- if (i === linq_1.length(operation) - 1) {
258
+ if (i === (0, linq_1.length)(operation) - 1) {
194
259
  // if it's last, the subject would be the first thing
195
- return [this.createCommandVariant(operation[i], group ? [...codegen_1.deconstruct(group), ...operation.slice(0, i)] : operation.slice(0, i), suffix, this.state.model)];
260
+ return [this.createCommandVariant(operation[i], group ? [group, ...operation.slice(0, i)] : operation.slice(0, i), suffix, this.state.model)];
196
261
  }
197
262
  // otherwise
198
263
  // things before are part of the subject
199
264
  // things after the verb should be part of the suffix
200
- return [this.createCommandVariant(operation[i], group ? [...codegen_1.deconstruct(group), ...operation.slice(i, i)] : operation.slice(i, i), [...suffix, ...operation.slice(i + 1)], this.state.model)];
265
+ return [this.createCommandVariant(operation[i], group ? [group, ...operation.slice(i, i)] : operation.slice(i, i), [...suffix, ...operation.slice(i + 1)], this.state.model)];
201
266
  }
202
267
  }
203
268
  // so couldn't tell what the action was.
204
269
  // fallback to the original behavior with a warning.
205
270
  this.state.warning(`Operation ${operation[0]}/${operation[1]} is inferred without finding action.`, [], {});
206
- return [this.createCommandVariant(operation[0], group ? [...codegen_1.deconstruct(group), ...operation.slice(1)] : operation.slice(1), [...suffix, ...operation.slice(1)], this.state.model)];
271
+ return [this.createCommandVariant(operation[0], group ? [group, ...operation.slice(1)] : operation.slice(1), [...suffix, ...operation.slice(1)], this.state.model)];
207
272
  }
208
273
  async inferCommandNames(op, group, state) {
209
274
  const method = op.language.default.name;
@@ -219,10 +284,10 @@ class Inferrer {
219
284
  // }
220
285
  // group = pascalCase(op.tags) || '';
221
286
  // }
222
- const groupWords = codegen_1.deconstruct(group);
287
+ const groupWords = [...(0, codegen_1.removeSequentialDuplicates)((0, codegen_1.deconstruct)(group))];
223
288
  groupWords[groupWords.length - 1] = pluralizationService.singularize(groupWords.last);
224
- group = codegen_1.pascalCase(groupWords);
225
- const operation = codegen_1.deconstruct(method);
289
+ group = (0, codegen_1.pascalCase)(groupWords);
290
+ const operation = (0, codegen_1.deconstruct)(method);
226
291
  // instant match
227
292
  if (this.verbMap[method]) {
228
293
  return [this.createCommandVariant(method, [group], [], state.model)];
@@ -230,8 +295,11 @@ class Inferrer {
230
295
  // dig deeper.
231
296
  return this.inferCommand(operation, group);
232
297
  }
233
- async addVariant(vname, body, bodyParameterName, parameters, operation, variant, state) {
234
- const op = await this.addCommandOperation(vname, parameters, operation, variant, state);
298
+ async addVariant(vname, body, bodyParameterName, parameters, operation, variant, state, preOperations, commandType) {
299
+ // beth: filter command description for New/Update command
300
+ const createOrUpdateRegex = /creates? or updates?/gi;
301
+ operation.language.default.description = operation.language.default.description.replace(createOrUpdateRegex, `${variant.action.capitalize()}`);
302
+ const op = await this.addCommandOperation(vname, parameters, operation, variant, state, preOperations, commandType);
235
303
  // if this has a body with it, let's add that parameter
236
304
  if (body && body.schema) {
237
305
  op.details.default.hasBody = true;
@@ -239,7 +307,7 @@ class Inferrer {
239
307
  details: {
240
308
  default: {
241
309
  description: body.schema.language.default.description,
242
- name: codegen_1.pascalCase(bodyParameterName),
310
+ name: (0, codegen_1.pascalCase)(bodyParameterName),
243
311
  isBodyParameter: true,
244
312
  }
245
313
  }
@@ -247,21 +315,22 @@ class Inferrer {
247
315
  // let's add a variant where it's expanded out.
248
316
  // *IF* the body is an object or dictionary
249
317
  if (body.schema.type === codemodel_1.SchemaType.Object || body.schema.type === codemodel_1.SchemaType.Dictionary || body.schema.type === codemodel_1.SchemaType.Any) {
250
- const opExpanded = await this.addCommandOperation(`${vname}Expanded`, parameters, operation, variant, state);
318
+ const opExpanded = await this.addCommandOperation(`${vname}Expanded`, parameters, operation, variant, state, preOperations, commandType);
251
319
  opExpanded.details.default.dropBodyParameter = true;
252
320
  opExpanded.parameters.push(new components_1.IParameter(`${bodyParameterName}Body`, body.schema, {
253
321
  details: {
254
322
  default: {
255
323
  description: body.schema.language.default.description,
256
- name: codegen_1.pascalCase(`${bodyParameterName}Body`),
324
+ name: (0, codegen_1.pascalCase)(`${bodyParameterName}Body`),
257
325
  isBodyParameter: true,
258
326
  }
259
327
  }
260
328
  }));
261
329
  }
262
330
  }
331
+ return op;
263
332
  }
264
- async addCommandOperation(vname, parameters, operation, variant, state) {
333
+ async addCommandOperation(vname, parameters, operation, variant, state, preOperations, commandType) {
265
334
  // skip-for-time-being following code seems redundant -----
266
335
  // let apiversion = '';
267
336
  var _a, _b;
@@ -276,12 +345,12 @@ class Inferrer {
276
345
  // ----------------------------------------------------------
277
346
  // if vname is > 64 characters, let's trim it
278
347
  // after trimming it, make sure there aren't any other operation with a name that's exactly the same
279
- if (linq_1.length(vname) > 64) {
280
- const names = codegen_1.deconstruct(vname);
348
+ if ((0, linq_1.length)(vname) > 64) {
349
+ const names = (0, codegen_1.deconstruct)(vname);
281
350
  let newVName = '';
282
- for (let i = 0; i < linq_1.length(names); i++) {
283
- newVName = codegen_1.pascalCase(names.slice(0, i));
284
- if (linq_1.length(newVName) > 60) {
351
+ for (let i = 0; i < (0, linq_1.length)(names); i++) {
352
+ newVName = (0, codegen_1.pascalCase)(names.slice(0, i));
353
+ if ((0, linq_1.length)(newVName) > 60) {
285
354
  break;
286
355
  }
287
356
  }
@@ -296,7 +365,16 @@ class Inferrer {
296
365
  }
297
366
  this.operationIdentities.add(fname);
298
367
  variant.variant = vname;
299
- vname = codegen_1.pascalCase(vname);
368
+ vname = (0, codegen_1.pascalCase)(vname);
369
+ let commandName = operation.language.default.name;
370
+ let operations = [operation];
371
+ const language = { default: { ...operation.language.default } };
372
+ //handle when there are pre operataions
373
+ if (preOperations && preOperations.length > 0) {
374
+ commandName = 'Update';
375
+ language.default.name = 'Update';
376
+ operations = [...preOperations, ...operations];
377
+ }
300
378
  // skip-for-time-being x-ms-metadata looks not supported any more.
301
379
  //const xmsMetadata = operation.pathExtensions ? operation.pathExtensions['x-ms-metadata'] ? clone(operation.pathExtensions['x-ms-metadata']) : {} : {};
302
380
  // Add operation type to support x-ms-mutability
@@ -309,15 +387,15 @@ class Inferrer {
309
387
  operationType = command_operation_2.OperationType.Update;
310
388
  }
311
389
  }
312
- return state.model.commands.operations[`${linq_1.length(state.model.commands.operations)}`] = new command_operation_1.CommandOperation(operation.language.default.name, {
313
- asjob: operation.language.default.asjob ? true : false,
390
+ return state.model.commands.operations[`${(0, linq_1.length)(state.model.commands.operations)}`] = new command_operation_1.CommandOperation(commandName, {
391
+ asjob: language.default.asjob ? true : false,
314
392
  operationType: operationType,
315
393
  extensions: {},
316
394
  ...variant,
317
395
  details: {
318
- ...operation.language,
396
+ ...language,
319
397
  default: {
320
- ...operation.language.default,
398
+ ...language.default,
321
399
  subject: variant.subject,
322
400
  subjectPrefix: variant.subjectPrefix,
323
401
  verb: variant.verb,
@@ -331,29 +409,29 @@ class Inferrer {
331
409
  parameters: parameters.map(httpParameter => {
332
410
  // make it's own copy of the parameter since after this,
333
411
  // the parameter can be altered for each operation individually.
334
- const each = linq_2.clone(httpParameter, false, undefined, undefined, ['schema', 'origin']);
412
+ const each = (0, linq_2.clone)(httpParameter, false, undefined, undefined, ['schema', 'origin']);
335
413
  each.language.default = {
336
414
  ...each.language.default,
337
- name: codegen_1.pascalCase(each.language.default.name),
415
+ name: (0, codegen_1.pascalCase)(each.language.default.name),
338
416
  httpParameter
339
417
  };
340
418
  each.details = {};
341
419
  each.details.default = {
342
420
  ...each.language.default,
343
- name: codegen_1.pascalCase(each.language.default.name),
421
+ name: (0, codegen_1.pascalCase)(each.language.default.name),
344
422
  httpParameter
345
423
  };
346
424
  each.name = each.language.default.serializedName;
347
425
  return each;
348
426
  }),
349
427
  // skip-for-time-being, this callGraph is used in the header comments
350
- callGraph: [operation],
351
- });
428
+ callGraph: operations
429
+ }, commandType);
352
430
  }
353
- async addVariants(parameters, operation, variant, vname, state) {
354
- var _a, _b, _c, _d;
431
+ async addVariants(parameters, operation, variant, vname, state, preOperations, commandType) {
432
+ var _a, _b, _c, _d, _e, _f;
355
433
  // now synthesize parameter set variants multiplexed by the variants.
356
- const [constants, requiredParameters] = linq_1.values(parameters).bifurcate(parameter => parameter.language.default.constantValue || parameter.language.default.fromHost ? true : false);
434
+ const [constants, requiredParameters] = (0, linq_1.values)(parameters).bifurcate(parameter => parameter.language.default.constantValue || parameter.language.default.fromHost ? true : false);
357
435
  const constantParameters = constants.map(each => `'${each.language.default.constantValue}'`);
358
436
  // the body parameter
359
437
  // xichen: How to handle if has multiple requests?
@@ -362,25 +440,118 @@ class Inferrer {
362
440
  //const bodyParameterName = (operation.requestBody && operation.requestBody.extensions) ? operation.requestBody.extensions['x-ms-requestBody-name'] || 'bodyParameter' : '';
363
441
  const bodyParameterName = body ? body.language.default.name : '';
364
442
  // all the properties in the body parameter
365
- const bodyProperties = (body && body.schema && codemodel_1.isObjectSchema(body.schema)) ? linq_1.values(codemodel_1.getAllProperties(body.schema)).where(property => !property.language.default.readOnly).toArray() : [];
443
+ const bodyProperties = (body && body.schema && (0, codemodel_1.isObjectSchema)(body.schema)) ? (0, linq_1.values)((0, codemodel_1.getAllProperties)(body.schema)).where(property => !property.language.default.readOnly).toArray() : [];
366
444
  // smash body property names together
367
445
  const bodyPropertyNames = bodyProperties.joinWith(each => each.language.default.name);
368
446
  // for each polymorphic body, we should do a separate variant that takes the polymorphic body type instead of the base type
369
447
  // skip-for-time-being, this is for polymorphism
370
448
  //const polymorphicBodies = (body && body.schema && body.schema.details.default.polymorphicChildren && length(body.schema.details.default.polymorphicChildren)) ? (<Array<Schema>>body.schema.details.default.polymorphicChildren).joinWith(child => child.details.default.name) : '';
371
- // wait! "update" should be "set" if it's a POST
449
+ // wait! "update" should be "set" if it's a PUT
372
450
  if (variant.verb === 'Update' && operation.requests && ((_d = (_c = operation.requests[0].protocol) === null || _c === void 0 ? void 0 : _c.http) === null || _d === void 0 ? void 0 : _d.method) === codemodel_1.HttpMethod.Put) {
373
451
  variant.verb = 'Set';
374
452
  }
453
+ //for operations which has pre operations (only support GET+PUT for now), change it's action to update
454
+ if (preOperations && preOperations.length > 0) {
455
+ variant.action = variant.verb = 'Update';
456
+ }
375
457
  // create variant
376
458
  // skip-for-time-being, since operationId looks not included in m4.
377
459
  //state.message({ Channel: Channel.Debug, Text: `${variant.verb}-${variant.subject} // ${operation.operationId} => ${JSON.stringify(variant)} taking ${requiredParameters.joinWith(each => each.name)}; ${constantParameters} ; ${bodyPropertyNames} ${polymorphicBodies ? `; Polymorphic bodies: ${polymorphicBodies} ` : ''}` });
378
- await this.addVariant(codegen_1.pascalCase([variant.action, vname]), body, bodyParameterName, [...constants, ...requiredParameters], operation, variant, state);
379
- const [pathParams, otherParams] = linq_1.values(requiredParameters).bifurcate(each => { var _a, _b; return ((_b = (_a = each === null || each === void 0 ? void 0 : each.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.in) === codemodel_1.ParameterLocation.Path; });
380
- const dvi = await state.getValue('disable-via-identity', false);
381
- if (!dvi && linq_1.length(pathParams) > 0 && variant.action.toLowerCase() != 'list') {
382
- // we have an operation that has path parameters, a good canididate for piping for identity.
383
- await this.addVariant(codegen_1.pascalCase([variant.action, vname, 'via-identity']), body, bodyParameterName, [...constants, ...otherParams], operation, variant, state);
460
+ await this.addVariant((0, codegen_1.pascalCase)([variant.action, vname]), body, bodyParameterName, [...constants, ...requiredParameters], operation, variant, state, preOperations, commandType);
461
+ if (await state.getValue('disable-via-identity', false)) {
462
+ return;
463
+ }
464
+ // eslint-disable-next-line prefer-const
465
+ let [pathParams, otherParams] = (0, linq_1.values)(requiredParameters).bifurcate(each => { var _a, _b; return ((_b = (_a = each === null || each === void 0 ? void 0 : each.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.in) === codemodel_1.ParameterLocation.Path; });
466
+ //exclude subscriptionId and resourceGroupName from path parameters
467
+ pathParams = pathParams.filter(pathParam => !this.reservedPathParam.has(pathParam.language.default.name));
468
+ //if parent pipline input is disabled, only generate identity for current resource itself
469
+ if (!await state.getValue('enable-parent-pipeline-input', this.isAzure)) {
470
+ if ((0, linq_1.length)(pathParams) > 0 && variant.action.toLowerCase() != 'list') {
471
+ await this.addVariant((0, codegen_1.pascalCase)([variant.action, vname, 'via-identity']), body, bodyParameterName, [...constants, ...otherParams], operation, variant, state, preOperations, commandType);
472
+ }
473
+ return;
474
+ }
475
+ const disableGetEnableList = await this.state.getValue('enable-parent-pipeline-input-for-list', true);
476
+ /*
477
+ for resource /A1/A2/.../An-1/An, generate variants that take
478
+ ViaIdentity: An as identity
479
+ ViaIdentity{An-1}: An-1 as identity + An Name
480
+ ...
481
+ ViaIdentity{A1}: A1 as identity + [A2 + A3 + ... + An-1 + An] Names
482
+ */
483
+ for (let i = pathParams.length - 1; i >= 0; i--) {
484
+ if ((!disableGetEnableList && variant.action.toLowerCase() === 'list') || (disableGetEnableList && i === pathParams.length - 1 && variant.action.toLowerCase() === 'get')) {
485
+ continue;
486
+ }
487
+ let resourceName = (0, resourceName_1.getResourceNameFromPath)((_f = (_e = operation.requests) === null || _e === void 0 ? void 0 : _e[0].protocol.http) === null || _f === void 0 ? void 0 : _f.path, pathParams[i].language.default.name, true);
488
+ //cannot get resource name from path, give up generate ViaIdentity variant
489
+ if (!resourceName) {
490
+ break;
491
+ }
492
+ //variant for current resource is simply named ViaIdentity otherwise ViaIdentity${resourceName}
493
+ if (i === pathParams.length - 1 && variant.action.toLowerCase() !== 'list') {
494
+ resourceName = '';
495
+ }
496
+ await this.addVariant((0, codegen_1.pascalCase)([variant.action, vname, `via-identity${resourceName}`]), body, bodyParameterName, [...constants, ...otherParams, ...pathParams.slice(i + 1)], operation, variant, state, preOperations, commandType);
497
+ }
498
+ if (this.supportJsonInput && (0, http_operation_1.hasValidBodyParameters)(operation) && !commandType) {
499
+ const createStringParameter = (name, description, serializedName) => {
500
+ const schema = new codemodel_2.Schema(name, description, codemodel_1.SchemaType.String);
501
+ const language = {
502
+ default: {
503
+ name: name,
504
+ description: description,
505
+ serializedName: serializedName,
506
+ },
507
+ };
508
+ schema.language = language;
509
+ const httpParameter = {
510
+ implementation: 'Method',
511
+ language: language,
512
+ schema: schema,
513
+ required: true,
514
+ };
515
+ const parameter = new components_1.IParameter(name, schema, {
516
+ description: description,
517
+ required: true,
518
+ details: {
519
+ default: {
520
+ description: description,
521
+ name: name,
522
+ isBodyParameter: false,
523
+ httpParameter: httpParameter,
524
+ },
525
+ },
526
+ schema: schema,
527
+ allowEmptyValue: false,
528
+ deprecated: false,
529
+ });
530
+ parameter.httpParameter = httpParameter;
531
+ return parameter;
532
+ };
533
+ const jsonVariant = (0, codegen_1.pascalCase)([variant.action, vname]);
534
+ const parameter = new components_1.IParameter(`${bodyParameterName}Body`, body.schema, {
535
+ details: {
536
+ default: {
537
+ description: body.schema.language.default.description,
538
+ name: (0, codegen_1.pascalCase)(`${bodyParameterName}Body`),
539
+ isBodyParameter: true,
540
+ }
541
+ }
542
+ });
543
+ const opJsonString = await this.addVariant(`${jsonVariant}ViaJsonString`, null, '', [...constants, ...requiredParameters], operation, variant, state, preOperations, commandType);
544
+ opJsonString.details.default.dropBodyParameter = true;
545
+ opJsonString.parameters = opJsonString.parameters.filter(each => each.details.default.isBodyParameter !== true);
546
+ opJsonString.parameters.push(createStringParameter('JsonString', `Json string supplied to the ${jsonVariant} operation`, 'jsonString'));
547
+ opJsonString.parameters.push(parameter);
548
+ opJsonString.details.default.dropBodyParameter = true;
549
+ const opJsonFilePath = await this.addVariant(`${jsonVariant}ViaJsonFilePath`, null, '', [...constants, ...requiredParameters], operation, variant, state, preOperations, commandType);
550
+ opJsonFilePath.details.default.dropBodyParameter = true;
551
+ opJsonFilePath.parameters = opJsonFilePath.parameters.filter(each => each.details.default.isBodyParameter !== true);
552
+ opJsonFilePath.parameters.push(createStringParameter('JsonFilePath', `Path of Json file supplied to the ${jsonVariant} operation`, 'jsonFilePath'));
553
+ opJsonFilePath.parameters.push(parameter);
554
+ opJsonFilePath.details.default.dropBodyParameter = true;
384
555
  }
385
556
  }
386
557
  createCommandVariant(action, subject, variant, model) {
@@ -394,15 +565,15 @@ class Inferrer {
394
565
  }
395
566
  return {
396
567
  alias: [],
397
- subject: codegen_1.pascalCase([...codegen_1.removeSequentialDuplicates(subject.map(each => pluralizationService.singularize(each)))]),
398
- variant: codegen_1.pascalCase(variant),
568
+ subject: (0, codegen_1.pascalCase)([...(0, codegen_1.removeSequentialDuplicates)(subject.map(each => pluralizationService.singularize(each)))]),
569
+ variant: (0, codegen_1.pascalCase)(variant),
399
570
  verb,
400
571
  subjectPrefix: model.language.default.subjectPrefix,
401
572
  action
402
573
  };
403
574
  }
404
575
  getPowerShellVerb(action) {
405
- const verb = this.verbMap[codegen_1.pascalCase(action)];
576
+ const verb = this.verbMap[(0, codegen_1.pascalCase)(action)];
406
577
  if (verb) {
407
578
  return verb;
408
579
  }
@@ -417,7 +588,7 @@ async function createCommandsV2(service) {
417
588
  //const session = await startSession<PwshModel>(service, {}, codeModelSchema);
418
589
  //const result = tweakModelV2(session);
419
590
  const state = await new model_state_1.ModelState(service).init();
420
- await service.WriteFile('code-model-v4-createcommands-v2.yaml', codegen_1.serialize(await (await new Inferrer(state).init()).createCommands()), undefined, 'code-model-v4');
591
+ await service.writeFile({ filename: 'code-model-v4-createcommands-v2.yaml', content: (0, codegen_1.serialize)(await (await new Inferrer(state).init()).createCommands()), sourceMap: undefined, artifactType: 'code-model-v4' });
421
592
  // return processCodeModel(async (state) => {
422
593
  // return await (await new Inferrer(state).init()).createCommands();
423
594
  // }, service, 'createCommands-v2');