@coveo/quantic 3.10.0-pre.faaf12d7a7 → 3.11.0
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 +52 -12
- package/force-app/main/default/labels/CustomLabels.labels-meta.xml +7 -0
- package/force-app/main/default/lwc/quanticCaseAssistInterface/quanticCaseAssistInterface.js +8 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +108 -1
- package/force-app/main/default/lwc/quanticCategoryFacet/quanticCategoryFacet.js +22 -0
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticDateFacet/quanticDateFacet.js +22 -0
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +106 -1
- package/force-app/main/default/lwc/quanticFacet/quanticFacet.js +21 -1
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +1 -1
- package/force-app/main/default/lwc/quanticFeedbackModalQna/quanticFeedbackModalQna.js +1 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.css +0 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/templates/generatedMarkdownContent.css +1 -0
- package/force-app/main/default/lwc/quanticInsightInterface/quanticInsightInterface.js +8 -0
- package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +112 -4
- package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.css +8 -0
- package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.html +20 -7
- package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.js +57 -18
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticNumericFacet/quanticNumericFacet.js +22 -0
- package/force-app/main/default/lwc/quanticRecommendationInterface/quanticRecommendationInterface.js +8 -0
- package/force-app/main/default/lwc/quanticSearchInterface/quanticSearchInterface.js +8 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticTimeframeFacet/quanticTimeframeFacet.js +22 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +18 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +32 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +32 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +71 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +39 -0
- package/force-app/main/default/staticresources/coveobueno/browser/bueno.js +3 -18
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +9 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/common/request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/recommendations/recommendations-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/search/query-suggest/query-suggest-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/case-assist/get-case-classifications/get-case-classifications-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/get-interface/get-interface-config-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/query/query-request.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/user-actions/user-actions-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-engine/commerce-engine.ssr.d.ts +4 -13
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/common.d.ts +8 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/build-factory.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/hydrated-state-factory.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/recommendation-hydrated-state-factory.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/recommendation-static-state-factory.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/static-state-factory.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/build.d.ts +13 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/common.d.ts +180 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/core-engine.d.ts +29 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/fetch-static-state.d.ts +15 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/from-build-result.d.ts +20 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/hydrate-static-state.d.ts +18 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/logger.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/navigatorContextProvider.d.ts +17 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/ssr-engine/types/common.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/ssr-engine/types/from-build-result.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/instant-products/headless-instant-products.ssr.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-view/headless-product-view.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.ssr.d.ts +10 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/analytics/search-action-cause.d.ts +0 -82
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-analytics-actions.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-analytics-actions.d.ts +0 -3
- 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-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/static-filter-set/static-filter-set-actions.d.ts +0 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-engine-v2.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/utils.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +11 -8
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +10 -7
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +9 -6
- package/force-app/main/default/staticresources/dompurify/purify.min.js +1339 -2
- package/package.json +23 -19
|
@@ -18,10 +18,10 @@ export declare const buildRequest: (req: CommerceAPIRequest, path: CommerceApiMe
|
|
|
18
18
|
sort: import("./sort.js").SortOption | undefined;
|
|
19
19
|
};
|
|
20
20
|
url: string;
|
|
21
|
-
origin: import("../../preprocess-request.js").PlatformClientOrigin;
|
|
22
21
|
accessToken: string;
|
|
23
22
|
method: import("../../platform-client.js").HttpMethods;
|
|
24
23
|
contentType: import("../../platform-client.js").HTTPContentType;
|
|
24
|
+
origin: import("../../preprocess-request.js").PlatformClientOrigin;
|
|
25
25
|
requestMetadata?: import("../../preprocess-request.js").RequestMetadata | undefined;
|
|
26
26
|
};
|
|
27
27
|
export declare const baseRequest: (req: BaseParam, path: CommerceApiMethod) => Pick<PlatformClientCallOptions, 'accessToken' | 'method' | 'contentType' | 'url' | 'origin' | 'requestMetadata'>;
|
|
@@ -15,9 +15,9 @@ export declare const buildRecommendationsRequest: (req: CommerceRecommendationsR
|
|
|
15
15
|
perPage: number | undefined;
|
|
16
16
|
};
|
|
17
17
|
url: string;
|
|
18
|
-
origin: import("../../preprocess-request.js").PlatformClientOrigin;
|
|
19
18
|
accessToken: string;
|
|
20
19
|
method: import("../../platform-client.js").HttpMethods;
|
|
21
20
|
contentType: import("../../platform-client.js").HTTPContentType;
|
|
21
|
+
origin: import("../../preprocess-request.js").PlatformClientOrigin;
|
|
22
22
|
requestMetadata?: import("../../preprocess-request.js").RequestMetadata | undefined;
|
|
23
23
|
};
|
|
@@ -12,9 +12,9 @@ export declare const buildQuerySuggestRequest: (req: QuerySuggestRequest) => {
|
|
|
12
12
|
currency: string;
|
|
13
13
|
};
|
|
14
14
|
url: string;
|
|
15
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
16
15
|
accessToken: string;
|
|
17
16
|
method: import("../../../platform-client.js").HttpMethods;
|
|
18
17
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
18
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
19
19
|
requestMetadata?: import("../../../preprocess-request.js").RequestMetadata | undefined;
|
|
20
20
|
};
|
|
@@ -70,7 +70,7 @@ export declare const constructAnswerQueryParams: (state: StateNeededByAnswerAPI,
|
|
|
70
70
|
} | undefined;
|
|
71
71
|
enableDidYouMean?: boolean | undefined;
|
|
72
72
|
fieldsToInclude?: string[] | undefined;
|
|
73
|
-
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/
|
|
73
|
+
facets?: (import("../../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest | import("../../features/facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest)[] | undefined;
|
|
74
74
|
pipeline?: string | undefined;
|
|
75
75
|
searchHub?: string | undefined;
|
|
76
76
|
q: string | undefined;
|
|
@@ -8,8 +8,8 @@ export declare const buildGetCaseClassificationsRequest: (req: GetCaseClassifica
|
|
|
8
8
|
fields: import("../case-assist-params.js").CaseFields;
|
|
9
9
|
};
|
|
10
10
|
url: string;
|
|
11
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
12
11
|
accessToken: string;
|
|
13
12
|
method: import("../../../platform-client.js").HttpMethods;
|
|
14
13
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
14
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
15
15
|
};
|
|
@@ -9,8 +9,8 @@ export declare const buildGetDocumentSuggestionsRequest: (req: GetDocumentSugges
|
|
|
9
9
|
context: Record<string, string | string[]> | undefined;
|
|
10
10
|
};
|
|
11
11
|
url: string;
|
|
12
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
13
12
|
accessToken: string;
|
|
14
13
|
method: import("../../../platform-client.js").HttpMethods;
|
|
15
14
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
15
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
16
16
|
};
|
|
@@ -4,8 +4,8 @@ export type GetInsightInterfaceConfigRequest = BaseParam & InsightIdParam;
|
|
|
4
4
|
export declare const buildGetInsightInterfaceConfigRequest: (req: GetInsightInterfaceConfigRequest) => {
|
|
5
5
|
requestParams: {};
|
|
6
6
|
url: string;
|
|
7
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
8
7
|
accessToken: string;
|
|
9
8
|
method: import("../../../platform-client.js").HttpMethods;
|
|
10
9
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
10
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
11
11
|
};
|
|
@@ -9,17 +9,17 @@ interface CaseContextParam {
|
|
|
9
9
|
export declare const buildInsightQueryRequest: (req: InsightQueryRequest) => {
|
|
10
10
|
requestParams: {};
|
|
11
11
|
url: string;
|
|
12
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
13
12
|
accessToken: string;
|
|
14
13
|
method: import("../../../platform-client.js").HttpMethods;
|
|
15
14
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
15
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
16
16
|
};
|
|
17
17
|
export declare const buildInsightQuerySuggestRequest: (req: InsightQuerySuggestRequest) => {
|
|
18
18
|
requestParams: {};
|
|
19
19
|
url: string;
|
|
20
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
21
20
|
accessToken: string;
|
|
22
21
|
method: import("../../../platform-client.js").HttpMethods;
|
|
23
22
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
23
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
|
@@ -11,9 +11,9 @@ export declare const buildInsightUserActionsRequest: (req: InsightUserActionsReq
|
|
|
11
11
|
objectId: string;
|
|
12
12
|
};
|
|
13
13
|
url: string;
|
|
14
|
-
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
15
14
|
accessToken: string;
|
|
16
15
|
method: import("../../../platform-client.js").HttpMethods;
|
|
17
16
|
contentType: import("../../../platform-client.js").HTTPContentType;
|
|
17
|
+
origin: import("../../../preprocess-request.js").PlatformClientOrigin;
|
|
18
18
|
};
|
|
19
19
|
export {};
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions to be used for Commerce Server Side Rendering.
|
|
3
3
|
*/
|
|
4
|
-
import { Action } from '@reduxjs/toolkit';
|
|
5
4
|
import type { Controller } from '../../controllers/controller/headless-controller.js';
|
|
5
|
+
import { CommerceEngineDefinitionOptions } from '../commerce-ssr-engine/factories/build-factory.js';
|
|
6
6
|
import { ControllerDefinitionsMap, SolutionType } from '../commerce-ssr-engine/types/common.js';
|
|
7
|
-
import { EngineDefinition
|
|
8
|
-
import {
|
|
9
|
-
/**
|
|
10
|
-
* The SSR commerce engine.
|
|
11
|
-
*/
|
|
12
|
-
export interface SSRCommerceEngine extends CommerceEngine {
|
|
13
|
-
/**
|
|
14
|
-
* Waits for the search to be completed and returns a promise that resolves to a `SearchCompletedAction`.
|
|
15
|
-
*/
|
|
16
|
-
waitForRequestCompletedAction(): Promise<Action>;
|
|
17
|
-
}
|
|
18
|
-
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<CommerceEngineOptions, TControllers>;
|
|
7
|
+
import { EngineDefinition } from '../commerce-ssr-engine/types/core-engine.js';
|
|
8
|
+
import { CommerceEngineOptions } from './commerce-engine.js';
|
|
19
9
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> extends EngineDefinition<TControllers, CommerceEngineOptions, TSolutionType> {
|
|
20
10
|
}
|
|
21
11
|
/**
|
|
@@ -28,4 +18,5 @@ export declare function defineCommerceEngine<TControllerDefinitions extends Cont
|
|
|
28
18
|
listingEngineDefinition: CommerceEngineDefinition<TControllerDefinitions, SolutionType.listing>;
|
|
29
19
|
searchEngineDefinition: CommerceEngineDefinition<TControllerDefinitions, SolutionType.search>;
|
|
30
20
|
standaloneEngineDefinition: CommerceEngineDefinition<TControllerDefinitions, SolutionType.standalone>;
|
|
21
|
+
recommendationEngineDefinition: CommerceEngineDefinition<TControllerDefinitions, SolutionType.recommendation>;
|
|
31
22
|
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { UnknownAction } from '@reduxjs/toolkit';
|
|
1
2
|
import { Controller } from '../../controllers/controller/headless-controller.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ControllerDefinitionOption, ControllerDefinitionsMap, InferControllersMapFromDefinition, SolutionType } from './types/common.js';
|
|
3
|
+
import { ControllersMap, InferControllerStaticStateMapFromControllers } from '../ssr-engine/types/common.js';
|
|
4
|
+
import { SSRCommerceEngine } from './factories/build-factory.js';
|
|
5
|
+
import { ControllerDefinitionOption, ControllerDefinitionsMap, EngineStaticState, InferControllerPropsMapFromDefinitions, InferControllersMapFromDefinition, SolutionType } from './types/common.js';
|
|
6
|
+
export declare function createStaticState<TSearchAction extends UnknownAction>({ searchActions, controllers, }: {
|
|
7
|
+
searchActions: TSearchAction[];
|
|
8
|
+
controllers: ControllersMap;
|
|
9
|
+
}): EngineStaticState<TSearchAction, InferControllerStaticStateMapFromControllers<ControllersMap>>;
|
|
5
10
|
export declare function buildControllerDefinitions<TControllerDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>({ definitionsMap, engine, solutionType, propsMap, }: {
|
|
6
11
|
definitionsMap: TControllerDefinitionsMap;
|
|
7
12
|
engine: SSRCommerceEngine;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Action } from '@reduxjs/toolkit';
|
|
2
|
+
import { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
+
import { CommerceEngine, CommerceEngineOptions } from '../../commerce-engine/commerce-engine.js';
|
|
4
|
+
import { ControllerDefinitionsMap, SolutionType } from '../types/common.js';
|
|
5
|
+
import { BuildParameters, CommerceControllerDefinitionsMap, EngineDefinitionOptions } from '../types/core-engine.js';
|
|
6
|
+
/**
|
|
7
|
+
* The SSR commerce engine.
|
|
8
|
+
*/
|
|
9
|
+
export interface SSRCommerceEngine extends CommerceEngine {
|
|
10
|
+
/**
|
|
11
|
+
* Waits for the request to be completed and returns a promise that resolves to an `Action`.
|
|
12
|
+
*/
|
|
13
|
+
waitForRequestCompletedAction(): Promise<Action>[];
|
|
14
|
+
}
|
|
15
|
+
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<CommerceEngineOptions, TControllers>;
|
|
16
|
+
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => <T extends SolutionType>(solutionType: T) => (...[buildOptions]: BuildParameters<TControllerDefinitions>) => Promise<{
|
|
17
|
+
engine: SSRCommerceEngine;
|
|
18
|
+
controllers: import("../types/common.js").InferControllersMapFromDefinition<TControllerDefinitions, T>;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SolutionType } from '../types/common.js';
|
|
2
|
+
import { HydrateStaticStateFunction, CommerceControllerDefinitionsMap } from '../types/core-engine.js';
|
|
3
|
+
import { CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
4
|
+
export declare const hydratedStaticStateFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => (solutionType: SolutionType) => HydrateStaticStateFunction<TControllerDefinitions>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { HydrateStaticStateFunction, CommerceControllerDefinitionsMap } from '../types/core-engine.js';
|
|
2
|
+
import { CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
3
|
+
export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): HydrateStaticStateFunction<TControllerDefinitions>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FetchStaticStateFunction, CommerceControllerDefinitionsMap } from '../types/core-engine.js';
|
|
2
|
+
import { CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
3
|
+
export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): FetchStaticStateFunction<TControllerDefinitions>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SolutionType } from '../types/common.js';
|
|
2
|
+
import { FetchStaticStateFunction, CommerceControllerDefinitionsMap } from '../types/core-engine.js';
|
|
3
|
+
import { CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
4
|
+
export declare const fetchStaticStateFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions | undefined, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => (solutionType: SolutionType) => FetchStaticStateFunction<TControllerDefinitions>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
|
+
import type { ControllersMap, ControllersPropsMap, EngineDefinitionBuildResult, OptionsExtender, OptionsTuple } from '../../ssr-engine/types/common.js';
|
|
3
|
+
import { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
4
|
+
import { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, SolutionType } from './common.js';
|
|
5
|
+
export interface BuildOptions<TEngineOptions> {
|
|
6
|
+
extend?: OptionsExtender<TEngineOptions>;
|
|
7
|
+
}
|
|
8
|
+
export type Build<TEngineOptions, TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
9
|
+
/**
|
|
10
|
+
* Initializes an engine and controllers from the definition.
|
|
11
|
+
*/
|
|
12
|
+
(...params: OptionsTuple<BuildOptions<TEngineOptions> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>): Promise<EngineDefinitionBuildResult<SSRCommerceEngine, TControllersMap>>;
|
|
13
|
+
};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import { UnknownAction } from '@reduxjs/toolkit';
|
|
1
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
3
|
import type { InvalidControllerDefinition } from '../../../utils/errors.js';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
export type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers,
|
|
4
|
+
import type { HasKey, InferControllerStaticStateMapFromControllers, InferControllerStaticStateFromController, ControllerStaticStateMap, EngineDefinitionBuildResult, HydratedState, OptionsTuple, ControllersPropsMap, HasKeys, HasRequiredKeys, HasOptionalKeys } from '../../ssr-engine/types/common.js';
|
|
5
|
+
import { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
6
|
+
export type { EngineDefinitionBuildResult, HydratedState, OptionsTuple, InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, };
|
|
6
7
|
export declare enum SolutionType {
|
|
7
8
|
search = "search",
|
|
8
9
|
listing = "listing",
|
|
9
|
-
standalone = "standalone"
|
|
10
|
+
standalone = "standalone",
|
|
11
|
+
recommendation = "recommendation"
|
|
10
12
|
}
|
|
13
|
+
export declare const recommendationInternalOptionKey: unique symbol;
|
|
14
|
+
export type RecommendationControllerSettings = {
|
|
15
|
+
/**
|
|
16
|
+
* Toggle to enable or disable the recommendation controller.
|
|
17
|
+
* When set to `true`, the controller will perform a recommendation request server-side.
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
};
|
|
11
23
|
export interface ControllerDefinitionWithoutProps<TController extends Controller> {
|
|
12
24
|
/**
|
|
13
25
|
* Creates an instance of the given controller.
|
|
@@ -29,11 +41,18 @@ export interface ControllerDefinitionWithProps<TController extends Controller, T
|
|
|
29
41
|
*/
|
|
30
42
|
buildWithProps(engine: SSRCommerceEngine, props: TProps, solutionType?: SolutionType): TController;
|
|
31
43
|
}
|
|
44
|
+
export interface EngineStaticState<TSearchAction extends UnknownAction, TControllers extends ControllerStaticStateMap> {
|
|
45
|
+
searchActions: TSearchAction[];
|
|
46
|
+
controllers: TControllers;
|
|
47
|
+
}
|
|
32
48
|
export type ControllerDefinition<TController extends Controller> = ControllerDefinitionWithoutProps<TController> | ControllerDefinitionWithProps<TController, unknown>;
|
|
33
49
|
export interface ControllerDefinitionsMap<TController extends Controller> {
|
|
34
50
|
[customName: string]: ControllerDefinition<TController>;
|
|
35
51
|
}
|
|
36
|
-
export type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ? Props : TController extends ControllerDefinitionWithoutProps<Controller> ? {} : unknown;
|
|
52
|
+
export type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ? HasKey<TController, typeof recommendationInternalOptionKey> extends never ? Props : Props & RecommendationControllerSettings : TController extends ControllerDefinitionWithoutProps<Controller> ? HasKey<TController, typeof recommendationInternalOptionKey> extends never ? {} : RecommendationControllerSettings : unknown;
|
|
53
|
+
export type InferControllerPropsMapFromDefinitions<TControllers extends ControllerDefinitionsMap<Controller>> = {
|
|
54
|
+
[K in keyof TControllers as HasKeys<InferControllerPropsFromDefinition<TControllers[K]>> extends false ? never : K]: InferControllerPropsFromDefinition<TControllers[K]>;
|
|
55
|
+
};
|
|
37
56
|
export type InferControllerFromDefinition<TDefinition extends ControllerDefinition<Controller>> = TDefinition extends ControllerDefinition<infer TController> ? TController : never;
|
|
38
57
|
export type InferControllersMapFromDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
39
58
|
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : K]: InferControllerFromDefinition<TControllers[K]>;
|
|
@@ -41,6 +60,123 @@ export type InferControllersMapFromDefinition<TControllers extends ControllerDef
|
|
|
41
60
|
export type InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
42
61
|
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : K]: InferControllerStaticStateFromController<InferControllerFromDefinition<TControllers[K]>>;
|
|
43
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* This type defines the required and optional controller props for the engine definition.
|
|
65
|
+
*/
|
|
66
|
+
export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = OptionalEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType> & RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
|
|
67
|
+
/**
|
|
68
|
+
* Represents an optional engine definition for controller properties.
|
|
69
|
+
*
|
|
70
|
+
* This type is used to define a map of optional controller properties based on the provided
|
|
71
|
+
* controller definitions, controller properties map, and solution type.
|
|
72
|
+
*
|
|
73
|
+
* @template TControllers - A map of controller definitions.
|
|
74
|
+
* @template TControllersPropsMap - A map of controller properties.
|
|
75
|
+
* @template TSolutionType - The type of solution.
|
|
76
|
+
*
|
|
77
|
+
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
78
|
+
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
79
|
+
* 2. The controller properties have optional options (HasOptionalKeys<ConditionalControllerProps<...>> is true).
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* Given the following controller definitions:
|
|
83
|
+
* ```
|
|
84
|
+
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
85
|
+
* controllers: {
|
|
86
|
+
* popularViewed: defineRecommendations({
|
|
87
|
+
* options: {slotId: 'slot-id'}
|
|
88
|
+
* })
|
|
89
|
+
* }
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* The following code will not throw an error since the 'popularViewed' controller props are optional
|
|
94
|
+
* ```
|
|
95
|
+
* recommendationEngineDefinition.fetchStaticState({
|
|
96
|
+
* controllers: {
|
|
97
|
+
* popularViewed: {enabled: true, productId: 'some-product-id'} // This is optional
|
|
98
|
+
* }
|
|
99
|
+
* })
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* The following code (with no arguments) is also valid because the 'popularViewed' controller props are optional, and there are no other required controller props in the engine definition.
|
|
103
|
+
* ```
|
|
104
|
+
* recommendationEngineDefinition.fetchStaticState()
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export type OptionalEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
108
|
+
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : HasOptionalKeys<ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>> extends false ? never : 'controllers']?: ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Represents a type that defines the required controller properties for engine definition controllers.
|
|
112
|
+
*
|
|
113
|
+
* @template TControllers - A map of controller definitions.
|
|
114
|
+
* @template TControllersPropsMap - A map of controller properties.
|
|
115
|
+
* @template TSolutionType - The type of solution being used.
|
|
116
|
+
*
|
|
117
|
+
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
118
|
+
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
119
|
+
* 2. The controller properties have required options (HasRequiredKeys<ConditionalControllerProps<...>> is true).
|
|
120
|
+
*
|
|
121
|
+
* The resulting type maps the valid keys to their corresponding conditional controller properties.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* Given the following controller definitions:
|
|
125
|
+
* ```
|
|
126
|
+
* const {standaloneEngineDefinition} = defineCommerceEngine({
|
|
127
|
+
* controllers: {cart: defineCart()},
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* The following code will not throw an error since the 'cart' controller props are required for the standalone engine definition:
|
|
132
|
+
* ```
|
|
133
|
+
* standaloneEngineDefinition.fetchStaticState({
|
|
134
|
+
* controllers: {
|
|
135
|
+
* cart: {initialState: {items: []}},
|
|
136
|
+
* },
|
|
137
|
+
* })
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
export type RequiredEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
142
|
+
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : HasRequiredKeys<ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>> extends false ? never : 'controllers']: ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>;
|
|
143
|
+
};
|
|
144
|
+
type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
145
|
+
/**
|
|
146
|
+
* This type ensures that recommendation controller props are optional, while other controller props remain required.
|
|
147
|
+
*
|
|
148
|
+
* It works by checking if the controller definition includes the `recommendationInternalOptionKey`.
|
|
149
|
+
*
|
|
150
|
+
* - If the key is present, the controller props are made optional.
|
|
151
|
+
* - If the key is absent, the controller props are required.
|
|
152
|
+
*
|
|
153
|
+
* Example:
|
|
154
|
+
*
|
|
155
|
+
* ```typescript
|
|
156
|
+
* type ControllerProps = InferControllerPropsFromDefinition<{
|
|
157
|
+
* recommendation: defineRecommendation({}),
|
|
158
|
+
* cart: defineCart(),
|
|
159
|
+
* }>;
|
|
160
|
+
*
|
|
161
|
+
* // In this example:
|
|
162
|
+
* // - The `recommendation` controller props are optional.
|
|
163
|
+
* // - The `cart` controller props are required.
|
|
164
|
+
*
|
|
165
|
+
* const props: ControllerProps = {
|
|
166
|
+
* cart: {initialState: {items: []}},
|
|
167
|
+
* // recommendation props can be omitted
|
|
168
|
+
* };
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
type RecommendationControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
172
|
+
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? never : I : never]?: TControllersPropsMap[I];
|
|
173
|
+
} & {
|
|
174
|
+
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? I : never : never]: TControllersPropsMap[I];
|
|
175
|
+
};
|
|
176
|
+
type DefaultControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
177
|
+
[I in keyof TControllersPropsMap as I extends K ? I : never]: TControllersPropsMap[I];
|
|
178
|
+
};
|
|
179
|
+
type ConditionalControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType, K extends keyof TControllers> = TSolutionType extends SolutionType.recommendation ? RecommendationControllerProps<TControllers, TControllersPropsMap, K> : DefaultControllerProps<TControllers, TControllersPropsMap, K>;
|
|
44
180
|
export interface ControllerDefinitionOption {
|
|
45
181
|
/**
|
|
46
182
|
* Whether the controller will be used in a product listing context.
|
|
@@ -53,6 +189,20 @@ export interface ControllerDefinitionOption {
|
|
|
53
189
|
*/
|
|
54
190
|
search?: boolean;
|
|
55
191
|
}
|
|
192
|
+
interface NonRecommendationController {
|
|
193
|
+
/**
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
[SolutionType.search]: true;
|
|
197
|
+
/**
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
[SolutionType.listing]: true;
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
[SolutionType.standalone]: true;
|
|
205
|
+
}
|
|
56
206
|
interface UniversalController {
|
|
57
207
|
/**
|
|
58
208
|
* @internal
|
|
@@ -66,6 +216,10 @@ interface UniversalController {
|
|
|
66
216
|
* @internal
|
|
67
217
|
*/
|
|
68
218
|
[SolutionType.standalone]: true;
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
[SolutionType.recommendation]: true;
|
|
69
223
|
}
|
|
70
224
|
interface SearchOnlyController {
|
|
71
225
|
/**
|
|
@@ -79,6 +233,12 @@ interface ListingOnlyController {
|
|
|
79
233
|
*/
|
|
80
234
|
[SolutionType.listing]: true;
|
|
81
235
|
}
|
|
236
|
+
interface RecommendationOnlyController {
|
|
237
|
+
/**
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
[SolutionType.recommendation]: true;
|
|
241
|
+
}
|
|
82
242
|
interface SearchAndListingController {
|
|
83
243
|
/**
|
|
84
244
|
* @internal
|
|
@@ -89,10 +249,25 @@ interface SearchAndListingController {
|
|
|
89
249
|
*/
|
|
90
250
|
[SolutionType.listing]: true;
|
|
91
251
|
}
|
|
252
|
+
interface ListingAndStandaloneController {
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
[SolutionType.listing]: true;
|
|
257
|
+
/**
|
|
258
|
+
* @internal
|
|
259
|
+
*/
|
|
260
|
+
[SolutionType.standalone]: true;
|
|
261
|
+
}
|
|
92
262
|
export type SearchOnlyControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & SearchOnlyController;
|
|
93
263
|
export type SearchOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & SearchOnlyController;
|
|
264
|
+
export type ListingAndStandaloneControllerWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & ListingAndStandaloneController;
|
|
94
265
|
export type ListingOnlyControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & ListingOnlyController;
|
|
95
266
|
export type ListingOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & ListingOnlyController;
|
|
267
|
+
export type RecommendationOnlyControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & RecommendationOnlyController;
|
|
268
|
+
export type RecommendationOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & RecommendationOnlyController;
|
|
269
|
+
export type NonRecommendationControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & NonRecommendationController;
|
|
270
|
+
export type NonRecommendationControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & NonRecommendationController;
|
|
96
271
|
export type UniversalControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & UniversalController;
|
|
97
272
|
export type UniversalControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & UniversalController;
|
|
98
273
|
export type SearchAndListingControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & SearchAndListingController;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
-
import {
|
|
3
|
+
import { CommerceEngineDefinition } from '../../commerce-engine/commerce-engine.ssr.js';
|
|
4
4
|
import { EngineConfiguration } from '../../engine-configuration.js';
|
|
5
5
|
import { NavigatorContextProvider } from '../../navigatorContextProvider.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
6
|
+
import type { FromBuildResultOptions } from '../../ssr-engine/types/from-build-result.js';
|
|
7
|
+
import { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
8
|
+
import { Build, BuildOptions } from './build.js';
|
|
9
|
+
import { ControllerDefinitionsMap, InferControllersMapFromDefinition, SolutionType, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllerPropsMapFromDefinitions } from './common.js';
|
|
10
|
+
import { FetchStaticState, FetchStaticStateOptions } from './fetch-static-state.js';
|
|
11
|
+
import { FromBuildResult } from './from-build-result.js';
|
|
12
|
+
import { HydrateStaticState, HydrateStaticStateOptions } from './hydrate-static-state.js';
|
|
13
|
+
export type { FromBuildResult, FromBuildResultOptions, HydrateStaticState, HydrateStaticStateOptions, FetchStaticState, FetchStaticStateOptions, Build, BuildOptions, };
|
|
12
14
|
export type EngineDefinitionOptions<TOptions extends {
|
|
13
15
|
configuration: EngineConfiguration;
|
|
14
16
|
}, TControllers extends ControllerDefinitionsMap<Controller>> = TOptions & {
|
|
@@ -21,15 +23,15 @@ export interface EngineDefinition<TControllers extends ControllerDefinitionsMap<
|
|
|
21
23
|
/**
|
|
22
24
|
* Fetches the static state on the server side using your engine definition.
|
|
23
25
|
*/
|
|
24
|
-
fetchStaticState: FetchStaticState<
|
|
26
|
+
fetchStaticState: FetchStaticState<InferControllersMapFromDefinition<TControllers, TSolutionType>, UnknownAction, InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllers, TSolutionType>, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
25
27
|
/**
|
|
26
28
|
* Fetches the hydrated state on the client side using your engine definition and the static state.
|
|
27
29
|
*/
|
|
28
|
-
hydrateStaticState: HydrateStaticState<
|
|
30
|
+
hydrateStaticState: HydrateStaticState<InferControllersMapFromDefinition<TControllers, TSolutionType>, UnknownAction, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
29
31
|
/**
|
|
30
32
|
* Builds an engine and its controllers from an engine definition.
|
|
31
33
|
*/
|
|
32
|
-
build: Build<
|
|
34
|
+
build: Build<TEngineOptions, InferControllersMapFromDefinition<TControllers, TSolutionType>, InferControllerPropsMapFromDefinitions<TControllers>, TControllers, TSolutionType>;
|
|
33
35
|
/**
|
|
34
36
|
* Sets the navigator context provider.
|
|
35
37
|
* 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.
|
|
@@ -47,3 +49,20 @@ export type InferHydratedState<T extends {
|
|
|
47
49
|
export type InferBuildResult<T extends {
|
|
48
50
|
build(...args: unknown[]): Promise<unknown>;
|
|
49
51
|
}> = Awaited<ReturnType<T['build']>>;
|
|
52
|
+
export type CommerceControllerDefinitionsMap = ControllerDefinitionsMap<Controller>;
|
|
53
|
+
type Definition<TControllerDefinitions extends CommerceControllerDefinitionsMap> = CommerceEngineDefinition<TControllerDefinitions, SolutionType>;
|
|
54
|
+
export type BuildFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['build'];
|
|
55
|
+
export type FetchStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['fetchStaticState'];
|
|
56
|
+
export type HydrateStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['hydrateStaticState'];
|
|
57
|
+
export type FetchStaticStateFromBuildResultFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = FetchStaticStateFunction<TControllerDefinitions>['fromBuildResult'];
|
|
58
|
+
export type HydrateStaticStateFromBuildResultFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = HydrateStaticStateFunction<TControllerDefinitions>['fromBuildResult'];
|
|
59
|
+
export type BuildParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<BuildFunction<TControllerDefinitions>>;
|
|
60
|
+
export type FetchStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<FetchStaticStateFunction<TControllerDefinitions>>;
|
|
61
|
+
export type HydrateStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<HydrateStaticStateFunction<TControllerDefinitions>>;
|
|
62
|
+
export type FetchStaticStateFromBuildResultParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<FetchStaticStateFromBuildResultFunction<TControllerDefinitions>>;
|
|
63
|
+
export type HydrateStaticStateFromBuildResultParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<HydrateStaticStateFromBuildResultFunction<TControllerDefinitions>>;
|
|
64
|
+
export type Controllers<TControllerDefinitions extends CommerceControllerDefinitionsMap> = InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>;
|
|
65
|
+
export type BuildResult<TControllerDefinitions extends CommerceControllerDefinitionsMap> = {
|
|
66
|
+
engine: SSRCommerceEngine;
|
|
67
|
+
controllers: Controllers<TControllerDefinitions>;
|
|
68
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
+
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, EngineStaticState, SolutionType } from '../../commerce-ssr-engine/types/common.js';
|
|
4
|
+
import type { ControllersMap, ControllersPropsMap, ControllerStaticStateMap, OptionsTuple } from '../../ssr-engine/types/common.js';
|
|
5
|
+
import { FromBuildResult } from './from-build-result.js';
|
|
6
|
+
export type FetchStaticStateOptions = {};
|
|
7
|
+
export type FetchStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
8
|
+
/**
|
|
9
|
+
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
10
|
+
*
|
|
11
|
+
* Useful for static generation and server-side rendering.
|
|
12
|
+
*/
|
|
13
|
+
(...params: OptionsTuple<FetchStaticStateOptions & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>): Promise<EngineStaticState<TSearchAction, TControllersStaticState>>;
|
|
14
|
+
fromBuildResult: FromBuildResult<TControllers, FetchStaticStateOptions, EngineStaticState<TSearchAction, TControllersStaticState>>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ControllersMap } from '../../ssr-engine/types/common.js';
|
|
2
|
+
import { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
3
|
+
import { EngineDefinitionBuildResult } from './common.js';
|
|
4
|
+
export interface FromBuildResultOptions<TControllers extends ControllersMap> {
|
|
5
|
+
/**
|
|
6
|
+
* The build result of the engine
|
|
7
|
+
*/
|
|
8
|
+
buildResult: EngineDefinitionBuildResult<SSRCommerceEngine, TControllers>;
|
|
9
|
+
/**
|
|
10
|
+
* An optional array of keys representing the recommendation controllers to refresh.
|
|
11
|
+
* If a recommendation key defined in your engine definition is present in this list, the associate recommendation controller
|
|
12
|
+
* will query the API.
|
|
13
|
+
*
|
|
14
|
+
* This is applicable only if the engine is a recommendation engine.
|
|
15
|
+
*/
|
|
16
|
+
allowedRecommendationKeys?: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface FromBuildResult<TControllers extends ControllersMap, TOptions, TReturn> {
|
|
19
|
+
(options: FromBuildResultOptions<TControllers> & TOptions): Promise<TReturn>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
+
import type { ControllersMap, ControllersPropsMap, HydratedState, OptionsTuple } from '../../ssr-engine/types/common.js';
|
|
4
|
+
import { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
5
|
+
import { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, SolutionType } from './common.js';
|
|
6
|
+
import { FromBuildResult } from './from-build-result.js';
|
|
7
|
+
export interface HydrateStaticStateOptions<TSearchAction> {
|
|
8
|
+
searchActions: TSearchAction[];
|
|
9
|
+
}
|
|
10
|
+
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new engine from the snapshot of the engine created in SSR with fetchStaticState.
|
|
13
|
+
*
|
|
14
|
+
* Useful when hydrating a server-side-rendered engine.
|
|
15
|
+
*/
|
|
16
|
+
(...params: OptionsTuple<HydrateStaticStateOptions<TSearchAction> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>): Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
17
|
+
fromBuildResult: FromBuildResult<TControllers, HydrateStaticStateOptions<TSearchAction>, HydratedState<SSRCommerceEngine, TControllers>>;
|
|
18
|
+
};
|
|
@@ -11,4 +11,4 @@ export interface LoggerOptions {
|
|
|
11
11
|
*/
|
|
12
12
|
logFormatter?: (object: {}) => {};
|
|
13
13
|
}
|
|
14
|
-
export declare function buildLogger(options: LoggerOptions | undefined): import("pino").Logger<never>;
|
|
14
|
+
export declare function buildLogger(options: LoggerOptions | undefined): import("pino").Logger<never, boolean>;
|