@coveo/quantic 3.35.1 → 3.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +132 -1
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.css +13 -1
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.html +29 -9
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.js +54 -0
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.js-meta.xml +1 -1
- package/force-app/main/default/lwc/quanticSourceCitations/quanticSourceCitations.js-meta.xml +1 -1
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/commerce-api-params.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/common/request.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/product-enrichment/product-enrichment-request.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/recommendations/recommendations-request.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/search/query-suggest/query-suggest-request.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/answer-generation-api-state.d.ts +29 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/answer-generation-api.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/endpoints/answer/answer-endpoint.d.ts +31 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/endpoints/answer/url-builders/endpoint-url-builder.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/streaming/answer-draft-reducer/answer-draft-reducer.d.ts +26 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/streaming/answer-streaming-runner.d.ts +26 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/streaming/server-state-event-handler/server-state-event-handler.d.ts +21 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/streaming/strategies/streaming-strategies.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-generation/streaming/types.d.ts +42 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/answer-slice.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/search/search-api-params.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/headless-context.d.ts +15 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-actions-loader.d.ts +9 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-actions.d.ts +6 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-state.d.ts +9 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-validation.d.ts +11 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/follow-up-answers/follow-up-answers-state.d.ts +28 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-mocks.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-state.d.ts +42 -36
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/head-answer-strategy.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-request.d.ts +1 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-request.d.ts +1 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/controllers/context/headless-context.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/context/headless-context.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +3 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +4 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/search-app-state.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts +7 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-search-request.d.ts +1 -8
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseQueryFn, CombinedState, FetchArgs, FetchBaseQueryError, QueryDefinition, RetryOptions } from '@reduxjs/toolkit/query';
|
|
2
|
+
import type { GeneratedAnswerCitation, GeneratedContentFormat } from '../../../index.js';
|
|
3
|
+
import type { SearchAppState } from '../../../state/search-app-state.js';
|
|
4
|
+
import type { ConfigurationSection, GeneratedAnswerSection, TabSection } from '../../../state/state-sections.js';
|
|
5
|
+
import type { AnswerEndpointArgs } from './endpoints/answer/answer-endpoint.js';
|
|
6
|
+
export interface GeneratedAnswerServerState {
|
|
7
|
+
answerId?: string;
|
|
8
|
+
contentFormat?: GeneratedContentFormat;
|
|
9
|
+
answer?: string;
|
|
10
|
+
citations?: GeneratedAnswerCitation[];
|
|
11
|
+
generated?: boolean;
|
|
12
|
+
isStreaming: boolean;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error?: {
|
|
15
|
+
message?: string;
|
|
16
|
+
code?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare const initialAnswerGenerationServerState: () => GeneratedAnswerServerState;
|
|
20
|
+
interface AnswerGenerationApiSection {
|
|
21
|
+
answerGenerationApi: CombinedState<{
|
|
22
|
+
generateAnswer: QueryDefinition<AnswerEndpointArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {} & RetryOptions, {}>, never, GeneratedAnswerServerState, 'answerGenerationApi'>;
|
|
23
|
+
}, never, 'answerGenerationApi'>;
|
|
24
|
+
}
|
|
25
|
+
export type AnswerGenerationApiState = {
|
|
26
|
+
searchHub: string;
|
|
27
|
+
pipeline: string;
|
|
28
|
+
} & AnswerGenerationApiSection & ConfigurationSection & Partial<SearchAppState> & GeneratedAnswerSection & Partial<TabSection>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RTK Query API for answer generation operations.
|
|
3
|
+
*/
|
|
4
|
+
export declare const answerGenerationApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, {}, "answerGenerationApi", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnyFacetRequest } from '../../../../../features/facets/generic/interfaces/generic-facet-request.js';
|
|
2
|
+
import type { AnalyticsParam, PipelineRuleParameters } from '../../../../search/search-api-params.js';
|
|
3
|
+
import { type GeneratedAnswerServerState } from '../../answer-generation-api-state.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for answer generation requests.
|
|
6
|
+
*/
|
|
7
|
+
type AnswerParams = {
|
|
8
|
+
q: string;
|
|
9
|
+
facets?: AnyFacetRequest[];
|
|
10
|
+
searchHub?: string;
|
|
11
|
+
pipeline?: string;
|
|
12
|
+
pipelineRuleParameters: PipelineRuleParameters;
|
|
13
|
+
locale: string;
|
|
14
|
+
} & AnalyticsParam;
|
|
15
|
+
/**
|
|
16
|
+
* Arguments for the answer endpoint including streaming strategy and request parameters.
|
|
17
|
+
*/
|
|
18
|
+
export type AnswerEndpointArgs = {
|
|
19
|
+
strategyKey: 'head-answer';
|
|
20
|
+
} & AnswerParams;
|
|
21
|
+
/**
|
|
22
|
+
* RTK Query endpoint for streaming answer generation.
|
|
23
|
+
*/
|
|
24
|
+
export declare const answerEndpoint: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, {
|
|
25
|
+
generateAnswer: import("@reduxjs/toolkit/query").QueryDefinition<AnswerEndpointArgs, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, GeneratedAnswerServerState, "answerGenerationApi">;
|
|
26
|
+
}, "answerGenerationApi", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
27
|
+
/**
|
|
28
|
+
* Initiates an answer generation query with the specified strategy and parameters.
|
|
29
|
+
*/
|
|
30
|
+
export declare const initiateAnswerEndpoint: (args: AnswerEndpointArgs) => import("redux-thunk").ThunkAction<import("@reduxjs/toolkit/query").QueryActionCreatorResult<import("@reduxjs/toolkit/query").QueryDefinition<AnswerEndpointArgs, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, GeneratedAnswerServerState, "answerGenerationApi">>, any, any, import("@reduxjs/toolkit").UnknownAction>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { GeneratedAnswerServerState } from '../../answer-generation-api-state.js';
|
|
2
|
+
import type { Message, StreamPayload } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sets the answer ID in the draft state if provided.
|
|
5
|
+
*/
|
|
6
|
+
export declare const setAnswerId: (draft: GeneratedAnswerServerState, answerId: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Initializes streaming by setting content format and updating streaming flags.
|
|
9
|
+
*/
|
|
10
|
+
export declare const initializeStreamingAnswer: (draft: GeneratedAnswerServerState, payload: Pick<GeneratedAnswerServerState, "contentFormat">) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Appends or sets answer text from streaming deltas.
|
|
13
|
+
*/
|
|
14
|
+
export declare const setAnswer: (draft: GeneratedAnswerServerState, payload: Pick<StreamPayload, "textDelta">) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Updates the citations list in the draft state.
|
|
17
|
+
*/
|
|
18
|
+
export declare const setCitations: (draft: GeneratedAnswerServerState, payload: Pick<StreamPayload, "citations">) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Finalizes streaming by marking it complete and stopping the stream.
|
|
21
|
+
*/
|
|
22
|
+
export declare const endStreaming: (draft: GeneratedAnswerServerState, payload: Pick<StreamPayload, "answerGenerated">) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Sets error state and stops streaming when an error occurs.
|
|
25
|
+
*/
|
|
26
|
+
export declare const setAnswerError: (draft: GeneratedAnswerServerState, message: Message) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ThunkDispatch, UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import type { GeneratedAnswerServerState } from '../answer-generation-api-state.js';
|
|
3
|
+
import type { StreamingStrategy } from './types.js';
|
|
4
|
+
type StateWithConfiguration = {
|
|
5
|
+
configuration: {
|
|
6
|
+
accessToken: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Streams answer generation from an endpoint using a specified strategy.
|
|
11
|
+
*
|
|
12
|
+
* Establishes a server-sent events connection to stream answer generation responses.
|
|
13
|
+
* Coordinates between server state updates (via serverStateEventHandler) and
|
|
14
|
+
* application-specific logic (via strategy handlers).
|
|
15
|
+
*
|
|
16
|
+
* @param endpointUrl - The streaming endpoint URL
|
|
17
|
+
* @param args - Request arguments to send in the POST body
|
|
18
|
+
* @param api - Redux toolkit query API with state getter, dispatch, and cache updater
|
|
19
|
+
* @param strategy - Strategy defining application-specific event handlers
|
|
20
|
+
*/
|
|
21
|
+
export declare const streamAnswerWithStrategy: <TArgs, TState extends StateWithConfiguration>(endpointUrl: string, args: TArgs, api: {
|
|
22
|
+
getState: () => TState;
|
|
23
|
+
dispatch: ThunkDispatch<TState, unknown, UnknownAction>;
|
|
24
|
+
updateCachedData: (updater: (draft: GeneratedAnswerServerState) => void) => void;
|
|
25
|
+
}, strategy: StreamingStrategy<TState>) => Promise<void>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GeneratedAnswerServerState } from '../../answer-generation-api-state.js';
|
|
2
|
+
import type { EventType, Message } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Event handler interface for managing answer server state updates during answer streaming.
|
|
5
|
+
*/
|
|
6
|
+
interface ServerStateEventHandler<TDraft = GeneratedAnswerServerState> {
|
|
7
|
+
/**
|
|
8
|
+
* Extracts and stores the answer ID from response headers.
|
|
9
|
+
*/
|
|
10
|
+
handleOpen: (response: Response, updateCachedData: (updater: (draft: TDraft) => void) => void) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Handlers for different streaming message types that update cached server state.
|
|
13
|
+
*/
|
|
14
|
+
handleMessage: Partial<Record<EventType, (message: Message, updateCachedData: (updater: (draft: TDraft) => void) => void) => void>>;
|
|
15
|
+
handleError?: (error: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Manages answer server state updates during answer generation streaming.
|
|
19
|
+
*/
|
|
20
|
+
export declare const serverStateEventHandler: ServerStateEventHandler;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ThunkDispatch, UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import type { GeneratedContentFormat } from '../../../../features/generated-answer/generated-response-format.js';
|
|
3
|
+
import type { GeneratedAnswerCitation } from '../../../generated-answer/generated-answer-event-payload.js';
|
|
4
|
+
/**
|
|
5
|
+
* Message types received during answer generation streaming.
|
|
6
|
+
*/
|
|
7
|
+
type PayloadType = 'genqa.headerMessageType' | 'genqa.messageType' | 'genqa.citationsType' | 'genqa.endOfStreamType';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a streaming message from the answer generation endpoint.
|
|
10
|
+
*/
|
|
11
|
+
export interface Message {
|
|
12
|
+
payloadType: PayloadType;
|
|
13
|
+
payload: string;
|
|
14
|
+
finishReason?: string;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
code?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Event types including standard payload types and error events.
|
|
20
|
+
*/
|
|
21
|
+
export type EventType = PayloadType | 'error';
|
|
22
|
+
/**
|
|
23
|
+
* Parsed payload data from streaming messages.
|
|
24
|
+
*/
|
|
25
|
+
export interface StreamPayload {
|
|
26
|
+
textDelta?: string;
|
|
27
|
+
padding?: string;
|
|
28
|
+
answerGenerated?: boolean;
|
|
29
|
+
contentFormat?: GeneratedContentFormat;
|
|
30
|
+
citations?: GeneratedAnswerCitation[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Strategy interface for handling application-specific streaming events.
|
|
34
|
+
* Defines handlers for connection lifecycle and message processing.
|
|
35
|
+
*/
|
|
36
|
+
export interface StreamingStrategy<TState> {
|
|
37
|
+
handleOpen: (response: Response, dispatch: ThunkDispatch<TState, unknown, UnknownAction>) => void;
|
|
38
|
+
handleError: (error: unknown) => void;
|
|
39
|
+
handleMessage: Partial<Record<EventType, (message: Message, dispatch: ThunkDispatch<TState, unknown, UnknownAction>) => void>>;
|
|
40
|
+
handleClose?: (dispatch: ThunkDispatch<TState, unknown, UnknownAction>) => void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { type BaseQueryFn, type FetchArgs, type FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
2
|
+
/**
|
|
3
|
+
* `dynamicBaseQuery` is passed to the baseQuery of the createApi,
|
|
4
|
+
* but note that the baseQuery will not be used if a queryFn is provided in the createApi endpoint
|
|
5
|
+
*/
|
|
6
|
+
export declare const dynamicBaseQuery: BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>;
|
|
2
7
|
export declare const answerSlice: import("@reduxjs/toolkit/query").Api<BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, {}, "answer", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
@@ -103,7 +103,7 @@ export interface AutomaticFacetsParams {
|
|
|
103
103
|
export interface PipelineRuleParams {
|
|
104
104
|
pipelineRuleParameters?: PipelineRuleParameters;
|
|
105
105
|
}
|
|
106
|
-
type PipelineRuleParameters = {
|
|
106
|
+
export type PipelineRuleParameters = {
|
|
107
107
|
mlGenerativeQuestionAnswering?: GenQAParameters;
|
|
108
108
|
};
|
|
109
109
|
type GenQAParameters = {
|
package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts
CHANGED
|
@@ -63,11 +63,12 @@ export type { PlatformEnvironment } from './utils/url-utils.js';
|
|
|
63
63
|
export { Selectors };
|
|
64
64
|
export type { CartItemParam } from './api/commerce/commerce-api-params.js';
|
|
65
65
|
export type { Badge, BadgePlacement, BadgesProduct, } from './api/commerce/product-enrichment/product-enrichment-response.js';
|
|
66
|
+
export { deserializeRelativeDate, validateRelativeDate, } from './api/search/date/relative-date.js';
|
|
66
67
|
export type { CategoryFacetSearchResult } from './api/search/facet-search/category-facet-search/category-facet-search-response.js';
|
|
67
68
|
export type { SpecificFacetSearchResult as RegularFacetSearchResult } from './api/search/facet-search/specific-facet-search/specific-facet-search-response.js';
|
|
68
69
|
export type { Cart, CartInitialState, CartItem, CartProps, CartState, } from './controllers/commerce/context/cart/headless-cart.js';
|
|
69
70
|
export { buildCart } from './controllers/commerce/context/cart/headless-cart.js';
|
|
70
|
-
export type { Context, ContextOptions, ContextProps, ContextState, UserLocation, View, } from './controllers/commerce/context/headless-context.js';
|
|
71
|
+
export type { Context, ContextOptions, ContextProps, ContextState, CustomContext, UserLocation, View, } from './controllers/commerce/context/headless-context.js';
|
|
71
72
|
export { buildContext } from './controllers/commerce/context/headless-context.js';
|
|
72
73
|
export type { Breadcrumb, BreadcrumbManager, BreadcrumbManagerState, BreadcrumbValue, DeselectableValue, } from './controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.js';
|
|
73
74
|
export type { CategoryFacet, CategoryFacetState, } from './controllers/commerce/core/facets/category/headless-commerce-category-facet.js';
|
|
@@ -142,6 +143,5 @@ export type { CommerceSearchParameters } from './features/commerce/search-parame
|
|
|
142
143
|
export type { SearchParameters } from './features/search-parameters/search-parameter-actions.js';
|
|
143
144
|
export type { Template } from './features/templates/templates-manager.ts';
|
|
144
145
|
export { HighlightUtils };
|
|
145
|
-
export { deserializeRelativeDate, validateRelativeDate, } from './api/search/date/relative-date.js';
|
|
146
146
|
export { productListingSerializer, searchSerializer, } from './features/commerce/parameters/parameters-serializer.js';
|
|
147
147
|
export { VERSION } from './utils/version.js';
|
|
@@ -7,6 +7,7 @@ export interface ContextOptions {
|
|
|
7
7
|
currency: CurrencyCodeISO4217;
|
|
8
8
|
view: View;
|
|
9
9
|
location?: UserLocation;
|
|
10
|
+
custom?: CustomContext;
|
|
10
11
|
}
|
|
11
12
|
export interface View {
|
|
12
13
|
url: string;
|
|
@@ -15,6 +16,14 @@ export interface UserLocation {
|
|
|
15
16
|
latitude: number;
|
|
16
17
|
longitude: number;
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom context that accepts JSON-serializable values.
|
|
21
|
+
* Values should be primitives (string, number, boolean, null) or nested objects/arrays of primitives.
|
|
22
|
+
* Detailed validation is performed by the backend.
|
|
23
|
+
*/
|
|
24
|
+
export interface CustomContext {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
18
27
|
export interface ContextProps {
|
|
19
28
|
/**
|
|
20
29
|
* The initial options that should be applied to this `Context` controller.
|
|
@@ -53,6 +62,11 @@ export interface Context extends Controller {
|
|
|
53
62
|
* @param location - The new location.
|
|
54
63
|
*/
|
|
55
64
|
setLocation(location: UserLocation): void;
|
|
65
|
+
/**
|
|
66
|
+
* Sets custom context values.
|
|
67
|
+
* @param custom - An object containing custom key-value pairs.
|
|
68
|
+
*/
|
|
69
|
+
setCustom(custom: CustomContext): void;
|
|
56
70
|
/**
|
|
57
71
|
* A scoped and simplified part of the headless state that is relevant to the `Context` controller.
|
|
58
72
|
*/
|
|
@@ -70,6 +84,7 @@ export interface ContextState {
|
|
|
70
84
|
currency: CurrencyCodeISO4217;
|
|
71
85
|
view: View;
|
|
72
86
|
location?: UserLocation;
|
|
87
|
+
custom?: CustomContext;
|
|
73
88
|
}
|
|
74
89
|
/**
|
|
75
90
|
* Creates a `Context` controller instance.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { CommerceEngine } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
|
-
import { type SetContextPayload, type SetLocationPayload, type SetViewPayload } from './context-actions.js';
|
|
4
|
-
export type { SetContextPayload,
|
|
3
|
+
import { type SetContextPayload, type SetCustomPayload, type SetLocationPayload, type SetViewPayload } from './context-actions.js';
|
|
4
|
+
export type { SetContextPayload, SetCustomPayload, SetLocationPayload, SetViewPayload, };
|
|
5
5
|
/**
|
|
6
6
|
* The context action creators.
|
|
7
7
|
*
|
|
@@ -30,6 +30,13 @@ export interface ContextActionCreators {
|
|
|
30
30
|
* @returns A dispatchable action.
|
|
31
31
|
*/
|
|
32
32
|
setLocation(payload: SetLocationPayload): PayloadAction<SetLocationPayload>;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the custom context property without modifying any other context properties.
|
|
35
|
+
*
|
|
36
|
+
* @param payload - The action creator payload.
|
|
37
|
+
* @returns A dispatchable action.
|
|
38
|
+
*/
|
|
39
|
+
setCustom(payload: SetCustomPayload): PayloadAction<SetCustomPayload>;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
35
42
|
* Loads the commerce context reducer and returns the available context action creators.
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { CurrencyCodeISO4217 } from '@coveo/relay-event-types';
|
|
2
2
|
import type { ViewParams } from '../../../api/commerce/commerce-api-params.js';
|
|
3
|
-
import type { LocationState } from './context-state.js';
|
|
3
|
+
import type { CustomContextState, LocationState } from './context-state.js';
|
|
4
4
|
export interface SetContextPayload {
|
|
5
5
|
language: string;
|
|
6
6
|
country: string;
|
|
7
7
|
currency: CurrencyCodeISO4217;
|
|
8
8
|
view: SetViewPayload;
|
|
9
9
|
location?: SetLocationPayload;
|
|
10
|
+
custom?: CustomContextState;
|
|
10
11
|
}
|
|
11
12
|
export declare const setContext: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetContextPayload], SetContextPayload, "commerce/context/set", never, never>;
|
|
12
13
|
export type SetViewPayload = Pick<ViewParams, 'url'>;
|
|
13
14
|
export declare const setView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetViewPayload], SetViewPayload, "commerce/context/setView", never, never>;
|
|
14
15
|
export type SetLocationPayload = LocationState;
|
|
15
16
|
export declare const setLocation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: Required<Pick<import("../../../api/commerce/commerce-api-params.js").UserParams, "latitude" | "longitude">>], Required<Pick<import("../../../api/commerce/commerce-api-params.js").UserParams, "latitude" | "longitude">>, "commerce/context/setLocation", never, never>;
|
|
17
|
+
export type SetCustomPayload = CustomContextState | undefined;
|
|
18
|
+
export declare const setCustom: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SetCustomPayload], {
|
|
19
|
+
custom: SetCustomPayload;
|
|
20
|
+
}, "commerce/context/setCustom", never, never>;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { CurrencyCodeISO4217 } from '@coveo/relay-event-types';
|
|
2
2
|
import type { UserParams, ViewParams } from '../../../api/commerce/commerce-api-params.js';
|
|
3
3
|
export type LocationState = Required<Pick<UserParams, 'latitude' | 'longitude'>>;
|
|
4
|
+
/**
|
|
5
|
+
* Custom context state that accepts JSON-serializable values.
|
|
6
|
+
* Values should be primitives (string, number, boolean, null) or nested objects/arrays of primitives.
|
|
7
|
+
* Detailed validation is performed by the backend.
|
|
8
|
+
*/
|
|
9
|
+
export interface CustomContextState {
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
4
12
|
export interface CommerceContextState {
|
|
5
13
|
language: string;
|
|
6
14
|
country: string;
|
|
7
15
|
currency: CurrencyCodeISO4217;
|
|
8
16
|
view: ViewParams;
|
|
9
17
|
location?: LocationState;
|
|
18
|
+
custom?: CustomContextState;
|
|
10
19
|
}
|
|
11
20
|
export declare const getContextInitialState: () => CommerceContextState;
|
|
@@ -7,12 +7,22 @@ export declare const locationDefinition: {
|
|
|
7
7
|
latitude: NumberValue;
|
|
8
8
|
longitude: NumberValue;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Custom context for passing additional JSON-serializable data.
|
|
12
|
+
* Values should be primitives (string, number, boolean, null) or nested objects/arrays.
|
|
13
|
+
* Pass undefined to clear custom context.
|
|
14
|
+
* Detailed validation is performed by the backend.
|
|
15
|
+
*/
|
|
16
|
+
export declare const customDefinition: {
|
|
17
|
+
custom: RecordValue;
|
|
18
|
+
};
|
|
10
19
|
export declare const contextDefinition: {
|
|
11
20
|
language: StringValue<string>;
|
|
12
21
|
country: StringValue<string>;
|
|
13
22
|
currency: StringValue<CurrencyCodeISO4217>;
|
|
14
23
|
view: RecordValue;
|
|
15
24
|
location: RecordValue;
|
|
25
|
+
custom: RecordValue;
|
|
16
26
|
};
|
|
17
27
|
export declare const contextSchema: Schema<{
|
|
18
28
|
language: string;
|
|
@@ -20,4 +30,5 @@ export declare const contextSchema: Schema<{
|
|
|
20
30
|
currency: CurrencyCodeISO4217;
|
|
21
31
|
view: unknown;
|
|
22
32
|
location: unknown;
|
|
33
|
+
custom: unknown;
|
|
23
34
|
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GeneratedAnswerBase } from '../generated-answer/generated-answer-state.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Represents a follow-up answer generated in response to a user's question.
|
|
5
|
+
* Extends the base generated answer structure with the originating question.
|
|
6
|
+
*/
|
|
7
|
+
interface FollowUpAnswer extends GeneratedAnswerBase {
|
|
8
|
+
/** The question prompted to generate this follow-up answer. */
|
|
9
|
+
question: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
* The follow-up answers state.
|
|
14
|
+
*/
|
|
15
|
+
export interface FollowUpAnswersState {
|
|
16
|
+
/** The unique identifier of the follow-up answer session. */
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Determines if the follow-up answer feature is enabled.
|
|
20
|
+
*/
|
|
21
|
+
isEnabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The follow-up answers.
|
|
24
|
+
*/
|
|
25
|
+
followUpAnswers: FollowUpAnswer[];
|
|
26
|
+
}
|
|
27
|
+
export declare function getFollowUpAnswersInitialState(): FollowUpAnswersState;
|
|
28
|
+
export {};
|
|
@@ -63,6 +63,7 @@ export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpressionWi
|
|
|
63
63
|
recentQueries?: import("../recent-queries/recent-queries-state.js").RecentQueriesState | undefined;
|
|
64
64
|
excerptLength?: import("../excerpt-length/excerpt-length-state.js").ExcerptLengthState | undefined;
|
|
65
65
|
generatedAnswer: import("./generated-answer-state.js").GeneratedAnswerState;
|
|
66
|
+
followUpAnswers?: import("../follow-up-answers/follow-up-answers-state.js").FollowUpAnswersState | undefined;
|
|
66
67
|
instantResults?: import("../instant-results/instant-results-state.js").InstantResultsState | undefined;
|
|
67
68
|
insightConfiguration?: import("../insight-configuration/insight-configuration-state.js").InsightConfigurationState | undefined;
|
|
68
69
|
insightCaseContext?: import("../case-context/case-context-state.js").CaseContextState | undefined;
|
|
@@ -2,17 +2,12 @@ import type { GeneratedAnswerCitation } from '../../api/generated-answer/generat
|
|
|
2
2
|
import type { AnswerApiQueryParams } from '../../features/generated-answer/generated-answer-request.js';
|
|
3
3
|
import type { GeneratedContentFormat, GeneratedResponseFormat } from './generated-response-format.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @group Controllers
|
|
8
|
-
* @category GeneratedAnswer
|
|
5
|
+
* Base interface for generated answer structures.
|
|
6
|
+
* Contains core properties shared across different generated answer implementations.
|
|
9
7
|
*/
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Determines if the generated answer is visible.
|
|
14
|
-
*/
|
|
15
|
-
isVisible: boolean;
|
|
8
|
+
export interface GeneratedAnswerBase {
|
|
9
|
+
/** The unique identifier of the answer returned by the backend. */
|
|
10
|
+
answerId?: string;
|
|
16
11
|
/**
|
|
17
12
|
* Determines if the generated answer is loading.
|
|
18
13
|
*/
|
|
@@ -21,10 +16,6 @@ export interface GeneratedAnswerState {
|
|
|
21
16
|
* Determines if the generated answer is streaming.
|
|
22
17
|
*/
|
|
23
18
|
isStreaming: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Determines if the generated answer is enabled.
|
|
26
|
-
*/
|
|
27
|
-
isEnabled: boolean;
|
|
28
19
|
/**
|
|
29
20
|
* The generated answer.
|
|
30
21
|
*/
|
|
@@ -39,6 +30,22 @@ export interface GeneratedAnswerState {
|
|
|
39
30
|
* The document snippets retrieved to generate the answer.
|
|
40
31
|
*/
|
|
41
32
|
citations: GeneratedAnswerCitation[];
|
|
33
|
+
/**
|
|
34
|
+
* The generated answer error.
|
|
35
|
+
*/
|
|
36
|
+
error?: {
|
|
37
|
+
message?: string;
|
|
38
|
+
code?: number;
|
|
39
|
+
isRetryable?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Determines if the answer is generated.
|
|
43
|
+
*/
|
|
44
|
+
isAnswerGenerated: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether an answer cannot be generated after a query is executed.
|
|
47
|
+
*/
|
|
48
|
+
cannotAnswer: boolean;
|
|
42
49
|
/**
|
|
43
50
|
* Determines if the generated answer is liked, or upvoted by the end user.
|
|
44
51
|
*/
|
|
@@ -48,41 +55,42 @@ export interface GeneratedAnswerState {
|
|
|
48
55
|
*/
|
|
49
56
|
disliked: boolean;
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
58
|
+
* Determines if the generated answer feedback was submitted.
|
|
52
59
|
*/
|
|
53
|
-
|
|
60
|
+
feedbackSubmitted: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A scoped and simplified part of the headless state that is relevant to the `GeneratedAnswer` component.
|
|
64
|
+
*
|
|
65
|
+
* @group Controllers
|
|
66
|
+
* @category GeneratedAnswer
|
|
67
|
+
*/
|
|
68
|
+
export interface GeneratedAnswerState extends GeneratedAnswerBase {
|
|
69
|
+
id: string;
|
|
54
70
|
/**
|
|
55
|
-
* Determines if the
|
|
71
|
+
* Determines if the generated answer is visible.
|
|
56
72
|
*/
|
|
57
|
-
|
|
73
|
+
isVisible: boolean;
|
|
58
74
|
/**
|
|
59
|
-
*
|
|
75
|
+
* Determines if the generated answer is enabled.
|
|
60
76
|
*/
|
|
61
|
-
|
|
62
|
-
message?: string;
|
|
63
|
-
code?: number;
|
|
64
|
-
isRetryable?: boolean;
|
|
65
|
-
};
|
|
77
|
+
isEnabled: boolean;
|
|
66
78
|
/**
|
|
67
|
-
*
|
|
79
|
+
* The desired format options for the generated answer.
|
|
68
80
|
*/
|
|
69
|
-
|
|
81
|
+
responseFormat: GeneratedResponseFormat;
|
|
70
82
|
/**
|
|
71
|
-
*
|
|
83
|
+
* Determines if the feedback modal is currently opened.
|
|
72
84
|
*/
|
|
73
|
-
|
|
85
|
+
feedbackModalOpen: boolean;
|
|
74
86
|
/**
|
|
75
|
-
*
|
|
87
|
+
* A list of indexed fields to include in the citations returned with the generated answer.
|
|
76
88
|
*/
|
|
77
|
-
|
|
89
|
+
fieldsToIncludeInCitations: string[];
|
|
78
90
|
/**
|
|
79
91
|
* Whether the answer is expanded.
|
|
80
92
|
*/
|
|
81
93
|
expanded: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Whether an answer cannot be generated after a query is executed.
|
|
84
|
-
*/
|
|
85
|
-
cannotAnswer: boolean;
|
|
86
94
|
/**
|
|
87
95
|
* The answer configuration unique identifier.
|
|
88
96
|
*/
|
|
@@ -91,8 +99,6 @@ export interface GeneratedAnswerState {
|
|
|
91
99
|
* The query parameters used for the answer API request cache key
|
|
92
100
|
*/
|
|
93
101
|
answerApiQueryParams?: AnswerApiQueryParams;
|
|
94
|
-
/** The unique identifier of the answer returned by the Answer API. */
|
|
95
|
-
answerId?: string;
|
|
96
102
|
/** The current mode of answer generation. */
|
|
97
103
|
answerGenerationMode: 'automatic' | 'manual';
|
|
98
104
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AnswerGenerationApiState } from '../../api/knowledge/answer-generation/answer-generation-api-state.js';
|
|
2
|
+
import type { StreamingStrategy } from '../../api/knowledge/answer-generation/streaming/types.js';
|
|
3
|
+
export declare const headAnswerStrategy: StreamingStrategy<AnswerGenerationApiState>;
|
|
@@ -4,14 +4,7 @@ import type { ConfigurationSection } from '../../../state/state-sections.js';
|
|
|
4
4
|
import type { AutomaticFacetRequest } from '../../facets/automatic-facet-set/interfaces/request.js';
|
|
5
5
|
type StateNeededBySearchRequest = ConfigurationSection & Partial<SearchAppState>;
|
|
6
6
|
export declare const buildSearchRequest: (state: StateNeededBySearchRequest, eventDescription?: EventDescription) => Promise<import("../search-mappings.js").MappedSearchRequest<{
|
|
7
|
-
pipelineRuleParameters?:
|
|
8
|
-
mlGenerativeQuestionAnswering?: {
|
|
9
|
-
responseFormat: {
|
|
10
|
-
contentFormat?: import("../../generated-answer/generated-response-format.js").GeneratedContentFormat[];
|
|
11
|
-
};
|
|
12
|
-
citationsFieldToInclude: string[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
7
|
+
pipelineRuleParameters?: import("../../../api/search/search-api-params.js").PipelineRuleParameters;
|
|
15
8
|
generateAutomaticFacets?: {
|
|
16
9
|
desiredCount: number;
|
|
17
10
|
numberOfValues?: number;
|
|
@@ -5,14 +5,7 @@ import type { ConfigurationSection } from '../../state/state-sections.js';
|
|
|
5
5
|
import type { AutomaticFacetRequest } from '../facets/automatic-facet-set/interfaces/request.js';
|
|
6
6
|
type StateNeededBySearchRequest = ConfigurationSection & Partial<SearchAppState>;
|
|
7
7
|
export declare const buildSearchRequest: (state: StateNeededBySearchRequest, navigatorContext: NavigatorContext, eventDescription?: EventDescription) => Promise<import("./search-mappings.js").MappedSearchRequest<{
|
|
8
|
-
pipelineRuleParameters?:
|
|
9
|
-
mlGenerativeQuestionAnswering?: {
|
|
10
|
-
responseFormat: {
|
|
11
|
-
contentFormat?: import("../generated-answer/generated-response-format.js").GeneratedContentFormat[];
|
|
12
|
-
};
|
|
13
|
-
citationsFieldToInclude: string[];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
8
|
+
pipelineRuleParameters?: import("../../api/search/search-api-params.js").PipelineRuleParameters;
|
|
16
9
|
generateAutomaticFacets?: {
|
|
17
10
|
desiredCount: number;
|
|
18
11
|
numberOfValues?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Context, type ContextOptions, type ContextProps, type ContextState, type UserLocation, type View } from '../../../../controllers/commerce/context/headless-context.js';
|
|
1
|
+
import { type Context, type ContextOptions, type ContextProps, type ContextState, type CustomContext, type UserLocation, type View } from '../../../../controllers/commerce/context/headless-context.js';
|
|
2
2
|
import type { UniversalControllerDefinitionWithProps } from '../../types/controller-definitions.js';
|
|
3
|
-
export type { Context, ContextProps, ContextState,
|
|
3
|
+
export type { Context, ContextOptions, ContextProps, ContextState, CustomContext, UserLocation, View, };
|
|
4
4
|
export interface ContextDefinition extends UniversalControllerDefinitionWithProps<Context, ContextOptions> {
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
@@ -85,7 +85,7 @@ export type { BreadcrumbManager, BreadcrumbManagerDefinition, BreadcrumbManagerS
|
|
|
85
85
|
export { defineBreadcrumbManager } from './ssr-next/commerce/controllers/breadcrumb-manager/headless-core-breadcrumb-manager.ssr.js';
|
|
86
86
|
export type { Cart, CartBuildProps, CartDefinition, CartInitialState, CartItem, CartProps, CartState, } from './ssr-next/commerce/controllers/cart/headless-cart.ssr.js';
|
|
87
87
|
export { defineCart } from './ssr-next/commerce/controllers/cart/headless-cart.ssr.js';
|
|
88
|
-
export type { Context, ContextDefinition, ContextOptions, ContextProps, ContextState, UserLocation, View, } from './ssr-next/commerce/controllers/context/headless-context.ssr.js';
|
|
88
|
+
export type { Context, ContextDefinition, ContextOptions, ContextProps, ContextState, CustomContext, UserLocation, View, } from './ssr-next/commerce/controllers/context/headless-context.ssr.js';
|
|
89
89
|
export { defineContext } from './ssr-next/commerce/controllers/context/headless-context.ssr.js';
|
|
90
90
|
export type { DidYouMean, DidYouMeanDefinition, DidYouMeanState, } from './ssr-next/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.js';
|
|
91
91
|
export { defineDidYouMean } from './ssr-next/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.js';
|
package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export type { BreadcrumbManager, BreadcrumbManagerState, } from './ssr/commerce/
|
|
|
80
80
|
export { defineBreadcrumbManager } from './ssr/commerce/controllers/breadcrumb-manager/headless-core-breadcrumb-manager.ssr.js';
|
|
81
81
|
export type { Cart, CartBuildProps, CartDefinition, CartInitialState, CartItem, CartProps, CartState, } from './ssr/commerce/controllers/cart/headless-cart.ssr.js';
|
|
82
82
|
export { defineCart } from './ssr/commerce/controllers/cart/headless-cart.ssr.js';
|
|
83
|
-
export type { Context, ContextDefinition, ContextOptions, ContextProps, ContextState, UserLocation, View, } from './ssr/commerce/controllers/context/headless-context.ssr.js';
|
|
83
|
+
export type { Context, ContextDefinition, ContextOptions, ContextProps, ContextState, CustomContext, UserLocation, View, } from './ssr/commerce/controllers/context/headless-context.ssr.js';
|
|
84
84
|
export { defineContext } from './ssr/commerce/controllers/context/headless-context.ssr.js';
|
|
85
85
|
export type { DidYouMean, DidYouMeanState, } from './ssr/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.js';
|
|
86
86
|
export { defineDidYouMean } from './ssr/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Context, type ContextOptions, type ContextProps, type ContextState, type UserLocation, type View } from '../../../../controllers/commerce/context/headless-context.js';
|
|
1
|
+
import { type Context, type ContextOptions, type ContextProps, type ContextState, type CustomContext, type UserLocation, type View } from '../../../../controllers/commerce/context/headless-context.js';
|
|
2
2
|
import type { UniversalControllerDefinitionWithProps } from '../../types/controller-definitions.js';
|
|
3
|
-
export type { Context, ContextProps, ContextState,
|
|
3
|
+
export type { Context, ContextOptions, ContextProps, ContextState, CustomContext, UserLocation, View, };
|
|
4
4
|
export type ContextDefinition = UniversalControllerDefinitionWithProps<Context, {
|
|
5
5
|
initialState: ContextOptions;
|
|
6
6
|
}>;
|