@coveo/quantic 3.29.4-pre.fe2dbcea63 → 3.29.4
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/staticresources/coveoheadless/case-assist/headless.js +8 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/search-analytics.d.ts +5 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/generated-answer-stream.d.ts +15 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api-state.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api.d.ts +8 -28
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/tests/stream-answer-api-state-mock.d.ts +12 -12
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/sort/headless-core-sort.d.ts +12 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-selectors.d.ts +1 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/engine/commerce-engine.ssr.d.ts +3 -28
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +1 -22
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/engine.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/fetch-static-state.d.ts +1 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +20 -18
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts +8 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -12
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -11
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +7 -9
- package/package.json +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/navigator-context-utils.d.ts +0 -16
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/navigator-context-utils.spec.d.ts +0 -1
|
@@ -90,13 +90,15 @@ export declare class SearchAnalyticsProvider extends BaseAnalyticsProvider<State
|
|
|
90
90
|
protected get responseTime(): number;
|
|
91
91
|
protected get numberOfResults(): number;
|
|
92
92
|
}
|
|
93
|
-
interface LegacyConfigureAnalyticsOptions {
|
|
93
|
+
interface LegacyConfigureAnalyticsOptions<State extends ConfigurationSection = StateNeededBySearchAnalyticsProvider> {
|
|
94
94
|
logger: Logger;
|
|
95
95
|
analyticsClientMiddleware?: AnalyticsClientSendEventHook;
|
|
96
96
|
preprocessRequest?: PreprocessRequest;
|
|
97
97
|
provider?: SearchPageClientProvider;
|
|
98
|
-
getState():
|
|
98
|
+
getState(): State;
|
|
99
99
|
}
|
|
100
|
-
export declare const configureLegacyAnalytics: ({ logger, getState, analyticsClientMiddleware, preprocessRequest, provider, }: LegacyConfigureAnalyticsOptions
|
|
100
|
+
export declare const configureLegacyAnalytics: <State extends ConfigurationSection = StateNeededBySearchAnalyticsProvider>({ logger, getState, analyticsClientMiddleware, preprocessRequest, provider, }: LegacyConfigureAnalyticsOptions<State> & {
|
|
101
|
+
provider: SearchPageClientProvider;
|
|
102
|
+
}) => CoveoSearchPageClient;
|
|
101
103
|
export declare const getPageID: () => string;
|
|
102
104
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GeneratedContentFormat } from '../../features/generated-answer/generated-response-format.js';
|
|
2
|
+
import type { GeneratedAnswerCitation } from '../generated-answer/generated-answer-event-payload.js';
|
|
3
|
+
export interface GeneratedAnswerStream {
|
|
4
|
+
answerId?: string;
|
|
5
|
+
contentFormat?: GeneratedContentFormat;
|
|
6
|
+
answer?: string;
|
|
7
|
+
citations?: GeneratedAnswerCitation[];
|
|
8
|
+
generated?: boolean;
|
|
9
|
+
isStreaming: boolean;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error?: {
|
|
12
|
+
message: string;
|
|
13
|
+
code: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NavigatorContext } from '../../app/navigator-context-provider.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { StreamAnswerAPIState } from './stream-answer-api-state.js';
|
|
3
3
|
export declare const triggerSearchRequest: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
4
|
-
state:
|
|
4
|
+
state: StreamAnswerAPIState;
|
|
5
5
|
navigatorContext: NavigatorContext;
|
|
6
6
|
}, {
|
|
7
7
|
state?: unknown;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SearchAppState } from '../../state/search-app-state.js';
|
|
2
|
+
import type { ConfigurationSection, GeneratedAnswerSection, GetAnswerQuerySection, InsightConfigurationSection, TabSection } from '../../state/state-sections.js';
|
|
3
|
+
export type StreamAnswerAPIState = {
|
|
4
|
+
searchHub: string;
|
|
5
|
+
pipeline: string;
|
|
6
|
+
} & GetAnswerQuerySection & ConfigurationSection & Partial<SearchAppState> & Partial<InsightConfigurationSection> & GeneratedAnswerSection & Partial<TabSection>;
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
import { type ThunkDispatch, type UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import { type NavigatorContext } from '../../app/navigator-context-provider.js';
|
|
3
|
-
import type { GeneratedContentFormat } from '../../features/generated-answer/generated-response-format.js';
|
|
4
|
-
import type { SearchAppState } from '../../state/search-app-state.js';
|
|
5
|
-
import type { ConfigurationSection, GeneratedAnswerSection, InsightConfigurationSection, TabSection } from '../../state/state-sections.js';
|
|
6
3
|
import type { EventSourceMessage } from '../../utils/fetch-event-source/parse.js';
|
|
7
|
-
import type { GeneratedAnswerCitation } from '../generated-answer/generated-answer-event-payload.js';
|
|
8
4
|
import type { SearchRequest } from '../search/search/search-request.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
answer: ReturnType<typeof answerApi.reducer>;
|
|
13
|
-
} & ConfigurationSection & Partial<SearchAppState> & Partial<InsightConfigurationSection> & GeneratedAnswerSection & Partial<TabSection>;
|
|
14
|
-
export interface GeneratedAnswerStream {
|
|
15
|
-
answerId?: string;
|
|
16
|
-
contentFormat?: GeneratedContentFormat;
|
|
17
|
-
answer?: string;
|
|
18
|
-
citations?: GeneratedAnswerCitation[];
|
|
19
|
-
generated?: boolean;
|
|
20
|
-
isStreaming: boolean;
|
|
21
|
-
isLoading: boolean;
|
|
22
|
-
error?: {
|
|
23
|
-
message: string;
|
|
24
|
-
code: number;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export declare const updateCacheWithEvent: (event: EventSourceMessage, draft: GeneratedAnswerStream, dispatch: ThunkDispatch<StateNeededByAnswerAPI, unknown, UnknownAction>) => void;
|
|
5
|
+
import type { GeneratedAnswerStream } from './generated-answer-stream.js';
|
|
6
|
+
import type { StreamAnswerAPIState } from './stream-answer-api-state.js';
|
|
7
|
+
export declare const updateCacheWithEvent: (event: EventSourceMessage, draft: GeneratedAnswerStream, dispatch: ThunkDispatch<StreamAnswerAPIState, unknown, UnknownAction>) => void;
|
|
28
8
|
export declare const answerApi: 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, {}>, {
|
|
29
9
|
getAnswer: import("@reduxjs/toolkit/query").QueryDefinition<Partial<SearchRequest>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, GeneratedAnswerStream, "answer">;
|
|
30
10
|
}, "answer", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
@@ -73,7 +53,7 @@ export declare const selectAnswerTriggerParams: ((state: any, ...params: any[])
|
|
|
73
53
|
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
74
54
|
memoize: typeof import("reselect").weakMapMemoize;
|
|
75
55
|
};
|
|
76
|
-
export declare const constructAnswerQueryParams: (state:
|
|
56
|
+
export declare const constructAnswerQueryParams: (state: StreamAnswerAPIState, usage: "fetch" | "select", navigatorContext: NavigatorContext) => {
|
|
77
57
|
analytics?: {
|
|
78
58
|
actionCause?: string;
|
|
79
59
|
customData?: object;
|
|
@@ -100,12 +80,12 @@ export declare const constructAnswerQueryParams: (state: StateNeededByAnswerAPI,
|
|
|
100
80
|
} | undefined;
|
|
101
81
|
enableDidYouMean?: boolean | undefined;
|
|
102
82
|
fieldsToInclude?: string[] | undefined;
|
|
103
|
-
facets?: (import("../../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../../features/facets/range-facets/
|
|
83
|
+
facets?: (import("../../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest | import("../../features/facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest)[] | undefined;
|
|
104
84
|
pipeline?: string | undefined;
|
|
105
85
|
searchHub?: string | undefined;
|
|
106
86
|
pipelineRuleParameters: {
|
|
107
87
|
mlGenerativeQuestionAnswering: {
|
|
108
|
-
responseFormat: import("../../
|
|
88
|
+
responseFormat: import("../../index.js").GeneratedResponseFormat;
|
|
109
89
|
citationsFieldToInclude: string[];
|
|
110
90
|
};
|
|
111
91
|
};
|
|
@@ -117,8 +97,8 @@ export declare const constructAnswerQueryParams: (state: StateNeededByAnswerAPI,
|
|
|
117
97
|
aq?: string | undefined;
|
|
118
98
|
q: string | undefined;
|
|
119
99
|
};
|
|
120
|
-
export declare const fetchAnswer: (state:
|
|
121
|
-
export declare const selectAnswer: (state:
|
|
100
|
+
export declare const fetchAnswer: (state: StreamAnswerAPIState, navigatorContext: NavigatorContext) => import("redux-thunk").ThunkAction<import("@reduxjs/toolkit/query").QueryActionCreatorResult<import("@reduxjs/toolkit/query").QueryDefinition<Partial<SearchRequest>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, GeneratedAnswerStream, "answer">>, any, any, UnknownAction>;
|
|
101
|
+
export declare const selectAnswer: (state: StreamAnswerAPIState, navigatorContext?: NavigatorContext) => ({
|
|
122
102
|
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
123
103
|
originalArgs?: undefined | undefined;
|
|
124
104
|
data?: undefined | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** biome-ignore-all lint/suspicious/noExplicitAny: <mock> */
|
|
2
|
-
import type {
|
|
3
|
-
export declare const streamAnswerAPIStateMock:
|
|
4
|
-
export declare const streamAnswerAPIStateMockWithATabWithAnExpression:
|
|
5
|
-
export declare const streamAnswerAPIStateMockWithoutAnyTab:
|
|
6
|
-
export declare const streamAnswerAPIStateMockWithStaticFiltersSelected:
|
|
7
|
-
export declare const streamAnswerAPIStateMockWithNonValidFilters:
|
|
8
|
-
export declare const streamAnswerAPIStateMockWithoutAnyFilters:
|
|
9
|
-
export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpression:
|
|
2
|
+
import type { StreamAnswerAPIState } from '../stream-answer-api-state.js';
|
|
3
|
+
export declare const streamAnswerAPIStateMock: StreamAnswerAPIState;
|
|
4
|
+
export declare const streamAnswerAPIStateMockWithATabWithAnExpression: StreamAnswerAPIState;
|
|
5
|
+
export declare const streamAnswerAPIStateMockWithoutAnyTab: StreamAnswerAPIState;
|
|
6
|
+
export declare const streamAnswerAPIStateMockWithStaticFiltersSelected: StreamAnswerAPIState;
|
|
7
|
+
export declare const streamAnswerAPIStateMockWithNonValidFilters: StreamAnswerAPIState;
|
|
8
|
+
export declare const streamAnswerAPIStateMockWithoutAnyFilters: StreamAnswerAPIState;
|
|
9
|
+
export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpression: StreamAnswerAPIState;
|
|
10
10
|
export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpressionWithEmptyCQ: {
|
|
11
11
|
advancedSearchQueries: {
|
|
12
12
|
cq: string;
|
|
@@ -26,9 +26,9 @@ export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpressionWi
|
|
|
26
26
|
};
|
|
27
27
|
searchHub: string;
|
|
28
28
|
pipeline: string;
|
|
29
|
-
answer:
|
|
30
|
-
getAnswer: import("@reduxjs/toolkit/query").QueryDefinition<Partial<import("../../search/search/search-request.js").SearchRequest>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, import("../
|
|
31
|
-
}, never, "answer"
|
|
29
|
+
answer: import("@reduxjs/toolkit/query").CombinedState<{
|
|
30
|
+
getAnswer: import("@reduxjs/toolkit/query").QueryDefinition<Partial<import("../../search/search/search-request.js").SearchRequest>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError, {} & import("@reduxjs/toolkit/query").RetryOptions, {}>, never, import("../generated-answer-stream.js").GeneratedAnswerStream, "answer">;
|
|
31
|
+
}, never, "answer">;
|
|
32
32
|
configuration: import("../../../features/configuration/configuration-state.js").ConfigurationState;
|
|
33
33
|
facetSet?: import("../../../features/facets/facet-set/facet-set-state.js").FacetSetState | undefined;
|
|
34
34
|
dateFacetSet?: import("../../../features/facets/range-facets/date-facet-set/date-facet-set-state.js").DateFacetSetState | undefined;
|
|
@@ -66,7 +66,7 @@ export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpressionWi
|
|
|
66
66
|
instantResults?: import("../../../features/instant-results/instant-results-state.js").InstantResultsState | undefined;
|
|
67
67
|
insightConfiguration?: import("../../../features/insight-configuration/insight-configuration-state.js").InsightConfigurationState | undefined;
|
|
68
68
|
};
|
|
69
|
-
export declare const streamAnswerAPIStateMockWithoutSearchAction:
|
|
69
|
+
export declare const streamAnswerAPIStateMockWithoutSearchAction: StreamAnswerAPIState;
|
|
70
70
|
export declare const expectedStreamAnswerAPIParam: {
|
|
71
71
|
q: string;
|
|
72
72
|
aq: string;
|
|
@@ -32,6 +32,18 @@ export interface Sort extends Controller {
|
|
|
32
32
|
* Verifies whether the specified sort criterion is the currently active one.
|
|
33
33
|
*
|
|
34
34
|
* @param criterion - The sort criterion to evaluate.
|
|
35
|
+
* Can be a single criterion or an array of criteria.
|
|
36
|
+
* The criteria in an array will be applied sequentially. For example, if there's a tie on the 1st criterion, the API uses the 2nd criterion to break the tie. However, this only works when combining:
|
|
37
|
+
* `SortByRelevancy` followed by one or more `SortByField` or `SortByDate` criteria.
|
|
38
|
+
* `SortByQRE` followed by one or more `SortByField` or `SortByDate` criteria.
|
|
39
|
+
* Two or more `SortByField` criteria.
|
|
40
|
+
* A single `SortByDate` criterion and one or more `SortByField` criteria in any order.
|
|
41
|
+
*
|
|
42
|
+
* Examples:
|
|
43
|
+
* * `SortByRelevancy`, `SortByField`
|
|
44
|
+
* * `SortByQRE`, `SortByField`
|
|
45
|
+
* * `SortByDate`, `SortByField`, `SortByField`
|
|
46
|
+
*
|
|
35
47
|
* @returns `true` if the specified sort criterion is the currently active one; `false` otherwise.
|
|
36
48
|
*/
|
|
37
49
|
isSortedBy(criterion: SortCriterion | SortCriterion[]): boolean;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { GeneratedAnswerCitation } from '../../controllers/generated-answer/headless-generated-answer.js';
|
|
2
2
|
import type { SearchAppState } from '../../state/search-app-state.js';
|
|
3
3
|
import type { GeneratedAnswerSection } from '../../state/state-sections.js';
|
|
4
|
-
export declare const generativeQuestionAnsweringIdSelector: (state: Partial<SearchAppState>) =>
|
|
5
|
-
answerAPIEnabled: boolean;
|
|
6
|
-
id: string | undefined;
|
|
7
|
-
};
|
|
4
|
+
export declare const generativeQuestionAnsweringIdSelector: (state: Partial<SearchAppState>) => string | undefined;
|
|
8
5
|
export declare const selectFieldsToIncludeInCitation: (state: Partial<GeneratedAnswerSection>) => string[] | undefined;
|
|
9
6
|
export declare const citationSourceSelector: ((state: Partial<GeneratedAnswerSection>, citationId: string) => GeneratedAnswerCitation | undefined) & {
|
|
10
7
|
clearCache: () => void;
|
|
@@ -24,7 +24,7 @@ export declare const buildSearchRequest: (state: StateNeededBySearchRequest, eve
|
|
|
24
24
|
facetOptions?: import("../../facet-options/facet-options.js").FacetOptions;
|
|
25
25
|
numberOfResults?: number;
|
|
26
26
|
firstResult?: number;
|
|
27
|
-
facets?: (import("../../facets/facet-set/interfaces/request.js").FacetRequest | import("../../facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../../facets/range-facets/
|
|
27
|
+
facets?: (import("../../facets/facet-set/interfaces/request.js").FacetRequest | import("../../facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../../facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest | import("../../facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest)[] | undefined;
|
|
28
28
|
cq?: string;
|
|
29
29
|
queryCorrection?: {
|
|
30
30
|
enabled?: boolean;
|
|
@@ -25,7 +25,7 @@ export declare const buildSearchRequest: (state: StateNeededBySearchRequest, nav
|
|
|
25
25
|
facetOptions?: import("../facet-options/facet-options.js").FacetOptions;
|
|
26
26
|
numberOfResults?: number;
|
|
27
27
|
firstResult?: number;
|
|
28
|
-
facets?: (import("../facets/facet-set/interfaces/request.js").FacetRequest | import("../facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../facets/range-facets/
|
|
28
|
+
facets?: (import("../facets/facet-set/interfaces/request.js").FacetRequest | import("../facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest | import("../facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest)[] | undefined;
|
|
29
29
|
cq?: string;
|
|
30
30
|
queryCorrection?: {
|
|
31
31
|
enabled?: boolean;
|
|
@@ -18,34 +18,9 @@ import type { CommerceEngineDefinition } from '../types/engine.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* const
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* const staticState = await listingEngineDefinition.fetchStaticState({
|
|
25
|
-
* navigatorContext: {
|
|
26
|
-
* forwardedFor: req.ip,
|
|
27
|
-
* referrer: req.headers.referer || null,
|
|
28
|
-
* userAgent: req.headers['user-agent'] || null,
|
|
29
|
-
* clientId: 'unique-session-id'
|
|
30
|
-
* }
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Framework examples:
|
|
34
|
-
* // Express.js
|
|
35
|
-
* app.get('/api/listing', async (req, res) => {
|
|
36
|
-
* const state = await listingEngineDefinition.fetchStaticState({
|
|
37
|
-
* navigatorContext: {
|
|
38
|
-
* forwardedFor: req.ip,
|
|
39
|
-
* referrer: req.headers.referer || null,
|
|
40
|
-
* userAgent: req.headers['user-agent'] || null,
|
|
41
|
-
* clientId: req.sessionID
|
|
42
|
-
* }
|
|
43
|
-
* });
|
|
44
|
-
* res.json(state);
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* type SearchStaticState = InferStaticState<typeof listingEngineDefinition>;
|
|
48
|
-
* type SearchHydratedState = InferHydratedState<typeof listingEngineDefinition>;
|
|
21
|
+
* const engineDefinition = defineCommerceEngine(engineConfig);
|
|
22
|
+
* type SearchStaticState = InferStaticState<typeof engineDefinition>;
|
|
23
|
+
* type SearchHydratedState = InferHydratedState<typeof engineDefinition>;
|
|
49
24
|
* ```
|
|
50
25
|
*
|
|
51
26
|
* @group Engine
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
3
|
import type { EngineConfiguration } from '../../../app/engine-configuration.js';
|
|
4
|
+
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
4
5
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
5
6
|
import type { ControllerStaticStateMap } from '../../common/types/controllers.js';
|
|
6
7
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
@@ -32,6 +33,13 @@ export interface CommerceEngineDefinition<TControllers extends ControllerDefinit
|
|
|
32
33
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
33
34
|
*/
|
|
34
35
|
hydrateStaticState: HydrateStaticState<InferControllersMapFromDefinition<TControllers, TSolutionType>, UnknownAction, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the navigator context provider.
|
|
38
|
+
* This provider is essential for retrieving navigation-related data such as referrer, userAgent, location, and clientId, which are crucial for handling both server-side and client-side API requests effectively.
|
|
39
|
+
*
|
|
40
|
+
* Note: The implementation specifics of the navigator context provider depend on the Node.js framework being utilized. It is the developer's responsibility to appropriately define and implement the navigator context provider to ensure accurate navigation context is available throughout the application. If the user fails to provide a navigator context provider, a warning will be logged either on the server or the browser console.
|
|
41
|
+
*/
|
|
42
|
+
setNavigatorContextProvider: (navigatorContextProvider: NavigatorContextProvider) => void;
|
|
35
43
|
/**
|
|
36
44
|
* Returns the access token.
|
|
37
45
|
*/
|
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
-
import type { NavigatorContext } from '../../../app/navigator-context-provider.js';
|
|
3
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
4
3
|
import type { ControllerStaticStateMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
5
4
|
import type { SolutionType } from './controller-constants.js';
|
|
6
5
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
7
6
|
import type { EngineStaticState } from './engine.js';
|
|
8
|
-
export
|
|
9
|
-
/**
|
|
10
|
-
* The navigator context for this request.
|
|
11
|
-
*
|
|
12
|
-
* Used to pass required client information when making server-side requests.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // In your server route handler
|
|
17
|
-
* const staticState = await listingEngineDefinition.fetchStaticState({
|
|
18
|
-
* navigatorContext: {
|
|
19
|
-
* forwardedFor: req.ip,
|
|
20
|
-
* referrer: req.headers.referer || null,
|
|
21
|
-
* userAgent: req.headers['user-agent'] || null,
|
|
22
|
-
* clientId: req.sessionID || 'anonymous'
|
|
23
|
-
* }
|
|
24
|
-
* });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
navigatorContext?: NavigatorContext;
|
|
28
|
-
}
|
|
7
|
+
export type FetchStaticStateOptions = {};
|
|
29
8
|
/**
|
|
30
9
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
31
10
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AnyAction, UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { CoreEngine, CoreEngineNext } from '../../../app/engine.js';
|
|
3
3
|
import type { EngineConfiguration } from '../../../app/engine-configuration.js';
|
|
4
|
+
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
4
5
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
5
6
|
import type { Build } from './build.js';
|
|
6
7
|
import type { ControllerDefinitionsMap, ControllerStaticStateMap, ControllersMap, ControllersPropsMap } from './controllers.js';
|
|
@@ -26,6 +27,13 @@ export interface EngineDefinition<TEngine extends CoreEngine | CoreEngineNext, T
|
|
|
26
27
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
27
28
|
*/
|
|
28
29
|
hydrateStaticState: HydrateStaticState<TEngine, InferControllersMapFromDefinition<TControllers>, AnyAction, InferControllerPropsMapFromDefinitions<TControllers>>;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the navigator context provider.
|
|
32
|
+
* This provider is essential for retrieving navigation-related data such as referrer, userAgent, location, and clientId, which are crucial for handling both server-side and client-side API requests effectively.
|
|
33
|
+
*
|
|
34
|
+
* Note: The implementation specifics of the navigator context provider depend on the Node.js framework being utilized. It is the developer's responsibility to appropriately define and implement the navigator context provider to ensure accurate navigation context is available throughout the application. If the user fails to provide a navigator context provider, a warning will be logged either on the server or the browser console.
|
|
35
|
+
*/
|
|
36
|
+
setNavigatorContextProvider: (navigatorContextProvider: NavigatorContextProvider) => void;
|
|
29
37
|
}
|
|
30
38
|
export interface EngineDefinitionBuildResult<TEngine extends CoreEngine | CoreEngineNext, TControllers extends ControllersMap> {
|
|
31
39
|
engine: TEngine;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
-
import type { NavigatorContext } from '../../../app/navigator-context-provider.js';
|
|
3
2
|
import type { ControllerStaticStateMap, ControllersPropsMap } from './controllers.js';
|
|
4
3
|
import type { EngineDefinitionControllersPropsOption, EngineStaticState } from './engine.js';
|
|
5
4
|
import type { OptionsTuple } from './utilities.js';
|
|
6
|
-
type FetchStaticStateOptions = {
|
|
7
|
-
navigatorContext?: NavigatorContext;
|
|
8
|
-
};
|
|
5
|
+
type FetchStaticStateOptions = {};
|
|
9
6
|
/**
|
|
10
7
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
11
8
|
*
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
+
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
1
2
|
import { type SearchEngine, type SearchEngineOptions } from '../../../app/search-engine/search-engine.js';
|
|
2
3
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
4
|
import type { LegacySearchAction } from '../../../features/analytics/analytics-utils.js';
|
|
4
5
|
import type { ControllerDefinitionsMap } from '../../common/types/controllers.js';
|
|
5
6
|
import type { EngineDefinition, EngineDefinitionOptions } from '../../common/types/engine.js';
|
|
7
|
+
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitions } from '../../common/types/inference.js';
|
|
6
8
|
/**
|
|
7
9
|
* The SSR search engine.
|
|
10
|
+
*
|
|
11
|
+
* @group Engine
|
|
8
12
|
*/
|
|
9
13
|
export interface SSRSearchEngine extends SearchEngine {
|
|
14
|
+
/**
|
|
15
|
+
* Waits for the search to be completed and returns a promise that resolves to a `SearchCompletedAction`.
|
|
16
|
+
*/
|
|
10
17
|
waitForSearchCompletedAction(): Promise<SearchCompletedAction>;
|
|
11
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The options to create a search engine definition in SSR.
|
|
21
|
+
*
|
|
22
|
+
* @group Engine
|
|
23
|
+
*/
|
|
12
24
|
export type SearchEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<SSRSearchEngine, Controller>> = EngineDefinitionOptions<SearchEngineOptions, TControllers>;
|
|
13
25
|
export type SearchCompletedAction = ReturnType<LegacySearchAction['fulfilled' | 'rejected']>;
|
|
14
26
|
export type SearchEngineDefinition<TControllers extends ControllerDefinitionsMap<SSRSearchEngine, Controller>> = EngineDefinition<SSRSearchEngine, TControllers>;
|
|
15
27
|
/**
|
|
16
|
-
* Initializes a Search engine definition in SSR with
|
|
28
|
+
* Initializes a Search engine definition in SSR with given controllers definitions and search engine config.
|
|
17
29
|
*
|
|
18
30
|
* @param options - The search engine definition
|
|
19
|
-
* @returns
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* const searchEngine = defineSearchEngine(config);
|
|
24
|
-
*
|
|
25
|
-
* // Pass navigator context directly to fetchStaticState
|
|
26
|
-
* const staticState = await searchEngine.fetchStaticState({
|
|
27
|
-
* navigatorContext: {
|
|
28
|
-
* forwardedFor: req.ip,
|
|
29
|
-
* referrer: req.headers.referer || null,
|
|
30
|
-
* userAgent: req.headers['user-agent'] || null,
|
|
31
|
-
* clientId: 'abc123'
|
|
32
|
-
* }
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
31
|
+
* @returns Three utility functions to fetch the initial state of the engine in SSR, hydrate the state in CSR,
|
|
32
|
+
* and a build function that can be used for edge cases requiring more control.
|
|
35
33
|
*
|
|
36
34
|
* @group Engine
|
|
37
35
|
*/
|
|
38
|
-
export declare function defineSearchEngine<TControllerDefinitions extends ControllerDefinitionsMap<SearchEngine, Controller>>(options: SearchEngineDefinitionOptions<TControllerDefinitions>):
|
|
36
|
+
export declare function defineSearchEngine<TControllerDefinitions extends ControllerDefinitionsMap<SearchEngine, Controller>>(options: SearchEngineDefinitionOptions<TControllerDefinitions>): {
|
|
37
|
+
fetchStaticState: import("../../common/types/fetch-static-state.js").FetchStaticState<import("redux").AnyAction, InferControllerStaticStateMapFromDefinitions<TControllerDefinitions>, InferControllerPropsMapFromDefinitions<TControllerDefinitions>>;
|
|
38
|
+
hydrateStaticState: import("../../common/types/hydrate-static-state.js").HydrateStaticState<SSRSearchEngine, import("../../common/types/inference.js").InferControllersMapFromDefinition<TControllerDefinitions>, import("redux").AnyAction, InferControllerPropsMapFromDefinitions<TControllerDefinitions>>;
|
|
39
|
+
setNavigatorContextProvider: (navigatorContextProvider: NavigatorContextProvider) => void;
|
|
40
|
+
};
|
package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { BaseQueryFn, CombinedState, FetchArgs, FetchBaseQueryError, QueryDefinition, RetryOptions } from '@reduxjs/toolkit/query';
|
|
2
|
+
import type { GeneratedAnswerStream } from '../api/knowledge/generated-answer-stream.js';
|
|
3
|
+
import type { SearchRequest } from '../api/search/search/search-request.js';
|
|
1
4
|
import type { StateWithHistory } from '../app/undoable.js';
|
|
2
5
|
import type { AdvancedSearchQueriesState } from '../features/advanced-search-queries/advanced-search-queries-state.js';
|
|
3
6
|
import type { AttachedResultsState } from '../features/attached-results/attached-results-state.js';
|
|
@@ -438,3 +441,8 @@ export interface InsightUserActionsSection {
|
|
|
438
441
|
export interface ManualRangeSection {
|
|
439
442
|
manualNumericFacetSet: ManualNumericFacetSetState;
|
|
440
443
|
}
|
|
444
|
+
export interface GetAnswerQuerySection {
|
|
445
|
+
answer: CombinedState<{
|
|
446
|
+
getAnswer: QueryDefinition<Partial<SearchRequest>, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {} & RetryOptions, {}>, never, GeneratedAnswerStream, 'answer'>;
|
|
447
|
+
}, never, 'answer'>;
|
|
448
|
+
}
|
package/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare function sortFacets<T extends {
|
|
|
9
9
|
facetId: string;
|
|
10
10
|
}>(facets: T[], sortOrder: string[]): T[];
|
|
11
11
|
export declare const sortCriteriaMap: Record<string, SortCriteria>;
|
|
12
|
-
export declare function getFacets(state: StateNeededBySearchRequest): (import("../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../features/facets/range-facets/
|
|
12
|
+
export declare function getFacets(state: StateNeededBySearchRequest): (import("../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest | import("../features/facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest)[];
|
|
13
13
|
export {};
|