@microsoft/teamsfx 0.7.1-beta.adb483893.0 → 1.0.0-alpha.074ce579f.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 +3 -3
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +95 -66
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +3 -3
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +99 -68
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -4
- package/types/teamsfx.d.ts +8 -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) {
|
|
@@ -2041,36 +2110,34 @@ class CommandResponseMiddleware {
|
|
|
2041
2110
|
}
|
|
2042
2111
|
onTurn(context, next) {
|
|
2043
2112
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
const response = yield handler.handleCommandReceived(context, message);
|
|
2113
|
+
if (context.activity.type === botbuilder.ActivityTypes.Message) {
|
|
2114
|
+
// Invoke corresponding command handler for the command response
|
|
2115
|
+
const commandText = this.getActivityText(context.activity);
|
|
2116
|
+
const message = {
|
|
2117
|
+
text: commandText,
|
|
2118
|
+
};
|
|
2119
|
+
for (const handler of this.commandHandlers) {
|
|
2120
|
+
const matchResult = this.shouldTrigger(handler.triggerPatterns, commandText);
|
|
2121
|
+
// It is important to note that the command bot will stop processing handlers
|
|
2122
|
+
// when the first command handler is matched.
|
|
2123
|
+
if (!!matchResult) {
|
|
2124
|
+
message.matches = Array.isArray(matchResult) ? matchResult : void 0;
|
|
2125
|
+
const response = yield handler.handleCommandReceived(context, message);
|
|
2126
|
+
if (typeof response === "string") {
|
|
2059
2127
|
yield context.sendActivity(response);
|
|
2060
|
-
|
|
2128
|
+
}
|
|
2129
|
+
else {
|
|
2130
|
+
const replyActivity = response;
|
|
2131
|
+
if (replyActivity) {
|
|
2132
|
+
yield context.sendActivity(replyActivity);
|
|
2133
|
+
}
|
|
2061
2134
|
}
|
|
2062
2135
|
}
|
|
2063
|
-
|
|
2136
|
+
}
|
|
2064
2137
|
}
|
|
2065
2138
|
yield next();
|
|
2066
2139
|
});
|
|
2067
2140
|
}
|
|
2068
|
-
classifyActivity(activity) {
|
|
2069
|
-
if (activity.type === botbuilder.ActivityTypes.Message) {
|
|
2070
|
-
return ActivityType.CurrentBotMessaged;
|
|
2071
|
-
}
|
|
2072
|
-
return ActivityType.Unknown;
|
|
2073
|
-
}
|
|
2074
2141
|
matchPattern(pattern, text) {
|
|
2075
2142
|
if (text) {
|
|
2076
2143
|
if (typeof pattern === "string") {
|
|
@@ -2285,41 +2352,6 @@ class ConversationReferenceStore {
|
|
|
2285
2352
|
}
|
|
2286
2353
|
}
|
|
2287
2354
|
|
|
2288
|
-
// Copyright (c) Microsoft Corporation.
|
|
2289
|
-
// Licensed under the MIT license.
|
|
2290
|
-
/**
|
|
2291
|
-
* @internal
|
|
2292
|
-
*/
|
|
2293
|
-
function cloneConversation(conversation) {
|
|
2294
|
-
return Object.assign({}, conversation);
|
|
2295
|
-
}
|
|
2296
|
-
/**
|
|
2297
|
-
* @internal
|
|
2298
|
-
*/
|
|
2299
|
-
function getTargetType(conversationReference) {
|
|
2300
|
-
var _a;
|
|
2301
|
-
const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
|
2302
|
-
if (conversationType === "personal") {
|
|
2303
|
-
return "Person";
|
|
2304
|
-
}
|
|
2305
|
-
else if (conversationType === "groupChat") {
|
|
2306
|
-
return "Group";
|
|
2307
|
-
}
|
|
2308
|
-
else if (conversationType === "channel") {
|
|
2309
|
-
return "Channel";
|
|
2310
|
-
}
|
|
2311
|
-
else {
|
|
2312
|
-
return undefined;
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* @internal
|
|
2317
|
-
*/
|
|
2318
|
-
function getTeamsBotInstallationId(context) {
|
|
2319
|
-
var _a, _b, _c, _d;
|
|
2320
|
-
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;
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
2355
|
// Copyright (c) Microsoft Corporation.
|
|
2324
2356
|
/**
|
|
2325
2357
|
* Send a plain text message to a notification target.
|
|
@@ -2355,7 +2387,7 @@ function sendAdaptiveCard(target, card) {
|
|
|
2355
2387
|
*/
|
|
2356
2388
|
class Channel {
|
|
2357
2389
|
/**
|
|
2358
|
-
*
|
|
2390
|
+
* Constructor.
|
|
2359
2391
|
*
|
|
2360
2392
|
* @remarks
|
|
2361
2393
|
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
@@ -2433,7 +2465,7 @@ class Channel {
|
|
|
2433
2465
|
*/
|
|
2434
2466
|
class Member {
|
|
2435
2467
|
/**
|
|
2436
|
-
*
|
|
2468
|
+
* Constructor.
|
|
2437
2469
|
*
|
|
2438
2470
|
* @remarks
|
|
2439
2471
|
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
@@ -2652,12 +2684,12 @@ class NotificationBot {
|
|
|
2652
2684
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
|
2653
2685
|
throw new Error("NotificationBot has not been initialized.");
|
|
2654
2686
|
}
|
|
2655
|
-
const references =
|
|
2687
|
+
const references = yield this.conversationReferenceStore.getAll();
|
|
2656
2688
|
const targets = [];
|
|
2657
2689
|
for (const reference of references) {
|
|
2658
2690
|
// validate connection
|
|
2659
2691
|
let valid = true;
|
|
2660
|
-
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* () {
|
|
2661
2693
|
try {
|
|
2662
2694
|
// try get member to see if the installation is still valid
|
|
2663
2695
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
|
@@ -2672,7 +2704,7 @@ class NotificationBot {
|
|
|
2672
2704
|
targets.push(new TeamsBotInstallation(this.adapter, reference));
|
|
2673
2705
|
}
|
|
2674
2706
|
else {
|
|
2675
|
-
this.conversationReferenceStore.delete(reference);
|
|
2707
|
+
yield this.conversationReferenceStore.delete(reference);
|
|
2676
2708
|
}
|
|
2677
2709
|
}
|
|
2678
2710
|
return targets;
|
|
@@ -2814,7 +2846,6 @@ class ConversationBot {
|
|
|
2814
2846
|
}
|
|
2815
2847
|
|
|
2816
2848
|
// Copyright (c) Microsoft Corporation.
|
|
2817
|
-
const { AdaptiveCards } = require("@microsoft/adaptivecards-tools");
|
|
2818
2849
|
/**
|
|
2819
2850
|
* Provides utility method to build bot message with cards that supported in Teams.
|
|
2820
2851
|
*/
|
|
@@ -2859,7 +2890,7 @@ class MessageBuilder {
|
|
|
2859
2890
|
*/
|
|
2860
2891
|
static attachAdaptiveCard(cardTemplate, data) {
|
|
2861
2892
|
return {
|
|
2862
|
-
attachments: [botbuilder.CardFactory.adaptiveCard(AdaptiveCards.declare(cardTemplate).render(data))],
|
|
2893
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(adaptivecardsTools.AdaptiveCards.declare(cardTemplate).render(data))],
|
|
2863
2894
|
};
|
|
2864
2895
|
}
|
|
2865
2896
|
/**
|
|
@@ -2872,7 +2903,7 @@ class MessageBuilder {
|
|
|
2872
2903
|
*/
|
|
2873
2904
|
static attachAdaptiveCardWithoutData(card) {
|
|
2874
2905
|
return {
|
|
2875
|
-
attachments: [botbuilder.CardFactory.adaptiveCard(AdaptiveCards.declareWithoutData(card).render())],
|
|
2906
|
+
attachments: [botbuilder.CardFactory.adaptiveCard(adaptivecardsTools.AdaptiveCards.declareWithoutData(card).render())],
|
|
2876
2907
|
};
|
|
2877
2908
|
}
|
|
2878
2909
|
/**
|