@microsoft/teamsfx 0.7.1-beta.c23501411.0 → 1.0.0-alpha.3511f64fb.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/dist/index.esm2017.js +2 -2
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +74 -43
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +2 -2
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +78 -45
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +7 -7
package/dist/index.node.cjs.js
CHANGED
|
@@ -15,6 +15,7 @@ var axios = require('axios');
|
|
|
15
15
|
var https = require('https');
|
|
16
16
|
var path = require('path');
|
|
17
17
|
var fs = require('fs');
|
|
18
|
+
var adaptivecardsTools = require('@microsoft/adaptivecards-tools');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -1638,8 +1639,12 @@ class ApiKeyProvider {
|
|
|
1638
1639
|
if (!config.params) {
|
|
1639
1640
|
config.params = {};
|
|
1640
1641
|
}
|
|
1641
|
-
|
|
1642
|
-
if (config.
|
|
1642
|
+
let urlHasDefinedApiKey = false;
|
|
1643
|
+
if (config.url) {
|
|
1644
|
+
const url = new URL(config.url, config.baseURL);
|
|
1645
|
+
urlHasDefinedApiKey = url.searchParams.has(this.keyName);
|
|
1646
|
+
}
|
|
1647
|
+
if (config.params[this.keyName] || urlHasDefinedApiKey) {
|
|
1643
1648
|
throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), exports.ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1644
1649
|
}
|
|
1645
1650
|
config.params[this.keyName] = this.keyValue;
|
|
@@ -1968,6 +1973,41 @@ class TeamsFx {
|
|
|
1968
1973
|
}
|
|
1969
1974
|
}
|
|
1970
1975
|
|
|
1976
|
+
// Copyright (c) Microsoft Corporation.
|
|
1977
|
+
// Licensed under the MIT license.
|
|
1978
|
+
/**
|
|
1979
|
+
* @internal
|
|
1980
|
+
*/
|
|
1981
|
+
function cloneConversation(conversation) {
|
|
1982
|
+
return JSON.parse(JSON.stringify(conversation));
|
|
1983
|
+
}
|
|
1984
|
+
/**
|
|
1985
|
+
* @internal
|
|
1986
|
+
*/
|
|
1987
|
+
function getTargetType(conversationReference) {
|
|
1988
|
+
var _a;
|
|
1989
|
+
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
1990
|
+
if (conversationType === "personal") {
|
|
1991
|
+
return "Person";
|
|
1992
|
+
}
|
|
1993
|
+
else if (conversationType === "groupChat") {
|
|
1994
|
+
return "Group";
|
|
1995
|
+
}
|
|
1996
|
+
else if (conversationType === "channel") {
|
|
1997
|
+
return "Channel";
|
|
1998
|
+
}
|
|
1999
|
+
else {
|
|
2000
|
+
return undefined;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* @internal
|
|
2005
|
+
*/
|
|
2006
|
+
function getTeamsBotInstallationId(context) {
|
|
2007
|
+
var _a, _b, _c, _d;
|
|
2008
|
+
return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
1971
2011
|
// Copyright (c) Microsoft Corporation.
|
|
1972
2012
|
/**
|
|
1973
2013
|
* @internal
|
|
@@ -1998,6 +2038,10 @@ class NotificationMiddleware {
|
|
|
1998
2038
|
yield this.conversationReferenceStore.set(reference);
|
|
1999
2039
|
break;
|
|
2000
2040
|
}
|
|
2041
|
+
case ActivityType.CurrentBotMessaged: {
|
|
2042
|
+
yield this.tryAddMessagedReference(context);
|
|
2043
|
+
break;
|
|
2044
|
+
}
|
|
2001
2045
|
case ActivityType.CurrentBotUninstalled:
|
|
2002
2046
|
case ActivityType.TeamDeleted: {
|
|
2003
2047
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
@@ -2029,8 +2073,33 @@ class NotificationMiddleware {
|
|
|
2029
2073
|
return ActivityType.TeamRestored;
|
|
2030
2074
|
}
|
|
2031
2075
|
}
|
|
2076
|
+
else if (activityType === "message") {
|
|
2077
|
+
return ActivityType.CurrentBotMessaged;
|
|
2078
|
+
}
|
|
2032
2079
|
return ActivityType.Unknown;
|
|
2033
2080
|
}
|
|
2081
|
+
tryAddMessagedReference(context) {
|
|
2082
|
+
var _a, _b, _c, _d;
|
|
2083
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2084
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
|
2085
|
+
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2086
|
+
if (conversationType === "personal" || conversationType === "groupChat") {
|
|
2087
|
+
if (!(yield this.conversationReferenceStore.check(reference))) {
|
|
2088
|
+
yield this.conversationReferenceStore.set(reference);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
else if (conversationType === "channel") {
|
|
2092
|
+
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
|
2093
|
+
if (teamId !== undefined) {
|
|
2094
|
+
const teamReference = cloneConversation(reference);
|
|
2095
|
+
teamReference.conversation.id = teamId;
|
|
2096
|
+
if (!(yield this.conversationReferenceStore.check(teamReference))) {
|
|
2097
|
+
yield this.conversationReferenceStore.set(teamReference);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2034
2103
|
}
|
|
2035
2104
|
class CommandResponseMiddleware {
|
|
2036
2105
|
constructor(handlers) {
|
|
@@ -2283,41 +2352,6 @@ class ConversationReferenceStore {
|
|
|
2283
2352
|
}
|
|
2284
2353
|
}
|
|
2285
2354
|
|
|
2286
|
-
// Copyright (c) Microsoft Corporation.
|
|
2287
|
-
// Licensed under the MIT license.
|
|
2288
|
-
/**
|
|
2289
|
-
* @internal
|
|
2290
|
-
*/
|
|
2291
|
-
function cloneConversation(conversation) {
|
|
2292
|
-
return Object.assign({}, conversation);
|
|
2293
|
-
}
|
|
2294
|
-
/**
|
|
2295
|
-
* @internal
|
|
2296
|
-
*/
|
|
2297
|
-
function getTargetType(conversationReference) {
|
|
2298
|
-
var _a;
|
|
2299
|
-
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2300
|
-
if (conversationType === "personal") {
|
|
2301
|
-
return "Person";
|
|
2302
|
-
}
|
|
2303
|
-
else if (conversationType === "groupChat") {
|
|
2304
|
-
return "Group";
|
|
2305
|
-
}
|
|
2306
|
-
else if (conversationType === "channel") {
|
|
2307
|
-
return "Channel";
|
|
2308
|
-
}
|
|
2309
|
-
else {
|
|
2310
|
-
return undefined;
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
/**
|
|
2314
|
-
* @internal
|
|
2315
|
-
*/
|
|
2316
|
-
function getTeamsBotInstallationId(context) {
|
|
2317
|
-
var _a, _b, _c, _d;
|
|
2318
|
-
return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
2355
|
// Copyright (c) Microsoft Corporation.
|
|
2322
2356
|
/**
|
|
2323
2357
|
* Send a plain text message to a notification target.
|
|
@@ -2353,7 +2387,7 @@ function sendAdaptiveCard(target, card) {
|
|
|
2353
2387
|
*/
|
|
2354
2388
|
class Channel {
|
|
2355
2389
|
/**
|
|
2356
|
-
*
|
|
2390
|
+
* Constructor.
|
|
2357
2391
|
*
|
|
2358
2392
|
* @remarks
|
|
2359
2393
|
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
@@ -2431,7 +2465,7 @@ class Channel {
|
|
|
2431
2465
|
*/
|
|
2432
2466
|
class Member {
|
|
2433
2467
|
/**
|
|
2434
|
-
*
|
|
2468
|
+
* Constructor.
|
|
2435
2469
|
*
|
|
2436
2470
|
* @remarks
|
|
2437
2471
|
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
@@ -2650,12 +2684,12 @@ class NotificationBot {
|
|
|
2650
2684
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
|
2651
2685
|
throw new Error("NotificationBot has not been initialized.");
|
|
2652
2686
|
}
|
|
2653
|
-
const references =
|
|
2687
|
+
const references = yield this.conversationReferenceStore.getAll();
|
|
2654
2688
|
const targets = [];
|
|
2655
2689
|
for (const reference of references) {
|
|
2656
2690
|
// validate connection
|
|
2657
2691
|
let valid = true;
|
|
2658
|
-
this.adapter.continueConversation(reference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2692
|
+
yield this.adapter.continueConversation(reference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2659
2693
|
try {
|
|
2660
2694
|
// try get member to see if the installation is still valid
|
|
2661
2695
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
|
@@ -2670,7 +2704,7 @@ class NotificationBot {
|
|
|
2670
2704
|
targets.push(new TeamsBotInstallation(this.adapter, reference));
|
|
2671
2705
|
}
|
|
2672
2706
|
else {
|
|
2673
|
-
this.conversationReferenceStore.delete(reference);
|
|
2707
|
+
yield this.conversationReferenceStore.delete(reference);
|
|
2674
2708
|
}
|
|
2675
2709
|
}
|
|
2676
2710
|
return targets;
|
|
@@ -2812,7 +2846,6 @@ class ConversationBot {
|
|
|
2812
2846
|
}
|
|
2813
2847
|
|
|
2814
2848
|
// Copyright (c) Microsoft Corporation.
|
|
2815
|
-
const { AdaptiveCards } = require("@microsoft/adaptivecards-tools");
|
|
2816
2849
|
/**
|
|
2817
2850
|
* Provides utility method to build bot message with cards that supported in Teams.
|
|
2818
2851
|
*/
|
|
@@ -2857,7 +2890,7 @@ class MessageBuilder {
|
|
|
2857
2890
|
*/
|
|
2858
2891
|
static attachAdaptiveCard(cardTemplate, data) {
|
|
2859
2892
|
return {
|
|
2860
|
-
attachments: [botbuilder.CardFactory.adaptiveCard(AdaptiveCards.declare(cardTemplate).render(data))],
|
|
2893
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(adaptivecardsTools.AdaptiveCards.declare(cardTemplate).render(data))],
|
|
2861
2894
|
};
|
|
2862
2895
|
}
|
|
2863
2896
|
/**
|
|
@@ -2870,7 +2903,7 @@ class MessageBuilder {
|
|
|
2870
2903
|
*/
|
|
2871
2904
|
static attachAdaptiveCardWithoutData(card) {
|
|
2872
2905
|
return {
|
|
2873
|
-
attachments: [botbuilder.CardFactory.adaptiveCard(AdaptiveCards.declareWithoutData(card).render())],
|
|
2906
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(adaptivecardsTools.AdaptiveCards.declareWithoutData(card).render())],
|
|
2874
2907
|
};
|
|
2875
2908
|
}
|
|
2876
2909
|
/**
|