@microsoft/teamsfx-core 1.0.0 → 1.0.1-alpha.04803ca3.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 (194) hide show
  1. package/build/common/armInterface.d.ts +6 -11
  2. package/build/common/armInterface.d.ts.map +1 -1
  3. package/build/common/tools.d.ts +2 -2
  4. package/build/common/tools.d.ts.map +1 -1
  5. package/build/common/tools.js +1 -5
  6. package/build/common/tools.js.map +1 -1
  7. package/build/core/error.d.ts +1 -0
  8. package/build/core/error.d.ts.map +1 -1
  9. package/build/core/error.js +5 -1
  10. package/build/core/error.js.map +1 -1
  11. package/build/core/index.d.ts +1 -0
  12. package/build/core/index.d.ts.map +1 -1
  13. package/build/core/index.js +46 -4
  14. package/build/core/index.js.map +1 -1
  15. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  16. package/build/core/middleware/envInfoLoader.js +23 -2
  17. package/build/core/middleware/envInfoLoader.js.map +1 -1
  18. package/build/core/middleware/envInfoWriter.d.ts.map +1 -1
  19. package/build/core/middleware/envInfoWriter.js +2 -0
  20. package/build/core/middleware/envInfoWriter.js.map +1 -1
  21. package/build/core/middleware/projectMigrator.js +1 -1
  22. package/build/core/middleware/projectMigrator.js.map +1 -1
  23. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  24. package/build/core/middleware/projectSettingsLoader.js +1 -0
  25. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  26. package/build/plugins/resource/aad/index.d.ts +2 -3
  27. package/build/plugins/resource/aad/index.d.ts.map +1 -1
  28. package/build/plugins/resource/aad/index.js.map +1 -1
  29. package/build/plugins/resource/aad/v2/index.d.ts +3 -0
  30. package/build/plugins/resource/aad/v2/index.d.ts.map +1 -1
  31. package/build/plugins/resource/aad/v2/index.js +9 -0
  32. package/build/plugins/resource/aad/v2/index.js.map +1 -1
  33. package/build/plugins/resource/apim/index.d.ts.map +1 -1
  34. package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
  35. package/build/plugins/resource/appstudio/index.js +16 -6
  36. package/build/plugins/resource/appstudio/index.js.map +1 -1
  37. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts +6 -2
  38. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts.map +1 -1
  39. package/build/plugins/resource/appstudio/plugin.d.ts +1 -1
  40. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  41. package/build/plugins/resource/appstudio/plugin.js +123 -36
  42. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  43. package/build/plugins/resource/appstudio/utils/telemetry.d.ts +1 -0
  44. package/build/plugins/resource/appstudio/utils/telemetry.d.ts.map +1 -1
  45. package/build/plugins/resource/appstudio/utils/telemetry.js +1 -0
  46. package/build/plugins/resource/appstudio/utils/telemetry.js.map +1 -1
  47. package/build/plugins/resource/appstudio/v2/index.d.ts +4 -2
  48. package/build/plugins/resource/appstudio/v2/index.d.ts.map +1 -1
  49. package/build/plugins/resource/appstudio/v2/index.js +9 -3
  50. package/build/plugins/resource/appstudio/v2/index.js.map +1 -1
  51. package/build/plugins/resource/frontend/index.d.ts +1 -2
  52. package/build/plugins/resource/frontend/index.d.ts.map +1 -1
  53. package/build/plugins/resource/frontend/index.js.map +1 -1
  54. package/build/plugins/resource/function/enums.d.ts +1 -0
  55. package/build/plugins/resource/function/enums.d.ts.map +1 -1
  56. package/build/plugins/resource/function/enums.js +1 -0
  57. package/build/plugins/resource/function/enums.js.map +1 -1
  58. package/build/plugins/resource/function/index.d.ts +1 -0
  59. package/build/plugins/resource/function/index.d.ts.map +1 -1
  60. package/build/plugins/resource/function/index.js +5 -0
  61. package/build/plugins/resource/function/index.js.map +1 -1
  62. package/build/plugins/resource/function/plugin.d.ts +1 -0
  63. package/build/plugins/resource/function/plugin.d.ts.map +1 -1
  64. package/build/plugins/resource/function/plugin.js +20 -2
  65. package/build/plugins/resource/function/plugin.js.map +1 -1
  66. package/build/plugins/resource/identity/v2/index.d.ts +2 -1
  67. package/build/plugins/resource/identity/v2/index.d.ts.map +1 -1
  68. package/build/plugins/resource/identity/v2/index.js +3 -0
  69. package/build/plugins/resource/identity/v2/index.js.map +1 -1
  70. package/build/plugins/resource/index.d.ts +1 -0
  71. package/build/plugins/resource/index.d.ts.map +1 -1
  72. package/build/plugins/resource/index.js +1 -0
  73. package/build/plugins/resource/index.js.map +1 -1
  74. package/build/plugins/resource/keyvault/constants.d.ts +35 -0
  75. package/build/plugins/resource/keyvault/constants.d.ts.map +1 -0
  76. package/build/plugins/resource/keyvault/constants.js +42 -0
  77. package/build/plugins/resource/keyvault/constants.js.map +1 -0
  78. package/build/plugins/resource/keyvault/index.d.ts +14 -0
  79. package/build/plugins/resource/keyvault/index.d.ts.map +1 -0
  80. package/build/plugins/resource/keyvault/index.js +60 -0
  81. package/build/plugins/resource/keyvault/index.js.map +1 -0
  82. package/build/plugins/resource/keyvault/plugin.d.ts +6 -0
  83. package/build/plugins/resource/keyvault/plugin.d.ts.map +1 -0
  84. package/build/plugins/resource/keyvault/plugin.js +31 -0
  85. package/build/plugins/resource/keyvault/plugin.js.map +1 -0
  86. package/build/plugins/resource/keyvault/result.d.ts +9 -0
  87. package/build/plugins/resource/keyvault/result.d.ts.map +1 -0
  88. package/build/plugins/resource/keyvault/result.js +21 -0
  89. package/build/plugins/resource/keyvault/result.js.map +1 -0
  90. package/build/plugins/resource/keyvault/utils/telemetry.d.ts +17 -0
  91. package/build/plugins/resource/keyvault/utils/telemetry.d.ts.map +1 -0
  92. package/build/plugins/resource/keyvault/utils/telemetry.js +45 -0
  93. package/build/plugins/resource/keyvault/utils/telemetry.js.map +1 -0
  94. package/build/plugins/resource/localdebug/localEnvMulti.d.ts +0 -2
  95. package/build/plugins/resource/localdebug/localEnvMulti.d.ts.map +1 -1
  96. package/build/plugins/resource/localdebug/localEnvMulti.js +0 -4
  97. package/build/plugins/resource/localdebug/localEnvMulti.js.map +1 -1
  98. package/build/plugins/resource/simpleauth/plugin.d.ts.map +1 -1
  99. package/build/plugins/resource/simpleauth/plugin.js +2 -2
  100. package/build/plugins/resource/simpleauth/plugin.js.map +1 -1
  101. package/build/plugins/resource/simpleauth/v2/index.d.ts +7 -6
  102. package/build/plugins/resource/simpleauth/v2/index.d.ts.map +1 -1
  103. package/build/plugins/resource/simpleauth/v2/index.js +12 -6
  104. package/build/plugins/resource/simpleauth/v2/index.js.map +1 -1
  105. package/build/plugins/resource/utils4v2.d.ts +8 -8
  106. package/build/plugins/resource/utils4v2.d.ts.map +1 -1
  107. package/build/plugins/resource/utils4v2.js +26 -1
  108. package/build/plugins/resource/utils4v2.js.map +1 -1
  109. package/build/plugins/solution/fx-solution/ResourcePluginContainer.d.ts +1 -0
  110. package/build/plugins/solution/fx-solution/ResourcePluginContainer.d.ts.map +1 -1
  111. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js +1 -0
  112. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js.map +1 -1
  113. package/build/plugins/solution/fx-solution/arm.d.ts +5 -3
  114. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  115. package/build/plugins/solution/fx-solution/arm.js +72 -32
  116. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  117. package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
  118. package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
  119. package/build/plugins/solution/fx-solution/constants.d.ts +1 -1
  120. package/build/plugins/solution/fx-solution/constants.d.ts.map +1 -1
  121. package/build/plugins/solution/fx-solution/constants.js +2 -2
  122. package/build/plugins/solution/fx-solution/constants.js.map +1 -1
  123. package/build/plugins/solution/fx-solution/question.d.ts +2 -1
  124. package/build/plugins/solution/fx-solution/question.d.ts.map +1 -1
  125. package/build/plugins/solution/fx-solution/question.js +10 -3
  126. package/build/plugins/solution/fx-solution/question.js.map +1 -1
  127. package/build/plugins/solution/fx-solution/solution.d.ts +2 -4
  128. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  129. package/build/plugins/solution/fx-solution/solution.js +65 -580
  130. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  131. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts +11 -1
  132. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts.map +1 -1
  133. package/build/plugins/solution/fx-solution/v2/adaptor.js +82 -9
  134. package/build/plugins/solution/fx-solution/v2/adaptor.js.map +1 -1
  135. package/build/plugins/solution/fx-solution/v2/checkPermission.d.ts +5 -0
  136. package/build/plugins/solution/fx-solution/v2/checkPermission.d.ts.map +1 -0
  137. package/build/plugins/solution/fx-solution/v2/checkPermission.js +185 -0
  138. package/build/plugins/solution/fx-solution/v2/checkPermission.js.map +1 -0
  139. package/build/plugins/solution/fx-solution/v2/collaborationUtil.d.ts +24 -0
  140. package/build/plugins/solution/fx-solution/v2/collaborationUtil.d.ts.map +1 -0
  141. package/build/plugins/solution/fx-solution/v2/collaborationUtil.js +110 -0
  142. package/build/plugins/solution/fx-solution/v2/collaborationUtil.js.map +1 -0
  143. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  144. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +14 -10
  145. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  146. package/build/plugins/solution/fx-solution/v2/executor.d.ts +1 -0
  147. package/build/plugins/solution/fx-solution/v2/executor.d.ts.map +1 -1
  148. package/build/plugins/solution/fx-solution/v2/executor.js +17 -1
  149. package/build/plugins/solution/fx-solution/v2/executor.js.map +1 -1
  150. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts +1 -0
  151. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts.map +1 -1
  152. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js +12 -1
  153. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js.map +1 -1
  154. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -1
  155. package/build/plugins/solution/fx-solution/v2/getQuestions.js +5 -8
  156. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -1
  157. package/build/plugins/solution/fx-solution/v2/grantPermission.d.ts +5 -0
  158. package/build/plugins/solution/fx-solution/v2/grantPermission.d.ts.map +1 -0
  159. package/build/plugins/solution/fx-solution/v2/grantPermission.js +205 -0
  160. package/build/plugins/solution/fx-solution/v2/grantPermission.js.map +1 -0
  161. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.d.ts +5 -0
  162. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.d.ts.map +1 -0
  163. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.js +118 -0
  164. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.js.map +1 -0
  165. package/build/plugins/solution/fx-solution/v2/listCollaborator.d.ts +8 -0
  166. package/build/plugins/solution/fx-solution/v2/listCollaborator.d.ts.map +1 -0
  167. package/build/plugins/solution/fx-solution/v2/listCollaborator.js +202 -0
  168. package/build/plugins/solution/fx-solution/v2/listCollaborator.js.map +1 -0
  169. package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -1
  170. package/build/plugins/solution/fx-solution/v2/provision.js +38 -9
  171. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -1
  172. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
  173. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +28 -17
  174. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
  175. package/build/plugins/solution/fx-solution/v2/solution.d.ts +4 -0
  176. package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -1
  177. package/build/plugins/solution/fx-solution/v2/solution.js +8 -0
  178. package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -1
  179. package/build/plugins/solution/fx-solution/v2/utils.d.ts +4 -1
  180. package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
  181. package/build/plugins/solution/fx-solution/v2/utils.js +27 -1
  182. package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
  183. package/package.json +5 -3
  184. package/resource/strings.json +1 -0
  185. package/templates/azure/config.bicep +1 -13
  186. package/templates/azure/provision.bicep +8 -36
  187. package/templates/azure/teamsFx/bot.bicep +34 -0
  188. package/templates/plugins/resource/bot/bicep/botConfiguration.template.bicep +10 -0
  189. package/templates/plugins/resource/function/bicep/functionConfiguration.template.bicep +5 -0
  190. package/templates/plugins/resource/keyvault/bicep/keyVaultProvision.template.bicep +54 -0
  191. package/templates/plugins/resource/keyvault/bicep/provision.template.bicep +13 -0
  192. package/templates/plugins/resource/simpleauth/bicep/simpleAuthConfiguration.template.bicep +5 -0
  193. package/templates/azure/provision/function.bicep +0 -79
  194. package/templates/azure/provision/identity.bicep +0 -14
@@ -10,7 +10,6 @@ const tslib_1 = require("tslib");
10
10
  // Licensed under the MIT license.
11
11
  const lib_1 = require("@feathersjs/hooks/lib");
12
12
  const teamsfx_api_1 = require("@microsoft/teamsfx-api");
13
- const axios_1 = tslib_1.__importDefault(require("axios"));
14
13
  const fs = tslib_1.__importStar(require("fs-extra"));
15
14
  const mustache_1 = tslib_1.__importDefault(require("mustache"));
16
15
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -18,7 +17,6 @@ const typedi_1 = require("typedi");
18
17
  const util = tslib_1.__importStar(require("util"));
19
18
  const constants_1 = require("../../../common/constants");
20
19
  const localSettingsConstants_1 = require("../../../common/localSettingsConstants");
21
- const permissionInterface_1 = require("../../../common/permissionInterface");
22
20
  const tools_1 = require("../../../common/tools");
23
21
  const core_1 = require("../../../core");
24
22
  const errorHandler_1 = require("../../../core/middleware/errorHandler");
@@ -35,11 +33,13 @@ const util_1 = require("./utils/util");
35
33
  const executeUserTask_1 = require("./v2/executeUserTask");
36
34
  const utils_1 = require("./v2/utils");
37
35
  const provision_1 = require("./v2/provision");
36
+ const grantPermission_1 = require("./v2/grantPermission");
37
+ const checkPermission_1 = require("./v2/checkPermission");
38
+ const listAllCollaborators_1 = require("./v2/listAllCollaborators");
39
+ const listCollaborator_1 = require("./v2/listCollaborator");
38
40
  const scaffolding_1 = require("./v2/scaffolding");
39
- const __1 = require("../../..");
40
41
  const telemetry_1 = require("../../../common/telemetry");
41
42
  const _1 = require(".");
42
- const constants_3 = require("../../../common/constants");
43
43
  // Maybe we need a state machine to track state transition.
44
44
  var SolutionRunningState;
45
45
  (function (SolutionRunningState) {
@@ -59,6 +59,7 @@ let TeamsAppSolution = class TeamsAppSolution {
59
59
  this.FunctionPlugin = typedi_1.Container.get(ResourcePluginContainer_1.ResourcePlugins.FunctionPlugin);
60
60
  this.SqlPlugin = typedi_1.Container.get(ResourcePluginContainer_1.ResourcePlugins.SqlPlugin);
61
61
  this.ApimPlugin = typedi_1.Container.get(ResourcePluginContainer_1.ResourcePlugins.ApimPlugin);
62
+ this.KeyVaultPlugin = typedi_1.Container.get(ResourcePluginContainer_1.ResourcePlugins.KeyVaultPlugin);
62
63
  this.LocalDebugPlugin = typedi_1.Container.get(ResourcePluginContainer_1.ResourcePlugins.LocalDebugPlugin);
63
64
  this.runningState = SolutionRunningState.Idle;
64
65
  }
@@ -224,9 +225,9 @@ let TeamsAppSolution = class TeamsAppSolution {
224
225
  }
225
226
  return result;
226
227
  }
227
- async doScaffold(ctx, selectedPlugins, generateResourceTemplate) {
228
+ async doScaffold(ctx, pluginsToScaffold, generateResourceTemplate, pluginsToDoArm) {
228
229
  var _a, _b;
229
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, selectedPlugins);
230
+ const pluginsWithCtx = this.getPluginAndContextArray(ctx, pluginsToScaffold);
230
231
  const preScaffoldWithCtx = pluginsWithCtx.map(([plugin, context]) => {
231
232
  var _a;
232
233
  return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.preScaffold) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
@@ -248,7 +249,7 @@ let TeamsAppSolution = class TeamsAppSolution {
248
249
  await scaffolding_1.scaffoldReadme(capabilities, azureResources, ctx.root);
249
250
  }
250
251
  if (tools_1.isArmSupportEnabled() && generateResourceTemplate && this.isAzureProject(ctx)) {
251
- return await arm_1.generateArmTemplate(ctx, selectedPlugins);
252
+ return await arm_1.generateArmTemplate(ctx, pluginsToDoArm ? pluginsToDoArm : pluginsToScaffold);
252
253
  }
253
254
  else {
254
255
  return res;
@@ -298,7 +299,7 @@ let TeamsAppSolution = class TeamsAppSolution {
298
299
  *
299
300
  */
300
301
  async provision(ctx) {
301
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
302
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
302
303
  const canProvision = this.checkWhetherSolutionIsIdle();
303
304
  if (canProvision.isErr()) {
304
305
  return canProvision;
@@ -320,12 +321,12 @@ let TeamsAppSolution = class TeamsAppSolution {
320
321
  }
321
322
  const provisionResult = await this.doProvision(ctx);
322
323
  if (provisionResult.isOk()) {
323
- const url = tools_1.getResourceGroupInPortal(ctx);
324
- const msg = util.format(`Success: ${tools_1.getStrings().solution.ProvisionSuccessNotice}`, (_c = ctx.projectSettings) === null || _c === void 0 ? void 0 : _c.appName);
325
- (_d = ctx.logProvider) === null || _d === void 0 ? void 0 : _d.info(msg);
324
+ const url = tools_1.getResourceGroupInPortal((_c = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _c === void 0 ? void 0 : _c.getString(constants_2.SUBSCRIPTION_ID), (_d = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _d === void 0 ? void 0 : _d.getString("tenantId"), (_e = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _e === void 0 ? void 0 : _e.getString(constants_2.RESOURCE_GROUP_NAME));
325
+ const msg = util.format(`Success: ${tools_1.getStrings().solution.ProvisionSuccessNotice}`, (_f = ctx.projectSettings) === null || _f === void 0 ? void 0 : _f.appName);
326
+ (_g = ctx.logProvider) === null || _g === void 0 ? void 0 : _g.info(msg);
326
327
  if (url) {
327
328
  const title = "View Provisioned Resources";
328
- (_e = ctx.ui) === null || _e === void 0 ? void 0 : _e.showMessage("info", msg, false, title).then((result) => {
329
+ (_h = ctx.ui) === null || _h === void 0 ? void 0 : _h.showMessage("info", msg, false, title).then((result) => {
329
330
  const userSelected = result.isOk() ? result.value : undefined;
330
331
  if (userSelected === title) {
331
332
  ctx.ui.openUrl(url);
@@ -333,16 +334,21 @@ let TeamsAppSolution = class TeamsAppSolution {
333
334
  });
334
335
  }
335
336
  else {
336
- (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", msg, false);
337
+ (_j = ctx.ui) === null || _j === void 0 ? void 0 : _j.showMessage("info", msg, false);
338
+ }
339
+ (_k = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _k === void 0 ? void 0 : _k.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, true);
340
+ if (!this.isAzureProject(ctx) && tools_1.isMultiEnvEnabled()) {
341
+ const appStudioTokenJson = await ((_l = ctx.appStudioToken) === null || _l === void 0 ? void 0 : _l.getJsonObject());
342
+ (_m = ctx.envInfo.state
343
+ .get(constants_2.GLOBAL_CONFIG)) === null || _m === void 0 ? void 0 : _m.set(_1.REMOTE_TEAMS_APP_TENANT_ID, appStudioTokenJson.tid);
337
344
  }
338
- (_g = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _g === void 0 ? void 0 : _g.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, true);
339
345
  }
340
346
  else {
341
347
  if (!tools_1.isUserCancelError(provisionResult.error) &&
342
348
  !tools_1.isCheckAccountError(provisionResult.error)) {
343
- const msg = util.format(tools_1.getStrings().solution.ProvisionFailNotice, (_h = ctx.projectSettings) === null || _h === void 0 ? void 0 : _h.appName);
344
- (_j = ctx.logProvider) === null || _j === void 0 ? void 0 : _j.error(msg);
345
- (_k = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _k === void 0 ? void 0 : _k.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, false);
349
+ const msg = util.format(tools_1.getStrings().solution.ProvisionFailNotice, (_o = ctx.projectSettings) === null || _o === void 0 ? void 0 : _o.appName);
350
+ (_p = ctx.logProvider) === null || _p === void 0 ? void 0 : _p.error(msg);
351
+ (_q = ctx.envInfo.state.get(constants_2.GLOBAL_CONFIG)) === null || _q === void 0 ? void 0 : _q.set(constants_2.SOLUTION_PROVISION_SUCCEEDED, false);
346
352
  }
347
353
  }
348
354
  return provisionResult;
@@ -719,7 +725,7 @@ let TeamsAppSolution = class TeamsAppSolution {
719
725
  const isAzureProject = this.isAzureProject(ctx);
720
726
  const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.state);
721
727
  if (isAzureProject && !provisioned) {
722
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToDeployBeforeProvision), constants_2.SolutionSource, constants_2.SolutionError.CannotDeployBeforeProvision, constants_3.HelpLinks.WhyNeedProvision));
728
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(tools_1.getStrings().solution.FailedToDeployBeforeProvision), constants_2.SolutionSource, constants_2.SolutionError.CannotDeployBeforeProvision, constants_1.HelpLinks.WhyNeedProvision));
723
729
  }
724
730
  }
725
731
  let pluginsToDeploy;
@@ -774,7 +780,7 @@ let TeamsAppSolution = class TeamsAppSolution {
774
780
  const errorMsg = isAzureProject
775
781
  ? tools_1.getStrings().solution.FailedToPublishBeforeProvision
776
782
  : tools_1.getStrings().solution.SPFxAskProvisionBeforePublish;
777
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.CannotPublishBeforeProvision, constants_3.HelpLinks.WhyNeedProvision));
783
+ return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.CannotPublishBeforeProvision, constants_1.HelpLinks.WhyNeedProvision));
778
784
  }
779
785
  }
780
786
  const pluginsToPublish = [this.AppStudioPlugin];
@@ -818,7 +824,7 @@ let TeamsAppSolution = class TeamsAppSolution {
818
824
  return await this.doLocalDebug(ctx);
819
825
  }
820
826
  async doLocalDebug(ctx) {
821
- var _a, _b, _c, _d, _e, _f, _g;
827
+ var _a, _b, _c, _d, _e;
822
828
  let checkPoint = 1;
823
829
  try {
824
830
  //check point 2
@@ -837,19 +843,9 @@ let TeamsAppSolution = class TeamsAppSolution {
837
843
  const localDebugTenantId = tools_1.isMultiEnvEnabled()
838
844
  ? (_c = (_b = ctx.localSettings) === null || _b === void 0 ? void 0 : _b.teamsApp) === null || _c === void 0 ? void 0 : _c.get(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TenantId)
839
845
  : (_d = ctx.envInfo.state.get(constants_2.PluginNames.AAD)) === null || _d === void 0 ? void 0 : _d.get(_1.LOCAL_TENANT_ID);
840
- if (localDebugTenantId) {
841
- const m365TenantId = utils_1.parseTeamsAppTenantId(await ((_e = ctx.appStudioToken) === null || _e === void 0 ? void 0 : _e.getJsonObject()));
842
- if (m365TenantId.isErr()) {
843
- throw teamsfx_api_1.err(m365TenantId.error);
844
- }
845
- const m365UserAccount = utils_1.parseUserName(await ((_f = ctx.appStudioToken) === null || _f === void 0 ? void 0 : _f.getJsonObject()));
846
- if (m365UserAccount.isErr()) {
847
- throw teamsfx_api_1.err(m365UserAccount.error);
848
- }
849
- if (m365TenantId.value !== localDebugTenantId) {
850
- const errorMessage = util.format(tools_1.getStrings().solution.LocalDebugTenantConfirmNotice, localDebugTenantId, m365UserAccount.value, tools_1.isMultiEnvEnabled() ? "localSettings.json" : "default.userdata");
851
- return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(errorMessage), "Solution", constants_2.SolutionError.CannotLocalDebugInDifferentTenant));
852
- }
846
+ const m365TenantMatches = await utils_1.checkWhetherLocalDebugM365TenantMatches(localDebugTenantId, ctx.appStudioToken);
847
+ if (m365TenantMatches.isErr()) {
848
+ return m365TenantMatches;
853
849
  }
854
850
  checkPoint = 3;
855
851
  //check point 4
@@ -886,7 +882,7 @@ let TeamsAppSolution = class TeamsAppSolution {
886
882
  checkPoint = 5;
887
883
  // check point 6
888
884
  // set local debug Teams app tenant id in context.
889
- const result = this.loadTeamsAppTenantId(ctx, true, await ((_g = ctx.appStudioToken) === null || _g === void 0 ? void 0 : _g.getJsonObject()));
885
+ const result = this.loadTeamsAppTenantId(ctx, true, await ((_e = ctx.appStudioToken) === null || _e === void 0 ? void 0 : _e.getJsonObject()));
890
886
  if (result.isErr()) {
891
887
  return result;
892
888
  }
@@ -925,509 +921,16 @@ let TeamsAppSolution = class TeamsAppSolution {
925
921
  }
926
922
  }
927
923
  async grantPermission(ctx) {
928
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
929
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.GrantPermissionStart, {
930
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
931
- });
932
- const progressBar = (_b = ctx.ui) === null || _b === void 0 ? void 0 : _b.createProgressBar("Granting permission", 1);
933
- try {
934
- const result = await this.getCurrentUserInfo(ctx);
935
- if (result.isErr()) {
936
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, result.error, ctx.telemetryReporter));
937
- }
938
- const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
939
- if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
940
- if (((_c = ctx.answers) === null || _c === void 0 ? void 0 : _c.platform) === teamsfx_api_1.Platform.CLI) {
941
- (_d = ctx.ui) === null || _d === void 0 ? void 0 : _d.showMessage("warn", stateResult.message, false);
942
- }
943
- else if (((_e = ctx.answers) === null || _e === void 0 ? void 0 : _e.platform) === teamsfx_api_1.Platform.VSCode) {
944
- (_f = ctx.logProvider) === null || _f === void 0 ? void 0 : _f.warning(stateResult.message);
945
- }
946
- return teamsfx_api_1.ok({
947
- state: stateResult.state,
948
- message: stateResult.message,
949
- });
950
- }
951
- const email = ctx.answers["email"];
952
- if (!email || email === result.value.userPrincipalName) {
953
- 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"), constants_2.SolutionSource, constants_2.SolutionError.EmailCannotBeEmptyOrSame), ctx.telemetryReporter));
954
- }
955
- const userInfo = await this.getUserInfo(ctx, email);
956
- if (!userInfo) {
957
- 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"), constants_2.SolutionSource, constants_2.SolutionError.CannotFindUserInCurrentTenant), ctx.telemetryReporter));
958
- }
959
- progressBar === null || progressBar === void 0 ? void 0 : progressBar.start();
960
- progressBar === null || progressBar === void 0 ? void 0 : progressBar.next(`Grant permission for user ${email}`);
961
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
962
- this.AadPlugin,
963
- this.AppStudioPlugin,
964
- ]);
965
- const grantPermissionWithCtx = pluginsWithCtx.map(([plugin, context]) => {
966
- return [
967
- (plugin === null || plugin === void 0 ? void 0 : plugin.grantPermission)
968
- ? (ctx) => plugin.grantPermission.bind(plugin)(ctx, userInfo)
969
- : undefined,
970
- context,
971
- plugin.name,
972
- ];
973
- });
974
- if (((_g = ctx.answers) === null || _g === void 0 ? void 0 : _g.platform) === teamsfx_api_1.Platform.CLI) {
975
- const aadAppTenantId = (_j = (_h = ctx.envInfo.state) === null || _h === void 0 ? void 0 : _h.get(constants_2.PluginNames.AAD)) === null || _j === void 0 ? void 0 : _j.get(constants_2.REMOTE_TENANT_ID);
976
- const envName = ctx.envInfo.envName;
977
- if (!envName) {
978
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), constants_2.SolutionSource, constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
979
- }
980
- const message = [
981
- { content: `Account to grant permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
982
- { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
983
- {
984
- content: `Starting grant permission for environment: `,
985
- color: teamsfx_api_1.Colors.BRIGHT_WHITE,
986
- },
987
- { content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
988
- { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
989
- { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
990
- ];
991
- (_k = ctx.ui) === null || _k === void 0 ? void 0 : _k.showMessage("info", message, false);
992
- }
993
- const results = await executor_1.executeConcurrently("", grantPermissionWithCtx);
994
- const permissions = [];
995
- const errors = [];
996
- for (const result of results) {
997
- if (result.isErr()) {
998
- errors.push(result);
999
- continue;
1000
- }
1001
- if (result && result.value) {
1002
- for (const res of result.value) {
1003
- permissions.push(res);
1004
- }
1005
- }
1006
- }
1007
- let errorMsg = "";
1008
- if (errors.length > 0) {
1009
- errorMsg += `Failed to grant permission for the below resources to user: ${email}.\n Resource details: \n`;
1010
- for (const fxError of errors) {
1011
- errorMsg += fxError.error.message + "\n";
1012
- }
1013
- }
1014
- if (((_l = ctx.answers) === null || _l === void 0 ? void 0 : _l.platform) === teamsfx_api_1.Platform.CLI) {
1015
- for (const permission of permissions) {
1016
- const message = [
1017
- { content: `${(_m = permission.roles) === null || _m === void 0 ? void 0 : _m.join(",")} `, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1018
- { content: "permission has been granted to ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1019
- { content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1020
- { content: ", Resource ID: ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1021
- { content: `${permission.resourceId}`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1022
- ];
1023
- (_o = ctx.ui) === null || _o === void 0 ? void 0 : _o.showMessage("info", message, false);
1024
- }
1025
- (_p = ctx.ui) === null || _p === void 0 ? void 0 : _p.showMessage("info", `\nSkip grant permission for Azure resources. You may want to handle that via Azure portal. `, false);
1026
- if (errorMsg) {
1027
- for (const fxError of errors) {
1028
- (_q = ctx.ui) === null || _q === void 0 ? void 0 : _q.showMessage("error", errorMsg, false);
1029
- }
1030
- }
1031
- }
1032
- if (errorMsg) {
1033
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.FailedToGrantPermission), ctx.telemetryReporter));
1034
- }
1035
- (_r = ctx.telemetryReporter) === null || _r === void 0 ? void 0 : _r.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.GrantPermission, {
1036
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1037
- [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1038
- });
1039
- return teamsfx_api_1.ok({
1040
- state: permissionInterface_1.CollaborationState.OK,
1041
- userInfo: userInfo,
1042
- permissions,
1043
- });
1044
- }
1045
- finally {
1046
- await (progressBar === null || progressBar === void 0 ? void 0 : progressBar.end(true));
1047
- this.runningState = SolutionRunningState.Idle;
1048
- }
924
+ return grantPermission_1.grantPermission({ apiVersion: 1, ctx });
1049
925
  }
1050
926
  async checkPermission(ctx) {
1051
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1052
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CheckPermissionStart, {
1053
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1054
- });
1055
- try {
1056
- const result = await this.getCurrentUserInfo(ctx);
1057
- if (result.isErr()) {
1058
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, result.error, ctx.telemetryReporter));
1059
- }
1060
- const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
1061
- if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
1062
- if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
1063
- (_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("warn", stateResult.message, false);
1064
- }
1065
- return teamsfx_api_1.ok({
1066
- state: stateResult.state,
1067
- message: stateResult.message,
1068
- });
1069
- }
1070
- const userInfo = result.value;
1071
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
1072
- this.AadPlugin,
1073
- this.AppStudioPlugin,
1074
- ]);
1075
- const checkPermissionWithCtx = pluginsWithCtx.map(([plugin, context]) => {
1076
- return [
1077
- (plugin === null || plugin === void 0 ? void 0 : plugin.checkPermission)
1078
- ? (ctx) => plugin.checkPermission.bind(plugin)(ctx, userInfo)
1079
- : undefined,
1080
- context,
1081
- plugin.name,
1082
- ];
1083
- });
1084
- if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.CLI) {
1085
- const aadAppTenantId = (_f = (_e = ctx.envInfo.state) === 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);
1086
- const envName = ctx.envInfo.envName;
1087
- if (!envName) {
1088
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), constants_2.SolutionSource, constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
1089
- }
1090
- const message = [
1091
- { content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1092
- { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1093
- {
1094
- content: `Starting check permission for environment: `,
1095
- color: teamsfx_api_1.Colors.BRIGHT_WHITE,
1096
- },
1097
- { content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1098
- { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1099
- { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1100
- ];
1101
- (_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", message, false);
1102
- }
1103
- const results = await executor_1.executeConcurrently("", checkPermissionWithCtx);
1104
- const permissions = [];
1105
- const errors = [];
1106
- for (const result of results) {
1107
- if (result.isErr()) {
1108
- errors.push(result);
1109
- continue;
1110
- }
1111
- if (result && result.value) {
1112
- for (const res of result.value) {
1113
- permissions.push(res);
1114
- }
1115
- }
1116
- }
1117
- let errorMsg = "";
1118
- if (errors.length > 0) {
1119
- errorMsg += `Failed to check permission for the below resources.\n Resource details: \n`;
1120
- for (const fxError of errors) {
1121
- errorMsg += fxError.error.message + "\n";
1122
- }
1123
- }
1124
- if (((_h = ctx.answers) === null || _h === void 0 ? void 0 : _h.platform) === teamsfx_api_1.Platform.CLI) {
1125
- for (const permission of permissions) {
1126
- const message = [
1127
- { content: `Resource ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1128
- { content: (_j = permission.resourceId) !== null && _j !== void 0 ? _j : "undefined", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1129
- { content: `, Resource Name: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1130
- { content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1131
- { content: `, Permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1132
- {
1133
- content: permission.roles ? permission.roles.toString() : "undefined" + "\n",
1134
- color: teamsfx_api_1.Colors.BRIGHT_MAGENTA,
1135
- },
1136
- ];
1137
- (_k = ctx.ui) === null || _k === void 0 ? void 0 : _k.showMessage("info", message, false);
1138
- }
1139
- }
1140
- if (errorMsg) {
1141
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.FailedToCheckPermission), ctx.telemetryReporter));
1142
- }
1143
- const aadPermission = permissions.find((permission) => permission.name === "Azure AD App");
1144
- const teamsAppPermission = permissions.find((permission) => permission.name === "Teams App");
1145
- (_l = ctx.telemetryReporter) === null || _l === void 0 ? void 0 : _l.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CheckPermission, {
1146
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1147
- [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1148
- [constants_2.SolutionTelemetryProperty.AadPermission]: (aadPermission === null || aadPermission === void 0 ? void 0 : aadPermission.roles)
1149
- ? aadPermission.roles.join(";")
1150
- : "undefined",
1151
- [constants_2.SolutionTelemetryProperty.TeamsAppPermission]: (teamsAppPermission === null || teamsAppPermission === void 0 ? void 0 : teamsAppPermission.roles)
1152
- ? teamsAppPermission.roles.join(";")
1153
- : "undefined",
1154
- });
1155
- return teamsfx_api_1.ok({
1156
- state: permissionInterface_1.CollaborationState.OK,
1157
- permissions,
1158
- });
1159
- }
1160
- finally {
1161
- this.runningState = SolutionRunningState.Idle;
1162
- }
927
+ return checkPermission_1.checkPermission({ apiVersion: 1, ctx });
1163
928
  }
1164
929
  async listAllCollaborators(ctx) {
1165
- var _a, _b, _c, _d, _e, _f;
1166
- try {
1167
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListAllCollaboratorsStart, {
1168
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1169
- });
1170
- const collaboratorsResult = {};
1171
- const envs = await __1.environmentManager.listEnvConfigs(ctx.root);
1172
- if (envs.isErr()) {
1173
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListAllCollaborators, envs.error, ctx.telemetryReporter));
1174
- }
1175
- const result = await this.getCurrentUserInfo(ctx);
1176
- if (result.isErr()) {
1177
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListAllCollaborators, result.error, ctx.telemetryReporter));
1178
- }
1179
- const userInfo = result.value;
1180
- for (const env of envs.value) {
1181
- try {
1182
- const envInfo = await __1.environmentManager.loadEnvInfo(ctx.root, ctx.cryptoProvider, env);
1183
- if (envInfo.isErr()) {
1184
- throw envInfo.error;
1185
- }
1186
- ctx.envInfo = envInfo.value;
1187
- const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
1188
- if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
1189
- if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
1190
- (_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("warn", stateResult.message, false);
1191
- }
1192
- collaboratorsResult[env] = {
1193
- state: stateResult.state,
1194
- message: stateResult.message,
1195
- };
1196
- continue;
1197
- }
1198
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
1199
- this.AppStudioPlugin,
1200
- this.AadPlugin,
1201
- ]);
1202
- const listCollaboratorWithCtx = pluginsWithCtx.map(([plugin, context]) => {
1203
- return [
1204
- (plugin === null || plugin === void 0 ? void 0 : plugin.listCollaborator)
1205
- ? (ctx) => plugin.listCollaborator.bind(plugin)(ctx, userInfo)
1206
- : undefined,
1207
- context,
1208
- plugin.name,
1209
- ];
1210
- });
1211
- const results = await executor_1.executeConcurrently("", listCollaboratorWithCtx);
1212
- const errors = [];
1213
- for (const result of results) {
1214
- if (result.isErr()) {
1215
- errors.push(result);
1216
- }
1217
- }
1218
- let errorMsg = "";
1219
- if (errors.length > 0) {
1220
- errorMsg += `Failed to list collaborator for the project.\n Error details: \n`;
1221
- for (const fxError of errors) {
1222
- errorMsg += fxError.error.message + "\n";
1223
- }
1224
- }
1225
- if (errorMsg) {
1226
- collaboratorsResult[env] = {
1227
- state: permissionInterface_1.CollaborationState.ERROR,
1228
- error: teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListAllCollaborators, teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.FailedToListCollaborator), ctx.telemetryReporter)),
1229
- };
1230
- continue;
1231
- }
1232
- const teamsAppOwners = results[0].isErr() ? [] : results[0].value;
1233
- const aadOwners = results[1].isErr() ? [] : results[1].value;
1234
- const collaborators = [];
1235
- for (const teamsAppOwner of teamsAppOwners) {
1236
- const aadOwner = aadOwners.find((owner) => owner.userObjectId === teamsAppOwner.userObjectId);
1237
- collaborators.push({
1238
- // For guest account, aadOwner.userPrincipalName will be user's email, and is easy to read.
1239
- userPrincipalName: (_e = (_d = aadOwner === null || aadOwner === void 0 ? void 0 : aadOwner.userPrincipalName) !== null && _d !== void 0 ? _d : teamsAppOwner.userPrincipalName) !== null && _e !== void 0 ? _e : teamsAppOwner.userObjectId,
1240
- userObjectId: teamsAppOwner.userObjectId,
1241
- isAadOwner: aadOwner ? true : false,
1242
- aadResourceId: aadOwner ? aadOwner.resourceId : undefined,
1243
- teamsAppResourceId: teamsAppOwner.resourceId,
1244
- });
1245
- }
1246
- const aadOwnerCount = collaborators.filter((collaborator) => collaborator.aadResourceId && collaborator.isAadOwner).length;
1247
- (_f = ctx.telemetryReporter) === null || _f === void 0 ? void 0 : _f.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListAllCollaborators, {
1248
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1249
- [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1250
- [constants_2.SolutionTelemetryProperty.CollaboratorCount]: collaborators.length.toString(),
1251
- [constants_2.SolutionTelemetryProperty.AadOwnerCount]: aadOwnerCount.toString(),
1252
- [constants_2.SolutionTelemetryProperty.Env]: tools_1.getHashedEnv(env),
1253
- });
1254
- collaboratorsResult[env] = {
1255
- collaborators: collaborators,
1256
- state: permissionInterface_1.CollaborationState.OK,
1257
- };
1258
- }
1259
- catch (error) {
1260
- collaboratorsResult[env] = {
1261
- state: permissionInterface_1.CollaborationState.ERROR,
1262
- error: teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListAllCollaborators, teamsfx_api_1.returnUserError(error, constants_2.SolutionSource, constants_2.SolutionError.FailedToListCollaborator), ctx.telemetryReporter)),
1263
- };
1264
- }
1265
- }
1266
- return teamsfx_api_1.ok(collaboratorsResult);
1267
- }
1268
- finally {
1269
- this.runningState = SolutionRunningState.Idle;
1270
- }
930
+ return listAllCollaborators_1.listAllCollaborators({ apiVersion: 1, ctx });
1271
931
  }
1272
932
  async listCollaborator(ctx) {
1273
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1274
- (_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaboratorStart, {
1275
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1276
- });
1277
- try {
1278
- const result = await this.getCurrentUserInfo(ctx);
1279
- if (result.isErr()) {
1280
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, result.error, ctx.telemetryReporter));
1281
- }
1282
- const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
1283
- if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
1284
- if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
1285
- (_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("warn", stateResult.message, false);
1286
- }
1287
- else if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.VSCode) {
1288
- (_e = ctx.logProvider) === null || _e === void 0 ? void 0 : _e.warning(stateResult.message);
1289
- }
1290
- return teamsfx_api_1.ok({
1291
- state: stateResult.state,
1292
- message: stateResult.message,
1293
- });
1294
- }
1295
- const userInfo = result.value;
1296
- const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
1297
- this.AppStudioPlugin,
1298
- this.AadPlugin,
1299
- ]);
1300
- const listCollaboratorWithCtx = pluginsWithCtx.map(([plugin, context]) => {
1301
- return [
1302
- (plugin === null || plugin === void 0 ? void 0 : plugin.listCollaborator)
1303
- ? (ctx) => plugin.listCollaborator.bind(plugin)(ctx, userInfo)
1304
- : undefined,
1305
- context,
1306
- plugin.name,
1307
- ];
1308
- });
1309
- const envName = ctx.envInfo.envName;
1310
- if (!envName) {
1311
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), constants_2.SolutionSource, constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
1312
- }
1313
- const results = await executor_1.executeConcurrently("", listCollaboratorWithCtx);
1314
- const errors = [];
1315
- for (const result of results) {
1316
- if (result.isErr()) {
1317
- errors.push(result);
1318
- }
1319
- }
1320
- let errorMsg = "";
1321
- if (errors.length > 0) {
1322
- errorMsg += `Failed to list collaborator for the project.\n Error details: \n`;
1323
- for (const fxError of errors) {
1324
- errorMsg += fxError.error.message + "\n";
1325
- }
1326
- }
1327
- if (errorMsg) {
1328
- return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, teamsfx_api_1.returnUserError(new Error(errorMsg), constants_2.SolutionSource, constants_2.SolutionError.FailedToListCollaborator), ctx.telemetryReporter));
1329
- }
1330
- const teamsAppOwners = results[0].isErr() ? [] : results[0].value;
1331
- const aadOwners = results[1].isErr() ? [] : results[1].value;
1332
- const collaborators = [];
1333
- const teamsAppId = (_g = (_f = teamsAppOwners[0]) === null || _f === void 0 ? void 0 : _f.resourceId) !== null && _g !== void 0 ? _g : "";
1334
- const aadAppId = (_j = (_h = aadOwners[0]) === null || _h === void 0 ? void 0 : _h.resourceId) !== null && _j !== void 0 ? _j : "";
1335
- const aadAppTenantId = (_l = (_k = ctx.envInfo.state) === null || _k === void 0 ? void 0 : _k.get(constants_2.PluginNames.AAD)) === null || _l === void 0 ? void 0 : _l.get(constants_2.REMOTE_TENANT_ID);
1336
- for (const teamsAppOwner of teamsAppOwners) {
1337
- const aadOwner = aadOwners.find((owner) => owner.userObjectId === teamsAppOwner.userObjectId);
1338
- collaborators.push({
1339
- // For guest account, aadOwner.userPrincipalName will be user's email, and is easy to read.
1340
- userPrincipalName: (_o = (_m = aadOwner === null || aadOwner === void 0 ? void 0 : aadOwner.userPrincipalName) !== null && _m !== void 0 ? _m : teamsAppOwner.userPrincipalName) !== null && _o !== void 0 ? _o : teamsAppOwner.userObjectId,
1341
- userObjectId: teamsAppOwner.userObjectId,
1342
- isAadOwner: aadOwner ? true : false,
1343
- aadResourceId: aadOwner ? aadOwner.resourceId : undefined,
1344
- teamsAppResourceId: teamsAppOwner.resourceId,
1345
- });
1346
- }
1347
- if (((_p = ctx.answers) === null || _p === void 0 ? void 0 : _p.platform) === teamsfx_api_1.Platform.CLI || ((_q = ctx.answers) === null || _q === void 0 ? void 0 : _q.platform) === teamsfx_api_1.Platform.VSCode) {
1348
- const message = [
1349
- { content: `Listing M365 permissions\n`, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1350
- { content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1351
- { content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1352
- {
1353
- content: `Starting list all teams app owners for environment: `,
1354
- color: teamsfx_api_1.Colors.BRIGHT_WHITE,
1355
- },
1356
- { content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1357
- { content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1358
- { content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1359
- { content: `M365 Teams App (ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1360
- { content: teamsAppId, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1361
- { content: `), SSO AAD App (ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1362
- { content: aadAppId, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
1363
- { content: `)\n`, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
1364
- ];
1365
- for (const collaborator of collaborators) {
1366
- message.push({ content: `Teams App Owner: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE }, { content: collaborator.userPrincipalName, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA }, { content: `. `, color: teamsfx_api_1.Colors.BRIGHT_WHITE });
1367
- if (!collaborator.isAadOwner) {
1368
- message.push({ content: `(Not owner of SSO AAD app)`, color: teamsfx_api_1.Colors.BRIGHT_YELLOW });
1369
- }
1370
- message.push({ content: "\n", color: teamsfx_api_1.Colors.BRIGHT_WHITE });
1371
- }
1372
- if (((_r = ctx.answers) === null || _r === void 0 ? void 0 : _r.platform) === teamsfx_api_1.Platform.CLI) {
1373
- (_s = ctx.ui) === null || _s === void 0 ? void 0 : _s.showMessage("info", message, false);
1374
- }
1375
- else if (((_t = ctx.answers) === null || _t === void 0 ? void 0 : _t.platform) === teamsfx_api_1.Platform.VSCode) {
1376
- (_u = ctx.logProvider) === null || _u === void 0 ? void 0 : _u.info(message);
1377
- }
1378
- }
1379
- const aadOwnerCount = collaborators.filter((collaborator) => collaborator.aadResourceId && collaborator.isAadOwner).length;
1380
- (_v = ctx.telemetryReporter) === null || _v === void 0 ? void 0 : _v.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaborator, {
1381
- [constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
1382
- [constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
1383
- [constants_2.SolutionTelemetryProperty.CollaboratorCount]: collaborators.length.toString(),
1384
- [constants_2.SolutionTelemetryProperty.AadOwnerCount]: aadOwnerCount.toString(),
1385
- [constants_2.SolutionTelemetryProperty.Env]: tools_1.getHashedEnv(envName),
1386
- });
1387
- return teamsfx_api_1.ok({
1388
- collaborators: collaborators,
1389
- state: permissionInterface_1.CollaborationState.OK,
1390
- });
1391
- }
1392
- finally {
1393
- this.runningState = SolutionRunningState.Idle;
1394
- }
1395
- }
1396
- async getCurrentUserInfo(ctx) {
1397
- const user = await this.getUserInfo(ctx);
1398
- if (!user) {
1399
- return teamsfx_api_1.err(teamsfx_api_1.returnSystemError(new Error("Failed to retrieve current user info from graph token"), constants_2.SolutionSource, constants_2.SolutionError.FailedToRetrieveUserInfo));
1400
- }
1401
- return teamsfx_api_1.ok(user);
1402
- }
1403
- getCurrentCollaborationState(ctx, user) {
1404
- var _a, _b;
1405
- const canProcess = this.checkWhetherSolutionIsIdle();
1406
- if (canProcess.isErr()) {
1407
- return {
1408
- state: permissionInterface_1.CollaborationState.SolutionIsNotIdle,
1409
- message: canProcess.error.message,
1410
- };
1411
- }
1412
- const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.state);
1413
- if (!provisioned) {
1414
- const warningMsg = "The resources have not been provisioned yet. Please provision the resources first.";
1415
- return {
1416
- state: permissionInterface_1.CollaborationState.NotProvisioned,
1417
- message: warningMsg,
1418
- };
1419
- }
1420
- const aadAppTenantId = (_b = (_a = ctx.envInfo.state) === 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);
1421
- if (!aadAppTenantId || user.tenantId != aadAppTenantId) {
1422
- const warningMsg = "Tenant id of your account and the provisioned Azure AD app does not match. Please check whether you logined with wrong account.";
1423
- return {
1424
- state: permissionInterface_1.CollaborationState.M365TenantNotMatch,
1425
- message: warningMsg,
1426
- };
1427
- }
1428
- return {
1429
- state: permissionInterface_1.CollaborationState.OK,
1430
- };
933
+ return listCollaborator_1.listCollaborator({ apiVersion: 1, ctx });
1431
934
  }
1432
935
  loadTeamsAppTenantId(ctx, isLocalDebug, appStudioToken) {
1433
936
  return utils_1.parseTeamsAppTenantId(appStudioToken).andThen((teamsAppTenantId) => {
@@ -1461,10 +964,12 @@ let TeamsAppSolution = class TeamsAppSolution {
1461
964
  const functionPlugin = this.FunctionPlugin;
1462
965
  const sqlPlugin = this.SqlPlugin;
1463
966
  const apimPlugin = this.ApimPlugin;
967
+ const keyVaultPlugin = this.KeyVaultPlugin;
1464
968
  const alreadyHaveFunction = selectedPlugins.includes(functionPlugin.name);
1465
969
  const alreadyHaveSQL = selectedPlugins.includes(sqlPlugin.name);
1466
970
  const alreadyHaveAPIM = selectedPlugins.includes(apimPlugin.name);
1467
- const addQuestion = question_1.createAddAzureResourceQuestion(alreadyHaveFunction, alreadyHaveSQL, alreadyHaveAPIM);
971
+ const alreadyHavekeyVault = selectedPlugins.includes(keyVaultPlugin.name);
972
+ const addQuestion = question_1.createAddAzureResourceQuestion(alreadyHaveFunction, alreadyHaveSQL, alreadyHaveAPIM, alreadyHavekeyVault);
1468
973
  const addAzureResourceNode = new teamsfx_api_1.QTreeNode(addQuestion);
1469
974
  // there two cases to add function re-scaffold: 1. select add function 2. select add sql and function is not selected when creating
1470
975
  if (functionPlugin.getQuestionsForUserTask) {
@@ -1480,7 +985,9 @@ let TeamsAppSolution = class TeamsAppSolution {
1480
985
  }
1481
986
  else {
1482
987
  // if not function activated, select any option will trigger function question
1483
- azure_function.condition = { minItems: 1 };
988
+ azure_function.condition = {
989
+ containsAny: [question_1.AzureResourceApim.id, question_1.AzureResourceFunction.id, question_1.AzureResourceSQL.id],
990
+ };
1484
991
  }
1485
992
  if (azure_function.data)
1486
993
  addAzureResourceNode.addChild(azure_function);
@@ -1622,9 +1129,11 @@ let TeamsAppSolution = class TeamsAppSolution {
1622
1129
  const functionPlugin = this.FunctionPlugin;
1623
1130
  const sqlPlugin = this.SqlPlugin;
1624
1131
  const apimPlugin = this.ApimPlugin;
1132
+ const keyVaultPlugin = this.KeyVaultPlugin;
1625
1133
  const alreadyHaveFunction = selectedPlugins === null || selectedPlugins === void 0 ? void 0 : selectedPlugins.includes(functionPlugin.name);
1626
1134
  const alreadyHaveSql = selectedPlugins === null || selectedPlugins === void 0 ? void 0 : selectedPlugins.includes(sqlPlugin.name);
1627
1135
  const alreadyHaveApim = selectedPlugins === null || selectedPlugins === void 0 ? void 0 : selectedPlugins.includes(apimPlugin.name);
1136
+ const alreadyHaveKeyVault = selectedPlugins === null || selectedPlugins === void 0 ? void 0 : selectedPlugins.includes(keyVaultPlugin.name);
1628
1137
  const addResourcesAnswer = ctx.answers[question_1.AzureSolutionQuestionNames.AddResources];
1629
1138
  if (!addResourcesAnswer) {
1630
1139
  return teamsfx_api_1.err(teamsfx_api_1.returnUserError(new Error(`answer of ${question_1.AzureSolutionQuestionNames.AddResources} is empty!`), constants_2.SolutionSource, constants_2.SolutionError.InvalidInput));
@@ -1632,49 +1141,63 @@ let TeamsAppSolution = class TeamsAppSolution {
1632
1141
  const addSQL = addResourcesAnswer.includes(question_1.AzureResourceSQL.id);
1633
1142
  const addFunc = addResourcesAnswer.includes(question_1.AzureResourceFunction.id);
1634
1143
  const addApim = addResourcesAnswer.includes(question_1.AzureResourceApim.id);
1635
- if ((alreadyHaveSql && addSQL) || (alreadyHaveApim && addApim)) {
1636
- const e = teamsfx_api_1.returnUserError(new Error("SQL/APIM is already added."), constants_2.SolutionSource, constants_2.SolutionError.AddResourceNotSupport);
1144
+ const addKeyVault = addResourcesAnswer.includes(question_1.AzureResourceKeyVault.id);
1145
+ if ((alreadyHaveSql && addSQL) ||
1146
+ (alreadyHaveApim && addApim) ||
1147
+ (alreadyHaveKeyVault && addKeyVault)) {
1148
+ const e = teamsfx_api_1.returnUserError(new Error("SQL/APIM/KeyVault is already added."), constants_2.SolutionSource, constants_2.SolutionError.AddResourceNotSupport);
1637
1149
  return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddResource, e, ctx.telemetryReporter));
1638
1150
  }
1639
- let addNewResoruceToProvision = false;
1151
+ let addNewResourceToProvision = false;
1640
1152
  const notifications = [];
1641
1153
  const pluginsToScaffold = [this.LocalDebugPlugin];
1154
+ const pluginsToDoArm = [];
1642
1155
  const azureResource = Array.from(settings.azureResources || []);
1643
1156
  if (addFunc || ((addSQL || addApim) && !alreadyHaveFunction)) {
1644
1157
  pluginsToScaffold.push(functionPlugin);
1645
1158
  if (!azureResource.includes(question_1.AzureResourceFunction.id)) {
1646
1159
  azureResource.push(question_1.AzureResourceFunction.id);
1647
- addNewResoruceToProvision = true;
1160
+ addNewResourceToProvision = true;
1161
+ pluginsToDoArm.push(functionPlugin);
1648
1162
  }
1649
1163
  notifications.push(question_1.AzureResourceFunction.label);
1650
1164
  }
1651
1165
  if (addSQL && !alreadyHaveSql) {
1652
1166
  pluginsToScaffold.push(sqlPlugin);
1167
+ pluginsToDoArm.push(sqlPlugin);
1653
1168
  azureResource.push(question_1.AzureResourceSQL.id);
1654
1169
  notifications.push(question_1.AzureResourceSQL.label);
1655
- addNewResoruceToProvision = true;
1170
+ addNewResourceToProvision = true;
1656
1171
  }
1657
1172
  if (addApim && !alreadyHaveApim) {
1658
1173
  pluginsToScaffold.push(apimPlugin);
1174
+ pluginsToDoArm.push(apimPlugin);
1659
1175
  azureResource.push(question_1.AzureResourceApim.id);
1660
1176
  notifications.push(question_1.AzureResourceApim.label);
1661
- addNewResoruceToProvision = true;
1177
+ addNewResourceToProvision = true;
1178
+ }
1179
+ if (addKeyVault && !alreadyHaveKeyVault) {
1180
+ pluginsToScaffold.push(keyVaultPlugin);
1181
+ pluginsToDoArm.push(keyVaultPlugin);
1182
+ azureResource.push(question_1.AzureResourceKeyVault.id);
1183
+ notifications.push(question_1.AzureResourceKeyVault.label);
1184
+ addNewResourceToProvision = true;
1662
1185
  }
1663
1186
  if (notifications.length > 0) {
1664
- if (tools_1.isArmSupportEnabled() && addNewResoruceToProvision) {
1187
+ if (tools_1.isArmSupportEnabled() && addNewResourceToProvision) {
1665
1188
  executeUserTask_1.showUpdateArmTemplateNotice(ctx.ui);
1666
1189
  }
1667
1190
  settings.azureResources = azureResource;
1668
1191
  await this.reloadPlugins(settings);
1669
1192
  (_b = ctx.logProvider) === null || _b === void 0 ? void 0 : _b.info(`start scaffolding ${notifications.join(",")}.....`);
1670
- const scaffoldRes = await this.doScaffold(ctx, pluginsToScaffold, addNewResoruceToProvision);
1193
+ const scaffoldRes = await this.doScaffold(ctx, pluginsToScaffold, addNewResourceToProvision, pluginsToDoArm);
1671
1194
  if (scaffoldRes.isErr()) {
1672
1195
  (_c = ctx.logProvider) === null || _c === void 0 ? void 0 : _c.info(`failed to scaffold ${notifications.join(",")}!`);
1673
1196
  ctx.projectSettings.solutionSettings = originalSettings;
1674
1197
  return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.AddResource, scaffoldRes.error, ctx.telemetryReporter));
1675
1198
  }
1676
1199
  (_d = ctx.logProvider) === null || _d === void 0 ? void 0 : _d.info(`finish scaffolding ${notifications.join(",")}!`);
1677
- if (addNewResoruceToProvision)
1200
+ if (addNewResourceToProvision)
1678
1201
  (_e = ctx.envInfo.state.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
1679
1202
  (_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", util.format(ctx.answers.platform === teamsfx_api_1.Platform.CLI
1680
1203
  ? tools_1.getStrings().solution.AddResourceNoticeForCli
@@ -1974,44 +1497,6 @@ let TeamsAppSolution = class TeamsAppSolution {
1974
1497
  applicationIdUri: configResult.value.applicationIdUri,
1975
1498
  });
1976
1499
  }
1977
- async getUserInfo(ctx, email) {
1978
- var _a, _b;
1979
- const currentUser = await ((_a = ctx.graphTokenProvider) === null || _a === void 0 ? void 0 : _a.getJsonObject());
1980
- if (!currentUser) {
1981
- return undefined;
1982
- }
1983
- const tenantId = currentUser["tid"];
1984
- let aadId = currentUser["oid"];
1985
- let userPrincipalName = currentUser["unique_name"];
1986
- let displayName = currentUser["name"];
1987
- const isAdministrator = true;
1988
- if (email) {
1989
- const graphToken = await ((_b = ctx.graphTokenProvider) === null || _b === void 0 ? void 0 : _b.getAccessToken());
1990
- const instance = axios_1.default.create({
1991
- baseURL: "https://graph.microsoft.com/v1.0",
1992
- });
1993
- instance.defaults.headers.common["Authorization"] = `Bearer ${graphToken}`;
1994
- const res = await instance.get(`/users?$filter=startsWith(mail,'${email}') or startsWith(userPrincipalName, '${email}')`);
1995
- if (!res || !res.data || !res.data.value) {
1996
- return undefined;
1997
- }
1998
- const collaborator = res.data.value.find((user) => user.mail.toLowerCase() === email.toLowerCase() ||
1999
- user.userPrincipalName.toLowerCase() === email.toLowerCase());
2000
- if (!collaborator) {
2001
- return undefined;
2002
- }
2003
- aadId = collaborator.id;
2004
- userPrincipalName = collaborator.userPrincipalName;
2005
- displayName = collaborator.displayName;
2006
- }
2007
- return {
2008
- tenantId,
2009
- aadId,
2010
- userPrincipalName,
2011
- displayName,
2012
- isAdministrator,
2013
- };
2014
- }
2015
1500
  };
2016
1501
  tslib_1.__decorate([
2017
1502
  lib_1.hooks([errorHandler_1.ErrorHandlerMW]),