Skip to content

Commit

Permalink
rename CEC to CEA
Browse files Browse the repository at this point in the history
  • Loading branch information
MengyiGong committed Sep 19, 2024
1 parent 3fb5cd6 commit 26f2731
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import React from 'react';
import { ApiWithoutInput, ApiWithTextInput } from '../utils';
import { ModuleWrapper } from '../utils/ModuleWrapper';

const CheckExternalAppCardActionsForCECCapability = (): React.ReactElement =>
const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement =>
ApiWithoutInput({
name: 'checkExternalAppCardActionsForCECCapability',
title: 'Check External App Card Actions For CEC Capability',
name: 'checkExternalAppCardActionsForCEACapability',
title: 'Check External App Card Actions For CEA Capability',
onClick: async () =>
`External App Card Actions For CEC module ${externalAppCardActions.isSupported() ? 'is' : 'is not'} supported`,
`External App Card Actions For CEA module ${externalAppCardActions.isSupported() ? 'is' : 'is not'} supported`,
});

const CECProcessActionSubmit = (): React.ReactElement =>
ApiWithTextInput<{
appId: string;
actionSubmitPayload: IAdaptiveCardActionSubmit;
}>({
name: 'processActionSubmitForCEC',
title: 'Process Action Submit For CEC',
name: 'processActionSubmitForCEA',
title: 'Process Action Submit For CEA',
onClick: {
validateInput: (input) => {
if (!input.appId) {
Expand Down Expand Up @@ -48,8 +48,8 @@ const CECProcessActionOpenUrl = (): React.ReactElement =>
url: string;
fromElement?: { name: 'composeExtensions' | 'plugins' };
}>({
name: 'processActionOpenUrlForCEC',
title: 'Process Action Open Url For CEC',
name: 'processActionOpenUrlForCEA',
title: 'Process Action Open Url For CEA',
onClick: {
validateInput: (input) => {
if (!input.appId) {
Expand All @@ -74,12 +74,12 @@ const CECProcessActionOpenUrl = (): React.ReactElement =>
}),
});

const ExternalAppCardActionsForCECAPIs = (): React.ReactElement => (
<ModuleWrapper title="External App Card Actions For CEC">
<CheckExternalAppCardActionsForCECCapability />
const ExternalAppCardActionsForCEAAPIs = (): React.ReactElement => (
<ModuleWrapper title="External App Card Actions For CEA">
<CheckExternalAppCardActionsForCEACapability />
<CECProcessActionSubmit />
<CECProcessActionOpenUrl />
</ModuleWrapper>
);

export default ExternalAppCardActionsForCECAPIs;
export default ExternalAppCardActionsForCEAAPIs;
4 changes: 2 additions & 2 deletions apps/teams-test-app/src/pages/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import ChatAPIs from '../components/privateApis/ChatAPIs';
import CopilotAPIs from '../components/privateApis/CopilotAPIs';
import ExternalAppAuthenticationAPIs from '../components/privateApis/ExternalAppAuthenticationAPIs';
import ExternalAppCardActionsAPIs from '../components/privateApis/ExternalAppCardActionsAPIs';
import ExternalAppCardActionsForCECAPIs from '../components/privateApis/ExternalAppCardActionsForCECAPIs';
import ExternalAppCardActionsForCEAAPIs from '../components/privateApis/ExternalAppCardActionsForCEAAPIs';
import ExternalAppCommandsAPIs from '../components/privateApis/ExternalAppCommandsAPIs';
import FilesAPIs from '../components/privateApis/FilesAPIs';
import FullTrustAPIs from '../components/privateApis/FullTrustAPIs';
Expand Down Expand Up @@ -115,7 +115,7 @@ export const TestApp: React.FC = () => {
<DialogUrlParentCommunicationAPIs childWindowRef={dialogWindowRef} />
<ExternalAppAuthenticationAPIs />
<ExternalAppCardActionsAPIs />
<ExternalAppCardActionsForCECAPIs />
<ExternalAppCardActionsForCEAAPIs />
<ExternalAppCommandsAPIs />
<FilesAPIs />
<FullTrustAPIs />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "minor",
"comment": "Added APIs for externalAppCardActionForCEC capability.",
"comment": "Added APIs for externalAppCardActionForCEA capability.",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
Expand Down
4 changes: 2 additions & 2 deletions packages/teams-js/src/internal/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export const enum ApiName {
ExternalAppAuthentication_AuthenticateWithPowerPlatformConnectorPlugins = 'externalAppAuthentication.authenticateWithPowerPlatformConnectorPlugins',
ExternalAppCardActions_ProcessActionOpenUrl = 'externalAppCardActions.processActionOpenUrl',
ExternalAppCardActions_ProcessActionSubmit = 'externalAppCardActions.processActionSubmit',
ExternalAppCardActionsForCEC_ProcessActionOpenUrl = 'externalAppCardActions.cec.processActionOpenUrl',
ExternalAppCardActionsForCEC_ProcessActionSubmit = 'externalAppCardActions.cec.processActionSubmit',
ExternalAppCardActionsForCEA_ProcessActionOpenUrl = 'externalAppCardActionsForCEA.processActionOpenUrl',
ExternalAppCardActionsForCEA_ProcessActionSubmit = 'externalAppCardActionsForCEA.processActionSubmit',
ExternalAppCommands_ProcessActionCommands = 'externalAppCommands.processActionCommand',
Files_AddCloudStorageFolder = 'files.addCloudStorageFolder',
Files_AddCloudStorageProvider = 'files.addCloudStorageProvider',
Expand Down
40 changes: 40 additions & 0 deletions packages/teams-js/src/private/externalAppCardActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,30 @@ const externalAppCardActionsTelemetryVersionNumber: ApiVersionNumber = ApiVersio
* Limited to Microsoft-internal use
*/
export namespace externalAppCardActions {
/**
* @hidden
* The type of deeplink action that was executed by the host
* @internal
* Limited to Microsoft-internal use
*/
export enum ActionOpenUrlType {
DeepLinkDialog = 'DeepLinkDialog',
DeepLinkOther = 'DeepLinkOther',
DeepLinkStageView = 'DeepLinkStageView',
GenericUrl = 'GenericUrl',
}

/**
* @beta
* @hidden
* Delegates an Adaptive Card Action.Submit request to the host for the application with the provided app ID
* @internal
* Limited to Microsoft-internal use
* @param appId ID of the application the request is intended for. This must be a UUID
* @param actionSubmitPayload The Adaptive Card Action.Submit payload
* @param cardActionsConfig The card actions configuration. This indicates which subtypes should be handled by this API
* @returns Promise that resolves when the request is completed and rejects with ActionSubmitError if the request fails
*/
export function processActionSubmit(appId: string, actionSubmitPayload: IAdaptiveCardActionSubmit): Promise<void> {
ensureInitialized(runtime, FrameContexts.content);

Expand All @@ -47,6 +64,19 @@ export namespace externalAppCardActions {
});
}

/**
* @beta
* @hidden
* Delegates an Adaptive Card Action.OpenUrl request to the host for the application with the provided app ID.
* If `fromElement` is not provided, the information from the manifest is used to determine whether the URL can
* be processed by the host. Deep link URLs for plugins are not supported and will result in an error.
* @internal
* Limited to Microsoft-internal use
* @param appId ID of the application the request is intended for. This must be a UUID
* @param url The URL to open
* @param fromElement The element on behalf of which the M365 app is making the request.
* @returns Promise that resolves to ActionOpenUrlType indicating the type of URL that was opened on success and rejects with ActionOpenUrlError if the request fails
*/
export function processActionOpenUrl(
appId: string,
url: URL,
Expand Down Expand Up @@ -74,6 +104,16 @@ export namespace externalAppCardActions {
});
}

/**
* @hidden
* Checks if the externalAppCardActions capability is supported by the host
* @returns boolean to represent whether externalAppCardActions capability is supported
*
* @throws Error if {@linkcode app.initialize} has not successfully completed
*
* @internal
* Limited to Microsoft-internal use
*/
export function isSupported(): boolean {
return ensureInitialized(runtime) && runtime.supports.externalAppCardActions ? true : false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@ import { ActionOpenUrlError, ActionOpenUrlType, ActionSubmitError, IAdaptiveCard
* Updated to constants file: v2 APIs telemetry file: All of APIs in this capability file should send out API version v2 ONLY
*/
const externalAppCardActionsTelemetryVersionNumber: ApiVersionNumber = ApiVersionNumber.V_2;
export namespace externalAppCardActionsForCEC {
export namespace externalAppCardActionsForCEA {
/**
* @beta
* @hidden
* Delegates an Adaptive Card Action.OpenUrl request to the host for the application with the provided app ID.
* If `fromElement` is not provided, the information from the manifest is used to determine whether the URL can
* be processed by the host. Deep link URLs for plugins are not supported and will result in an error.
* @internal
* Limited to Microsoft-internal use
* @param appId ID of the application the request is intended for. This must be a UUID
* @param conversationId To tell the bot what conversation the calls are coming from
* @param url The URL to open
* @returns Promise that resolves to ActionOpenUrlType indicating the type of URL that was opened on success and rejects with ActionOpenUrlError if the request fails
*/
export function processActionOpenUrl(appId: string, conversationId: string, url: URL): Promise<ActionOpenUrlType> {
ensureInitialized(runtime, FrameContexts.content);

Expand All @@ -22,9 +35,9 @@ export namespace externalAppCardActionsForCEC {
return sendMessageToParentAsync<[ActionOpenUrlError, ActionOpenUrlType]>(
getApiVersionTag(
externalAppCardActionsTelemetryVersionNumber,
ApiName.ExternalAppCardActionsForCEC_ProcessActionOpenUrl,
ApiName.ExternalAppCardActionsForCEA_ProcessActionOpenUrl,
),
'externalAppCardActionsForCEC.processActionOpenUrl',
'externalAppCardActionsForCEA.processActionOpenUrl',
[appId, url.href, conversationId],
).then(([error, response]: [ActionOpenUrlError, ActionOpenUrlType]) => {
if (error) {
Expand All @@ -35,6 +48,17 @@ export namespace externalAppCardActionsForCEC {
});
}

/**
* @beta
* @hidden
* Delegates an Adaptive Card Action.Submit request to the host for the application with the provided app ID
* @internal
* Limited to Microsoft-internal use
* @param appId ID of the application the request is intended for. This must be a UUID
* @param conversationId To tell the bot what conversation the calls are coming from
* @param actionSubmitPayload The Adaptive Card Action.Submit payload
* @returns Promise that resolves when the request is completed and rejects with ActionSubmitError if the request fails
*/
export function processActionSubmit(
appId: string,
conversationId: string,
Expand All @@ -50,9 +74,9 @@ export namespace externalAppCardActionsForCEC {
return sendMessageToParentAsync<[boolean, ActionSubmitError]>(
getApiVersionTag(
externalAppCardActionsTelemetryVersionNumber,
ApiName.ExternalAppCardActionsForCEC_ProcessActionSubmit,
ApiName.ExternalAppCardActionsForCEA_ProcessActionSubmit,
),
'externalAppCardActionsForCEC.processActionSubmit',
'externalAppCardActionsForCEA.processActionSubmit',
[appId, conversationId, actionSubmitPayload],
).then(([wasSuccessful, error]: [boolean, ActionSubmitError]) => {
if (!wasSuccessful) {
Expand All @@ -61,7 +85,17 @@ export namespace externalAppCardActionsForCEC {
});
}

/**
* @hidden
* Checks if the externalAppCardActionsForCEA capability is supported by the host
* @returns boolean to represent whether externalAppCardActions capability is supported
*
* @throws Error if {@linkcode app.initialize} has not successfully completed
*
* @internal
* Limited to Microsoft-internal use
*/
export function isSupported(): boolean {
return ensureInitialized(runtime) && runtime.supports.externalAppCardActionsForCEC ? true : false;
return ensureInitialized(runtime) && runtime.supports.externalAppCardActionsForCEA ? true : false;
}
}
2 changes: 1 addition & 1 deletion packages/teams-js/src/private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { conversations } from './conversations';
export { copilot } from './copilot';
export { externalAppAuthentication } from './externalAppAuthentication';
export { externalAppCardActions } from './externalAppCardActions';
export { externalAppCardActionsForCEC } from './externalAppCardActionsForCEC';
export { externalAppCardActionsForCEA } from './externalAppCardActionsForCEA';
export { externalAppCommands } from './externalAppCommands';
export { files } from './files';
export { meetingRoom } from './meetingRoom';
Expand Down
27 changes: 27 additions & 0 deletions packages/teams-js/src/private/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,49 @@ export enum ActionOpenUrlType {
GenericUrl = 'GenericUrl',
}

/**
* @hidden
* Error that can be thrown from IExternalAppCardActionService.handleActionOpenUrl
*
* @internal
* Limited to Microsoft-internal use
*/
export interface ActionOpenUrlError {
errorCode: ActionOpenUrlErrorCode;
message?: string;
}

/**
* @hidden
* Error codes that can be thrown from IExternalAppCardActionService.handleActionOpenUrl
* @internal
* Limited to Microsoft-internal use
*/
export enum ActionOpenUrlErrorCode {
INTERNAL_ERROR = 'INTERNAL_ERROR', // Generic error
INVALID_LINK = 'INVALID_LINK', // Deep link is invalid
NOT_SUPPORTED = 'NOT_SUPPORTED', // Deep link is not supported
}

/**
* @hidden
* The payload that is used when executing an Adaptive Card Action.Submit
* @internal
* Limited to Microsoft-internal use
*/
export interface IAdaptiveCardActionSubmit {
id: string;
data: string | Record<string, unknown>;
}

/**
*
* @hidden
* Error that can be thrown from IExternalAppCardActionService.handleActionSubmit
*
* @internal
* Limited to Microsoft-internal use
*/
export interface ActionSubmitError {
errorCode: ExternalAppErrorCode;
message?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/teams-js/src/public/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ interface IRuntimeV4 extends IBaseRuntime {
};
readonly externalAppAuthentication?: {};
readonly externalAppCardActions?: {};
readonly externalAppCardActionsForCEC?: {};
readonly externalAppCardActionsForCEA?: {};
readonly externalAppCommands?: {};
readonly geoLocation?: {
readonly map?: {};
Expand Down
Loading

0 comments on commit 26f2731

Please sign in to comment.