@coveo/headless 3.29.0-pre.032a5300a8 → 3.29.0-pre.075377ce6d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/case-assist/headless.cjs +1 -1
- package/dist/cjs/commerce/headless.cjs +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce-next/node.cjs.stats.json +1 -1
- package/dist/cjs/ssr-next/headless.cjs +1 -1
- package/dist/definitions/ssr/commerce/types/fetch-static-state.d.ts +4 -0
- package/dist/definitions/ssr/common/types/build.d.ts +3 -0
- package/dist/definitions/ssr/common/types/engine.d.ts +3 -0
- package/dist/definitions/ssr-commerce-next.index.d.ts +3 -3
- package/dist/definitions/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.d.ts +8 -4
- package/dist/definitions/ssr-next/commerce/factories/build-factory.d.ts +4 -3
- package/dist/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +2 -1
- package/dist/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts +1 -1
- package/dist/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts +2 -1
- package/dist/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +2 -1
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +73 -7
- package/dist/definitions/ssr-next/commerce/types/controller-definitions.d.ts +35 -112
- package/dist/definitions/ssr-next/commerce/types/controller-inference.d.ts +3 -3
- package/dist/definitions/ssr-next/commerce/types/engine.d.ts +15 -8
- package/dist/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +3 -3
- package/dist/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +2 -1
- package/dist/definitions/ssr-next/commerce/types/utilities.d.ts +6 -0
- package/dist/definitions/ssr-next/commerce/utils/controller-wiring.d.ts +35 -0
- package/dist/definitions/ssr-next/commerce/utils/engine-wiring.d.ts +5 -0
- package/dist/definitions/ssr-next/commerce/utils/recommendation-filter.d.ts +14 -1
- package/dist/definitions/ssr-next/commerce/validation/controller-validation.d.ts +1 -0
- package/dist/definitions/ssr-next/common/types/fetch-static-state.d.ts +1 -3
- package/dist/definitions/ssr-next/common/types/utilities.d.ts +0 -3
- package/dist/definitions/test/mock-ssr-controller-definitions.d.ts +12 -0
- package/dist/esm/ssr/commerce/types/kind.js +1 -0
- package/dist/esm/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.js +1 -1
- package/dist/esm/ssr-next/commerce/engine/commerce-engine.ssr.js +15 -4
- package/dist/esm/ssr-next/commerce/factories/build-factory.js +13 -18
- package/dist/esm/ssr-next/commerce/factories/hydrated-state-factory.js +1 -3
- package/dist/esm/ssr-next/commerce/factories/recommendation-static-state-factory.js +6 -10
- package/dist/esm/ssr-next/commerce/factories/static-state-factory.js +5 -4
- package/dist/esm/ssr-next/commerce/types/utilities.js +1 -0
- package/dist/esm/ssr-next/commerce/utils/controller-wiring.js +153 -0
- package/dist/esm/ssr-next/commerce/utils/engine-wiring.js +10 -0
- package/dist/esm/ssr-next/commerce/utils/recommendation-filter.js +27 -8
- package/dist/esm/ssr-next/commerce/validation/controller-validation.js +7 -0
- package/dist/esm/test/mock-ssr-controller-definitions.js +15 -0
- package/dist/esm/utils/version.js +1 -1
- package/dist/quantic/case-assist/headless.js +1 -1
- package/dist/quantic/commerce/headless.js +1 -1
- package/dist/quantic/headless.js +1 -1
- package/dist/quantic/insight/headless.js +1 -1
- package/dist/quantic/recommendation/headless.js +1 -1
- package/package.json +1 -1
|
@@ -1306,7 +1306,7 @@ var import_toolkit2 = require("@reduxjs/toolkit");
|
|
|
1306
1306
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1307
1307
|
|
|
1308
1308
|
// src/utils/version.ts
|
|
1309
|
-
var VERSION = "3.29.0-pre.
|
|
1309
|
+
var VERSION = "3.29.0-pre.075377ce6d";
|
|
1310
1310
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1311
1311
|
|
|
1312
1312
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -5,6 +5,10 @@ import type { SolutionType } from './controller-constants.js';
|
|
|
5
5
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
6
6
|
import type { EngineStaticState } from './engine.js';
|
|
7
7
|
import type { FromBuildResult } from './from-build-result.js';
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This interface will be remove on the next major version.
|
|
10
|
+
* Use BuildConfig interface instead
|
|
11
|
+
*/
|
|
8
12
|
export type FetchStaticStateOptions = {};
|
|
9
13
|
export type FetchStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = {
|
|
10
14
|
/**
|
|
@@ -3,6 +3,9 @@ import type { ControllersMap, ControllersPropsMap } from './controllers.js';
|
|
|
3
3
|
import type { EngineDefinitionBuildResult, EngineDefinitionControllersPropsOption } from './engine.js';
|
|
4
4
|
import type { OptionsExtender, OptionsTuple } from './utilities.js';
|
|
5
5
|
interface BuildOptions<TEngineOptions> {
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated This option will be removed in the next major version.
|
|
8
|
+
*/
|
|
6
9
|
extend?: OptionsExtender<TEngineOptions>;
|
|
7
10
|
}
|
|
8
11
|
export type Build<TEngine extends CoreEngine | CoreEngineNext, TEngineOptions, TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap> = (...params: OptionsTuple<BuildOptions<TEngineOptions> & EngineDefinitionControllersPropsOption<TControllersProps>>) => Promise<EngineDefinitionBuildResult<TEngine, TControllersMap>>;
|
|
@@ -38,6 +38,9 @@ export interface EngineDefinition<TEngine extends CoreEngine | CoreEngineNext, T
|
|
|
38
38
|
*/
|
|
39
39
|
build: Build<TEngine, TEngineOptions, InferControllersMapFromDefinition<TControllers>, InferControllerPropsMapFromDefinitions<TControllers>>;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use SearchEngineDefinitionBuildResult or CommerceEngineDefinitionBuildResult instead
|
|
43
|
+
*/
|
|
41
44
|
export interface EngineDefinitionBuildResult<TEngine extends CoreEngine | CoreEngineNext, TControllers extends ControllersMap> {
|
|
42
45
|
engine: TEngine;
|
|
43
46
|
controllers: TControllers;
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
*/
|
|
69
69
|
export type { Relay } from '@coveo/relay';
|
|
70
70
|
export type { Middleware, Unsubscribe } from '@reduxjs/toolkit';
|
|
71
|
-
export type { CommerceEngineOptions } from './app/commerce-engine/commerce-engine.js';
|
|
72
71
|
export type { CommerceEngineConfiguration } from './app/commerce-engine/commerce-engine-configuration.js';
|
|
73
72
|
export { getSampleCommerceEngineConfiguration } from './app/commerce-engine/commerce-engine-configuration.js';
|
|
74
73
|
export type { CoreEngineNext, ExternalEngineOptions } from './app/engine.js';
|
|
@@ -119,10 +118,11 @@ export type { RedirectionTrigger, RedirectionTriggerDefinition, RedirectionTrigg
|
|
|
119
118
|
export { defineRedirectionTrigger } from './ssr-next/commerce/controllers/triggers/headless-redirection-trigger.ssr.js';
|
|
120
119
|
export { defineCommerceEngine } from './ssr-next/commerce/engine/commerce-engine.ssr.js';
|
|
121
120
|
export type { CommerceEngineDefinitionOptions, SSRCommerceEngine as CommerceEngine, } from './ssr-next/commerce/factories/build-factory.js';
|
|
121
|
+
export type { BuildConfig, SSRCommerceEngineOptions, } from './ssr-next/commerce/types/build.js';
|
|
122
122
|
export { SolutionType } from './ssr-next/commerce/types/controller-constants.js';
|
|
123
|
-
export type { ControllerDefinition, ControllerDefinitionsMap, ControllerWithKind,
|
|
123
|
+
export type { ControllerDefinition, ControllerDefinitionsMap, ControllerWithKind, EngineDefinitionControllersPropsOption, HydratedState, InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, OptionsTuple, } from './ssr-next/commerce/types/controller-definitions.js';
|
|
124
124
|
export type { InferControllerFromDefinition, InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition, InferHydratedState, InferStaticState, } from './ssr-next/commerce/types/controller-inference.js';
|
|
125
|
-
export type { CommerceEngineDefinition, EngineStaticState, FetchStaticState,
|
|
125
|
+
export type { CommerceEngineDefinition, CommerceEngineDefinitionBuildResult, EngineStaticState, FetchStaticState, HydrateStaticState, HydrateStaticStateOptions, } from './ssr-next/commerce/types/engine.js';
|
|
126
126
|
export { Kind } from './ssr-next/commerce/types/kind.js';
|
|
127
127
|
export type { CommerceAppState, CommerceProductListingParametersState, CommerceSearchParametersState, } from './state/commerce-app-state.js';
|
|
128
128
|
export * from './features/commerce/configuration/configuration-actions-loader.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type Recommendations, type RecommendationsOptions, type
|
|
1
|
+
import { type Recommendations, type RecommendationsOptions, type RecommendationsState } from '../../../../controllers/commerce/recommendations/headless-recommendations.js';
|
|
2
2
|
import { recommendationInternalOptionKey } from '../../types/controller-constants.js';
|
|
3
3
|
import type { RecommendationOnlyControllerDefinitionWithProps } from '../../types/controller-definitions.js';
|
|
4
4
|
export type { Recommendations, RecommendationsState };
|
|
5
5
|
export type RecommendationsDefinitionMeta = {
|
|
6
|
-
[recommendationInternalOptionKey]: {} &
|
|
6
|
+
[recommendationInternalOptionKey]: {} & RecommendationsOptions;
|
|
7
7
|
};
|
|
8
|
-
export interface RecommendationsDefinition extends RecommendationOnlyControllerDefinitionWithProps<Recommendations,
|
|
8
|
+
export interface RecommendationsDefinition extends RecommendationOnlyControllerDefinitionWithProps<Recommendations, {
|
|
9
|
+
initialState: Partial<RecommendationsOptions>;
|
|
10
|
+
}> {
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Defines a `Recommendations` controller instance.
|
|
@@ -14,4 +16,6 @@ export interface RecommendationsDefinition extends RecommendationOnlyControllerD
|
|
|
14
16
|
* @param props - The configurable `Recommendations` properties.
|
|
15
17
|
* @returns The `Recommendations` controller definition.
|
|
16
18
|
* */
|
|
17
|
-
export declare function defineRecommendations(props:
|
|
19
|
+
export declare function defineRecommendations(props: {
|
|
20
|
+
options: Omit<RecommendationsOptions, 'productId'>;
|
|
21
|
+
}): RecommendationsDefinition & RecommendationsDefinitionMeta;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Action } from '@reduxjs/toolkit';
|
|
2
|
-
import { type CommerceEngine
|
|
2
|
+
import { type CommerceEngine } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
3
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
4
|
+
import type { SSRCommerceEngineOptions } from '../types/build.js';
|
|
4
5
|
import { SolutionType } from '../types/controller-constants.js';
|
|
5
6
|
import type { ControllerDefinitionsMap } from '../types/controller-definitions.js';
|
|
6
7
|
import type { BuildParameters, CommerceControllerDefinitionsMap, EngineDefinitionOptions } from '../types/engine.js';
|
|
@@ -15,8 +16,8 @@ export interface SSRCommerceEngine extends CommerceEngine {
|
|
|
15
16
|
*/
|
|
16
17
|
waitForRequestCompletedAction(): Promise<Action>[];
|
|
17
18
|
}
|
|
18
|
-
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<
|
|
19
|
-
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
19
|
+
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<SSRCommerceEngineOptions, TControllers>;
|
|
20
|
+
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => <T extends SolutionType>(solutionType: T) => (...[buildOptions]: BuildParameters<TControllerDefinitions>) => Promise<{
|
|
20
21
|
engine: SSRCommerceEngine;
|
|
21
22
|
controllers: import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions, T>;
|
|
22
23
|
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SolutionType } from '../types/controller-constants.js';
|
|
2
|
+
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
2
3
|
import type { CommerceControllerDefinitionsMap, HydrateStaticStateFunction } from '../types/engine.js';
|
|
3
4
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
4
|
-
export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
5
|
+
export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType: SolutionType) => HydrateStaticStateFunction<TControllerDefinitions>;
|
package/dist/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommerceControllerDefinitionsMap, HydrateStaticStateFunction } from '../types/engine.js';
|
|
2
2
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
3
|
-
export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
3
|
+
export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): HydrateStaticStateFunction<TControllerDefinitions>;
|
package/dist/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
1
2
|
import type { CommerceControllerDefinitionsMap, FetchStaticStateFunction } from '../types/engine.js';
|
|
2
3
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
3
|
-
export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
4
|
+
export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): FetchStaticStateFunction<TControllerDefinitions>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SolutionType } from '../types/controller-constants.js';
|
|
2
|
+
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
2
3
|
import type { CommerceControllerDefinitionsMap, FetchStaticStateFunction } from '../types/engine.js';
|
|
3
4
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
4
|
-
export declare function fetchStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
5
|
+
export declare function fetchStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType: SolutionType) => FetchStaticStateFunction<TControllerDefinitions>;
|
|
@@ -1,14 +1,80 @@
|
|
|
1
|
+
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
1
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
4
|
+
import type { HasKey, OptionsTuple } from '../../common/types/utilities.js';
|
|
5
|
+
import type { CartInitialState } from '../controllers/cart/headless-cart.ssr.js';
|
|
6
|
+
import type { ContextOptions } from '../controllers/context/headless-context.ssr.js';
|
|
7
|
+
import type { ParameterManagerState, Parameters } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
5
8
|
import type { SolutionType } from './controller-constants.js';
|
|
6
|
-
import type { ControllerDefinitionsMap,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, IsRecommendationController } from './controller-definitions.js';
|
|
10
|
+
import type { CommerceEngineDefinitionBuildResult } from './engine.js';
|
|
11
|
+
export interface SearchBuildConfig extends CommonBuildConfig {
|
|
12
|
+
searchParams: ParameterManagerState<Parameters & {
|
|
13
|
+
query: string;
|
|
14
|
+
}>['parameters'];
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The `RecommendationBuildConfig` type defines the shape of the configuration object required when fetching static state for recommendations.
|
|
18
|
+
*
|
|
19
|
+
* The `recommendations` property is a string array containing the names of the recommendation controllers
|
|
20
|
+
* that were defined in your engine definition. This allows you to specify which recommendation controllers
|
|
21
|
+
* should be included in the SSR request.
|
|
22
|
+
*
|
|
23
|
+
* For example, on a storefront homepage, it might make sense to display a carousel of popular products.
|
|
24
|
+
* However, showing recommendations based on items frequently bought together may not be relevant in that context and should not be retrieved unnecessarily.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* Given the following engine definition:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
31
|
+
* controllers: {
|
|
32
|
+
* popularProducts: defineRecommendations({options: {slotId: '...'}}),
|
|
33
|
+
* frequentlyBought: defineRecommendations({options: {slotId: '...'}}),
|
|
34
|
+
* // ...other controllers
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // When fetching static state for recommendations:
|
|
39
|
+
* const staticState = await recommendationEngineDefinition.fetchStaticState({
|
|
40
|
+
* recommendations: ['popularProducts'],
|
|
41
|
+
* // ...other config
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* In this example, only the `popularProducts` recommendation controller will be included in the SSR request.
|
|
46
|
+
*/
|
|
47
|
+
export type RecommendationBuildConfig<TControllers extends ControllerDefinitionsMap<Controller>> = CommonBuildConfig & {
|
|
48
|
+
/**
|
|
49
|
+
* The unique identifier of the product to use for seeded recommendations.
|
|
50
|
+
*/
|
|
51
|
+
productId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* An array of recommendation controller names from your engine definition to include in the SSR request.
|
|
54
|
+
* Each name corresponds to a key used when defining recommendation controllers in your engine definition.
|
|
55
|
+
* If not specified, no recommendation requests will be executed.
|
|
56
|
+
*/
|
|
57
|
+
recommendations: Array<Extract<keyof TControllers, {
|
|
58
|
+
[K in keyof TControllers]: HasKey<TControllers[K], SolutionType.recommendation> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? never : K;
|
|
59
|
+
}[keyof TControllers]>>;
|
|
60
|
+
};
|
|
61
|
+
export interface ListingBuildConfig extends CommonBuildConfig {
|
|
62
|
+
}
|
|
63
|
+
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
64
|
+
}
|
|
65
|
+
export interface CommonBuildConfig {
|
|
66
|
+
context: ContextOptions;
|
|
67
|
+
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
68
|
+
cart?: CartInitialState;
|
|
69
|
+
}
|
|
70
|
+
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;
|
|
71
|
+
/**
|
|
72
|
+
* Commerce engine options for SSR scenarios where context is defined when fetching static state.
|
|
73
|
+
*/
|
|
74
|
+
export type SSRCommerceEngineOptions = Omit<CommerceEngineOptions, 'configuration'> & {
|
|
75
|
+
configuration: Omit<CommerceEngineOptions['configuration'], 'context'>;
|
|
76
|
+
};
|
|
10
77
|
/**
|
|
11
78
|
* @internal
|
|
12
79
|
*/
|
|
13
|
-
export type Build<
|
|
14
|
-
export {};
|
|
80
|
+
export type Build<TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TControllersDefinitionsMap, TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<CommerceEngineDefinitionBuildResult<TControllersMap>>;
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
2
|
import type { InvalidControllerDefinition } from '../../common/errors.js';
|
|
3
3
|
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
|
-
import type { EngineDefinitionBuildResult } from '../../common/types/engine.js';
|
|
5
4
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
6
5
|
import type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers } from '../../common/types/inference.js';
|
|
7
|
-
import type { HasKey,
|
|
6
|
+
import type { HasKey, HasRequiredKeys, OptionsTuple } from '../../common/types/utilities.js';
|
|
7
|
+
import type { CartDefinition } from '../controllers/cart/headless-cart.ssr.js';
|
|
8
|
+
import type { ContextDefinition } from '../controllers/context/headless-context.ssr.js';
|
|
9
|
+
import type { ParameterManagerDefinition } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
8
10
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
9
11
|
import { type recommendationInternalOptionKey, SolutionType } from './controller-constants.js';
|
|
10
12
|
import type { ListingAndStandaloneController, ListingOnlyController, NonRecommendationController, RecommendationOnlyController, SearchAndListingController, SearchOnlyController, UniversalController } from './controller-scopes.js';
|
|
11
13
|
import type { Kind } from './kind.js';
|
|
12
|
-
|
|
13
|
-
export type
|
|
14
|
-
/**
|
|
15
|
-
* Toggle to enable or disable the recommendation controller.
|
|
16
|
-
* When set to `true`, the controller will perform a recommendation request server-side.
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
enabled?: boolean;
|
|
21
|
-
};
|
|
14
|
+
import type { HasSolutionType } from './utilities.js';
|
|
15
|
+
export type { HydratedState, OptionsTuple, InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, };
|
|
22
16
|
export interface ControllerDefinitionWithoutProps<TController extends Controller> {
|
|
23
17
|
/**
|
|
24
18
|
* Creates an instance of the given controller.
|
|
@@ -53,123 +47,52 @@ export type ControllerDefinition<TController extends Controller> = SolutionTypeA
|
|
|
53
47
|
export interface ControllerDefinitionsMap<TController extends Controller> {
|
|
54
48
|
[customName: string]: ControllerDefinition<TController>;
|
|
55
49
|
}
|
|
50
|
+
type BakedInControllerDefinitions = {
|
|
51
|
+
parameterManager: ParameterManagerDefinition<{
|
|
52
|
+
listing: true;
|
|
53
|
+
search: true;
|
|
54
|
+
}>;
|
|
55
|
+
context: ContextDefinition;
|
|
56
|
+
cart: CartDefinition;
|
|
57
|
+
};
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
59
|
+
* Map of baked-in controllers
|
|
58
60
|
*/
|
|
59
|
-
export type
|
|
61
|
+
export type BakedInControllers = {
|
|
62
|
+
[K in keyof BakedInControllerDefinitions]: BakedInControllerDefinitions[K]['buildWithProps'];
|
|
63
|
+
};
|
|
60
64
|
/**
|
|
61
|
-
*
|
|
65
|
+
* A dynamically filtered map of baked-in controller definitions based on solution type compatibility.
|
|
62
66
|
*
|
|
63
|
-
* This type
|
|
64
|
-
*
|
|
67
|
+
* This type automatically includes only the baked-in controllers that are available for the specified
|
|
68
|
+
* solution type by checking each controller's `SolutionTypeAvailability` configuration. Controllers
|
|
69
|
+
* that don't support the given solution type are excluded from the resulting type.
|
|
65
70
|
*
|
|
66
|
-
* @template
|
|
67
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
68
|
-
* @template TSolutionType - The type of solution.
|
|
69
|
-
*
|
|
70
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
71
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
72
|
-
* 2. The controller properties have optional options (HasOptionalKeys<ConditionalControllerProps<...>> is true).
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* Given the following controller definitions:
|
|
76
|
-
* ```
|
|
77
|
-
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
78
|
-
* controllers: {
|
|
79
|
-
* popularViewed: defineRecommendations({
|
|
80
|
-
* options: {slotId: 'slot-id'}
|
|
81
|
-
* })
|
|
82
|
-
* }
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* The following code will not throw an error since the 'popularViewed' controller props are optional
|
|
87
|
-
* ```
|
|
88
|
-
* recommendationEngineDefinition.fetchStaticState({
|
|
89
|
-
* controllers: {
|
|
90
|
-
* popularViewed: {enabled: true, productId: 'some-product-id'} // This is optional
|
|
91
|
-
* }
|
|
92
|
-
* })
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* 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.
|
|
96
|
-
* ```
|
|
97
|
-
* recommendationEngineDefinition.fetchStaticState()
|
|
98
|
-
* ```
|
|
71
|
+
* @template TSolutionType - The target solution type to filter controllers for
|
|
99
72
|
*/
|
|
100
|
-
type
|
|
101
|
-
[K in keyof
|
|
73
|
+
export type FilteredBakedInControllers<TSolutionType extends SolutionType> = {
|
|
74
|
+
[K in keyof BakedInControllers as HasSolutionType<BakedInControllerDefinitions[K], TSolutionType> extends true ? K : never]: BakedInControllers[K];
|
|
102
75
|
};
|
|
103
76
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* @template TControllers - A map of controller definitions.
|
|
107
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
108
|
-
* @template TSolutionType - The type of solution being used.
|
|
109
|
-
*
|
|
110
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
111
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
112
|
-
* 2. The controller properties have required options (HasRequiredKeys<ConditionalControllerProps<...>> is true).
|
|
77
|
+
* Map of controller definitions available to the commerce engine definition.
|
|
113
78
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* Given the following controller definitions:
|
|
118
|
-
* ```
|
|
119
|
-
* const {standaloneEngineDefinition} = defineCommerceEngine({
|
|
120
|
-
* controllers: {cart: defineCart()},
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* The following code will not throw an error since the 'cart' controller props are required for the standalone engine definition:
|
|
125
|
-
* ```
|
|
126
|
-
* standaloneEngineDefinition.fetchStaticState({
|
|
127
|
-
* controllers: {
|
|
128
|
-
* cart: {initialState: {items: []}},
|
|
129
|
-
* },
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
79
|
+
* This type combines user-defined controllers with the system's baked-in controllers
|
|
80
|
+
* (parameterManager, context, and cart).
|
|
132
81
|
*
|
|
82
|
+
* @template TControllerDefinitions - The controller definitions map
|
|
133
83
|
*/
|
|
134
|
-
type
|
|
135
|
-
[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>;
|
|
136
|
-
};
|
|
137
|
-
type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
84
|
+
export type AugmentedControllerDefinition<TControllerDefinitions extends ControllerDefinitionsMap<Controller>> = TControllerDefinitions & BakedInControllerDefinitions;
|
|
138
85
|
/**
|
|
139
|
-
* This type
|
|
140
|
-
*
|
|
141
|
-
* It works by checking if the controller definition includes the `recommendationInternalOptionKey`.
|
|
142
|
-
*
|
|
143
|
-
* - If the key is present, the controller props are made optional.
|
|
144
|
-
* - If the key is absent, the controller props are required.
|
|
145
|
-
*
|
|
146
|
-
* Example:
|
|
147
|
-
*
|
|
148
|
-
* ```typescript
|
|
149
|
-
* type ControllerProps = InferControllerPropsFromDefinition<{
|
|
150
|
-
* recommendation: defineRecommendation({}),
|
|
151
|
-
* cart: defineCart(),
|
|
152
|
-
* }>;
|
|
153
|
-
*
|
|
154
|
-
* // In this example:
|
|
155
|
-
* // - The `recommendation` controller props are optional.
|
|
156
|
-
* // - The `cart` controller props are required.
|
|
157
|
-
*
|
|
158
|
-
* const props: ControllerProps = {
|
|
159
|
-
* cart: {initialState: {items: []}},
|
|
160
|
-
* // recommendation props can be omitted
|
|
161
|
-
* };
|
|
162
|
-
* ```
|
|
86
|
+
* This type defines the required and optional controller props for the engine definition.
|
|
163
87
|
*/
|
|
164
|
-
type
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? I : never : never]: TControllersPropsMap[I];
|
|
88
|
+
export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
|
|
89
|
+
type RequiredEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
90
|
+
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? HasRequiredKeys<DefaultControllerProps<TControllers, TControllersPropsMap, K>> extends false ? never : 'controllers' : never]: DefaultControllerProps<TControllers, TControllersPropsMap, K>;
|
|
168
91
|
};
|
|
92
|
+
export type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
169
93
|
type DefaultControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
170
94
|
[I in keyof TControllersPropsMap as I extends K ? I : never]: TControllersPropsMap[I];
|
|
171
95
|
};
|
|
172
|
-
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>;
|
|
173
96
|
export interface ControllerDefinitionOption {
|
|
174
97
|
/**
|
|
175
98
|
* Whether the controller will be used in a product listing context.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
2
|
import type { HasKey, HasKeys } from '../../common/types/utilities.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { ControllerDefinition, ControllerDefinitionsMap, ControllerDefinitionWithoutProps, ControllerDefinitionWithProps, InferControllerStaticStateFromController
|
|
3
|
+
import type { SolutionType } from './controller-constants.js';
|
|
4
|
+
import type { ControllerDefinition, ControllerDefinitionsMap, ControllerDefinitionWithoutProps, ControllerDefinitionWithProps, InferControllerStaticStateFromController } from './controller-definitions.js';
|
|
5
5
|
export type InferStaticState<T extends {
|
|
6
6
|
fetchStaticState(...args: unknown[]): Promise<unknown>;
|
|
7
7
|
}> = Awaited<ReturnType<T['fetchStaticState']>>;
|
|
8
8
|
export type InferHydratedState<T extends {
|
|
9
9
|
hydrateStaticState(...args: unknown[]): Promise<unknown>;
|
|
10
10
|
}> = Awaited<ReturnType<T['hydrateStaticState']>>;
|
|
11
|
-
type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ?
|
|
11
|
+
type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ? Props : TController extends ControllerDefinitionWithoutProps<Controller> ? {} : unknown;
|
|
12
12
|
export type InferControllerPropsMapFromDefinitions<TControllers extends ControllerDefinitionsMap<Controller>> = {
|
|
13
13
|
[K in keyof TControllers as HasKeys<InferControllerPropsFromDefinition<TControllers[K]>> extends false ? never : K]: InferControllerPropsFromDefinition<TControllers[K]>;
|
|
14
14
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
-
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
2
|
import type { EngineConfiguration } from '../../../app/engine-configuration.js';
|
|
4
3
|
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
5
4
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
6
|
-
import type { ControllerStaticStateMap } from '../../common/types/controllers.js';
|
|
5
|
+
import type { ControllerStaticStateMap, ControllersMap } from '../../common/types/controllers.js';
|
|
7
6
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
8
7
|
import type { Build } from './build.js';
|
|
9
8
|
import type { SolutionType } from './controller-constants.js';
|
|
10
|
-
import type { ControllerDefinitionsMap } from './controller-definitions.js';
|
|
9
|
+
import type { BakedInControllers, ControllerDefinitionsMap } from './controller-definitions.js';
|
|
11
10
|
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition } from './controller-inference.js';
|
|
12
|
-
import type { FetchStaticState
|
|
11
|
+
import type { FetchStaticState } from './fetch-static-state.js';
|
|
13
12
|
import type { HydrateStaticState, HydrateStaticStateOptions } from './hydrate-static-state.js';
|
|
14
|
-
export type { HydrateStaticState, HydrateStaticStateOptions, FetchStaticState
|
|
13
|
+
export type { HydrateStaticState, HydrateStaticStateOptions, FetchStaticState };
|
|
15
14
|
export interface EngineStaticState<TSearchAction extends UnknownAction, TControllers extends ControllerStaticStateMap> {
|
|
16
15
|
searchActions: TSearchAction[];
|
|
17
16
|
controllers: TControllers;
|
|
18
17
|
}
|
|
18
|
+
type ReservedControllerNames = 'context' | 'parameterManager' | 'cart';
|
|
19
|
+
type ValidateControllerNames<T extends ControllerDefinitionsMap<Controller>> = {
|
|
20
|
+
[K in keyof T]: K extends ReservedControllerNames ? `ERROR: Controller name "${K & string}" is reserved and cannot be used. Reserved names are: context, parameterManager, cart. Please choose a different controller name.` : T[K];
|
|
21
|
+
};
|
|
19
22
|
export type EngineDefinitionOptions<TOptions extends {
|
|
20
23
|
configuration: EngineConfiguration;
|
|
21
24
|
}, TControllers extends ControllerDefinitionsMap<Controller>> = TOptions & {
|
|
22
25
|
/**
|
|
23
26
|
* The controllers to initialize with the commerce engine.
|
|
24
27
|
*/
|
|
25
|
-
controllers?: TControllers
|
|
28
|
+
controllers?: ValidateControllerNames<TControllers>;
|
|
26
29
|
};
|
|
27
30
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> {
|
|
28
31
|
/**
|
|
@@ -50,15 +53,19 @@ export interface CommerceEngineDefinition<TControllers extends ControllerDefinit
|
|
|
50
53
|
*/
|
|
51
54
|
setAccessToken: (accessToken: string) => void;
|
|
52
55
|
}
|
|
56
|
+
export interface CommerceEngineDefinitionBuildResult<TControllers extends ControllersMap> {
|
|
57
|
+
engine: SSRCommerceEngine;
|
|
58
|
+
controllers: TControllers & BakedInControllers;
|
|
59
|
+
}
|
|
53
60
|
export type CommerceControllerDefinitionsMap = ControllerDefinitionsMap<Controller>;
|
|
54
61
|
type Definition<TControllerDefinitions extends CommerceControllerDefinitionsMap> = CommerceEngineDefinition<TControllerDefinitions, SolutionType>;
|
|
55
62
|
export type FetchStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['fetchStaticState'];
|
|
56
63
|
export type HydrateStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['hydrateStaticState'];
|
|
57
|
-
export type BuildParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<Build<
|
|
64
|
+
export type BuildParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<Build<InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>, InferControllerPropsMapFromDefinitions<TControllerDefinitions>, TControllerDefinitions, SolutionType>>;
|
|
58
65
|
export type FetchStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<FetchStaticStateFunction<TControllerDefinitions>>;
|
|
59
66
|
export type HydrateStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<HydrateStaticStateFunction<TControllerDefinitions>>;
|
|
60
67
|
type Controllers<TControllerDefinitions extends CommerceControllerDefinitionsMap> = InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>;
|
|
61
68
|
export type BuildResult<TControllerDefinitions extends CommerceControllerDefinitionsMap> = {
|
|
62
69
|
engine: SSRCommerceEngine;
|
|
63
|
-
controllers: Controllers<TControllerDefinitions
|
|
70
|
+
controllers: Controllers<TControllerDefinitions> & BakedInControllers;
|
|
64
71
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
3
|
import type { ControllerStaticStateMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
|
+
import type { BuildConfig } from './build.js';
|
|
4
5
|
import type { SolutionType } from './controller-constants.js';
|
|
5
|
-
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
6
|
+
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, FilteredBakedInControllers, OptionsTuple } from './controller-definitions.js';
|
|
6
7
|
import type { EngineStaticState } from './engine.js';
|
|
7
|
-
export type FetchStaticStateOptions = {};
|
|
8
8
|
/**
|
|
9
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
10
|
*
|
|
11
11
|
* Useful for static generation and server-side rendering.
|
|
12
12
|
*/
|
|
13
|
-
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<
|
|
13
|
+
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TControllersDefinitionsMap, TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<EngineStaticState<TSearchAction, TControllersStaticState & FilteredBakedInControllers<TSolutionType>> & BuildConfig<TControllersDefinitionsMap, TSolutionType>>;
|
|
@@ -3,6 +3,7 @@ import type { Controller } from '../../../controllers/controller/headless-contro
|
|
|
3
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
4
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
5
5
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
6
|
+
import type { BuildConfig } from './build.js';
|
|
6
7
|
import type { SolutionType } from './controller-constants.js';
|
|
7
8
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
8
9
|
export interface HydrateStaticStateOptions<TSearchAction> {
|
|
@@ -13,4 +14,4 @@ export interface HydrateStaticStateOptions<TSearchAction> {
|
|
|
13
14
|
*
|
|
14
15
|
* Useful when hydrating a server-side-rendered engine.
|
|
15
16
|
*/
|
|
16
|
-
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<HydrateStaticStateOptions<TSearchAction> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
17
|
+
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<HydrateStaticStateOptions<TSearchAction> & BuildConfig<TControllersDefinitionsMap, TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SolutionType } from './controller-constants.js';
|
|
2
|
+
export type HasSolutionType<TDefinition, TSolutionType extends SolutionType> = TDefinition extends {
|
|
3
|
+
[K in TSolutionType]: true;
|
|
4
|
+
} ? true : TDefinition extends {
|
|
5
|
+
[K in TSolutionType]: false;
|
|
6
|
+
} ? false : false;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Schema } from '@coveo/bueno';
|
|
2
|
+
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
3
|
+
import type { BuildConfig } from '../types/build.js';
|
|
4
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
5
|
+
import type { InferControllerPropsMapFromDefinitions } from '../types/controller-inference.js';
|
|
6
|
+
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
7
|
+
export declare const listingDefinitionSchema: Schema<{
|
|
8
|
+
searchParams: unknown;
|
|
9
|
+
context: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const searchDefinitionSchema: Schema<{
|
|
12
|
+
searchParams: unknown;
|
|
13
|
+
context: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const standaloneDefinitionSchema: Schema<{
|
|
16
|
+
context: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const recommendationsDefinitionSchema: (recommendationName: string[]) => Schema<{
|
|
19
|
+
recommendations: import("@coveo/bueno").PrimitivesValues[] | null | undefined;
|
|
20
|
+
productId: string;
|
|
21
|
+
context: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Converts simple user configuration (URL, language, currency, query) into the
|
|
25
|
+
* nested structure required by the internal {@link Build} method. Automatically generates
|
|
26
|
+
* appropriate controllers (context, cart, parameterManager) transparently.
|
|
27
|
+
*
|
|
28
|
+
* @param solutionType - The type of solution (search, listing, recommendation, standalone)
|
|
29
|
+
* @param controllerDefinitions - Map of controller definitions to be initialized
|
|
30
|
+
* @param buildConfig - Simple configuration object with simplified controller properties
|
|
31
|
+
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
32
|
+
*/
|
|
33
|
+
export declare function wireControllerParams<TControllerDefinitions extends CommerceControllerDefinitionsMap>(solutionType: SolutionType, controllerDefinitions: TControllerDefinitions, buildConfig: BuildConfig<TControllerDefinitions, SolutionType> & {
|
|
34
|
+
controllers?: ControllersPropsMap;
|
|
35
|
+
}): InferControllerPropsMapFromDefinitions<TControllerDefinitions>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommerceEngineConfiguration } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
|
+
import type { CommerceEngineDefinitionOptions } from '../factories/build-factory.js';
|
|
3
|
+
import type { CommonBuildConfig } from '../types/build.js';
|
|
4
|
+
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
5
|
+
export declare function extendEngineConfiguration<TControllerDefinitions extends CommerceControllerDefinitionsMap>(configuration: CommerceEngineDefinitionOptions<TControllerDefinitions>['configuration'], commonBuildOptions: CommonBuildConfig): CommerceEngineConfiguration;
|