From b310c0af0072ec9e29091aef332f4fdc1a0dd7ce Mon Sep 17 00:00:00 2001 From: zhith Date: Tue, 17 Dec 2024 16:40:42 +0800 Subject: [PATCH 1/4] add extra ics filters params to store.open api --- packages/teams-js/src/private/store.ts | 74 ++++++++++++++++++-- packages/teams-js/test/private/store.spec.ts | 2 +- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/packages/teams-js/src/private/store.ts b/packages/teams-js/src/private/store.ts index 9571b1b6f3..a33d6727ef 100644 --- a/packages/teams-js/src/private/store.ts +++ b/packages/teams-js/src/private/store.ts @@ -57,16 +57,55 @@ 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"]). + * Reference: + * https://domoreexp.visualstudio.com/Teamspace/_git/teams-modular-packages?path=/packages/data/data-schema/src/module.graphql&version=GBmaster&line=9463&lineEnd=9463&lineStartColumn=6&lineEndColumn=25&lineStyle=plain&_a=contents + */ + 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 @@ -84,6 +123,7 @@ export interface OpenAppDetailParams extends StoreSizeInfo { */ appId: AppId; } + /** * @beta * @hidden @@ -101,14 +141,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 @@ -178,6 +228,17 @@ 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, [ @@ -185,6 +246,7 @@ export async function openStoreExperience(openStoreParams: OpenStoreParams): Pro (openStoreParams as OpenAppDetailParams).appId, (openStoreParams as OpenSpecificStoreParams).collectionId, JSON.stringify(openStoreParams.size), + inContextStoreFilters, ], getApiVersionTag(StoreVersionTagNum, ApiName.Store_Open), ); diff --git a/packages/teams-js/test/private/store.spec.ts b/packages/teams-js/test/private/store.spec.ts index 356a311ae4..6293c48614 100644 --- a/packages/teams-js/test/private/store.spec.ts +++ b/packages/teams-js/test/private/store.spec.ts @@ -23,7 +23,7 @@ describe('store', () => { }); describe('openStoreExperience', () => { - const paramFullStore: store.OpenFullStoreAndICSParams = { + const paramFullStore: store.OpenFullStoreParams = { dialogType: store.StoreDialogType.FullStore, }; const paramAppDetail: store.OpenAppDetailParams = { From d90fab1f28a4765127f6390897a8c0a22e530749 Mon Sep 17 00:00:00 2001 From: zhith Date: Tue, 17 Dec 2024 16:45:06 +0800 Subject: [PATCH 2/4] remove internal link --- packages/teams-js/src/private/store.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/teams-js/src/private/store.ts b/packages/teams-js/src/private/store.ts index a33d6727ef..a201e32198 100644 --- a/packages/teams-js/src/private/store.ts +++ b/packages/teams-js/src/private/store.ts @@ -89,8 +89,6 @@ export interface OpenInContextStoreParams extends StoreSizeInfo { /** * The application meta capabilities (e.g., ["copilotPlugins", "copilotExtensions"]). - * Reference: - * https://domoreexp.visualstudio.com/Teamspace/_git/teams-modular-packages?path=/packages/data/data-schema/src/module.graphql&version=GBmaster&line=9463&lineEnd=9463&lineStartColumn=6&lineEndColumn=25&lineStyle=plain&_a=contents */ appMetaCapabilities?: string[]; From f09a86abc08544615cdc8500d873e2bfa46f1cf0 Mon Sep 17 00:00:00 2001 From: zhith Date: Wed, 18 Dec 2024 15:26:15 +0800 Subject: [PATCH 3/4] add e2e tests --- apps/teams-test-app/e2e-test-data/store.json | 35 +++++++++++++++++-- .../src/components/StoreApis.tsx | 15 +++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/apps/teams-test-app/e2e-test-data/store.json b/apps/teams-test-app/e2e-test-data/store.json index 43a1531629..b332ec126b 100644 --- a/apps/teams-test-app/e2e-test-data/store.json +++ b/apps/teams-test-app/e2e-test-data/store.json @@ -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": { @@ -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": { @@ -147,6 +147,37 @@ } }, "expectedTestAppValue": "Error: Error: Invalid store dialog size" + }, + { + "title": "openStoreExperience API Call InContextStore - 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 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" } ] } diff --git a/apps/teams-test-app/src/components/StoreApis.tsx b/apps/teams-test-app/src/components/StoreApis.tsx index c717f9a234..d1ed10f021 100644 --- a/apps/teams-test-app/src/components/StoreApis.tsx +++ b/apps/teams-test-app/src/components/StoreApis.tsx @@ -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: { @@ -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 { From acaef427c5737f2dc798326916f548ad33a9ed47 Mon Sep 17 00:00:00 2001 From: zhith Date: Wed, 18 Dec 2024 15:28:15 +0800 Subject: [PATCH 4/4] refine title --- apps/teams-test-app/e2e-test-data/store.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/teams-test-app/e2e-test-data/store.json b/apps/teams-test-app/e2e-test-data/store.json index b332ec126b..6fc21c8360 100644 --- a/apps/teams-test-app/e2e-test-data/store.json +++ b/apps/teams-test-app/e2e-test-data/store.json @@ -149,7 +149,7 @@ "expectedTestAppValue": "Error: Error: Invalid store dialog size" }, { - "title": "openStoreExperience API Call InContextStore - Success", + "title": "openStoreExperience API Call InContextStore with Filters - Success", "type": "callResponse", "boxSelector": "#box_storeOpen", "inputValue": { @@ -166,7 +166,7 @@ "expectedAlertValue": "openStoreExperience called with ##JSON_INPUT_VALUE##" }, { - "title": "openStoreExperience API Call InContextStore With Invalid Params - Fail", + "title": "openStoreExperience API Call InContextStore with Filters - Invalid Params - Fail", "type": "callResponse", "boxSelector": "#box_storeOpen", "inputValue": {