@microsoft/teamsfx-core 2.0.4-alpha.a99162fe0.0 → 2.0.4-alpha.aa8d93004.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 (438) hide show
  1. package/build/common/constants.d.ts +1 -0
  2. package/build/common/constants.d.ts.map +1 -1
  3. package/build/common/constants.js +1 -0
  4. package/build/common/constants.js.map +1 -1
  5. package/build/common/deps-checker/checkerFactory.d.ts +1 -2
  6. package/build/common/deps-checker/checkerFactory.d.ts.map +1 -1
  7. package/build/common/deps-checker/checkerFactory.js +2 -2
  8. package/build/common/deps-checker/checkerFactory.js.map +1 -1
  9. package/build/common/deps-checker/depsLogger.d.ts +14 -14
  10. package/build/common/deps-checker/depsLogger.d.ts.map +1 -1
  11. package/build/common/deps-checker/depsLogger.js +7 -21
  12. package/build/common/deps-checker/depsLogger.js.map +1 -1
  13. package/build/common/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
  14. package/build/common/deps-checker/internal/dotnetChecker.js +40 -35
  15. package/build/common/deps-checker/internal/dotnetChecker.js.map +1 -1
  16. package/build/common/deps-checker/internal/nodeChecker.js +3 -3
  17. package/build/common/deps-checker/internal/nodeChecker.js.map +1 -1
  18. package/build/common/deps-checker/util/cpUtils.d.ts +1 -1
  19. package/build/common/deps-checker/util/cpUtils.d.ts.map +1 -1
  20. package/build/common/deps-checker/util/cpUtils.js +4 -4
  21. package/build/common/deps-checker/util/cpUtils.js.map +1 -1
  22. package/build/common/deps-checker/util/progressIndicator.js +2 -2
  23. package/build/common/deps-checker/util/progressIndicator.js.map +1 -1
  24. package/build/common/local/localCertificateManager.d.ts.map +1 -1
  25. package/build/common/local/localCertificateManager.js +3 -0
  26. package/build/common/local/localCertificateManager.js.map +1 -1
  27. package/build/common/local/packageJsonHelper.d.ts.map +1 -1
  28. package/build/common/local/packageJsonHelper.js +1 -0
  29. package/build/common/local/packageJsonHelper.js.map +1 -1
  30. package/build/common/local/portChecker.js.map +1 -1
  31. package/build/common/m365/launchHelper.d.ts +1 -1
  32. package/build/common/m365/launchHelper.d.ts.map +1 -1
  33. package/build/common/m365/launchHelper.js +20 -2
  34. package/build/common/m365/launchHelper.js.map +1 -1
  35. package/build/common/m365/packageService.d.ts.map +1 -1
  36. package/build/common/m365/packageService.js +66 -19
  37. package/build/common/m365/packageService.js.map +1 -1
  38. package/build/common/projectSettingsHelper.d.ts.map +1 -1
  39. package/build/common/projectSettingsHelper.js +1 -0
  40. package/build/common/projectSettingsHelper.js.map +1 -1
  41. package/build/common/samples.d.ts +7 -1
  42. package/build/common/samples.d.ts.map +1 -1
  43. package/build/common/samples.js +48 -21
  44. package/build/common/samples.js.map +1 -1
  45. package/build/common/spec-parser/adaptiveCardGenerator.d.ts.map +1 -1
  46. package/build/common/spec-parser/adaptiveCardGenerator.js +4 -4
  47. package/build/common/spec-parser/adaptiveCardGenerator.js.map +1 -1
  48. package/build/common/spec-parser/constants.d.ts +7 -0
  49. package/build/common/spec-parser/constants.d.ts.map +1 -1
  50. package/build/common/spec-parser/constants.js +31 -0
  51. package/build/common/spec-parser/constants.js.map +1 -1
  52. package/build/common/spec-parser/interfaces.d.ts +19 -6
  53. package/build/common/spec-parser/interfaces.d.ts.map +1 -1
  54. package/build/common/spec-parser/interfaces.js +7 -2
  55. package/build/common/spec-parser/interfaces.js.map +1 -1
  56. package/build/common/spec-parser/manifestUpdater.d.ts +4 -3
  57. package/build/common/spec-parser/manifestUpdater.d.ts.map +1 -1
  58. package/build/common/spec-parser/manifestUpdater.js +84 -33
  59. package/build/common/spec-parser/manifestUpdater.js.map +1 -1
  60. package/build/common/spec-parser/specFilter.d.ts +1 -1
  61. package/build/common/spec-parser/specFilter.d.ts.map +1 -1
  62. package/build/common/spec-parser/specFilter.js +5 -19
  63. package/build/common/spec-parser/specFilter.js.map +1 -1
  64. package/build/common/spec-parser/specParser.d.ts +8 -2
  65. package/build/common/spec-parser/specParser.d.ts.map +1 -1
  66. package/build/common/spec-parser/specParser.js +68 -35
  67. package/build/common/spec-parser/specParser.js.map +1 -1
  68. package/build/common/spec-parser/utils.d.ts +22 -0
  69. package/build/common/spec-parser/utils.d.ts.map +1 -1
  70. package/build/common/spec-parser/utils.js +251 -21
  71. package/build/common/spec-parser/utils.js.map +1 -1
  72. package/build/common/telemetry.d.ts +7 -4
  73. package/build/common/telemetry.d.ts.map +1 -1
  74. package/build/common/telemetry.js +43 -8
  75. package/build/common/telemetry.js.map +1 -1
  76. package/build/common/tools.d.ts.map +1 -1
  77. package/build/common/tools.js +5 -0
  78. package/build/common/tools.js.map +1 -1
  79. package/build/component/configManager/interface.d.ts +0 -1
  80. package/build/component/configManager/interface.d.ts.map +1 -1
  81. package/build/component/configManager/lifecycle.d.ts +1 -3
  82. package/build/component/configManager/lifecycle.d.ts.map +1 -1
  83. package/build/component/configManager/lifecycle.js +23 -51
  84. package/build/component/configManager/lifecycle.js.map +1 -1
  85. package/build/component/configManager/parser.js.map +1 -1
  86. package/build/component/configManager/validator.js +1 -1
  87. package/build/component/configManager/validator.js.map +1 -1
  88. package/build/component/constants.d.ts +6 -0
  89. package/build/component/constants.d.ts.map +1 -1
  90. package/build/component/constants.js +7 -1
  91. package/build/component/constants.js.map +1 -1
  92. package/build/component/coordinator/index.d.ts +6 -5
  93. package/build/component/coordinator/index.d.ts.map +1 -1
  94. package/build/component/coordinator/index.js +57 -61
  95. package/build/component/coordinator/index.js.map +1 -1
  96. package/build/component/coordinator/summary.d.ts.map +1 -1
  97. package/build/component/coordinator/summary.js +2 -1
  98. package/build/component/coordinator/summary.js.map +1 -1
  99. package/build/component/developerPortalScaffoldUtils.js +3 -3
  100. package/build/component/developerPortalScaffoldUtils.js.map +1 -1
  101. package/build/component/driver/aad/create.d.ts +1 -2
  102. package/build/component/driver/aad/create.d.ts.map +1 -1
  103. package/build/component/driver/aad/create.js +4 -11
  104. package/build/component/driver/aad/create.js.map +1 -1
  105. package/build/component/driver/aad/update.d.ts +1 -2
  106. package/build/component/driver/aad/update.d.ts.map +1 -1
  107. package/build/component/driver/aad/update.js +4 -11
  108. package/build/component/driver/aad/update.js.map +1 -1
  109. package/build/component/driver/aad/utility/aadAppClient.d.ts +1 -1
  110. package/build/component/driver/aad/utility/aadAppClient.d.ts.map +1 -1
  111. package/build/component/driver/aad/utility/aadAppClient.js +37 -4
  112. package/build/component/driver/aad/utility/aadAppClient.js.map +1 -1
  113. package/build/component/driver/add/addWebPart.d.ts.map +1 -1
  114. package/build/component/driver/add/addWebPart.js +9 -0
  115. package/build/component/driver/add/addWebPart.js.map +1 -1
  116. package/build/component/driver/arm/deploy.d.ts +1 -3
  117. package/build/component/driver/arm/deploy.d.ts.map +1 -1
  118. package/build/component/driver/arm/deploy.js +1 -14
  119. package/build/component/driver/arm/deploy.js.map +1 -1
  120. package/build/component/driver/arm/deployImpl.d.ts.map +1 -1
  121. package/build/component/driver/arm/deployImpl.js +8 -0
  122. package/build/component/driver/arm/deployImpl.js.map +1 -1
  123. package/build/component/driver/arm/util/bicepChecker.js +7 -6
  124. package/build/component/driver/arm/util/bicepChecker.js.map +1 -1
  125. package/build/component/driver/arm/util/handleError.js.map +1 -1
  126. package/build/component/driver/botAadApp/create.d.ts +2 -1
  127. package/build/component/driver/botAadApp/create.d.ts.map +1 -1
  128. package/build/component/driver/botAadApp/create.js +5 -8
  129. package/build/component/driver/botAadApp/create.js.map +1 -1
  130. package/build/component/driver/botFramework/createOrUpdateBot.d.ts +1 -0
  131. package/build/component/driver/botFramework/createOrUpdateBot.d.ts.map +1 -1
  132. package/build/component/driver/botFramework/createOrUpdateBot.js +4 -10
  133. package/build/component/driver/botFramework/createOrUpdateBot.js.map +1 -1
  134. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.d.ts +0 -2
  135. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.d.ts.map +1 -1
  136. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js +0 -10
  137. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js.map +1 -1
  138. package/build/component/driver/deploy/azure/azureFunctionDeployDriver.d.ts +0 -2
  139. package/build/component/driver/deploy/azure/azureFunctionDeployDriver.d.ts.map +1 -1
  140. package/build/component/driver/deploy/azure/azureFunctionDeployDriver.js +0 -10
  141. package/build/component/driver/deploy/azure/azureFunctionDeployDriver.js.map +1 -1
  142. package/build/component/driver/deploy/azure/azureStorageDeployDriver.d.ts +0 -2
  143. package/build/component/driver/deploy/azure/azureStorageDeployDriver.d.ts.map +1 -1
  144. package/build/component/driver/deploy/azure/azureStorageDeployDriver.js +17 -19
  145. package/build/component/driver/deploy/azure/azureStorageDeployDriver.js.map +1 -1
  146. package/build/component/driver/deploy/azure/azureStorageStaticWebsiteConfigDriver.d.ts.map +1 -1
  147. package/build/component/driver/deploy/azure/azureStorageStaticWebsiteConfigDriver.js +10 -3
  148. package/build/component/driver/deploy/azure/azureStorageStaticWebsiteConfigDriver.js.map +1 -1
  149. package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.d.ts.map +1 -1
  150. package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.js +29 -16
  151. package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.js.map +1 -1
  152. package/build/component/driver/deploy/azure/impl/azureDeployImpl.d.ts.map +1 -1
  153. package/build/component/driver/deploy/azure/impl/azureDeployImpl.js +18 -15
  154. package/build/component/driver/deploy/azure/impl/azureDeployImpl.js.map +1 -1
  155. package/build/component/driver/deploy/azure/impl/baseDeployImpl.d.ts.map +1 -1
  156. package/build/component/driver/deploy/azure/impl/baseDeployImpl.js +4 -4
  157. package/build/component/driver/deploy/azure/impl/baseDeployImpl.js.map +1 -1
  158. package/build/component/driver/deploy/spfx/deployDriver.d.ts +1 -0
  159. package/build/component/driver/deploy/spfx/deployDriver.d.ts.map +1 -1
  160. package/build/component/driver/deploy/spfx/deployDriver.js +24 -2
  161. package/build/component/driver/deploy/spfx/deployDriver.js.map +1 -1
  162. package/build/component/driver/devTool/installDriver.d.ts +1 -0
  163. package/build/component/driver/devTool/installDriver.d.ts.map +1 -1
  164. package/build/component/driver/devTool/installDriver.js +34 -12
  165. package/build/component/driver/devTool/installDriver.js.map +1 -1
  166. package/build/component/driver/file/createOrUpdateEnvironmentFile.d.ts +1 -0
  167. package/build/component/driver/file/createOrUpdateEnvironmentFile.d.ts.map +1 -1
  168. package/build/component/driver/file/createOrUpdateEnvironmentFile.js +10 -16
  169. package/build/component/driver/file/createOrUpdateEnvironmentFile.js.map +1 -1
  170. package/build/component/driver/file/createOrUpdateJsonFile.d.ts +1 -0
  171. package/build/component/driver/file/createOrUpdateJsonFile.d.ts.map +1 -1
  172. package/build/component/driver/file/createOrUpdateJsonFile.js +3 -9
  173. package/build/component/driver/file/createOrUpdateJsonFile.js.map +1 -1
  174. package/build/component/driver/interface/stepDriver.d.ts +2 -7
  175. package/build/component/driver/interface/stepDriver.d.ts.map +1 -1
  176. package/build/component/driver/m365/acquire.d.ts +1 -0
  177. package/build/component/driver/m365/acquire.d.ts.map +1 -1
  178. package/build/component/driver/m365/acquire.js +4 -10
  179. package/build/component/driver/m365/acquire.js.map +1 -1
  180. package/build/component/driver/script/baseBuildDriver.d.ts.map +1 -1
  181. package/build/component/driver/script/baseBuildDriver.js +1 -0
  182. package/build/component/driver/script/baseBuildDriver.js.map +1 -1
  183. package/build/component/driver/script/baseBuildStepDriver.d.ts +0 -2
  184. package/build/component/driver/script/baseBuildStepDriver.d.ts.map +1 -1
  185. package/build/component/driver/script/baseBuildStepDriver.js +0 -4
  186. package/build/component/driver/script/baseBuildStepDriver.js.map +1 -1
  187. package/build/component/driver/script/dotnetBuildDriver.d.ts +0 -2
  188. package/build/component/driver/script/dotnetBuildDriver.d.ts.map +1 -1
  189. package/build/component/driver/script/dotnetBuildDriver.js +0 -9
  190. package/build/component/driver/script/dotnetBuildDriver.js.map +1 -1
  191. package/build/component/driver/script/npmBuildDriver.d.ts +0 -2
  192. package/build/component/driver/script/npmBuildDriver.d.ts.map +1 -1
  193. package/build/component/driver/script/npmBuildDriver.js +0 -9
  194. package/build/component/driver/script/npmBuildDriver.js.map +1 -1
  195. package/build/component/driver/script/npxBuildDriver.d.ts +0 -2
  196. package/build/component/driver/script/npxBuildDriver.d.ts.map +1 -1
  197. package/build/component/driver/script/npxBuildDriver.js +0 -9
  198. package/build/component/driver/script/npxBuildDriver.js.map +1 -1
  199. package/build/component/driver/script/scriptDriver.d.ts +10 -1
  200. package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
  201. package/build/component/driver/script/scriptDriver.js +31 -30
  202. package/build/component/driver/script/scriptDriver.js.map +1 -1
  203. package/build/component/driver/teamsApp/appStudio.d.ts.map +1 -1
  204. package/build/component/driver/teamsApp/appStudio.js +8 -8
  205. package/build/component/driver/teamsApp/appStudio.js.map +1 -1
  206. package/build/component/driver/teamsApp/clients/appStudioClient.d.ts +5 -5
  207. package/build/component/driver/teamsApp/clients/appStudioClient.d.ts.map +1 -1
  208. package/build/component/driver/teamsApp/clients/appStudioClient.js +31 -11
  209. package/build/component/driver/teamsApp/clients/appStudioClient.js.map +1 -1
  210. package/build/component/driver/teamsApp/clients/authSvcClient.d.ts.map +1 -1
  211. package/build/component/driver/teamsApp/clients/authSvcClient.js +2 -0
  212. package/build/component/driver/teamsApp/clients/authSvcClient.js.map +1 -1
  213. package/build/component/driver/teamsApp/configure.d.ts +1 -1
  214. package/build/component/driver/teamsApp/configure.d.ts.map +1 -1
  215. package/build/component/driver/teamsApp/configure.js +3 -11
  216. package/build/component/driver/teamsApp/configure.js.map +1 -1
  217. package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts +1 -2
  218. package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts.map +1 -1
  219. package/build/component/driver/teamsApp/copyAppPackageToSPFx.js +4 -11
  220. package/build/component/driver/teamsApp/copyAppPackageToSPFx.js.map +1 -1
  221. package/build/component/driver/teamsApp/create.d.ts +1 -1
  222. package/build/component/driver/teamsApp/create.d.ts.map +1 -1
  223. package/build/component/driver/teamsApp/create.js +6 -11
  224. package/build/component/driver/teamsApp/create.js.map +1 -1
  225. package/build/component/driver/teamsApp/createAppPackage.d.ts +4 -3
  226. package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
  227. package/build/component/driver/teamsApp/createAppPackage.js +53 -43
  228. package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
  229. package/build/component/driver/teamsApp/errors.d.ts.map +1 -1
  230. package/build/component/driver/teamsApp/errors.js +2 -0
  231. package/build/component/driver/teamsApp/errors.js.map +1 -1
  232. package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtension.d.ts +2 -3
  233. package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtension.d.ts.map +1 -1
  234. package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtensionCommand.d.ts +1 -1
  235. package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtensionCommand.d.ts.map +1 -1
  236. package/build/component/driver/teamsApp/publishAppPackage.d.ts +1 -1
  237. package/build/component/driver/teamsApp/publishAppPackage.d.ts.map +1 -1
  238. package/build/component/driver/teamsApp/publishAppPackage.js +5 -13
  239. package/build/component/driver/teamsApp/publishAppPackage.js.map +1 -1
  240. package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts +2 -1
  241. package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts.map +1 -1
  242. package/build/component/driver/teamsApp/utils/ManifestUtils.js +7 -2
  243. package/build/component/driver/teamsApp/utils/ManifestUtils.js.map +1 -1
  244. package/build/component/driver/teamsApp/utils/telemetry.d.ts +1 -0
  245. package/build/component/driver/teamsApp/utils/telemetry.d.ts.map +1 -1
  246. package/build/component/driver/teamsApp/utils/telemetry.js +1 -0
  247. package/build/component/driver/teamsApp/utils/telemetry.js.map +1 -1
  248. package/build/component/driver/teamsApp/utils/utils.d.ts +2 -2
  249. package/build/component/driver/teamsApp/utils/utils.d.ts.map +1 -1
  250. package/build/component/driver/teamsApp/utils/utils.js +22 -10
  251. package/build/component/driver/teamsApp/utils/utils.js.map +1 -1
  252. package/build/component/driver/teamsApp/validate.d.ts +1 -1
  253. package/build/component/driver/teamsApp/validate.d.ts.map +1 -1
  254. package/build/component/driver/teamsApp/validate.js +18 -13
  255. package/build/component/driver/teamsApp/validate.js.map +1 -1
  256. package/build/component/driver/teamsApp/validateAppPackage.d.ts +1 -1
  257. package/build/component/driver/teamsApp/validateAppPackage.d.ts.map +1 -1
  258. package/build/component/driver/teamsApp/validateAppPackage.js +3 -11
  259. package/build/component/driver/teamsApp/validateAppPackage.js.map +1 -1
  260. package/build/component/feature/collaboration.d.ts.map +1 -1
  261. package/build/component/feature/collaboration.js +32 -13
  262. package/build/component/feature/collaboration.js.map +1 -1
  263. package/build/component/generator/copilotPlugin/generator.d.ts +3 -1
  264. package/build/component/generator/copilotPlugin/generator.d.ts.map +1 -1
  265. package/build/component/generator/copilotPlugin/generator.js +42 -16
  266. package/build/component/generator/copilotPlugin/generator.js.map +1 -1
  267. package/build/component/generator/copilotPlugin/helper.d.ts +1 -1
  268. package/build/component/generator/copilotPlugin/helper.d.ts.map +1 -1
  269. package/build/component/generator/copilotPlugin/helper.js +29 -27
  270. package/build/component/generator/copilotPlugin/helper.js.map +1 -1
  271. package/build/component/generator/error.d.ts +6 -0
  272. package/build/component/generator/error.d.ts.map +1 -1
  273. package/build/component/generator/error.js +13 -1
  274. package/build/component/generator/error.js.map +1 -1
  275. package/build/component/generator/generator.d.ts.map +1 -1
  276. package/build/component/generator/generator.js +28 -19
  277. package/build/component/generator/generator.js.map +1 -1
  278. package/build/component/generator/generatorAction.d.ts +2 -1
  279. package/build/component/generator/generatorAction.d.ts.map +1 -1
  280. package/build/component/generator/generatorAction.js +8 -2
  281. package/build/component/generator/generatorAction.js.map +1 -1
  282. package/build/component/generator/officeAddin/generator.js +3 -3
  283. package/build/component/generator/officeAddin/generator.js.map +1 -1
  284. package/build/component/generator/officeAddin/helperMethods.d.ts.map +1 -1
  285. package/build/component/generator/officeAddin/helperMethods.js +6 -2
  286. package/build/component/generator/officeAddin/helperMethods.js.map +1 -1
  287. package/build/component/generator/spfx/depsChecker/generatorChecker.d.ts.map +1 -1
  288. package/build/component/generator/spfx/depsChecker/generatorChecker.js +4 -2
  289. package/build/component/generator/spfx/depsChecker/generatorChecker.js.map +1 -1
  290. package/build/component/generator/spfx/depsChecker/yoChecker.d.ts.map +1 -1
  291. package/build/component/generator/spfx/depsChecker/yoChecker.js +3 -3
  292. package/build/component/generator/spfx/depsChecker/yoChecker.js.map +1 -1
  293. package/build/component/generator/spfx/spfxGenerator.d.ts.map +1 -1
  294. package/build/component/generator/spfx/spfxGenerator.js +2 -2
  295. package/build/component/generator/spfx/spfxGenerator.js.map +1 -1
  296. package/build/component/generator/spfx/utils/utils.js +3 -3
  297. package/build/component/generator/spfx/utils/utils.js.map +1 -1
  298. package/build/component/generator/utils.d.ts +2 -2
  299. package/build/component/generator/utils.d.ts.map +1 -1
  300. package/build/component/generator/utils.js +13 -13
  301. package/build/component/generator/utils.js.map +1 -1
  302. package/build/component/messages.d.ts +2 -3
  303. package/build/component/messages.d.ts.map +1 -1
  304. package/build/component/messages.js +3 -4
  305. package/build/component/messages.js.map +1 -1
  306. package/build/component/middleware/actionExecutionMW.d.ts +2 -2
  307. package/build/component/middleware/actionExecutionMW.d.ts.map +1 -1
  308. package/build/component/middleware/envMW.js +1 -1
  309. package/build/component/middleware/envMW.js.map +1 -1
  310. package/build/component/provisionUtils.d.ts +3 -3
  311. package/build/component/provisionUtils.d.ts.map +1 -1
  312. package/build/component/provisionUtils.js +3 -3
  313. package/build/component/provisionUtils.js.map +1 -1
  314. package/build/component/resource/botService/appStudio/appStudioClient.d.ts.map +1 -1
  315. package/build/component/resource/botService/appStudio/appStudioClient.js +24 -2
  316. package/build/component/resource/botService/appStudio/appStudioClient.js.map +1 -1
  317. package/build/component/resource/botService/botRegistration/botFrameworkRegistration.d.ts +2 -2
  318. package/build/component/resource/botService/botRegistration/botFrameworkRegistration.d.ts.map +1 -1
  319. package/build/component/resource/botService/botRegistration/botFrameworkRegistration.js +6 -1
  320. package/build/component/resource/botService/botRegistration/botFrameworkRegistration.js.map +1 -1
  321. package/build/component/telemetry.js +2 -2
  322. package/build/component/telemetry.js.map +1 -1
  323. package/build/component/utils/ResourceGroupHelper.d.ts +2 -2
  324. package/build/component/utils/ResourceGroupHelper.d.ts.map +1 -1
  325. package/build/component/utils/ResourceGroupHelper.js +1 -4
  326. package/build/component/utils/ResourceGroupHelper.js.map +1 -1
  327. package/build/component/utils/charsetUtils.js +3 -3
  328. package/build/component/utils/charsetUtils.js.map +1 -1
  329. package/build/component/utils/common.js +1 -1
  330. package/build/component/utils/common.js.map +1 -1
  331. package/build/component/utils/depsChecker/cpUtils.d.ts.map +1 -1
  332. package/build/component/utils/depsChecker/cpUtils.js +8 -4
  333. package/build/component/utils/depsChecker/cpUtils.js.map +1 -1
  334. package/build/component/utils/envUtil.js +2 -2
  335. package/build/component/utils/envUtil.js.map +1 -1
  336. package/build/component/utils/teamsFxTelemetryReporter.js +2 -2
  337. package/build/component/utils/teamsFxTelemetryReporter.js.map +1 -1
  338. package/build/core/FxCore.d.ts +15 -19
  339. package/build/core/FxCore.d.ts.map +1 -1
  340. package/build/core/FxCore.js +800 -60
  341. package/build/core/FxCore.js.map +1 -1
  342. package/build/core/globalVars.d.ts +16 -0
  343. package/build/core/globalVars.d.ts.map +1 -1
  344. package/build/core/globalVars.js +34 -1
  345. package/build/core/globalVars.js.map +1 -1
  346. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  347. package/build/core/middleware/concurrentLocker.js +7 -3
  348. package/build/core/middleware/concurrentLocker.js.map +1 -1
  349. package/build/core/middleware/projectMigratorV3.d.ts.map +1 -1
  350. package/build/core/middleware/projectMigratorV3.js.map +1 -1
  351. package/build/core/middleware/projectVersionChecker.js +5 -5
  352. package/build/core/middleware/projectVersionChecker.js.map +1 -1
  353. package/build/core/middleware/utils/appYmlGenerator.d.ts.map +1 -1
  354. package/build/core/middleware/utils/appYmlGenerator.js +2 -1
  355. package/build/core/middleware/utils/appYmlGenerator.js.map +1 -1
  356. package/build/core/middleware/utils/debug/taskMigrator.d.ts.map +1 -1
  357. package/build/core/middleware/utils/debug/taskMigrator.js +3 -0
  358. package/build/core/middleware/utils/debug/taskMigrator.js.map +1 -1
  359. package/build/core/middleware/utils/v3MigrationUtils.js +1 -1
  360. package/build/core/middleware/utils/v3MigrationUtils.js.map +1 -1
  361. package/build/error/common.d.ts +2 -8
  362. package/build/error/common.d.ts.map +1 -1
  363. package/build/error/common.js +6 -31
  364. package/build/error/common.js.map +1 -1
  365. package/build/index.d.ts +3 -1
  366. package/build/index.d.ts.map +1 -1
  367. package/build/index.js +2 -0
  368. package/build/index.js.map +1 -1
  369. package/build/question/constants.d.ts +4 -2
  370. package/build/question/constants.d.ts.map +1 -1
  371. package/build/question/constants.js +9 -3
  372. package/build/question/constants.js.map +1 -1
  373. package/build/question/create.d.ts +11 -8
  374. package/build/question/create.d.ts.map +1 -1
  375. package/build/question/create.js +110 -120
  376. package/build/question/create.js.map +1 -1
  377. package/build/question/generator.d.ts.map +1 -1
  378. package/build/question/generator.js +11 -17
  379. package/build/question/generator.js.map +1 -1
  380. package/build/question/index.d.ts +1 -0
  381. package/build/question/index.d.ts.map +1 -1
  382. package/build/question/index.js +1 -0
  383. package/build/question/index.js.map +1 -1
  384. package/build/question/inputs/CreateProjectInputs.d.ts +4 -6
  385. package/build/question/inputs/CreateProjectInputs.d.ts.map +1 -1
  386. package/build/question/inputs/SPFxAddWebpartInputs.d.ts +1 -1
  387. package/build/question/inputs/SPFxAddWebpartInputs.d.ts.map +1 -1
  388. package/build/question/options/CreateProjectOptions.d.ts.map +1 -1
  389. package/build/question/options/CreateProjectOptions.js +18 -23
  390. package/build/question/options/CreateProjectOptions.js.map +1 -1
  391. package/build/question/options/CreateSampleProjectOptions.js +1 -1
  392. package/build/question/options/CreateSampleProjectOptions.js.map +1 -1
  393. package/build/question/options/DeployAadManifestOptions.js +2 -2
  394. package/build/question/options/DeployAadManifestOptions.js.map +1 -1
  395. package/build/question/options/PermissionGrantOptions.js +4 -4
  396. package/build/question/options/PermissionGrantOptions.js.map +1 -1
  397. package/build/question/options/PermissionListOptions.js +4 -4
  398. package/build/question/options/PermissionListOptions.js.map +1 -1
  399. package/build/question/options/PreviewTeamsAppOptions.js +3 -3
  400. package/build/question/options/PreviewTeamsAppOptions.js.map +1 -1
  401. package/build/question/options/SPFxAddWebpartOptions.d.ts.map +1 -1
  402. package/build/question/options/SPFxAddWebpartOptions.js +7 -6
  403. package/build/question/options/SPFxAddWebpartOptions.js.map +1 -1
  404. package/build/question/options/SelectTeamsManifestOptions.js +2 -2
  405. package/build/question/options/SelectTeamsManifestOptions.js.map +1 -1
  406. package/build/question/options/ValidateTeamsAppOptions.js +4 -4
  407. package/build/question/options/ValidateTeamsAppOptions.js.map +1 -1
  408. package/build/question/other.d.ts.map +1 -1
  409. package/build/question/other.js +13 -8
  410. package/build/question/other.js.map +1 -1
  411. package/build/question/questionNames.d.ts +5 -3
  412. package/build/question/questionNames.d.ts.map +1 -1
  413. package/build/question/questionNames.js +7 -4
  414. package/build/question/questionNames.js.map +1 -1
  415. package/build/ui/validationUtils.d.ts +17 -1
  416. package/build/ui/validationUtils.d.ts.map +1 -1
  417. package/build/ui/validationUtils.js +206 -17
  418. package/build/ui/validationUtils.js.map +1 -1
  419. package/build/ui/visitor.d.ts.map +1 -1
  420. package/build/ui/visitor.js +17 -17
  421. package/build/ui/visitor.js.map +1 -1
  422. package/package.json +15 -13
  423. package/resource/package.nls.json +12 -9
  424. package/templates/fallback/common.zip +0 -0
  425. package/templates/fallback/csharp.zip +0 -0
  426. package/templates/fallback/js.zip +0 -0
  427. package/templates/fallback/ts.zip +0 -0
  428. package/templates/plugins/resource/aad/auth/V3/Tab/GetUserProfile.razor +1 -2
  429. package/templates/plugins/resource/aad/auth/tab/csharp/GetUserProfile.razor +1 -2
  430. package/build/common/samples-config-v3.json +0 -446
  431. package/build/component/driver/middleware/updateProgress.d.ts +0 -6
  432. package/build/component/driver/middleware/updateProgress.d.ts.map +0 -1
  433. package/build/component/driver/middleware/updateProgress.js +0 -15
  434. package/build/component/driver/middleware/updateProgress.js.map +0 -1
  435. package/build/core/FxCoreImplementV3.d.ts +0 -51
  436. package/build/core/FxCoreImplementV3.d.ts.map +0 -1
  437. package/build/core/FxCoreImplementV3.js +0 -736
  438. package/build/core/FxCoreImplementV3.js.map +0 -1
@@ -6,27 +6,27 @@ exports.specFilter = void 0;
6
6
  const utils_1 = require("./utils");
7
7
  const specParserError_1 = require("./specParserError");
8
8
  const interfaces_1 = require("./interfaces");
9
- const allMethodNames = ["get", "post", "put", "delete", "patch", "head", "options", "trace"];
10
- function specFilter(filter, unResolveSpec) {
9
+ const constants_1 = require("./constants");
10
+ function specFilter(filter, unResolveSpec, resolvedSpec) {
11
11
  try {
12
12
  const newSpec = Object.assign({}, unResolveSpec);
13
13
  const newPaths = {};
14
14
  for (const filterItem of filter) {
15
15
  const [method, path] = filterItem.split(" ");
16
16
  const methodName = method.toLowerCase();
17
- if (!utils_1.isSupportedApi(methodName, path, unResolveSpec)) {
17
+ if (!utils_1.isSupportedApi(methodName, path, resolvedSpec)) {
18
18
  continue;
19
19
  }
20
20
  if (!newPaths[path]) {
21
21
  newPaths[path] = Object.assign({}, unResolveSpec.paths[path]);
22
- for (const m of allMethodNames) {
22
+ for (const m of constants_1.ConstantString.AllOperationMethods) {
23
23
  delete newPaths[path][m];
24
24
  }
25
25
  }
26
26
  newPaths[path][methodName] = unResolveSpec.paths[path][methodName];
27
27
  // Add the operationId if missing
28
28
  if (!newPaths[path][methodName].operationId) {
29
- newPaths[path][methodName].operationId = `${methodName}${convertPathToCamelCase(path)}`;
29
+ newPaths[path][methodName].operationId = `${methodName}${utils_1.convertPathToCamelCase(path)}`;
30
30
  }
31
31
  }
32
32
  newSpec.paths = newPaths;
@@ -37,18 +37,4 @@ function specFilter(filter, unResolveSpec) {
37
37
  }
38
38
  }
39
39
  exports.specFilter = specFilter;
40
- function convertPathToCamelCase(path) {
41
- const pathSegments = path.split("/");
42
- const camelCaseSegments = pathSegments.map((segment) => {
43
- if (segment.startsWith("{")) {
44
- const name = segment.substring(1, segment.length - 1);
45
- return name.charAt(0).toUpperCase() + name.slice(1);
46
- }
47
- else {
48
- return segment;
49
- }
50
- });
51
- const camelCasePath = camelCaseSegments.join("");
52
- return camelCasePath.charAt(0).toUpperCase() + camelCasePath.slice(1);
53
- }
54
40
  //# sourceMappingURL=specFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"specFilter.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specFilter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAGb,mCAAyC;AACzC,uDAAoD;AACpD,6CAAyC;AAEzC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAE7F,SAAgB,UAAU,CACxB,MAAgB,EAChB,aAAiC;IAEjC,IAAI;QACF,MAAM,OAAO,qBAAQ,aAAa,CAAE,CAAC;QACrC,MAAM,QAAQ,GAA0B,EAAE,CAAC;QAC3C,KAAK,MAAM,UAAU,IAAI,MAAM,EAAE;YAC/B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YAExC,IAAI,CAAC,sBAAc,CAAC,UAAU,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE;gBACpD,SAAS;aACV;YAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACnB,QAAQ,CAAC,IAAI,CAAC,qBAAQ,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,CAAC;gBAClD,KAAK,MAAM,CAAC,IAAI,cAAc,EAA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QAAQ,CAAC,IAAI,CAAS,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,GAAG,UAAU,GAAG,8BAAsB,CACtF,IAAI,CACL,EAAE,CAAC;aACL;SACF;QAED,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;QACzB,OAAO,OAAO,CAAC;KAChB;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,iCAAe,CAAE,GAAa,CAAC,QAAQ,EAAE,EAAE,sBAAS,CAAC,gBAAgB,CAAC,CAAC;KAClF;AACH,CAAC;AAtCD,gCAsCC"}
@@ -1,5 +1,5 @@
1
1
  import SwaggerParser from "@apidevtools/swagger-parser";
2
- import { ValidateResult } from "./interfaces";
2
+ import { GenerateResult, ValidateResult } from "./interfaces";
3
3
  /**
4
4
  * A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
5
5
  */
@@ -9,6 +9,7 @@ export declare class SpecParser {
9
9
  private apiMap;
10
10
  private spec;
11
11
  private unResolveSpec;
12
+ private isSwaggerFile;
12
13
  /**
13
14
  * Creates a new instance of the SpecParser class.
14
15
  * @param path The URL or file path of the OpenAPI specification file. The OpenAPI specification file must have a version of 3.0 or higher.
@@ -26,6 +27,11 @@ export declare class SpecParser {
26
27
  * according to copilot plugin spec, only list get and post method without auth
27
28
  */
28
29
  list(): Promise<string[]>;
30
+ /**
31
+ * List all the OpenAPI operations in the specification file and return a map of operationId and operation path.
32
+ * @returns A map of operationId and operation path, such as [{'getPetById': 'GET /pets/{petId}'}, {'getUser': 'GET /user/{userId}'}]
33
+ */
34
+ listOperationMap(): Promise<Map<string, string>>;
29
35
  /**
30
36
  * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
31
37
  * @param manifestPath A file path of the Teams app manifest file to update.
@@ -33,7 +39,7 @@ export declare class SpecParser {
33
39
  * @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
34
40
  * @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
35
41
  */
36
- generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<void>;
42
+ generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<GenerateResult>;
37
43
  private loadSpec;
38
44
  private getAllSupportedApi;
39
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAIL,cAAc,EAIf,MAAM,cAAc,CAAC;AAUtB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IAEtD;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAuGzC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/B;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;YAqDF,QAAQ;IAQtB,OAAO,CAAC,kBAAkB;CAqB3B"}
1
+ {"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAIxD,OAAO,EAIL,cAAc,EACd,cAAc,EAIf,MAAM,cAAc,CAAC;AAUtB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAsFzC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/B;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqBtD;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC;YA0EZ,QAAQ;IAetB,OAAO,CAAC,kBAAkB;CAqB3B"}
@@ -7,6 +7,7 @@ const tslib_1 = require("tslib");
7
7
  const util = tslib_1.__importStar(require("util"));
8
8
  const swagger_parser_1 = tslib_1.__importDefault(require("@apidevtools/swagger-parser"));
9
9
  const specParserError_1 = require("./specParserError");
10
+ const swagger2openapi_1 = tslib_1.__importDefault(require("swagger2openapi"));
10
11
  const interfaces_1 = require("./interfaces");
11
12
  const constants_1 = require("./constants");
12
13
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
@@ -50,33 +51,15 @@ class SpecParser {
50
51
  errors,
51
52
  };
52
53
  }
53
- // Spec version not supported
54
- if (!this.spec.openapi || this.spec.openapi < "3.0.0") {
55
- errors.push({
56
- type: interfaces_1.ErrorType.VersionNotSupported,
57
- content: constants_1.ConstantString.SpecVersionNotSupported,
58
- data: this.spec.openapi,
59
- });
60
- return {
61
- status: interfaces_1.ValidationStatus.Error,
62
- warnings,
63
- errors,
64
- };
65
- }
66
- // Server information invalid
67
- if (!this.spec.servers || this.spec.servers.length === 0) {
68
- errors.push({
69
- type: interfaces_1.ErrorType.NoServerInformation,
70
- content: constants_1.ConstantString.NoServerInformation,
71
- });
72
- }
73
- else if (this.spec.servers.length > 1) {
74
- errors.push({
75
- type: interfaces_1.ErrorType.MultipleServerInformation,
76
- content: constants_1.ConstantString.MultipleServerInformation,
77
- data: this.spec.servers,
54
+ if (this.isSwaggerFile) {
55
+ warnings.push({
56
+ type: interfaces_1.WarningType.ConvertSwaggerToOpenAPI,
57
+ content: constants_1.ConstantString.ConvertSwaggerToOpenAPI,
78
58
  });
79
59
  }
60
+ // Server validation
61
+ const serverErrors = utils_1.validateServer(this.spec);
62
+ errors.push(...serverErrors);
80
63
  // Remote reference not supported
81
64
  const refPaths = this.parser.$refs.paths();
82
65
  // refPaths [0] is the current spec file path
@@ -142,6 +125,31 @@ class SpecParser {
142
125
  throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ListFailed);
143
126
  }
144
127
  }
128
+ /**
129
+ * List all the OpenAPI operations in the specification file and return a map of operationId and operation path.
130
+ * @returns A map of operationId and operation path, such as [{'getPetById': 'GET /pets/{petId}'}, {'getUser': 'GET /user/{userId}'}]
131
+ */
132
+ async listOperationMap() {
133
+ try {
134
+ await this.loadSpec();
135
+ const apiMap = this.getAllSupportedApi(this.spec);
136
+ const operationMap = new Map();
137
+ for (const key in apiMap) {
138
+ const pathObjectItem = apiMap[key];
139
+ let operationId = pathObjectItem.operationId;
140
+ if (!operationId) {
141
+ const [method, path] = key.split(" ");
142
+ const methodName = method.toLowerCase();
143
+ operationId = `${methodName}${utils_1.convertPathToCamelCase(path)}`;
144
+ }
145
+ operationMap.set(operationId, key);
146
+ }
147
+ return operationMap;
148
+ }
149
+ catch (err) {
150
+ throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ListOperationMapFailed);
151
+ }
152
+ }
145
153
  /**
146
154
  * Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
147
155
  * @param manifestPath A file path of the Teams app manifest file to update.
@@ -150,7 +158,10 @@ class SpecParser {
150
158
  * @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
151
159
  */
152
160
  async generate(manifestPath, filter, outputSpecPath, adaptiveCardFolder, signal) {
153
- var _a;
161
+ const result = {
162
+ allSuccess: true,
163
+ warnings: [],
164
+ };
154
165
  try {
155
166
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
156
167
  throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
@@ -159,7 +170,7 @@ class SpecParser {
159
170
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
160
171
  throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
161
172
  }
162
- const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec);
173
+ const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec);
163
174
  let resultStr;
164
175
  if (outputSpecPath.endsWith(".yaml") || outputSpecPath.endsWith(".yml")) {
165
176
  resultStr = js_yaml_1.default.dump(newUnResolvedSpec);
@@ -172,17 +183,32 @@ class SpecParser {
172
183
  throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
173
184
  }
174
185
  const newSpec = (await this.parser.dereference(newUnResolvedSpec));
175
- const updatedManifest = await manifestUpdater_1.updateManifest(manifestPath, outputSpecPath, adaptiveCardFolder, newSpec);
176
- await fs_extra_1.default.outputJSON(manifestPath, updatedManifest, { spaces: 2 });
186
+ for (const url in newSpec.paths) {
187
+ for (const method in newSpec.paths[url]) {
188
+ if (method === constants_1.ConstantString.GetMethod || method === constants_1.ConstantString.PostMethod) {
189
+ const operation = newSpec.paths[url][method];
190
+ try {
191
+ const card = adaptiveCardGenerator_1.generateAdaptiveCard(operation);
192
+ const fileName = path_1.default.join(adaptiveCardFolder, `${operation.operationId}.json`);
193
+ await fs_extra_1.default.outputJSON(fileName, card, { spaces: 2 });
194
+ }
195
+ catch (err) {
196
+ result.allSuccess = false;
197
+ result.warnings.push({
198
+ type: interfaces_1.WarningType.GenerateCardFailed,
199
+ content: err.toString(),
200
+ data: operation.operationId,
201
+ });
202
+ }
203
+ }
204
+ }
205
+ }
177
206
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
178
207
  throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
179
208
  }
180
- for (const url in newSpec.paths) {
181
- const getOperation = (_a = newSpec.paths[url]) === null || _a === void 0 ? void 0 : _a.get;
182
- const card = adaptiveCardGenerator_1.generateAdaptiveCard(getOperation);
183
- const fileName = path_1.default.join(adaptiveCardFolder, `${getOperation.operationId}.json`);
184
- await fs_extra_1.default.outputJSON(fileName, card, { spaces: 2 });
185
- }
209
+ const [updatedManifest, warnings] = await manifestUpdater_1.updateManifest(manifestPath, outputSpecPath, adaptiveCardFolder, newSpec);
210
+ await fs_extra_1.default.outputJSON(manifestPath, updatedManifest, { spaces: 2 });
211
+ result.warnings.push(...warnings);
186
212
  }
187
213
  catch (err) {
188
214
  if (err instanceof specParserError_1.SpecParserError) {
@@ -190,10 +216,17 @@ class SpecParser {
190
216
  }
191
217
  throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.GenerateFailed);
192
218
  }
219
+ return result;
193
220
  }
194
221
  async loadSpec() {
195
222
  if (!this.spec) {
196
223
  this.unResolveSpec = (await this.parser.parse(this.specPath));
224
+ // Convert swagger 2.0 to openapi 3.0
225
+ if (!this.unResolveSpec.openapi && this.unResolveSpec.swagger === "2.0") {
226
+ const specObj = await swagger2openapi_1.default.convert(this.unResolveSpec, {});
227
+ this.unResolveSpec = specObj.openapi;
228
+ this.isSwaggerFile = true;
229
+ }
197
230
  const clonedUnResolveSpec = JSON.parse(JSON.stringify(this.unResolveSpec));
198
231
  this.spec = (await this.parser.dereference(clonedUnResolveSpec));
199
232
  }
@@ -1 +1 @@
1
- {"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,mDAA6B;AAC7B,yFAAwD;AAExD,uDAAoD;AACpD,6CAQsB;AACtB,2CAA6C;AAC7C,8DAA6B;AAC7B,gEAA0B;AAC1B,6CAA0C;AAC1C,mCAAyC;AACzC,uDAAmD;AACnD,mEAA+D;AAC/D,wDAAwB;AAExB;;GAEG;AACH,MAAa,UAAU;IAQrB;;;OAGG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAa,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI;YACF,MAAM,MAAM,GAAkB,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAoB,EAAE,CAAC;YACrC,IAAI;gBACF,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACtB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAK,CAAC,CAAC;aACxC;YAAC,OAAO,CAAC,EAAE;gBACV,iBAAiB;gBACjB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sBAAS,CAAC,YAAY,EAAE,OAAO,EAAG,CAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAChF,OAAO;oBACL,MAAM,EAAE,6BAAgB,CAAC,KAAK;oBAC9B,QAAQ;oBACR,MAAM;iBACP,CAAC;aACH;YAED,6BAA6B;YAC7B,IAAI,CAAC,IAAI,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E,CAAC,GAAG,eAAe,CAAC;iBAC7D;aACF;SACF;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA3OD,gCA2OC"}
1
+ {"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,mDAA6B;AAC7B,yFAAwD;AAExD,uDAAoD;AACpD,8EAAwC;AACxC,6CASsB;AACtB,2CAA6C;AAC7C,8DAA6B;AAC7B,gEAA0B;AAC1B,6CAA0C;AAC1C,mCAAiF;AACjF,uDAAmD;AACnD,mEAA+D;AAC/D,wDAAwB;AAExB;;GAEG;AACH,MAAa,UAAU;IASrB;;;OAGG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAa,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI;YACF,MAAM,MAAM,GAAkB,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAoB,EAAE,CAAC;YACrC,IAAI;gBACF,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACtB,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAK,CAAC,CAAC;aACxC;YAAC,OAAO,CAAC,EAAE;gBACV,iBAAiB;gBACjB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sBAAS,CAAC,YAAY,EAAE,OAAO,EAAG,CAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBAChF,OAAO;oBACL,MAAM,EAAE,6BAAgB,CAAC,KAAK;oBAC9B,QAAQ;oBACR,MAAM;iBACP,CAAC;aACH;YAED,IAAI,IAAI,CAAC,aAAa,EAAE;gBACtB,QAAQ,CAAC,IAAI,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IAAI,EAAE,CAAC,GAAG,eAAe,CAAC;iBAC7D;aACF;SACF;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhRD,gCAgRC"}
@@ -1,7 +1,29 @@
1
1
  import { OpenAPIV3 } from "openapi-types";
2
+ import { CheckParamResult, ErrorResult } from "./interfaces";
2
3
  export declare function isYamlSpecFile(specPath: string): Promise<boolean>;
4
+ export declare function checkParameters(paramObject: OpenAPIV3.ParameterObject[]): CheckParamResult;
5
+ export declare function checkPostBody(schema: OpenAPIV3.SchemaObject): CheckParamResult;
6
+ /**
7
+ * Checks if the given API is supported.
8
+ * @param {string} method - The HTTP method of the API.
9
+ * @param {string} path - The path of the API.
10
+ * @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
11
+ * @returns {boolean} - Returns true if the API is supported, false otherwise.
12
+ * @description The following APIs are supported:
13
+ * 1. only support Get/Post operation without auth property
14
+ * 2. parameter inside query or path only support string, number, boolean and integer
15
+ * 3. parameter inside post body only support string, number, boolean, integer and object
16
+ * 4. request body + required parameters <= 1
17
+ * 5. response body should be “application/json” and not empty, and response code should be 20X
18
+ * 6. only support request body with “application/json” content type
19
+ */
3
20
  export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document): boolean;
4
21
  export declare function updateFirstLetter(str: string): string;
5
22
  export declare function getRelativePath(from: string, to: string): string;
6
23
  export declare function getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
24
+ export declare function convertPathToCamelCase(path: string): string;
25
+ export declare function getUrlProtocol(urlString: string): string | undefined;
26
+ export declare function resolveServerUrl(url: string): string;
27
+ export declare function checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
28
+ export declare function validateServer(spec: OpenAPIV3.Document): ErrorResult[];
7
29
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBvE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,OAAO,CAgC9F;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,eAAe,CAC7B,eAAe,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,GACrD,SAAS,CAAC,eAAe,CAiB3B"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAa,MAAM,cAAc,CAAC;AAGxE,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBvE;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,eAAe,EAAE,GAAG,gBAAgB,CA2C1F;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,GAAG,gBAAgB,CAoC9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,OAAO,CA0D9F;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,eAAe,CAC7B,eAAe,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,GACrD,SAAS,CAAC,eAAe,CAY3B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU3D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAepD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,EAAE,GAAG,WAAW,EAAE,CAiC/E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,WAAW,EAAE,CA2CtE"}
@@ -2,12 +2,15 @@
2
2
  // Licensed under the MIT license.
3
3
  "use strict";
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getResponseJson = exports.getRelativePath = exports.updateFirstLetter = exports.isSupportedApi = exports.isYamlSpecFile = void 0;
5
+ exports.validateServer = exports.checkServerUrl = exports.resolveServerUrl = exports.getUrlProtocol = exports.convertPathToCamelCase = exports.getResponseJson = exports.getRelativePath = exports.updateFirstLetter = exports.isSupportedApi = exports.checkPostBody = exports.checkParameters = exports.isYamlSpecFile = void 0;
6
6
  const tslib_1 = require("tslib");
7
7
  const axios_1 = tslib_1.__importDefault(require("axios"));
8
8
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
9
  const constants_1 = require("./constants");
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
+ const util = tslib_1.__importStar(require("util"));
12
+ const interfaces_1 = require("./interfaces");
13
+ const util_1 = require("util");
11
14
  async function isYamlSpecFile(specPath) {
12
15
  if (specPath.endsWith(".yaml") || specPath.endsWith(".yml")) {
13
16
  return true;
@@ -28,30 +31,140 @@ async function isYamlSpecFile(specPath) {
28
31
  }
29
32
  }
30
33
  exports.isYamlSpecFile = isYamlSpecFile;
34
+ function checkParameters(paramObject) {
35
+ const paramResult = {
36
+ requiredNum: 0,
37
+ optionalNum: 0,
38
+ isValid: true,
39
+ };
40
+ if (!paramObject) {
41
+ return paramResult;
42
+ }
43
+ for (let i = 0; i < paramObject.length; i++) {
44
+ const param = paramObject[i];
45
+ if (param.in === "header" || param.in === "cookie") {
46
+ if (param.required) {
47
+ paramResult.isValid = false;
48
+ }
49
+ continue;
50
+ }
51
+ const schema = param.schema;
52
+ if (schema.type !== "boolean" &&
53
+ schema.type !== "string" &&
54
+ schema.type !== "number" &&
55
+ schema.type !== "integer") {
56
+ if (param.required) {
57
+ paramResult.isValid = false;
58
+ }
59
+ continue;
60
+ }
61
+ if (param.in === "query" || param.in === "path") {
62
+ if (param.required) {
63
+ paramResult.requiredNum = paramResult.requiredNum + 1;
64
+ }
65
+ else {
66
+ paramResult.optionalNum = paramResult.optionalNum + 1;
67
+ }
68
+ }
69
+ }
70
+ return paramResult;
71
+ }
72
+ exports.checkParameters = checkParameters;
73
+ function checkPostBody(schema) {
74
+ const paramResult = {
75
+ requiredNum: 0,
76
+ optionalNum: 0,
77
+ isValid: true,
78
+ };
79
+ if (Object.keys(schema).length === 0) {
80
+ return paramResult;
81
+ }
82
+ if (schema.type === "string" ||
83
+ schema.type === "integer" ||
84
+ schema.type === "boolean" ||
85
+ schema.type === "number") {
86
+ if (schema.required) {
87
+ paramResult.requiredNum = paramResult.requiredNum + 1;
88
+ }
89
+ else {
90
+ paramResult.optionalNum = paramResult.optionalNum + 1;
91
+ }
92
+ }
93
+ else if (schema.type === "object") {
94
+ const { properties } = schema;
95
+ for (const property in properties) {
96
+ const result = checkPostBody(properties[property]);
97
+ paramResult.requiredNum += result.requiredNum;
98
+ paramResult.optionalNum += result.optionalNum;
99
+ paramResult.isValid = paramResult.isValid && result.isValid;
100
+ }
101
+ }
102
+ else {
103
+ if (schema.required) {
104
+ paramResult.isValid = false;
105
+ }
106
+ }
107
+ return paramResult;
108
+ }
109
+ exports.checkPostBody = checkPostBody;
110
+ /**
111
+ * Checks if the given API is supported.
112
+ * @param {string} method - The HTTP method of the API.
113
+ * @param {string} path - The path of the API.
114
+ * @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
115
+ * @returns {boolean} - Returns true if the API is supported, false otherwise.
116
+ * @description The following APIs are supported:
117
+ * 1. only support Get/Post operation without auth property
118
+ * 2. parameter inside query or path only support string, number, boolean and integer
119
+ * 3. parameter inside post body only support string, number, boolean, integer and object
120
+ * 4. request body + required parameters <= 1
121
+ * 5. response body should be “application/json” and not empty, and response code should be 20X
122
+ * 6. only support request body with “application/json” content type
123
+ */
31
124
  function isSupportedApi(method, path, spec) {
32
125
  var _a;
33
126
  const pathObj = spec.paths[path];
34
127
  method = method.toLocaleLowerCase();
35
128
  if (pathObj) {
36
- if (method === constants_1.ConstantString.GetMethod && pathObj[method] && !((_a = pathObj[method]) === null || _a === void 0 ? void 0 : _a.security)) {
129
+ if ((method === constants_1.ConstantString.PostMethod || method === constants_1.ConstantString.GetMethod) &&
130
+ pathObj[method] &&
131
+ !((_a = pathObj[method]) === null || _a === void 0 ? void 0 : _a.security)) {
37
132
  const operationObject = pathObj[method];
38
133
  const paramObject = operationObject.parameters;
39
- if (!paramObject || paramObject.length === 0) {
40
- return true;
134
+ const requestBody = operationObject.requestBody;
135
+ const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
136
+ const responseJson = getResponseJson(operationObject);
137
+ if (Object.keys(responseJson).length === 0) {
138
+ return false;
41
139
  }
42
- if (paramObject && paramObject.length === 1) {
43
- for (let i = 0; i < paramObject.length; i++) {
44
- const param = paramObject[i];
45
- if (param.in === "query" || param.in === "path") {
46
- const schema = param.schema;
47
- if (schema.type === "boolean" ||
48
- schema.type === "integer" ||
49
- schema.type === "number" ||
50
- schema.type === "string") {
51
- return true;
52
- }
53
- }
54
- }
140
+ let requestBodyParamResult = {
141
+ requiredNum: 0,
142
+ optionalNum: 0,
143
+ isValid: true,
144
+ };
145
+ if (requestJsonBody) {
146
+ const requestBodySchema = requestJsonBody.schema;
147
+ requestBodyParamResult = checkPostBody(requestBodySchema);
148
+ }
149
+ if (!requestBodyParamResult.isValid) {
150
+ return false;
151
+ }
152
+ const paramResult = checkParameters(paramObject);
153
+ if (!paramResult.isValid) {
154
+ return false;
155
+ }
156
+ if (requestBodyParamResult.requiredNum + paramResult.requiredNum > 1) {
157
+ return false;
158
+ }
159
+ else if (requestBodyParamResult.requiredNum +
160
+ requestBodyParamResult.optionalNum +
161
+ paramResult.requiredNum +
162
+ paramResult.optionalNum ===
163
+ 0) {
164
+ return false;
165
+ }
166
+ else {
167
+ return true;
55
168
  }
56
169
  }
57
170
  }
@@ -68,12 +181,129 @@ function getRelativePath(from, to) {
68
181
  }
69
182
  exports.getRelativePath = getRelativePath;
70
183
  function getResponseJson(operationObject) {
71
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
72
- let json = (_h = (_d = (_c = (_b = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a["200"]) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c["application/json"]) !== null && _d !== void 0 ? _d : (_g = (_f = (_e = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _e === void 0 ? void 0 : _e["201"]) === null || _f === void 0 ? void 0 : _f.content) === null || _g === void 0 ? void 0 : _g["application/json"]) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _j === void 0 ? void 0 : _j.default) === null || _k === void 0 ? void 0 : _k.content) === null || _l === void 0 ? void 0 : _l["application/json"];
73
- if (!json) {
74
- json = {};
184
+ var _a, _b;
185
+ let json = {};
186
+ for (const code of constants_1.ConstantString.ResponseCodeFor20X) {
187
+ const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
188
+ if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
189
+ json = responseObject.content["application/json"];
190
+ break;
191
+ }
75
192
  }
76
193
  return json;
77
194
  }
78
195
  exports.getResponseJson = getResponseJson;
196
+ function convertPathToCamelCase(path) {
197
+ const pathSegments = path.split("/");
198
+ const camelCaseSegments = pathSegments.map((segment) => {
199
+ if (segment.startsWith("{")) {
200
+ segment = segment.substring(1, segment.length - 1);
201
+ }
202
+ return segment.charAt(0).toUpperCase() + segment.slice(1);
203
+ });
204
+ const camelCasePath = camelCaseSegments.join("");
205
+ return camelCasePath;
206
+ }
207
+ exports.convertPathToCamelCase = convertPathToCamelCase;
208
+ function getUrlProtocol(urlString) {
209
+ try {
210
+ const url = new URL(urlString);
211
+ return url.protocol;
212
+ }
213
+ catch (err) {
214
+ return undefined;
215
+ }
216
+ }
217
+ exports.getUrlProtocol = getUrlProtocol;
218
+ function resolveServerUrl(url) {
219
+ const placeHolderReg = /\${{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*}}/g;
220
+ let matches = placeHolderReg.exec(url);
221
+ let newUrl = url;
222
+ while (matches != null) {
223
+ const envVar = matches[1];
224
+ const envVal = process.env[envVar];
225
+ if (!envVal) {
226
+ throw new Error(util_1.format(constants_1.ConstantString.ResolveServerUrlFailed, envVar));
227
+ }
228
+ else {
229
+ newUrl = newUrl.replace(matches[0], envVal);
230
+ }
231
+ matches = placeHolderReg.exec(url);
232
+ }
233
+ return newUrl;
234
+ }
235
+ exports.resolveServerUrl = resolveServerUrl;
236
+ function checkServerUrl(servers) {
237
+ const errors = [];
238
+ let serverUrl;
239
+ try {
240
+ serverUrl = resolveServerUrl(servers[0].url);
241
+ }
242
+ catch (err) {
243
+ errors.push({
244
+ type: interfaces_1.ErrorType.ResolveServerUrlFailed,
245
+ content: err.message,
246
+ data: servers,
247
+ });
248
+ return errors;
249
+ }
250
+ const protocol = getUrlProtocol(serverUrl);
251
+ if (!protocol) {
252
+ // Relative server url is not supported
253
+ errors.push({
254
+ type: interfaces_1.ErrorType.RelativeServerUrlNotSupported,
255
+ content: constants_1.ConstantString.RelativeServerUrlNotSupported,
256
+ data: servers,
257
+ });
258
+ }
259
+ else if (protocol !== "https:") {
260
+ // Http server url is not supported
261
+ errors.push({
262
+ type: interfaces_1.ErrorType.UrlProtocolNotSupported,
263
+ content: util.format(constants_1.ConstantString.UrlProtocolNotSupported, protocol),
264
+ data: servers,
265
+ });
266
+ }
267
+ return errors;
268
+ }
269
+ exports.checkServerUrl = checkServerUrl;
270
+ function validateServer(spec) {
271
+ const errors = [];
272
+ let hasTopLevelServers = false;
273
+ let hasPathLevelServers = false;
274
+ let hasOperationLevelServers = false;
275
+ if (spec.servers && spec.servers.length >= 1) {
276
+ hasTopLevelServers = true;
277
+ // for multiple server, we only use the first url
278
+ const serverErrors = checkServerUrl(spec.servers);
279
+ errors.push(...serverErrors);
280
+ }
281
+ const paths = spec.paths;
282
+ for (const path in paths) {
283
+ const methods = paths[path];
284
+ if ((methods === null || methods === void 0 ? void 0 : methods.servers) && methods.servers.length >= 1) {
285
+ hasPathLevelServers = true;
286
+ const serverErrors = checkServerUrl(methods.servers);
287
+ errors.push(...serverErrors);
288
+ }
289
+ for (const method in methods) {
290
+ const operationObject = methods[method];
291
+ if (isSupportedApi(method, path, spec)) {
292
+ if ((operationObject === null || operationObject === void 0 ? void 0 : operationObject.servers) && operationObject.servers.length >= 1) {
293
+ hasOperationLevelServers = true;
294
+ const serverErrors = checkServerUrl(operationObject.servers);
295
+ errors.push(...serverErrors);
296
+ }
297
+ }
298
+ }
299
+ }
300
+ if (!hasTopLevelServers && !hasPathLevelServers && !hasOperationLevelServers) {
301
+ errors.push({
302
+ type: interfaces_1.ErrorType.NoServerInformation,
303
+ content: constants_1.ConstantString.NoServerInformation,
304
+ });
305
+ }
306
+ return errors;
307
+ }
308
+ exports.validateServer = validateServer;
79
309
  //# sourceMappingURL=utils.js.map