From 99250054273dff46df16f73ce58f517e333e501d Mon Sep 17 00:00:00 2001 From: Karan Gandhi Date: Wed, 15 Mar 2023 17:01:54 +0530 Subject: [PATCH 1/3] Added Feature selection by name in catalogs for Catalog Explorer --- .../BookRecommendation/lambda/index.ts | 1 + .../conversations/book_recommendation.acdl | 37 +++-- .../interactionModels/custom/en-US.json | 90 ++++++++++++ .../lambda/handlers/index-of-by-name.ts | 85 +++++++++++ catalog-explorer/lambda/handlers/index.ts | 1 + catalog-explorer/lambda/interface.ts | 3 + .../lambda/providers/ddb-provider.ts | 9 +- catalog-explorer/src/actionAdapters.acdl | 4 +- catalog-explorer/src/builderDialogs.acdl | 37 +++-- catalog-explorer/src/catalog-explorer.acdl | 4 +- catalog-explorer/src/navigate.acdl | 99 +++++++++---- catalog-explorer/src/offers.acdl | 8 +- catalog-explorer/src/properties.acdl | 12 +- catalog-explorer/src/propertiesAdapters.acdl | 40 ++--- catalog-explorer/src/search.acdl | 60 ++++---- catalog-explorer/src/searchAdapters.acdl | 24 +-- catalog-explorer/src/types.acdl | 46 +++--- .../test/handlers/index-of-by-name.test.ts | 84 +++++++++++ .../resources/indexOfByNameHandlerInput.json | 139 ++++++++++++++++++ 19 files changed, 623 insertions(+), 160 deletions(-) create mode 100644 catalog-explorer/lambda/handlers/index-of-by-name.ts create mode 100644 catalog-explorer/test/handlers/index-of-by-name.test.ts create mode 100644 catalog-explorer/test/resources/indexOfByNameHandlerInput.json diff --git a/catalog-explorer/examples/BookRecommendation/lambda/index.ts b/catalog-explorer/examples/BookRecommendation/lambda/index.ts index 40865a4..9d24462 100644 --- a/catalog-explorer/examples/BookRecommendation/lambda/index.ts +++ b/catalog-explorer/examples/BookRecommendation/lambda/index.ts @@ -20,6 +20,7 @@ exports.handler = SkillBuilders.custom() // are required to be defined by skills using catalog explorer ...CatalogExplorer.createHandlers( `${skillDomain}.getPage`, + `${skillDomain}.indexOfItemByNameApi`, `${skillDomain}.selectItemApi`, `${skillDomain}.search_`, `${skillDomain}.getProperty_`, diff --git a/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl b/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl index 5a6460e..7cf31ed 100644 --- a/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl +++ b/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl @@ -10,6 +10,9 @@ import prompts.* import displays.* import slotTypes.* +/************************ + * CREATE CATALOG ITEM + ************************/ multiModalWelcome = MultiModalResponse { apl = WelcomeAPL, apla = AlexaConversationsWelcome @@ -29,10 +32,6 @@ import slotTypes.* } ) -/************************ - * CREATE CATALOG ITEM - ************************/ - type BookItem { String title String genre @@ -161,9 +160,17 @@ selectByIndexEvent = utterances([ "{index}" ]) -action RecommendationResult getPage(SearchConditions searchConditions, Optional pageToken, optional CatalogReference catalogRef) -action RecommendationResult selectItemApi(SearchConditions searchConditions, Page page, Number index, optional CatalogReference catalogRef) +selectByNameEvent = utterances>([ + "{name}", + "{name} would be good", + "I like {name}", + "{name} sounds interesting", + "show me {name}" +]) +action RecommendationResult getPage(SearchConditions searchConditions, Optional pageToken, optional CatalogReference catalogRef) +action RecommendationResult selectItemApi(Page page, Number index, optional SearchConditions searchConditions, optional CatalogReference catalogRef) +action NUMBER indexOfItemByNameApi(Page page, TITLE name) /************************ * OFFERS @@ -241,25 +248,25 @@ action CatalogActionResult performAction_SendToPhone(List items, optio * Anonymous Dialogs ************************/ -dialog RecommendationResult allSearchPathsAdaptor(PropertyConfig config, optional CatalogReference catalogRef) { +dialog RecommendationResult allSearchPathsAdaptor(PropertyConfig config, optional CatalogReference catalogRef) { sample { allSearchPaths_2(config) } } -dialog RecommendationResult baseSearchPathsAdaptor(PropertyConfig config, optional CatalogReference catalogRef) { +dialog RecommendationResult baseSearchPathsAdaptor(PropertyConfig config, optional CatalogReference catalogRef) { sample { baseSearchPaths_2(config) } } -dialog RecommendationResult allFollowUpPathsAdaptor(PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef) { +dialog RecommendationResult allFollowUpPathsAdaptor(PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef) { sample { allFollowUpPaths_5(config, priorResult, catalogRef) } } -dialog CatalogActionResult allCatalogActionPathsAdaptor(PropertyConfig config, List items, optional CatalogReference catalogRef) { +dialog CatalogActionResult allCatalogActionPathsAdaptor(PropertyConfig config, List items, optional CatalogReference catalogRef) { sample { allCatalogActionPaths_3(config, items, catalogRef) } @@ -305,14 +312,16 @@ dialog MainDialog{ ] //Buidling the navigation configuration - navigationConfig = buildNavigationConfig( + navigationConfig = buildNavigationConfig( nextEvent = nextEvent, prevEvent = prevEvent, getPageApi = getPage, selectByOrdinalEvent = selectByOrdinalEvent, selectByRelativePositionEvent = selectByRelativePositionEvent, selectByIndexEvent = selectByIndexEvent, - selectItemApi = selectItemApi + selectByNameEvent = selectByNameEvent, + indexOfItemByNameApi = indexOfItemByNameApi, + selectItemApi = selectItemApi, ) //Buidling the Offers configuration @@ -375,7 +384,7 @@ dialog MainDialog{ ] //Building the main catalog explorer configuration object - config = buildCatalogConfig( + config = buildCatalogConfig( searchPatterns, navigationConfig, catalogProperties, @@ -388,7 +397,7 @@ dialog MainDialog{ ) //calling the the catalog explorer component with the configuration object - result = exploreCatalog(config) + result = exploreCatalog(config) //Below part is just for a workaround that the main deployable dialog cannont //return CatalogExplorationResult which is the return type of the component diff --git a/catalog-explorer/examples/BookRecommendation/skill-package/interactionModels/custom/en-US.json b/catalog-explorer/examples/BookRecommendation/skill-package/interactionModels/custom/en-US.json index 4382574..9e8eedd 100644 --- a/catalog-explorer/examples/BookRecommendation/skill-package/interactionModels/custom/en-US.json +++ b/catalog-explorer/examples/BookRecommendation/skill-package/interactionModels/custom/en-US.json @@ -158,6 +158,96 @@ } } ] + }, + { + "name": "TITLE", + "values": [ + { + "name": { + "value": "The Shining" + } + }, + { + "name": { + "value": "It" + } + }, + { + "name": { + "value": "Pet Sematary" + } + }, + { + "name": { + "value": "The Green Mile" + } + }, + { + "name": { + "value": "Under the Dome" + } + }, + { + "name": { + "value": "Doctor Sleep" + } + }, + { + "name": { + "value": "Four Past Midnight" + } + }, + { + "name": { + "value": "Do androids dream of robotic sheep" + } + }, + { + "name": { + "value": "Dune" + } + }, + { + "name": { + "value": "A Game of Thrones" + } + }, + { + "name": { + "value": "Pride and Prejudice" + } + }, + { + "name": { + "value": "Hyperion" + } + }, + { + "name": { + "value": "Ready Player One" + } + }, + { + "name": { + "value": "Harry Potter: Deathly Hallows" + } + }, + { + "name": { + "value": "The Fault in Our Stars" + } + }, + { + "name": { + "value": "The Notebook" + } + }, + { + "name": { + "value": "The Hobbit" + } + } + ] } ] } diff --git a/catalog-explorer/lambda/handlers/index-of-by-name.ts b/catalog-explorer/lambda/handlers/index-of-by-name.ts new file mode 100644 index 0000000..0a9394d --- /dev/null +++ b/catalog-explorer/lambda/handlers/index-of-by-name.ts @@ -0,0 +1,85 @@ +// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0 +// Licensed under the Amazon Software License http://aws.amazon.com/asl/ + +import { HandlerInput } from 'ask-sdk-core'; +import { Response } from "ask-sdk-model"; + +import { apiNamespace } from '../config'; +import { CatalogExplorer } from '../interface'; +import { Page } from "../catalog-provider"; +import { CatalogExplorerSessionState } from '../state'; +import * as util from '../util'; +import { BaseApiHandler } from './base-api-handler'; + +interface Arguments{ + // the page to retrieve an item from + page: Page; + + // the name of the item + name: string; +} + +export type ItemNameMatcher = (items: any[], name: string) => number | undefined; + +// called when a user tries to select a item on the current page by name, +// utilizes a matcher callback to determine how to match an item to name; +// assuming each item simply has a "name" field by default +export class IndexOfItemByNameHandler extends BaseApiHandler { + static defaultApiName = `${apiNamespace}.indexOfItemByNameApi`; + + // default matcher just assumes each item has a 'name' field that can be matched against + static defaultItemNameMatcher: ItemNameMatcher = (items, name) => { + return items.findIndex((item) => { + return item?.name?.toLowerCase() == name; + }); + } + + private itemNameMatcher: ItemNameMatcher; + + constructor( + apiName: string = IndexOfItemByNameHandler.defaultApiName, + itemNameMatcher: ItemNameMatcher = IndexOfItemByNameHandler.defaultItemNameMatcher, + ) { + super(apiName); + this.itemNameMatcher = itemNameMatcher; + } + + handle(handlerInput : HandlerInput): Response { + const args = util.getApiArguments(handlerInput) as Arguments; + + let currentRecommendationsPage: Page + + if(CatalogExplorer.useSessionArgs){ + currentRecommendationsPage = this.getRecommendationPageFromSession(handlerInput); + } + else{ + currentRecommendationsPage = args.page; + } + + const index = this.itemNameMatcher(currentRecommendationsPage.items, args.name); + if (index == undefined || index < 0) { + throw new Error("indexOfItemByName: API called with name matching no displayed element"); + } else if (index >= currentRecommendationsPage.items.length) { + throw new Error("indexOfItemByName: item matcher returned index out of bounds of current page"); + }else{ + console.log("indexOfItemByName: ",index); + } + + return handlerInput.responseBuilder + .withApiResponse(index+1) // index in ACDL currently starts at 1 to match ordinal + .withShouldEndSession(false) + .getResponse(); + } + + getRecommendationPageFromSession(handlerInput: HandlerInput): Page{ + const sessionState = CatalogExplorerSessionState.load(handlerInput); + + const recommendationResultFromSession = sessionState.argsState?.recommendationResult; + if (recommendationResultFromSession === undefined){ + throw new Error("Recommendation Result from session state in undefined"); + } + + return recommendationResultFromSession.recommendations; + } +} diff --git a/catalog-explorer/lambda/handlers/index.ts b/catalog-explorer/lambda/handlers/index.ts index 24ab86a..ec329ec 100644 --- a/catalog-explorer/lambda/handlers/index.ts +++ b/catalog-explorer/lambda/handlers/index.ts @@ -1,6 +1,7 @@ export * from "./base-api-handler"; export * from "./convert-ordinal-to-index"; export * from "./convert-relative-position-to-index"; +export * from "./index-of-by-name"; export * from "./accept-offer-handler"; export * from "./get-page-handler"; export * from "./get-property-handler"; diff --git a/catalog-explorer/lambda/interface.ts b/catalog-explorer/lambda/interface.ts index 3977744..de94520 100644 --- a/catalog-explorer/lambda/interface.ts +++ b/catalog-explorer/lambda/interface.ts @@ -13,6 +13,7 @@ import { ConvertOrdinalToIndexHandler, ConvertRelativePositionToIndexHandler, GetPageHandler, + IndexOfItemByNameHandler, GetPropertyHandler, PerformActionHandler, SearchHandler, @@ -146,6 +147,7 @@ export class CatalogExplorer { // Returns: array of constructed handlers static createHandlers( getPageApiName: string, + indexOfItemByNameApiName: string, selectItemApiName: string, searchApiName: string, getPropertyApiName: string, @@ -164,6 +166,7 @@ export class CatalogExplorer { // APIs that have to be defined by skill dev (as they use generics) new SearchHandler(searchApiName), + new IndexOfItemByNameHandler(indexOfItemByNameApiName), new GetPageHandler(getPageApiName), new SelectItemHandler(selectItemApiName), new AcceptOfferHandler(acceptOfferApiName), diff --git a/catalog-explorer/lambda/providers/ddb-provider.ts b/catalog-explorer/lambda/providers/ddb-provider.ts index 11c12de..2df1f9f 100644 --- a/catalog-explorer/lambda/providers/ddb-provider.ts +++ b/catalog-explorer/lambda/providers/ddb-provider.ts @@ -54,7 +54,7 @@ export class DDBListProvider implements CatalogProvider } } count = seenListEntries.size; - console.log("Count", count); + console.log("Seen item Count", count); console.log("Items in table:", results.Table?.ItemCount) if(count === results.Table?.ItemCount) { @@ -222,8 +222,6 @@ export class DDBListProvider implements CatalogProvider excludeList.push(temp[y]); } } - console.log("Exclude List:", excludeList); - console.log("DDB key:", key); const filterExpression= "NOT #pk IN (" + excludeList.map((_: any, index: string) => ":pk" + index).join(", ") + ")"; const expressionAttributeNames = { "#pk": key }; let expressionAttributeValue : any = {}; @@ -232,12 +230,8 @@ export class DDBListProvider implements CatalogProvider }); let unseenList: any[] = []; let scanResults: any ; - console.log("filterExpression:",filterExpression); - console.log("expressionAttributeNames:",expressionAttributeNames); - console.log("ExpressionAttributeValues:",expressionAttributeValue); do { - console.log("INSIDE LOOP"); let scanCommand: ScanCommandInput = { Limit : pageSize, TableName : this.tableName, @@ -322,7 +316,6 @@ export class DDBListProvider implements CatalogProvider try { const results = await this.client.send(new QueryCommand(params)); this.lek = results.LastEvaluatedKey; - console.log("LEKKKK:",this.lek); (results.Items || []).forEach(function (element: any, index: any, array: any) { matchingData.push(unmarshall(element)); }); diff --git a/catalog-explorer/src/actionAdapters.acdl b/catalog-explorer/src/actionAdapters.acdl index ac14f59..90198e1 100644 --- a/catalog-explorer/src/actionAdapters.acdl +++ b/catalog-explorer/src/actionAdapters.acdl @@ -10,8 +10,8 @@ import com.amazon.alexa.schema.* import com.amazon.alexa.skill.components.catalog_explorer.types.* import com.amazon.alexa.skill.components.catalog_explorer.action.* -dialog CatalogActionResult allCatalogActionPaths_1 ( - PropertyConfig config, +dialog CatalogActionResult allCatalogActionPaths_1 ( + PropertyConfig config, List items, optional CatalogReference catalogRef ) { diff --git a/catalog-explorer/src/builderDialogs.acdl b/catalog-explorer/src/builderDialogs.acdl index e886aaf..f3fe6bc 100644 --- a/catalog-explorer/src/builderDialogs.acdl +++ b/catalog-explorer/src/builderDialogs.acdl @@ -76,6 +76,7 @@ defaultSelectByRelativePositionEvent = utterances([ "the {relativePosition}", "{relativePosition}" ]) + defaultSelectByIndexEvent = utterances([ "show item view on number {index}", "show me more about number {index}", @@ -112,7 +113,7 @@ dialog CatalogAction buildCatalogAction( } -dialog NavigationConfig buildNavigationConfig( +dialog NavigationConfig buildNavigationConfig( Event nextEvent = defaultNextEvent, Event prevEvent = defaultPrevEvent, Action3< @@ -125,11 +126,19 @@ dialog NavigationConfig buildNavigationConfig selectByOrdinalEvent=defaultSelectByOrdinalEvent, Event selectByRelativePositionEvent=defaultSelectByRelativePositionEvent, + Event> selectByNameEvent, Event selectByIndexEvent=defaultSelectByIndexEvent, + + Action2< // current search conditions + Page, // current page of results + ItemName, + NUMBER // index to select + > indexOfItemByNameApi, + Action4< - SearchConditions, // current search conditions Page, // current page of results NUMBER, + Optional, // current search conditions Optional, // index to select RecommendationResult // results for selection > selectItemApi @@ -142,15 +151,17 @@ dialog NavigationConfig buildNavigationConfig{ + selectionConfig = SelectionConfig{ selectByOrdinalEvent = selectByOrdinalEvent, selectByRelativePositionEvent = selectByRelativePositionEvent, selectByIndexEvent = selectByIndexEvent, + selectByNameEvent = selectByNameEvent, + indexOfItemByNameApi = indexOfItemByNameApi, selectItemApi = selectItemApi, presentSelectedItemResponse = presentSelectedItemResponse } - /*return*/ NavigationConfig { + /*return*/ NavigationConfig { paginationConfig = paginationConfig, selectionConfig = selectionConfig } @@ -225,20 +236,20 @@ dialog CatalogOffers buildCatalogOffers buildCatalogConfig( +dialog CatalogConfig buildCatalogConfig( List> searchPatterns, - NavigationConfig navConfig, + NavigationConfig navConfig, List> properties, List> catalogActions, CatalogOffers offers, - Dialog2, Optional, RecommendationResult > allSearchPaths, - Dialog2, Optional,RecommendationResult> baseSearchPaths, - Dialog3, RecommendationResult, Optional, RecommendationResult> allFollowUpPaths, - Dialog3, List, Optional,CatalogActionResult> allCatalogActionPaths + Dialog2, Optional, RecommendationResult > allSearchPaths, + Dialog2, Optional,RecommendationResult> baseSearchPaths, + Dialog3, RecommendationResult, Optional, RecommendationResult> allFollowUpPaths, + Dialog3, List, Optional,CatalogActionResult> allCatalogActionPaths ) { sample{ - propertyConfig = PropertyConfig { + propertyConfig = PropertyConfig { searchPatterns = searchPatterns, navConfig = navConfig, properties = properties, @@ -246,14 +257,14 @@ dialog CatalogConfig buildCatalogConfig { + dialogConfig = DialogConfig { allSearchPathsAdaptor = allSearchPaths, baseSearchPathsAdaptor= baseSearchPaths, allFollowUpPathsAdaptor = allFollowUpPaths, allCatalogActionPathsAdaptor = allCatalogActionPaths } - CatalogConfig { + CatalogConfig { propertyConfig = propertyConfig, dialogConfig = dialogConfig } diff --git a/catalog-explorer/src/catalog-explorer.acdl b/catalog-explorer/src/catalog-explorer.acdl index a097b54..9bda0f6 100644 --- a/catalog-explorer/src/catalog-explorer.acdl +++ b/catalog-explorer/src/catalog-explorer.acdl @@ -15,8 +15,8 @@ import com.amazon.alexa.skill.components.catalog_explorer.types.* // main Catalog Explorer dialog; returns result of a action performed after // the user is finished exploring the catalog -dialog CatalogExplorationResult exploreCatalog( - CatalogConfig config, +dialog CatalogExplorationResult exploreCatalog( + CatalogConfig config, optional CatalogReference catalogRef ) { diff --git a/catalog-explorer/src/navigate.acdl b/catalog-explorer/src/navigate.acdl index b38e946..309bfdb 100644 --- a/catalog-explorer/src/navigate.acdl +++ b/catalog-explorer/src/navigate.acdl @@ -40,8 +40,8 @@ dialog Nothing presentPage( } } -dialog RecommendationResult presentPage_withHint( - PropertyConfig config, +dialog RecommendationResult presentPage_withHint( + PropertyConfig config, Action api, RecommendationResult result, Response response, @@ -65,8 +65,8 @@ dialog RecommendationResult presentPage_withHint navigateNext( - PropertyConfig config, +dialog RecommendationResult navigateNext( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -79,8 +79,8 @@ dialog RecommendationResult navigateNext navigatePrev( - PropertyConfig config, +dialog RecommendationResult navigatePrev( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -93,8 +93,8 @@ dialog RecommendationResult navigatePrev navigateNext_withHint( - PropertyConfig config, +dialog RecommendationResult navigateNext_withHint( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -107,8 +107,8 @@ dialog RecommendationResult navigateNext_withHint navigatePrevious_withHint( - PropertyConfig config, +dialog RecommendationResult navigatePrevious_withHint( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -121,8 +121,8 @@ dialog RecommendationResult navigatePrevious_withHint navigateSelectItemByOrdinal( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByOrdinal( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -130,13 +130,13 @@ dialog RecommendationResult navigateSelectItemByOrdinal< slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByOrdinalEvent) index = convertOrdinalToIndex(slotValues.ordinal) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations ,index,catalogRef) + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) presentPage(getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse) result } } -dialog RecommendationResult navigateSelectItemByRelativePosition( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByRelativePosition( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -144,26 +144,41 @@ dialog RecommendationResult navigateSelectItemByRelative slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByRelativePositionEvent) index = convertRelativePositionToIndex(slotValues.relativePosition) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations ,index,catalogRef) + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) + presentPage(getItem,result,config.navConfig.paginationConfig.presentPageResponse) + result + } +} +dialog RecommendationResult navigateSelectItemByName( + PropertyConfig config, + RecommendationResult searchResult, + optional CatalogReference catalogRef +) { + sample { + slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByNameEvent) + indexOfApi = config.navConfig.selectionConfig.indexOfItemByNameApi + index = indexOfApi(searchResult.recommendations, slotValues.name) + getItem=config.navConfig.selectionConfig.selectItemApi + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) presentPage(getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse) result } } -dialog RecommendationResult navigateSelectItemByIndex( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByIndex( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { sample { slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByIndexEvent) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations ,slotValues.index,catalogRef) + result = getItem(searchResult.recommendations, slotValues.index, searchResult.searchConditions, catalogRef) presentPage(getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse) result } } -dialog RecommendationResult navigateSelectItemByOrdinal_withHint( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByOrdinal_withHint( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -171,13 +186,13 @@ dialog RecommendationResult navigateSelectItemByOrdinal_ slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByOrdinalEvent) index = convertOrdinalToIndex(slotValues.ordinal) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations ,index, catalogRef) + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) presentPage_withHint(config,getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse, catalogRef) result } } -dialog RecommendationResult navigateSelectItemByRelativePosition_withHint( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByRelativePosition_withHint( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -185,28 +200,44 @@ dialog RecommendationResult navigateSelectItemByRelative slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByRelativePositionEvent) index = convertRelativePositionToIndex(slotValues.relativePosition) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations ,index, catalogRef) + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) + presentPage_withHint(config,getItem,result,config.navConfig.paginationConfig.presentPageResponse, catalogRef) + result + } +} + +dialog RecommendationResult navigateSelectItemByName_withHint( + PropertyConfig config, + RecommendationResult searchResult, + optional CatalogReference catalogRef +) { + sample { + slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByNameEvent) + indexOfApi = config.navConfig.selectionConfig.indexOfItemByNameApi + index = indexOfApi(searchResult.recommendations, slotValues.name) + getItem=config.navConfig.selectionConfig.selectItemApi + result = getItem(searchResult.recommendations, index, searchResult.searchConditions, catalogRef) presentPage_withHint(config,getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse, catalogRef) result } } -dialog RecommendationResult navigateSelectItemByIndex_withHint( - PropertyConfig config, +dialog RecommendationResult navigateSelectItemByIndex_withHint( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { sample { slotValues = expect(Invoke, config.navConfig.selectionConfig.selectByIndexEvent) getItem=config.navConfig.selectionConfig.selectItemApi - result = getItem(searchResult.searchConditions, searchResult.recommendations, slotValues.index, catalogRef) + result = getItem(searchResult.recommendations, slotValues.index, searchResult.searchConditions, catalogRef) presentPage_withHint(config,getItem,result,config.navConfig.selectionConfig.presentSelectedItemResponse, catalogRef) result } } -dialog RecommendationResult allNavigationPaths( - PropertyConfig config, +dialog RecommendationResult allNavigationPaths( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { @@ -226,6 +257,10 @@ dialog RecommendationResult allNavigationPaths allNavigationPaths allNavigationPaths_WithPassthrough( - PropertyConfig config, +dialog RecommendationResult allNavigationPaths_WithPassthrough( + PropertyConfig config, RecommendationResult searchResult, optional CatalogReference catalogRef ) { diff --git a/catalog-explorer/src/offers.acdl b/catalog-explorer/src/offers.acdl index b6a51b8..290c010 100644 --- a/catalog-explorer/src/offers.acdl +++ b/catalog-explorer/src/offers.acdl @@ -12,8 +12,8 @@ import com.amazon.alexa.skill.components.catalog_explorer.navigate.* import com.amazon.alexa.skill.components.catalog_explorer.util.* import com.amazon.alexa.skill.components.catalog_explorer.types.* -dialog RecommendationResult notifyWithProactiveHint( - PropertyConfig config, +dialog RecommendationResult notifyWithProactiveHint( + PropertyConfig config, CatalogOffers offers, RecommendationResult priorResult, NotifyResponseContents notifyResponseContents, @@ -45,8 +45,8 @@ dialog Nothing notifyWithProactiveHint_AffirmOnly( } } -dialog RecommendationResult offerHint( - PropertyConfig config, +dialog RecommendationResult offerHint( + PropertyConfig config, CatalogOffers offers, RecommendationResult priorResult, NotifyResponseContents notifyResponseContents, diff --git a/catalog-explorer/src/properties.acdl b/catalog-explorer/src/properties.acdl index 466ddc3..d739370 100644 --- a/catalog-explorer/src/properties.acdl +++ b/catalog-explorer/src/properties.acdl @@ -15,8 +15,8 @@ import com.amazon.alexa.skill.components.catalog_explorer.* // definition of a catalog property that user can request for the current item -dialog Nothing requestPropertyValue( - PropertyConfig config, +dialog Nothing requestPropertyValue( + PropertyConfig config, CatalogProperty property, List priorRecommendations, optional CatalogReference catalogRef @@ -36,8 +36,8 @@ dialog Nothing requestPropertyValue( } } -dialog RecommendationResult requestPropertyValue_WithPassthrough( - PropertyConfig config, +dialog RecommendationResult requestPropertyValue_WithPassthrough( + PropertyConfig config, CatalogProperty property, RecommendationResult priorResult, optional CatalogReference catalogRef @@ -52,8 +52,8 @@ dialog RecommendationResult requestPropertyValue_WithPa priorResult } } -dialog RecommendationResult requestPropertyValue_withHint( - PropertyConfig config, +dialog RecommendationResult requestPropertyValue_withHint( + PropertyConfig config, CatalogProperty property, RecommendationResult priorResult, optional CatalogReference catalogRef diff --git a/catalog-explorer/src/propertiesAdapters.acdl b/catalog-explorer/src/propertiesAdapters.acdl index 9f33d30..3fd34be 100644 --- a/catalog-explorer/src/propertiesAdapters.acdl +++ b/catalog-explorer/src/propertiesAdapters.acdl @@ -10,8 +10,8 @@ import com.amazon.alexa.schema.* import com.amazon.alexa.skill.components.catalog_explorer.types.* import com.amazon.alexa.skill.components.catalog_explorer.properties.* -dialog RecommendationResult allFollowUpPaths_1( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_1( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -20,8 +20,8 @@ dialog RecommendationResult allFollowUpPaths_1 allFollowUpPaths_2( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_2( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -34,8 +34,8 @@ dialog RecommendationResult allFollowUpPaths_2 allFollowUpPaths_3( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_3( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -48,8 +48,8 @@ dialog RecommendationResult allFollowUpPaths_3 allFollowUpPaths_4( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_4( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -62,8 +62,8 @@ dialog RecommendationResult allFollowUpPaths_4 allFollowUpPaths_5( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_5( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -76,8 +76,8 @@ dialog RecommendationResult allFollowUpPaths_5 allFollowUpPaths_6( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_6( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -90,8 +90,8 @@ dialog RecommendationResult allFollowUpPaths_6 allFollowUpPaths_7( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_7( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -104,8 +104,8 @@ dialog RecommendationResult allFollowUpPaths_7 allFollowUpPaths_8( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_8( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -118,8 +118,8 @@ dialog RecommendationResult allFollowUpPaths_8 allFollowUpPaths_9( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_9( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -132,8 +132,8 @@ dialog RecommendationResult allFollowUpPaths_9 allFollowUpPaths_10( - PropertyConfig config, +dialog RecommendationResult allFollowUpPaths_10( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { diff --git a/catalog-explorer/src/search.acdl b/catalog-explorer/src/search.acdl index 306064e..7d6102a 100644 --- a/catalog-explorer/src/search.acdl +++ b/catalog-explorer/src/search.acdl @@ -13,8 +13,8 @@ import com.amazon.alexa.skill.components.catalog_explorer.util.* import com.amazon.alexa.skill.components.catalog_explorer.types.* import com.amazon.alexa.skill.components.catalog_explorer.* -dialog Nothing recommendationResponse ( - PropertyConfig config, +dialog Nothing recommendationResponse ( + PropertyConfig config, SearchPattern searchPattern, RecommendationResult result ) { @@ -28,8 +28,8 @@ dialog Nothing recommendationResponse ( } } -dialog RecommendationResult recommendationResponse_withHint ( - PropertyConfig config, +dialog RecommendationResult recommendationResponse_withHint ( + PropertyConfig config, SearchPattern searchPattern, RecommendationResult result, optional CatalogReference catalogRef @@ -50,8 +50,8 @@ dialog RecommendationResult recommendationResponse_withH } } -dialog RecommendationResult searchForItem_Index0 ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index0 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -62,8 +62,8 @@ dialog RecommendationResult searchForItem_Index0 searchForItem_Index0_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index0_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -75,8 +75,8 @@ dialog RecommendationResult searchForItem_Index0_withHi } } -dialog RecommendationResult searchForItem_Index1 ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index1 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -88,8 +88,8 @@ dialog RecommendationResult searchForItem_Index1 searchForItem_Index1_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index1_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -102,8 +102,8 @@ dialog RecommendationResult searchForItem_Index1_withH } } -dialog RecommendationResult searchForItem_Index2 ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index2 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -116,8 +116,8 @@ dialog RecommendationResult searchForItem_Index2 searchForItem_Index2_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index2_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -130,8 +130,8 @@ dialog RecommendationResult searchForItem_Index2_withH } // IMPROVE: replace with a wrapper Optional reusable dialog once lambdas are supported -dialog RecommendationResult searchForItem_Index0_WithPassthrough ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index0_WithPassthrough ( + PropertyConfig config, RecommendationResult priorResult, optional CatalogReference catalogRef ) { @@ -145,8 +145,8 @@ dialog RecommendationResult searchForItem_Index0_WithPa } } -dialog RecommendationResult searchForItem_Index0_WithVariations ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index0_WithVariations ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -166,8 +166,8 @@ dialog RecommendationResult searchForItem_Index0_WithVa result } } -dialog RecommendationResult searchForItem_Index0_WithVariations_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index0_WithVariations_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -188,8 +188,8 @@ dialog RecommendationResult searchForItem_Index0_WithVa } } -dialog RecommendationResult searchForItem_Index1_WithVariations ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index1_WithVariations ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -209,8 +209,8 @@ dialog RecommendationResult searchForItem_Index1_WithVa result } } -dialog RecommendationResult searchForItem_Index1_WithVariations_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index1_WithVariations_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -232,8 +232,8 @@ dialog RecommendationResult searchForItem_Index1_WithVa } -dialog RecommendationResult searchForItem_Index2_WithVariations ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index2_WithVariations ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -253,8 +253,8 @@ dialog RecommendationResult searchForItem_Index2_WithVa result } } -dialog RecommendationResult searchForItem_Index2_WithVariations_withHint ( - PropertyConfig config, +dialog RecommendationResult searchForItem_Index2_WithVariations_withHint ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { diff --git a/catalog-explorer/src/searchAdapters.acdl b/catalog-explorer/src/searchAdapters.acdl index fb63042..9fc4c1c 100644 --- a/catalog-explorer/src/searchAdapters.acdl +++ b/catalog-explorer/src/searchAdapters.acdl @@ -11,16 +11,16 @@ import com.amazon.alexa.skill.components.catalog_explorer.types.* import com.amazon.alexa.skill.components.catalog_explorer.search.* -dialog RecommendationResult baseSearchPaths_1 ( - PropertyConfig config, +dialog RecommendationResult baseSearchPaths_1 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { searchForItem_Index0_WithVariations(config,catalogRef) } } -dialog RecommendationResult allSearchPaths_1 ( - PropertyConfig config, +dialog RecommendationResult allSearchPaths_1 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -28,8 +28,8 @@ dialog RecommendationResult allSearchPaths_1 baseSearchPaths_2 ( - PropertyConfig config, +dialog RecommendationResult baseSearchPaths_2 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -40,8 +40,8 @@ dialog RecommendationResult baseSearchPaths_2 allSearchPaths_2 ( - PropertyConfig config, +dialog RecommendationResult allSearchPaths_2 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -53,8 +53,8 @@ dialog RecommendationResult allSearchPaths_2 baseSearchPaths_3 ( - PropertyConfig config, +dialog RecommendationResult baseSearchPaths_3 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { @@ -65,8 +65,8 @@ dialog RecommendationResult baseSearchPaths_3 allSearchPaths_3 ( - PropertyConfig config, +dialog RecommendationResult allSearchPaths_3 ( + PropertyConfig config, optional CatalogReference catalogRef ) { sample { diff --git a/catalog-explorer/src/types.acdl b/catalog-explorer/src/types.acdl index fe7b04c..ab058eb 100644 --- a/catalog-explorer/src/types.acdl +++ b/catalog-explorer/src/types.acdl @@ -21,28 +21,28 @@ type CatalogReference { String id } -type PropertyConfig { +type PropertyConfig { // config for search, navigate, properties, actions, and offers List> searchPatterns - NavigationConfig navConfig + NavigationConfig navConfig List> properties List> catalogActions CatalogOffers offers } -type DialogConfig{ +type DialogConfig{ // adaptors needed to "tell" the component the length of the search patterns, properties, // and actions lists; needed as there is no current support in ACDL to generate a dynamic // number of samples based on the length of a list - Dialog2, Optional , RecommendationResult> allSearchPathsAdaptor - Dialog2,Optional , RecommendationResult> baseSearchPathsAdaptor - Dialog3, RecommendationResult, Optional , RecommendationResult> allFollowUpPathsAdaptor - Dialog3, List,Optional , CatalogActionResult> allCatalogActionPathsAdaptor + Dialog2, Optional , RecommendationResult> allSearchPathsAdaptor + Dialog2,Optional , RecommendationResult> baseSearchPathsAdaptor + Dialog3, RecommendationResult, Optional , RecommendationResult> allFollowUpPathsAdaptor + Dialog3, List,Optional , CatalogActionResult> allCatalogActionPathsAdaptor } -type CatalogConfig { - PropertyConfig propertyConfig - DialogConfig dialogConfig +type CatalogConfig { + PropertyConfig propertyConfig + DialogConfig dialogConfig } //action type ActionResultPayload @@ -88,10 +88,14 @@ type IndexSlotWrapper { NUMBER index } +type ItemNameSlotWrapper { + ItemName name +} + // root config object bringing together configuration for pagination and item selection -type NavigationConfig { +type NavigationConfig { PaginationConfig paginationConfig - SelectionConfig selectionConfig + SelectionConfig selectionConfig } type NavigationPayload{ RecommendationResult result @@ -115,23 +119,31 @@ type PaginationConfig { } // configuration for item selection -type SelectionConfig { +type SelectionConfig { Event selectByOrdinalEvent Event selectByRelativePositionEvent + Event> selectByNameEvent Event selectByIndexEvent + Action2< + Page, // current page of results + ItemName, + NUMBER // index to select + > indexOfItemByNameApi + Action4< - SearchConditions, // current search conditions Page, // current page of results - NUMBER, - Optional, // index to select + NUMBER, // index to select + Optional, // current search conditions + Optional, RecommendationResult // results for selection > selectItemApi Response presentSelectedItemResponse + } //offers -type CatalogOffers { +type CatalogOffers { // event to allow user to accept a offer Event acceptEvent diff --git a/catalog-explorer/test/handlers/index-of-by-name.test.ts b/catalog-explorer/test/handlers/index-of-by-name.test.ts new file mode 100644 index 0000000..c6a67e7 --- /dev/null +++ b/catalog-explorer/test/handlers/index-of-by-name.test.ts @@ -0,0 +1,84 @@ +import { HandlerInput, ResponseBuilder, AttributesManager } from 'ask-sdk-core'; +import { IndexOfItemByNameHandler } from "../../lambda/handlers/index-of-by-name"; +import { CatalogExplorer } from '../../lambda/interface'; +import * as util from '../../lambda/util'; +import handlerInputObject from "../resources/convertOrdinalToIndexHandlerInput.json"; +import { FixedProvider } from "../../lambda/providers/fixed-provider" +import { + testList, + sessionActiveCatalog, + sessionProviderState +} from '../resources/test-common'; + +let handlerInput: HandlerInput; +let indexOfItemByNameHandler: IndexOfItemByNameHandler; + +let withApiResponseMock = jest.fn(() => handlerInput.responseBuilder); +let getResponseMock = jest.fn(() => handlerInput.responseBuilder); +let withShouldEndSessionMock = jest.fn(() => handlerInput.responseBuilder); + +let getSessionAttributesMock = jest.fn().mockReturnValue({ + "_ac_catalogExplorer": { + "activeCatalog": sessionActiveCatalog, + "providerState": sessionProviderState, + "argsState": {} + } +} +); + +let setSessionAttributesMock = jest.fn(() => handlerInput.responseBuilder); + +let isApiRequestMock = jest.fn(); + +handlerInput = JSON.parse(JSON.stringify(handlerInputObject)); + +beforeEach(() => { + jest.clearAllMocks(); + indexOfItemByNameHandler = new IndexOfItemByNameHandler(); + indexOfItemByNameHandler.getActiveCatalog = jest.fn().mockReturnValue(sessionActiveCatalog); + + + (util.isApiRequest as any) = isApiRequestMock; + isApiRequestMock.mockReturnValue(true); + + handlerInput.responseBuilder = { + withApiResponse: withApiResponseMock, + getResponse: getResponseMock, + withShouldEndSession: withShouldEndSessionMock, + } as unknown as ResponseBuilder; + + handlerInput.attributesManager = { + getSessionAttributes: getSessionAttributesMock, + setSessionAttributes: setSessionAttributesMock, + } as unknown as AttributesManager; + + CatalogExplorer.buildCatalogReference( + handlerInput, + new FixedProvider(testList), + 2 + ) + + jest.spyOn(console, 'error').mockImplementation(() => { }); + jest.spyOn(console, 'log').mockImplementation(() => { }); +}); + +test('IndexOfItemByNameHandler -> canHandle -> should return true when util.isApiRequest returns true', () => { + expect( + indexOfItemByNameHandler.canHandle(handlerInput) + ).toBe(true); +}); + +test('IndexOfItemByNameHandler -> canHandle -> should return false when util.isApiRequest returns false', () => { + isApiRequestMock.mockReturnValue(false); + + expect( + indexOfItemByNameHandler.canHandle(handlerInput) + ).toBe(false); +}); + + +test('IndexOfItemByNameHandler -> handle -> should return correct property value result', () => { + indexOfItemByNameHandler.handle(handlerInput); + expect(handlerInput.responseBuilder.withApiResponse) + .toHaveBeenCalledWith(1); +}); \ No newline at end of file diff --git a/catalog-explorer/test/resources/indexOfByNameHandlerInput.json b/catalog-explorer/test/resources/indexOfByNameHandlerInput.json new file mode 100644 index 0000000..efafa92 --- /dev/null +++ b/catalog-explorer/test/resources/indexOfByNameHandlerInput.json @@ -0,0 +1,139 @@ +{ + "requestEnvelope": { + "version": "1.0", + "session": { + "new": false, + "sessionId": "amzn1.echo-api.session.fakeSessionID", + "application": { + "applicationId": "amzn1.ask.skill.fakeApplicationID" + }, + "user": { + "userId": "amzn1.ask.account.fakeUserID" + } + }, + "context": { + "System": { + "application": { + "applicationId": "amzn1.ask.skill.fakeApplicationID" + }, + "user": { + "userId": "amzn1.ask.account.fakeUserID" + }, + "device": { + "deviceId": "amzn1.ask.device.fakeDeviceID", + "supportedInterfaces": {} + }, + "apiEndpoint": "https://api.amazonalexa.com", + "apiAccessToken": "fakeAPIAccessToken" + }, + "Viewport": { + "experiences": [ + { + "arcMinuteWidth": 346, + "arcMinuteHeight": 216, + "canRotate": false, + "canResize": false + } + ], + "mode": "HUB", + "shape": "RECTANGLE", + "pixelWidth": 1280, + "pixelHeight": 800, + "dpi": 213, + "currentPixelWidth": 1280, + "currentPixelHeight": 800, + "touch": [ + "SINGLE" + ], + "keyboard": null, + "video": { + "codecs": [ + "H_264_42", + "H_264_41" + ] + } + }, + "Viewports": [ + { + "type": "APL", + "id": "main", + "shape": "RECTANGLE", + "dpi": 213, + "presentationType": "STANDARD", + "canRotate": false, + "configuration": { + "current": { + "mode": "HUB", + "video": { + "codecs": [ + "H_264_42", + "H_264_41" + ] + }, + "size": { + "type": "DISCRETE", + "pixelWidth": 1280, + "pixelHeight": 800 + } + } + } + } + ], + "Extensions": { + "available": { + "aplext:backstack:10": {} + } + } + }, + "request": { + "type": "Dialog.API.Invoked", + "requestId": "amzn1.echo-api.request.fakeRequestID", + "timestamp": "2021-11-09T02:05:13Z", + "locale": "en-US", + "currentTurnRawASR": null, + "_utteranceId": null, + "apiRequest": { + "name": "com.amazon.alexa.skill.components.catalog_explorer.utils.convertOrdinalToIndex", + "arguments": { + "page": { + "items": [ + { + "genre": "horror", + "author": "author name" + }, + { + "genre": "comedy", + "author": "author name2" + }, + { + "genre": "horror", + "author": "author name3" + } + ], + "itemCount": 3 + }, + "name": "author name" + } + } + } + }, + "context": { + "callbackWaitsForEmptyEventLoop": true, + "functionVersion": "$LATEST", + "functionName": "catalog_explorer", + "memoryLimitInMB": "128", + "logGroupName": "/aws/lambda/catalog_explorer", + "logStreamName": "2021/11/09/[$LATEST]62295edccfa04441a312cce53bebd7e4", + "invokedFunctionArn": "arn:aws:lambda:us-east-1:786310803673:function:catalog_explorer", + "awsRequestId": "fakeRequestID" + }, + "attributesManager": {}, + "responseBuilder": {}, + "serviceClientFactory": { + "apiConfiguration": { + "apiClient": {}, + "apiEndpoint": "https://api.amazonalexa.com", + "authorizationValue": "fakeValue" + } + } +} \ No newline at end of file From a5ded69ee510c07d9065f4e4a9e4b4b545753256 Mon Sep 17 00:00:00 2001 From: Karan Gandhi Date: Wed, 15 Mar 2023 17:04:35 +0530 Subject: [PATCH 2/3] Bumping version for catalog-explorer --- catalog-explorer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog-explorer/package.json b/catalog-explorer/package.json index 2e03bf6..d42e4d4 100644 --- a/catalog-explorer/package.json +++ b/catalog-explorer/package.json @@ -1,6 +1,6 @@ { "name": "@alexa-skill-components/catalog-explorer", - "version": "0.0.2", + "version": "0.0.3", "publisher": "Amazon", "description": "Alexa skill component for searching, refining and navigating through a catalog", "license": "AmznSL-1.0", From 62b8698b404c828e91903a880a3276f1d7a4ed83 Mon Sep 17 00:00:00 2001 From: Karan Gandhi Date: Wed, 15 Mar 2023 17:15:16 +0530 Subject: [PATCH 3/3] Resolving bug in example skill --- .../skill-package/conversations/book_recommendation.acdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl b/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl index 7cf31ed..d4fa532 100644 --- a/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl +++ b/catalog-explorer/examples/BookRecommendation/skill-package/conversations/book_recommendation.acdl @@ -318,8 +318,8 @@ dialog MainDialog{ getPageApi = getPage, selectByOrdinalEvent = selectByOrdinalEvent, selectByRelativePositionEvent = selectByRelativePositionEvent, - selectByIndexEvent = selectByIndexEvent, selectByNameEvent = selectByNameEvent, + selectByIndexEvent = selectByIndexEvent, indexOfItemByNameApi = indexOfItemByNameApi, selectItemApi = selectItemApi, )