@microsoft/teamsfx 2.3.0 → 2.3.1-beta.2023091908.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/README.md +3 -2
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +40 -4
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +30 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +161 -115
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +26 -9
- package/types/teamsfx.d.ts +3 -3
package/dist/index.node.cjs.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var tslib = require('tslib');
|
6
5
|
var jwt_decode = require('jwt-decode');
|
7
6
|
var msalNode = require('@azure/msal-node');
|
8
7
|
var crypto = require('crypto');
|
@@ -190,6 +189,48 @@ class ErrorWithCode extends Error {
|
|
190
189
|
}
|
191
190
|
}
|
192
191
|
|
192
|
+
/******************************************************************************
|
193
|
+
Copyright (c) Microsoft Corporation.
|
194
|
+
|
195
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
196
|
+
purpose with or without fee is hereby granted.
|
197
|
+
|
198
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
199
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
200
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
201
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
202
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
203
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
204
|
+
PERFORMANCE OF THIS SOFTWARE.
|
205
|
+
***************************************************************************** */
|
206
|
+
|
207
|
+
function __rest(s, e) {
|
208
|
+
var t = {};
|
209
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
210
|
+
t[p] = s[p];
|
211
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
212
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
213
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
214
|
+
t[p[i]] = s[p[i]];
|
215
|
+
}
|
216
|
+
return t;
|
217
|
+
}
|
218
|
+
|
219
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
220
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
221
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
222
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
223
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
224
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
225
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
226
|
+
});
|
227
|
+
}
|
228
|
+
|
229
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
230
|
+
var e = new Error(message);
|
231
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
232
|
+
};
|
233
|
+
|
193
234
|
// Copyright (c) Microsoft Corporation.
|
194
235
|
// Licensed under the MIT license.
|
195
236
|
/**
|
@@ -514,7 +555,7 @@ class AppCredential {
|
|
514
555
|
* Throw error if get access token failed.
|
515
556
|
*/
|
516
557
|
getToken(scopes, options) {
|
517
|
-
return
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
518
559
|
let accessToken;
|
519
560
|
validateScopesType(scopes);
|
520
561
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
@@ -652,7 +693,7 @@ class OnBehalfOfUserCredential {
|
|
652
693
|
* If scopes is non-empty, it returns access token for target scope.
|
653
694
|
*/
|
654
695
|
getToken(scopes, options) {
|
655
|
-
return
|
696
|
+
return __awaiter(this, void 0, void 0, function* () {
|
656
697
|
validateScopesType(scopes);
|
657
698
|
const scopesArray = getScopesArray(scopes);
|
658
699
|
let result;
|
@@ -805,7 +846,7 @@ class MsGraphAuthProvider {
|
|
805
846
|
*
|
806
847
|
*/
|
807
848
|
getAccessToken() {
|
808
|
-
return
|
849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
809
850
|
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes.toString()}'`);
|
810
851
|
let accessToken;
|
811
852
|
if (this.credentialOrTeamsFx.getCredential) {
|
@@ -985,7 +1026,7 @@ const defaultSQLScope = "https://database.windows.net/";
|
|
985
1026
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
986
1027
|
*/
|
987
1028
|
function getTediousConnectionConfig(teamsfx, databaseName) {
|
988
|
-
return
|
1029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
989
1030
|
internalLogger.info("Get SQL configuration");
|
990
1031
|
try {
|
991
1032
|
isSQLConfigurationValid(teamsfx);
|
@@ -1089,7 +1130,7 @@ function generateDefaultConfig(teamsfx, databaseName) {
|
|
1089
1130
|
* @internal
|
1090
1131
|
*/
|
1091
1132
|
function generateTokenConfig(teamsfx, databaseName) {
|
1092
|
-
return
|
1133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1093
1134
|
internalLogger.verbose("Generate tedious config with MSI token");
|
1094
1135
|
let token;
|
1095
1136
|
try {
|
@@ -1246,7 +1287,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1246
1287
|
*/
|
1247
1288
|
beginDialog(dc) {
|
1248
1289
|
var _a;
|
1249
|
-
return
|
1290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1250
1291
|
internalLogger.info("Begin Teams Bot SSO Prompt");
|
1251
1292
|
this.ensureMsTeamsChannel(dc);
|
1252
1293
|
// Initialize prompt state
|
@@ -1295,7 +1336,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1295
1336
|
*/
|
1296
1337
|
continueDialog(dc) {
|
1297
1338
|
var _a;
|
1298
|
-
return
|
1339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1299
1340
|
internalLogger.info("Continue Teams Bot SSO Prompt");
|
1300
1341
|
this.ensureMsTeamsChannel(dc);
|
1301
1342
|
// Check for timeout
|
@@ -1388,7 +1429,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1388
1429
|
* @internal
|
1389
1430
|
*/
|
1390
1431
|
sendOAuthCardAsync(context) {
|
1391
|
-
return
|
1432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1392
1433
|
internalLogger.verbose("Send OAuth card to get SSO token");
|
1393
1434
|
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
|
1394
1435
|
internalLogger.verbose("Get Teams member account user principal name: " +
|
@@ -1425,7 +1466,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1425
1466
|
* @internal
|
1426
1467
|
*/
|
1427
1468
|
recognizeToken(dc) {
|
1428
|
-
return
|
1469
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1429
1470
|
const context = dc.context;
|
1430
1471
|
let tokenResponse;
|
1431
1472
|
if (this.isTokenExchangeRequestInvoke(context)) {
|
@@ -1522,7 +1563,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
1522
1563
|
baseURL: apiEndpoint,
|
1523
1564
|
});
|
1524
1565
|
instance.interceptors.request.use(function (config) {
|
1525
|
-
return
|
1566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1526
1567
|
return yield authProvider.AddAuthenticationInfo(config);
|
1527
1568
|
});
|
1528
1569
|
});
|
@@ -1551,7 +1592,7 @@ class BearerTokenAuthProvider {
|
|
1551
1592
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
1552
1593
|
*/
|
1553
1594
|
AddAuthenticationInfo(config) {
|
1554
|
-
return
|
1595
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1555
1596
|
const token = yield this.getToken();
|
1556
1597
|
if (!config.headers) {
|
1557
1598
|
config.headers = {};
|
@@ -1870,7 +1911,7 @@ class TeamsFx {
|
|
1870
1911
|
* @returns UserInfo object.
|
1871
1912
|
*/
|
1872
1913
|
getUserInfo(resources) {
|
1873
|
-
return
|
1914
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1874
1915
|
if (this.identityType !== exports.IdentityType.User) {
|
1875
1916
|
const errorMsg = formatString(ErrorMessage.IdentityTypeNotSupported, this.identityType.toString(), "TeamsFx");
|
1876
1917
|
internalLogger.error(errorMsg);
|
@@ -1901,7 +1942,7 @@ class TeamsFx {
|
|
1901
1942
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
1902
1943
|
*/
|
1903
1944
|
login(scopes, resources) {
|
1904
|
-
return
|
1945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1905
1946
|
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "login"), exports.ErrorCode.RuntimeNotSupported);
|
1906
1947
|
});
|
1907
1948
|
}
|
@@ -2040,6 +2081,7 @@ exports.InvokeResponseErrorCode = void 0;
|
|
2040
2081
|
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
2041
2082
|
})(exports.InvokeResponseErrorCode || (exports.InvokeResponseErrorCode = {}));
|
2042
2083
|
|
2084
|
+
// Copyright (c) Microsoft Corporation.
|
2043
2085
|
/**
|
2044
2086
|
* Available response type for an adaptive card invoke response.
|
2045
2087
|
* @internal
|
@@ -2054,7 +2096,7 @@ var InvokeResponseType;
|
|
2054
2096
|
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
2055
2097
|
*
|
2056
2098
|
* @remarks
|
2057
|
-
* All of these functions return an
|
2099
|
+
* All of these functions return an `InvokeResponse` object, which can be
|
2058
2100
|
* passed as input to generate a new `invokeResponse` activity.
|
2059
2101
|
*
|
2060
2102
|
* This example sends an invoke response that contains an adaptive card.
|
@@ -2180,7 +2222,7 @@ class CardActionMiddleware {
|
|
2180
2222
|
}
|
2181
2223
|
onTurn(context, next) {
|
2182
2224
|
var _a, _b, _c;
|
2183
|
-
return
|
2225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2184
2226
|
if (context.activity.name === "adaptiveCard/action") {
|
2185
2227
|
const action = context.activity.value.action;
|
2186
2228
|
const actionVerb = action.verb;
|
@@ -2237,7 +2279,7 @@ class CardActionMiddleware {
|
|
2237
2279
|
});
|
2238
2280
|
}
|
2239
2281
|
sendInvokeResponse(context, response) {
|
2240
|
-
return
|
2282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2241
2283
|
yield context.sendActivity({
|
2242
2284
|
type: botbuilder.ActivityTypes.InvokeResponse,
|
2243
2285
|
value: response,
|
@@ -2306,7 +2348,7 @@ class CommandResponseMiddleware {
|
|
2306
2348
|
}
|
2307
2349
|
addSsoCommand(ssoHandler) {
|
2308
2350
|
var _a;
|
2309
|
-
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) =>
|
2351
|
+
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) => __awaiter(this, void 0, void 0, function* () {
|
2310
2352
|
const matchResult = this.shouldTrigger(ssoHandler.triggerPatterns, message.text);
|
2311
2353
|
message.matches = Array.isArray(matchResult) ? matchResult : void 0;
|
2312
2354
|
const response = yield ssoHandler.handleCommandReceived(context, message, tokenResponse);
|
@@ -2317,7 +2359,7 @@ class CommandResponseMiddleware {
|
|
2317
2359
|
}
|
2318
2360
|
onTurn(context, next) {
|
2319
2361
|
var _a, _b;
|
2320
|
-
return
|
2362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2321
2363
|
if (context.activity.type === botbuilder.ActivityTypes.Message) {
|
2322
2364
|
// Invoke corresponding command handler for the command response
|
2323
2365
|
const commandText = this.getActivityText(context.activity);
|
@@ -2356,7 +2398,7 @@ class CommandResponseMiddleware {
|
|
2356
2398
|
});
|
2357
2399
|
}
|
2358
2400
|
processResponse(context, response) {
|
2359
|
-
return
|
2401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2360
2402
|
if (typeof response === "string") {
|
2361
2403
|
yield context.sendActivity(response);
|
2362
2404
|
}
|
@@ -2487,6 +2529,7 @@ function cloneConversation(conversation) {
|
|
2487
2529
|
*/
|
2488
2530
|
function getKey(reference) {
|
2489
2531
|
var _a, _b;
|
2532
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2490
2533
|
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2491
2534
|
}
|
2492
2535
|
/**
|
@@ -2546,7 +2589,7 @@ class NotificationMiddleware {
|
|
2546
2589
|
this.conversationReferenceStore = options.conversationReferenceStore;
|
2547
2590
|
}
|
2548
2591
|
onTurn(context, next) {
|
2549
|
-
return
|
2592
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2550
2593
|
const type = this.classifyActivity(context.activity);
|
2551
2594
|
switch (type) {
|
2552
2595
|
case ActivityType.CurrentBotInstalled:
|
@@ -2599,7 +2642,7 @@ class NotificationMiddleware {
|
|
2599
2642
|
}
|
2600
2643
|
tryAddMessagedReference(context) {
|
2601
2644
|
var _a, _b, _c, _d;
|
2602
|
-
return
|
2645
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2603
2646
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2604
2647
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2605
2648
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
@@ -2629,7 +2672,7 @@ class LocalFileStorage {
|
|
2629
2672
|
this.filePath = path__namespace.resolve(fileDir, this.localFileName);
|
2630
2673
|
}
|
2631
2674
|
read(key) {
|
2632
|
-
return
|
2675
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2633
2676
|
if (!(yield this.storeFileExists())) {
|
2634
2677
|
return undefined;
|
2635
2678
|
}
|
@@ -2638,7 +2681,7 @@ class LocalFileStorage {
|
|
2638
2681
|
});
|
2639
2682
|
}
|
2640
2683
|
list() {
|
2641
|
-
return
|
2684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2642
2685
|
if (!(yield this.storeFileExists())) {
|
2643
2686
|
return [];
|
2644
2687
|
}
|
@@ -2647,7 +2690,7 @@ class LocalFileStorage {
|
|
2647
2690
|
});
|
2648
2691
|
}
|
2649
2692
|
write(key, object) {
|
2650
|
-
return
|
2693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2651
2694
|
if (!(yield this.storeFileExists())) {
|
2652
2695
|
yield this.writeToFile({ [key]: object });
|
2653
2696
|
return;
|
@@ -2657,7 +2700,7 @@ class LocalFileStorage {
|
|
2657
2700
|
});
|
2658
2701
|
}
|
2659
2702
|
delete(key) {
|
2660
|
-
return
|
2703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2661
2704
|
if (yield this.storeFileExists()) {
|
2662
2705
|
const data = yield this.readFromFile();
|
2663
2706
|
if (data[key] !== undefined) {
|
@@ -2702,7 +2745,7 @@ class LocalFileStorage {
|
|
2702
2745
|
});
|
2703
2746
|
}
|
2704
2747
|
writeToFile(data) {
|
2705
|
-
return
|
2748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2706
2749
|
return new Promise((resolve, reject) => {
|
2707
2750
|
try {
|
2708
2751
|
const rawData = JSON.stringify(data, undefined, 2);
|
@@ -2730,7 +2773,7 @@ class DefaultConversationReferenceStore {
|
|
2730
2773
|
this.storage = storage;
|
2731
2774
|
}
|
2732
2775
|
add(key, reference, options) {
|
2733
|
-
return
|
2776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2734
2777
|
if (options.overwrite) {
|
2735
2778
|
yield this.storage.write(key, reference);
|
2736
2779
|
return true;
|
@@ -2744,7 +2787,7 @@ class DefaultConversationReferenceStore {
|
|
2744
2787
|
});
|
2745
2788
|
}
|
2746
2789
|
remove(key, reference) {
|
2747
|
-
return
|
2790
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2748
2791
|
const ref = yield this.storage.read(key);
|
2749
2792
|
if (ref === undefined) {
|
2750
2793
|
return false;
|
@@ -2754,7 +2797,7 @@ class DefaultConversationReferenceStore {
|
|
2754
2797
|
});
|
2755
2798
|
}
|
2756
2799
|
list(pageSize, continuationToken) {
|
2757
|
-
return
|
2800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2758
2801
|
const data = yield this.storage.list();
|
2759
2802
|
return {
|
2760
2803
|
data,
|
@@ -2822,11 +2865,11 @@ class Channel$1 {
|
|
2822
2865
|
* @returns the response of sending message.
|
2823
2866
|
*/
|
2824
2867
|
sendMessage(text, onError) {
|
2825
|
-
return
|
2868
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2826
2869
|
const response = {};
|
2827
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2870
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2828
2871
|
const conversation = this.newConversation(context);
|
2829
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2872
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2830
2873
|
try {
|
2831
2874
|
const res = yield ctx.sendActivity(text);
|
2832
2875
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2853,11 +2896,11 @@ class Channel$1 {
|
|
2853
2896
|
* @returns the response of sending adaptive card message.
|
2854
2897
|
*/
|
2855
2898
|
sendAdaptiveCard(card, onError) {
|
2856
|
-
return
|
2899
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2857
2900
|
const response = {};
|
2858
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2901
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2859
2902
|
const conversation = this.newConversation(context);
|
2860
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2903
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2861
2904
|
try {
|
2862
2905
|
const res = yield ctx.sendActivity({
|
2863
2906
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2920,11 +2963,11 @@ class Member$1 {
|
|
2920
2963
|
* @returns the response of sending message.
|
2921
2964
|
*/
|
2922
2965
|
sendMessage(text, onError) {
|
2923
|
-
return
|
2966
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2924
2967
|
const response = {};
|
2925
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2968
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2926
2969
|
const conversation = yield this.newConversation(context);
|
2927
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2970
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2928
2971
|
try {
|
2929
2972
|
const res = yield ctx.sendActivity(text);
|
2930
2973
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2951,11 +2994,11 @@ class Member$1 {
|
|
2951
2994
|
* @returns the response of sending adaptive card message.
|
2952
2995
|
*/
|
2953
2996
|
sendAdaptiveCard(card, onError) {
|
2954
|
-
return
|
2997
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2955
2998
|
const response = {};
|
2956
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2999
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2957
3000
|
const conversation = yield this.newConversation(context);
|
2958
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
3001
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2959
3002
|
try {
|
2960
3003
|
const res = yield ctx.sendActivity({
|
2961
3004
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2979,7 +3022,7 @@ class Member$1 {
|
|
2979
3022
|
* @internal
|
2980
3023
|
*/
|
2981
3024
|
newConversation(context) {
|
2982
|
-
return
|
3025
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2983
3026
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2984
3027
|
const personalConversation = cloneConversation(reference);
|
2985
3028
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -3031,9 +3074,9 @@ class TeamsBotInstallation$1 {
|
|
3031
3074
|
* @returns the response of sending message.
|
3032
3075
|
*/
|
3033
3076
|
sendMessage(text, onError) {
|
3034
|
-
return
|
3077
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3035
3078
|
const response = {};
|
3036
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3079
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3037
3080
|
try {
|
3038
3081
|
const res = yield context.sendActivity(text);
|
3039
3082
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -3059,9 +3102,9 @@ class TeamsBotInstallation$1 {
|
|
3059
3102
|
* @returns the response of sending adaptive card message.
|
3060
3103
|
*/
|
3061
3104
|
sendAdaptiveCard(card, onError) {
|
3062
|
-
return
|
3105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3063
3106
|
const response = {};
|
3064
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3107
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3065
3108
|
try {
|
3066
3109
|
const res = yield context.sendActivity({
|
3067
3110
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -3086,13 +3129,13 @@ class TeamsBotInstallation$1 {
|
|
3086
3129
|
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
3087
3130
|
*/
|
3088
3131
|
channels() {
|
3089
|
-
return
|
3132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3090
3133
|
const channels = [];
|
3091
3134
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3092
3135
|
return channels;
|
3093
3136
|
}
|
3094
3137
|
let teamsChannels = [];
|
3095
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3138
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3096
3139
|
const teamId = getTeamsBotInstallationId(context);
|
3097
3140
|
if (teamId !== undefined) {
|
3098
3141
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -3110,9 +3153,9 @@ class TeamsBotInstallation$1 {
|
|
3110
3153
|
* @returns an array of members from where the bot is installed.
|
3111
3154
|
*/
|
3112
3155
|
members() {
|
3113
|
-
return
|
3156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3114
3157
|
const members = [];
|
3115
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3158
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3116
3159
|
let continuationToken;
|
3117
3160
|
do {
|
3118
3161
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, undefined, continuationToken);
|
@@ -3131,12 +3174,12 @@ class TeamsBotInstallation$1 {
|
|
3131
3174
|
* @returns the team details if bot is installed into a team, otherwise returns undefined.
|
3132
3175
|
*/
|
3133
3176
|
getTeamDetails() {
|
3134
|
-
return
|
3177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3135
3178
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3136
3179
|
return undefined;
|
3137
3180
|
}
|
3138
3181
|
let teamDetails;
|
3139
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3182
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3140
3183
|
const teamId = getTeamsBotInstallationId(context);
|
3141
3184
|
if (teamId !== undefined) {
|
3142
3185
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -3179,7 +3222,7 @@ class NotificationBot$1 {
|
|
3179
3222
|
* @returns - an array of {@link TeamsBotInstallation}.
|
3180
3223
|
*/
|
3181
3224
|
installations() {
|
3182
|
-
return
|
3225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3183
3226
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
3184
3227
|
throw new Error("NotificationBot has not been initialized.");
|
3185
3228
|
}
|
@@ -3188,7 +3231,7 @@ class NotificationBot$1 {
|
|
3188
3231
|
for (const reference of references) {
|
3189
3232
|
// validate connection
|
3190
3233
|
let valid = true;
|
3191
|
-
yield this.adapter.continueConversation(reference, (context) =>
|
3234
|
+
yield this.adapter.continueConversation(reference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3192
3235
|
try {
|
3193
3236
|
// try get member to see if the installation is still valid
|
3194
3237
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -3220,7 +3263,7 @@ class NotificationBot$1 {
|
|
3220
3263
|
* @returns the first {@link Member} where predicate is true, and undefined otherwise.
|
3221
3264
|
*/
|
3222
3265
|
findMember(predicate, scope) {
|
3223
|
-
return
|
3266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3224
3267
|
for (const target of yield this.installations()) {
|
3225
3268
|
if (this.matchSearchScope(target, scope)) {
|
3226
3269
|
for (const member of yield target.members()) {
|
@@ -3243,7 +3286,7 @@ class NotificationBot$1 {
|
|
3243
3286
|
* @returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
3244
3287
|
*/
|
3245
3288
|
findChannel(predicate) {
|
3246
|
-
return
|
3289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3247
3290
|
for (const target of yield this.installations()) {
|
3248
3291
|
if (target.type === exports.NotificationTargetType.Channel) {
|
3249
3292
|
const teamDetails = yield target.getTeamDetails();
|
@@ -3266,7 +3309,7 @@ class NotificationBot$1 {
|
|
3266
3309
|
* @returns an array of {@link Member} where predicate is true, and empty array otherwise.
|
3267
3310
|
*/
|
3268
3311
|
findAllMembers(predicate, scope) {
|
3269
|
-
return
|
3312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3270
3313
|
const members = [];
|
3271
3314
|
for (const target of yield this.installations()) {
|
3272
3315
|
if (this.matchSearchScope(target, scope)) {
|
@@ -3288,7 +3331,7 @@ class NotificationBot$1 {
|
|
3288
3331
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|
3289
3332
|
*/
|
3290
3333
|
findAllChannels(predicate) {
|
3291
|
-
return
|
3334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3292
3335
|
const channels = [];
|
3293
3336
|
for (const target of yield this.installations()) {
|
3294
3337
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -3381,7 +3424,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3381
3424
|
const dialog = new botbuilderDialogs.WaterfallDialog(commandId, [
|
3382
3425
|
this.ssoStep.bind(this),
|
3383
3426
|
this.dedupStep.bind(this),
|
3384
|
-
(stepContext) =>
|
3427
|
+
(stepContext) => __awaiter(this, void 0, void 0, function* () {
|
3385
3428
|
const tokenResponse = stepContext.result.tokenResponse;
|
3386
3429
|
const context = stepContext.context;
|
3387
3430
|
const message = stepContext.result.message;
|
@@ -3418,7 +3461,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3418
3461
|
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
3419
3462
|
*/
|
3420
3463
|
run(context, accessor) {
|
3421
|
-
return
|
3464
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3422
3465
|
const dialogSet = new botbuilderDialogs.DialogSet(accessor);
|
3423
3466
|
dialogSet.add(this);
|
3424
3467
|
const dialogContext = yield dialogSet.createContext(context);
|
@@ -3446,7 +3489,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3446
3489
|
return text;
|
3447
3490
|
}
|
3448
3491
|
commandRouteStep(stepContext) {
|
3449
|
-
return
|
3492
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3450
3493
|
const turnContext = stepContext.context;
|
3451
3494
|
const text = this.getActivityText(turnContext.activity);
|
3452
3495
|
const commandId = this.getMatchesCommandId(text);
|
@@ -3459,7 +3502,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3459
3502
|
});
|
3460
3503
|
}
|
3461
3504
|
ssoStep(stepContext) {
|
3462
|
-
return
|
3505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3463
3506
|
try {
|
3464
3507
|
const turnContext = stepContext.context;
|
3465
3508
|
const text = this.getActivityText(turnContext.activity);
|
@@ -3477,7 +3520,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3477
3520
|
});
|
3478
3521
|
}
|
3479
3522
|
dedupStep(stepContext) {
|
3480
|
-
return
|
3523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3481
3524
|
const tokenResponse = stepContext.result;
|
3482
3525
|
if (!tokenResponse) {
|
3483
3526
|
internalLogger.error(ErrorMessage.FailedToRetrieveSsoToken);
|
@@ -3506,7 +3549,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3506
3549
|
* @param context Context for the current turn of conversation.
|
3507
3550
|
*/
|
3508
3551
|
onEndDialog(context) {
|
3509
|
-
return
|
3552
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3510
3553
|
const conversationId = context.activity.conversation.id;
|
3511
3554
|
const currentDedupKeys = this.dedupStorageKeys.filter((key) => key.indexOf(conversationId) > 0);
|
3512
3555
|
yield this.dedupStorage.delete(currentDedupKeys);
|
@@ -3522,7 +3565,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3522
3565
|
* @returns boolean value indicate whether the message should be removed
|
3523
3566
|
*/
|
3524
3567
|
shouldDedup(context) {
|
3525
|
-
return
|
3568
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3526
3569
|
const storeItem = {
|
3527
3570
|
eTag: context.activity.value.id,
|
3528
3571
|
};
|
@@ -3622,7 +3665,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3622
3665
|
const userState = (_b = (_a = ssoConfig.dialog) === null || _a === void 0 ? void 0 : _a.userState) !== null && _b !== void 0 ? _b : new botbuilder.UserState(memoryStorage);
|
3623
3666
|
const conversationState = (_d = (_c = ssoConfig.dialog) === null || _c === void 0 ? void 0 : _c.conversationState) !== null && _d !== void 0 ? _d : new botbuilder.ConversationState(memoryStorage);
|
3624
3667
|
const dedupStorage = (_f = (_e = ssoConfig.dialog) === null || _e === void 0 ? void 0 : _e.dedupStorage) !== null && _f !== void 0 ? _f : memoryStorage;
|
3625
|
-
const _l = ssoConfig.aad, { scopes } = _l, customConfig =
|
3668
|
+
const _l = ssoConfig.aad, { scopes } = _l, customConfig = __rest(_l, ["scopes"]);
|
3626
3669
|
const settings = {
|
3627
3670
|
scopes: scopes,
|
3628
3671
|
timeout: (_h = (_g = ssoConfig.dialog) === null || _g === void 0 ? void 0 : _g.ssoPromptConfig) === null || _h === void 0 ? void 0 : _h.timeout,
|
@@ -3632,7 +3675,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3632
3675
|
this.conversationState = conversationState;
|
3633
3676
|
this.dialogState = conversationState.createProperty("DialogState");
|
3634
3677
|
this.userState = userState;
|
3635
|
-
this.onMessage((context, next) =>
|
3678
|
+
this.onMessage((context, next) => __awaiter(this, void 0, void 0, function* () {
|
3636
3679
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3637
3680
|
yield next();
|
3638
3681
|
}));
|
@@ -3656,7 +3699,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3656
3699
|
const _super = Object.create(null, {
|
3657
3700
|
run: { get: () => super.run }
|
3658
3701
|
});
|
3659
|
-
return
|
3702
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3660
3703
|
try {
|
3661
3704
|
yield _super.run.call(this, context);
|
3662
3705
|
}
|
@@ -3676,7 +3719,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3676
3719
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3677
3720
|
*/
|
3678
3721
|
handleTeamsSigninVerifyState(context, query) {
|
3679
|
-
return
|
3722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3680
3723
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3681
3724
|
});
|
3682
3725
|
}
|
@@ -3686,11 +3729,11 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3686
3729
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3687
3730
|
* @returns A promise that represents the work queued.
|
3688
3731
|
*
|
3689
|
-
* @
|
3732
|
+
* @remarks
|
3690
3733
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3691
3734
|
*/
|
3692
3735
|
handleTeamsSigninTokenExchange(context, query) {
|
3693
|
-
return
|
3736
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3694
3737
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3695
3738
|
});
|
3696
3739
|
}
|
@@ -3796,11 +3839,14 @@ class ConversationBot$1 {
|
|
3796
3839
|
})
|
3797
3840
|
: new botbuilder.BotFrameworkAdapter(adapterConfig);
|
3798
3841
|
// the default error handler
|
3799
|
-
adapter.onTurnError = (context, error) =>
|
3842
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
3800
3843
|
// This check writes out errors to console.
|
3844
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3801
3845
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3802
3846
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3803
|
-
yield context.sendTraceActivity("OnTurnError Trace",
|
3847
|
+
yield context.sendTraceActivity("OnTurnError Trace",
|
3848
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3849
|
+
`${error}`, "https://www.botframework.com/schemas/error", "TurnError");
|
3804
3850
|
// Send a message to the user
|
3805
3851
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3806
3852
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3829,10 +3875,10 @@ class ConversationBot$1 {
|
|
3829
3875
|
* ```
|
3830
3876
|
*/
|
3831
3877
|
requestHandler(req, res, logic) {
|
3832
|
-
return
|
3878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3833
3879
|
if (logic === undefined) {
|
3834
3880
|
// create empty logic
|
3835
|
-
logic = () =>
|
3881
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
3836
3882
|
}
|
3837
3883
|
yield this.adapter.processActivity(req, res, logic);
|
3838
3884
|
});
|
@@ -4049,7 +4095,7 @@ function getSignInResponseForMessageExtension(teamsfx, scopes) {
|
|
4049
4095
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4050
4096
|
*/
|
4051
4097
|
function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint, scopes, logic) {
|
4052
|
-
return
|
4098
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4053
4099
|
const valueObj = context.activity.value;
|
4054
4100
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4055
4101
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4099,7 +4145,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4099
4145
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4100
4146
|
*/
|
4101
4147
|
function executionWithToken(context, config, scopes, logic) {
|
4102
|
-
return
|
4148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4103
4149
|
const valueObj = context.activity.value;
|
4104
4150
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4105
4151
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4151,7 +4197,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4151
4197
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4152
4198
|
*/
|
4153
4199
|
function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
4154
|
-
return
|
4200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4155
4201
|
if (context.activity.name != "composeExtension/query") {
|
4156
4202
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4157
4203
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4178,7 +4224,7 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
4178
4224
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4179
4225
|
*/
|
4180
4226
|
function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4181
|
-
return
|
4227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4182
4228
|
if (context.activity.name != "composeExtension/query") {
|
4183
4229
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4184
4230
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4356,11 +4402,11 @@ class Channel {
|
|
4356
4402
|
* @returns The response of sending message.
|
4357
4403
|
*/
|
4358
4404
|
sendMessage(text, onError) {
|
4359
|
-
return
|
4405
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4360
4406
|
const response = {};
|
4361
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4407
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4362
4408
|
const conversation = yield this.newConversation(context);
|
4363
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4409
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4364
4410
|
try {
|
4365
4411
|
const res = yield ctx.sendActivity(text);
|
4366
4412
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4388,11 +4434,11 @@ class Channel {
|
|
4388
4434
|
* @returns The response of sending adaptive card message.
|
4389
4435
|
*/
|
4390
4436
|
sendAdaptiveCard(card, onError) {
|
4391
|
-
return
|
4437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4392
4438
|
const response = {};
|
4393
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4439
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4394
4440
|
const conversation = yield this.newConversation(context);
|
4395
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4441
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4396
4442
|
try {
|
4397
4443
|
const res = yield ctx.sendActivity({
|
4398
4444
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4456,11 +4502,11 @@ class Member {
|
|
4456
4502
|
* @returns The response of sending message.
|
4457
4503
|
*/
|
4458
4504
|
sendMessage(text, onError) {
|
4459
|
-
return
|
4505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4460
4506
|
const response = {};
|
4461
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4507
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4462
4508
|
const conversation = yield this.newConversation(context);
|
4463
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4509
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4464
4510
|
try {
|
4465
4511
|
const res = yield ctx.sendActivity(text);
|
4466
4512
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4488,11 +4534,11 @@ class Member {
|
|
4488
4534
|
* @returns The response of sending adaptive card message.
|
4489
4535
|
*/
|
4490
4536
|
sendAdaptiveCard(card, onError) {
|
4491
|
-
return
|
4537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4492
4538
|
const response = {};
|
4493
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4539
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4494
4540
|
const conversation = yield this.newConversation(context);
|
4495
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4541
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4496
4542
|
try {
|
4497
4543
|
const res = yield ctx.sendActivity({
|
4498
4544
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4516,7 +4562,7 @@ class Member {
|
|
4516
4562
|
* @internal
|
4517
4563
|
*/
|
4518
4564
|
newConversation(context) {
|
4519
|
-
return
|
4565
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4520
4566
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4521
4567
|
const personalConversation = cloneConversation(reference);
|
4522
4568
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -4568,9 +4614,9 @@ class TeamsBotInstallation {
|
|
4568
4614
|
* @returns The response of sending message.
|
4569
4615
|
*/
|
4570
4616
|
sendMessage(text, onError) {
|
4571
|
-
return
|
4617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4572
4618
|
const response = {};
|
4573
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4619
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4574
4620
|
try {
|
4575
4621
|
const res = yield context.sendActivity(text);
|
4576
4622
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4597,9 +4643,9 @@ class TeamsBotInstallation {
|
|
4597
4643
|
* @returns The response of sending adaptive card message.
|
4598
4644
|
*/
|
4599
4645
|
sendAdaptiveCard(card, onError) {
|
4600
|
-
return
|
4646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4601
4647
|
const response = {};
|
4602
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4648
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4603
4649
|
try {
|
4604
4650
|
const res = yield context.sendActivity({
|
4605
4651
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4624,13 +4670,13 @@ class TeamsBotInstallation {
|
|
4624
4670
|
* @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
|
4625
4671
|
*/
|
4626
4672
|
channels() {
|
4627
|
-
return
|
4673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4628
4674
|
const channels = [];
|
4629
4675
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4630
4676
|
return channels;
|
4631
4677
|
}
|
4632
4678
|
let teamsChannels = [];
|
4633
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4679
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4634
4680
|
const teamId = getTeamsBotInstallationId(context);
|
4635
4681
|
if (teamId !== undefined) {
|
4636
4682
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -4650,12 +4696,12 @@ class TeamsBotInstallation {
|
|
4650
4696
|
* @returns An array of members from where the bot is installed.
|
4651
4697
|
*/
|
4652
4698
|
getPagedMembers(pageSize, continuationToken) {
|
4653
|
-
return
|
4699
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4654
4700
|
let result = {
|
4655
4701
|
data: [],
|
4656
4702
|
continuationToken: "",
|
4657
4703
|
};
|
4658
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4704
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4659
4705
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
|
4660
4706
|
result = {
|
4661
4707
|
data: pagedMembers.members.map((m) => new Member(this, m)),
|
@@ -4673,7 +4719,7 @@ class TeamsBotInstallation {
|
|
4673
4719
|
* @deprecated Use `getPagedMembers` instead.
|
4674
4720
|
*/
|
4675
4721
|
members() {
|
4676
|
-
return
|
4722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4677
4723
|
const members = [];
|
4678
4724
|
let continuationToken;
|
4679
4725
|
do {
|
@@ -4690,12 +4736,12 @@ class TeamsBotInstallation {
|
|
4690
4736
|
* @returns The team details if bot is installed into a team, otherwise returns `undefined`.
|
4691
4737
|
*/
|
4692
4738
|
getTeamDetails() {
|
4693
|
-
return
|
4739
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4694
4740
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4695
4741
|
return undefined;
|
4696
4742
|
}
|
4697
4743
|
let teamDetails;
|
4698
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4744
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4699
4745
|
const teamId = getTeamsBotInstallationId(context);
|
4700
4746
|
if (teamId !== undefined) {
|
4701
4747
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -4751,9 +4797,9 @@ class NotificationBot {
|
|
4751
4797
|
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4752
4798
|
*/
|
4753
4799
|
validateInstallation(conversationReference) {
|
4754
|
-
return
|
4800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4755
4801
|
let isValid = true;
|
4756
|
-
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) =>
|
4802
|
+
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4757
4803
|
try {
|
4758
4804
|
// try get member to see if the installation is still valid
|
4759
4805
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -4779,7 +4825,7 @@ class NotificationBot {
|
|
4779
4825
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4780
4826
|
*/
|
4781
4827
|
getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4782
|
-
return
|
4828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4783
4829
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4784
4830
|
throw new Error("NotificationBot has not been initialized.");
|
4785
4831
|
}
|
@@ -4816,7 +4862,7 @@ class NotificationBot {
|
|
4816
4862
|
* @deprecated Use getPagedInstallations instead.
|
4817
4863
|
*/
|
4818
4864
|
installations() {
|
4819
|
-
return
|
4865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4820
4866
|
let continuationToken;
|
4821
4867
|
const targets = [];
|
4822
4868
|
do {
|
@@ -4839,7 +4885,7 @@ class NotificationBot {
|
|
4839
4885
|
* @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
|
4840
4886
|
*/
|
4841
4887
|
findMember(predicate, scope) {
|
4842
|
-
return
|
4888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4843
4889
|
for (const target of yield this.installations()) {
|
4844
4890
|
if (this.matchSearchScope(target, scope)) {
|
4845
4891
|
for (const member of yield target.members()) {
|
@@ -4863,7 +4909,7 @@ class NotificationBot {
|
|
4863
4909
|
* @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
|
4864
4910
|
*/
|
4865
4911
|
findChannel(predicate) {
|
4866
|
-
return
|
4912
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4867
4913
|
for (const target of yield this.installations()) {
|
4868
4914
|
if (target.type === exports.NotificationTargetType.Channel) {
|
4869
4915
|
const teamDetails = yield target.getTeamDetails();
|
@@ -4887,7 +4933,7 @@ class NotificationBot {
|
|
4887
4933
|
* @returns An array of {@link Member} where predicate is true, and empty array otherwise.
|
4888
4934
|
*/
|
4889
4935
|
findAllMembers(predicate, scope) {
|
4890
|
-
return
|
4936
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4891
4937
|
const members = [];
|
4892
4938
|
for (const target of yield this.installations()) {
|
4893
4939
|
if (this.matchSearchScope(target, scope)) {
|
@@ -4910,7 +4956,7 @@ class NotificationBot {
|
|
4910
4956
|
* @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
|
4911
4957
|
*/
|
4912
4958
|
findAllChannels(predicate) {
|
4913
|
-
return
|
4959
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4914
4960
|
const channels = [];
|
4915
4961
|
for (const target of yield this.installations()) {
|
4916
4962
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -5063,7 +5109,7 @@ class ConversationBot {
|
|
5063
5109
|
const botFrameworkAuthentication = new botbuilder.ConfigurationBotFrameworkAuthentication({}, credentialsFactory);
|
5064
5110
|
const adapter = new botbuilder.CloudAdapter(botFrameworkAuthentication);
|
5065
5111
|
// the default error handler
|
5066
|
-
adapter.onTurnError = (context, error) =>
|
5112
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
5067
5113
|
// This check writes out errors to console.
|
5068
5114
|
console.error(`[onTurnError] unhandled error`, error);
|
5069
5115
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
@@ -5098,10 +5144,10 @@ class ConversationBot {
|
|
5098
5144
|
* ```
|
5099
5145
|
*/
|
5100
5146
|
requestHandler(req, res, logic) {
|
5101
|
-
return
|
5147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
5102
5148
|
if (logic === undefined) {
|
5103
5149
|
// create empty logic
|
5104
|
-
logic = () =>
|
5150
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
5105
5151
|
}
|
5106
5152
|
yield this.adapter.process(req, res, logic);
|
5107
5153
|
});
|