@microsoft/teamsfx-core 0.7.0 → 0.7.1-alpha.5e8f6dea.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 (494) hide show
  1. package/build/common/constants.d.ts +5 -0
  2. package/build/common/constants.d.ts.map +1 -1
  3. package/build/common/constants.js +6 -1
  4. package/build/common/constants.js.map +1 -1
  5. package/build/common/fileUtils.d.ts.map +1 -1
  6. package/build/common/fileUtils.js +12 -6
  7. package/build/common/fileUtils.js.map +1 -1
  8. package/build/common/localSettingsProvider.d.ts +4 -2
  9. package/build/common/localSettingsProvider.d.ts.map +1 -1
  10. package/build/common/localSettingsProvider.js +32 -1
  11. package/build/common/localSettingsProvider.js.map +1 -1
  12. package/build/common/templates.d.ts.map +1 -1
  13. package/build/common/templates.js +9 -9
  14. package/build/common/templates.js.map +1 -1
  15. package/build/common/templatesActions.d.ts +39 -0
  16. package/build/common/templatesActions.d.ts.map +1 -0
  17. package/build/common/templatesActions.js +120 -0
  18. package/build/common/templatesActions.js.map +1 -0
  19. package/build/common/templatesUtils.d.ts +14 -0
  20. package/build/common/templatesUtils.d.ts.map +1 -0
  21. package/build/common/templatesUtils.js +94 -0
  22. package/build/common/templatesUtils.js.map +1 -0
  23. package/build/common/tools.d.ts +12 -2
  24. package/build/common/tools.d.ts.map +1 -1
  25. package/build/common/tools.js +52 -7
  26. package/build/common/tools.js.map +1 -1
  27. package/build/core/SolutionPluginContainer.d.ts +15 -0
  28. package/build/core/SolutionPluginContainer.d.ts.map +1 -0
  29. package/build/core/SolutionPluginContainer.js +54 -0
  30. package/build/core/SolutionPluginContainer.js.map +1 -0
  31. package/build/core/callback.d.ts +9 -0
  32. package/build/core/callback.d.ts.map +1 -0
  33. package/build/core/callback.js +33 -0
  34. package/build/core/callback.js.map +1 -0
  35. package/build/core/environment.d.ts +7 -3
  36. package/build/core/environment.d.ts.map +1 -1
  37. package/build/core/environment.js +68 -13
  38. package/build/core/environment.js.map +1 -1
  39. package/build/core/error.d.ts +19 -2
  40. package/build/core/error.d.ts.map +1 -1
  41. package/build/core/error.js +72 -34
  42. package/build/core/error.js.map +1 -1
  43. package/build/core/index.d.ts +24 -12
  44. package/build/core/index.d.ts.map +1 -1
  45. package/build/core/index.js +604 -309
  46. package/build/core/index.js.map +1 -1
  47. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  48. package/build/core/middleware/concurrentLocker.js +13 -6
  49. package/build/core/middleware/concurrentLocker.js.map +1 -1
  50. package/build/core/middleware/contextInjector.d.ts +3 -0
  51. package/build/core/middleware/contextInjector.d.ts.map +1 -0
  52. package/build/core/middleware/{contextInjecter.js → contextInjector.js} +4 -4
  53. package/build/core/middleware/contextInjector.js.map +1 -0
  54. package/build/core/middleware/envInfoLoader.d.ts +8 -4
  55. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  56. package/build/core/middleware/envInfoLoader.js +77 -40
  57. package/build/core/middleware/envInfoLoader.js.map +1 -1
  58. package/build/core/middleware/envInfoWriter.d.ts +1 -1
  59. package/build/core/middleware/envInfoWriter.d.ts.map +1 -1
  60. package/build/core/middleware/envInfoWriter.js +30 -13
  61. package/build/core/middleware/envInfoWriter.js.map +1 -1
  62. package/build/core/middleware/localSettingsLoader.d.ts.map +1 -1
  63. package/build/core/middleware/localSettingsLoader.js +18 -8
  64. package/build/core/middleware/localSettingsLoader.js.map +1 -1
  65. package/build/core/middleware/localSettingsWriter.d.ts.map +1 -1
  66. package/build/core/middleware/localSettingsWriter.js +14 -5
  67. package/build/core/middleware/localSettingsWriter.js.map +1 -1
  68. package/build/core/middleware/projectMigrator.d.ts +5 -0
  69. package/build/core/middleware/projectMigrator.d.ts.map +1 -0
  70. package/build/core/middleware/projectMigrator.js +382 -0
  71. package/build/core/middleware/projectMigrator.js.map +1 -0
  72. package/build/core/middleware/projectSettingsLoader.d.ts +2 -2
  73. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  74. package/build/core/middleware/projectSettingsLoader.js +13 -9
  75. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  76. package/build/core/middleware/projectSettingsWriter.d.ts.map +1 -1
  77. package/build/core/middleware/projectSettingsWriter.js +6 -7
  78. package/build/core/middleware/projectSettingsWriter.js.map +1 -1
  79. package/build/core/middleware/projectUpgrader.d.ts.map +1 -1
  80. package/build/core/middleware/projectUpgrader.js +15 -7
  81. package/build/core/middleware/projectUpgrader.js.map +1 -1
  82. package/build/core/middleware/questionModel.d.ts.map +1 -1
  83. package/build/core/middleware/questionModel.js +25 -17
  84. package/build/core/middleware/questionModel.js.map +1 -1
  85. package/build/core/middleware/solutionLoader.d.ts +1 -2
  86. package/build/core/middleware/solutionLoader.d.ts.map +1 -1
  87. package/build/core/middleware/solutionLoader.js +24 -4
  88. package/build/core/middleware/solutionLoader.js.map +1 -1
  89. package/build/core/question.d.ts +2 -0
  90. package/build/core/question.d.ts.map +1 -1
  91. package/build/core/question.js +12 -1
  92. package/build/core/question.js.map +1 -1
  93. package/build/core/tools.d.ts +2 -2
  94. package/build/core/tools.d.ts.map +1 -1
  95. package/build/core/tools.js +15 -5
  96. package/build/core/tools.js.map +1 -1
  97. package/build/index.d.ts +1 -0
  98. package/build/index.d.ts.map +1 -1
  99. package/build/index.js +1 -0
  100. package/build/index.js.map +1 -1
  101. package/build/plugins/resource/aad/appStudio.js +1 -1
  102. package/build/plugins/resource/aad/appStudio.js.map +1 -1
  103. package/build/plugins/resource/aad/errors.d.ts.map +1 -1
  104. package/build/plugins/resource/aad/errors.js +1 -0
  105. package/build/plugins/resource/aad/errors.js.map +1 -1
  106. package/build/plugins/resource/aad/index.d.ts +1 -0
  107. package/build/plugins/resource/aad/index.d.ts.map +1 -1
  108. package/build/plugins/resource/aad/index.js +2 -1
  109. package/build/plugins/resource/aad/index.js.map +1 -1
  110. package/build/plugins/resource/aad/utils/configs.d.ts.map +1 -1
  111. package/build/plugins/resource/aad/utils/configs.js +9 -10
  112. package/build/plugins/resource/aad/utils/configs.js.map +1 -1
  113. package/build/plugins/resource/aad/utils/telemetry.js +1 -1
  114. package/build/plugins/resource/aad/utils/telemetry.js.map +1 -1
  115. package/build/plugins/resource/aad/v2/index.d.ts +7 -7
  116. package/build/plugins/resource/aad/v2/index.d.ts.map +1 -1
  117. package/build/plugins/resource/aad/v2/index.js +6 -6
  118. package/build/plugins/resource/aad/v2/index.js.map +1 -1
  119. package/build/plugins/resource/apim/config.d.ts +1 -0
  120. package/build/plugins/resource/apim/config.d.ts.map +1 -1
  121. package/build/plugins/resource/apim/config.js.map +1 -1
  122. package/build/plugins/resource/apim/constants.d.ts +3 -0
  123. package/build/plugins/resource/apim/constants.d.ts.map +1 -1
  124. package/build/plugins/resource/apim/constants.js +5 -1
  125. package/build/plugins/resource/apim/constants.js.map +1 -1
  126. package/build/plugins/resource/apim/factory.d.ts +2 -1
  127. package/build/plugins/resource/apim/factory.d.ts.map +1 -1
  128. package/build/plugins/resource/apim/factory.js +19 -8
  129. package/build/plugins/resource/apim/factory.js.map +1 -1
  130. package/build/plugins/resource/apim/index.d.ts +2 -0
  131. package/build/plugins/resource/apim/index.d.ts.map +1 -1
  132. package/build/plugins/resource/apim/index.js +15 -8
  133. package/build/plugins/resource/apim/index.js.map +1 -1
  134. package/build/plugins/resource/apim/questions/vscodeQuestion.js +1 -1
  135. package/build/plugins/resource/apim/questions/vscodeQuestion.js.map +1 -1
  136. package/build/plugins/resource/apim/v2/index.d.ts +9 -11
  137. package/build/plugins/resource/apim/v2/index.d.ts.map +1 -1
  138. package/build/plugins/resource/apim/v2/index.js +25 -29
  139. package/build/plugins/resource/apim/v2/index.js.map +1 -1
  140. package/build/plugins/resource/appstudio/appStudio.d.ts.map +1 -1
  141. package/build/plugins/resource/appstudio/appStudio.js +9 -8
  142. package/build/plugins/resource/appstudio/appStudio.js.map +1 -1
  143. package/build/plugins/resource/appstudio/constants.d.ts +6 -2
  144. package/build/plugins/resource/appstudio/constants.d.ts.map +1 -1
  145. package/build/plugins/resource/appstudio/constants.js +124 -13
  146. package/build/plugins/resource/appstudio/constants.js.map +1 -1
  147. package/build/plugins/resource/appstudio/errors.d.ts +4 -0
  148. package/build/plugins/resource/appstudio/errors.d.ts.map +1 -1
  149. package/build/plugins/resource/appstudio/errors.js +8 -0
  150. package/build/plugins/resource/appstudio/errors.js.map +1 -1
  151. package/build/plugins/resource/appstudio/index.d.ts +1 -0
  152. package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
  153. package/build/plugins/resource/appstudio/index.js +23 -5
  154. package/build/plugins/resource/appstudio/index.js.map +1 -1
  155. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts +1 -0
  156. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts.map +1 -1
  157. package/build/plugins/resource/appstudio/plugin.d.ts +2 -1
  158. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  159. package/build/plugins/resource/appstudio/plugin.js +197 -68
  160. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  161. package/build/plugins/resource/appstudio/utils/telemetry.d.ts +2 -1
  162. package/build/plugins/resource/appstudio/utils/telemetry.d.ts.map +1 -1
  163. package/build/plugins/resource/appstudio/utils/telemetry.js +17 -12
  164. package/build/plugins/resource/appstudio/utils/telemetry.js.map +1 -1
  165. package/build/plugins/resource/appstudio/v2/index.d.ts +10 -13
  166. package/build/plugins/resource/appstudio/v2/index.d.ts.map +1 -1
  167. package/build/plugins/resource/appstudio/v2/index.js +25 -20
  168. package/build/plugins/resource/appstudio/v2/index.js.map +1 -1
  169. package/build/plugins/resource/bot/appStudio/appStudio.js +2 -2
  170. package/build/plugins/resource/bot/appStudio/appStudio.js.map +1 -1
  171. package/build/plugins/resource/bot/configs/localDebugConfig.d.ts +1 -1
  172. package/build/plugins/resource/bot/configs/localDebugConfig.d.ts.map +1 -1
  173. package/build/plugins/resource/bot/configs/localDebugConfig.js +3 -3
  174. package/build/plugins/resource/bot/configs/localDebugConfig.js.map +1 -1
  175. package/build/plugins/resource/bot/configs/provisionConfig.js +21 -20
  176. package/build/plugins/resource/bot/configs/provisionConfig.js.map +1 -1
  177. package/build/plugins/resource/bot/configs/scaffoldConfig.d.ts +1 -3
  178. package/build/plugins/resource/bot/configs/scaffoldConfig.d.ts.map +1 -1
  179. package/build/plugins/resource/bot/configs/scaffoldConfig.js +9 -10
  180. package/build/plugins/resource/bot/configs/scaffoldConfig.js.map +1 -1
  181. package/build/plugins/resource/bot/configs/teamsBotConfig.d.ts.map +1 -1
  182. package/build/plugins/resource/bot/configs/teamsBotConfig.js +5 -5
  183. package/build/plugins/resource/bot/configs/teamsBotConfig.js.map +1 -1
  184. package/build/plugins/resource/bot/constants.d.ts +0 -2
  185. package/build/plugins/resource/bot/constants.d.ts.map +1 -1
  186. package/build/plugins/resource/bot/constants.js +2 -14
  187. package/build/plugins/resource/bot/constants.js.map +1 -1
  188. package/build/plugins/resource/bot/index.d.ts +2 -3
  189. package/build/plugins/resource/bot/index.d.ts.map +1 -1
  190. package/build/plugins/resource/bot/index.js +1 -7
  191. package/build/plugins/resource/bot/index.js.map +1 -1
  192. package/build/plugins/resource/bot/plugin.d.ts +1 -4
  193. package/build/plugins/resource/bot/plugin.d.ts.map +1 -1
  194. package/build/plugins/resource/bot/plugin.js +21 -80
  195. package/build/plugins/resource/bot/plugin.js.map +1 -1
  196. package/build/plugins/resource/bot/resources/messages.d.ts +0 -1
  197. package/build/plugins/resource/bot/resources/messages.d.ts.map +1 -1
  198. package/build/plugins/resource/bot/resources/messages.js +0 -1
  199. package/build/plugins/resource/bot/resources/messages.js.map +1 -1
  200. package/build/plugins/resource/bot/resources/strings.d.ts +1 -1
  201. package/build/plugins/resource/bot/resources/strings.d.ts.map +1 -1
  202. package/build/plugins/resource/bot/resources/strings.js +1 -1
  203. package/build/plugins/resource/bot/resources/strings.js.map +1 -1
  204. package/build/plugins/resource/bot/utils/telemetry-helper.d.ts.map +1 -1
  205. package/build/plugins/resource/bot/utils/telemetry-helper.js +1 -1
  206. package/build/plugins/resource/bot/utils/telemetry-helper.js.map +1 -1
  207. package/build/plugins/resource/bot/v2/index.d.ts +9 -13
  208. package/build/plugins/resource/bot/v2/index.d.ts.map +1 -1
  209. package/build/plugins/resource/bot/v2/index.js +7 -7
  210. package/build/plugins/resource/bot/v2/index.js.map +1 -1
  211. package/build/plugins/resource/frontend/configs.d.ts +7 -2
  212. package/build/plugins/resource/frontend/configs.d.ts.map +1 -1
  213. package/build/plugins/resource/frontend/configs.js +49 -29
  214. package/build/plugins/resource/frontend/configs.js.map +1 -1
  215. package/build/plugins/resource/frontend/constants.d.ts +3 -2
  216. package/build/plugins/resource/frontend/constants.d.ts.map +1 -1
  217. package/build/plugins/resource/frontend/constants.js +4 -3
  218. package/build/plugins/resource/frontend/constants.js.map +1 -1
  219. package/build/plugins/resource/frontend/index.d.ts +1 -1
  220. package/build/plugins/resource/frontend/index.d.ts.map +1 -1
  221. package/build/plugins/resource/frontend/index.js +6 -5
  222. package/build/plugins/resource/frontend/index.js.map +1 -1
  223. package/build/plugins/resource/frontend/ops/deploy.d.ts.map +1 -1
  224. package/build/plugins/resource/frontend/ops/deploy.js +1 -0
  225. package/build/plugins/resource/frontend/ops/deploy.js.map +1 -1
  226. package/build/plugins/resource/frontend/plugin.d.ts +4 -1
  227. package/build/plugins/resource/frontend/plugin.d.ts.map +1 -1
  228. package/build/plugins/resource/frontend/plugin.js +32 -32
  229. package/build/plugins/resource/frontend/plugin.js.map +1 -1
  230. package/build/plugins/resource/frontend/resources/errors.d.ts +1 -1
  231. package/build/plugins/resource/frontend/resources/errors.d.ts.map +1 -1
  232. package/build/plugins/resource/frontend/resources/errors.js +5 -2
  233. package/build/plugins/resource/frontend/resources/errors.js.map +1 -1
  234. package/build/plugins/resource/frontend/utils/telemetry-helper.js +1 -1
  235. package/build/plugins/resource/frontend/utils/telemetry-helper.js.map +1 -1
  236. package/build/plugins/resource/frontend/v2/index.d.ts +6 -9
  237. package/build/plugins/resource/frontend/v2/index.d.ts.map +1 -1
  238. package/build/plugins/resource/frontend/v2/index.js +5 -2
  239. package/build/plugins/resource/frontend/v2/index.js.map +1 -1
  240. package/build/plugins/resource/function/constants.d.ts +2 -6
  241. package/build/plugins/resource/function/constants.d.ts.map +1 -1
  242. package/build/plugins/resource/function/constants.js +3 -8
  243. package/build/plugins/resource/function/constants.js.map +1 -1
  244. package/build/plugins/resource/function/enums.d.ts +2 -0
  245. package/build/plugins/resource/function/enums.d.ts.map +1 -1
  246. package/build/plugins/resource/function/enums.js +2 -0
  247. package/build/plugins/resource/function/enums.js.map +1 -1
  248. package/build/plugins/resource/function/index.d.ts +1 -0
  249. package/build/plugins/resource/function/index.d.ts.map +1 -1
  250. package/build/plugins/resource/function/index.js +1 -0
  251. package/build/plugins/resource/function/index.js.map +1 -1
  252. package/build/plugins/resource/function/ops/deploy.d.ts +1 -1
  253. package/build/plugins/resource/function/ops/deploy.d.ts.map +1 -1
  254. package/build/plugins/resource/function/ops/deploy.js +13 -5
  255. package/build/plugins/resource/function/ops/deploy.js.map +1 -1
  256. package/build/plugins/resource/function/ops/scaffold.d.ts +4 -7
  257. package/build/plugins/resource/function/ops/scaffold.d.ts.map +1 -1
  258. package/build/plugins/resource/function/ops/scaffold.js +42 -40
  259. package/build/plugins/resource/function/ops/scaffold.js.map +1 -1
  260. package/build/plugins/resource/function/plugin.d.ts +4 -0
  261. package/build/plugins/resource/function/plugin.d.ts.map +1 -1
  262. package/build/plugins/resource/function/plugin.js +57 -41
  263. package/build/plugins/resource/function/plugin.js.map +1 -1
  264. package/build/plugins/resource/function/resources/errors.d.ts +2 -5
  265. package/build/plugins/resource/function/resources/errors.d.ts.map +1 -1
  266. package/build/plugins/resource/function/resources/errors.js +5 -13
  267. package/build/plugins/resource/function/resources/errors.js.map +1 -1
  268. package/build/plugins/resource/function/resources/message.d.ts +1 -0
  269. package/build/plugins/resource/function/resources/message.d.ts.map +1 -1
  270. package/build/plugins/resource/function/resources/message.js +1 -0
  271. package/build/plugins/resource/function/resources/message.js.map +1 -1
  272. package/build/plugins/resource/function/utils/telemetry-helper.js +1 -1
  273. package/build/plugins/resource/function/utils/telemetry-helper.js.map +1 -1
  274. package/build/plugins/resource/function/v2/index.d.ts +8 -11
  275. package/build/plugins/resource/function/v2/index.d.ts.map +1 -1
  276. package/build/plugins/resource/function/v2/index.js +9 -17
  277. package/build/plugins/resource/function/v2/index.js.map +1 -1
  278. package/build/plugins/resource/identity/index.d.ts +1 -0
  279. package/build/plugins/resource/identity/index.d.ts.map +1 -1
  280. package/build/plugins/resource/identity/index.js +7 -9
  281. package/build/plugins/resource/identity/index.js.map +1 -1
  282. package/build/plugins/resource/identity/utils/contextUtils.js +1 -1
  283. package/build/plugins/resource/identity/utils/contextUtils.js.map +1 -1
  284. package/build/plugins/resource/identity/utils/telemetryUtil.d.ts.map +1 -1
  285. package/build/plugins/resource/identity/utils/telemetryUtil.js +1 -1
  286. package/build/plugins/resource/identity/utils/telemetryUtil.js.map +1 -1
  287. package/build/plugins/resource/identity/v2/index.d.ts +3 -3
  288. package/build/plugins/resource/identity/v2/index.d.ts.map +1 -1
  289. package/build/plugins/resource/identity/v2/index.js +2 -2
  290. package/build/plugins/resource/identity/v2/index.js.map +1 -1
  291. package/build/plugins/resource/localdebug/constants.d.ts +4 -0
  292. package/build/plugins/resource/localdebug/constants.d.ts.map +1 -1
  293. package/build/plugins/resource/localdebug/constants.js +6 -1
  294. package/build/plugins/resource/localdebug/constants.js.map +1 -1
  295. package/build/plugins/resource/localdebug/index.d.ts +1 -0
  296. package/build/plugins/resource/localdebug/index.d.ts.map +1 -1
  297. package/build/plugins/resource/localdebug/index.js +12 -6
  298. package/build/plugins/resource/localdebug/index.js.map +1 -1
  299. package/build/plugins/resource/localdebug/launch.d.ts +1 -0
  300. package/build/plugins/resource/localdebug/launch.d.ts.map +1 -1
  301. package/build/plugins/resource/localdebug/launch.js +66 -1
  302. package/build/plugins/resource/localdebug/launch.js.map +1 -1
  303. package/build/plugins/resource/localdebug/legacyPlugin.js +4 -4
  304. package/build/plugins/resource/localdebug/legacyPlugin.js.map +1 -1
  305. package/build/plugins/resource/localdebug/tasks.d.ts.map +1 -1
  306. package/build/plugins/resource/localdebug/tasks.js +12 -2
  307. package/build/plugins/resource/localdebug/tasks.js.map +1 -1
  308. package/build/plugins/resource/localdebug/util/telemetry.js +1 -1
  309. package/build/plugins/resource/localdebug/util/telemetry.js.map +1 -1
  310. package/build/plugins/resource/localdebug/v2/index.d.ts +6 -8
  311. package/build/plugins/resource/localdebug/v2/index.d.ts.map +1 -1
  312. package/build/plugins/resource/localdebug/v2/index.js +2 -2
  313. package/build/plugins/resource/localdebug/v2/index.js.map +1 -1
  314. package/build/plugins/resource/simpleauth/index.d.ts +1 -0
  315. package/build/plugins/resource/simpleauth/index.d.ts.map +1 -1
  316. package/build/plugins/resource/simpleauth/index.js +1 -0
  317. package/build/plugins/resource/simpleauth/index.js.map +1 -1
  318. package/build/plugins/resource/simpleauth/plugin.d.ts.map +1 -1
  319. package/build/plugins/resource/simpleauth/plugin.js +1 -6
  320. package/build/plugins/resource/simpleauth/plugin.js.map +1 -1
  321. package/build/plugins/resource/simpleauth/utils/common.js +1 -1
  322. package/build/plugins/resource/simpleauth/utils/common.js.map +1 -1
  323. package/build/plugins/resource/simpleauth/utils/telemetry.d.ts.map +1 -1
  324. package/build/plugins/resource/simpleauth/utils/telemetry.js +2 -1
  325. package/build/plugins/resource/simpleauth/utils/telemetry.js.map +1 -1
  326. package/build/plugins/resource/simpleauth/v2/index.d.ts +4 -4
  327. package/build/plugins/resource/simpleauth/v2/index.d.ts.map +1 -1
  328. package/build/plugins/resource/simpleauth/v2/index.js.map +1 -1
  329. package/build/plugins/resource/spfx/index.d.ts +1 -0
  330. package/build/plugins/resource/spfx/index.d.ts.map +1 -1
  331. package/build/plugins/resource/spfx/index.js +1 -0
  332. package/build/plugins/resource/spfx/index.js.map +1 -1
  333. package/build/plugins/resource/spfx/v2/index.d.ts +4 -8
  334. package/build/plugins/resource/spfx/v2/index.d.ts.map +1 -1
  335. package/build/plugins/resource/spfx/v2/index.js.map +1 -1
  336. package/build/plugins/resource/sql/config.d.ts +0 -1
  337. package/build/plugins/resource/sql/config.d.ts.map +1 -1
  338. package/build/plugins/resource/sql/config.js +0 -1
  339. package/build/plugins/resource/sql/config.js.map +1 -1
  340. package/build/plugins/resource/sql/errors.d.ts +4 -0
  341. package/build/plugins/resource/sql/errors.d.ts.map +1 -1
  342. package/build/plugins/resource/sql/errors.js +4 -0
  343. package/build/plugins/resource/sql/errors.js.map +1 -1
  344. package/build/plugins/resource/sql/index.d.ts +1 -0
  345. package/build/plugins/resource/sql/index.d.ts.map +1 -1
  346. package/build/plugins/resource/sql/index.js +1 -0
  347. package/build/plugins/resource/sql/index.js.map +1 -1
  348. package/build/plugins/resource/sql/plugin.d.ts +4 -0
  349. package/build/plugins/resource/sql/plugin.d.ts.map +1 -1
  350. package/build/plugins/resource/sql/plugin.js +68 -69
  351. package/build/plugins/resource/sql/plugin.js.map +1 -1
  352. package/build/plugins/resource/sql/utils/contextUtils.js +1 -1
  353. package/build/plugins/resource/sql/utils/contextUtils.js.map +1 -1
  354. package/build/plugins/resource/sql/utils/telemetryUtils.d.ts.map +1 -1
  355. package/build/plugins/resource/sql/utils/telemetryUtils.js +2 -1
  356. package/build/plugins/resource/sql/utils/telemetryUtils.js.map +1 -1
  357. package/build/plugins/resource/sql/v2/index.d.ts +5 -4
  358. package/build/plugins/resource/sql/v2/index.d.ts.map +1 -1
  359. package/build/plugins/resource/sql/v2/index.js +18 -16
  360. package/build/plugins/resource/sql/v2/index.js.map +1 -1
  361. package/build/plugins/resource/utils4v2.d.ts +16 -14
  362. package/build/plugins/resource/utils4v2.d.ts.map +1 -1
  363. package/build/plugins/resource/utils4v2.js +127 -92
  364. package/build/plugins/resource/utils4v2.js.map +1 -1
  365. package/build/plugins/solution/fx-solution/ResourcePluginContainer.d.ts.map +1 -1
  366. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js +4 -2
  367. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js.map +1 -1
  368. package/build/plugins/solution/fx-solution/arm.d.ts +11 -0
  369. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  370. package/build/plugins/solution/fx-solution/arm.js +118 -40
  371. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  372. package/build/plugins/solution/fx-solution/commonQuestions.d.ts +2 -2
  373. package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
  374. package/build/plugins/solution/fx-solution/commonQuestions.js +120 -47
  375. package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
  376. package/build/plugins/solution/fx-solution/constants.d.ts +16 -2
  377. package/build/plugins/solution/fx-solution/constants.d.ts.map +1 -1
  378. package/build/plugins/solution/fx-solution/constants.js +15 -1
  379. package/build/plugins/solution/fx-solution/constants.js.map +1 -1
  380. package/build/plugins/solution/fx-solution/executor.d.ts.map +1 -1
  381. package/build/plugins/solution/fx-solution/executor.js +39 -21
  382. package/build/plugins/solution/fx-solution/executor.js.map +1 -1
  383. package/build/plugins/solution/fx-solution/index.d.ts +2 -0
  384. package/build/plugins/solution/fx-solution/index.d.ts.map +1 -1
  385. package/build/plugins/solution/fx-solution/index.js +2 -0
  386. package/build/plugins/solution/fx-solution/index.js.map +1 -1
  387. package/build/plugins/solution/fx-solution/question.d.ts +2 -1
  388. package/build/plugins/solution/fx-solution/question.d.ts.map +1 -1
  389. package/build/plugins/solution/fx-solution/question.js +18 -1
  390. package/build/plugins/solution/fx-solution/question.js.map +1 -1
  391. package/build/plugins/solution/fx-solution/solution.d.ts +3 -6
  392. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  393. package/build/plugins/solution/fx-solution/solution.js +406 -379
  394. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  395. package/build/plugins/solution/fx-solution/utils/util.js +1 -1
  396. package/build/plugins/solution/fx-solution/utils/util.js.map +1 -1
  397. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts +3 -0
  398. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts.map +1 -1
  399. package/build/plugins/solution/fx-solution/v2/adaptor.js +37 -3
  400. package/build/plugins/solution/fx-solution/v2/adaptor.js.map +1 -1
  401. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts +3 -0
  402. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -0
  403. package/build/plugins/solution/fx-solution/v2/createEnv.js +28 -0
  404. package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -0
  405. package/build/plugins/solution/fx-solution/v2/deploy.d.ts +2 -4
  406. package/build/plugins/solution/fx-solution/v2/deploy.d.ts.map +1 -1
  407. package/build/plugins/solution/fx-solution/v2/deploy.js +19 -14
  408. package/build/plugins/solution/fx-solution/v2/deploy.js.map +1 -1
  409. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts +2 -2
  410. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  411. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +20 -4
  412. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  413. package/build/plugins/solution/fx-solution/v2/executor.d.ts +2 -2
  414. package/build/plugins/solution/fx-solution/v2/executor.d.ts.map +1 -1
  415. package/build/plugins/solution/fx-solution/v2/executor.js +27 -3
  416. package/build/plugins/solution/fx-solution/v2/executor.js.map +1 -1
  417. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts +2 -2
  418. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts.map +1 -1
  419. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js +8 -2
  420. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js.map +1 -1
  421. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts +8 -0
  422. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -0
  423. package/build/plugins/solution/fx-solution/v2/getQuestions.js +393 -0
  424. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -0
  425. package/build/plugins/solution/fx-solution/v2/package.d.ts.map +1 -1
  426. package/build/plugins/solution/fx-solution/v2/package.js +12 -2
  427. package/build/plugins/solution/fx-solution/v2/package.js.map +1 -1
  428. package/build/plugins/solution/fx-solution/v2/provision.d.ts +4 -0
  429. package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -0
  430. package/build/plugins/solution/fx-solution/v2/provision.js +153 -0
  431. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -0
  432. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts +3 -0
  433. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -0
  434. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +73 -0
  435. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -0
  436. package/build/plugins/solution/fx-solution/v2/publish.d.ts +2 -2
  437. package/build/plugins/solution/fx-solution/v2/publish.d.ts.map +1 -1
  438. package/build/plugins/solution/fx-solution/v2/publish.js +11 -11
  439. package/build/plugins/solution/fx-solution/v2/publish.js.map +1 -1
  440. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts +3 -7
  441. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts.map +1 -1
  442. package/build/plugins/solution/fx-solution/v2/scaffolding.js +21 -6
  443. package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
  444. package/build/plugins/solution/fx-solution/v2/solution.d.ts +18 -0
  445. package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -0
  446. package/build/plugins/solution/fx-solution/v2/solution.js +38 -0
  447. package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -0
  448. package/build/plugins/solution/fx-solution/v2/utils.d.ts +11 -9
  449. package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
  450. package/build/plugins/solution/fx-solution/v2/utils.js +81 -1
  451. package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
  452. package/package.json +8 -5
  453. package/resource/strings.json +2 -1
  454. package/templates/plugins/resource/bot/bicep/botConfiguration.template.bicep +0 -4
  455. package/templates/plugins/resource/bot/bicep/botProvision.template.bicep +0 -6
  456. package/templates/plugins/resource/bot/bicep/module.template.bicep +0 -4
  457. package/templates/plugins/resource/bot/bicep/output.template.bicep +0 -2
  458. package/templates/plugins/resource/bot/bicep/param.template.bicep +0 -2
  459. package/templates/plugins/resource/bot/bot-msgext.js.default.zip +0 -0
  460. package/templates/plugins/resource/bot/bot-msgext.ts.default.zip +0 -0
  461. package/templates/plugins/resource/bot/bot.js.default.zip +0 -0
  462. package/templates/plugins/resource/bot/bot.ts.default.zip +0 -0
  463. package/templates/plugins/resource/bot/msgext.js.default.zip +0 -0
  464. package/templates/plugins/resource/bot/msgext.ts.default.zip +0 -0
  465. package/templates/plugins/resource/frontend/bicep/frontendHosting.bicep +1 -1
  466. package/templates/plugins/resource/frontend/bicep/output.template.bicep +1 -1
  467. package/templates/plugins/resource/frontend/tab.js.default.zip +0 -0
  468. package/templates/plugins/resource/frontend/tab.ts.default.zip +0 -0
  469. package/templates/plugins/resource/function/bicep/functionProvision.template.bicep +1 -3
  470. package/templates/plugins/resource/function/bicep/output.template.bicep +1 -3
  471. package/templates/plugins/resource/function/function-base.js.default.zip +0 -0
  472. package/templates/plugins/resource/function/function-base.ts.default.zip +0 -0
  473. package/templates/plugins/resource/function/function-triggers.js.HTTPTrigger.zip +0 -0
  474. package/templates/plugins/resource/function/function-triggers.ts.HTTPTrigger.zip +0 -0
  475. package/templates/plugins/resource/spfx/solution/manifest_multi_env.json +62 -0
  476. package/build/core/loader.d.ts +0 -11
  477. package/build/core/loader.d.ts.map +0 -1
  478. package/build/core/loader.js +0 -17
  479. package/build/core/loader.js.map +0 -1
  480. package/build/core/middleware/contextInjecter.d.ts +0 -3
  481. package/build/core/middleware/contextInjecter.d.ts.map +0 -1
  482. package/build/core/middleware/contextInjecter.js.map +0 -1
  483. package/build/plugins/resource/bot/enums/wayToRegisterBot.d.ts +0 -5
  484. package/build/plugins/resource/bot/enums/wayToRegisterBot.d.ts.map +0 -1
  485. package/build/plugins/resource/bot/enums/wayToRegisterBot.js +0 -11
  486. package/build/plugins/resource/bot/enums/wayToRegisterBot.js.map +0 -1
  487. package/build/plugins/resource/bot/questions.d.ts +0 -4
  488. package/build/plugins/resource/bot/questions.d.ts.map +0 -1
  489. package/build/plugins/resource/bot/questions.js +0 -65
  490. package/build/plugins/resource/bot/questions.js.map +0 -1
  491. package/build/plugins/resource/function/utils/templates-fetch.d.ts +0 -10
  492. package/build/plugins/resource/function/utils/templates-fetch.d.ts.map +0 -1
  493. package/build/plugins/resource/function/utils/templates-fetch.js +0 -107
  494. package/build/plugins/resource/function/utils/templates-fetch.js.map +0 -1
@@ -8,30 +8,33 @@ const tslib_1 = require("tslib");
8
8
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
9
9
  // Copyright (c) Microsoft Corporation.
10
10
  // Licensed under the MIT license.
11
+ const lib_1 = require("@feathersjs/hooks/lib");
11
12
  const teamsfx_api_1 = require("@microsoft/teamsfx-api");
12
- const commonQuestions_1 = require("./commonQuestions");
13
- const executor_1 = require("./executor");
14
- const util_1 = require("./utils/util");
13
+ const axios_1 = tslib_1.__importDefault(require("axios"));
15
14
  const fs = tslib_1.__importStar(require("fs-extra"));
16
- const constants_1 = require("./constants");
17
- const question_1 = require("./question");
18
15
  const mustache_1 = tslib_1.__importDefault(require("mustache"));
19
16
  const path_1 = tslib_1.__importDefault(require("path"));
17
+ const typedi_1 = require("typedi");
20
18
  const util = tslib_1.__importStar(require("util"));
19
+ const constants_1 = require("../../../common/constants");
20
+ const localSettingsConstants_1 = require("../../../common/localSettingsConstants");
21
21
  const tools_1 = require("../../../common/tools");
22
- const ResourcePluginContainer_1 = require("./ResourcePluginContainer");
23
- const resource_1 = require("../../resource");
22
+ const core_1 = require("../../../core");
24
23
  const errorHandler_1 = require("../../../core/middleware/errorHandler");
25
- const lib_1 = require("@feathersjs/hooks/lib");
26
- const typedi_1 = require("typedi");
27
- const arm_1 = require("./arm");
28
- const constants_2 = require("../../../common/constants");
29
- const localSettingsConstants_1 = require("../../../common/localSettingsConstants");
30
- const scaffolding_1 = require("./v2/scaffolding");
31
24
  const permissionRequest_1 = require("../../../core/permissionRequest");
32
- const axios_1 = tslib_1.__importDefault(require("axios"));
25
+ const SolutionPluginContainer_1 = require("../../../core/SolutionPluginContainer");
26
+ const resource_1 = require("../../resource");
27
+ const arm_1 = require("./arm");
28
+ const commonQuestions_1 = require("./commonQuestions");
29
+ const constants_2 = require("./constants");
30
+ const executor_1 = require("./executor");
31
+ const question_1 = require("./question");
32
+ const ResourcePluginContainer_1 = require("./ResourcePluginContainer");
33
+ const util_1 = require("./utils/util");
33
34
  const executeUserTask_1 = require("./v2/executeUserTask");
34
- const envInfoLoader_1 = require("../../../core/middleware/envInfoLoader");
35
+ const utils_1 = require("./v2/utils");
36
+ const provision_1 = require("./v2/provision");
37
+ const scaffolding_1 = require("./v2/scaffolding");
35
38
  // Maybe we need a state machine to track state transition.
36
39
  var SolutionRunningState;
37
40
  (function (SolutionRunningState) {
@@ -63,56 +66,10 @@ let TeamsAppSolution = class TeamsAppSolution {
63
66
  }
64
67
  assertSettingsNotEmpty(settings, key) {
65
68
  if (!settings) {
66
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`${key} is undefined`), "Solution", constants_1.SolutionError.InternelError));
69
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`${key} is undefined`), "Solution", constants_2.SolutionError.InternelError));
67
70
  }
68
71
  return teamsfx_api_1.ok(settings);
69
72
  }
70
- fillInSolutionSettings(ctx) {
71
- var _a;
72
- const assertList = [
73
- this.assertSettingsNotEmpty(ctx.answers, "answers"),
74
- this.assertSettingsNotEmpty(ctx.projectSettings, "projectSettings"),
75
- this.assertSettingsNotEmpty((_a = ctx === null || ctx === void 0 ? void 0 : ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings, "solutionSettings"),
76
- ];
77
- const assertRes = teamsfx_api_1.combine(assertList);
78
- if (assertRes.isErr()) {
79
- return teamsfx_api_1.err(assertRes.error);
80
- }
81
- const [answers, projectSettings, solutionSettingsSource] = assertRes.value;
82
- const capabilities = answers[question_1.AzureSolutionQuestionNames.Capabilities] || [];
83
- if (!capabilities || capabilities.length === 0) {
84
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("capabilities is empty"), "Solution", constants_1.SolutionError.InternelError));
85
- }
86
- let hostType = answers[question_1.AzureSolutionQuestionNames.HostType];
87
- if (capabilities.includes(question_1.BotOptionItem.id) || capabilities.includes(question_1.MessageExtensionItem.id))
88
- hostType = question_1.HostTypeOptionAzure.id;
89
- if (!hostType) {
90
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("hostType is undefined"), "Solution", constants_1.SolutionError.InternelError));
91
- }
92
- let azureResources;
93
- if (hostType === question_1.HostTypeOptionAzure.id && capabilities.includes(question_1.TabOptionItem.id)) {
94
- azureResources = answers[question_1.AzureSolutionQuestionNames.AzureResources];
95
- if (azureResources) {
96
- if ((azureResources.includes(question_1.AzureResourceSQL.id) ||
97
- azureResources.includes(question_1.AzureResourceApim.id)) &&
98
- !azureResources.includes(question_1.AzureResourceFunction.id)) {
99
- azureResources.push(question_1.AzureResourceFunction.id);
100
- }
101
- }
102
- else
103
- azureResources = [];
104
- }
105
- const solutionSettings = {
106
- name: solutionSettingsSource.name,
107
- version: solutionSettingsSource.version,
108
- hostType: hostType,
109
- capabilities: capabilities,
110
- azureResources: azureResources || [],
111
- activeResourcePlugins: [],
112
- };
113
- projectSettings.solutionSettings = solutionSettings;
114
- return teamsfx_api_1.ok(solutionSettings);
115
- }
116
73
  async fillInV1SolutionSettings(ctx) {
117
74
  var _a;
118
75
  const assertList = [
@@ -129,7 +86,7 @@ let TeamsAppSolution = class TeamsAppSolution {
129
86
  projectSettings.programmingLanguage = isTypescriptProject ? "typescript" : "javascript";
130
87
  const capability = answers[question_1.AzureSolutionQuestionNames.V1Capability];
131
88
  if (!capability) {
132
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("capabilities is empty"), "Solution", constants_1.SolutionError.InternelError));
89
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("capabilities is empty"), "Solution", constants_2.SolutionError.InternelError));
133
90
  }
134
91
  const solutionSettings = {
135
92
  name: solutionSettingsSource.name,
@@ -147,56 +104,59 @@ let TeamsAppSolution = class TeamsAppSolution {
147
104
  * create
148
105
  */
149
106
  async create(ctx) {
150
- var _a, _b;
151
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.CreateStart, {
152
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
107
+ var _a, _b, _c, _d;
108
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CreateStart, {
109
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
153
110
  });
111
+ if (!ctx.projectSettings)
112
+ return teamsfx_api_1.err(new teamsfx_api_1.SystemError(constants_2.SolutionError.InternelError, "projectSettings undefined", "Solution"));
154
113
  // ensure that global namespace is present
155
- if (!ctx.envInfo.profile.has(constants_1.GLOBAL_CONFIG)) {
156
- ctx.envInfo.profile.set(constants_1.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
114
+ if (!ctx.envInfo.profile.has(constants_2.GLOBAL_CONFIG)) {
115
+ ctx.envInfo.profile.set(constants_2.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
157
116
  }
158
117
  // Only non-SPFx project will ask this question.
159
118
  const lang = ctx.answers[question_1.AzureSolutionQuestionNames.ProgrammingLanguage];
160
119
  if (lang) {
161
120
  ctx.projectSettings.programmingLanguage = lang;
162
121
  }
163
- const settingsRes = this.fillInSolutionSettings(ctx);
122
+ const solutionSettings = ctx.projectSettings.solutionSettings;
123
+ const settingsRes = utils_1.fillInSolutionSettings(solutionSettings, ctx.answers);
164
124
  if (settingsRes.isErr()) {
165
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.Create, settingsRes.error, ctx.telemetryReporter));
125
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.Create, settingsRes.error, ctx.telemetryReporter));
166
126
  }
167
- const solutionSettings = settingsRes.value;
168
127
  //Reload plugins according to user answers
169
128
  await this.reloadPlugins(solutionSettings);
170
129
  if (this.isAzureProject(ctx)) {
171
- await fs.writeJSON(`${ctx.root}/permissions.json`, constants_1.DEFAULT_PERMISSION_REQUEST, { spaces: 4 });
172
- (_b = ctx.telemetryReporter) === null || _b === void 0 ? void 0 : _b.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.Create, {
173
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
174
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
175
- [constants_1.SolutionTelemetryProperty.Resources]: solutionSettings.azureResources.join(";"),
176
- [constants_1.SolutionTelemetryProperty.Capabilities]: solutionSettings.capabilities.join(";"),
130
+ await fs.writeJSON(`${ctx.root}/permissions.json`, constants_2.DEFAULT_PERMISSION_REQUEST, { spaces: 4 });
131
+ (_b = ctx.telemetryReporter) === null || _b === void 0 ? void 0 : _b.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.Create, {
132
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
133
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
134
+ [constants_2.SolutionTelemetryProperty.Resources]: solutionSettings.azureResources.join(";"),
135
+ [constants_2.SolutionTelemetryProperty.Capabilities]: solutionSettings.capabilities.join(";"),
136
+ [constants_2.SolutionTelemetryProperty.ProgrammingLanguage]: (_d = (_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.programmingLanguage) !== null && _d !== void 0 ? _d : "",
177
137
  });
178
138
  }
179
- return teamsfx_api_1.ok(constants_1.Void);
139
+ return teamsfx_api_1.ok(constants_2.Void);
180
140
  }
181
141
  // Migrate
182
142
  async migrate(ctx) {
183
143
  var _a, _b, _c, _d, _e;
184
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.MigrateStart, {
185
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
144
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.MigrateStart, {
145
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
186
146
  });
187
147
  // ensure that global namespace is present
188
- if (!ctx.envInfo.profile.has(constants_1.GLOBAL_CONFIG)) {
189
- ctx.envInfo.profile.set(constants_1.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
148
+ if (!ctx.envInfo.profile.has(constants_2.GLOBAL_CONFIG)) {
149
+ ctx.envInfo.profile.set(constants_2.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
190
150
  }
191
151
  const settingsRes = await this.fillInV1SolutionSettings(ctx);
192
152
  if (settingsRes.isErr()) {
193
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.Migrate, settingsRes.error, ctx.telemetryReporter));
153
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.Migrate, settingsRes.error, ctx.telemetryReporter));
194
154
  }
195
155
  const solutionSettings = settingsRes.value;
196
156
  const selectedPlugins = await this.reloadPlugins(solutionSettings);
197
157
  const results = await Promise.all(selectedPlugins.map((migratePlugin) => {
198
158
  return this.executeUserTask({
199
- namespace: `${constants_1.PluginNames.SOLUTION}/${migratePlugin.name}`,
159
+ namespace: `${constants_2.PluginNames.SOLUTION}/${migratePlugin.name}`,
200
160
  method: "migrateV1Project",
201
161
  params: {},
202
162
  }, ctx);
@@ -212,12 +172,12 @@ let TeamsAppSolution = class TeamsAppSolution {
212
172
  const azureResources = ((_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.solutionSettings)
213
173
  .azureResources;
214
174
  await scaffolding_1.scaffoldReadmeAndLocalSettings(capabilities, azureResources, ctx.root, true);
215
- (_d = ctx.telemetryReporter) === null || _d === void 0 ? void 0 : _d.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.Migrate, {
216
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
217
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
175
+ (_d = ctx.telemetryReporter) === null || _d === void 0 ? void 0 : _d.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.Migrate, {
176
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
177
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
218
178
  });
219
179
  (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("info", `Success: ${tools_1.getStrings().solution.MigrateSuccessNotice}`, false);
220
- return teamsfx_api_1.ok(constants_1.Void);
180
+ return teamsfx_api_1.ok(constants_2.Void);
221
181
  }
222
182
  reloadPlugins(solutionSettings) {
223
183
  const res = ResourcePluginContainer_1.getActivatedResourcePlugins(solutionSettings);
@@ -237,7 +197,7 @@ let TeamsAppSolution = class TeamsAppSolution {
237
197
  }
238
198
  async update(ctx) {
239
199
  var _a;
240
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
200
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
241
201
  if (v1Blocked.isErr()) {
242
202
  return v1Blocked;
243
203
  }
@@ -288,29 +248,29 @@ let TeamsAppSolution = class TeamsAppSolution {
288
248
  .azureResources;
289
249
  await scaffolding_1.scaffoldReadmeAndLocalSettings(capabilities, azureResources, ctx.root);
290
250
  }
291
- if (tools_1.isArmSupportEnabled() && generateResourceTemplate) {
251
+ if (tools_1.isArmSupportEnabled() && generateResourceTemplate && this.isAzureProject(ctx)) {
292
252
  return await arm_1.generateArmTemplate(ctx);
293
253
  }
294
254
  else {
295
255
  return res;
296
256
  }
297
257
  }
298
- async ensurePermissionRequest(ctx) {
299
- var _a, _b;
300
- if ((_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings) === null || _b === void 0 ? void 0 : _b.migrateFromV1) {
301
- return teamsfx_api_1.ok(undefined);
302
- }
303
- if (!this.isAzureProject(ctx)) {
304
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Cannot update permission for SPFx project"), "Solution", constants_1.SolutionError.CannotUpdatePermissionForSPFx));
305
- }
306
- if (ctx.permissionRequestProvider === undefined) {
307
- ctx.permissionRequestProvider = new permissionRequest_1.PermissionRequestFileProvider(ctx.root);
308
- }
309
- const result = await ctx.permissionRequestProvider.checkPermissionRequest();
310
- if (result.isErr()) {
311
- return result;
258
+ async createEnv(ctx) {
259
+ if (tools_1.isArmSupportEnabled() &&
260
+ utils_1.isAzureProject(ctx.projectSettings.solutionSettings)) {
261
+ try {
262
+ if (ctx.answers.copy === true) {
263
+ await arm_1.copyParameterJson(ctx, ctx.answers.targetEnvName, ctx.answers.sourceEnvName);
264
+ }
265
+ else {
266
+ await arm_1.getParameterJson(ctx);
267
+ }
268
+ }
269
+ catch (e) {
270
+ return teamsfx_api_1.err(core_1.CopyFileError(e));
271
+ }
312
272
  }
313
- return teamsfx_api_1.ok(undefined);
273
+ return teamsfx_api_1.ok(constants_2.Void);
314
274
  }
315
275
  /**
316
276
  * Checks whether solution's state is idle
@@ -318,24 +278,18 @@ let TeamsAppSolution = class TeamsAppSolution {
318
278
  checkWhetherSolutionIsIdle() {
319
279
  switch (this.runningState) {
320
280
  case SolutionRunningState.Idle:
321
- return teamsfx_api_1.ok(constants_1.Void);
281
+ return teamsfx_api_1.ok(constants_2.Void);
322
282
  case SolutionRunningState.ProvisionInProgress:
323
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Provision in progress. Please wait for its completion."), "Solution", constants_1.SolutionError.ProvisionInProgress));
283
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Provision in progress. Please wait for its completion."), "Solution", constants_2.SolutionError.ProvisionInProgress));
324
284
  case SolutionRunningState.DeployInProgress:
325
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Deployment in progress. Please wait for its completion."), "Solution", constants_1.SolutionError.DeploymentInProgress));
285
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Deployment in progress. Please wait for its completion."), "Solution", constants_2.SolutionError.DeploymentInProgress));
326
286
  case SolutionRunningState.PublishInProgress:
327
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Publish in progress. Please wait for its completion."), "Solution", constants_1.SolutionError.PublishInProgress));
287
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Publish in progress. Please wait for its completion."), "Solution", constants_2.SolutionError.PublishInProgress));
328
288
  }
329
289
  }
330
290
  checkWetherProvisionSucceeded(solutionConfig) {
331
291
  var _a;
332
- return !!((_a = solutionConfig.get(constants_1.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.getBoolean(constants_1.SOLUTION_PROVISION_SUCCEEDED));
333
- }
334
- blockV1Project(solutionSettings) {
335
- if (solutionSettings === null || solutionSettings === void 0 ? void 0 : solutionSettings.migrateFromV1) {
336
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Command is not supported in Teams Toolkit V1 Project"), "Solution", constants_1.SolutionError.V1ProjectNotSupported));
337
- }
338
- return teamsfx_api_1.ok(null);
292
+ return !!((_a = solutionConfig.get(constants_2.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.getBoolean(constants_2.SOLUTION_PROVISION_SUCCEEDED));
339
293
  }
340
294
  /**
341
295
  * Provision resources. It can only run in a non-SPFx project when solution's running state is Idle.
@@ -343,8 +297,8 @@ let TeamsAppSolution = class TeamsAppSolution {
343
297
  *
344
298
  */
345
299
  async provision(ctx) {
346
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
347
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
300
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
301
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
348
302
  if (v1Blocked.isErr()) {
349
303
  return v1Blocked;
350
304
  }
@@ -359,23 +313,26 @@ let TeamsAppSolution = class TeamsAppSolution {
359
313
  await ((_b = ctx.appStudioToken) === null || _b === void 0 ? void 0 : _b.getAccessToken());
360
314
  this.runningState = SolutionRunningState.ProvisionInProgress;
361
315
  if (this.isAzureProject(ctx)) {
362
- const result = await this.ensurePermissionRequest(ctx);
316
+ if (ctx.permissionRequestProvider === undefined) {
317
+ ctx.permissionRequestProvider = new permissionRequest_1.PermissionRequestFileProvider(ctx.root);
318
+ }
319
+ const result = await utils_1.ensurePermissionRequest((_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.solutionSettings, ctx.permissionRequestProvider);
363
320
  if (result.isErr()) {
364
321
  return result;
365
322
  }
366
323
  }
367
324
  const provisionResult = await this.doProvision(ctx);
368
325
  if (provisionResult.isOk()) {
369
- const msg = util.format(`Success: ${tools_1.getStrings().solution.ProvisionSuccessNotice}`, (_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.appName);
370
- (_d = ctx.logProvider) === null || _d === void 0 ? void 0 : _d.info(msg);
371
- (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("info", msg, false);
372
- (_f = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _f === void 0 ? void 0 : _f.set(constants_1.SOLUTION_PROVISION_SUCCEEDED, true);
326
+ const msg = util.format(`Success: ${tools_1.getStrings().solution.ProvisionSuccessNotice}`, (_d = ctx.projectSettings) === null || _d === void 0 ? void 0 : _d.appName);
327
+ (_e = ctx.logProvider) === null || _e === void 0 ? void 0 : _e.info(msg);
328
+ (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", msg, false);
329
+ (_g = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _g === void 0 ? void 0 : _g.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, true);
373
330
  }
374
331
  else {
375
332
  if (!tools_1.isUserCancelError(provisionResult.error)) {
376
- const msg = util.format(tools_1.getStrings().solution.ProvisionFailNotice, (_g = ctx.projectSettings) === null || _g === void 0 ? void 0 : _g.appName);
377
- (_h = ctx.logProvider) === null || _h === void 0 ? void 0 : _h.error(msg);
378
- (_j = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _j === void 0 ? void 0 : _j.set(constants_1.SOLUTION_PROVISION_SUCCEEDED, false);
333
+ const msg = util.format(tools_1.getStrings().solution.ProvisionFailNotice, (_h = ctx.projectSettings) === null || _h === void 0 ? void 0 : _h.appName);
334
+ (_j = ctx.logProvider) === null || _j === void 0 ? void 0 : _j.error(msg);
335
+ (_k = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _k === void 0 ? void 0 : _k.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, false);
379
336
  }
380
337
  }
381
338
  return provisionResult;
@@ -388,7 +345,7 @@ let TeamsAppSolution = class TeamsAppSolution {
388
345
  * provision
389
346
  */
390
347
  async doProvision(ctx) {
391
- var _a, _b, _c, _d, _e, _f, _g;
348
+ var _a;
392
349
  const maybeSelectedPlugins = this.getSelectedPlugins(ctx);
393
350
  if (maybeSelectedPlugins.isErr()) {
394
351
  return maybeSelectedPlugins;
@@ -401,34 +358,9 @@ let TeamsAppSolution = class TeamsAppSolution {
401
358
  if (res.isErr()) {
402
359
  return res;
403
360
  }
404
- const azureToken = await ((_b = ctx.azureAccountProvider) === null || _b === void 0 ? void 0 : _b.getAccountCredentialAsync());
405
- // Only Azure project requires this confirm dialog
406
- const username = azureToken.username ? azureToken.username : "";
407
- const subscriptionInfo = await ((_c = ctx.azureAccountProvider) === null || _c === void 0 ? void 0 : _c.getSelectedSubscription());
408
- const subscriptionId = subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.subscriptionId;
409
- const subscriptionName = subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.subscriptionName;
410
- const msg = util.format(tools_1.getStrings().solution.ProvisionConfirmNotice, username, subscriptionName ? subscriptionName : subscriptionId);
411
- let confirmRes = undefined;
412
- if (tools_1.isMultiEnvEnabled()) {
413
- const msgNew = util.format(tools_1.getStrings().solution.ProvisionConfirmEnvNotice, ctx.projectSettings.activeEnvironment, username, subscriptionName ? subscriptionName : subscriptionId);
414
- confirmRes = await ((_d = ctx.ui) === null || _d === void 0 ? void 0 : _d.showMessage("warn", msgNew, true, "Provision", "Switch environment", "Pricing calculator"));
415
- }
416
- else {
417
- confirmRes = await ((_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("warn", msg, true, "Provision", "Pricing calculator"));
418
- }
419
- const confirm = (confirmRes === null || confirmRes === void 0 ? void 0 : confirmRes.isOk()) ? confirmRes.value : undefined;
420
- if (confirm !== "Provision") {
421
- if (confirm === "Pricing calculator") {
422
- (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.openUrl("https://azure.microsoft.com/en-us/pricing/calculator/");
423
- }
424
- else if (confirm === "Switch environment") {
425
- const envName = await envInfoLoader_1.askTargetEnvironment(ctx, ctx.answers);
426
- if (envName) {
427
- ctx.projectSettings.activeEnvironment = envName;
428
- (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", `[${envName}] is activated.`, false);
429
- }
430
- }
431
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.CancelProvision), "Solution", tools_1.getStrings().solution.CancelProvision));
361
+ const consentResult = await provision_1.askForProvisionConsent(ctx);
362
+ if (consentResult.isErr()) {
363
+ return consentResult;
432
364
  }
433
365
  }
434
366
  const pluginsWithCtx = this.getPluginAndContextArray(ctx, selectedPlugins);
@@ -446,21 +378,23 @@ let TeamsAppSolution = class TeamsAppSolution {
446
378
  });
447
379
  return executor_1.executeLifecycles(preProvisionWithCtx, provisionWithCtx, postProvisionWithCtx, async () => {
448
380
  var _a;
449
- (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.ProvisionStartNotice, constants_2.PluginDisplayName.Solution));
381
+ (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.ProvisionStartNotice, constants_1.PluginDisplayName.Solution));
450
382
  return teamsfx_api_1.ok(undefined);
451
383
  }, async (provisionResults) => {
452
384
  var _a;
453
- if (provisionWithCtx.length === (provisionResults === null || provisionResults === void 0 ? void 0 : provisionResults.length)) {
454
- provisionWithCtx.map(function (plugin, index) {
455
- var _a;
456
- if (plugin[2] === constants_1.PluginNames.APPST) {
457
- const teamsAppResult = provisionResults[index];
458
- if (teamsAppResult.isOk()) {
459
- (_a = ctx.envInfo.profile
460
- .get(constants_1.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.set(constants_1.REMOTE_TEAMS_APP_ID, teamsAppResult.value);
385
+ if (!tools_1.isMultiEnvEnabled()) {
386
+ if (provisionWithCtx.length === (provisionResults === null || provisionResults === void 0 ? void 0 : provisionResults.length)) {
387
+ provisionWithCtx.map(function (plugin, index) {
388
+ var _a;
389
+ if (plugin[2] === constants_2.PluginNames.APPST) {
390
+ const teamsAppResult = provisionResults[index];
391
+ if (teamsAppResult.isOk()) {
392
+ (_a = ctx.envInfo.profile
393
+ .get(constants_2.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.set(constants_2.REMOTE_TEAMS_APP_ID, teamsAppResult.value);
394
+ }
461
395
  }
462
- }
463
- });
396
+ });
397
+ }
464
398
  }
465
399
  if (provisionResults) {
466
400
  for (const result of provisionResults) {
@@ -469,7 +403,7 @@ let TeamsAppSolution = class TeamsAppSolution {
469
403
  }
470
404
  }
471
405
  }
472
- (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.ProvisionFinishNotice, constants_2.PluginDisplayName.Solution));
406
+ (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.ProvisionFinishNotice, constants_1.PluginDisplayName.Solution));
473
407
  if (tools_1.isArmSupportEnabled() && this.isAzureProject(ctx)) {
474
408
  const armDeploymentResult = await arm_1.deployArmTemplates(ctx);
475
409
  if (armDeploymentResult.isErr()) {
@@ -479,7 +413,7 @@ let TeamsAppSolution = class TeamsAppSolution {
479
413
  const aadPlugin = this.AadPlugin;
480
414
  if (selectedPlugins.some((plugin) => plugin.name === aadPlugin.name)) {
481
415
  return await aadPlugin.executeUserTask({
482
- namespace: `${constants_1.PluginNames.SOLUTION}/${constants_1.PluginNames.AAD}`,
416
+ namespace: `${constants_2.PluginNames.SOLUTION}/${constants_2.PluginNames.AAD}`,
483
417
  method: "setApplicationInContext",
484
418
  params: { isLocal: false },
485
419
  }, util_1.getPluginContext(ctx, aadPlugin.name));
@@ -487,21 +421,21 @@ let TeamsAppSolution = class TeamsAppSolution {
487
421
  return teamsfx_api_1.ok(undefined);
488
422
  }, async () => {
489
423
  var _a, _b;
490
- (_a = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.delete(constants_1.ARM_TEMPLATE_OUTPUT);
491
- (_b = ctx.logProvider) === null || _b === void 0 ? void 0 : _b.info(util.format(tools_1.getStrings().solution.ConfigurationFinishNotice, constants_2.PluginDisplayName.Solution));
424
+ (_a = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _a === void 0 ? void 0 : _a.delete(constants_2.ARM_TEMPLATE_OUTPUT);
425
+ (_b = ctx.logProvider) === null || _b === void 0 ? void 0 : _b.info(util.format(tools_1.getStrings().solution.ConfigurationFinishNotice, constants_1.PluginDisplayName.Solution));
492
426
  return teamsfx_api_1.ok(undefined);
493
427
  });
494
428
  }
495
429
  async deploy(ctx) {
496
430
  var _a, _b, _c, _d, _e, _f, _g, _h;
497
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
431
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
498
432
  if (v1Blocked.isErr()) {
499
433
  return v1Blocked;
500
434
  }
501
435
  const isAzureProject = this.isAzureProject(ctx);
502
436
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
503
437
  if (isAzureProject && !provisioned) {
504
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(util.format(tools_1.getStrings().solution.NotProvisionedNotice, (_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.appName)), "Solution", constants_1.SolutionError.CannotDeployBeforeProvision));
438
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(util.format(tools_1.getStrings().solution.NotProvisionedNotice, (_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.appName)), "Solution", constants_2.SolutionError.CannotDeployBeforeProvision));
505
439
  }
506
440
  try {
507
441
  if (this.isAzureProject(ctx)) {
@@ -540,7 +474,7 @@ let TeamsAppSolution = class TeamsAppSolution {
540
474
  }
541
475
  const optionsToDeploy = ctx.answers[question_1.AzureSolutionQuestionNames.PluginSelectionDeploy];
542
476
  if (optionsToDeploy === undefined || optionsToDeploy.length === 0) {
543
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`No plugin selected`), "Solution", constants_1.SolutionError.NoResourcePluginSelected));
477
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`No plugin selected`), "Solution", constants_2.SolutionError.NoResourcePluginSelected));
544
478
  }
545
479
  const pluginMap = ResourcePluginContainer_1.getAllResourcePluginMap();
546
480
  const pluginsToDeploy = [];
@@ -550,7 +484,7 @@ let TeamsAppSolution = class TeamsAppSolution {
550
484
  pluginsToDeploy.push(filtered);
551
485
  }
552
486
  }
553
- (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.SelectedPluginsToDeployNotice, constants_2.PluginDisplayName.Solution, JSON.stringify(pluginsToDeploy.map((p) => p.name))));
487
+ (_a = ctx.logProvider) === null || _a === void 0 ? void 0 : _a.info(util.format(tools_1.getStrings().solution.SelectedPluginsToDeployNotice, constants_1.PluginDisplayName.Solution, JSON.stringify(pluginsToDeploy.map((p) => p.name))));
554
488
  if (this.isAzureProject(ctx)) {
555
489
  //make sure sub is selected
556
490
  await ((_b = ctx.azureAccountProvider) === null || _b === void 0 ? void 0 : _b.getSelectedSubscription(true));
@@ -568,12 +502,12 @@ let TeamsAppSolution = class TeamsAppSolution {
568
502
  var _a;
569
503
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.postDeploy) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
570
504
  });
571
- (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(util.format(tools_1.getStrings().solution.DeployStartNotice, constants_2.PluginDisplayName.Solution));
505
+ (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(util.format(tools_1.getStrings().solution.DeployStartNotice, constants_1.PluginDisplayName.Solution));
572
506
  return executor_1.executeLifecycles(preDeployWithCtx, deployWithCtx, postDeployWithCtx);
573
507
  }
574
508
  async publish(ctx) {
575
509
  var _a, _b, _c, _d, _e;
576
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
510
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
577
511
  if (v1Blocked.isErr()) {
578
512
  return v1Blocked;
579
513
  }
@@ -583,7 +517,7 @@ let TeamsAppSolution = class TeamsAppSolution {
583
517
  const isAzureProject = this.isAzureProject(ctx);
584
518
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
585
519
  if (!provisioned) {
586
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(util.format(tools_1.getStrings().solution.NotProvisionedNotice, (_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.appName)), "Solution", constants_1.SolutionError.CannotPublishBeforeProvision));
520
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(util.format(tools_1.getStrings().solution.NotProvisionedNotice, (_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.appName)), "Solution", constants_2.SolutionError.CannotPublishBeforeProvision));
587
521
  }
588
522
  try {
589
523
  this.runningState = SolutionRunningState.PublishInProgress;
@@ -594,7 +528,7 @@ let TeamsAppSolution = class TeamsAppSolution {
594
528
  var _a;
595
529
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.publish) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
596
530
  });
597
- (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(util.format(tools_1.getStrings().solution.PublishStartNotice, constants_2.PluginDisplayName.Solution));
531
+ (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(util.format(tools_1.getStrings().solution.PublishStartNotice, constants_1.PluginDisplayName.Solution));
598
532
  const results = await executor_1.executeConcurrently("", publishWithCtx);
599
533
  for (const result of results) {
600
534
  if (result.isErr()) {
@@ -728,9 +662,9 @@ let TeamsAppSolution = class TeamsAppSolution {
728
662
  }
729
663
  else if (stage === teamsfx_api_1.Stage.provision) {
730
664
  if (isDynamicQuestion) {
731
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
665
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
732
666
  if (v1Blocked.isErr()) {
733
- return v1Blocked;
667
+ return teamsfx_api_1.err(v1Blocked.error);
734
668
  }
735
669
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
736
670
  if (provisioned)
@@ -765,21 +699,21 @@ let TeamsAppSolution = class TeamsAppSolution {
765
699
  }
766
700
  else if (stage === teamsfx_api_1.Stage.deploy) {
767
701
  if (isDynamicQuestion) {
768
- const v1Blocked = this.blockV1Project((_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.solutionSettings);
702
+ const v1Blocked = utils_1.blockV1Project((_b = ctx.projectSettings) === null || _b === void 0 ? void 0 : _b.solutionSettings);
769
703
  if (v1Blocked.isErr()) {
770
- return v1Blocked;
704
+ return teamsfx_api_1.err(v1Blocked.error);
771
705
  }
772
706
  const isAzureProject = this.isAzureProject(ctx);
773
707
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
774
708
  if (isAzureProject && !provisioned) {
775
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToDeployBeforeProvision), "Solution", constants_1.SolutionError.CannotDeployBeforeProvision));
709
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToDeployBeforeProvision), "Solution", constants_2.SolutionError.CannotDeployBeforeProvision));
776
710
  }
777
711
  }
778
712
  let pluginsToDeploy;
779
713
  if (isDynamicQuestion) {
780
714
  const res = this.getSelectedPlugins(ctx);
781
715
  if (res.isErr()) {
782
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("No resource to deploy"), "Solution", constants_1.SolutionError.NoResourceToDeploy));
716
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("No resource to deploy"), "Solution", constants_2.SolutionError.NoResourceToDeploy));
783
717
  }
784
718
  pluginsToDeploy = res.value.filter((plugin) => !!plugin.deploy);
785
719
  }
@@ -788,7 +722,7 @@ let TeamsAppSolution = class TeamsAppSolution {
788
722
  pluginsToDeploy = allPlugins.filter((plugin) => !!plugin.deploy);
789
723
  }
790
724
  if (pluginsToDeploy.length === 0) {
791
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("No resource to deploy"), "Solution", constants_1.SolutionError.NoResourceToDeploy));
725
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("No resource to deploy"), "Solution", constants_2.SolutionError.NoResourceToDeploy));
792
726
  }
793
727
  const pluginPrefix = "fx-resource-";
794
728
  const options = pluginsToDeploy.map((plugin) => {
@@ -821,22 +755,22 @@ let TeamsAppSolution = class TeamsAppSolution {
821
755
  }
822
756
  else if (stage === teamsfx_api_1.Stage.publish) {
823
757
  if (isDynamicQuestion) {
824
- const v1Blocked = this.blockV1Project((_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.solutionSettings);
758
+ const v1Blocked = utils_1.blockV1Project((_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.solutionSettings);
825
759
  if (v1Blocked.isErr()) {
826
- return v1Blocked;
760
+ return teamsfx_api_1.err(v1Blocked.error);
827
761
  }
828
762
  const isAzureProject = this.isAzureProject(ctx);
829
763
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
830
764
  if (isAzureProject && !provisioned) {
831
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToPublishBeforeProvision), "Solution", constants_1.SolutionError.CannotPublishBeforeProvision));
765
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToPublishBeforeProvision), "Solution", constants_2.SolutionError.CannotPublishBeforeProvision));
832
766
  }
833
767
  if (!provisioned && this.spfxSelected(ctx)) {
834
768
  if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.VSCode) {
835
769
  (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("error", tools_1.getStrings().solution.SPFxAskProvisionBeforePublish, false);
836
- throw constants_1.CancelError;
770
+ throw constants_2.CancelError;
837
771
  }
838
772
  else {
839
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.SPFxAskProvisionBeforePublish), "Solution", constants_1.SolutionError.CannotPublishBeforeProvision));
773
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.SPFxAskProvisionBeforePublish), "Solution", constants_2.SolutionError.CannotPublishBeforeProvision));
840
774
  }
841
775
  }
842
776
  }
@@ -854,95 +788,143 @@ let TeamsAppSolution = class TeamsAppSolution {
854
788
  }
855
789
  }
856
790
  }
791
+ else if (stage === teamsfx_api_1.Stage.grantPermission) {
792
+ node.addChild(new teamsfx_api_1.QTreeNode(question_1.GetUserEmailQuestion));
793
+ }
857
794
  return teamsfx_api_1.ok(node);
858
795
  }
859
796
  async localDebug(ctx) {
860
- const result = await this.ensurePermissionRequest(ctx);
861
- if (result.isErr()) {
862
- return result;
797
+ var _a;
798
+ try {
799
+ if (!this.spfxSelected(ctx)) {
800
+ if (ctx.permissionRequestProvider === undefined) {
801
+ ctx.permissionRequestProvider = new permissionRequest_1.PermissionRequestFileProvider(ctx.root);
802
+ }
803
+ const result = await utils_1.ensurePermissionRequest((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings, ctx.permissionRequestProvider);
804
+ if (result.isErr()) {
805
+ return result;
806
+ }
807
+ }
808
+ }
809
+ catch (e) {
810
+ if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
811
+ return teamsfx_api_1.err(e);
812
+ }
813
+ return teamsfx_api_1.err(new teamsfx_api_1.SystemError("UnknownError", "check point 1 - " + JSON.stringify(e), "Solution"));
863
814
  }
864
815
  return await this.doLocalDebug(ctx);
865
816
  }
866
817
  async doLocalDebug(ctx) {
867
818
  var _a, _b;
868
- const maybeSelectedPlugins = this.getSelectedPlugins(ctx);
869
- if (maybeSelectedPlugins.isErr()) {
870
- return maybeSelectedPlugins;
871
- }
872
- const selectedPlugins = maybeSelectedPlugins.value;
873
- // Just to trigger M365 login before the concurrent execution of localDebug.
874
- // Because concurrent exectution of localDebug may getAccessToken() concurrently, which
875
- // causes 2 M365 logins before the token caching in common lib takes effect.
876
- await ((_a = ctx.appStudioToken) === null || _a === void 0 ? void 0 : _a.getAccessToken());
877
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, selectedPlugins);
878
- const localDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
879
- var _a;
880
- return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.localDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
881
- });
882
- const postLocalDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
883
- var _a;
884
- return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.postLocalDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
885
- });
886
- const localDebugResults = await executor_1.executeConcurrently("", localDebugWithCtx);
887
- for (const localDebugResult of localDebugResults) {
888
- if (localDebugResult.isErr()) {
889
- return localDebugResult;
819
+ let checkPoint = 1;
820
+ try {
821
+ //check point 2
822
+ const maybeSelectedPlugins = this.getSelectedPlugins(ctx);
823
+ if (maybeSelectedPlugins.isErr()) {
824
+ return maybeSelectedPlugins;
825
+ }
826
+ const selectedPlugins = maybeSelectedPlugins.value;
827
+ checkPoint = 2;
828
+ //check point 3
829
+ // Just to trigger M365 login before the concurrent execution of localDebug.
830
+ // Because concurrent exectution of localDebug may getAccessToken() concurrently, which
831
+ // causes 2 M365 logins before the token caching in common lib takes effect.
832
+ await ((_a = ctx.appStudioToken) === null || _a === void 0 ? void 0 : _a.getAccessToken());
833
+ checkPoint = 3;
834
+ //check point 4
835
+ const pluginsWithCtx = this.getPluginAndContextArray(ctx, selectedPlugins);
836
+ const localDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
837
+ var _a;
838
+ return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.localDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
839
+ });
840
+ const postLocalDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
841
+ var _a;
842
+ return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.postLocalDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
843
+ });
844
+ const localDebugResults = await executor_1.executeConcurrently("", localDebugWithCtx);
845
+ for (const localDebugResult of localDebugResults) {
846
+ if (localDebugResult.isErr()) {
847
+ return localDebugResult;
848
+ }
890
849
  }
891
- }
892
- const aadPlugin = this.AadPlugin;
893
- if (selectedPlugins.some((plugin) => plugin.name === aadPlugin.name)) {
894
- const result = await aadPlugin.executeUserTask({
895
- namespace: `${constants_1.PluginNames.SOLUTION}/${constants_1.PluginNames.AAD}`,
896
- method: "setApplicationInContext",
897
- params: { isLocal: true },
898
- }, util_1.getPluginContext(ctx, aadPlugin.name));
850
+ checkPoint = 4;
851
+ //check point 5
852
+ if (!this.spfxSelected(ctx)) {
853
+ const aadPlugin = this.AadPlugin;
854
+ if (selectedPlugins.some((plugin) => plugin.name === aadPlugin.name)) {
855
+ const result = await aadPlugin.executeUserTask({
856
+ namespace: `${constants_2.PluginNames.SOLUTION}/${constants_2.PluginNames.AAD}`,
857
+ method: "setApplicationInContext",
858
+ params: { isLocal: true },
859
+ }, util_1.getPluginContext(ctx, aadPlugin.name));
860
+ if (result.isErr()) {
861
+ return result;
862
+ }
863
+ }
864
+ }
865
+ checkPoint = 5;
866
+ // check point 6
867
+ // set local debug Teams app tenant id in context.
868
+ const result = this.loadTeamsAppTenantId(ctx, true, await ((_b = ctx.appStudioToken) === null || _b === void 0 ? void 0 : _b.getJsonObject()));
899
869
  if (result.isErr()) {
900
870
  return result;
901
871
  }
902
- }
903
- // set local debug Teams app tenant id in context.
904
- const result = this.loadTeamsAppTenantId(ctx, true, await ((_b = ctx.appStudioToken) === null || _b === void 0 ? void 0 : _b.getJsonObject()));
905
- if (result.isErr()) {
906
- return result;
907
- }
908
- const postLocalDebugResults = await executor_1.executeConcurrently("post", postLocalDebugWithCtx);
909
- const combinedPostLocalDebugResults = teamsfx_api_1.combine(postLocalDebugResults);
910
- if (combinedPostLocalDebugResults.isErr()) {
911
- return combinedPostLocalDebugResults;
912
- }
913
- // set local debug Teams app id in context.
914
- if (postLocalDebugWithCtx.length === combinedPostLocalDebugResults.value.length) {
915
- postLocalDebugWithCtx.map(function (plugin, index) {
916
- var _a, _b;
917
- if (plugin[2] === constants_1.PluginNames.APPST) {
918
- if (tools_1.isMultiEnvEnabled()) {
919
- (_a = ctx.localSettings) === null || _a === void 0 ? void 0 : _a.teamsApp.set(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TeamsAppId, combinedPostLocalDebugResults.value[index]);
920
- }
921
- else {
922
- (_b = ctx.envInfo.profile
923
- .get(constants_1.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_1.LOCAL_DEBUG_TEAMS_APP_ID, combinedPostLocalDebugResults.value[index]);
872
+ checkPoint = 6;
873
+ //check point 7
874
+ const postLocalDebugResults = await executor_1.executeConcurrently("post", postLocalDebugWithCtx);
875
+ const combinedPostLocalDebugResults = teamsfx_api_1.combine(postLocalDebugResults);
876
+ if (combinedPostLocalDebugResults.isErr()) {
877
+ return combinedPostLocalDebugResults;
878
+ }
879
+ checkPoint = 7;
880
+ //check point 8
881
+ // set local debug Teams app id in context.
882
+ if (postLocalDebugWithCtx.length === combinedPostLocalDebugResults.value.length) {
883
+ postLocalDebugWithCtx.map(function (plugin, index) {
884
+ var _a, _b;
885
+ if (plugin[2] === constants_2.PluginNames.APPST) {
886
+ if (tools_1.isMultiEnvEnabled()) {
887
+ (_a = ctx.localSettings) === null || _a === void 0 ? void 0 : _a.teamsApp.set(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TeamsAppId, combinedPostLocalDebugResults.value[index]);
888
+ }
889
+ else {
890
+ (_b = ctx.envInfo.profile
891
+ .get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_2.LOCAL_DEBUG_TEAMS_APP_ID, combinedPostLocalDebugResults.value[index]);
892
+ }
924
893
  }
925
- }
926
- });
894
+ });
895
+ }
896
+ checkPoint = 8;
897
+ return teamsfx_api_1.ok(constants_2.Void);
898
+ }
899
+ catch (e) {
900
+ if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
901
+ return teamsfx_api_1.err(e);
902
+ }
903
+ return teamsfx_api_1.err(new teamsfx_api_1.SystemError("UnknownError", `check point ${checkPoint} - ${JSON.stringify(e)}`, "Solution"));
927
904
  }
928
- return teamsfx_api_1.ok(constants_1.Void);
929
905
  }
930
906
  async grantPermission(ctx) {
931
907
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
932
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.GrantPermissionStart, {
933
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
908
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.GrantPermissionStart, {
909
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
934
910
  });
911
+ const progressBar = (_b = ctx.ui) === null || _b === void 0 ? void 0 : _b.createProgressBar("Granting permission", 1);
935
912
  try {
936
913
  const result = await this.checkAndGetCurrentUserInfo(ctx);
937
914
  if (result.isErr()) {
938
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.GrantPermission, result.error, ctx.telemetryReporter));
915
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, result.error, ctx.telemetryReporter));
939
916
  }
940
917
  const email = ctx.answers["email"];
918
+ if (!email || email === result.value.userPrincipalName) {
919
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error("Collaborator's email cannot be null or same as current user"), "Solution", constants_2.SolutionError.EmailCannotBeEmptyOrSame), ctx.telemetryReporter));
920
+ }
941
921
  const userInfo = await this.getUserInfo(ctx, email);
942
922
  if (!userInfo) {
943
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error("Cannot find user in current tenant, please check whether your email address is correct"), "Solution", constants_1.SolutionError.CannotFindUserInCurrentTenant), ctx.telemetryReporter));
923
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error("Cannot find user in current tenant, please check whether your email address is correct"), "Solution", constants_2.SolutionError.CannotFindUserInCurrentTenant), ctx.telemetryReporter));
944
924
  }
945
- (_b = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_1.USER_INFO, JSON.stringify(userInfo));
925
+ progressBar === null || progressBar === void 0 ? void 0 : progressBar.start();
926
+ progressBar === null || progressBar === void 0 ? void 0 : progressBar.next(`Grant permission for user ${email}`);
927
+ (_c = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _c === void 0 ? void 0 : _c.set(constants_2.USER_INFO, JSON.stringify(userInfo));
946
928
  const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
947
929
  this.AadPlugin,
948
930
  this.AppStudioPlugin,
@@ -951,11 +933,21 @@ let TeamsAppSolution = class TeamsAppSolution {
951
933
  var _a;
952
934
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.grantPermission) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
953
935
  });
954
- if (((_c = ctx.answers) === null || _c === void 0 ? void 0 : _c.platform) === teamsfx_api_1.Platform.CLI) {
955
- const aadAppTenantId = (_e = (_d = ctx.envInfo.profile) === null || _d === void 0 ? void 0 : _d.get(constants_1.PluginNames.AAD)) === null || _e === void 0 ? void 0 : _e.get(constants_1.REMOTE_TENANT_ID);
956
- // Todo, when multi-environment is ready, we will update to current environment
957
- (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", `Starting permission grant for environment: default`, false);
958
- (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", `Tenant ID: ${aadAppTenantId}`, false);
936
+ if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.CLI) {
937
+ const aadAppTenantId = (_f = (_e = ctx.envInfo.profile) === null || _e === void 0 ? void 0 : _e.get(constants_2.PluginNames.AAD)) === null || _f === void 0 ? void 0 : _f.get(constants_2.REMOTE_TENANT_ID);
938
+ const message = [
939
+ { content: `Account to grant permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
940
+ { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
941
+ {
942
+ content: `Starting grant permission for environment: `,
943
+ color: teamsfx_api_1.Colors.BRIGHT_WHITE,
944
+ },
945
+ // Todo, when multi-environment is ready, we will update to current environment
946
+ { content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
947
+ { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
948
+ { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
949
+ ];
950
+ (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", message, false);
959
951
  }
960
952
  const results = await executor_1.executeConcurrently("", grantPermissionWithCtx);
961
953
  const permissions = [];
@@ -980,9 +972,16 @@ let TeamsAppSolution = class TeamsAppSolution {
980
972
  }
981
973
  if (((_h = ctx.answers) === null || _h === void 0 ? void 0 : _h.platform) === teamsfx_api_1.Platform.CLI) {
982
974
  for (const permission of permissions) {
983
- (_j = ctx.ui) === null || _j === void 0 ? void 0 : _j.showMessage("info", `${(_k = permission.roles) === null || _k === void 0 ? void 0 : _k.join(" ")} permission has been granted to ${permission.name}, ID: ${permission.resourceId}`, false);
975
+ const message = [
976
+ { content: `${(_j = permission.roles) === null || _j === void 0 ? void 0 : _j.join(",")} `, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
977
+ { content: "permission has been granted to ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
978
+ { content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
979
+ { content: ", Resource ID: ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
980
+ { content: `${permission.resourceId}`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
981
+ ];
982
+ (_k = ctx.ui) === null || _k === void 0 ? void 0 : _k.showMessage("info", message, false);
984
983
  }
985
- (_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("info", `Skip grant permission for Azure resources. You may want to handle that via Azure portal. `, false);
984
+ (_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("info", `\nSkip grant permission for Azure resources. You may want to handle that via Azure portal. `, false);
986
985
  if (errorMsg) {
987
986
  for (const fxError of errors) {
988
987
  (_m = ctx.ui) === null || _m === void 0 ? void 0 : _m.showMessage("error", errorMsg, false);
@@ -990,31 +989,32 @@ let TeamsAppSolution = class TeamsAppSolution {
990
989
  }
991
990
  }
992
991
  if (errorMsg) {
993
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_1.SolutionError.FailedToGrantPermission), ctx.telemetryReporter));
992
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_2.SolutionError.FailedToGrantPermission), ctx.telemetryReporter));
994
993
  }
995
- (_o = ctx.telemetryReporter) === null || _o === void 0 ? void 0 : _o.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.GrantPermission, {
996
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
997
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
994
+ (_o = ctx.telemetryReporter) === null || _o === void 0 ? void 0 : _o.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.GrantPermission, {
995
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
996
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
998
997
  });
999
998
  return teamsfx_api_1.ok(permissions);
1000
999
  }
1001
1000
  finally {
1002
- (_p = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _p === void 0 ? void 0 : _p.delete(constants_1.USER_INFO);
1001
+ await (progressBar === null || progressBar === void 0 ? void 0 : progressBar.end(true));
1002
+ (_p = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _p === void 0 ? void 0 : _p.delete(constants_2.USER_INFO);
1003
1003
  this.runningState = SolutionRunningState.Idle;
1004
1004
  }
1005
1005
  }
1006
1006
  async checkPermission(ctx) {
1007
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1008
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.CheckPermissionStart, {
1009
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1007
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1008
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CheckPermissionStart, {
1009
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1010
1010
  });
1011
1011
  try {
1012
1012
  const result = await this.checkAndGetCurrentUserInfo(ctx);
1013
1013
  if (result.isErr()) {
1014
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.CheckPermission, result.error, ctx.telemetryReporter));
1014
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, result.error, ctx.telemetryReporter));
1015
1015
  }
1016
1016
  const userInfo = result.value;
1017
- (_b = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_1.USER_INFO, JSON.stringify(userInfo));
1017
+ (_b = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_2.USER_INFO, JSON.stringify(userInfo));
1018
1018
  const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
1019
1019
  this.AadPlugin,
1020
1020
  this.AppStudioPlugin,
@@ -1024,11 +1024,20 @@ let TeamsAppSolution = class TeamsAppSolution {
1024
1024
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.checkPermission) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
1025
1025
  });
1026
1026
  if (((_c = ctx.answers) === null || _c === void 0 ? void 0 : _c.platform) === teamsfx_api_1.Platform.CLI) {
1027
- const aadAppTenantId = (_e = (_d = ctx.envInfo.profile) === null || _d === void 0 ? void 0 : _d.get(constants_1.PluginNames.AAD)) === null || _e === void 0 ? void 0 : _e.get(constants_1.REMOTE_TENANT_ID);
1028
- (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", `Account used to check: ${userInfo.userPrincipalName}`, false);
1029
- // Todo, when multi-environment is ready, we will update to current environment
1030
- (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", `Starting permission check for environment: default`, false);
1031
- (_h = ctx.ui) === null || _h === void 0 ? void 0 : _h.showMessage("info", `Tenant ID: ${aadAppTenantId}`, false);
1027
+ const aadAppTenantId = (_e = (_d = ctx.envInfo.profile) === null || _d === void 0 ? void 0 : _d.get(constants_2.PluginNames.AAD)) === null || _e === void 0 ? void 0 : _e.get(constants_2.REMOTE_TENANT_ID);
1028
+ const message = [
1029
+ { content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1030
+ { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1031
+ {
1032
+ content: `Starting check permission for environment: `,
1033
+ color: teamsfx_api_1.Colors.BRIGHT_WHITE,
1034
+ },
1035
+ // Todo, when multi-environment is ready, we will update to current environment
1036
+ { content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1037
+ { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1038
+ { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1039
+ ];
1040
+ (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", message, false);
1032
1041
  }
1033
1042
  const results = await executor_1.executeConcurrently("", checkPermissionWithCtx);
1034
1043
  const permissions = [];
@@ -1051,42 +1060,53 @@ let TeamsAppSolution = class TeamsAppSolution {
1051
1060
  errorMsg += fxError.error.message + "\n";
1052
1061
  }
1053
1062
  }
1054
- if (((_j = ctx.answers) === null || _j === void 0 ? void 0 : _j.platform) === teamsfx_api_1.Platform.CLI) {
1063
+ if (((_g = ctx.answers) === null || _g === void 0 ? void 0 : _g.platform) === teamsfx_api_1.Platform.CLI) {
1055
1064
  for (const permission of permissions) {
1056
- (_k = ctx.ui) === null || _k === void 0 ? void 0 : _k.showMessage("info", `Resource ID: ${permission.resourceId}, Resource Name: ${permission.name}, Permission: ${permission.roles}`, false);
1065
+ const message = [
1066
+ { content: `Resource ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1067
+ { content: (_h = permission.resourceId) !== null && _h !== void 0 ? _h : "undefined", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1068
+ { content: `, Resource Name: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1069
+ { content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1070
+ { content: `, Permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1071
+ {
1072
+ content: permission.roles ? permission.roles.toString() : "undefined" + "\n",
1073
+ color: teamsfx_api_1.Colors.BRIGHT_MAGENTA,
1074
+ },
1075
+ ];
1076
+ (_j = ctx.ui) === null || _j === void 0 ? void 0 : _j.showMessage("info", message, false);
1057
1077
  }
1058
1078
  }
1059
1079
  if (errorMsg) {
1060
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.CheckPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_1.SolutionError.FailedToCheckPermission), ctx.telemetryReporter));
1080
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_2.SolutionError.FailedToCheckPermission), ctx.telemetryReporter));
1061
1081
  }
1062
1082
  const aadPermission = permissions.find((permission) => permission.name === "Azure AD App");
1063
1083
  const teamsAppPermission = permissions.find((permission) => permission.name === "Teams App");
1064
- (_l = ctx.telemetryReporter) === null || _l === void 0 ? void 0 : _l.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.CheckPermission, {
1065
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1066
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1067
- [constants_1.SolutionTelemetryProperty.AadPermission]: (aadPermission === null || aadPermission === void 0 ? void 0 : aadPermission.roles)
1084
+ (_k = ctx.telemetryReporter) === null || _k === void 0 ? void 0 : _k.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CheckPermission, {
1085
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1086
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1087
+ [constants_2.SolutionTelemetryProperty.AadPermission]: (aadPermission === null || aadPermission === void 0 ? void 0 : aadPermission.roles)
1068
1088
  ? aadPermission.roles.join(";")
1069
1089
  : "undefined",
1070
- [constants_1.SolutionTelemetryProperty.TeamsAppPermission]: (teamsAppPermission === null || teamsAppPermission === void 0 ? void 0 : teamsAppPermission.roles)
1090
+ [constants_2.SolutionTelemetryProperty.TeamsAppPermission]: (teamsAppPermission === null || teamsAppPermission === void 0 ? void 0 : teamsAppPermission.roles)
1071
1091
  ? teamsAppPermission.roles.join(";")
1072
1092
  : "undefined",
1073
1093
  });
1074
1094
  return teamsfx_api_1.ok(permissions);
1075
1095
  }
1076
1096
  finally {
1077
- (_m = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _m === void 0 ? void 0 : _m.delete(constants_1.USER_INFO);
1097
+ (_l = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _l === void 0 ? void 0 : _l.delete(constants_2.USER_INFO);
1078
1098
  this.runningState = SolutionRunningState.Idle;
1079
1099
  }
1080
1100
  }
1081
1101
  async listCollaborator(ctx) {
1082
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1083
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.ListCollaboratorStart, {
1084
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1102
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1103
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaboratorStart, {
1104
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1085
1105
  });
1086
1106
  try {
1087
1107
  const result = await this.checkAndGetCurrentUserInfo(ctx);
1088
1108
  if (result.isErr()) {
1089
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.ListCollaborator, result.error, ctx.telemetryReporter));
1109
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, result.error, ctx.telemetryReporter));
1090
1110
  }
1091
1111
  const userInfo = result.value;
1092
1112
  const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
@@ -1098,11 +1118,20 @@ let TeamsAppSolution = class TeamsAppSolution {
1098
1118
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.listCollaborator) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
1099
1119
  });
1100
1120
  if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
1101
- const aadAppTenantId = (_d = (_c = ctx.envInfo.profile) === null || _c === void 0 ? void 0 : _c.get(constants_1.PluginNames.AAD)) === null || _d === void 0 ? void 0 : _d.get(constants_1.REMOTE_TENANT_ID);
1102
- (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("info", `Account used to check: ${userInfo.userPrincipalName}`, false);
1103
- // Todo, when multi-environment is ready, we will update to current environment
1104
- (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", `Starting list all collaborators for environment: default`, false);
1105
- (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", `Tenant ID: ${aadAppTenantId}`, false);
1121
+ const aadAppTenantId = (_d = (_c = ctx.envInfo.profile) === null || _c === void 0 ? void 0 : _c.get(constants_2.PluginNames.AAD)) === null || _d === void 0 ? void 0 : _d.get(constants_2.REMOTE_TENANT_ID);
1122
+ const message = [
1123
+ { content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1124
+ { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1125
+ {
1126
+ content: `Starting list all collaborators for environment: `,
1127
+ color: teamsfx_api_1.Colors.BRIGHT_WHITE,
1128
+ },
1129
+ // Todo, when multi-environment is ready, we will update to current environment
1130
+ { content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1131
+ { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1132
+ { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1133
+ ];
1134
+ (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("info", message, false);
1106
1135
  }
1107
1136
  const results = await executor_1.executeConcurrently("", listCollaboratorWithCtx);
1108
1137
  const errors = [];
@@ -1119,7 +1148,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1119
1148
  }
1120
1149
  }
1121
1150
  if (errorMsg) {
1122
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.ListCollaborator, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_1.SolutionError.FailedToListCollaborator), ctx.telemetryReporter));
1151
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, teamsfx_api_1.returnUserError(new Error(errorMsg), "Solution", constants_2.SolutionError.FailedToListCollaborator), ctx.telemetryReporter));
1123
1152
  }
1124
1153
  const teamsAppOwners = results[0].isErr() ? [] : results[0].value;
1125
1154
  const aadOwners = results[1].isErr() ? [] : results[1].value;
@@ -1128,28 +1157,38 @@ let TeamsAppSolution = class TeamsAppSolution {
1128
1157
  const aadOwner = aadOwners.find((owner) => owner.userObjectId === teamsAppOwner.userObjectId);
1129
1158
  collaborators.push({
1130
1159
  // Sometimes app studio will return null as userPrincipalName, thus using aad's instead.
1131
- userPrincipalName: (_j = (_h = teamsAppOwner.userPrincipalName) !== null && _h !== void 0 ? _h : aadOwner === null || aadOwner === void 0 ? void 0 : aadOwner.userPrincipalName) !== null && _j !== void 0 ? _j : teamsAppOwner.userObjectId,
1160
+ userPrincipalName: (_g = (_f = teamsAppOwner.userPrincipalName) !== null && _f !== void 0 ? _f : aadOwner === null || aadOwner === void 0 ? void 0 : aadOwner.userPrincipalName) !== null && _g !== void 0 ? _g : teamsAppOwner.userObjectId,
1132
1161
  userObjectId: teamsAppOwner.userObjectId,
1133
1162
  isAadOwner: aadOwner ? true : false,
1134
1163
  aadResourceId: aadOwner ? aadOwner.resourceId : undefined,
1135
1164
  teamsAppResourceId: teamsAppOwner.resourceId,
1136
1165
  });
1137
1166
  }
1138
- if (((_k = ctx.answers) === null || _k === void 0 ? void 0 : _k.platform) === teamsfx_api_1.Platform.CLI) {
1167
+ if (((_h = ctx.answers) === null || _h === void 0 ? void 0 : _h.platform) === teamsfx_api_1.Platform.CLI) {
1139
1168
  for (const collaborator of collaborators) {
1140
- (_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("info", `Account: ${collaborator.userPrincipalName}`, false);
1141
- (_m = ctx.ui) === null || _m === void 0 ? void 0 : _m.showMessage("info", `Resource ID: ${collaborator.teamsAppResourceId}, Resource Name: Teams App, Permission: Administrator`, false);
1169
+ const message = [
1170
+ { content: `Account: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1171
+ { content: collaborator.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1172
+ { content: `Resource ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1173
+ { content: collaborator.teamsAppResourceId, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1174
+ { content: `, Resource Name: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1175
+ { content: `Teams App`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1176
+ { content: `, Permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1177
+ { content: `Administrator`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1178
+ ];
1142
1179
  if (collaborator.aadResourceId) {
1143
- (_o = ctx.ui) === null || _o === void 0 ? void 0 : _o.showMessage("info", `Resource ID: ${collaborator.aadResourceId}, Resource Name: AAD App, Permission: Owner`, false);
1180
+ message.push({ content: `\nResource ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE }, { content: collaborator.aadResourceId, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA }, { content: `, Resource Name: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE }, { content: `AAD App`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA }, { content: `, Permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE }, { content: `Owner`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA });
1144
1181
  }
1182
+ message.push({ content: "\n", color: teamsfx_api_1.Colors.BRIGHT_WHITE });
1183
+ (_j = ctx.ui) === null || _j === void 0 ? void 0 : _j.showMessage("info", message, false);
1145
1184
  }
1146
1185
  }
1147
1186
  const aadOwnerCount = collaborators.filter((collaborator) => collaborator.aadResourceId && collaborator.isAadOwner).length;
1148
- (_p = ctx.telemetryReporter) === null || _p === void 0 ? void 0 : _p.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.ListCollaborator, {
1149
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1150
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1151
- [constants_1.SolutionTelemetryProperty.CollaboratorCount]: collaborators.length.toString(),
1152
- [constants_1.SolutionTelemetryProperty.AadOwnerCount]: aadOwnerCount.toString(),
1187
+ (_k = ctx.telemetryReporter) === null || _k === void 0 ? void 0 : _k.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaborator, {
1188
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1189
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1190
+ [constants_2.SolutionTelemetryProperty.CollaboratorCount]: collaborators.length.toString(),
1191
+ [constants_2.SolutionTelemetryProperty.AadOwnerCount]: aadOwnerCount.toString(),
1153
1192
  });
1154
1193
  return teamsfx_api_1.ok(collaborators);
1155
1194
  }
@@ -1165,38 +1204,26 @@ let TeamsAppSolution = class TeamsAppSolution {
1165
1204
  }
1166
1205
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
1167
1206
  if (!provisioned) {
1168
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Failed to process because the resources have not been provisioned yet. Make sure you do the provision first."), "Solution", constants_1.SolutionError.CannotProcessBeforeProvision));
1207
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Failed to process because the resources have not been provisioned yet. Make sure you do the provision first."), "Solution", constants_2.SolutionError.CannotProcessBeforeProvision));
1169
1208
  }
1170
1209
  const user = await this.getUserInfo(ctx);
1171
1210
  if (!user) {
1172
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("Failed to retrieve current user info from graph token"), "Solution", constants_1.SolutionError.FailedToRetrieveUserInfo));
1211
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("Failed to retrieve current user info from graph token"), "Solution", constants_2.SolutionError.FailedToRetrieveUserInfo));
1173
1212
  }
1174
- const aadAppTenantId = (_b = (_a = ctx.envInfo.profile) === null || _a === void 0 ? void 0 : _a.get(constants_1.PluginNames.AAD)) === null || _b === void 0 ? void 0 : _b.get(constants_1.REMOTE_TENANT_ID);
1213
+ const aadAppTenantId = (_b = (_a = ctx.envInfo.profile) === null || _a === void 0 ? void 0 : _a.get(constants_2.PluginNames.AAD)) === null || _b === void 0 ? void 0 : _b.get(constants_2.REMOTE_TENANT_ID);
1175
1214
  if (!aadAppTenantId || user.tenantId != aadAppTenantId) {
1176
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Tenant id of your account and the provisioned Azure AD app does not match. Please check whether you logined with wrong account."), "Solution", constants_1.SolutionError.M365AccountNotMatch));
1215
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Tenant id of your account and the provisioned Azure AD app does not match. Please check whether you logined with wrong account."), "Solution", constants_2.SolutionError.M365AccountNotMatch));
1177
1216
  }
1178
1217
  return teamsfx_api_1.ok(user);
1179
1218
  }
1180
- parseTeamsAppTenantId(appStudioToken) {
1181
- if (appStudioToken === undefined) {
1182
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("Graph token json is undefined"), "Solution", constants_1.SolutionError.NoAppStudioToken));
1183
- }
1184
- const teamsAppTenantId = appStudioToken.tid;
1185
- if (teamsAppTenantId === undefined ||
1186
- !(typeof teamsAppTenantId === "string") ||
1187
- teamsAppTenantId.length === 0) {
1188
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("Cannot find teams app tenant id"), "Solution", constants_1.SolutionError.NoTeamsAppTenantId));
1189
- }
1190
- return teamsfx_api_1.ok(teamsAppTenantId);
1191
- }
1192
1219
  loadTeamsAppTenantId(ctx, isLocalDebug, appStudioToken) {
1193
- return this.parseTeamsAppTenantId(appStudioToken).andThen((teamsAppTenantId) => {
1220
+ return utils_1.parseTeamsAppTenantId(appStudioToken).andThen((teamsAppTenantId) => {
1194
1221
  var _a, _b;
1195
1222
  if (isLocalDebug && tools_1.isMultiEnvEnabled()) {
1196
1223
  (_a = ctx.localSettings) === null || _a === void 0 ? void 0 : _a.teamsApp.set(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TenantId, teamsAppTenantId);
1197
1224
  }
1198
1225
  else {
1199
- (_b = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set("teamsAppTenantId", teamsAppTenantId);
1226
+ (_b = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set("teamsAppTenantId", teamsAppTenantId);
1200
1227
  }
1201
1228
  return teamsfx_api_1.ok(ctx);
1202
1229
  });
@@ -1207,9 +1234,9 @@ let TeamsAppSolution = class TeamsAppSolution {
1207
1234
  }
1208
1235
  async getQuestionsForAddResource(func, ctx) {
1209
1236
  var _a;
1210
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
1237
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
1211
1238
  if (v1Blocked.isErr()) {
1212
- return v1Blocked;
1239
+ return teamsfx_api_1.err(v1Blocked.error);
1213
1240
  }
1214
1241
  const isDynamicQuestion = teamsfx_api_1.DynamicPlatforms.includes(ctx.answers.platform);
1215
1242
  const settings = this.getAzureSolutionSettings(ctx);
@@ -1217,11 +1244,11 @@ let TeamsAppSolution = class TeamsAppSolution {
1217
1244
  !(settings.hostType === question_1.HostTypeOptionAzure.id &&
1218
1245
  settings.capabilities &&
1219
1246
  settings.capabilities.includes(question_1.TabOptionItem.id))) {
1220
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Add resource is only supported for Tab app hosted in Azure."), "Solution", constants_1.SolutionError.AddResourceNotSupport));
1247
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Add resource is only supported for Tab app hosted in Azure."), "Solution", constants_2.SolutionError.AddResourceNotSupport));
1221
1248
  }
1222
1249
  const selectedPlugins = settings.activeResourcePlugins || [];
1223
1250
  if (!selectedPlugins) {
1224
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("selectedPlugins is empty"), "Solution", constants_1.SolutionError.InternelError));
1251
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("selectedPlugins is empty"), "Solution", constants_2.SolutionError.InternelError));
1225
1252
  }
1226
1253
  const functionPlugin = this.FunctionPlugin;
1227
1254
  const sqlPlugin = this.SqlPlugin;
@@ -1295,14 +1322,14 @@ let TeamsAppSolution = class TeamsAppSolution {
1295
1322
  }
1296
1323
  async getQuestionsForAddCapability(ctx) {
1297
1324
  var _a, _b;
1298
- const v1Blocked = this.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
1325
+ const v1Blocked = utils_1.blockV1Project((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings);
1299
1326
  if (v1Blocked.isErr()) {
1300
- return v1Blocked;
1327
+ return teamsfx_api_1.err(v1Blocked.error);
1301
1328
  }
1302
1329
  const isDynamicQuestion = teamsfx_api_1.DynamicPlatforms.includes(ctx.answers.platform);
1303
1330
  const settings = this.getAzureSolutionSettings(ctx);
1304
1331
  if (!(settings.hostType === question_1.HostTypeOptionAzure.id) && isDynamicQuestion) {
1305
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Add capability is not supported for SPFx project"), "Solution", constants_1.SolutionError.AddResourceNotSupport));
1332
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error("Add capability is not supported for SPFx project"), "Solution", constants_2.SolutionError.AddResourceNotSupport));
1306
1333
  }
1307
1334
  const capabilities = settings.capabilities || [];
1308
1335
  const alreadyHaveTab = capabilities.includes(question_1.TabOptionItem.id);
@@ -1372,11 +1399,11 @@ let TeamsAppSolution = class TeamsAppSolution {
1372
1399
  }
1373
1400
  async executeAddResource(ctx) {
1374
1401
  var _a, _b, _c, _d, _e, _f, _g;
1375
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddResourceStart, {
1376
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1402
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddResourceStart, {
1403
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1377
1404
  });
1378
1405
  if (!ctx.answers) {
1379
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_1.SolutionError.InternelError));
1406
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_2.SolutionError.InternelError));
1380
1407
  }
1381
1408
  const settings = this.getAzureSolutionSettings(ctx);
1382
1409
  const originalSettings = tools_1.deepCopy(settings);
@@ -1393,14 +1420,14 @@ let TeamsAppSolution = class TeamsAppSolution {
1393
1420
  const alreadyHaveApim = selectedPlugins === null || selectedPlugins === void 0 ? void 0 : selectedPlugins.includes(apimPlugin.name);
1394
1421
  const addResourcesAnswer = ctx.answers[question_1.AzureSolutionQuestionNames.AddResources];
1395
1422
  if (!addResourcesAnswer) {
1396
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer of ${question_1.AzureSolutionQuestionNames.AddResources} is empty!`), "Solution", constants_1.SolutionError.InvalidInput));
1423
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer of ${question_1.AzureSolutionQuestionNames.AddResources} is empty!`), "Solution", constants_2.SolutionError.InvalidInput));
1397
1424
  }
1398
1425
  const addSQL = addResourcesAnswer.includes(question_1.AzureResourceSQL.id);
1399
1426
  const addFunc = addResourcesAnswer.includes(question_1.AzureResourceFunction.id);
1400
1427
  const addApim = addResourcesAnswer.includes(question_1.AzureResourceApim.id);
1401
1428
  if ((alreadyHaveSql && addSQL) || (alreadyHaveApim && addApim)) {
1402
- const e = teamsfx_api_1.returnUserError(new Error("SQL/APIM is already added."), "Solution", constants_1.SolutionError.AddResourceNotSupport);
1403
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.AddResource, e, ctx.telemetryReporter));
1429
+ const e = teamsfx_api_1.returnUserError(new Error("SQL/APIM is already added."), "Solution", constants_2.SolutionError.AddResourceNotSupport);
1430
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddResource, e, ctx.telemetryReporter));
1404
1431
  }
1405
1432
  let addNewResoruceToProvision = false;
1406
1433
  const notifications = [];
@@ -1430,7 +1457,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1430
1457
  if (tools_1.isArmSupportEnabled() && addNewResoruceToProvision) {
1431
1458
  const confirmed = await executeUserTask_1.confirmRegenerateArmTemplate(ctx.ui);
1432
1459
  if (!confirmed) {
1433
- return teamsfx_api_1.ok(constants_1.Void);
1460
+ return teamsfx_api_1.ok(constants_2.Void);
1434
1461
  }
1435
1462
  }
1436
1463
  settings.azureResources = azureResource;
@@ -1440,29 +1467,29 @@ let TeamsAppSolution = class TeamsAppSolution {
1440
1467
  if (scaffoldRes.isErr()) {
1441
1468
  (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(`failed to scaffold ${notifications.join(",")}!`);
1442
1469
  ctx.projectSettings.solutionSettings = originalSettings;
1443
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.AddResource, scaffoldRes.error, ctx.telemetryReporter));
1470
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddResource, scaffoldRes.error, ctx.telemetryReporter));
1444
1471
  }
1445
1472
  (_d = ctx.logProvider) === null || _d === void 0 ? void 0 : _d.info(`finish scaffolding ${notifications.join(",")}!`);
1446
1473
  if (addNewResoruceToProvision)
1447
- (_e = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _e === void 0 ? void 0 : _e.set(constants_1.SOLUTION_PROVISION_SUCCEEDED, false); //if selected plugin changed, we need to re-do provision
1474
+ (_e = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _e === void 0 ? void 0 : _e.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, false); //if selected plugin changed, we need to re-do provision
1448
1475
  (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", util.format(ctx.answers.platform === teamsfx_api_1.Platform.CLI
1449
1476
  ? tools_1.getStrings().solution.AddResourceNoticeForCli
1450
1477
  : tools_1.getStrings().solution.AddResourceNotice, notifications.join(",")), false);
1451
1478
  }
1452
- (_g = ctx.telemetryReporter) === null || _g === void 0 ? void 0 : _g.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddResource, {
1453
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1454
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1455
- [constants_1.SolutionTelemetryProperty.Resources]: addResourcesAnswer.join(";"),
1479
+ (_g = ctx.telemetryReporter) === null || _g === void 0 ? void 0 : _g.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddResource, {
1480
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1481
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1482
+ [constants_2.SolutionTelemetryProperty.Resources]: addResourcesAnswer.join(";"),
1456
1483
  });
1457
- return teamsfx_api_1.ok(constants_1.Void);
1484
+ return teamsfx_api_1.ok(constants_2.Void);
1458
1485
  }
1459
1486
  async executeAddCapability(ctx) {
1460
1487
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1461
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddCapabilityStart, {
1462
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1488
+ (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddCapabilityStart, {
1489
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1463
1490
  });
1464
1491
  if (!ctx.answers) {
1465
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_1.SolutionError.InternelError));
1492
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_2.SolutionError.InternelError));
1466
1493
  }
1467
1494
  const settings = this.getAzureSolutionSettings(ctx);
1468
1495
  const originalSettings = tools_1.deepCopy(settings);
@@ -1472,19 +1499,19 @@ let TeamsAppSolution = class TeamsAppSolution {
1472
1499
  }
1473
1500
  const capabilitiesAnswer = ctx.answers[question_1.AzureSolutionQuestionNames.Capabilities];
1474
1501
  if (!capabilitiesAnswer || capabilitiesAnswer.length === 0) {
1475
- (_b = ctx.telemetryReporter) === null || _b === void 0 ? void 0 : _b.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddCapability, {
1476
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1477
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1478
- [constants_1.SolutionTelemetryProperty.Capabilities]: [].join(";"),
1502
+ (_b = ctx.telemetryReporter) === null || _b === void 0 ? void 0 : _b.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddCapability, {
1503
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1504
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1505
+ [constants_2.SolutionTelemetryProperty.Capabilities]: [].join(";"),
1479
1506
  });
1480
- return teamsfx_api_1.ok(constants_1.Void);
1507
+ return teamsfx_api_1.ok(constants_2.Void);
1481
1508
  }
1482
1509
  if ((((_c = settings.capabilities) === null || _c === void 0 ? void 0 : _c.includes(question_1.BotOptionItem.id)) ||
1483
1510
  ((_d = settings.capabilities) === null || _d === void 0 ? void 0 : _d.includes(question_1.MessageExtensionItem.id))) &&
1484
1511
  (capabilitiesAnswer.includes(question_1.BotOptionItem.id) ||
1485
1512
  capabilitiesAnswer.includes(question_1.MessageExtensionItem.id))) {
1486
- const e = teamsfx_api_1.returnUserError(new Error("Application already contains a Bot and/or Messaging Extension"), "Solution", constants_1.SolutionError.FailedToAddCapability);
1487
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.AddCapability, e, ctx.telemetryReporter));
1513
+ const e = teamsfx_api_1.returnUserError(new Error("Application already contains a Bot and/or Messaging Extension"), "Solution", constants_2.SolutionError.FailedToAddCapability);
1514
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddCapability, e, ctx.telemetryReporter));
1488
1515
  }
1489
1516
  let change = false;
1490
1517
  const notifications = [];
@@ -1509,7 +1536,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1509
1536
  if (tools_1.isArmSupportEnabled()) {
1510
1537
  const confirmed = await executeUserTask_1.confirmRegenerateArmTemplate(ctx.ui);
1511
1538
  if (!confirmed) {
1512
- return teamsfx_api_1.ok(constants_1.Void);
1539
+ return teamsfx_api_1.ok(constants_2.Void);
1513
1540
  }
1514
1541
  }
1515
1542
  settings.capabilities = capabilities;
@@ -1519,27 +1546,27 @@ let TeamsAppSolution = class TeamsAppSolution {
1519
1546
  if (scaffoldRes.isErr()) {
1520
1547
  (_f = ctx.logProvider) === null || _f === void 0 ? void 0 : _f.info(`failed to scaffold ${notifications.join(",")}!`);
1521
1548
  ctx.projectSettings.solutionSettings = originalSettings;
1522
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_1.SolutionTelemetryEvent.AddCapability, scaffoldRes.error, ctx.telemetryReporter));
1549
+ return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddCapability, scaffoldRes.error, ctx.telemetryReporter));
1523
1550
  }
1524
1551
  (_g = ctx.logProvider) === null || _g === void 0 ? void 0 : _g.info(`finish scaffolding ${notifications.join(",")}!`);
1525
- (_h = ctx.envInfo.profile.get(constants_1.GLOBAL_CONFIG)) === null || _h === void 0 ? void 0 : _h.set(constants_1.SOLUTION_PROVISION_SUCCEEDED, false);
1552
+ (_h = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _h === void 0 ? void 0 : _h.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, false);
1526
1553
  const msg = util.format(ctx.answers.platform === teamsfx_api_1.Platform.CLI
1527
1554
  ? tools_1.getStrings().solution.AddCapabilityNoticeForCli
1528
1555
  : tools_1.getStrings().solution.AddCapabilityNotice, notifications.join(","));
1529
1556
  (_j = ctx.ui) === null || _j === void 0 ? void 0 : _j.showMessage("info", msg, false);
1530
- (_k = ctx.telemetryReporter) === null || _k === void 0 ? void 0 : _k.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddCapability, {
1531
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1532
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1533
- [constants_1.SolutionTelemetryProperty.Capabilities]: capabilitiesAnswer.join(";"),
1557
+ (_k = ctx.telemetryReporter) === null || _k === void 0 ? void 0 : _k.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddCapability, {
1558
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1559
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1560
+ [constants_2.SolutionTelemetryProperty.Capabilities]: capabilitiesAnswer.join(";"),
1534
1561
  });
1535
1562
  return teamsfx_api_1.ok({});
1536
1563
  }
1537
1564
  const cannotAddCapWarnMsg = "Add nothing";
1538
1565
  (_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("warn", cannotAddCapWarnMsg, false);
1539
- (_m = ctx.telemetryReporter) === null || _m === void 0 ? void 0 : _m.sendTelemetryEvent(constants_1.SolutionTelemetryEvent.AddCapability, {
1540
- [constants_1.SolutionTelemetryProperty.Component]: constants_1.SolutionTelemetryComponentName,
1541
- [constants_1.SolutionTelemetryProperty.Success]: constants_1.SolutionTelemetrySuccess.Yes,
1542
- [constants_1.SolutionTelemetryProperty.Capabilities]: [].join(";"),
1566
+ (_m = ctx.telemetryReporter) === null || _m === void 0 ? void 0 : _m.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.AddCapability, {
1567
+ [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1568
+ [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1569
+ [constants_2.SolutionTelemetryProperty.Capabilities]: [].join(";"),
1543
1570
  });
1544
1571
  return teamsfx_api_1.ok({});
1545
1572
  }
@@ -1549,7 +1576,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1549
1576
  async executeUserTask(func, ctx) {
1550
1577
  var _a, _b;
1551
1578
  if (!ctx.answers)
1552
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_1.SolutionError.InternelError));
1579
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer is empty!`), "Solution", constants_2.SolutionError.InternelError));
1553
1580
  const namespace = func.namespace;
1554
1581
  const method = func.method;
1555
1582
  const array = namespace.split("/");
@@ -1572,7 +1599,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1572
1599
  // It's teamsfx init followed by teamsfx publish without running provision.
1573
1600
  // Using executeUserTask here could bypass the fx project check.
1574
1601
  if (((_a = ctx.answers) === null || _a === void 0 ? void 0 : _a.platform) !== "vs") {
1575
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`VS publish is not supposed to run on platform ${(_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform}`), "Solution", constants_1.SolutionError.UnsupportedPlatform));
1602
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`VS publish is not supposed to run on platform ${(_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform}`), "Solution", constants_2.SolutionError.UnsupportedPlatform));
1576
1603
  }
1577
1604
  const appStudioPlugin = this.AppStudioPlugin;
1578
1605
  const pluginCtx = util_1.getPluginContext(ctx, appStudioPlugin.name);
@@ -1603,8 +1630,8 @@ let TeamsAppSolution = class TeamsAppSolution {
1603
1630
  prepareConfigForRegisterTeamsAppAndAad(config, params) {
1604
1631
  const endpoint = params.endpoint;
1605
1632
  const domain = new URL(endpoint).hostname;
1606
- if (config.get(constants_1.GLOBAL_CONFIG) == undefined) {
1607
- config.set(constants_1.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
1633
+ if (config.get(constants_2.GLOBAL_CONFIG) == undefined) {
1634
+ config.set(constants_2.GLOBAL_CONFIG, new teamsfx_api_1.ConfigMap());
1608
1635
  }
1609
1636
  const aadPlugin = this.AadPlugin;
1610
1637
  if (config.get(aadPlugin.name) == undefined) {
@@ -1617,19 +1644,19 @@ let TeamsAppSolution = class TeamsAppSolution {
1617
1644
  extractConfigForRegisterTeamsAppAndAad(config, isLocal) {
1618
1645
  var _a, _b, _c;
1619
1646
  const aadPlugin = this.AadPlugin;
1620
- const aadId = (_a = config.get(aadPlugin.name)) === null || _a === void 0 ? void 0 : _a.get(isLocal ? constants_1.LOCAL_DEBUG_AAD_ID : constants_1.REMOTE_AAD_ID);
1647
+ const aadId = (_a = config.get(aadPlugin.name)) === null || _a === void 0 ? void 0 : _a.get(isLocal ? constants_2.LOCAL_DEBUG_AAD_ID : constants_2.REMOTE_AAD_ID);
1621
1648
  if (aadId === undefined || typeof aadId !== "string") {
1622
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_1.LOCAL_DEBUG_AAD_ID} is missing`), "Solution", constants_1.SolutionError.RegisterTeamsAppAndAadError));
1649
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_2.LOCAL_DEBUG_AAD_ID} is missing`), "Solution", constants_2.SolutionError.RegisterTeamsAppAndAadError));
1623
1650
  }
1624
1651
  const applicationIdUri = (_b = config
1625
- .get(aadPlugin.name)) === null || _b === void 0 ? void 0 : _b.get(isLocal ? constants_1.LOCAL_APPLICATION_ID_URIS : constants_1.REMOTE_APPLICATION_ID_URIS);
1652
+ .get(aadPlugin.name)) === null || _b === void 0 ? void 0 : _b.get(isLocal ? constants_2.LOCAL_APPLICATION_ID_URIS : constants_2.REMOTE_APPLICATION_ID_URIS);
1626
1653
  if (applicationIdUri === undefined || typeof applicationIdUri !== "string") {
1627
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_1.LOCAL_APPLICATION_ID_URIS} is missing`), "Solution", constants_1.SolutionError.RegisterTeamsAppAndAadError));
1654
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_2.LOCAL_APPLICATION_ID_URIS} is missing`), "Solution", constants_2.SolutionError.RegisterTeamsAppAndAadError));
1628
1655
  }
1629
1656
  const clientSecret = (_c = config
1630
- .get(aadPlugin.name)) === null || _c === void 0 ? void 0 : _c.get(isLocal ? constants_1.LOCAL_CLIENT_SECRET : constants_1.REMOTE_CLIENT_SECRET);
1657
+ .get(aadPlugin.name)) === null || _c === void 0 ? void 0 : _c.get(isLocal ? constants_2.LOCAL_CLIENT_SECRET : constants_2.REMOTE_CLIENT_SECRET);
1631
1658
  if (clientSecret === undefined || typeof clientSecret !== "string") {
1632
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_1.LOCAL_CLIENT_SECRET} is missing`), "Solution", constants_1.SolutionError.RegisterTeamsAppAndAadError));
1659
+ return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error(`config ${constants_2.LOCAL_CLIENT_SECRET} is missing`), "Solution", constants_2.SolutionError.RegisterTeamsAppAndAadError));
1633
1660
  }
1634
1661
  return teamsfx_api_1.ok({
1635
1662
  aadId,
@@ -1657,7 +1684,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1657
1684
  return teamsfx_api_1.ok(undefined);
1658
1685
  },
1659
1686
  async getPermissionRequest() {
1660
- return teamsfx_api_1.ok(JSON.stringify(constants_1.DEFAULT_PERMISSION_REQUEST));
1687
+ return teamsfx_api_1.ok(JSON.stringify(constants_2.DEFAULT_PERMISSION_REQUEST));
1661
1688
  },
1662
1689
  };
1663
1690
  }
@@ -1668,7 +1695,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1668
1695
  return provisionResult;
1669
1696
  }
1670
1697
  await aadPlugin.executeUserTask({
1671
- namespace: `${constants_1.PluginNames.SOLUTION}/${constants_1.PluginNames.AAD}`,
1698
+ namespace: `${constants_2.PluginNames.SOLUTION}/${constants_2.PluginNames.AAD}`,
1672
1699
  method: "setApplicationInContext",
1673
1700
  params: { isLocal: isLocal },
1674
1701
  }, aadPluginCtx);
@@ -1696,7 +1723,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1696
1723
  await fs.writeFile(manifestPath, manifestStr);
1697
1724
  const appStudioPlugin = this.AppStudioPlugin;
1698
1725
  const func = {
1699
- namespace: `${constants_1.PluginNames.SOLUTION}/${constants_1.PluginNames.APPST}`,
1726
+ namespace: `${constants_2.PluginNames.SOLUTION}/${constants_2.PluginNames.APPST}`,
1700
1727
  method: "getAppDefinitionAndUpdate",
1701
1728
  params: {
1702
1729
  type: "remote",
@@ -1709,7 +1736,7 @@ let TeamsAppSolution = class TeamsAppSolution {
1709
1736
  }
1710
1737
  const teamsAppId = maybeTeamsAppId.value;
1711
1738
  const appSettingsJSONTpl = (await fs.readFile(appSettingsJSONPath)).toString();
1712
- const maybeTenantId = this.parseTeamsAppTenantId(await ((_a = ctx.appStudioToken) === null || _a === void 0 ? void 0 : _a.getJsonObject()));
1739
+ const maybeTenantId = utils_1.parseTeamsAppTenantId(await ((_a = ctx.appStudioToken) === null || _a === void 0 ? void 0 : _a.getJsonObject()));
1713
1740
  if (maybeTenantId.isErr()) {
1714
1741
  return teamsfx_api_1.err(maybeTenantId.error);
1715
1742
  }
@@ -1824,7 +1851,7 @@ tslib_1.__decorate([
1824
1851
  tslib_1.__metadata("design:returntype", Promise)
1825
1852
  ], TeamsAppSolution.prototype, "executeUserTask", null);
1826
1853
  TeamsAppSolution = tslib_1.__decorate([
1827
- typedi_1.Service(),
1854
+ typedi_1.Service(SolutionPluginContainer_1.SolutionPlugins.AzureTeamsSolution),
1828
1855
  tslib_1.__metadata("design:paramtypes", [])
1829
1856
  ], TeamsAppSolution);
1830
1857
  exports.TeamsAppSolution = TeamsAppSolution;