diff --git a/packages/x-adapter-platform/src/platform.adapter.ts b/packages/x-adapter-platform/src/platform.adapter.ts index a144cb63ec..a39523e2e6 100644 --- a/packages/x-adapter-platform/src/platform.adapter.ts +++ b/packages/x-adapter-platform/src/platform.adapter.ts @@ -23,6 +23,7 @@ export const platformAdapter: PlatformAdapter = { recommendations: recommendationsEndpointAdapter, nextQueries: nextQueriesEndpointAdapter, querySuggestions: querySuggestionsEndpointAdapter, + relatedPrompts: undefined, relatedTags: relatedTagsEndpointAdapter, identifierResults: identifierResultsEndpointAdapter, tagging: taggingEndpointAdapter, diff --git a/packages/x-adapter-platform/src/types/platform-adapter.types.ts b/packages/x-adapter-platform/src/types/platform-adapter.types.ts index 03a7f51f37..9c3a81e7af 100644 --- a/packages/x-adapter-platform/src/types/platform-adapter.types.ts +++ b/packages/x-adapter-platform/src/types/platform-adapter.types.ts @@ -33,6 +33,7 @@ export interface PlatformAdapter extends XComponentsAdapter { nextQueries: ExtendableEndpointAdapter; recommendations: ExtendableEndpointAdapter; querySuggestions: ExtendableEndpointAdapter; + relatedPrompts: any; relatedTags: ExtendableEndpointAdapter; identifierResults: ExtendableEndpointAdapter; semanticQueries: ExtendableEndpointAdapter; diff --git a/packages/x-components/src/__tests__/adapter.dummy.ts b/packages/x-components/src/__tests__/adapter.dummy.ts index 2238dcb0d7..de130321fc 100644 --- a/packages/x-components/src/__tests__/adapter.dummy.ts +++ b/packages/x-components/src/__tests__/adapter.dummy.ts @@ -6,6 +6,7 @@ export const XComponentsAdapterDummy: XComponentsAdapter = { popularSearches: jest.fn(), querySuggestions: jest.fn(), recommendations: jest.fn(), + relatedPrompts: jest.fn(), relatedTags: jest.fn(), search: jest.fn(), semanticQueries: jest.fn(), diff --git a/packages/x-components/src/__tests__/utils.ts b/packages/x-components/src/__tests__/utils.ts index 4eceba7d5c..a48590b35a 100644 --- a/packages/x-components/src/__tests__/utils.ts +++ b/packages/x-components/src/__tests__/utils.ts @@ -12,7 +12,8 @@ import { RelatedTagsResponse, SearchResponse, SemanticQueriesResponse, - ExperienceControlsResponse + ExperienceControlsResponse, + RelatedPromptsResponse } from '@empathyco/x-types'; import { XPluginOptions } from '../plugins'; import { XPlugin } from '../plugins/x-plugin'; @@ -41,6 +42,7 @@ interface MockedAdapterFeatures { popularSearches: PopularSearchesResponse; querySuggestions: QuerySuggestionsResponse; recommendations: RecommendationsResponse; + relatedPrompts: RelatedPromptsResponse; relatedTags: RelatedTagsResponse; search: SearchResponse; semanticQueries: SemanticQueriesResponse; @@ -156,6 +158,7 @@ export function getMockedAdapter( popularSearches: getMockedAdapterFunction(responseFeatures?.popularSearches!), querySuggestions: getMockedAdapterFunction(responseFeatures?.querySuggestions!), recommendations: getMockedAdapterFunction(responseFeatures?.recommendations!), + relatedPrompts: getMockedAdapterFunction(responseFeatures?.relatedPrompts!), relatedTags: getMockedAdapterFunction(responseFeatures?.relatedTags!), search: getMockedAdapterFunction(responseFeatures?.search!), semanticQueries: getMockedAdapterFunction(responseFeatures?.semanticQueries!), diff --git a/packages/x-components/src/adapter/e2e-adapter.ts b/packages/x-components/src/adapter/e2e-adapter.ts index 7c7108bc06..092d8a049b 100644 --- a/packages/x-components/src/adapter/e2e-adapter.ts +++ b/packages/x-components/src/adapter/e2e-adapter.ts @@ -42,6 +42,7 @@ export const e2eAdapter: XComponentsAdapter = { popularSearches: mockEndpointAdapter('popular-searches'), querySuggestions: mockEndpointAdapter('query-suggestions'), recommendations: mockEndpointAdapter('recommendations'), + relatedPrompts: mockEndpointAdapter('related-prompts'), relatedTags: mockEndpointAdapter('related-tags'), search: mockEndpointAdapter('search'), semanticQueries: mockEndpointAdapter('semantic-queries'), diff --git a/packages/x-types/src/query-signals/index.ts b/packages/x-types/src/query-signals/index.ts index 84e0740073..b75c532072 100644 --- a/packages/x-types/src/query-signals/index.ts +++ b/packages/x-types/src/query-signals/index.ts @@ -1,4 +1,5 @@ export * from './next-queries.model'; export * from './next-query.model'; +export * from './related-prompt.model'; export * from './related-tag.model'; export * from './semantic-query.model'; diff --git a/packages/x-types/src/query-signals/related-prompt.model.ts b/packages/x-types/src/query-signals/related-prompt.model.ts new file mode 100644 index 0000000000..e3601cbda6 --- /dev/null +++ b/packages/x-types/src/query-signals/related-prompt.model.ts @@ -0,0 +1,13 @@ +import { NamedModel } from '../named-model.model'; + +/** + * Represents a related prompt. + */ +export interface RelatedPrompt extends NamedModel<'RelatedPrompt'> { + /** The next queries related to the prompt. */ + nextQueries: string[]; + /** The prompt. */ + suggestionText: string; + /** The type of the prompt. */ + type: string; +} diff --git a/packages/x-types/src/request/index.ts b/packages/x-types/src/request/index.ts index cd0fd87b3f..f5d02bc968 100644 --- a/packages/x-types/src/request/index.ts +++ b/packages/x-types/src/request/index.ts @@ -3,6 +3,7 @@ export * from './next-queries-request.model'; export * from './popular-searches-request.model'; export * from './query-suggestions-request.model'; export * from './recommendations-request.model'; +export * from './related-prompts-request.model'; export * from './related-tags-request.model'; export * from './request.model'; export * from './search-request.model'; diff --git a/packages/x-types/src/request/related-prompts-request.model.ts b/packages/x-types/src/request/related-prompts-request.model.ts new file mode 100644 index 0000000000..fe005b3c6c --- /dev/null +++ b/packages/x-types/src/request/related-prompts-request.model.ts @@ -0,0 +1,6 @@ +import { ExtraParamsRequest, QueryableRequest } from './request.model'; + +/** + * Request for Related Prompts endpoint. + */ +export interface RelatedPromptsRequest extends QueryableRequest, ExtraParamsRequest {} diff --git a/packages/x-types/src/response/index.ts b/packages/x-types/src/response/index.ts index 14fc912f28..3852605e9f 100644 --- a/packages/x-types/src/response/index.ts +++ b/packages/x-types/src/response/index.ts @@ -3,6 +3,7 @@ export * from './next-queries-response.model'; export * from './popular-searches-response.model'; export * from './query-suggestions-response.model'; export * from './recommendations-response.model'; +export * from './related-prompts-response.model'; export * from './related-tags-response.model'; export * from './response.model'; export * from './search-response.model'; diff --git a/packages/x-types/src/response/related-prompts-response.model.ts b/packages/x-types/src/response/related-prompts-response.model.ts new file mode 100644 index 0000000000..c07147e100 --- /dev/null +++ b/packages/x-types/src/response/related-prompts-response.model.ts @@ -0,0 +1,8 @@ +import { RelatedPrompt } from '../query-signals/related-prompt.model'; + +/** + * Response for the related prompts endpoint. + */ +export interface RelatedPromptsResponse { + relatedPrompts: RelatedPrompt[]; +} diff --git a/packages/x-types/src/schemas/related-prompt.schema.ts b/packages/x-types/src/schemas/related-prompt.schema.ts new file mode 100644 index 0000000000..b2c5400e2b --- /dev/null +++ b/packages/x-types/src/schemas/related-prompt.schema.ts @@ -0,0 +1,11 @@ +import { RelatedPrompt } from '../query-signals'; + +/** + * Jest schema for validating Related Prompt entities. + */ +export const RelatedPromptSchema: RelatedPrompt = { + modelName: expect.any(String), + nextQueries: expect.any(Array), + suggestionText: expect.any(String), + type: expect.any(String) +}; diff --git a/packages/x-types/src/x-components-adapter.model.ts b/packages/x-types/src/x-components-adapter.model.ts index f25072e53f..20978ed03f 100644 --- a/packages/x-types/src/x-components-adapter.model.ts +++ b/packages/x-types/src/x-components-adapter.model.ts @@ -6,6 +6,7 @@ import { PopularSearchesRequest, QuerySuggestionsRequest, RecommendationsRequest, + RelatedPromptsRequest, RelatedTagsRequest, SearchRequest, SemanticQueriesRequest, @@ -20,7 +21,8 @@ import { RelatedTagsResponse, SearchResponse, SemanticQueriesResponse, - ExperienceControlsResponse + ExperienceControlsResponse, + RelatedPromptsResponse } from './response'; export interface XComponentsAdapter { @@ -29,6 +31,7 @@ export interface XComponentsAdapter { nextQueries: EndpointAdapter; recommendations: EndpointAdapter; querySuggestions: EndpointAdapter; + relatedPrompts: EndpointAdapter; relatedTags: EndpointAdapter; identifierResults: EndpointAdapter; tagging: EndpointAdapter;