@coveo/quantic 3.29.4-pre.da2dda7f86 → 3.29.4-pre.e09e4720ea
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 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/search-analytics.d.ts +3 -5
- 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.d.ts +28 -8
- 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/features/generated-answer/generated-answer-selectors.d.ts +4 -1
- 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 +28 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +0 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +22 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/navigator-context-utils.d.ts +16 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/navigator-context-utils.spec.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/engine.d.ts +0 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/fetch-static-state.d.ts +4 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +18 -20
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next.index.d.ts +11 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts +0 -8
- 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 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +7 -7
- package/package.json +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/generated-answer-stream.d.ts +0 -15
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api-state.d.ts +0 -6
|
@@ -90,15 +90,13 @@ 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 {
|
|
94
94
|
logger: Logger;
|
|
95
95
|
analyticsClientMiddleware?: AnalyticsClientSendEventHook;
|
|
96
96
|
preprocessRequest?: PreprocessRequest;
|
|
97
97
|
provider?: SearchPageClientProvider;
|
|
98
|
-
getState():
|
|
98
|
+
getState(): StateNeededBySearchAnalyticsProvider;
|
|
99
99
|
}
|
|
100
|
-
export declare const configureLegacyAnalytics:
|
|
101
|
-
provider: SearchPageClientProvider;
|
|
102
|
-
}) => CoveoSearchPageClient;
|
|
100
|
+
export declare const configureLegacyAnalytics: ({ logger, getState, analyticsClientMiddleware, preprocessRequest, provider, }: LegacyConfigureAnalyticsOptions) => CoveoSearchPageClient;
|
|
103
101
|
export declare const getPageID: () => string;
|
|
104
102
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NavigatorContext } from '../../app/navigator-context-provider.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type StateNeededByAnswerAPI } from './stream-answer-api.js';
|
|
3
3
|
export declare const triggerSearchRequest: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
4
|
-
state:
|
|
4
|
+
state: StateNeededByAnswerAPI;
|
|
5
5
|
navigatorContext: NavigatorContext;
|
|
6
6
|
}, {
|
|
7
7
|
state?: unknown;
|
|
@@ -1,10 +1,30 @@
|
|
|
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';
|
|
3
6
|
import type { EventSourceMessage } from '../../utils/fetch-event-source/parse.js';
|
|
7
|
+
import type { GeneratedAnswerCitation } from '../generated-answer/generated-answer-event-payload.js';
|
|
4
8
|
import type { SearchRequest } from '../search/search/search-request.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
export type StateNeededByAnswerAPI = {
|
|
10
|
+
searchHub: string;
|
|
11
|
+
pipeline: string;
|
|
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;
|
|
8
28
|
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, {}>, {
|
|
9
29
|
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">;
|
|
10
30
|
}, "answer", never, typeof import("@reduxjs/toolkit/query").coreModuleName>;
|
|
@@ -53,7 +73,7 @@ export declare const selectAnswerTriggerParams: ((state: any, ...params: any[])
|
|
|
53
73
|
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
54
74
|
memoize: typeof import("reselect").weakMapMemoize;
|
|
55
75
|
};
|
|
56
|
-
export declare const constructAnswerQueryParams: (state:
|
|
76
|
+
export declare const constructAnswerQueryParams: (state: StateNeededByAnswerAPI, usage: "fetch" | "select", navigatorContext: NavigatorContext) => {
|
|
57
77
|
analytics?: {
|
|
58
78
|
actionCause?: string;
|
|
59
79
|
customData?: object;
|
|
@@ -80,12 +100,12 @@ export declare const constructAnswerQueryParams: (state: StreamAnswerAPIState, u
|
|
|
80
100
|
} | undefined;
|
|
81
101
|
enableDidYouMean?: boolean | undefined;
|
|
82
102
|
fieldsToInclude?: string[] | undefined;
|
|
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/
|
|
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/numeric-facet-set/interfaces/request.js").NumericFacetRequest | import("../../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest)[] | undefined;
|
|
84
104
|
pipeline?: string | undefined;
|
|
85
105
|
searchHub?: string | undefined;
|
|
86
106
|
pipelineRuleParameters: {
|
|
87
107
|
mlGenerativeQuestionAnswering: {
|
|
88
|
-
responseFormat: import("../../
|
|
108
|
+
responseFormat: import("../../features/generated-answer/generated-response-format.js").GeneratedResponseFormat;
|
|
89
109
|
citationsFieldToInclude: string[];
|
|
90
110
|
};
|
|
91
111
|
};
|
|
@@ -97,8 +117,8 @@ export declare const constructAnswerQueryParams: (state: StreamAnswerAPIState, u
|
|
|
97
117
|
aq?: string | undefined;
|
|
98
118
|
q: string | undefined;
|
|
99
119
|
};
|
|
100
|
-
export declare const fetchAnswer: (state:
|
|
101
|
-
export declare const selectAnswer: (state:
|
|
120
|
+
export declare const fetchAnswer: (state: StateNeededByAnswerAPI, 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>;
|
|
121
|
+
export declare const selectAnswer: (state: StateNeededByAnswerAPI, navigatorContext?: NavigatorContext) => ({
|
|
102
122
|
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
103
123
|
originalArgs?: undefined | undefined;
|
|
104
124
|
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 { StateNeededByAnswerAPI } from '../stream-answer-api.js';
|
|
3
|
+
export declare const streamAnswerAPIStateMock: StateNeededByAnswerAPI;
|
|
4
|
+
export declare const streamAnswerAPIStateMockWithATabWithAnExpression: StateNeededByAnswerAPI;
|
|
5
|
+
export declare const streamAnswerAPIStateMockWithoutAnyTab: StateNeededByAnswerAPI;
|
|
6
|
+
export declare const streamAnswerAPIStateMockWithStaticFiltersSelected: StateNeededByAnswerAPI;
|
|
7
|
+
export declare const streamAnswerAPIStateMockWithNonValidFilters: StateNeededByAnswerAPI;
|
|
8
|
+
export declare const streamAnswerAPIStateMockWithoutAnyFilters: StateNeededByAnswerAPI;
|
|
9
|
+
export declare const streamAnswerAPIStateMockWithStaticFiltersAndTabExpression: StateNeededByAnswerAPI;
|
|
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: 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("../
|
|
31
|
-
}, never, "answer"
|
|
29
|
+
answer: ReturnType<import("redux").Reducer<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("../stream-answer-api.js").GeneratedAnswerStream, "answer">;
|
|
31
|
+
}, never, "answer">, import("redux").UnknownAction>>;
|
|
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: StateNeededByAnswerAPI;
|
|
70
70
|
export declare const expectedStreamAnswerAPIParam: {
|
|
71
71
|
q: string;
|
|
72
72
|
aq: string;
|
|
@@ -1,7 +1,10 @@
|
|
|
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>) =>
|
|
4
|
+
export declare const generativeQuestionAnsweringIdSelector: (state: Partial<SearchAppState>) => {
|
|
5
|
+
answerAPIEnabled: boolean;
|
|
6
|
+
id: string | undefined;
|
|
7
|
+
};
|
|
5
8
|
export declare const selectFieldsToIncludeInCitation: (state: Partial<GeneratedAnswerSection>) => string[] | undefined;
|
|
6
9
|
export declare const citationSourceSelector: ((state: Partial<GeneratedAnswerSection>, citationId: string) => GeneratedAnswerCitation | undefined) & {
|
|
7
10
|
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/numeric-facet-set/interfaces/request.js").NumericFacetRequest | import("../../facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest)[] | 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/numeric-facet-set/interfaces/request.js").NumericFacetRequest | import("../facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest)[] | undefined;
|
|
29
29
|
cq?: string;
|
|
30
30
|
queryCorrection?: {
|
|
31
31
|
enabled?: boolean;
|
|
@@ -18,9 +18,34 @@ import type { CommerceEngineDefinition } from '../types/engine.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* const
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* const { listingEngineDefinition } = defineCommerceEngine(engineConfig);
|
|
22
|
+
*
|
|
23
|
+
* // Pass navigator context directly to fetchStaticState
|
|
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>;
|
|
24
49
|
* ```
|
|
25
50
|
*
|
|
26
51
|
* @group Engine
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
6
5
|
import type { ControllerStaticStateMap } from '../../common/types/controllers.js';
|
|
7
6
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
@@ -33,13 +32,6 @@ export interface CommerceEngineDefinition<TControllers extends ControllerDefinit
|
|
|
33
32
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
34
33
|
*/
|
|
35
34
|
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;
|
|
43
35
|
/**
|
|
44
36
|
* Returns the access token.
|
|
45
37
|
*/
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import type { NavigatorContext } from '../../../app/navigator-context-provider.js';
|
|
2
3
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
4
|
import type { ControllerStaticStateMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
5
|
import type { SolutionType } from './controller-constants.js';
|
|
5
6
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
6
7
|
import type { EngineStaticState } from './engine.js';
|
|
7
|
-
export
|
|
8
|
+
export interface FetchStaticStateOptions {
|
|
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
|
+
}
|
|
8
29
|
/**
|
|
9
30
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
10
31
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LoggerOptions } from '../../app/logger.js';
|
|
2
|
+
import type { NavigatorContext } from '../../app/navigator-context-provider.js';
|
|
3
|
+
/**
|
|
4
|
+
* Processes fetchStaticState parameters and returns enhanced engine options with navigator context.
|
|
5
|
+
* This is the single function that handles all navigator context logic for both commerce and search engines.
|
|
6
|
+
*/
|
|
7
|
+
export declare function processNavigatorContext<TOptions extends {
|
|
8
|
+
configuration: object;
|
|
9
|
+
loggerOptions?: LoggerOptions;
|
|
10
|
+
}>(params: unknown[], baseOptions: TOptions): {
|
|
11
|
+
engineOptions: TOptions;
|
|
12
|
+
callOptions?: {
|
|
13
|
+
navigatorContext?: NavigatorContext;
|
|
14
|
+
controllers?: unknown;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
6
5
|
import type { Build } from './build.js';
|
|
7
6
|
import type { ControllerDefinitionsMap, ControllerStaticStateMap, ControllersMap, ControllersPropsMap } from './controllers.js';
|
|
@@ -27,13 +26,6 @@ export interface EngineDefinition<TEngine extends CoreEngine | CoreEngineNext, T
|
|
|
27
26
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
28
27
|
*/
|
|
29
28
|
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;
|
|
37
29
|
}
|
|
38
30
|
export interface EngineDefinitionBuildResult<TEngine extends CoreEngine | CoreEngineNext, TControllers extends ControllersMap> {
|
|
39
31
|
engine: TEngine;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import type { NavigatorContext } from '../../../app/navigator-context-provider.js';
|
|
2
3
|
import type { ControllerStaticStateMap, ControllersPropsMap } from './controllers.js';
|
|
3
4
|
import type { EngineDefinitionControllersPropsOption, EngineStaticState } from './engine.js';
|
|
4
5
|
import type { OptionsTuple } from './utilities.js';
|
|
5
|
-
type FetchStaticStateOptions = {
|
|
6
|
+
type FetchStaticStateOptions = {
|
|
7
|
+
navigatorContext?: NavigatorContext;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
8
11
|
*
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
2
1
|
import { type SearchEngine, type SearchEngineOptions } from '../../../app/search-engine/search-engine.js';
|
|
3
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
4
3
|
import type { LegacySearchAction } from '../../../features/analytics/analytics-utils.js';
|
|
5
4
|
import type { ControllerDefinitionsMap } from '../../common/types/controllers.js';
|
|
6
5
|
import type { EngineDefinition, EngineDefinitionOptions } from '../../common/types/engine.js';
|
|
7
|
-
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitions } from '../../common/types/inference.js';
|
|
8
6
|
/**
|
|
9
7
|
* The SSR search engine.
|
|
10
|
-
*
|
|
11
|
-
* @group Engine
|
|
12
8
|
*/
|
|
13
9
|
export interface SSRSearchEngine extends SearchEngine {
|
|
14
|
-
/**
|
|
15
|
-
* Waits for the search to be completed and returns a promise that resolves to a `SearchCompletedAction`.
|
|
16
|
-
*/
|
|
17
10
|
waitForSearchCompletedAction(): Promise<SearchCompletedAction>;
|
|
18
11
|
}
|
|
19
|
-
/**
|
|
20
|
-
* The options to create a search engine definition in SSR.
|
|
21
|
-
*
|
|
22
|
-
* @group Engine
|
|
23
|
-
*/
|
|
24
12
|
export type SearchEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<SSRSearchEngine, Controller>> = EngineDefinitionOptions<SearchEngineOptions, TControllers>;
|
|
25
13
|
export type SearchCompletedAction = ReturnType<LegacySearchAction['fulfilled' | 'rejected']>;
|
|
26
14
|
export type SearchEngineDefinition<TControllers extends ControllerDefinitionsMap<SSRSearchEngine, Controller>> = EngineDefinition<SSRSearchEngine, TControllers>;
|
|
27
15
|
/**
|
|
28
|
-
* Initializes a Search engine definition in SSR with
|
|
16
|
+
* Initializes a Search engine definition in SSR with per-call navigator context support.
|
|
29
17
|
*
|
|
30
18
|
* @param options - The search engine definition
|
|
31
|
-
* @returns
|
|
32
|
-
*
|
|
19
|
+
* @returns Engine definition with support for per-call navigator context.
|
|
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
|
+
* ```
|
|
33
35
|
*
|
|
34
36
|
* @group Engine
|
|
35
37
|
*/
|
|
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
|
-
};
|
|
38
|
+
export declare function defineSearchEngine<TControllerDefinitions extends ControllerDefinitionsMap<SearchEngine, Controller>>(options: SearchEngineDefinitionOptions<TControllerDefinitions>): EngineDefinition<SSRSearchEngine, TControllerDefinitions>;
|
package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next.index.d.ts
CHANGED
|
@@ -36,11 +36,17 @@
|
|
|
36
36
|
* export type SearchStaticState = InferStaticState<typeof engineDefinition>;
|
|
37
37
|
* export type SearchHydratedState = InferHydratedState<typeof engineDefinition>;
|
|
38
38
|
*
|
|
39
|
-
* export const {
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
39
|
+
* export const {fetchStaticState, hydrateStaticState} = engineDefinition;
|
|
40
|
+
|
|
41
|
+
* // Pass navigator context directly per call (server-side)
|
|
42
|
+
* await fetchStaticState({
|
|
43
|
+
* navigatorContext: {
|
|
44
|
+
* forwardedFor: req.ip,
|
|
45
|
+
* referrer: req.headers.referer || null,
|
|
46
|
+
* userAgent: req.headers['user-agent'] || null,
|
|
47
|
+
* clientId: req.sessionID || 'anonymous',
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
44
50
|
|
|
45
51
|
* ```
|
|
46
52
|
* @module SSR Search
|
package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
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';
|
|
4
1
|
import type { StateWithHistory } from '../app/undoable.js';
|
|
5
2
|
import type { AdvancedSearchQueriesState } from '../features/advanced-search-queries/advanced-search-queries-state.js';
|
|
6
3
|
import type { AttachedResultsState } from '../features/attached-results/attached-results-state.js';
|
|
@@ -441,8 +438,3 @@ export interface InsightUserActionsSection {
|
|
|
441
438
|
export interface ManualRangeSection {
|
|
442
439
|
manualNumericFacetSet: ManualNumericFacetSetState;
|
|
443
440
|
}
|
|
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/numeric-facet-set/interfaces/request.js").NumericFacetRequest | import("../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest)[];
|
|
13
13
|
export {};
|