@microsoft/teamsfx-core 0.8.0 → 0.8.1-alpha.249dee5b.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.
- package/build/common/index.d.ts +1 -0
- package/build/common/index.d.ts.map +1 -1
- package/build/common/index.js +1 -0
- package/build/common/index.js.map +1 -1
- package/build/common/permissionInterface.d.ts +20 -0
- package/build/common/permissionInterface.d.ts.map +1 -1
- package/build/common/permissionInterface.js +8 -0
- package/build/common/permissionInterface.js.map +1 -1
- package/build/common/tools.d.ts +3 -1
- package/build/common/tools.d.ts.map +1 -1
- package/build/common/tools.js +14 -1
- package/build/common/tools.js.map +1 -1
- package/build/core/environment.d.ts +1 -0
- package/build/core/environment.d.ts.map +1 -1
- package/build/core/environment.js +13 -2
- package/build/core/environment.js.map +1 -1
- package/build/core/error.d.ts +4 -2
- package/build/core/error.d.ts.map +1 -1
- package/build/core/error.js +5 -3
- package/build/core/error.js.map +1 -1
- package/build/core/index.d.ts +6 -10
- package/build/core/index.d.ts.map +1 -1
- package/build/core/index.js +121 -98
- package/build/core/index.js.map +1 -1
- package/build/core/middleware/envInfoLoader.d.ts +1 -2
- package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
- package/build/core/middleware/envInfoLoader.js +77 -60
- package/build/core/middleware/envInfoLoader.js.map +1 -1
- package/build/core/middleware/envInfoWriter.d.ts +1 -1
- package/build/core/middleware/envInfoWriter.d.ts.map +1 -1
- package/build/core/middleware/envInfoWriter.js +5 -5
- package/build/core/middleware/envInfoWriter.js.map +1 -1
- package/build/core/middleware/errorHandler.d.ts.map +1 -1
- package/build/core/middleware/errorHandler.js +2 -1
- package/build/core/middleware/errorHandler.js.map +1 -1
- package/build/core/middleware/projectMigrator.d.ts.map +1 -1
- package/build/core/middleware/projectMigrator.js +30 -3
- package/build/core/middleware/projectMigrator.js.map +1 -1
- package/build/core/middleware/projectSettingsLoader.js +1 -1
- package/build/core/middleware/projectSettingsLoader.js.map +1 -1
- package/build/core/middleware/questionModel.d.ts.map +1 -1
- package/build/core/middleware/questionModel.js +10 -10
- package/build/core/middleware/questionModel.js.map +1 -1
- package/build/plugins/resource/aad/index.d.ts +2 -2
- package/build/plugins/resource/aad/index.d.ts.map +1 -1
- package/build/plugins/resource/aad/index.js +4 -4
- package/build/plugins/resource/aad/index.js.map +1 -1
- package/build/plugins/resource/aad/plugin.d.ts +3 -2
- package/build/plugins/resource/aad/plugin.d.ts.map +1 -1
- package/build/plugins/resource/aad/plugin.js +4 -4
- package/build/plugins/resource/aad/plugin.js.map +1 -1
- package/build/plugins/resource/aad/utils/configs.d.ts +0 -1
- package/build/plugins/resource/aad/utils/configs.d.ts.map +1 -1
- package/build/plugins/resource/aad/utils/configs.js +1 -11
- package/build/plugins/resource/aad/utils/configs.js.map +1 -1
- package/build/plugins/resource/aad/utils/tokenProvider.d.ts.map +1 -1
- package/build/plugins/resource/aad/utils/tokenProvider.js +1 -1
- package/build/plugins/resource/aad/utils/tokenProvider.js.map +1 -1
- package/build/plugins/resource/aad/v2/index.d.ts +1 -1
- package/build/plugins/resource/aad/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/aad/v2/index.js +2 -2
- package/build/plugins/resource/aad/v2/index.js.map +1 -1
- package/build/plugins/resource/apim/v2/index.d.ts +4 -2
- package/build/plugins/resource/apim/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/apim/v2/index.js +21 -23
- package/build/plugins/resource/apim/v2/index.js.map +1 -1
- package/build/plugins/resource/appstudio/errors.d.ts +1 -1
- package/build/plugins/resource/appstudio/errors.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/errors.js +5 -1
- package/build/plugins/resource/appstudio/errors.js.map +1 -1
- package/build/plugins/resource/appstudio/index.d.ts +2 -2
- package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/index.js +6 -5
- package/build/plugins/resource/appstudio/index.js.map +1 -1
- package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts +1 -0
- package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/plugin.d.ts +3 -3
- package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/plugin.js +21 -45
- package/build/plugins/resource/appstudio/plugin.js.map +1 -1
- package/build/plugins/resource/appstudio/utils/telemetry.d.ts +2 -1
- package/build/plugins/resource/appstudio/utils/telemetry.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/utils/telemetry.js +1 -0
- package/build/plugins/resource/appstudio/utils/telemetry.js.map +1 -1
- package/build/plugins/resource/appstudio/v2/index.d.ts +5 -5
- package/build/plugins/resource/appstudio/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/appstudio/v2/index.js +17 -17
- package/build/plugins/resource/appstudio/v2/index.js.map +1 -1
- package/build/plugins/resource/bot/v2/index.d.ts +2 -2
- package/build/plugins/resource/bot/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/bot/v2/index.js +3 -3
- package/build/plugins/resource/bot/v2/index.js.map +1 -1
- package/build/plugins/resource/frontend/v2/index.d.ts +2 -1
- package/build/plugins/resource/frontend/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/frontend/v2/index.js +3 -0
- package/build/plugins/resource/frontend/v2/index.js.map +1 -1
- package/build/plugins/resource/function/v2/index.d.ts +4 -3
- package/build/plugins/resource/function/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/function/v2/index.js +5 -13
- package/build/plugins/resource/function/v2/index.js.map +1 -1
- package/build/plugins/resource/identity/index.d.ts +2 -0
- package/build/plugins/resource/identity/index.d.ts.map +1 -1
- package/build/plugins/resource/identity/index.js +14 -6
- package/build/plugins/resource/identity/index.js.map +1 -1
- package/build/plugins/resource/identity/utils/contextUtils.d.ts +1 -3
- package/build/plugins/resource/identity/utils/contextUtils.d.ts.map +1 -1
- package/build/plugins/resource/identity/utils/contextUtils.js +2 -5
- package/build/plugins/resource/identity/utils/contextUtils.js.map +1 -1
- package/build/plugins/resource/localdebug/constants.d.ts +4 -0
- package/build/plugins/resource/localdebug/constants.d.ts.map +1 -1
- package/build/plugins/resource/localdebug/constants.js +6 -1
- package/build/plugins/resource/localdebug/constants.js.map +1 -1
- package/build/plugins/resource/localdebug/index.d.ts.map +1 -1
- package/build/plugins/resource/localdebug/index.js +8 -5
- package/build/plugins/resource/localdebug/index.js.map +1 -1
- package/build/plugins/resource/localdebug/v2/index.d.ts +2 -2
- package/build/plugins/resource/localdebug/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/localdebug/v2/index.js +2 -2
- package/build/plugins/resource/localdebug/v2/index.js.map +1 -1
- package/build/plugins/resource/sql/config.d.ts +1 -0
- package/build/plugins/resource/sql/config.d.ts.map +1 -1
- package/build/plugins/resource/sql/config.js +1 -0
- package/build/plugins/resource/sql/config.js.map +1 -1
- package/build/plugins/resource/sql/constants.d.ts +3 -0
- package/build/plugins/resource/sql/constants.d.ts.map +1 -1
- package/build/plugins/resource/sql/constants.js +3 -0
- package/build/plugins/resource/sql/constants.js.map +1 -1
- package/build/plugins/resource/sql/errors.d.ts +4 -0
- package/build/plugins/resource/sql/errors.d.ts.map +1 -1
- package/build/plugins/resource/sql/errors.js +4 -0
- package/build/plugins/resource/sql/errors.js.map +1 -1
- package/build/plugins/resource/sql/plugin.d.ts +4 -1
- package/build/plugins/resource/sql/plugin.d.ts.map +1 -1
- package/build/plugins/resource/sql/plugin.js +62 -16
- package/build/plugins/resource/sql/plugin.js.map +1 -1
- package/build/plugins/resource/sql/utils/contextUtils.d.ts +1 -3
- package/build/plugins/resource/sql/utils/contextUtils.d.ts.map +1 -1
- package/build/plugins/resource/sql/utils/contextUtils.js +2 -5
- package/build/plugins/resource/sql/utils/contextUtils.js.map +1 -1
- package/build/plugins/resource/sql/v2/index.d.ts +3 -2
- package/build/plugins/resource/sql/v2/index.d.ts.map +1 -1
- package/build/plugins/resource/sql/v2/index.js +14 -12
- package/build/plugins/resource/sql/v2/index.js.map +1 -1
- package/build/plugins/resource/utils4v2.d.ts +5 -3
- package/build/plugins/resource/utils4v2.d.ts.map +1 -1
- package/build/plugins/resource/utils4v2.js +38 -7
- package/build/plugins/resource/utils4v2.js.map +1 -1
- package/build/plugins/solution/fx-solution/ResourcePluginContainer.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/ResourcePluginContainer.js +4 -2
- package/build/plugins/solution/fx-solution/ResourcePluginContainer.js.map +1 -1
- package/build/plugins/solution/fx-solution/arm.d.ts +0 -1
- package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/arm.js +2 -6
- package/build/plugins/solution/fx-solution/arm.js.map +1 -1
- package/build/plugins/solution/fx-solution/commonQuestions.d.ts +2 -2
- package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/commonQuestions.js +46 -29
- package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
- package/build/plugins/solution/fx-solution/constants.d.ts +3 -6
- package/build/plugins/solution/fx-solution/constants.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/constants.js +3 -6
- package/build/plugins/solution/fx-solution/constants.js.map +1 -1
- package/build/plugins/solution/fx-solution/executor.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/executor.js +39 -21
- package/build/plugins/solution/fx-solution/executor.js.map +1 -1
- package/build/plugins/solution/fx-solution/index.d.ts +1 -0
- package/build/plugins/solution/fx-solution/index.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/index.js +1 -0
- package/build/plugins/solution/fx-solution/index.js.map +1 -1
- package/build/plugins/solution/fx-solution/solution.d.ts +6 -5
- package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/solution.js +226 -119
- package/build/plugins/solution/fx-solution/solution.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/createEnv.js +11 -1
- package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts +2 -2
- package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/executeUserTask.js +23 -10
- package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/executor.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/executor.js +9 -1
- package/build/plugins/solution/fx-solution/v2/executor.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js +8 -2
- package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts +5 -1
- package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/getQuestions.js +287 -1
- package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/package.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/package.js +2 -1
- package/build/plugins/solution/fx-solution/v2/package.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/provision.js +4 -12
- package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/provisionLocal.js +2 -1
- package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/publish.d.ts +2 -2
- package/build/plugins/solution/fx-solution/v2/publish.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/publish.js +9 -9
- package/build/plugins/solution/fx-solution/v2/publish.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/scaffolding.js +4 -0
- package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/solution.d.ts +6 -4
- package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/solution.js +2 -0
- package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -1
- package/build/plugins/solution/fx-solution/v2/utils.d.ts +1 -0
- package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
- package/build/plugins/solution/fx-solution/v2/utils.js +5 -1
- package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
- package/package.json +3 -3
- package/resource/strings.json +2 -2
- package/templates/plugins/resource/bot/bot-msgext.js.default.zip +0 -0
- package/templates/plugins/resource/bot/bot-msgext.ts.default.zip +0 -0
- package/templates/plugins/resource/bot/bot.js.default.zip +0 -0
- package/templates/plugins/resource/bot/bot.ts.default.zip +0 -0
- package/templates/plugins/resource/bot/msgext.js.default.zip +0 -0
- package/templates/plugins/resource/bot/msgext.ts.default.zip +0 -0
- package/templates/plugins/resource/frontend/tab.js.default.zip +0 -0
- package/templates/plugins/resource/frontend/tab.ts.default.zip +0 -0
- package/templates/plugins/resource/function/function-base.js.default.zip +0 -0
- package/templates/plugins/resource/function/function-base.ts.default.zip +0 -0
- package/templates/plugins/resource/function/function-triggers.js.HTTPTrigger.zip +0 -0
- package/templates/plugins/resource/function/function-triggers.ts.HTTPTrigger.zip +0 -0
- package/templates/plugins/resource/sql/bicep/output.template.bicep +1 -0
- package/templates/plugins/resource/sql/bicep/sql.template.bicep +3 -2
|
@@ -18,6 +18,7 @@ const typedi_1 = require("typedi");
|
|
|
18
18
|
const util = tslib_1.__importStar(require("util"));
|
|
19
19
|
const constants_1 = require("../../../common/constants");
|
|
20
20
|
const localSettingsConstants_1 = require("../../../common/localSettingsConstants");
|
|
21
|
+
const permissionInterface_1 = require("../../../common/permissionInterface");
|
|
21
22
|
const tools_1 = require("../../../common/tools");
|
|
22
23
|
const core_1 = require("../../../core");
|
|
23
24
|
const errorHandler_1 = require("../../../core/middleware/errorHandler");
|
|
@@ -795,82 +796,113 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
795
796
|
}
|
|
796
797
|
async localDebug(ctx) {
|
|
797
798
|
var _a;
|
|
798
|
-
|
|
799
|
-
if (ctx
|
|
800
|
-
ctx.permissionRequestProvider
|
|
799
|
+
try {
|
|
800
|
+
if (!this.spfxSelected(ctx)) {
|
|
801
|
+
if (ctx.permissionRequestProvider === undefined) {
|
|
802
|
+
ctx.permissionRequestProvider = new permissionRequest_1.PermissionRequestFileProvider(ctx.root);
|
|
803
|
+
}
|
|
804
|
+
const result = await utils_1.ensurePermissionRequest((_a = ctx.projectSettings) === null || _a === void 0 ? void 0 : _a.solutionSettings, ctx.permissionRequestProvider);
|
|
805
|
+
if (result.isErr()) {
|
|
806
|
+
return result;
|
|
807
|
+
}
|
|
801
808
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
809
|
+
}
|
|
810
|
+
catch (e) {
|
|
811
|
+
if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
|
|
812
|
+
return teamsfx_api_1.err(e);
|
|
805
813
|
}
|
|
814
|
+
return teamsfx_api_1.err(new teamsfx_api_1.SystemError("UnknownError", "check point 1 - " + JSON.stringify(e), "Solution"));
|
|
806
815
|
}
|
|
807
816
|
return await this.doLocalDebug(ctx);
|
|
808
817
|
}
|
|
809
818
|
async doLocalDebug(ctx) {
|
|
810
819
|
var _a, _b;
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
method: "setApplicationInContext",
|
|
841
|
-
params: { isLocal: true },
|
|
842
|
-
}, util_1.getPluginContext(ctx, aadPlugin.name));
|
|
843
|
-
if (result.isErr()) {
|
|
844
|
-
return result;
|
|
820
|
+
let checkPoint = 1;
|
|
821
|
+
try {
|
|
822
|
+
//check point 2
|
|
823
|
+
const maybeSelectedPlugins = this.getSelectedPlugins(ctx);
|
|
824
|
+
if (maybeSelectedPlugins.isErr()) {
|
|
825
|
+
return maybeSelectedPlugins;
|
|
826
|
+
}
|
|
827
|
+
const selectedPlugins = maybeSelectedPlugins.value;
|
|
828
|
+
checkPoint = 2;
|
|
829
|
+
//check point 3
|
|
830
|
+
// Just to trigger M365 login before the concurrent execution of localDebug.
|
|
831
|
+
// Because concurrent exectution of localDebug may getAccessToken() concurrently, which
|
|
832
|
+
// causes 2 M365 logins before the token caching in common lib takes effect.
|
|
833
|
+
await ((_a = ctx.appStudioToken) === null || _a === void 0 ? void 0 : _a.getAccessToken());
|
|
834
|
+
checkPoint = 3;
|
|
835
|
+
//check point 4
|
|
836
|
+
const pluginsWithCtx = this.getPluginAndContextArray(ctx, selectedPlugins);
|
|
837
|
+
const localDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
|
|
838
|
+
var _a;
|
|
839
|
+
return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.localDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
|
|
840
|
+
});
|
|
841
|
+
const postLocalDebugWithCtx = pluginsWithCtx.map(([plugin, context]) => {
|
|
842
|
+
var _a;
|
|
843
|
+
return [(_a = plugin === null || plugin === void 0 ? void 0 : plugin.postLocalDebug) === null || _a === void 0 ? void 0 : _a.bind(plugin), context, plugin.name];
|
|
844
|
+
});
|
|
845
|
+
const localDebugResults = await executor_1.executeConcurrently("", localDebugWithCtx);
|
|
846
|
+
for (const localDebugResult of localDebugResults) {
|
|
847
|
+
if (localDebugResult.isErr()) {
|
|
848
|
+
return localDebugResult;
|
|
845
849
|
}
|
|
846
850
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (postLocalDebugWithCtx.length === combinedPostLocalDebugResults.value.length) {
|
|
860
|
-
postLocalDebugWithCtx.map(function (plugin, index) {
|
|
861
|
-
var _a, _b;
|
|
862
|
-
if (plugin[2] === constants_2.PluginNames.APPST) {
|
|
863
|
-
if (tools_1.isMultiEnvEnabled()) {
|
|
864
|
-
(_a = ctx.localSettings) === null || _a === void 0 ? void 0 : _a.teamsApp.set(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TeamsAppId, combinedPostLocalDebugResults.value[index]);
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
(_b = ctx.envInfo.profile
|
|
868
|
-
.get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_2.LOCAL_DEBUG_TEAMS_APP_ID, combinedPostLocalDebugResults.value[index]);
|
|
851
|
+
checkPoint = 4;
|
|
852
|
+
//check point 5
|
|
853
|
+
if (!this.spfxSelected(ctx)) {
|
|
854
|
+
const aadPlugin = this.AadPlugin;
|
|
855
|
+
if (selectedPlugins.some((plugin) => plugin.name === aadPlugin.name)) {
|
|
856
|
+
const result = await aadPlugin.executeUserTask({
|
|
857
|
+
namespace: `${constants_2.PluginNames.SOLUTION}/${constants_2.PluginNames.AAD}`,
|
|
858
|
+
method: "setApplicationInContext",
|
|
859
|
+
params: { isLocal: true },
|
|
860
|
+
}, util_1.getPluginContext(ctx, aadPlugin.name));
|
|
861
|
+
if (result.isErr()) {
|
|
862
|
+
return result;
|
|
869
863
|
}
|
|
870
864
|
}
|
|
871
|
-
}
|
|
865
|
+
}
|
|
866
|
+
checkPoint = 5;
|
|
867
|
+
// check point 6
|
|
868
|
+
// set local debug Teams app tenant id in context.
|
|
869
|
+
const result = this.loadTeamsAppTenantId(ctx, true, await ((_b = ctx.appStudioToken) === null || _b === void 0 ? void 0 : _b.getJsonObject()));
|
|
870
|
+
if (result.isErr()) {
|
|
871
|
+
return result;
|
|
872
|
+
}
|
|
873
|
+
checkPoint = 6;
|
|
874
|
+
//check point 7
|
|
875
|
+
const postLocalDebugResults = await executor_1.executeConcurrently("post", postLocalDebugWithCtx);
|
|
876
|
+
const combinedPostLocalDebugResults = teamsfx_api_1.combine(postLocalDebugResults);
|
|
877
|
+
if (combinedPostLocalDebugResults.isErr()) {
|
|
878
|
+
return combinedPostLocalDebugResults;
|
|
879
|
+
}
|
|
880
|
+
checkPoint = 7;
|
|
881
|
+
//check point 8
|
|
882
|
+
// set local debug Teams app id in context.
|
|
883
|
+
if (postLocalDebugWithCtx.length === combinedPostLocalDebugResults.value.length) {
|
|
884
|
+
postLocalDebugWithCtx.map(function (plugin, index) {
|
|
885
|
+
var _a, _b;
|
|
886
|
+
if (plugin[2] === constants_2.PluginNames.APPST) {
|
|
887
|
+
if (tools_1.isMultiEnvEnabled()) {
|
|
888
|
+
(_a = ctx.localSettings) === null || _a === void 0 ? void 0 : _a.teamsApp.set(localSettingsConstants_1.LocalSettingsTeamsAppKeys.TeamsAppId, combinedPostLocalDebugResults.value[index]);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
(_b = ctx.envInfo.profile
|
|
892
|
+
.get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_2.LOCAL_DEBUG_TEAMS_APP_ID, combinedPostLocalDebugResults.value[index]);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
checkPoint = 8;
|
|
898
|
+
return teamsfx_api_1.ok(constants_2.Void);
|
|
899
|
+
}
|
|
900
|
+
catch (e) {
|
|
901
|
+
if (e instanceof teamsfx_api_1.UserError || e instanceof teamsfx_api_1.SystemError) {
|
|
902
|
+
return teamsfx_api_1.err(e);
|
|
903
|
+
}
|
|
904
|
+
return teamsfx_api_1.err(new teamsfx_api_1.SystemError("UnknownError", `check point ${checkPoint} - ${JSON.stringify(e)}`, "Solution"));
|
|
872
905
|
}
|
|
873
|
-
return teamsfx_api_1.ok(constants_2.Void);
|
|
874
906
|
}
|
|
875
907
|
async grantPermission(ctx) {
|
|
876
908
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
@@ -879,10 +911,20 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
879
911
|
});
|
|
880
912
|
const progressBar = (_b = ctx.ui) === null || _b === void 0 ? void 0 : _b.createProgressBar("Granting permission", 1);
|
|
881
913
|
try {
|
|
882
|
-
const result = await this.
|
|
914
|
+
const result = await this.getCurrentUserInfo(ctx);
|
|
883
915
|
if (result.isErr()) {
|
|
884
916
|
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, result.error, ctx.telemetryReporter));
|
|
885
917
|
}
|
|
918
|
+
const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
|
|
919
|
+
if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
|
|
920
|
+
if (((_c = ctx.answers) === null || _c === void 0 ? void 0 : _c.platform) === teamsfx_api_1.Platform.CLI) {
|
|
921
|
+
(_d = ctx.ui) === null || _d === void 0 ? void 0 : _d.showMessage("warn", stateResult.message, false);
|
|
922
|
+
}
|
|
923
|
+
return teamsfx_api_1.ok({
|
|
924
|
+
state: stateResult.state,
|
|
925
|
+
message: stateResult.message,
|
|
926
|
+
});
|
|
927
|
+
}
|
|
886
928
|
const email = ctx.answers["email"];
|
|
887
929
|
if (!email || email === result.value.userPrincipalName) {
|
|
888
930
|
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));
|
|
@@ -893,17 +935,25 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
893
935
|
}
|
|
894
936
|
progressBar === null || progressBar === void 0 ? void 0 : progressBar.start();
|
|
895
937
|
progressBar === null || progressBar === void 0 ? void 0 : progressBar.next(`Grant permission for user ${email}`);
|
|
896
|
-
(_c = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _c === void 0 ? void 0 : _c.set(constants_2.USER_INFO, JSON.stringify(userInfo));
|
|
897
938
|
const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
|
|
898
939
|
this.AadPlugin,
|
|
899
940
|
this.AppStudioPlugin,
|
|
900
941
|
]);
|
|
901
942
|
const grantPermissionWithCtx = pluginsWithCtx.map(([plugin, context]) => {
|
|
902
|
-
|
|
903
|
-
|
|
943
|
+
return [
|
|
944
|
+
(plugin === null || plugin === void 0 ? void 0 : plugin.grantPermission)
|
|
945
|
+
? (ctx) => plugin.grantPermission.bind(plugin)(ctx, userInfo)
|
|
946
|
+
: undefined,
|
|
947
|
+
context,
|
|
948
|
+
plugin.name,
|
|
949
|
+
];
|
|
904
950
|
});
|
|
905
|
-
if (((
|
|
906
|
-
const aadAppTenantId = (
|
|
951
|
+
if (((_e = ctx.answers) === null || _e === void 0 ? void 0 : _e.platform) === teamsfx_api_1.Platform.CLI) {
|
|
952
|
+
const aadAppTenantId = (_g = (_f = ctx.envInfo.profile) === null || _f === void 0 ? void 0 : _f.get(constants_2.PluginNames.AAD)) === null || _g === void 0 ? void 0 : _g.get(constants_2.REMOTE_TENANT_ID);
|
|
953
|
+
const envName = ctx.envInfo.envName;
|
|
954
|
+
if (!envName) {
|
|
955
|
+
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.GrantPermission, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), "Solution", constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
|
|
956
|
+
}
|
|
907
957
|
const message = [
|
|
908
958
|
{ content: `Account to grant permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
909
959
|
{ content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
@@ -911,12 +961,11 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
911
961
|
content: `Starting grant permission for environment: `,
|
|
912
962
|
color: teamsfx_api_1.Colors.BRIGHT_WHITE,
|
|
913
963
|
},
|
|
914
|
-
|
|
915
|
-
{ content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
964
|
+
{ content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
916
965
|
{ content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
917
966
|
{ content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
918
967
|
];
|
|
919
|
-
(
|
|
968
|
+
(_h = ctx.ui) === null || _h === void 0 ? void 0 : _h.showMessage("info", message, false);
|
|
920
969
|
}
|
|
921
970
|
const results = await executor_1.executeConcurrently("", grantPermissionWithCtx);
|
|
922
971
|
const permissions = [];
|
|
@@ -939,36 +988,38 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
939
988
|
errorMsg += fxError.error.message + "\n";
|
|
940
989
|
}
|
|
941
990
|
}
|
|
942
|
-
if (((
|
|
991
|
+
if (((_j = ctx.answers) === null || _j === void 0 ? void 0 : _j.platform) === teamsfx_api_1.Platform.CLI) {
|
|
943
992
|
for (const permission of permissions) {
|
|
944
993
|
const message = [
|
|
945
|
-
{ content: `${(
|
|
994
|
+
{ content: `${(_k = permission.roles) === null || _k === void 0 ? void 0 : _k.join(",")} `, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
946
995
|
{ content: "permission has been granted to ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
947
996
|
{ content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
948
997
|
{ content: ", Resource ID: ", color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
949
998
|
{ content: `${permission.resourceId}`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
950
999
|
];
|
|
951
|
-
(
|
|
1000
|
+
(_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("info", message, false);
|
|
952
1001
|
}
|
|
953
|
-
(
|
|
1002
|
+
(_m = ctx.ui) === null || _m === void 0 ? void 0 : _m.showMessage("info", `\nSkip grant permission for Azure resources. You may want to handle that via Azure portal. `, false);
|
|
954
1003
|
if (errorMsg) {
|
|
955
1004
|
for (const fxError of errors) {
|
|
956
|
-
(
|
|
1005
|
+
(_o = ctx.ui) === null || _o === void 0 ? void 0 : _o.showMessage("error", errorMsg, false);
|
|
957
1006
|
}
|
|
958
1007
|
}
|
|
959
1008
|
}
|
|
960
1009
|
if (errorMsg) {
|
|
961
1010
|
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));
|
|
962
1011
|
}
|
|
963
|
-
(
|
|
1012
|
+
(_p = ctx.telemetryReporter) === null || _p === void 0 ? void 0 : _p.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.GrantPermission, {
|
|
964
1013
|
[constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
|
|
965
1014
|
[constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
|
|
966
1015
|
});
|
|
967
|
-
return teamsfx_api_1.ok(
|
|
1016
|
+
return teamsfx_api_1.ok({
|
|
1017
|
+
state: permissionInterface_1.CollaborationState.OK,
|
|
1018
|
+
permissions,
|
|
1019
|
+
});
|
|
968
1020
|
}
|
|
969
1021
|
finally {
|
|
970
1022
|
await (progressBar === null || progressBar === void 0 ? void 0 : progressBar.end(true));
|
|
971
|
-
(_p = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _p === void 0 ? void 0 : _p.delete(constants_2.USER_INFO);
|
|
972
1023
|
this.runningState = SolutionRunningState.Idle;
|
|
973
1024
|
}
|
|
974
1025
|
}
|
|
@@ -978,22 +1029,40 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
978
1029
|
[constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
|
|
979
1030
|
});
|
|
980
1031
|
try {
|
|
981
|
-
const result = await this.
|
|
1032
|
+
const result = await this.getCurrentUserInfo(ctx);
|
|
982
1033
|
if (result.isErr()) {
|
|
983
1034
|
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, result.error, ctx.telemetryReporter));
|
|
984
1035
|
}
|
|
1036
|
+
const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
|
|
1037
|
+
if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
|
|
1038
|
+
if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1039
|
+
(_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("warn", stateResult.message, false);
|
|
1040
|
+
}
|
|
1041
|
+
return teamsfx_api_1.ok({
|
|
1042
|
+
state: stateResult.state,
|
|
1043
|
+
message: stateResult.message,
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
985
1046
|
const userInfo = result.value;
|
|
986
|
-
(_b = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _b === void 0 ? void 0 : _b.set(constants_2.USER_INFO, JSON.stringify(userInfo));
|
|
987
1047
|
const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
|
|
988
1048
|
this.AadPlugin,
|
|
989
1049
|
this.AppStudioPlugin,
|
|
990
1050
|
]);
|
|
991
1051
|
const checkPermissionWithCtx = pluginsWithCtx.map(([plugin, context]) => {
|
|
992
|
-
|
|
993
|
-
|
|
1052
|
+
return [
|
|
1053
|
+
(plugin === null || plugin === void 0 ? void 0 : plugin.checkPermission)
|
|
1054
|
+
? (ctx) => plugin.checkPermission.bind(plugin)(ctx, userInfo)
|
|
1055
|
+
: undefined,
|
|
1056
|
+
context,
|
|
1057
|
+
plugin.name,
|
|
1058
|
+
];
|
|
994
1059
|
});
|
|
995
|
-
if (((
|
|
996
|
-
const aadAppTenantId = (
|
|
1060
|
+
if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1061
|
+
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);
|
|
1062
|
+
const envName = ctx.envInfo.envName;
|
|
1063
|
+
if (!envName) {
|
|
1064
|
+
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.CheckPermission, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), "Solution", constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
|
|
1065
|
+
}
|
|
997
1066
|
const message = [
|
|
998
1067
|
{ content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
999
1068
|
{ content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
@@ -1001,12 +1070,11 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1001
1070
|
content: `Starting check permission for environment: `,
|
|
1002
1071
|
color: teamsfx_api_1.Colors.BRIGHT_WHITE,
|
|
1003
1072
|
},
|
|
1004
|
-
|
|
1005
|
-
{ content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1073
|
+
{ content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1006
1074
|
{ content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
1007
1075
|
{ content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1008
1076
|
];
|
|
1009
|
-
(
|
|
1077
|
+
(_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", message, false);
|
|
1010
1078
|
}
|
|
1011
1079
|
const results = await executor_1.executeConcurrently("", checkPermissionWithCtx);
|
|
1012
1080
|
const permissions = [];
|
|
@@ -1029,11 +1097,11 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1029
1097
|
errorMsg += fxError.error.message + "\n";
|
|
1030
1098
|
}
|
|
1031
1099
|
}
|
|
1032
|
-
if (((
|
|
1100
|
+
if (((_h = ctx.answers) === null || _h === void 0 ? void 0 : _h.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1033
1101
|
for (const permission of permissions) {
|
|
1034
1102
|
const message = [
|
|
1035
1103
|
{ content: `Resource ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
1036
|
-
{ content: (
|
|
1104
|
+
{ content: (_j = permission.resourceId) !== null && _j !== void 0 ? _j : "undefined", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1037
1105
|
{ content: `, Resource Name: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
1038
1106
|
{ content: permission.name, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1039
1107
|
{ content: `, Permission: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
@@ -1042,7 +1110,7 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1042
1110
|
color: teamsfx_api_1.Colors.BRIGHT_MAGENTA,
|
|
1043
1111
|
},
|
|
1044
1112
|
];
|
|
1045
|
-
(
|
|
1113
|
+
(_k = ctx.ui) === null || _k === void 0 ? void 0 : _k.showMessage("info", message, false);
|
|
1046
1114
|
}
|
|
1047
1115
|
}
|
|
1048
1116
|
if (errorMsg) {
|
|
@@ -1050,7 +1118,7 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1050
1118
|
}
|
|
1051
1119
|
const aadPermission = permissions.find((permission) => permission.name === "Azure AD App");
|
|
1052
1120
|
const teamsAppPermission = permissions.find((permission) => permission.name === "Teams App");
|
|
1053
|
-
(
|
|
1121
|
+
(_l = ctx.telemetryReporter) === null || _l === void 0 ? void 0 : _l.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.CheckPermission, {
|
|
1054
1122
|
[constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
|
|
1055
1123
|
[constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
|
|
1056
1124
|
[constants_2.SolutionTelemetryProperty.AadPermission]: (aadPermission === null || aadPermission === void 0 ? void 0 : aadPermission.roles)
|
|
@@ -1060,34 +1128,55 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1060
1128
|
? teamsAppPermission.roles.join(";")
|
|
1061
1129
|
: "undefined",
|
|
1062
1130
|
});
|
|
1063
|
-
return teamsfx_api_1.ok(
|
|
1131
|
+
return teamsfx_api_1.ok({
|
|
1132
|
+
state: permissionInterface_1.CollaborationState.OK,
|
|
1133
|
+
permissions,
|
|
1134
|
+
});
|
|
1064
1135
|
}
|
|
1065
1136
|
finally {
|
|
1066
|
-
(_l = ctx.envInfo.profile.get(constants_2.GLOBAL_CONFIG)) === null || _l === void 0 ? void 0 : _l.delete(constants_2.USER_INFO);
|
|
1067
1137
|
this.runningState = SolutionRunningState.Idle;
|
|
1068
1138
|
}
|
|
1069
1139
|
}
|
|
1070
1140
|
async listCollaborator(ctx) {
|
|
1071
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1141
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1072
1142
|
(_a = ctx.telemetryReporter) === null || _a === void 0 ? void 0 : _a.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaboratorStart, {
|
|
1073
1143
|
[constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
|
|
1074
1144
|
});
|
|
1075
1145
|
try {
|
|
1076
|
-
const result = await this.
|
|
1146
|
+
const result = await this.getCurrentUserInfo(ctx);
|
|
1077
1147
|
if (result.isErr()) {
|
|
1078
1148
|
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, result.error, ctx.telemetryReporter));
|
|
1079
1149
|
}
|
|
1150
|
+
const stateResult = await this.getCurrentCollaborationState(ctx, result.value);
|
|
1151
|
+
if (stateResult.state != permissionInterface_1.CollaborationState.OK) {
|
|
1152
|
+
if (((_b = ctx.answers) === null || _b === void 0 ? void 0 : _b.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1153
|
+
(_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("warn", stateResult.message, false);
|
|
1154
|
+
}
|
|
1155
|
+
return teamsfx_api_1.ok({
|
|
1156
|
+
state: stateResult.state,
|
|
1157
|
+
message: stateResult.message,
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1080
1160
|
const userInfo = result.value;
|
|
1081
1161
|
const pluginsWithCtx = this.getPluginAndContextArray(ctx, [
|
|
1082
1162
|
this.AppStudioPlugin,
|
|
1083
1163
|
this.AadPlugin,
|
|
1084
1164
|
]);
|
|
1085
1165
|
const listCollaboratorWithCtx = pluginsWithCtx.map(([plugin, context]) => {
|
|
1086
|
-
|
|
1087
|
-
|
|
1166
|
+
return [
|
|
1167
|
+
(plugin === null || plugin === void 0 ? void 0 : plugin.listCollaborator)
|
|
1168
|
+
? (ctx) => plugin.listCollaborator.bind(plugin)(ctx, userInfo)
|
|
1169
|
+
: undefined,
|
|
1170
|
+
context,
|
|
1171
|
+
plugin.name,
|
|
1172
|
+
];
|
|
1088
1173
|
});
|
|
1089
|
-
if (((
|
|
1090
|
-
const aadAppTenantId = (
|
|
1174
|
+
if (((_d = ctx.answers) === null || _d === void 0 ? void 0 : _d.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1175
|
+
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);
|
|
1176
|
+
const envName = ctx.envInfo.envName;
|
|
1177
|
+
if (!envName) {
|
|
1178
|
+
return teamsfx_api_1.err(util_1.sendErrorTelemetryThenReturnError(constants_2.SolutionTelemetryEvent.ListCollaborator, teamsfx_api_1.returnSystemError(new Error("Failed to get env name."), "Solution", constants_2.SolutionError.FailedToGetEnvName), ctx.telemetryReporter));
|
|
1179
|
+
}
|
|
1091
1180
|
const message = [
|
|
1092
1181
|
{ content: `Account used to check: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
1093
1182
|
{ content: userInfo.userPrincipalName + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
@@ -1095,12 +1184,11 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1095
1184
|
content: `Starting list all collaborators for environment: `,
|
|
1096
1185
|
color: teamsfx_api_1.Colors.BRIGHT_WHITE,
|
|
1097
1186
|
},
|
|
1098
|
-
|
|
1099
|
-
{ content: "default\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1187
|
+
{ content: `${envName}\n`, color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1100
1188
|
{ content: `Tenant ID: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
1101
1189
|
{ content: aadAppTenantId + "\n", color: teamsfx_api_1.Colors.BRIGHT_MAGENTA },
|
|
1102
1190
|
];
|
|
1103
|
-
(
|
|
1191
|
+
(_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", message, false);
|
|
1104
1192
|
}
|
|
1105
1193
|
const results = await executor_1.executeConcurrently("", listCollaboratorWithCtx);
|
|
1106
1194
|
const errors = [];
|
|
@@ -1126,14 +1214,14 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1126
1214
|
const aadOwner = aadOwners.find((owner) => owner.userObjectId === teamsAppOwner.userObjectId);
|
|
1127
1215
|
collaborators.push({
|
|
1128
1216
|
// Sometimes app studio will return null as userPrincipalName, thus using aad's instead.
|
|
1129
|
-
userPrincipalName: (
|
|
1217
|
+
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,
|
|
1130
1218
|
userObjectId: teamsAppOwner.userObjectId,
|
|
1131
1219
|
isAadOwner: aadOwner ? true : false,
|
|
1132
1220
|
aadResourceId: aadOwner ? aadOwner.resourceId : undefined,
|
|
1133
1221
|
teamsAppResourceId: teamsAppOwner.resourceId,
|
|
1134
1222
|
});
|
|
1135
1223
|
}
|
|
1136
|
-
if (((
|
|
1224
|
+
if (((_k = ctx.answers) === null || _k === void 0 ? void 0 : _k.platform) === teamsfx_api_1.Platform.CLI) {
|
|
1137
1225
|
for (const collaborator of collaborators) {
|
|
1138
1226
|
const message = [
|
|
1139
1227
|
{ content: `Account: `, color: teamsfx_api_1.Colors.BRIGHT_WHITE },
|
|
@@ -1149,41 +1237,60 @@ let TeamsAppSolution = class TeamsAppSolution {
|
|
|
1149
1237
|
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 });
|
|
1150
1238
|
}
|
|
1151
1239
|
message.push({ content: "\n", color: teamsfx_api_1.Colors.BRIGHT_WHITE });
|
|
1152
|
-
(
|
|
1240
|
+
(_l = ctx.ui) === null || _l === void 0 ? void 0 : _l.showMessage("info", message, false);
|
|
1153
1241
|
}
|
|
1154
1242
|
}
|
|
1155
1243
|
const aadOwnerCount = collaborators.filter((collaborator) => collaborator.aadResourceId && collaborator.isAadOwner).length;
|
|
1156
|
-
(
|
|
1244
|
+
(_m = ctx.telemetryReporter) === null || _m === void 0 ? void 0 : _m.sendTelemetryEvent(constants_2.SolutionTelemetryEvent.ListCollaborator, {
|
|
1157
1245
|
[constants_2.SolutionTelemetryProperty.Component]: constants_2.SolutionTelemetryComponentName,
|
|
1158
1246
|
[constants_2.SolutionTelemetryProperty.Success]: constants_2.SolutionTelemetrySuccess.Yes,
|
|
1159
1247
|
[constants_2.SolutionTelemetryProperty.CollaboratorCount]: collaborators.length.toString(),
|
|
1160
1248
|
[constants_2.SolutionTelemetryProperty.AadOwnerCount]: aadOwnerCount.toString(),
|
|
1161
1249
|
});
|
|
1162
|
-
return teamsfx_api_1.ok(
|
|
1250
|
+
return teamsfx_api_1.ok({
|
|
1251
|
+
collaborators: collaborators,
|
|
1252
|
+
state: permissionInterface_1.CollaborationState.OK,
|
|
1253
|
+
});
|
|
1163
1254
|
}
|
|
1164
1255
|
finally {
|
|
1165
1256
|
this.runningState = SolutionRunningState.Idle;
|
|
1166
1257
|
}
|
|
1167
1258
|
}
|
|
1168
|
-
async
|
|
1259
|
+
async getCurrentUserInfo(ctx) {
|
|
1260
|
+
const user = await this.getUserInfo(ctx);
|
|
1261
|
+
if (!user) {
|
|
1262
|
+
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));
|
|
1263
|
+
}
|
|
1264
|
+
return teamsfx_api_1.ok(user);
|
|
1265
|
+
}
|
|
1266
|
+
getCurrentCollaborationState(ctx, user) {
|
|
1169
1267
|
var _a, _b;
|
|
1170
1268
|
const canProcess = this.checkWhetherSolutionIsIdle();
|
|
1171
1269
|
if (canProcess.isErr()) {
|
|
1172
|
-
return
|
|
1270
|
+
return {
|
|
1271
|
+
state: permissionInterface_1.CollaborationState.SolutionIsNotIdle,
|
|
1272
|
+
message: canProcess.error.message,
|
|
1273
|
+
};
|
|
1173
1274
|
}
|
|
1174
1275
|
const provisioned = this.checkWetherProvisionSucceeded(ctx.envInfo.profile);
|
|
1175
1276
|
if (!provisioned) {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1277
|
+
const warningMsg = "Failed to process because the resources have not been provisioned yet. Make sure you do the provision first.";
|
|
1278
|
+
return {
|
|
1279
|
+
state: permissionInterface_1.CollaborationState.NotProvisioned,
|
|
1280
|
+
message: warningMsg,
|
|
1281
|
+
};
|
|
1181
1282
|
}
|
|
1182
1283
|
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);
|
|
1183
1284
|
if (!aadAppTenantId || user.tenantId != aadAppTenantId) {
|
|
1184
|
-
|
|
1285
|
+
const warningMsg = "Tenant id of your account and the provisioned Azure AD app does not match. Please check whether you logined with wrong account.";
|
|
1286
|
+
return {
|
|
1287
|
+
state: permissionInterface_1.CollaborationState.M365TenantNotMatch,
|
|
1288
|
+
message: warningMsg,
|
|
1289
|
+
};
|
|
1185
1290
|
}
|
|
1186
|
-
return
|
|
1291
|
+
return {
|
|
1292
|
+
state: permissionInterface_1.CollaborationState.OK,
|
|
1293
|
+
};
|
|
1187
1294
|
}
|
|
1188
1295
|
loadTeamsAppTenantId(ctx, isLocalDebug, appStudioToken) {
|
|
1189
1296
|
return utils_1.parseTeamsAppTenantId(appStudioToken).andThen((teamsAppTenantId) => {
|