Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra filters params for store.open for in context store #2660

Open
wants to merge 4 commits into
base: users/hangyin/1204_ics
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions apps/teams-test-app/e2e-test-data/store.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"expectedTestAppValue": "Error: Error: 500, message: App does not have the required permissions for this operation"
},
{
"title": "openStoreExperience API Call With Invalid Dialog Width Size - Fail",
"title": "openStoreExperience API Call With Invalid Dialog Size - Fail",
"type": "callResponse",
"boxSelector": "#box_storeOpen",
"inputValue": {
Expand All @@ -136,7 +136,7 @@
"expectedTestAppValue": "Error: Error: Invalid store dialog size"
},
{
"title": "openStoreExperience API Call With Invalid Dialog Height Size - Fail",
"title": "openStoreExperience API Call With Invalid Dialog Size - Fail",
"type": "callResponse",
"boxSelector": "#box_storeOpen",
"inputValue": {
Expand All @@ -147,6 +147,37 @@
}
},
"expectedTestAppValue": "Error: Error: Invalid store dialog size"
},
{
"title": "openStoreExperience API Call InContextStore with Filters - Success",
"type": "callResponse",
"boxSelector": "#box_storeOpen",
"inputValue": {
"dialogType": "ics",
"appCapability": "Bot",
"appMetaCapabilities": ["copilotplugins", "copilotExtensions"],
"installationScope": "Team",
"filteredOutAppIds": ["123"],
"size": {
"width": "large",
"height": "large"
}
},
"expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##"
},
{
"title": "openStoreExperience API Call InContextStore with Filters - Invalid Params - Fail",
"type": "callResponse",
"boxSelector": "#box_storeOpen",
"inputValue": {
"dialogType": "ics",
"size": {
"width": "large",
"height": "large"
},
"appCapability": 1234
},
"expectedTestAppValue": "Error: Error: 4000, message: appCapability must be a string"
}
]
}
15 changes: 14 additions & 1 deletion apps/teams-test-app/src/components/StoreApis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ const StoreAPIs = (): ReactElement => {
});

const OpenStore = (): ReactElement =>
ApiWithTextInput<{ dialogType: string; appId?: string; collectionId?: string; size?: DialogSize }>({
ApiWithTextInput<{
dialogType: string;
appId?: string;
collectionId?: string;
size?: DialogSize;
appCapability?: string;
appMetaCapabilities?: string[];
installationScope?: string;
filteredOutAppIds?: string[];
}>({
name: 'storeOpen',
title: 'Store Open',
onClick: {
Expand All @@ -36,6 +45,10 @@ const StoreAPIs = (): ReactElement => {
appId: appId,
collectionId: input.collectionId,
size: input.size,
appCapability: input.appCapability,
appMetaCapabilities: input.appMetaCapabilities,
installationScope: input.installationScope,
filteredOutAppIds: input.filteredOutAppIds,
};
// eslint-disable-next-line no-useless-catch
try {
Expand Down
72 changes: 66 additions & 6 deletions packages/teams-js/src/private/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,53 @@ export interface StoreSizeInfo {
/**
* @beta
* @hidden
* Interface of open full store, copilot store and in-context-store function parameter
* Interface for opening the full store function parameters
* @internal
* Limited to Microsoft-internal use
*/
export interface OpenFullStoreAndICSParams extends StoreSizeInfo {
export interface OpenFullStoreParams extends StoreSizeInfo {
/**
* the store dialog type, defined by {@link StoreDialogType}
* The store dialog type, specifically the full store, defined by {@link StoreDialogType}
*/
dialogType: StoreDialogType.FullStore | StoreDialogType.InContextStore;
dialogType: StoreDialogType.FullStore;
}

/**
* @beta
* @hidden
* Interface for opening the in-context store function parameters
* @internal
* Limited to Microsoft-internal use
*/
export interface OpenInContextStoreParams extends StoreSizeInfo {
/**
* The store dialog type, specifically the in-context store, defined by {@link StoreDialogType}
*/
dialogType: StoreDialogType.InContextStore;

/**
* The application capability (e.g., "Tab", "Bot", "Messaging", "Connector", "CUSTOMBOT").
* Defaults to "Bot".
*/
appCapability?: string;

/**
* The application meta capabilities (e.g., ["copilotPlugins", "copilotExtensions"]).
*/
appMetaCapabilities?: string[];

/**
* The installation scope (e.g., "Personal" | "Team").
* Defaults to "Personal".
*/
installationScope?: string;

/**
* A list of app IDs to be filtered out.
*/
filteredOutAppIds?: string[];
}

/**
* @beta
* @hidden
Expand All @@ -84,6 +121,7 @@ export interface OpenAppDetailParams extends StoreSizeInfo {
*/
appId: AppId;
}

/**
* @beta
* @hidden
Expand All @@ -101,14 +139,24 @@ export interface OpenSpecificStoreParams extends StoreSizeInfo {
*/
collectionId: string;
}

/**
* @beta
* @hidden
* Interface of open store function parameters, including OpenFullStoreAndICSParams, OpenAppDetailParams, OpenSpecificStoreParams
* Interface of open store function parameters, including:
* - `OpenAppDetailParams`
* - `OpenFullStoreParams`
* - `OpenInContextStoreParams`
* - `OpenSpecificStoreParams`
*
* @internal
* Limited to Microsoft-internal use
*/
export type OpenStoreParams = OpenFullStoreAndICSParams | OpenAppDetailParams | OpenSpecificStoreParams;
export type OpenStoreParams =
| OpenAppDetailParams
| OpenFullStoreParams
| OpenInContextStoreParams
| OpenSpecificStoreParams;

/**
* @beta
Expand Down Expand Up @@ -178,13 +226,25 @@ export async function openStoreExperience(openStoreParams: OpenStoreParams): Pro
throw new Error(errorInvalidDialogSize);
}
}

const inContextStoreFilters =
dialogType === StoreDialogType.InContextStore
? JSON.stringify({
appCapability: openStoreParams.appCapability,
appMetaCapabilities: openStoreParams.appMetaCapabilities,
installationScope: openStoreParams.installationScope,
filteredOutAppIds: openStoreParams.filteredOutAppIds,
})
: undefined;

return callFunctionInHost(
ApiName.Store_Open,
[
openStoreParams.dialogType,
(openStoreParams as OpenAppDetailParams).appId,
(openStoreParams as OpenSpecificStoreParams).collectionId,
JSON.stringify(openStoreParams.size),
inContextStoreFilters,
],
getApiVersionTag(StoreVersionTagNum, ApiName.Store_Open),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/teams-js/test/private/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('store', () => {
});

describe('openStoreExperience', () => {
const paramFullStore: store.OpenFullStoreAndICSParams = {
const paramFullStore: store.OpenFullStoreParams = {
dialogType: store.StoreDialogType.FullStore,
};
const paramAppDetail: store.OpenAppDetailParams = {
Expand Down