@coveo/headless 3.35.1 → 3.35.2
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/dist/cjs/case-assist/headless.cjs +1 -1
- package/dist/cjs/commerce/headless.cjs +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
- package/dist/cjs/ssr-next/headless.cjs +1 -1
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +75 -0
- package/dist/definitions/ssr-next/commerce/types/engine.d.ts +52 -2
- package/dist/definitions/ssr-next/common/types/engine.d.ts +53 -0
- package/dist/esm/utils/version.js +1 -1
- package/dist/quantic/case-assist/headless.js +1 -1
- package/dist/quantic/commerce/headless.js +1 -1
- package/dist/quantic/headless.js +1 -1
- package/dist/quantic/insight/headless.js +1 -1
- package/dist/quantic/recommendation/headless.js +1 -1
- package/package.json +3 -3
|
@@ -824,7 +824,7 @@ var import_bueno5 = require("@coveo/bueno");
|
|
|
824
824
|
var import_toolkit7 = require("@reduxjs/toolkit");
|
|
825
825
|
|
|
826
826
|
// src/utils/version.ts
|
|
827
|
-
var VERSION = "3.35.
|
|
827
|
+
var VERSION = "3.35.2";
|
|
828
828
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
829
829
|
|
|
830
830
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -1116,7 +1116,7 @@ var import_bueno6 = require("@coveo/bueno");
|
|
|
1116
1116
|
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
1117
1117
|
|
|
1118
1118
|
// src/utils/version.ts
|
|
1119
|
-
var VERSION = "3.35.
|
|
1119
|
+
var VERSION = "3.35.2";
|
|
1120
1120
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1121
1121
|
|
|
1122
1122
|
// src/features/configuration/configuration-actions.ts
|
package/dist/cjs/headless.cjs
CHANGED
|
@@ -1403,7 +1403,7 @@ function isBrowser2() {
|
|
|
1403
1403
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1404
1404
|
|
|
1405
1405
|
// src/utils/version.ts
|
|
1406
|
-
var VERSION = "3.35.
|
|
1406
|
+
var VERSION = "3.35.2";
|
|
1407
1407
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1408
1408
|
|
|
1409
1409
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -1311,7 +1311,7 @@ function isBrowser2() {
|
|
|
1311
1311
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1312
1312
|
|
|
1313
1313
|
// src/utils/version.ts
|
|
1314
|
-
var VERSION = "3.35.
|
|
1314
|
+
var VERSION = "3.35.2";
|
|
1315
1315
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1316
1316
|
|
|
1317
1317
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -905,7 +905,7 @@ var validateObject = (engine, schema, obj, validationMessage, errorMessage) => {
|
|
|
905
905
|
};
|
|
906
906
|
|
|
907
907
|
// src/utils/version.ts
|
|
908
|
-
var VERSION = "3.35.
|
|
908
|
+
var VERSION = "3.35.2";
|
|
909
909
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
910
910
|
|
|
911
911
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -1335,7 +1335,7 @@ function isBrowser2() {
|
|
|
1335
1335
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1336
1336
|
|
|
1337
1337
|
// src/utils/version.ts
|
|
1338
|
-
var VERSION = "3.35.
|
|
1338
|
+
var VERSION = "3.35.2";
|
|
1339
1339
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1340
1340
|
|
|
1341
1341
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -468,7 +468,7 @@ var import_bueno8 = require("@coveo/bueno");
|
|
|
468
468
|
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
469
469
|
|
|
470
470
|
// src/utils/version.ts
|
|
471
|
-
var VERSION = "3.35.
|
|
471
|
+
var VERSION = "3.35.2";
|
|
472
472
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
473
473
|
|
|
474
474
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -467,7 +467,7 @@ var import_bueno8 = require("@coveo/bueno");
|
|
|
467
467
|
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
468
468
|
|
|
469
469
|
// src/utils/version.ts
|
|
470
|
-
var VERSION = "3.35.
|
|
470
|
+
var VERSION = "3.35.2";
|
|
471
471
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
472
472
|
|
|
473
473
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -1335,7 +1335,7 @@ function isBrowser2() {
|
|
|
1335
1335
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1336
1336
|
|
|
1337
1337
|
// src/utils/version.ts
|
|
1338
|
-
var VERSION = "3.35.
|
|
1338
|
+
var VERSION = "3.35.2";
|
|
1339
1339
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1340
1340
|
|
|
1341
1341
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -75,9 +75,84 @@ export interface ListingBuildConfig extends CommonBuildConfig {
|
|
|
75
75
|
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
76
76
|
}
|
|
77
77
|
export interface CommonBuildConfig {
|
|
78
|
+
/**
|
|
79
|
+
* The `NavigatorContext` interface represents the context of the browser client.
|
|
80
|
+
* See {@link NavigatorContext}
|
|
81
|
+
*/
|
|
78
82
|
navigatorContext: NavigatorContext;
|
|
83
|
+
/**
|
|
84
|
+
* The initial context options passed to the engine when fetching the static state.
|
|
85
|
+
*
|
|
86
|
+
* This property is used to configure the commerce context (e.g., currency, language, country)
|
|
87
|
+
* when calling `fetchStaticState()`.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* To access the context after engine creation, use the context controller.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Setting context during static state fetch
|
|
95
|
+
* const staticState = await engineDefinition.fetchStaticState({
|
|
96
|
+
* context: { currency: 'USD', language: 'en', country: 'US' },
|
|
97
|
+
* // ...other config
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // Reading context from the static state
|
|
101
|
+
* const {context} = staticState.controllers;
|
|
102
|
+
* console.log(context.state.currency); // 'USD'
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
79
105
|
context: ContextOptions;
|
|
106
|
+
/**
|
|
107
|
+
* The initial search parameters to apply when fetching the static state.
|
|
108
|
+
*
|
|
109
|
+
* This property allows you to set initial search parameters (filters, facets, query, etc.)
|
|
110
|
+
* that will be applied during the server-side search execution.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* To access search parameters after engine creation, use the parameter manager controller.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Setting search parameters during static state fetch
|
|
118
|
+
* const staticState = await engineDefinition.fetchStaticState({
|
|
119
|
+
* searchParams: {
|
|
120
|
+
* q: 'shoes',
|
|
121
|
+
* },
|
|
122
|
+
* // ...other config
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* // Reading search parameters from the static state
|
|
126
|
+
* const {parameterManager} = staticState.controllers;
|
|
127
|
+
* console.log(parameterManager.state.parameters.q); // 'shoes'
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
80
130
|
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
131
|
+
/**
|
|
132
|
+
* The initial cart state to apply when fetching the static state.
|
|
133
|
+
*
|
|
134
|
+
* This property allows you to set an initial cart state that will be used during
|
|
135
|
+
* server-side rendering.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* To access cart state after engine creation, use the cart controller.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Setting cart state during static state fetch
|
|
143
|
+
* const staticState = await engineDefinition.fetchStaticState({
|
|
144
|
+
* cart: {
|
|
145
|
+
* // This is a simplified example. The actual item structure may require additional properties.
|
|
146
|
+
* items: [{ productId: 'abc123', quantity: 1 }]
|
|
147
|
+
* },
|
|
148
|
+
* // ...other config
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* // Reading cart state from the static state
|
|
152
|
+
* const {cart} = staticState.controllers;
|
|
153
|
+
* console.log(cart.state.items.length); // 1
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
81
156
|
cart?: CartInitialState;
|
|
82
157
|
}
|
|
83
158
|
export type BuildConfig<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = TSolutionType extends SolutionType.search ? SearchBuildConfig : TSolutionType extends SolutionType.listing ? ListingBuildConfig : TSolutionType extends SolutionType.recommendation ? RecommendationBuildConfig<TControllers> : TSolutionType extends SolutionType.standalone ? CommonBuildConfig : never;
|
|
@@ -29,11 +29,61 @@ export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefin
|
|
|
29
29
|
};
|
|
30
30
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> {
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Executes a commerce search/listing/recommendation request on the server side and returns the static state.
|
|
33
|
+
*
|
|
34
|
+
* This method performs the initial commerce request based on the solution type, captures the response,
|
|
35
|
+
* and returns a serializable state snapshot that can be transferred to the client for hydration.
|
|
36
|
+
*
|
|
37
|
+
* The returned static state includes controller states (facets, products, pagination, etc.)
|
|
38
|
+
*
|
|
39
|
+
* @param params - A configuration object containing navigation context, search parameters,
|
|
40
|
+
* cart state, and controller-specific props
|
|
41
|
+
* @returns A Promise that resolves to the static state containing controller states
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // For a search page
|
|
46
|
+
* const staticState = await searchEngineDefinition.fetchStaticState({
|
|
47
|
+
* navigatorContext: { ... },
|
|
48
|
+
* context: { ... },
|
|
49
|
+
* searchParams: { q: 'running shoes' }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // For recommendations
|
|
53
|
+
* const staticState = await recommendationEngineDefinition.fetchStaticState({
|
|
54
|
+
* navigatorContext: { ... },
|
|
55
|
+
* context: { ... },
|
|
56
|
+
* recommendations: ['popularProducts'],
|
|
57
|
+
* productId: 'abc123'
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
33
60
|
*/
|
|
34
61
|
fetchStaticState: FetchStaticState<UnknownAction, InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
35
62
|
/**
|
|
36
|
-
*
|
|
63
|
+
* Creates a commerce engine on the client side from the server-side static state.
|
|
64
|
+
*
|
|
65
|
+
* This method is used for client-side hydration in SSR scenarios. It takes the static state
|
|
66
|
+
* generated by `fetchStaticState()` on the server and reconstructs a live commerce engine
|
|
67
|
+
* with all controllers in the exact same state as they were on the server.
|
|
68
|
+
*
|
|
69
|
+
* The hydration process:
|
|
70
|
+
* - Recreates the engine with the same configuration
|
|
71
|
+
* - Restores all controller states from the static state
|
|
72
|
+
* - Replays search/listing/recommendation actions to synchronize the state
|
|
73
|
+
* - Returns live, interactive controllers ready for user interaction
|
|
74
|
+
*
|
|
75
|
+
* @param params - A configuration object containing the static state, navigation context,
|
|
76
|
+
* and any controller-specific props needed for hydration
|
|
77
|
+
* @returns A Promise that resolves to the hydrated engine and interactive controllers
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Client-side hydration
|
|
82
|
+
* const result = await engineDefinition.hydrateStaticState(staticState);
|
|
83
|
+
*
|
|
84
|
+
* // Controllers are now interactive
|
|
85
|
+
* result.controllers.productListing.sort({ criterion: 'price' });
|
|
86
|
+
* ```
|
|
37
87
|
*/
|
|
38
88
|
hydrateStaticState: HydrateStaticState<InferControllersMapFromDefinition<TControllers, TSolutionType>, UnknownAction, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
39
89
|
/**
|
|
@@ -1,12 +1,65 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { ControllerStaticStateMap } from './controllers.js';
|
|
3
3
|
export interface EngineStaticState<TSearchAction extends UnknownAction, TControllers extends ControllerStaticStateMap> {
|
|
4
|
+
/**
|
|
5
|
+
* An array of Redux actions representing completed search operations that were executed when the static state was fetched.
|
|
6
|
+
*
|
|
7
|
+
* These actions capture the results of search requests (both successful and failed) performed on the server side.
|
|
8
|
+
* During client-side hydration, these actions are replayed to restore the engine to the exact same state
|
|
9
|
+
* it was in on the server, ensuring consistency between server-rendered and client-rendered content.
|
|
10
|
+
*
|
|
11
|
+
* Each action contains the search results, metadata, and any error information from the Search API responses.
|
|
12
|
+
*/
|
|
4
13
|
searchActions: TSearchAction[];
|
|
14
|
+
/**
|
|
15
|
+
* A map of controller static states, where each key is the controller name and
|
|
16
|
+
* each value contains the serializable state of that controller.
|
|
17
|
+
*/
|
|
5
18
|
controllers: TControllers;
|
|
6
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Utility type to infer the static state type from an engine definition's `fetchStaticState` method.
|
|
22
|
+
*
|
|
23
|
+
* This type extracts the resolved type from the Promise returned by `fetchStaticState`,
|
|
24
|
+
* allowing you to work with the static state type without manually specifying it.
|
|
25
|
+
*
|
|
26
|
+
* @template T - An object with a `fetchStaticState` method that returns a Promise
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const searchEngineDefinition = defineSearchEngine({
|
|
31
|
+
* configuration: { organizationId: 'myorg', accessToken: 'token' },
|
|
32
|
+
* controllers: { searchBox: defineSearchBox() }
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* type StaticState = InferStaticState<typeof searchEngineDefinition>;
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @group Engine
|
|
39
|
+
*/
|
|
7
40
|
export type InferStaticState<T extends {
|
|
8
41
|
fetchStaticState(...args: unknown[]): Promise<unknown>;
|
|
9
42
|
}> = Awaited<ReturnType<T['fetchStaticState']>>;
|
|
43
|
+
/**
|
|
44
|
+
* Utility type to infer the hydrated state type from an engine definition's `hydrateStaticState` method.
|
|
45
|
+
*
|
|
46
|
+
* This type extracts the resolved type from the Promise returned by `hydrateStaticState`,
|
|
47
|
+
* allowing you to work with the hydrated state type without manually specifying it.
|
|
48
|
+
*
|
|
49
|
+
* @template T - An object with a `hydrateStaticState` method that returns a Promise
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const searchEngineDefinition = defineSearchEngine({
|
|
54
|
+
* configuration: { organizationId: 'myorg', accessToken: 'token' },
|
|
55
|
+
* controllers: { searchBox: defineSearchBox() }
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* type HydratedState = InferHydratedState<typeof searchEngineDefinition>;
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @group Engine
|
|
62
|
+
*/
|
|
10
63
|
export type InferHydratedState<T extends {
|
|
11
64
|
hydrateStaticState(...args: unknown[]): Promise<unknown>;
|
|
12
65
|
}> = Awaited<ReturnType<T['hydrateStaticState']>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.35.
|
|
1
|
+
export const VERSION = "3.35.2" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|