@coveo/quantic 3.44.3 → 3.45.1
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/docs/out/quantic-docs.json +58 -0
- package/force-app/main/default/labels/CustomLabels.labels-meta.xml +28 -0
- package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.css +5 -0
- package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.html +30 -0
- package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.js +162 -0
- package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.js-meta.xml +5 -0
- package/force-app/main/default/lwc/quanticPlaceholder/quanticPlaceholder.css +3 -3
- package/force-app/main/default/lwc/quanticPlaceholder/quanticPlaceholder.html +1 -1
- package/force-app/main/default/lwc/quanticResultLink/quanticResultLink.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +16 -16
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/analytics-relay-client.d.ts +2 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/factories/build-factory.d.ts +14 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/build.d.ts +9 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/engine.d.ts +16 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/fetch-static-state.d.ts +31 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/hydrate-static-state.d.ts +30 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/access-token-manager.d.ts +7 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +0 -13
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/build.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/engine.d.ts +0 -13
- package/force-app/main/default/staticresources/coveoheadless/headless.js +18 -18
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +17 -17
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +15 -15
- package/force-app/main/default/staticresources/dompurify/purify.min.js +2 -2
- package/package.json +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/access-token-manager.d.ts +0 -19
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lruMemoize } from '@reduxjs/toolkit';
|
|
1
2
|
import type { NavigatorContextProvider } from '../../app/navigator-context-provider.js';
|
|
2
3
|
import type { CommerceConfigurationSection, ConfigurationSection } from '../../state/state-sections.js';
|
|
3
4
|
type StateNeededByRelay = ConfigurationSection | CommerceConfigurationSection;
|
|
@@ -20,6 +21,6 @@ export declare const getRelayInstanceFromState: ((state: StateNeededByRelay, nav
|
|
|
20
21
|
resetDependencyRecomputations: () => void;
|
|
21
22
|
} & {
|
|
22
23
|
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
23
|
-
memoize: typeof
|
|
24
|
+
memoize: typeof lruMemoize;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
|
@@ -38,9 +38,21 @@ export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefin
|
|
|
38
38
|
/**
|
|
39
39
|
* Callback invoked when the access token changes.
|
|
40
40
|
*/
|
|
41
|
-
onAccessTokenUpdate?: (updateCallback: (token: string) => void) => void;
|
|
41
|
+
onAccessTokenUpdate?: (updateCallback: (token: string) => void, owner: object) => void;
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Internal options describing the lifecycle of the engines a factory produces.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export interface BuildFactoryOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Set by paths that produce an engine outliving the call that created it, namely client-side
|
|
50
|
+
* hydration. Such an engine keeps its subscription to the definition's shared access token even
|
|
51
|
+
* when a per-request token is supplied, so a later `setAccessToken()` still reaches it.
|
|
52
|
+
*/
|
|
53
|
+
engineOutlivesRequest?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>, factoryOptions?: BuildFactoryOptions) => <T extends SolutionType>(solutionType: T) => (...[buildOptions]: BuildParameters<TControllerDefinitions>) => Promise<{
|
|
44
56
|
engine: SSRCommerceEngine;
|
|
45
57
|
controllers: import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions, T>;
|
|
46
58
|
}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NavigatorContext } from '../../../app/navigator-context-provider.js';
|
|
1
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
3
4
|
import type { OptionsExtender, OptionsTuple } from '../../common/types/utilities.js';
|
|
@@ -12,6 +13,14 @@ export interface BuildOptions<TEngineOptions> {
|
|
|
12
13
|
* @deprecated This option will be removed in the next major version.
|
|
13
14
|
*/
|
|
14
15
|
extend?: OptionsExtender<TEngineOptions>;
|
|
16
|
+
/**
|
|
17
|
+
* A per-request access token applied to this call only, without mutating the shared definition.
|
|
18
|
+
*/
|
|
19
|
+
accessToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A per-request navigator context applied to this call only, without mutating the shared definition.
|
|
22
|
+
*/
|
|
23
|
+
navigatorContext?: NavigatorContext;
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
26
|
* This type should not be used directly.
|
|
@@ -54,10 +54,26 @@ export interface EngineDefinition<TControllers extends ControllerDefinitionsMap<
|
|
|
54
54
|
*/
|
|
55
55
|
setNavigatorContextProvider: (navigatorContextProvider: NavigatorContextProvider) => void;
|
|
56
56
|
/**
|
|
57
|
+
* @deprecated This method will be removed in a future major version. Prefer providing the access token
|
|
58
|
+
* directly when fetching the static state to avoid relying on the shared definition.
|
|
59
|
+
*
|
|
57
60
|
* Returns the access token.
|
|
58
61
|
*/
|
|
59
62
|
getAccessToken: () => string;
|
|
60
63
|
/**
|
|
64
|
+
* @deprecated This method will be removed in a future major version. It mutates the shared engine
|
|
65
|
+
* definition, so on a server handling concurrent requests one request can overwrite another
|
|
66
|
+
* request's token. Provide the access token directly when fetching the static state, and pass the
|
|
67
|
+
* same token to `hydrateStaticState()`. To rotate the token of an engine that is already running,
|
|
68
|
+
* configure `renewAccessToken` on the engine configuration.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const staticState = await engineDefinition.fetchStaticState({
|
|
73
|
+
* accessToken: perUserSearchToken,
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
61
77
|
* Updates the access token.
|
|
62
78
|
* @param accessToken - The access token to update.
|
|
63
79
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
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, ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
5
|
import type { SolutionType } from './controller-constants.js';
|
|
@@ -9,7 +10,35 @@ import type { FromBuildResult } from './from-build-result.js';
|
|
|
9
10
|
* @deprecated This interface will be remove on the next major version.
|
|
10
11
|
* Use BuildConfig interface instead
|
|
11
12
|
*/
|
|
12
|
-
export type FetchStaticStateOptions = {
|
|
13
|
+
export type FetchStaticStateOptions = {
|
|
14
|
+
/**
|
|
15
|
+
* A per-request access token (for example, a per-user Coveo search token) to use for this
|
|
16
|
+
* `fetchStaticState()` call only.
|
|
17
|
+
*
|
|
18
|
+
* When provided, it overrides the access token from the engine definition configuration for this
|
|
19
|
+
* request without mutating the shared definition, which is the supported way to use per-user
|
|
20
|
+
* search tokens in a multi-tenant server process. When omitted, the definition's configured
|
|
21
|
+
* access token is used.
|
|
22
|
+
*
|
|
23
|
+
* The resulting engine is request-scoped, so it is not subscribed to `setAccessToken()` updates:
|
|
24
|
+
* a concurrent call on the shared definition cannot overwrite this token.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* This token is NOT carried over to `hydrateStaticState()`. When you pass an `accessToken` here,
|
|
28
|
+
* you MUST pass the same token to the matching `hydrateStaticState()` call, otherwise the hydrated
|
|
29
|
+
* engine silently falls back to the definition's configured token and every client-side request
|
|
30
|
+
* (facets, pagination, search-as-you-type) queries with the wrong permissions.
|
|
31
|
+
*/
|
|
32
|
+
accessToken?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The navigator context to use for this request only.
|
|
35
|
+
*
|
|
36
|
+
* When provided, it is applied to this request's engine without mutating the shared definition,
|
|
37
|
+
* so concurrent requests do not read each other's client ID, user agent, or forwarded-for values.
|
|
38
|
+
* When omitted, the provider set with `setNavigatorContextProvider` is used.
|
|
39
|
+
*/
|
|
40
|
+
navigatorContext?: NavigatorContext;
|
|
41
|
+
};
|
|
13
42
|
export type FetchStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
14
43
|
/**
|
|
15
44
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
@@ -20,5 +49,5 @@ export type FetchStaticState<TControllers extends ControllersMap, TSearchAction
|
|
|
20
49
|
/**
|
|
21
50
|
* @deprecated Use the fetchStaticState() method instead
|
|
22
51
|
*/
|
|
23
|
-
fromBuildResult: FromBuildResult<TControllers, FetchStaticStateOptions, EngineStaticState<TSearchAction, TControllersStaticState>>;
|
|
52
|
+
fromBuildResult: FromBuildResult<TControllers, Omit<FetchStaticStateOptions, 'accessToken' | 'navigatorContext'>, EngineStaticState<TSearchAction, TControllersStaticState>>;
|
|
24
53
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
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 { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
5
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
@@ -8,6 +9,34 @@ import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption,
|
|
|
8
9
|
import type { FromBuildResult } from './from-build-result.js';
|
|
9
10
|
export interface HydrateStaticStateOptions<TSearchAction> {
|
|
10
11
|
searchActions: TSearchAction[];
|
|
12
|
+
/**
|
|
13
|
+
* A per-request access token (for example, a per-user Coveo search token) to use for this
|
|
14
|
+
* `hydrateStaticState()` call only.
|
|
15
|
+
*
|
|
16
|
+
* When provided, it overrides the access token from the engine definition configuration for this
|
|
17
|
+
* call without mutating the shared definition. When omitted, the definition's configured access
|
|
18
|
+
* token is used.
|
|
19
|
+
*
|
|
20
|
+
* Unlike `fetchStaticState()`, the engine returned by `hydrateStaticState()` outlives the call, so
|
|
21
|
+
* it stays subscribed to `setAccessToken()` updates even when this option is provided.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* The token passed to `fetchStaticState()` is NOT carried over here. If you passed an
|
|
25
|
+
* `accessToken` to the matching `fetchStaticState()` call, you MUST pass the same token here,
|
|
26
|
+
* otherwise the hydrated engine falls back to the definition's configured token and every
|
|
27
|
+
* client-side request (facets, pagination, search-as-you-type) queries with the wrong
|
|
28
|
+
* permissions.
|
|
29
|
+
*/
|
|
30
|
+
accessToken?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The navigator context to use for this `hydrateStaticState()` call only.
|
|
33
|
+
*
|
|
34
|
+
* When provided, it is applied to this call's engine without mutating the shared definition.
|
|
35
|
+
* Pass the same navigator context that was used to fetch the static state so the hydrated engine
|
|
36
|
+
* reports the same client ID and keeps the analytics session continuous. When omitted, the provider
|
|
37
|
+
* set with `setNavigatorContextProvider` is used.
|
|
38
|
+
*/
|
|
39
|
+
navigatorContext?: NavigatorContext;
|
|
11
40
|
}
|
|
12
41
|
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
13
42
|
/**
|
|
@@ -19,5 +48,5 @@ export type HydrateStaticState<TControllers extends ControllersMap, TSearchActio
|
|
|
19
48
|
/**
|
|
20
49
|
* @deprecated Use the hydrateStaticState() method instead
|
|
21
50
|
*/
|
|
22
|
-
fromBuildResult: FromBuildResult<TControllers, HydrateStaticStateOptions<TSearchAction>, HydratedState<SSRCommerceEngine, TControllers>>;
|
|
51
|
+
fromBuildResult: FromBuildResult<TControllers, Omit<HydrateStaticStateOptions<TSearchAction>, 'accessToken' | 'navigatorContext'>, HydratedState<SSRCommerceEngine, TControllers>>;
|
|
23
52
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type TokenChangeCallback = (accessToken: string) => void;
|
|
1
2
|
/**
|
|
2
3
|
* This helper allows updating the search token at any point in the SSR workflow—before or after
|
|
3
4
|
* static state creation, and before or after hydration.
|
|
@@ -14,6 +15,11 @@ export declare function createAccessTokenManager(initialToken: string): {
|
|
|
14
15
|
/**
|
|
15
16
|
* Registers a callback function to be invoked when the access token changes.
|
|
16
17
|
* If there's a queued token, the callback will be invoked immediately.
|
|
18
|
+
*
|
|
19
|
+
* @param callback - Invoked with the new token on every subsequent change.
|
|
20
|
+
* @param owner - The object whose lifetime bounds the subscription (the engine).
|
|
21
|
+
* @returns An unsubscribe function that removes the callback immediately.
|
|
17
22
|
*/
|
|
18
|
-
registerCallback(callback:
|
|
23
|
+
registerCallback(callback: TokenChangeCallback, owner: object): () => void;
|
|
19
24
|
};
|
|
25
|
+
export {};
|
|
@@ -154,5 +154,24 @@ export interface CommonBuildConfig {
|
|
|
154
154
|
* ```
|
|
155
155
|
*/
|
|
156
156
|
cart?: CartInitialState;
|
|
157
|
+
/**
|
|
158
|
+
* A per-request access token (for example, a per-user Coveo search token) to use for this
|
|
159
|
+
* `fetchStaticState()` or `hydrateStaticState()` call only.
|
|
160
|
+
*
|
|
161
|
+
* When provided, it overrides the access token from the engine definition configuration for this
|
|
162
|
+
* request without mutating the shared definition, which is the supported way to use per-user
|
|
163
|
+
* search tokens in a multi-tenant server process. When omitted, the definition's configured
|
|
164
|
+
* access token is used.
|
|
165
|
+
*
|
|
166
|
+
* `fetchStaticState()` returns this build configuration alongside the static state, so passing the
|
|
167
|
+
* returned static state to `hydrateStaticState()` carries the token to the hydrated engine
|
|
168
|
+
* automatically. That also means the token is serialized into the payload sent to the browser.
|
|
169
|
+
* Use a scoped, short-lived search token rather than an API key, and do not cache a response whose
|
|
170
|
+
* static state carries a per-user token, or one user's token would be served to another.
|
|
171
|
+
*
|
|
172
|
+
* To rotate the token of a hydrated engine that is already running, configure `renewAccessToken`
|
|
173
|
+
* on the engine configuration rather than mutating the shared definition.
|
|
174
|
+
*/
|
|
175
|
+
accessToken?: string;
|
|
157
176
|
}
|
|
158
177
|
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;
|
|
@@ -22,10 +22,6 @@ export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefin
|
|
|
22
22
|
* The controllers to initialize with the commerce engine.
|
|
23
23
|
*/
|
|
24
24
|
controllers?: ValidateControllerNames<TControllers>;
|
|
25
|
-
/**
|
|
26
|
-
* Callback invoked when the access token changes.
|
|
27
|
-
*/
|
|
28
|
-
onAccessTokenUpdate?: (updateCallback: (token: string) => void) => void;
|
|
29
25
|
};
|
|
30
26
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> {
|
|
31
27
|
/**
|
|
@@ -86,15 +82,6 @@ export interface CommerceEngineDefinition<TControllers extends ControllerDefinit
|
|
|
86
82
|
* ```
|
|
87
83
|
*/
|
|
88
84
|
hydrateStaticState: HydrateStaticState<InferControllersMapFromDefinition<TControllers, TSolutionType>, UnknownAction, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the access token.
|
|
91
|
-
*/
|
|
92
|
-
getAccessToken: () => string;
|
|
93
|
-
/**
|
|
94
|
-
* Updates the access token.
|
|
95
|
-
* @param accessToken - The access token to update.
|
|
96
|
-
*/
|
|
97
|
-
setAccessToken: (accessToken: string) => void;
|
|
98
85
|
}
|
|
99
86
|
export interface CommerceEngineDefinitionBuildResult<TControllers extends ControllersMap> {
|
|
100
87
|
engine: SSRCommerceEngine;
|
|
@@ -17,4 +17,23 @@ export type SearchCompletedAction = ReturnType<LegacySearchAction['fulfilled' |
|
|
|
17
17
|
export type BuildConfig = {
|
|
18
18
|
navigatorContext: NavigatorContext;
|
|
19
19
|
searchParams?: SearchParameterManagerInitialState['parameters'];
|
|
20
|
+
/**
|
|
21
|
+
* A per-request access token (for example, a per-user Coveo search token) to use for this
|
|
22
|
+
* `fetchStaticState()` or `hydrateStaticState()` call only.
|
|
23
|
+
*
|
|
24
|
+
* When provided, it overrides the access token from the engine definition configuration for this
|
|
25
|
+
* request without mutating the shared definition, which is the supported way to use per-user
|
|
26
|
+
* search tokens in a multi-tenant server process. When omitted, the definition's configured
|
|
27
|
+
* access token is used.
|
|
28
|
+
*
|
|
29
|
+
* `fetchStaticState()` returns this build configuration alongside the static state, so passing the
|
|
30
|
+
* returned static state to `hydrateStaticState()` carries the token to the hydrated engine
|
|
31
|
+
* automatically. That also means the token is serialized into the payload sent to the browser.
|
|
32
|
+
* Use a scoped, short-lived search token rather than an API key, and do not cache a response whose
|
|
33
|
+
* static state carries a per-user token, or one user's token would be served to another.
|
|
34
|
+
*
|
|
35
|
+
* To rotate the token of a hydrated engine that is already running, configure `renewAccessToken`
|
|
36
|
+
* on the engine configuration rather than mutating the shared definition.
|
|
37
|
+
*/
|
|
38
|
+
accessToken?: string;
|
|
20
39
|
};
|
|
@@ -23,10 +23,6 @@ export type SearchEngineDefinitionOptions<TControllers extends SearchControllerD
|
|
|
23
23
|
* The controllers to initialize with the search engine.
|
|
24
24
|
*/
|
|
25
25
|
controllers?: ValidateControllerNames<TControllers>;
|
|
26
|
-
/**
|
|
27
|
-
* Callback invoked when the access token changes.
|
|
28
|
-
*/
|
|
29
|
-
onAccessTokenUpdate?: (updateCallback: (token: string) => void) => void;
|
|
30
26
|
};
|
|
31
27
|
export interface SearchEngineDefinition<TEngine extends CoreEngine | CoreEngineNext, TControllers extends ControllerDefinitionsMap<TEngine, Controller>> {
|
|
32
28
|
/**
|
|
@@ -37,15 +33,6 @@ export interface SearchEngineDefinition<TEngine extends CoreEngine | CoreEngineN
|
|
|
37
33
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
38
34
|
*/
|
|
39
35
|
hydrateStaticState: HydrateStaticState<TEngine, InferControllersMapFromDefinition<TControllers>, UnknownAction, InferControllerPropsMapFromDefinitions<TControllers>>;
|
|
40
|
-
/**
|
|
41
|
-
* Returns the access token.
|
|
42
|
-
*/
|
|
43
|
-
getAccessToken: () => string;
|
|
44
|
-
/**
|
|
45
|
-
* Updates the access token.
|
|
46
|
-
* @param accessToken - The access token to update.
|
|
47
|
-
*/
|
|
48
|
-
setAccessToken: (accessToken: string) => void;
|
|
49
36
|
}
|
|
50
37
|
/**
|
|
51
38
|
* This type defines the required and optional controller props for the search engine definition.
|