@microsoft/teamsfx 1.1.2-alpha.c46d33f34.0 → 1.1.2-alpha.d61ffd7b2.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 +104 -19
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +394 -108
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +104 -19
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +402 -110
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -3
- package/types/teamsfx.d.ts +222 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teamsfx",
|
|
3
|
-
"version": "1.1.2-alpha.
|
|
3
|
+
"version": "1.1.2-alpha.d61ffd7b2.0",
|
|
4
4
|
"description": "Microsoft Teams Framework for Node.js and browser.",
|
|
5
5
|
"main": "dist/index.node.cjs.js",
|
|
6
6
|
"browser": "dist/index.esm2017.js",
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"@azure/identity": "^2.0.1",
|
|
50
50
|
"@azure/msal-browser": "^2.21.0",
|
|
51
51
|
"@azure/msal-node": "~1.1.0",
|
|
52
|
-
"@microsoft/adaptivecards-tools": "1.0.2-alpha.
|
|
52
|
+
"@microsoft/adaptivecards-tools": "1.0.2-alpha.d61ffd7b2.0",
|
|
53
53
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
54
|
+
"adaptivecards": "^2.10.0",
|
|
54
55
|
"axios": "^0.27.2",
|
|
55
56
|
"botbuilder": ">=4.15.0 <5.0.0",
|
|
56
57
|
"botbuilder-dialogs": ">=4.15.0 <5.0.0",
|
|
@@ -128,7 +129,7 @@
|
|
|
128
129
|
"webpack": "^5.62.1",
|
|
129
130
|
"yargs": "^17.2.1"
|
|
130
131
|
},
|
|
131
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "ebe3f7cb6ab5c7ee8b2f925816fa5b3f432f10c8",
|
|
132
133
|
"publishConfig": {
|
|
133
134
|
"access": "public"
|
|
134
135
|
},
|
package/types/teamsfx.d.ts
CHANGED
|
@@ -19,9 +19,13 @@ import { DialogContext } from 'botbuilder-dialogs';
|
|
|
19
19
|
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
20
20
|
import { GetTokenOptions } from '@azure/identity';
|
|
21
21
|
import { HeroCard } from 'botbuilder';
|
|
22
|
+
import { IAdaptiveCard } from 'adaptivecards';
|
|
23
|
+
import { InvokeResponse } from 'botbuilder-core';
|
|
24
|
+
import { InvokeResponse as InvokeResponse_2 } from 'botbuilder';
|
|
22
25
|
import { O365ConnectorCard } from 'botbuilder';
|
|
23
26
|
import { ReceiptCard } from 'botbuilder';
|
|
24
27
|
import { SecureContextOptions } from 'tls';
|
|
28
|
+
import { StatusCodes } from 'botbuilder';
|
|
25
29
|
import { TeamsChannelAccount } from 'botbuilder';
|
|
26
30
|
import { ThumbnailCard } from 'botbuilder';
|
|
27
31
|
import { TokenCredential } from '@azure/identity';
|
|
@@ -31,6 +35,24 @@ import { TurnContext as TurnContext_2 } from 'botbuilder';
|
|
|
31
35
|
import { WebRequest } from 'botbuilder';
|
|
32
36
|
import { WebResponse } from 'botbuilder';
|
|
33
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Options used to control how the response card will be sent to users.
|
|
40
|
+
*/
|
|
41
|
+
export declare enum AdaptiveCardResponse {
|
|
42
|
+
/**
|
|
43
|
+
* The response card will be replaced the current one for the interactor who trigger the action.
|
|
44
|
+
*/
|
|
45
|
+
ReplaceForInteractor = 0,
|
|
46
|
+
/**
|
|
47
|
+
* The response card will be replaced the current one for all users in the chat.
|
|
48
|
+
*/
|
|
49
|
+
ReplaceForAll = 1,
|
|
50
|
+
/**
|
|
51
|
+
* The response card will be sent as a new message for all users in the chat.
|
|
52
|
+
*/
|
|
53
|
+
NewForAll = 2
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
/**
|
|
35
57
|
* Define available location for API Key location
|
|
36
58
|
*/
|
|
@@ -249,6 +271,41 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
|
249
271
|
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
250
272
|
}
|
|
251
273
|
|
|
274
|
+
/**
|
|
275
|
+
* A card action bot to respond to adaptive card universal actions.
|
|
276
|
+
*/
|
|
277
|
+
export declare class CardActionBot {
|
|
278
|
+
private readonly adapter;
|
|
279
|
+
private middleware;
|
|
280
|
+
/**
|
|
281
|
+
* Creates a new instance of the `CardActionBot`.
|
|
282
|
+
*
|
|
283
|
+
* @param adapter The bound `BotFrameworkAdapter`.
|
|
284
|
+
* @param options - initialize options
|
|
285
|
+
*/
|
|
286
|
+
constructor(adapter: BotFrameworkAdapter, options?: CardActionOptions);
|
|
287
|
+
/**
|
|
288
|
+
* Registers a card action handler to the bot.
|
|
289
|
+
* @param actionHandler A card action handler to be registered.
|
|
290
|
+
*/
|
|
291
|
+
registerHandler(actionHandler: TeamsFxAdaptiveCardActionHandler): void;
|
|
292
|
+
/**
|
|
293
|
+
* Registers card action handlers to the bot.
|
|
294
|
+
* @param actionHandlers A set of card action handlers to be registered.
|
|
295
|
+
*/
|
|
296
|
+
registerHandlers(actionHandlers: TeamsFxAdaptiveCardActionHandler[]): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Options to initialize {@link CardActionBot}.
|
|
301
|
+
*/
|
|
302
|
+
export declare interface CardActionOptions {
|
|
303
|
+
/**
|
|
304
|
+
* The action handlers to registered with the action bot. Each command should implement the interface {@link TeamsFxAdaptiveCardActionHandler} so that it can be correctly handled by this bot.
|
|
305
|
+
*/
|
|
306
|
+
actions?: TeamsFxAdaptiveCardActionHandler[];
|
|
307
|
+
}
|
|
308
|
+
|
|
252
309
|
/**
|
|
253
310
|
* Provider that handles Certificate authentication
|
|
254
311
|
*/
|
|
@@ -441,6 +498,10 @@ export declare class ConversationBot {
|
|
|
441
498
|
* The entrypoint of notification.
|
|
442
499
|
*/
|
|
443
500
|
readonly notification?: NotificationBot;
|
|
501
|
+
/**
|
|
502
|
+
* The action handler used for adaptive card universal actions.
|
|
503
|
+
*/
|
|
504
|
+
readonly cardAction?: CardActionBot;
|
|
444
505
|
/**
|
|
445
506
|
* Creates new instance of the `ConversationBot`.
|
|
446
507
|
*
|
|
@@ -515,6 +576,15 @@ export declare interface ConversationOptions {
|
|
|
515
576
|
*/
|
|
516
577
|
enabled?: boolean;
|
|
517
578
|
};
|
|
579
|
+
/**
|
|
580
|
+
* The adaptive card action handler part.
|
|
581
|
+
*/
|
|
582
|
+
cardAction?: CardActionOptions & {
|
|
583
|
+
/**
|
|
584
|
+
* Whether to enable adaptive card actions or not.
|
|
585
|
+
*/
|
|
586
|
+
enabled?: boolean;
|
|
587
|
+
};
|
|
518
588
|
}
|
|
519
589
|
|
|
520
590
|
/**
|
|
@@ -702,6 +772,10 @@ export declare class ErrorWithCode extends Error {
|
|
|
702
772
|
*/
|
|
703
773
|
export declare function getLogLevel(): LogLevel | undefined;
|
|
704
774
|
|
|
775
|
+
export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
|
|
776
|
+
resources?: string[];
|
|
777
|
+
}
|
|
778
|
+
|
|
705
779
|
/**
|
|
706
780
|
* Generate connection configuration consumed by tedious.
|
|
707
781
|
*
|
|
@@ -730,6 +804,96 @@ export declare enum IdentityType {
|
|
|
730
804
|
App = "Application"
|
|
731
805
|
}
|
|
732
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Status code for an `application/vnd.microsoft.error` invoke response.
|
|
809
|
+
*/
|
|
810
|
+
export declare enum InvokeResponseErrorCode {
|
|
811
|
+
/**
|
|
812
|
+
* Invalid request.
|
|
813
|
+
*/
|
|
814
|
+
BadRequest = 400,
|
|
815
|
+
/**
|
|
816
|
+
* Internal server error.
|
|
817
|
+
*/
|
|
818
|
+
InternalServerError = 500
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
|
823
|
+
*
|
|
824
|
+
* @remarks
|
|
825
|
+
* All of these functions return an {@link InvokeResponse} object, which can be
|
|
826
|
+
* passed as input to generate a new `invokeResponse` activity.
|
|
827
|
+
*
|
|
828
|
+
* This example sends an invoke response that contains an adaptive card.
|
|
829
|
+
*
|
|
830
|
+
* ```typescript
|
|
831
|
+
*
|
|
832
|
+
* const myCard: IAdaptiveCard = {
|
|
833
|
+
* type: "AdaptiveCard",
|
|
834
|
+
* body: [
|
|
835
|
+
* {
|
|
836
|
+
* "type": "TextBlock",
|
|
837
|
+
* "text": "This is a sample card"
|
|
838
|
+
* }],
|
|
839
|
+
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
840
|
+
* version: "1.4"
|
|
841
|
+
* };
|
|
842
|
+
*
|
|
843
|
+
* const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
|
|
844
|
+
* await context.sendActivity({
|
|
845
|
+
* type: ActivityTypes.InvokeResponse,
|
|
846
|
+
* value: invokeResponse,
|
|
847
|
+
* });
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
export declare class InvokeResponseFactory {
|
|
851
|
+
/**
|
|
852
|
+
* Create an invoke response from a text message.
|
|
853
|
+
* The type of the invoke response is `application/vnd.microsoft.activity.message`
|
|
854
|
+
* indicates the request was successfully processed.
|
|
855
|
+
*
|
|
856
|
+
* @param message A text message included in a invoke response.
|
|
857
|
+
*
|
|
858
|
+
* @returns {InvokeResponse} An InvokeResponse object.
|
|
859
|
+
*/
|
|
860
|
+
static textMessage(message: string): InvokeResponse_2;
|
|
861
|
+
/**
|
|
862
|
+
* Create an invoke response from an adaptive card.
|
|
863
|
+
*
|
|
864
|
+
* The type of the invoke response is `application/vnd.microsoft.card.adaptive` indicates
|
|
865
|
+
* the request was successfully processed, and the response includes an adaptive card
|
|
866
|
+
* that the client should display in place of the current one.
|
|
867
|
+
*
|
|
868
|
+
* @param card The adaptive card JSON payload.
|
|
869
|
+
*
|
|
870
|
+
* @returns {InvokeResponse} An InvokeResponse object.
|
|
871
|
+
*/
|
|
872
|
+
static adaptiveCard(card: IAdaptiveCard): InvokeResponse_2;
|
|
873
|
+
/**
|
|
874
|
+
* Create an invoke response with error code and message.
|
|
875
|
+
*
|
|
876
|
+
* The type of the invoke response is `application/vnd.microsoft.error` indicates
|
|
877
|
+
* the request was failed to processed.
|
|
878
|
+
*
|
|
879
|
+
* @param errorCode The status code indicates error, available values:
|
|
880
|
+
* - 400 (BadRequest): indicate the incoming request was invalid.
|
|
881
|
+
* - 500 (InternalServerError): indicate an unexpected error occurred.
|
|
882
|
+
* @param errorMessage The error message.
|
|
883
|
+
*
|
|
884
|
+
* @returns {InvokeResponse} An InvokeResponse object.
|
|
885
|
+
*/
|
|
886
|
+
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse_2;
|
|
887
|
+
/**
|
|
888
|
+
* Create an invoke response with status code and response value.
|
|
889
|
+
* @param statusCode The status code.
|
|
890
|
+
* @param body The value of the response body.
|
|
891
|
+
*
|
|
892
|
+
* @returns {InvokeResponse} An InvokeResponse object.
|
|
893
|
+
*/
|
|
894
|
+
static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse_2;
|
|
895
|
+
}
|
|
896
|
+
|
|
733
897
|
/**
|
|
734
898
|
* Log function for customized logging.
|
|
735
899
|
*/
|
|
@@ -1511,7 +1675,7 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1511
1675
|
*
|
|
1512
1676
|
* @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
|
|
1513
1677
|
*/
|
|
1514
|
-
constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
|
|
1678
|
+
constructor(identityType?: IdentityType, customConfig?: Record<string, string> | AuthenticationConfiguration);
|
|
1515
1679
|
/**
|
|
1516
1680
|
* Identity type set by user.
|
|
1517
1681
|
*
|
|
@@ -1530,9 +1694,10 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1530
1694
|
getCredential(): TokenCredential;
|
|
1531
1695
|
/**
|
|
1532
1696
|
* Get user information.
|
|
1697
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1533
1698
|
* @returns UserInfo object.
|
|
1534
1699
|
*/
|
|
1535
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1700
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1536
1701
|
/**
|
|
1537
1702
|
* Popup login page to get user's access token with specific scopes.
|
|
1538
1703
|
*
|
|
@@ -1547,13 +1712,14 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1547
1712
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1548
1713
|
* ```
|
|
1549
1714
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
1715
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1550
1716
|
*
|
|
1551
1717
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1552
1718
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1553
1719
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1554
1720
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1555
1721
|
*/
|
|
1556
|
-
login(scopes: string | string[]): Promise<void>;
|
|
1722
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1557
1723
|
/**
|
|
1558
1724
|
* Set SSO token when using user identity in NodeJS.
|
|
1559
1725
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1583,6 +1749,47 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1583
1749
|
private loadFromEnv;
|
|
1584
1750
|
}
|
|
1585
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* Interface for adaptive card action handler that can process card action invoke and return a response.
|
|
1754
|
+
*/
|
|
1755
|
+
export declare interface TeamsFxAdaptiveCardActionHandler {
|
|
1756
|
+
/**
|
|
1757
|
+
* The verb defined in adaptive card action that can trigger this handler.
|
|
1758
|
+
* The verb string here is case-insensitive.
|
|
1759
|
+
*/
|
|
1760
|
+
triggerVerb: string;
|
|
1761
|
+
/**
|
|
1762
|
+
* Specify the behavior for how the card response will be sent in Teams conversation.
|
|
1763
|
+
* The default value is `AdaptiveCardResponse.ReplaceForInteractor`, which means the card
|
|
1764
|
+
* response will replace the current one only for the interactor.
|
|
1765
|
+
*/
|
|
1766
|
+
adaptiveCardResponse?: AdaptiveCardResponse;
|
|
1767
|
+
/**
|
|
1768
|
+
* The handler function that will be invoked when the action is fired.
|
|
1769
|
+
* @param context The turn context.
|
|
1770
|
+
* @param actionData The contextual data that associated with the action.
|
|
1771
|
+
*
|
|
1772
|
+
* @returns A `Promise` representing a invoke response for the adaptive card invoke action.
|
|
1773
|
+
* You can use the `InvokeResponseFactory` utility class to create an invoke response from
|
|
1774
|
+
* - A text message:
|
|
1775
|
+
* ```typescript
|
|
1776
|
+
* return InvokeResponseFactory.textMessage("Action is processed successfully!");
|
|
1777
|
+
* ```
|
|
1778
|
+
* - An adaptive card:
|
|
1779
|
+
* ```typescript
|
|
1780
|
+
* const responseCard = AdaptiveCards.declare(helloWorldCard).render(actionData);
|
|
1781
|
+
return InvokeResponseFactory.adaptiveCard(responseCard);
|
|
1782
|
+
* ```
|
|
1783
|
+
* - An error response:
|
|
1784
|
+
* ```typescript
|
|
1785
|
+
* return InvokeResponseFactory.errorResponse(InvokeResponseErrorCode.BadRequest, "Invalid request");
|
|
1786
|
+
* ```
|
|
1787
|
+
*
|
|
1788
|
+
* @remark For more details about the invoke response format, refer to https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model#response-format.
|
|
1789
|
+
*/
|
|
1790
|
+
handleActionInvoked(context: TurnContext, actionData: any): Promise<InvokeResponse>;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1586
1793
|
/**
|
|
1587
1794
|
* Interface for a command handler that can process command to a TeamsFx bot and return a response.
|
|
1588
1795
|
*/
|
|
@@ -1624,9 +1831,10 @@ declare interface TeamsFxConfiguration {
|
|
|
1624
1831
|
getCredential(): TokenCredential;
|
|
1625
1832
|
/**
|
|
1626
1833
|
* Get user information.
|
|
1834
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1627
1835
|
* @returns UserInfo object.
|
|
1628
1836
|
*/
|
|
1629
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1837
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1630
1838
|
/**
|
|
1631
1839
|
* Popup login page to get user's access token with specific scopes.
|
|
1632
1840
|
*
|
|
@@ -1641,13 +1849,14 @@ declare interface TeamsFxConfiguration {
|
|
|
1641
1849
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1642
1850
|
* ```
|
|
1643
1851
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
1852
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1644
1853
|
*
|
|
1645
1854
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1646
1855
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1647
1856
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1648
1857
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1649
1858
|
*/
|
|
1650
|
-
login(scopes: string | string[]): Promise<void>;
|
|
1859
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1651
1860
|
/**
|
|
1652
1861
|
* Set SSO token when using user identity in NodeJS.
|
|
1653
1862
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1688,10 +1897,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1688
1897
|
constructor(authConfig: AuthenticationConfiguration);
|
|
1689
1898
|
/**
|
|
1690
1899
|
* Popup login page to get user's access token with specific scopes.
|
|
1900
|
+
*
|
|
1901
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1902
|
+
*
|
|
1691
1903
|
* @remarks
|
|
1692
1904
|
* Can only be used within Teams.
|
|
1693
1905
|
*/
|
|
1694
|
-
login(scopes: string | string[]): Promise<void>;
|
|
1906
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1695
1907
|
/**
|
|
1696
1908
|
* Get access token from credential.
|
|
1697
1909
|
* @remarks
|
|
@@ -1700,10 +1912,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1700
1912
|
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
1701
1913
|
/**
|
|
1702
1914
|
* Get basic user info from SSO token
|
|
1915
|
+
*
|
|
1916
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1917
|
+
*
|
|
1703
1918
|
* @remarks
|
|
1704
1919
|
* Can only be used within Teams.
|
|
1705
1920
|
*/
|
|
1706
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1921
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1707
1922
|
}
|
|
1708
1923
|
|
|
1709
1924
|
/**
|