@microsoft/teamsfx 0.6.2-alpha.eb3c5cc12.0 → 0.6.3-alpha.266fa3b9f.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 +676 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +1303 -5
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +698 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1380 -3
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +5 -3
- package/types/teamsfx.d.ts +1649 -653
package/dist/index.esm2017.js
CHANGED
|
@@ -2,6 +2,7 @@ import jwt_decode from 'jwt-decode';
|
|
|
2
2
|
import * as microsoftTeams from '@microsoft/teams-js';
|
|
3
3
|
import { PublicClientApplication } from '@azure/msal-browser';
|
|
4
4
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
5
|
+
import axios from 'axios';
|
|
5
6
|
|
|
6
7
|
// Copyright (c) Microsoft Corporation.
|
|
7
8
|
// Licensed under the MIT license.
|
|
@@ -63,6 +64,10 @@ var ErrorCode;
|
|
|
63
64
|
* Identity type error.
|
|
64
65
|
*/
|
|
65
66
|
ErrorCode["IdentityTypeNotSupported"] = "IdentityTypeNotSupported";
|
|
67
|
+
/**
|
|
68
|
+
* Authentication info already exists error.
|
|
69
|
+
*/
|
|
70
|
+
ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
|
|
66
71
|
})(ErrorCode || (ErrorCode = {}));
|
|
67
72
|
/**
|
|
68
73
|
* @internal
|
|
@@ -84,6 +89,14 @@ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token
|
|
|
84
89
|
ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
|
|
85
90
|
// IdentityTypeNotSupported Error
|
|
86
91
|
ErrorMessage.IdentityTypeNotSupported = "{0} identity is not supported in {1}";
|
|
92
|
+
// AuthorizationInfoError
|
|
93
|
+
ErrorMessage.AuthorizationHeaderAlreadyExists = "Authorization header already exists!";
|
|
94
|
+
ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
|
|
95
|
+
// InvalidParameter Error
|
|
96
|
+
ErrorMessage.EmptyParameter = "Parameter {0} is empty";
|
|
97
|
+
ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
|
|
98
|
+
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
|
99
|
+
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
|
87
100
|
/**
|
|
88
101
|
* Error class with code and message thrown by the SDK.
|
|
89
102
|
*
|
|
@@ -1054,6 +1067,270 @@ class TeamsBotSsoPrompt {
|
|
|
1054
1067
|
}
|
|
1055
1068
|
}
|
|
1056
1069
|
|
|
1070
|
+
// Copyright (c) Microsoft Corporation.
|
|
1071
|
+
/**
|
|
1072
|
+
* Initializes new Axios instance with specific auth provider
|
|
1073
|
+
*
|
|
1074
|
+
* @param apiEndpoint - Base url of the API
|
|
1075
|
+
* @param authProvider - Auth provider that injects authentication info to each request
|
|
1076
|
+
* @returns axios instance configured with specfic auth provider
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```typescript
|
|
1080
|
+
* const client = createApiClient("https://my-api-endpoint-base-url", new BasicAuthProvider("xxx","xxx"));
|
|
1081
|
+
* ```
|
|
1082
|
+
*
|
|
1083
|
+
* @beta
|
|
1084
|
+
*/
|
|
1085
|
+
function createApiClient(apiEndpoint, authProvider) {
|
|
1086
|
+
// Add a request interceptor
|
|
1087
|
+
const instance = axios.create({
|
|
1088
|
+
baseURL: apiEndpoint,
|
|
1089
|
+
});
|
|
1090
|
+
instance.interceptors.request.use(async function (config) {
|
|
1091
|
+
return await authProvider.AddAuthenticationInfo(config);
|
|
1092
|
+
});
|
|
1093
|
+
return instance;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// Copyright (c) Microsoft Corporation.
|
|
1097
|
+
/**
|
|
1098
|
+
* Provider that handles Bearer Token authentication
|
|
1099
|
+
*
|
|
1100
|
+
* @beta
|
|
1101
|
+
*/
|
|
1102
|
+
class BearerTokenAuthProvider {
|
|
1103
|
+
/**
|
|
1104
|
+
* @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
|
|
1105
|
+
*
|
|
1106
|
+
* @beta
|
|
1107
|
+
*/
|
|
1108
|
+
constructor(getToken) {
|
|
1109
|
+
this.getToken = getToken;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Adds authentication info to http requests
|
|
1113
|
+
*
|
|
1114
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1115
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1116
|
+
*
|
|
1117
|
+
* @returns Updated axios request config.
|
|
1118
|
+
*
|
|
1119
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
|
1120
|
+
*
|
|
1121
|
+
* @beta
|
|
1122
|
+
*/
|
|
1123
|
+
async AddAuthenticationInfo(config) {
|
|
1124
|
+
const token = await this.getToken();
|
|
1125
|
+
if (!config.headers) {
|
|
1126
|
+
config.headers = {};
|
|
1127
|
+
}
|
|
1128
|
+
if (config.headers["Authorization"]) {
|
|
1129
|
+
throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1130
|
+
}
|
|
1131
|
+
config.headers["Authorization"] = `Bearer ${token}`;
|
|
1132
|
+
return config;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// Copyright (c) Microsoft Corporation.
|
|
1137
|
+
/**
|
|
1138
|
+
* Provider that handles Basic authentication
|
|
1139
|
+
*
|
|
1140
|
+
* @beta
|
|
1141
|
+
*/
|
|
1142
|
+
class BasicAuthProvider {
|
|
1143
|
+
/**
|
|
1144
|
+
*
|
|
1145
|
+
* @param { string } userName - Username used in basic auth
|
|
1146
|
+
* @param { string } password - Password used in basic auth
|
|
1147
|
+
*
|
|
1148
|
+
* @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
|
|
1149
|
+
*
|
|
1150
|
+
* @beta
|
|
1151
|
+
*/
|
|
1152
|
+
constructor(userName, password) {
|
|
1153
|
+
if (!userName) {
|
|
1154
|
+
throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
|
|
1155
|
+
}
|
|
1156
|
+
if (!password) {
|
|
1157
|
+
throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
|
|
1158
|
+
}
|
|
1159
|
+
this.userName = userName;
|
|
1160
|
+
this.password = password;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Adds authentication info to http requests
|
|
1164
|
+
*
|
|
1165
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1166
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1167
|
+
*
|
|
1168
|
+
* @returns Updated axios request config.
|
|
1169
|
+
*
|
|
1170
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
|
|
1171
|
+
*
|
|
1172
|
+
* @beta
|
|
1173
|
+
*/
|
|
1174
|
+
async AddAuthenticationInfo(config) {
|
|
1175
|
+
if (config.headers && config.headers["Authorization"]) {
|
|
1176
|
+
throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1177
|
+
}
|
|
1178
|
+
if (config.auth) {
|
|
1179
|
+
throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1180
|
+
}
|
|
1181
|
+
config.auth = {
|
|
1182
|
+
username: this.userName,
|
|
1183
|
+
password: this.password,
|
|
1184
|
+
};
|
|
1185
|
+
return config;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Copyright (c) Microsoft Corporation.
|
|
1190
|
+
/**
|
|
1191
|
+
* Provider that handles API Key authentication
|
|
1192
|
+
*
|
|
1193
|
+
* @beta
|
|
1194
|
+
*/
|
|
1195
|
+
class ApiKeyProvider {
|
|
1196
|
+
/**
|
|
1197
|
+
*
|
|
1198
|
+
* @param { string } keyName - The name of request header or query parameter that specifies API Key
|
|
1199
|
+
* @param { string } keyValue - The value of API Key
|
|
1200
|
+
* @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
|
|
1201
|
+
*
|
|
1202
|
+
* @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
|
|
1203
|
+
*
|
|
1204
|
+
* @beta
|
|
1205
|
+
*/
|
|
1206
|
+
constructor(keyName, keyValue, keyLocation) {
|
|
1207
|
+
if (!keyName) {
|
|
1208
|
+
throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyName"), ErrorCode.InvalidParameter);
|
|
1209
|
+
}
|
|
1210
|
+
if (!keyValue) {
|
|
1211
|
+
throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyVaule"), ErrorCode.InvalidParameter);
|
|
1212
|
+
}
|
|
1213
|
+
this.keyName = keyName;
|
|
1214
|
+
this.keyValue = keyValue;
|
|
1215
|
+
this.keyLocation = keyLocation;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Adds authentication info to http requests
|
|
1219
|
+
*
|
|
1220
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1221
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns Updated axios request config.
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
|
|
1226
|
+
*
|
|
1227
|
+
* @beta
|
|
1228
|
+
*/
|
|
1229
|
+
async AddAuthenticationInfo(config) {
|
|
1230
|
+
switch (this.keyLocation) {
|
|
1231
|
+
case ApiKeyLocation.Header:
|
|
1232
|
+
if (!config.headers) {
|
|
1233
|
+
config.headers = {};
|
|
1234
|
+
}
|
|
1235
|
+
if (config.headers[this.keyName]) {
|
|
1236
|
+
throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1237
|
+
}
|
|
1238
|
+
config.headers[this.keyName] = this.keyValue;
|
|
1239
|
+
break;
|
|
1240
|
+
case ApiKeyLocation.QueryParams:
|
|
1241
|
+
if (!config.params) {
|
|
1242
|
+
config.params = {};
|
|
1243
|
+
}
|
|
1244
|
+
const url = new URL(config.url, config.baseURL);
|
|
1245
|
+
if (config.params[this.keyName] || url.searchParams.has(this.keyName)) {
|
|
1246
|
+
throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1247
|
+
}
|
|
1248
|
+
config.params[this.keyName] = this.keyValue;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
return config;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Define available location for API Key location
|
|
1256
|
+
*
|
|
1257
|
+
* @beta
|
|
1258
|
+
*/
|
|
1259
|
+
var ApiKeyLocation;
|
|
1260
|
+
(function (ApiKeyLocation) {
|
|
1261
|
+
/**
|
|
1262
|
+
* The API Key is placed in request header
|
|
1263
|
+
*/
|
|
1264
|
+
ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
|
|
1265
|
+
/**
|
|
1266
|
+
* The API Key is placed in query parameter
|
|
1267
|
+
*/
|
|
1268
|
+
ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
|
|
1269
|
+
})(ApiKeyLocation || (ApiKeyLocation = {}));
|
|
1270
|
+
|
|
1271
|
+
// Copyright (c) Microsoft Corporation.
|
|
1272
|
+
/**
|
|
1273
|
+
* Provider that handles Certificate authentication
|
|
1274
|
+
*
|
|
1275
|
+
* @beta
|
|
1276
|
+
*/
|
|
1277
|
+
class CertificateAuthProvider {
|
|
1278
|
+
/**
|
|
1279
|
+
*
|
|
1280
|
+
* @param { SecureContextOptions } certOption - information about the cert used in http requests
|
|
1281
|
+
*
|
|
1282
|
+
* @beta
|
|
1283
|
+
*/
|
|
1284
|
+
constructor(certOption) {
|
|
1285
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Adds authentication info to http requests.
|
|
1289
|
+
*
|
|
1290
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1291
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1292
|
+
*
|
|
1293
|
+
* @returns Updated axios request config.
|
|
1294
|
+
*
|
|
1295
|
+
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
|
1296
|
+
*
|
|
1297
|
+
* @beta
|
|
1298
|
+
*/
|
|
1299
|
+
async AddAuthenticationInfo(config) {
|
|
1300
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Helper to create SecureContextOptions from PEM format cert
|
|
1305
|
+
*
|
|
1306
|
+
* @param { string | Buffer } cert - The cert chain in PEM format
|
|
1307
|
+
* @param { string | Buffer } key - The private key for the cert chain
|
|
1308
|
+
* @param { string? } passphrase - The passphrase for private key
|
|
1309
|
+
* @param { string? | Buffer? } ca - Overrides the trusted CA certificates
|
|
1310
|
+
*
|
|
1311
|
+
* @returns Instance of SecureContextOptions
|
|
1312
|
+
*
|
|
1313
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1314
|
+
*
|
|
1315
|
+
*/
|
|
1316
|
+
function createPemCertOption(cert, key, passphrase, ca) {
|
|
1317
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Helper to create SecureContextOptions from PFX format cert
|
|
1321
|
+
*
|
|
1322
|
+
* @param { string | Buffer } pfx - The content of .pfx file
|
|
1323
|
+
* @param { string? } passphrase - Optional. The passphrase of .pfx file
|
|
1324
|
+
*
|
|
1325
|
+
* @returns Instance of SecureContextOptions
|
|
1326
|
+
*
|
|
1327
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1328
|
+
*
|
|
1329
|
+
*/
|
|
1330
|
+
function createPfxCertOption(pfx, passphrase) {
|
|
1331
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1057
1334
|
// Copyright (c) Microsoft Corporation.
|
|
1058
1335
|
// Licensed under the MIT license.
|
|
1059
1336
|
/**
|
|
@@ -1170,5 +1447,403 @@ class TeamsFx {
|
|
|
1170
1447
|
}
|
|
1171
1448
|
}
|
|
1172
1449
|
|
|
1173
|
-
|
|
1450
|
+
// Copyright (c) Microsoft Corporation.
|
|
1451
|
+
/**
|
|
1452
|
+
* Provide utilities for bot conversation, including:
|
|
1453
|
+
* - handle command and response.
|
|
1454
|
+
* - send notification to varies targets (e.g., member, group, channel).
|
|
1455
|
+
*
|
|
1456
|
+
* @remarks
|
|
1457
|
+
* Only work on server side.
|
|
1458
|
+
*
|
|
1459
|
+
* @beta
|
|
1460
|
+
*/
|
|
1461
|
+
class ConversationBot {
|
|
1462
|
+
/**
|
|
1463
|
+
* Creates new instance of the `ConversationBot`.
|
|
1464
|
+
*
|
|
1465
|
+
* @param options - initialize options
|
|
1466
|
+
*
|
|
1467
|
+
* @remarks
|
|
1468
|
+
* Only work on server side.
|
|
1469
|
+
*
|
|
1470
|
+
* @beta
|
|
1471
|
+
*/
|
|
1472
|
+
constructor(options) {
|
|
1473
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* The request handler to integrate with web request.
|
|
1477
|
+
*
|
|
1478
|
+
* @param req - an Express or Restify style request object.
|
|
1479
|
+
* @param res - an Express or Restify style response object.
|
|
1480
|
+
* @param logic - the additional function to handle bot context.
|
|
1481
|
+
*
|
|
1482
|
+
* @remarks
|
|
1483
|
+
* Only work on server side.
|
|
1484
|
+
*
|
|
1485
|
+
* @beta
|
|
1486
|
+
*/
|
|
1487
|
+
async requestHandler(req, res, logic) {
|
|
1488
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// Copyright (c) Microsoft Corporation.
|
|
1493
|
+
/**
|
|
1494
|
+
* Send a plain text message to a notification target.
|
|
1495
|
+
*
|
|
1496
|
+
* @remarks
|
|
1497
|
+
* Only work on server side.
|
|
1498
|
+
*
|
|
1499
|
+
* @param target - the notification target.
|
|
1500
|
+
* @param text - the plain text message.
|
|
1501
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1502
|
+
*
|
|
1503
|
+
* @beta
|
|
1504
|
+
*/
|
|
1505
|
+
function sendMessage(target, text) {
|
|
1506
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendMessage"), ErrorCode.RuntimeNotSupported);
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Send an adaptive card message to a notification target.
|
|
1510
|
+
*
|
|
1511
|
+
* @remarks
|
|
1512
|
+
* Only work on server side.
|
|
1513
|
+
*
|
|
1514
|
+
* @param target - the notification target.
|
|
1515
|
+
* @param card - the adaptive card raw JSON.
|
|
1516
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1517
|
+
*
|
|
1518
|
+
* @beta
|
|
1519
|
+
*/
|
|
1520
|
+
function sendAdaptiveCard(target, card) {
|
|
1521
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendAdaptiveCard"), ErrorCode.RuntimeNotSupported);
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* A {@link NotificationTarget} that represents a team channel.
|
|
1525
|
+
*
|
|
1526
|
+
* @remarks
|
|
1527
|
+
* Only work on server side.
|
|
1528
|
+
*
|
|
1529
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
|
|
1530
|
+
*
|
|
1531
|
+
* @beta
|
|
1532
|
+
*/
|
|
1533
|
+
class Channel {
|
|
1534
|
+
/**
|
|
1535
|
+
* Constuctor.
|
|
1536
|
+
*
|
|
1537
|
+
* @remarks
|
|
1538
|
+
* Only work on server side.
|
|
1539
|
+
*
|
|
1540
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
1541
|
+
*
|
|
1542
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
1543
|
+
* @param info - Detailed channel information.
|
|
1544
|
+
*
|
|
1545
|
+
* @beta
|
|
1546
|
+
*/
|
|
1547
|
+
constructor(parent, info) {
|
|
1548
|
+
/**
|
|
1549
|
+
* Notification target type. For channel it's always "Channel".
|
|
1550
|
+
*
|
|
1551
|
+
* @remarks
|
|
1552
|
+
* Only work on server side.
|
|
1553
|
+
*
|
|
1554
|
+
* @beta
|
|
1555
|
+
*/
|
|
1556
|
+
this.type = "Channel";
|
|
1557
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Send a plain text message.
|
|
1561
|
+
*
|
|
1562
|
+
* @remarks
|
|
1563
|
+
* Only work on server side.
|
|
1564
|
+
*
|
|
1565
|
+
* @param text - the plain text message.
|
|
1566
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1567
|
+
*
|
|
1568
|
+
* @beta
|
|
1569
|
+
*/
|
|
1570
|
+
sendMessage(text) {
|
|
1571
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Send an adaptive card message.
|
|
1575
|
+
*
|
|
1576
|
+
* @remarks
|
|
1577
|
+
* Only work on server side.
|
|
1578
|
+
*
|
|
1579
|
+
* @param card - the adaptive card raw JSON.
|
|
1580
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1581
|
+
*
|
|
1582
|
+
* @beta
|
|
1583
|
+
*/
|
|
1584
|
+
async sendAdaptiveCard(card) {
|
|
1585
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* A {@link NotificationTarget} that represents a team member.
|
|
1590
|
+
*
|
|
1591
|
+
* @remarks
|
|
1592
|
+
* Only work on server side.
|
|
1593
|
+
*
|
|
1594
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}.
|
|
1595
|
+
*
|
|
1596
|
+
* @beta
|
|
1597
|
+
*/
|
|
1598
|
+
class Member {
|
|
1599
|
+
/**
|
|
1600
|
+
* Constuctor.
|
|
1601
|
+
*
|
|
1602
|
+
* @remarks
|
|
1603
|
+
* Only work on server side.
|
|
1604
|
+
*
|
|
1605
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
1606
|
+
*
|
|
1607
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
|
|
1608
|
+
* @param account - Detailed member account information.
|
|
1609
|
+
*
|
|
1610
|
+
* @beta
|
|
1611
|
+
*/
|
|
1612
|
+
constructor(parent, account) {
|
|
1613
|
+
/**
|
|
1614
|
+
* Notification target type. For member it's always "Person".
|
|
1615
|
+
*
|
|
1616
|
+
* @remarks
|
|
1617
|
+
* Only work on server side.
|
|
1618
|
+
*
|
|
1619
|
+
* @beta
|
|
1620
|
+
*/
|
|
1621
|
+
this.type = "Person";
|
|
1622
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Send a plain text message.
|
|
1626
|
+
*
|
|
1627
|
+
* @remarks
|
|
1628
|
+
* Only work on server side.
|
|
1629
|
+
*
|
|
1630
|
+
* @param text - the plain text message.
|
|
1631
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1632
|
+
*
|
|
1633
|
+
* @beta
|
|
1634
|
+
*/
|
|
1635
|
+
sendMessage(text) {
|
|
1636
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Send an adaptive card message.
|
|
1640
|
+
*
|
|
1641
|
+
* @remarks
|
|
1642
|
+
* Only work on server side.
|
|
1643
|
+
*
|
|
1644
|
+
* @param card - the adaptive card raw JSON.
|
|
1645
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1646
|
+
*
|
|
1647
|
+
* @beta
|
|
1648
|
+
*/
|
|
1649
|
+
async sendAdaptiveCard(card) {
|
|
1650
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
|
|
1655
|
+
* - Personal chat
|
|
1656
|
+
* - Group chat
|
|
1657
|
+
* - Team (by default the `General` channel)
|
|
1658
|
+
*
|
|
1659
|
+
* @remarks
|
|
1660
|
+
* Only work on server side.
|
|
1661
|
+
*
|
|
1662
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
1663
|
+
*
|
|
1664
|
+
* @beta
|
|
1665
|
+
*/
|
|
1666
|
+
class TeamsBotInstallation {
|
|
1667
|
+
/**
|
|
1668
|
+
* Constructor
|
|
1669
|
+
*
|
|
1670
|
+
* @remarks
|
|
1671
|
+
* Only work on server side.
|
|
1672
|
+
*
|
|
1673
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
|
|
1674
|
+
*
|
|
1675
|
+
* @param adapter - the bound `BotFrameworkAdapter`.
|
|
1676
|
+
* @param conversationReference - the bound `ConversationReference`.
|
|
1677
|
+
*
|
|
1678
|
+
* @beta
|
|
1679
|
+
*/
|
|
1680
|
+
constructor(adapter, conversationReference) {
|
|
1681
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Send a plain text message.
|
|
1685
|
+
*
|
|
1686
|
+
* @remarks
|
|
1687
|
+
* Only work on server side.
|
|
1688
|
+
*
|
|
1689
|
+
* @param text - the plain text message.
|
|
1690
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1691
|
+
*
|
|
1692
|
+
* @beta
|
|
1693
|
+
*/
|
|
1694
|
+
sendMessage(text) {
|
|
1695
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Send an adaptive card message.
|
|
1699
|
+
*
|
|
1700
|
+
* @remarks
|
|
1701
|
+
* Only work on server side.
|
|
1702
|
+
*
|
|
1703
|
+
* @param card - the adaptive card raw JSON.
|
|
1704
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1705
|
+
*
|
|
1706
|
+
* @beta
|
|
1707
|
+
*/
|
|
1708
|
+
sendAdaptiveCard(card) {
|
|
1709
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Get channels from this bot installation.
|
|
1713
|
+
*
|
|
1714
|
+
* @remarks
|
|
1715
|
+
* Only work on server side.
|
|
1716
|
+
*
|
|
1717
|
+
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
|
1718
|
+
*
|
|
1719
|
+
* @beta
|
|
1720
|
+
*/
|
|
1721
|
+
async channels() {
|
|
1722
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Get members from this bot installation.
|
|
1726
|
+
*
|
|
1727
|
+
* @remarks
|
|
1728
|
+
* Only work on server side.
|
|
1729
|
+
*
|
|
1730
|
+
* @returns an array of members from where the bot is installed.
|
|
1731
|
+
*
|
|
1732
|
+
* @beta
|
|
1733
|
+
*/
|
|
1734
|
+
async members() {
|
|
1735
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Provide static utilities for bot notification.
|
|
1740
|
+
*
|
|
1741
|
+
* @remarks
|
|
1742
|
+
* Only work on server side.
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* Here's an example on how to send notification via Teams Bot.
|
|
1746
|
+
* ```typescript
|
|
1747
|
+
* // initialize (it's recommended to be called before handling any bot message)
|
|
1748
|
+
* const notificationBot = new NotificationBot(adapter);
|
|
1749
|
+
*
|
|
1750
|
+
* // get all bot installations and send message
|
|
1751
|
+
* for (const target of await notificationBot.installations()) {
|
|
1752
|
+
* await target.sendMessage("Hello Notification");
|
|
1753
|
+
* }
|
|
1754
|
+
*
|
|
1755
|
+
* // alternative - send message to all members
|
|
1756
|
+
* for (const target of await notificationBot.installations()) {
|
|
1757
|
+
* for (const member of await target.members()) {
|
|
1758
|
+
* await member.sendMessage("Hello Notification");
|
|
1759
|
+
* }
|
|
1760
|
+
* }
|
|
1761
|
+
* ```
|
|
1762
|
+
*
|
|
1763
|
+
* @beta
|
|
1764
|
+
*/
|
|
1765
|
+
class NotificationBot {
|
|
1766
|
+
/**
|
|
1767
|
+
* constructor of the notification bot.
|
|
1768
|
+
*
|
|
1769
|
+
* @remarks
|
|
1770
|
+
* Only work on server side.
|
|
1771
|
+
*
|
|
1772
|
+
* To ensure accuracy, it's recommended to initialize before handling any message.
|
|
1773
|
+
*
|
|
1774
|
+
* @param adapter - the bound `BotFrameworkAdapter`
|
|
1775
|
+
* @param options - initialize options
|
|
1776
|
+
*
|
|
1777
|
+
* @beta
|
|
1778
|
+
*/
|
|
1779
|
+
constructor(adapter, options) {
|
|
1780
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported);
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Get all targets where the bot is installed.
|
|
1784
|
+
*
|
|
1785
|
+
* @remarks
|
|
1786
|
+
* Only work on server side.
|
|
1787
|
+
*
|
|
1788
|
+
* The result is retrieving from the persisted storage.
|
|
1789
|
+
*
|
|
1790
|
+
* @returns - an array of {@link TeamsBotInstallation}.
|
|
1791
|
+
*
|
|
1792
|
+
* @beta
|
|
1793
|
+
*/
|
|
1794
|
+
static async installations() {
|
|
1795
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// Copyright (c) Microsoft Corporation.
|
|
1800
|
+
/**
|
|
1801
|
+
* A command bot for receiving commands and sending responses in Teams.
|
|
1802
|
+
*
|
|
1803
|
+
* @remarks
|
|
1804
|
+
* Only work on server side.
|
|
1805
|
+
*
|
|
1806
|
+
* @beta
|
|
1807
|
+
*/
|
|
1808
|
+
class CommandBot {
|
|
1809
|
+
/**
|
|
1810
|
+
* Creates a new instance of the `CommandBot`.
|
|
1811
|
+
*
|
|
1812
|
+
* @param adapter The bound `BotFrameworkAdapter`.
|
|
1813
|
+
* @param commands The commands to registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
|
|
1814
|
+
*
|
|
1815
|
+
* @beta
|
|
1816
|
+
*/
|
|
1817
|
+
constructor(adapter, commands) {
|
|
1818
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Registers a command into the command bot.
|
|
1822
|
+
*
|
|
1823
|
+
* @param command The command to registered.
|
|
1824
|
+
*
|
|
1825
|
+
* @remarks
|
|
1826
|
+
* Only work on server side.
|
|
1827
|
+
*
|
|
1828
|
+
* @beta
|
|
1829
|
+
*/
|
|
1830
|
+
registerCommand(command) {
|
|
1831
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Registers commands into the command bot.
|
|
1835
|
+
*
|
|
1836
|
+
* @param commands The command to registered.
|
|
1837
|
+
*
|
|
1838
|
+
* @remarks
|
|
1839
|
+
* Only work on server side.
|
|
1840
|
+
*
|
|
1841
|
+
* @beta
|
|
1842
|
+
*/
|
|
1843
|
+
registerCommands(commands) {
|
|
1844
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandnBot"), ErrorCode.RuntimeNotSupported);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
export { ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, LogLevel, Member, MsGraphAuthProvider, NotificationBot, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1174
1849
|
//# sourceMappingURL=index.esm2017.js.map
|