@coveo/headless 3.34.0 → 3.34.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/README.md +5 -5
- package/dist/cjs/case-assist/headless.cjs +2 -2
- package/dist/cjs/case-assist/node.cjs.stats.json +1 -1
- package/dist/cjs/commerce/headless.cjs +2 -2
- package/dist/cjs/commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/headless.cjs +2 -2
- package/dist/cjs/insight/headless.cjs +2 -2
- package/dist/cjs/insight/node.cjs.stats.json +1 -1
- package/dist/cjs/node.cjs.stats.json +1 -1
- package/dist/cjs/recommendation/headless.cjs +2 -2
- package/dist/cjs/recommendation/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr/headless.cjs +2 -2
- package/dist/cjs/ssr/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +80 -21
- package/dist/cjs/ssr-commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +81 -20
- package/dist/cjs/ssr-commerce-next/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-next/headless.cjs +2 -2
- package/dist/cjs/ssr-next/node.cjs.stats.json +1 -1
- package/dist/definitions/app/case-assist-engine/case-assist-engine.d.ts +3 -3
- package/dist/definitions/app/commerce-engine/commerce-engine.d.ts +16 -16
- package/dist/definitions/app/common-reducers.d.ts +1 -1
- package/dist/definitions/app/insight-engine/insight-engine.d.ts +5 -5
- package/dist/definitions/app/recommendation-engine/recommendation-engine.d.ts +4 -4
- package/dist/definitions/app/search-engine/search-engine.d.ts +4 -4
- package/dist/definitions/app/store.d.ts +2 -2
- package/dist/definitions/controllers/commerce/core/facets/headless-core-commerce-facet.d.ts +1 -1
- package/dist/definitions/controllers/core/facets/range-facet/headless-core-range-facet.d.ts +1 -1
- package/dist/definitions/features/actions-history/ipx-actions-history-actions.d.ts +1 -1
- package/dist/definitions/features/advanced-search-queries/advanced-search-queries-slice.d.ts +1 -1
- package/dist/definitions/features/attached-results/attached-results-slice.d.ts +1 -1
- package/dist/definitions/features/case-assist-configuration/case-assist-configuration-slice.d.ts +1 -1
- package/dist/definitions/features/case-context/case-context-slice.d.ts +1 -1
- package/dist/definitions/features/case-field/case-field-actions.d.ts +1 -1
- package/dist/definitions/features/case-field/case-field-slice.d.ts +1 -1
- package/dist/definitions/features/case-input/case-input-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/configuration/configuration-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/context/cart/cart-actions.d.ts +2 -2
- package/dist/definitions/features/commerce/context/cart/cart-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/context/context-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/did-you-mean/did-you-mean-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/facets/facet-search-set/commerce-facet-search-actions.d.ts +2 -2
- package/dist/definitions/features/commerce/facets/facet-set/facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/instant-products/instant-products-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/pagination/pagination-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/parameters/parameters-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/product/product-actions.d.ts +2 -2
- package/dist/definitions/features/commerce/product-listing/product-listing-actions.d.ts +2 -2
- package/dist/definitions/features/commerce/product-listing/product-listing-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/query/query-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/query-suggest/query-suggest-actions.d.ts +1 -1
- package/dist/definitions/features/commerce/recent-queries/recent-queries-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/recommendations/recommendations-actions.d.ts +2 -2
- package/dist/definitions/features/commerce/recommendations/recommendations-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/search/search-actions.d.ts +4 -4
- package/dist/definitions/features/commerce/search/search-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/sort/sort-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
- package/dist/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
- package/dist/definitions/features/commerce/triggers/triggers-slice.d.ts +1 -1
- package/dist/definitions/features/configuration/configuration-slice.d.ts +1 -1
- package/dist/definitions/features/context/context-slice.d.ts +1 -1
- package/dist/definitions/features/debug/debug-slice.d.ts +1 -1
- package/dist/definitions/features/debug/version-slice.d.ts +1 -1
- package/dist/definitions/features/dictionary-field-context/dictionary-field-context-slice.d.ts +1 -1
- package/dist/definitions/features/did-you-mean/did-you-mean-slice.d.ts +1 -1
- package/dist/definitions/features/document-suggestion/document-suggestion-actions.d.ts +1 -1
- package/dist/definitions/features/document-suggestion/document-suggestion-slice.d.ts +1 -1
- package/dist/definitions/features/excerpt-length/excerpt-length-slice.d.ts +1 -1
- package/dist/definitions/features/facet-options/facet-options-slice.d.ts +1 -1
- package/dist/definitions/features/facets/automatic-facet-set/automatic-facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/category-facet-set/category-facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/facet-order/facet-order-slice.d.ts +1 -1
- package/dist/definitions/features/facets/facet-search-set/category/category-facet-search-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/facet-search-set/generic/generic-facet-search-actions.d.ts +2 -2
- package/dist/definitions/features/facets/facet-search-set/specific/specific-facet-search-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/facet-set/facet-set-controller-actions.d.ts +2 -2
- package/dist/definitions/features/facets/facet-set/facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/range-facets/date-facet-set/date-facet-controller-actions.d.ts +2 -2
- package/dist/definitions/features/facets/range-facets/date-facet-set/date-facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.d.ts +2 -2
- package/dist/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.d.ts +1 -1
- package/dist/definitions/features/fields/fields-actions.d.ts +1 -1
- package/dist/definitions/features/fields/fields-slice.d.ts +1 -1
- package/dist/definitions/features/folding/folding-actions.d.ts +1 -1
- package/dist/definitions/features/folding/folding-slice.d.ts +1 -1
- package/dist/definitions/features/folding/insight-folding-actions.d.ts +1 -1
- package/dist/definitions/features/generated-answer/generated-answer-actions.d.ts +2 -2
- package/dist/definitions/features/generated-answer/generated-answer-slice.d.ts +1 -1
- package/dist/definitions/features/history/history-actions.d.ts +3 -3
- package/dist/definitions/features/history/history-slice.d.ts +2 -2
- package/dist/definitions/features/insight-configuration/insight-configuration-slice.d.ts +1 -1
- package/dist/definitions/features/insight-interface/insight-interface-actions.d.ts +1 -1
- package/dist/definitions/features/insight-interface/insight-interface-slice.d.ts +1 -1
- package/dist/definitions/features/insight-search/insight-search-actions.d.ts +5 -5
- package/dist/definitions/features/insight-search/legacy/insight-search-actions.d.ts +4 -4
- package/dist/definitions/features/insight-user-actions/insight-user-actions-actions.d.ts +1 -1
- package/dist/definitions/features/insight-user-actions/insight-user-actions-slice.d.ts +1 -1
- package/dist/definitions/features/instant-results/instant-results-slice.d.ts +1 -1
- package/dist/definitions/features/pagination/pagination-slice.d.ts +1 -1
- package/dist/definitions/features/pipeline/pipeline-slice.d.ts +1 -1
- package/dist/definitions/features/query/query-slice.d.ts +1 -1
- package/dist/definitions/features/query-set/query-set-slice.d.ts +1 -1
- package/dist/definitions/features/query-suggest/query-suggest-actions.d.ts +1 -1
- package/dist/definitions/features/query-suggest/query-suggest-slice.d.ts +1 -1
- package/dist/definitions/features/question-answering/question-answering-slice.d.ts +1 -1
- package/dist/definitions/features/recent-queries/recent-queries-slice.d.ts +1 -1
- package/dist/definitions/features/recent-results/recent-results-slice.d.ts +1 -1
- package/dist/definitions/features/recommendation/recommendation-actions.d.ts +1 -1
- package/dist/definitions/features/recommendation/recommendation-slice.d.ts +1 -1
- package/dist/definitions/features/result-preview/result-preview-actions.d.ts +2 -2
- package/dist/definitions/features/result-preview/result-preview-slice.d.ts +1 -1
- package/dist/definitions/features/search/legacy/search-actions.d.ts +5 -5
- package/dist/definitions/features/search/search-actions.d.ts +6 -6
- package/dist/definitions/features/search/search-slice.d.ts +1 -1
- package/dist/definitions/features/search-hub/search-hub-slice.d.ts +1 -1
- package/dist/definitions/features/sort-criteria/sort-criteria-slice.d.ts +1 -1
- package/dist/definitions/features/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
- package/dist/definitions/features/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
- package/dist/definitions/features/static-filter-set/static-filter-set-slice.d.ts +1 -1
- package/dist/definitions/features/tab-set/tab-set-slice.d.ts +1 -1
- package/dist/definitions/features/triggers/triggers-slice.d.ts +1 -1
- package/dist/definitions/ssr/commerce/factories/build-factory.d.ts +6 -1
- package/dist/definitions/ssr/common/access-token-manager.d.ts +19 -0
- package/dist/definitions/ssr-next/commerce/types/engine.d.ts +4 -2
- package/dist/definitions/ssr-next/common/access-token-manager.d.ts +19 -0
- package/dist/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +2 -2
- package/dist/definitions/test/mock-ssr-controller-definitions.d.ts +2 -2
- package/dist/esm/ssr/commerce/engine/commerce-engine.ssr.js +31 -7
- package/dist/esm/ssr/commerce/factories/build-factory.js +10 -0
- package/dist/esm/ssr/common/access-token-manager.js +43 -0
- package/dist/esm/ssr-next/commerce/engine/commerce-engine.ssr.js +15 -6
- package/dist/esm/ssr-next/commerce/factories/build-factory.js +10 -0
- package/dist/esm/ssr-next/common/access-token-manager.js +43 -0
- package/dist/esm/utils/version.js +1 -1
- package/dist/quantic/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/browser.cjs.stats.json +1 -1
- package/dist/quantic/case-assist/headless.js +1 -1
- package/dist/quantic/case-assist/headless.js.map +1 -1
- package/dist/quantic/commerce/browser.cjs.stats.json +1 -1
- package/dist/quantic/commerce/headless.js +1 -1
- package/dist/quantic/commerce/headless.js.map +1 -1
- package/dist/quantic/headless.js +1 -1
- package/dist/quantic/headless.js.map +1 -1
- package/dist/quantic/insight/browser.cjs.stats.json +1 -1
- package/dist/quantic/insight/headless.js +1 -1
- package/dist/quantic/insight/headless.js.map +1 -1
- package/dist/quantic/recommendation/browser.cjs.stats.json +1 -1
- package/dist/quantic/recommendation/headless.js +1 -1
- package/dist/quantic/recommendation/headless.js.map +1 -1
- package/package.json +33 -31
|
@@ -29,7 +29,7 @@ export interface PrepareForSearchWithQueryOptions {
|
|
|
29
29
|
export declare const prepareForSearchWithQuery: import("@reduxjs/toolkit").AsyncThunk<void, UpdateQueryActionCreatorPayload & PrepareForSearchWithQueryOptions, {
|
|
30
30
|
state: StateNeededByExecuteSearch;
|
|
31
31
|
extra: import("../../app/thunk-extra-arguments.js").ThunkExtraArguments;
|
|
32
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
32
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
33
33
|
rejectValue?: unknown;
|
|
34
34
|
serializedErrorType?: unknown;
|
|
35
35
|
pendingMeta?: unknown;
|
|
@@ -45,7 +45,7 @@ export declare const executeSearch: import("@reduxjs/toolkit").AsyncThunk<Execut
|
|
|
45
45
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
46
46
|
state: StateNeededByExecuteSearch;
|
|
47
47
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
48
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
48
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
49
49
|
serializedErrorType?: unknown;
|
|
50
50
|
pendingMeta?: unknown;
|
|
51
51
|
fulfilledMeta?: unknown;
|
|
@@ -55,7 +55,7 @@ export declare const fetchPage: import("@reduxjs/toolkit").AsyncThunk<ExecuteSea
|
|
|
55
55
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
56
56
|
state: StateNeededByExecuteSearch;
|
|
57
57
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
58
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
58
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
59
59
|
serializedErrorType?: unknown;
|
|
60
60
|
pendingMeta?: unknown;
|
|
61
61
|
fulfilledMeta?: unknown;
|
|
@@ -65,7 +65,7 @@ export declare const fetchMoreResults: import("@reduxjs/toolkit").AsyncThunk<Exe
|
|
|
65
65
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
66
66
|
state: StateNeededByExecuteSearch;
|
|
67
67
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
68
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
68
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
69
69
|
serializedErrorType?: unknown;
|
|
70
70
|
pendingMeta?: unknown;
|
|
71
71
|
fulfilledMeta?: unknown;
|
|
@@ -75,7 +75,7 @@ export declare const fetchFacetValues: import("@reduxjs/toolkit").AsyncThunk<Exe
|
|
|
75
75
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
76
76
|
state: StateNeededByExecuteSearch;
|
|
77
77
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
78
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
78
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
79
79
|
serializedErrorType?: unknown;
|
|
80
80
|
pendingMeta?: unknown;
|
|
81
81
|
fulfilledMeta?: unknown;
|
|
@@ -85,7 +85,7 @@ export declare const fetchInstantResults: import("@reduxjs/toolkit").AsyncThunk<
|
|
|
85
85
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
86
86
|
state: import("../../state/state-sections.js").ConfigurationSection & Partial<import("../../state/state-sections.js").QuerySection & import("../../state/state-sections.js").AdvancedSearchQueriesSection & import("../../state/state-sections.js").PaginationSection & import("../../state/state-sections.js").SortSection & import("../../state/state-sections.js").FacetSection & import("../../state/state-sections.js").NumericFacetSection & import("../../state/state-sections.js").CategoryFacetSection & import("../../state/state-sections.js").DateFacetSection & import("../../state/state-sections.js").ContextSection & import("../../state/state-sections.js").DidYouMeanSection & import("../../state/state-sections.js").FieldsSection & import("../../state/state-sections.js").PipelineSection & import("../../state/state-sections.js").SearchHubSection & import("../../state/state-sections.js").QuerySetSection & import("../../state/state-sections.js").FacetOptionsSection & import("../../state/state-sections.js").FacetOrderSection & import("../../state/state-sections.js").DebugSection & import("../../state/state-sections.js").SearchSection & import("../../state/state-sections.js").FoldingSection & import("../../state/state-sections.js").TriggerSection> & InstantResultSection;
|
|
87
87
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
88
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
88
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
89
89
|
serializedErrorType?: unknown;
|
|
90
90
|
pendingMeta?: unknown;
|
|
91
91
|
fulfilledMeta?: unknown;
|
package/dist/definitions/features/standalone-search-box-set/standalone-search-box-set-actions.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export declare const fetchRedirectUrl: import("@reduxjs/toolkit").AsyncThunk<str
|
|
|
64
64
|
rejectValue: import("../../api/search/search-api-error-response.js").SearchAPIErrorWithStatusCode;
|
|
65
65
|
state: StateNeededForRedirect;
|
|
66
66
|
extra: import("../../app/thunk-extra-arguments.js").ClientThunkExtraArguments<import("../../api/search/search-api-client.js").SearchAPIClient, import("../../api/generated-answer/generated-answer-client.js").GeneratedAnswerAPIClient>;
|
|
67
|
-
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("
|
|
67
|
+
dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("@reduxjs/toolkit").UnknownAction> | undefined;
|
|
68
68
|
serializedErrorType?: unknown;
|
|
69
69
|
pendingMeta?: unknown;
|
|
70
70
|
fulfilledMeta?: unknown;
|
package/dist/definitions/features/standalone-search-box-set/standalone-search-box-set-slice.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const standaloneSearchBoxSetReducer: import("
|
|
1
|
+
export declare const standaloneSearchBoxSetReducer: import("@reduxjs/toolkit").Reducer<import("./standalone-search-box-set-state.js").StandaloneSearchBoxSetState> & {
|
|
2
2
|
getInitialState: () => import("./standalone-search-box-set-state.js").StandaloneSearchBoxSetState;
|
|
3
3
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const staticFilterSetReducer: import("
|
|
1
|
+
export declare const staticFilterSetReducer: import("@reduxjs/toolkit").Reducer<import("./static-filter-set-state.js").StaticFilterSetState> & {
|
|
2
2
|
getInitialState: () => import("./static-filter-set-state.js").StaticFilterSetState;
|
|
3
3
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const triggerReducer: import("
|
|
1
|
+
export declare const triggerReducer: import("@reduxjs/toolkit").Reducer<import("./triggers-state.js").TriggerState> & {
|
|
2
2
|
getInitialState: () => import("./triggers-state.js").TriggerState;
|
|
3
3
|
};
|
|
@@ -34,7 +34,12 @@ export type SSRCommerceEngineOptions = Omit<CommerceEngineOptions, 'configuratio
|
|
|
34
34
|
context: CommerceEngineOptions['configuration']['context'];
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<SSRCommerceEngineOptions, TControllers
|
|
37
|
+
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<SSRCommerceEngineOptions, TControllers> & {
|
|
38
|
+
/**
|
|
39
|
+
* Callback invoked when the access token changes.
|
|
40
|
+
*/
|
|
41
|
+
onAccessTokenUpdate?: (updateCallback: (token: string) => void) => void;
|
|
42
|
+
};
|
|
38
43
|
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => <T extends SolutionType>(solutionType: T) => (...[buildOptions]: BuildParameters<TControllerDefinitions>) => Promise<{
|
|
39
44
|
engine: SSRCommerceEngine;
|
|
40
45
|
controllers: import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions, T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This helper allows updating the search token at any point in the SSR workflow—before or after
|
|
3
|
+
* static state creation, and before or after hydration.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createAccessTokenManager(initialToken: string): {
|
|
6
|
+
/**
|
|
7
|
+
* Gets the current access token.
|
|
8
|
+
*/
|
|
9
|
+
getAccessToken(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the access token, updating both configuration and active engines.
|
|
12
|
+
*/
|
|
13
|
+
setAccessToken(accessToken: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Registers a callback function to be invoked when the access token changes.
|
|
16
|
+
* If there's a queued token, the callback will be invoked immediately.
|
|
17
|
+
*/
|
|
18
|
+
registerCallback(callback: (accessToken: string) => void): void;
|
|
19
|
+
};
|
|
@@ -16,14 +16,16 @@ type ValidateControllerNames<T extends ControllerDefinitionsMap<Controller>> = {
|
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* The options to create a Commerce engine definition in SSR.
|
|
19
|
-
*
|
|
20
|
-
* @group Engine
|
|
21
19
|
*/
|
|
22
20
|
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = SSRCommerceEngineOptions & {
|
|
23
21
|
/**
|
|
24
22
|
* The controllers to initialize with the commerce engine.
|
|
25
23
|
*/
|
|
26
24
|
controllers?: ValidateControllerNames<TControllers>;
|
|
25
|
+
/**
|
|
26
|
+
* Callback invoked when the access token changes.
|
|
27
|
+
*/
|
|
28
|
+
onAccessTokenUpdate?: (updateCallback: (token: string) => void) => void;
|
|
27
29
|
};
|
|
28
30
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> {
|
|
29
31
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This helper allows updating the search token at any point in the SSR workflow—before or after
|
|
3
|
+
* static state creation, and before or after hydration.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createAccessTokenManager(initialToken: string): {
|
|
6
|
+
/**
|
|
7
|
+
* Gets the current access token.
|
|
8
|
+
*/
|
|
9
|
+
getAccessToken(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the access token, updating both configuration and active engines.
|
|
12
|
+
*/
|
|
13
|
+
setAccessToken(accessToken: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Registers a callback function to be invoked when the access token changes.
|
|
16
|
+
* If there's a queued token, the callback will be invoked immediately.
|
|
17
|
+
*/
|
|
18
|
+
registerCallback(callback: (accessToken: string) => void): void;
|
|
19
|
+
};
|
|
@@ -34,6 +34,6 @@ export type SearchCompletedAction = ReturnType<LegacySearchAction['fulfilled' |
|
|
|
34
34
|
* @group Engine
|
|
35
35
|
*/
|
|
36
36
|
export declare function defineSearchEngine<TControllerDefinitions extends ControllerDefinitionsMap<SearchEngine, Controller>>(options: SearchEngineDefinitionOptions<TControllerDefinitions>): {
|
|
37
|
-
fetchStaticState: import("../types/fetch-static-state.js").FetchStaticState<import("
|
|
38
|
-
hydrateStaticState: import("../types/hydrate-static-state.js").HydrateStaticState<SSRSearchEngine, import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions>, import("
|
|
37
|
+
fetchStaticState: import("../types/fetch-static-state.js").FetchStaticState<import("@reduxjs/toolkit").AnyAction, InferControllerStaticStateMapFromDefinitions<TControllerDefinitions>, InferControllerPropsMapFromDefinitions<TControllerDefinitions>>;
|
|
38
|
+
hydrateStaticState: import("../types/hydrate-static-state.js").HydrateStaticState<SSRSearchEngine, import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions>, import("@reduxjs/toolkit").AnyAction, InferControllerPropsMapFromDefinitions<TControllerDefinitions>>;
|
|
39
39
|
};
|
|
@@ -27,7 +27,7 @@ export declare function defineMockCommerceController(options?: SolutionTypeAvail
|
|
|
27
27
|
export declare function defineMockCommerceControllerWithProps(options?: SolutionTypeAvailabilities): {
|
|
28
28
|
buildWithProps: import("vitest").Mock<(engine: any, props: any) => {
|
|
29
29
|
state: {};
|
|
30
|
-
subscribe(listener: () => void): import("
|
|
30
|
+
subscribe(listener: () => void): import("@reduxjs/toolkit").Unsubscribe;
|
|
31
31
|
}>;
|
|
32
32
|
listing: boolean;
|
|
33
33
|
search: boolean;
|
|
@@ -41,7 +41,7 @@ export declare function defineMockRecommendationDefinition(slotId: string): {
|
|
|
41
41
|
};
|
|
42
42
|
buildWithProps: import("vitest").Mock<(engine: any, props: any) => {
|
|
43
43
|
state: {};
|
|
44
|
-
subscribe(listener: () => void): import("
|
|
44
|
+
subscribe(listener: () => void): import("@reduxjs/toolkit").Unsubscribe;
|
|
45
45
|
}>;
|
|
46
46
|
};
|
|
47
47
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions to be used for Commerce Server Side Rendering.
|
|
3
3
|
*/
|
|
4
|
+
import { createAccessTokenManager } from '../../common/access-token-manager.js';
|
|
4
5
|
import { buildFactory, } from '../factories/build-factory.js';
|
|
5
6
|
import { hydratedStaticStateFactory } from '../factories/hydrated-state-factory.js';
|
|
6
7
|
import { hydratedRecommendationStaticStateFactory } from '../factories/recommendation-hydrated-state-factory.js';
|
|
@@ -17,19 +18,42 @@ import { SolutionType } from '../types/controller-constants.js';
|
|
|
17
18
|
*/
|
|
18
19
|
export function defineCommerceEngine(options) {
|
|
19
20
|
const { controllers: controllerDefinitions, ...engineOptions } = options;
|
|
20
|
-
const getOptions = () => engineOptions;
|
|
21
21
|
const setNavigatorContextProvider = (navigatorContextProvider) => {
|
|
22
22
|
engineOptions.navigatorContextProvider = navigatorContextProvider;
|
|
23
23
|
};
|
|
24
|
-
const
|
|
24
|
+
const tokenManager = createAccessTokenManager(engineOptions.configuration.accessToken);
|
|
25
|
+
const onAccessTokenUpdate = (updateCallback) => {
|
|
26
|
+
tokenManager.registerCallback(updateCallback);
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* HACK: We assign engineOptions by reference (not by value) to definitionOptions
|
|
30
|
+
* so that when setNavigatorContextProvider() modifies engineOptions.navigatorContextProvider,
|
|
31
|
+
* the factories will see the updated navigator context when they are called later.
|
|
32
|
+
*
|
|
33
|
+
* This works because:
|
|
34
|
+
* 1. setNavigatorContextProvider() modifies engineOptions.navigatorContextProvider
|
|
35
|
+
* 2. definitionOptions points to the same object as engineOptions
|
|
36
|
+
* 3. When fetchStaticState() is called, it uses the current value from the shared object
|
|
37
|
+
*
|
|
38
|
+
* Without this reference sharing, definitionOptions would be a snapshot taken at
|
|
39
|
+
* definition time, and navigator context updates would be ignored.
|
|
40
|
+
*
|
|
41
|
+
* TODO: This will be removed in the next major version with a cleaner design
|
|
42
|
+
* where context is provided directly to fetchStaticState() rather than through
|
|
43
|
+
* the engine definition.
|
|
44
|
+
*/
|
|
45
|
+
const definitionOptions = engineOptions;
|
|
46
|
+
definitionOptions.onAccessTokenUpdate = onAccessTokenUpdate;
|
|
47
|
+
const getAccessToken = () => tokenManager.getAccessToken();
|
|
25
48
|
const setAccessToken = (accessToken) => {
|
|
26
49
|
engineOptions.configuration.accessToken = accessToken;
|
|
50
|
+
tokenManager.setAccessToken(accessToken);
|
|
27
51
|
};
|
|
28
|
-
const build = buildFactory(controllerDefinitions,
|
|
29
|
-
const fetchStaticState = fetchStaticStateFactory(controllerDefinitions,
|
|
30
|
-
const hydrateStaticState = hydratedStaticStateFactory(controllerDefinitions,
|
|
31
|
-
const fetchRecommendationStaticState = fetchRecommendationStaticStateFactory(controllerDefinitions,
|
|
32
|
-
const hydrateRecommendationStaticState = hydratedRecommendationStaticStateFactory(controllerDefinitions,
|
|
52
|
+
const build = buildFactory(controllerDefinitions, definitionOptions);
|
|
53
|
+
const fetchStaticState = fetchStaticStateFactory(controllerDefinitions, definitionOptions);
|
|
54
|
+
const hydrateStaticState = hydratedStaticStateFactory(controllerDefinitions, definitionOptions);
|
|
55
|
+
const fetchRecommendationStaticState = fetchRecommendationStaticStateFactory(controllerDefinitions, definitionOptions);
|
|
56
|
+
const hydrateRecommendationStaticState = hydratedRecommendationStaticStateFactory(controllerDefinitions, definitionOptions);
|
|
33
57
|
return {
|
|
34
58
|
listingEngineDefinition: {
|
|
35
59
|
build: build(SolutionType.listing),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildCommerceEngine, } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
2
|
import { buildLogger } from '../../../app/logger.js';
|
|
3
3
|
import { stateKey } from '../../../app/state-key.js';
|
|
4
|
+
import { loadConfigurationActions } from '../../../features/commerce/configuration/configuration-actions-loader.js';
|
|
4
5
|
import { createWaitForActionMiddleware, createWaitForActionMiddlewareForRecommendation, } from '../../../utils/utils.js';
|
|
5
6
|
import { buildControllerDefinitions } from '../controller-utils.js';
|
|
6
7
|
import { SolutionType } from '../types/controller-constants.js';
|
|
@@ -75,6 +76,15 @@ export const buildFactory = (controllerDefinitions, options) => (solutionType) =
|
|
|
75
76
|
const engine = buildSSRCommerceEngine(solutionType, buildOptions && 'extend' in buildOptions && buildOptions?.extend
|
|
76
77
|
? await buildOptions.extend(options)
|
|
77
78
|
: options, enabledRecommendationControllers);
|
|
79
|
+
const updateEngineConfiguration = (accessToken) => {
|
|
80
|
+
const { updateBasicConfiguration } = loadConfigurationActions(engine);
|
|
81
|
+
engine.dispatch(updateBasicConfiguration({
|
|
82
|
+
accessToken,
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
if (options.onAccessTokenUpdate) {
|
|
86
|
+
options.onAccessTokenUpdate(updateEngineConfiguration);
|
|
87
|
+
}
|
|
78
88
|
const controllers = buildControllerDefinitions({
|
|
79
89
|
definitionsMap: (controllerDefinitions ?? {}),
|
|
80
90
|
engine,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This helper allows updating the search token at any point in the SSR workflow—before or after
|
|
3
|
+
* static state creation, and before or after hydration.
|
|
4
|
+
*/
|
|
5
|
+
export function createAccessTokenManager(initialToken) {
|
|
6
|
+
const tokenChangeCallbacks = new Set();
|
|
7
|
+
let queuedToken = null;
|
|
8
|
+
let currentAccessToken = initialToken;
|
|
9
|
+
return {
|
|
10
|
+
/**
|
|
11
|
+
* Gets the current access token.
|
|
12
|
+
*/
|
|
13
|
+
getAccessToken() {
|
|
14
|
+
return currentAccessToken;
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Sets the access token, updating both configuration and active engines.
|
|
18
|
+
*/
|
|
19
|
+
setAccessToken(accessToken) {
|
|
20
|
+
currentAccessToken = accessToken;
|
|
21
|
+
if (tokenChangeCallbacks.size > 0) {
|
|
22
|
+
tokenChangeCallbacks.forEach((callback) => {
|
|
23
|
+
callback(accessToken);
|
|
24
|
+
});
|
|
25
|
+
queuedToken = null;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
queuedToken = accessToken;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Registers a callback function to be invoked when the access token changes.
|
|
33
|
+
* If there's a queued token, the callback will be invoked immediately.
|
|
34
|
+
*/
|
|
35
|
+
registerCallback(callback) {
|
|
36
|
+
tokenChangeCallbacks.add(callback);
|
|
37
|
+
if (queuedToken) {
|
|
38
|
+
callback(queuedToken);
|
|
39
|
+
queuedToken = null;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions to be used for Commerce Server Side Rendering.
|
|
3
3
|
*/
|
|
4
|
+
import { createAccessTokenManager } from '../../common/access-token-manager.js';
|
|
4
5
|
import { defineCart } from '../controllers/cart/headless-cart.ssr.js';
|
|
5
6
|
import { defineContext } from '../controllers/context/headless-context.ssr.js';
|
|
6
7
|
import { defineParameterManager } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
@@ -37,10 +38,18 @@ import { validateControllerNames } from '../validation/controller-validation.js'
|
|
|
37
38
|
*/
|
|
38
39
|
export function defineCommerceEngine(options) {
|
|
39
40
|
const { controllers: controllerDefinitions, ...engineOptions } = options;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
41
|
+
const tokenManager = createAccessTokenManager(engineOptions.configuration.accessToken);
|
|
42
|
+
const onAccessTokenUpdate = (updateCallback) => {
|
|
43
|
+
tokenManager.registerCallback(updateCallback);
|
|
44
|
+
};
|
|
45
|
+
const definitionOptions = {
|
|
46
|
+
...engineOptions,
|
|
47
|
+
onAccessTokenUpdate,
|
|
48
|
+
};
|
|
49
|
+
const getAccessToken = () => tokenManager.getAccessToken();
|
|
42
50
|
const setAccessToken = (accessToken) => {
|
|
43
51
|
engineOptions.configuration.accessToken = accessToken;
|
|
52
|
+
tokenManager.setAccessToken(accessToken);
|
|
44
53
|
};
|
|
45
54
|
controllerDefinitions && validateControllerNames(controllerDefinitions);
|
|
46
55
|
const augmentedControllerDefinition = {
|
|
@@ -49,10 +58,10 @@ export function defineCommerceEngine(options) {
|
|
|
49
58
|
context: defineContext(),
|
|
50
59
|
cart: defineCart(),
|
|
51
60
|
};
|
|
52
|
-
const fetchStaticState = fetchStaticStateFactory(augmentedControllerDefinition,
|
|
53
|
-
const hydrateStaticState = hydratedStaticStateFactory(augmentedControllerDefinition,
|
|
54
|
-
const fetchRecommendationStaticState = fetchRecommendationStaticStateFactory(augmentedControllerDefinition,
|
|
55
|
-
const hydrateRecommendationStaticState = hydratedRecommendationStaticStateFactory(augmentedControllerDefinition,
|
|
61
|
+
const fetchStaticState = fetchStaticStateFactory(augmentedControllerDefinition, definitionOptions);
|
|
62
|
+
const hydrateStaticState = hydratedStaticStateFactory(augmentedControllerDefinition, definitionOptions);
|
|
63
|
+
const fetchRecommendationStaticState = fetchRecommendationStaticStateFactory(augmentedControllerDefinition, definitionOptions);
|
|
64
|
+
const hydrateRecommendationStaticState = hydratedRecommendationStaticStateFactory(augmentedControllerDefinition, definitionOptions);
|
|
56
65
|
const commonMethods = {
|
|
57
66
|
getAccessToken,
|
|
58
67
|
setAccessToken,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildCommerceEngine, } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
2
|
import { stateKey } from '../../../app/state-key.js';
|
|
3
|
+
import { loadConfigurationActions } from '../../../features/commerce/configuration/configuration-actions-loader.js';
|
|
3
4
|
import { createWaitForActionMiddleware, createWaitForActionMiddlewareForRecommendation, } from '../../../utils/utils.js';
|
|
4
5
|
import { buildControllerDefinitions } from '../controller-utils.js';
|
|
5
6
|
import { SolutionType } from '../types/controller-constants.js';
|
|
@@ -64,6 +65,15 @@ export const buildFactory = (controllerDefinitions, options) => (solutionType) =
|
|
|
64
65
|
: 0;
|
|
65
66
|
const engineOptions = augmentCommerceEngineOptions(options, buildOptions);
|
|
66
67
|
const engine = buildSSRCommerceEngine(solutionType, engineOptions, enabledRecommendationControllers);
|
|
68
|
+
const updateEngineConfiguration = (accessToken) => {
|
|
69
|
+
const { updateBasicConfiguration } = loadConfigurationActions(engine);
|
|
70
|
+
engine.dispatch(updateBasicConfiguration({
|
|
71
|
+
accessToken,
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
if (options.onAccessTokenUpdate) {
|
|
75
|
+
options.onAccessTokenUpdate(updateEngineConfiguration);
|
|
76
|
+
}
|
|
67
77
|
const controllers = buildControllerDefinitions({
|
|
68
78
|
definitionsMap: controllerDefinitions ?? {},
|
|
69
79
|
engine,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This helper allows updating the search token at any point in the SSR workflow—before or after
|
|
3
|
+
* static state creation, and before or after hydration.
|
|
4
|
+
*/
|
|
5
|
+
export function createAccessTokenManager(initialToken) {
|
|
6
|
+
const tokenChangeCallbacks = new Set();
|
|
7
|
+
let queuedToken = null;
|
|
8
|
+
let currentAccessToken = initialToken;
|
|
9
|
+
return {
|
|
10
|
+
/**
|
|
11
|
+
* Gets the current access token.
|
|
12
|
+
*/
|
|
13
|
+
getAccessToken() {
|
|
14
|
+
return currentAccessToken;
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Sets the access token, updating both configuration and active engines.
|
|
18
|
+
*/
|
|
19
|
+
setAccessToken(accessToken) {
|
|
20
|
+
currentAccessToken = accessToken;
|
|
21
|
+
if (tokenChangeCallbacks.size > 0) {
|
|
22
|
+
tokenChangeCallbacks.forEach((callback) => {
|
|
23
|
+
callback(accessToken);
|
|
24
|
+
});
|
|
25
|
+
queuedToken = null;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
queuedToken = accessToken;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Registers a callback function to be invoked when the access token changes.
|
|
33
|
+
* If there's a queued token, the callback will be invoked immediately.
|
|
34
|
+
*/
|
|
35
|
+
registerCallback(callback) {
|
|
36
|
+
tokenChangeCallbacks.add(callback);
|
|
37
|
+
if (queuedToken) {
|
|
38
|
+
callback(queuedToken);
|
|
39
|
+
queuedToken = null;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.34.
|
|
1
|
+
export const VERSION = "3.34.1" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|