@coveo/headless 3.29.2-pre.ee24f8bd85 → 3.29.2-pre.f230cfebef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/case-assist/headless.cjs +1 -1
- package/dist/cjs/commerce/headless.cjs +1 -1
- package/dist/cjs/headless.cjs +1 -1
- package/dist/cjs/insight/headless.cjs +1 -1
- package/dist/cjs/recommendation/headless.cjs +1 -1
- package/dist/cjs/ssr/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce/headless.cjs +1 -1
- package/dist/cjs/ssr-commerce-next/headless.cjs +1 -1
- package/dist/cjs/ssr-next/headless.cjs +1 -1
- package/dist/definitions/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.d.ts +8 -4
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +58 -7
- package/dist/definitions/ssr-next/commerce/types/controller-definitions.d.ts +4 -119
- package/dist/definitions/ssr-next/commerce/types/controller-inference.d.ts +3 -3
- package/dist/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +1 -1
- package/dist/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +1 -1
- package/dist/definitions/ssr-next/commerce/utils/controller-wiring.d.ts +4 -7
- package/dist/definitions/ssr-next/commerce/utils/recommendation-filter.d.ts +14 -1
- 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-next/commerce/controllers/recommendations/headless-recommendations.ssr.js +1 -1
- package/dist/esm/ssr-next/commerce/factories/build-factory.js +4 -9
- package/dist/esm/ssr-next/commerce/factories/recommendation-static-state-factory.js +1 -10
- package/dist/esm/ssr-next/commerce/utils/controller-wiring.js +32 -15
- package/dist/esm/ssr-next/commerce/utils/recommendation-filter.js +27 -8
- 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
|
@@ -800,7 +800,7 @@ var import_bueno5 = require("@coveo/bueno");
|
|
|
800
800
|
var import_toolkit7 = require("@reduxjs/toolkit");
|
|
801
801
|
|
|
802
802
|
// src/utils/version.ts
|
|
803
|
-
var VERSION = "3.29.2-pre.
|
|
803
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
804
804
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
805
805
|
|
|
806
806
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -1149,7 +1149,7 @@ var import_bueno6 = require("@coveo/bueno");
|
|
|
1149
1149
|
var import_toolkit4 = require("@reduxjs/toolkit");
|
|
1150
1150
|
|
|
1151
1151
|
// src/utils/version.ts
|
|
1152
|
-
var VERSION = "3.29.2-pre.
|
|
1152
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
1153
1153
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1154
1154
|
|
|
1155
1155
|
// src/features/configuration/configuration-actions.ts
|
package/dist/cjs/headless.cjs
CHANGED
|
@@ -1374,7 +1374,7 @@ var import_toolkit2 = require("@reduxjs/toolkit");
|
|
|
1374
1374
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1375
1375
|
|
|
1376
1376
|
// src/utils/version.ts
|
|
1377
|
-
var VERSION = "3.29.2-pre.
|
|
1377
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
1378
1378
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1379
1379
|
|
|
1380
1380
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -1278,7 +1278,7 @@ var import_toolkit2 = require("@reduxjs/toolkit");
|
|
|
1278
1278
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
1279
1279
|
|
|
1280
1280
|
// src/utils/version.ts
|
|
1281
|
-
var VERSION = "3.29.2-pre.
|
|
1281
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
1282
1282
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1283
1283
|
|
|
1284
1284
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -881,7 +881,7 @@ var validateObject = (engine, schema, obj, validationMessage, errorMessage) => {
|
|
|
881
881
|
};
|
|
882
882
|
|
|
883
883
|
// src/utils/version.ts
|
|
884
|
-
var VERSION = "3.29.2-pre.
|
|
884
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
885
885
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
886
886
|
|
|
887
887
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -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.2-pre.
|
|
1309
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
1310
1310
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1311
1311
|
|
|
1312
1312
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -468,7 +468,7 @@ var import_bueno8 = require("@coveo/bueno");
|
|
|
468
468
|
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
469
469
|
|
|
470
470
|
// src/utils/version.ts
|
|
471
|
-
var VERSION = "3.29.2-pre.
|
|
471
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
472
472
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
473
473
|
|
|
474
474
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -468,7 +468,7 @@ var import_bueno8 = require("@coveo/bueno");
|
|
|
468
468
|
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
469
469
|
|
|
470
470
|
// src/utils/version.ts
|
|
471
|
-
var VERSION = "3.29.2-pre.
|
|
471
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
472
472
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
473
473
|
|
|
474
474
|
// src/features/configuration/configuration-actions.ts
|
|
@@ -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.2-pre.
|
|
1309
|
+
var VERSION = "3.29.2-pre.f230cfebef";
|
|
1310
1310
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1311
1311
|
|
|
1312
1312
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -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,21 +1,18 @@
|
|
|
1
1
|
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
|
-
import type { OptionsTuple } from '../../common/types/utilities.js';
|
|
4
|
+
import type { HasKey, OptionsTuple } from '../../common/types/utilities.js';
|
|
5
5
|
import type { CartInitialState } from '../controllers/cart/headless-cart.ssr.js';
|
|
6
6
|
import type { ContextOptions } from '../controllers/context/headless-context.ssr.js';
|
|
7
7
|
import type { ParameterManagerState, Parameters } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
8
8
|
import type { SolutionType } from './controller-constants.js';
|
|
9
|
-
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption } from './controller-definitions.js';
|
|
9
|
+
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, IsRecommendationController } from './controller-definitions.js';
|
|
10
10
|
import type { CommerceEngineDefinitionBuildResult } from './engine.js';
|
|
11
11
|
export interface SearchBuildConfig extends CommonBuildConfig {
|
|
12
12
|
searchParams: ParameterManagerState<Parameters & {
|
|
13
13
|
query: string;
|
|
14
14
|
}>['parameters'];
|
|
15
15
|
}
|
|
16
|
-
export interface RecommendationBuildConfig extends CommonBuildConfig {
|
|
17
|
-
recommendations?: [];
|
|
18
|
-
}
|
|
19
16
|
export interface ListingBuildConfig extends CommonBuildConfig {
|
|
20
17
|
}
|
|
21
18
|
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
@@ -25,14 +22,68 @@ export interface CommonBuildConfig {
|
|
|
25
22
|
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
26
23
|
cart?: CartInitialState;
|
|
27
24
|
}
|
|
28
|
-
export type BuildConfig<TSolutionType extends SolutionType> = TSolutionType extends SolutionType.search ? SearchBuildConfig : TSolutionType extends SolutionType.listing ? ListingBuildConfig : TSolutionType extends SolutionType.recommendation ? RecommendationBuildConfig : TSolutionType extends SolutionType.standalone ? CommonBuildConfig : never;
|
|
29
25
|
/**
|
|
30
26
|
* Commerce engine options for SSR scenarios where context is defined when fetching static state.
|
|
31
27
|
*/
|
|
32
28
|
export type SSRCommerceEngineOptions = Omit<CommerceEngineOptions, 'configuration'> & {
|
|
33
29
|
configuration: Omit<CommerceEngineOptions['configuration'], 'context'>;
|
|
34
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* The `RecommendationBuildConfig` type defines the shape of the configuration object required when fetching static state for recommendations.
|
|
33
|
+
*
|
|
34
|
+
* The `recommendations` property is a string array containing the names of the recommendation controllers
|
|
35
|
+
* that were defined in your engine definition. This allows you to specify which recommendation controllers
|
|
36
|
+
* should be included in the SSR request.
|
|
37
|
+
*
|
|
38
|
+
* For example, on a storefront homepage, it might make sense to display a carousel of popular products.
|
|
39
|
+
* However, showing recommendations based on items frequently bought together may not be relevant in that context and should not be retrieved unnecessarily.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* Given the following engine definition:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
46
|
+
* controllers: {
|
|
47
|
+
* popularProducts: defineRecommendations({options: {slotId: '...'}}),
|
|
48
|
+
* frequentlyBought: defineRecommendations({options: {slotId: '...'}}),
|
|
49
|
+
* // ...other controllers
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // When fetching static state for recommendations:
|
|
54
|
+
* const staticState = await recommendationEngineDefinition.fetchStaticState({
|
|
55
|
+
* recommendations: ['popularProducts'],
|
|
56
|
+
* // ...other config
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* In this example, only the `popularProducts` recommendation controller will be included in the SSR request.
|
|
61
|
+
*/
|
|
62
|
+
export type RecommendationBuildConfig<TControllers extends ControllerDefinitionsMap<Controller>> = CommonBuildConfig & {
|
|
63
|
+
/**
|
|
64
|
+
* The unique identifier of the product to use for seeded recommendations.
|
|
65
|
+
*/
|
|
66
|
+
productId?: string;
|
|
67
|
+
/**
|
|
68
|
+
* An array of recommendation controller names from your engine definition to include in the SSR request.
|
|
69
|
+
* Each name corresponds to a key used when defining recommendation controllers in your engine definition.
|
|
70
|
+
* If not specified, no recommendation requests will be executed.
|
|
71
|
+
*/
|
|
72
|
+
recommendations: Array<Extract<keyof TControllers, {
|
|
73
|
+
[K in keyof TControllers]: HasKey<TControllers[K], SolutionType.recommendation> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? never : K;
|
|
74
|
+
}[keyof TControllers]>>;
|
|
75
|
+
};
|
|
76
|
+
export interface ListingBuildConfig extends CommonBuildConfig {
|
|
77
|
+
}
|
|
78
|
+
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
79
|
+
}
|
|
80
|
+
export interface CommonBuildConfig {
|
|
81
|
+
context: ContextOptions;
|
|
82
|
+
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
83
|
+
cart?: CartInitialState;
|
|
84
|
+
}
|
|
85
|
+
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;
|
|
35
86
|
/**
|
|
36
87
|
* @internal
|
|
37
88
|
*/
|
|
38
|
-
export type Build<TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<CommerceEngineDefinitionBuildResult<TControllersMap>>;
|
|
89
|
+
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>>;
|
|
@@ -3,7 +3,7 @@ import type { InvalidControllerDefinition } from '../../common/errors.js';
|
|
|
3
3
|
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
4
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
5
5
|
import type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers } from '../../common/types/inference.js';
|
|
6
|
-
import type { HasKey,
|
|
6
|
+
import type { HasKey, HasRequiredKeys, OptionsTuple } from '../../common/types/utilities.js';
|
|
7
7
|
import type { CartDefinition } from '../controllers/cart/headless-cart.ssr.js';
|
|
8
8
|
import type { ContextDefinition } from '../controllers/context/headless-context.ssr.js';
|
|
9
9
|
import type { ParameterManagerDefinition } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
@@ -13,15 +13,6 @@ import type { ListingAndStandaloneController, ListingOnlyController, NonRecommen
|
|
|
13
13
|
import type { Kind } from './kind.js';
|
|
14
14
|
import type { HasSolutionType } from './utilities.js';
|
|
15
15
|
export type { HydratedState, OptionsTuple, InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, };
|
|
16
|
-
export type RecommendationControllerSettings = {
|
|
17
|
-
/**
|
|
18
|
-
* Toggle to enable or disable the recommendation controller.
|
|
19
|
-
* When set to `true`, the controller will perform a recommendation request server-side.
|
|
20
|
-
*
|
|
21
|
-
* @default false
|
|
22
|
-
*/
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
};
|
|
25
16
|
export interface ControllerDefinitionWithoutProps<TController extends Controller> {
|
|
26
17
|
/**
|
|
27
18
|
* Creates an instance of the given controller.
|
|
@@ -94,120 +85,14 @@ export type AugmentedControllerDefinition<TControllerDefinitions extends Control
|
|
|
94
85
|
/**
|
|
95
86
|
* This type defines the required and optional controller props for the engine definition.
|
|
96
87
|
*/
|
|
97
|
-
export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> =
|
|
98
|
-
/**
|
|
99
|
-
* Represents an optional engine definition for controller properties.
|
|
100
|
-
*
|
|
101
|
-
* This type is used to define a map of optional controller properties based on the provided
|
|
102
|
-
* controller definitions, controller properties map, and solution type.
|
|
103
|
-
*
|
|
104
|
-
* @template TControllers - A map of controller definitions.
|
|
105
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
106
|
-
* @template TSolutionType - The type of solution.
|
|
107
|
-
*
|
|
108
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
109
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
110
|
-
* 2. The controller properties have optional options (HasOptionalKeys<ConditionalControllerProps<...>> is true).
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* Given the following controller definitions:
|
|
114
|
-
* ```
|
|
115
|
-
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
116
|
-
* controllers: {
|
|
117
|
-
* popularViewed: defineRecommendations({
|
|
118
|
-
* options: {slotId: 'slot-id'}
|
|
119
|
-
* })
|
|
120
|
-
* }
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* The following code will not throw an error since the 'popularViewed' controller props are optional
|
|
125
|
-
* ```
|
|
126
|
-
* recommendationEngineDefinition.fetchStaticState({
|
|
127
|
-
* controllers: {
|
|
128
|
-
* popularViewed: {enabled: true, productId: 'some-product-id'} // This is optional
|
|
129
|
-
* }
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* 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.
|
|
134
|
-
* ```
|
|
135
|
-
* recommendationEngineDefinition.fetchStaticState()
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
type OptionalEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
139
|
-
[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>;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Represents a type that defines the required controller properties for engine definition controllers.
|
|
143
|
-
*
|
|
144
|
-
* @template TControllers - A map of controller definitions.
|
|
145
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
146
|
-
* @template TSolutionType - The type of solution being used.
|
|
147
|
-
*
|
|
148
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
149
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
150
|
-
* 2. The controller properties have required options (HasRequiredKeys<ConditionalControllerProps<...>> is true).
|
|
151
|
-
*
|
|
152
|
-
* The resulting type maps the valid keys to their corresponding conditional controller properties.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* Given the following controller definitions:
|
|
156
|
-
* ```
|
|
157
|
-
* const {standaloneEngineDefinition} = defineCommerceEngine({
|
|
158
|
-
* controllers: {cart: defineCart()},
|
|
159
|
-
* });
|
|
160
|
-
* ```
|
|
161
|
-
*
|
|
162
|
-
* The following code will not throw an error since the 'cart' controller props are required for the standalone engine definition:
|
|
163
|
-
* ```
|
|
164
|
-
* standaloneEngineDefinition.fetchStaticState({
|
|
165
|
-
* controllers: {
|
|
166
|
-
* cart: {initialState: {items: []}},
|
|
167
|
-
* },
|
|
168
|
-
* })
|
|
169
|
-
* ```
|
|
170
|
-
*
|
|
171
|
-
*/
|
|
88
|
+
export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
|
|
172
89
|
type RequiredEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
173
|
-
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : HasRequiredKeys<
|
|
174
|
-
};
|
|
175
|
-
type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
176
|
-
/**
|
|
177
|
-
* This type ensures that recommendation controller props are optional, while other controller props remain required.
|
|
178
|
-
*
|
|
179
|
-
* It works by checking if the controller definition includes the `recommendationInternalOptionKey`.
|
|
180
|
-
*
|
|
181
|
-
* - If the key is present, the controller props are made optional.
|
|
182
|
-
* - If the key is absent, the controller props are required.
|
|
183
|
-
*
|
|
184
|
-
* Example:
|
|
185
|
-
*
|
|
186
|
-
* ```typescript
|
|
187
|
-
* type ControllerProps = InferControllerPropsFromDefinition<{
|
|
188
|
-
* recommendation: defineRecommendation({}),
|
|
189
|
-
* cart: defineCart(),
|
|
190
|
-
* }>;
|
|
191
|
-
*
|
|
192
|
-
* // In this example:
|
|
193
|
-
* // - The `recommendation` controller props are optional.
|
|
194
|
-
* // - The `cart` controller props are required.
|
|
195
|
-
*
|
|
196
|
-
* const props: ControllerProps = {
|
|
197
|
-
* cart: {initialState: {items: []}},
|
|
198
|
-
* // recommendation props can be omitted
|
|
199
|
-
* };
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
type RecommendationControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
203
|
-
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? never : I : never]?: TControllersPropsMap[I];
|
|
204
|
-
} & {
|
|
205
|
-
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? I : never : never]: TControllersPropsMap[I];
|
|
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>;
|
|
206
91
|
};
|
|
92
|
+
export type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
207
93
|
type DefaultControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
208
94
|
[I in keyof TControllersPropsMap as I extends K ? I : never]: TControllersPropsMap[I];
|
|
209
95
|
};
|
|
210
|
-
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>;
|
|
211
96
|
export interface ControllerDefinitionOption {
|
|
212
97
|
/**
|
|
213
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
|
};
|
|
@@ -10,4 +10,4 @@ import type { EngineStaticState } from './engine.js';
|
|
|
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<BuildConfig<TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<EngineStaticState<TSearchAction, TControllersStaticState & FilteredBakedInControllers<TSolutionType>> & BuildConfig<TSolutionType>>;
|
|
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>>;
|
|
@@ -14,4 +14,4 @@ export interface HydrateStaticStateOptions<TSearchAction> {
|
|
|
14
14
|
*
|
|
15
15
|
* Useful when hydrating a server-side-rendered engine.
|
|
16
16
|
*/
|
|
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<TSolutionType> & 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>>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Controller Wiring Utilities
|
|
3
|
-
*
|
|
4
|
-
* Transforms simple user configuration into complex internal controller structures.
|
|
5
|
-
*/
|
|
6
1
|
import { Schema } from '@coveo/bueno';
|
|
7
2
|
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
8
3
|
import type { BuildConfig } from '../types/build.js';
|
|
@@ -20,7 +15,9 @@ export declare const searchDefinitionSchema: Schema<{
|
|
|
20
15
|
export declare const standaloneDefinitionSchema: Schema<{
|
|
21
16
|
context: unknown;
|
|
22
17
|
}>;
|
|
23
|
-
export declare const recommendationsDefinitionSchema: Schema<{
|
|
18
|
+
export declare const recommendationsDefinitionSchema: (recommendationName: string[]) => Schema<{
|
|
19
|
+
recommendations: import("@coveo/bueno").PrimitivesValues[] | null | undefined;
|
|
20
|
+
productId: string;
|
|
24
21
|
context: unknown;
|
|
25
22
|
}>;
|
|
26
23
|
/**
|
|
@@ -33,6 +30,6 @@ export declare const recommendationsDefinitionSchema: Schema<{
|
|
|
33
30
|
* @param buildConfig - Simple configuration object with simplified controller properties
|
|
34
31
|
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
35
32
|
*/
|
|
36
|
-
export declare function wireControllerParams<TControllerDefinitions extends CommerceControllerDefinitionsMap>(solutionType: SolutionType, controllerDefinitions: TControllerDefinitions, buildConfig: BuildConfig<SolutionType> & {
|
|
33
|
+
export declare function wireControllerParams<TControllerDefinitions extends CommerceControllerDefinitionsMap>(solutionType: SolutionType, controllerDefinitions: TControllerDefinitions, buildConfig: BuildConfig<TControllerDefinitions, SolutionType> & {
|
|
37
34
|
controllers?: ControllersPropsMap;
|
|
38
35
|
}): InferControllerPropsMapFromDefinitions<TControllerDefinitions>;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RecommendationsDefinitionMeta } from '../controllers/recommendations/headless-recommendations.ssr.js';
|
|
3
|
+
import type { ControllerDefinition, ControllerDefinitionsMap } from '../types/controller-definitions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if a controller definition is a recommendation controller.
|
|
6
|
+
* A recommendation controller must have both the recommendation flag and a slotId.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isRecommendationDefinition<C extends ControllerDefinition<Controller>>(controllerDefinition: C): controllerDefinition is C & RecommendationsDefinitionMeta;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts recommendation controller definitions from a controller definitions map.
|
|
11
|
+
*
|
|
12
|
+
* @param controllerDefinitions - Map of controller definitions
|
|
13
|
+
* @returns Object containing only the recommendation controller definitions
|
|
14
|
+
*/
|
|
15
|
+
export declare function getRecommendationDefinitions(controllerDefinitions: ControllerDefinitionsMap<Controller>): Record<string, ControllerDefinition<Controller> & RecommendationsDefinitionMeta>;
|
|
3
16
|
export declare function filterRecommendationControllers<TControllerDefinitions extends ControllerDefinitionsMap<Controller>>(controllers: Record<string, Controller>, controllerDefinitions: TControllerDefinitions): {
|
|
4
17
|
/**
|
|
5
18
|
* Go through all the controllers passed in argument and only refresh recommendation controllers.
|
|
@@ -3,9 +3,6 @@ export type HasKeys<TObject> = TObject extends {} ? keyof TObject extends never
|
|
|
3
3
|
export type HasRequiredKeys<TObject> = TObject extends {} ? {
|
|
4
4
|
[K in keyof TObject]-?: {} extends Pick<TObject, K> ? never : K;
|
|
5
5
|
}[keyof TObject] extends never ? false : true : boolean;
|
|
6
|
-
export type HasOptionalKeys<TObject> = TObject extends {} ? {
|
|
7
|
-
[K in keyof TObject]-?: {} extends Pick<TObject, K> ? K : never;
|
|
8
|
-
}[keyof TObject] extends never ? false : true : boolean;
|
|
9
6
|
type ExtractRequiredOptions<TOptions> = {
|
|
10
7
|
[TKey in keyof TOptions as Pick<TOptions, TKey> extends Required<Pick<TOptions, TKey>> ? TKey : never]: TOptions[TKey];
|
|
11
8
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SearchEngine } from '../app/search-engine/search-engine.js';
|
|
2
2
|
import type { Controller } from '../controllers/controller/headless-controller.js';
|
|
3
3
|
import type { Kind } from '../ssr/commerce/types/kind.js';
|
|
4
|
+
import { recommendationInternalOptionKey } from '../ssr-next/commerce/types/controller-constants.js';
|
|
4
5
|
import type { ControllerDefinitionWithoutProps, ControllerDefinitionWithProps } from '../ssr-next/common/types/controllers.js';
|
|
5
6
|
interface MockController {
|
|
6
7
|
initialState?: Record<string, unknown>;
|
|
@@ -35,4 +36,15 @@ export declare function defineMockCommerceControllerWithProps(options?: Solution
|
|
|
35
36
|
standalone: boolean;
|
|
36
37
|
recommendation: boolean;
|
|
37
38
|
};
|
|
39
|
+
export declare function defineMockRecommendationDefinition(slotId: string): {
|
|
40
|
+
recommendation: boolean;
|
|
41
|
+
[recommendationInternalOptionKey]: {
|
|
42
|
+
slotId: string;
|
|
43
|
+
};
|
|
44
|
+
buildWithProps: import("vitest").Mock<(engine: any, props: any) => {
|
|
45
|
+
state: {};
|
|
46
|
+
subscribe(listener: () => void): import("redux").Unsubscribe;
|
|
47
|
+
_kind: Kind;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
38
50
|
export {};
|
package/dist/esm/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.js
CHANGED
|
@@ -17,7 +17,7 @@ export function defineRecommendations(props) {
|
|
|
17
17
|
buildWithProps: (engine, options) => {
|
|
18
18
|
const staticOptions = props.options;
|
|
19
19
|
const controller = buildRecommendations(engine, {
|
|
20
|
-
options: { ...staticOptions, ...options },
|
|
20
|
+
options: { ...staticOptions, ...options.initialState },
|
|
21
21
|
});
|
|
22
22
|
return createControllerWithKind(controller, Kind.Recommendations);
|
|
23
23
|
},
|
|
@@ -57,21 +57,16 @@ function buildSSRCommerceEngine(solutionType, options, recommendationCount) {
|
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function fetchActiveRecommendationControllers(controllerProps, solutionType) {
|
|
61
|
-
return solutionType === SolutionType.recommendation
|
|
62
|
-
? Object.values(controllerProps).filter((controller) => controller &&
|
|
63
|
-
typeof controller === 'object' &&
|
|
64
|
-
'enabled' in controller &&
|
|
65
|
-
controller.enabled).length
|
|
66
|
-
: 0;
|
|
67
|
-
}
|
|
68
60
|
export const buildFactory = (controllerDefinitions, options) => (solutionType) => async (...[buildOptions]) => {
|
|
69
61
|
const controllerProps = wireControllerParams(solutionType, controllerDefinitions, buildOptions); // TODO: KIT-4754: remove non-null assertion operator
|
|
70
62
|
const logger = buildLogger(options.loggerOptions);
|
|
71
63
|
if (!options.navigatorContextProvider) {
|
|
72
64
|
logger.warn('[WARNING] Missing navigator context in server-side code. Make sure to set it with `setNavigatorContextProvider` before calling fetchStaticState()');
|
|
73
65
|
}
|
|
74
|
-
const enabledRecommendationControllers =
|
|
66
|
+
const enabledRecommendationControllers = buildOptions && 'recommendations' in buildOptions // TODO: KIT-4754: remove non-null assertion
|
|
67
|
+
? buildOptions
|
|
68
|
+
?.recommendations.length
|
|
69
|
+
: 0;
|
|
75
70
|
const engineOptions = {
|
|
76
71
|
...options,
|
|
77
72
|
configuration: extendEngineConfiguration(options.configuration, buildOptions), // TODO: KIT-4754: remove non-null assertion operator
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { filterObject } from '../../../utils/utils.js';
|
|
2
1
|
import { createStaticState } from '../controller-utils.js';
|
|
3
2
|
import { SolutionType } from '../types/controller-constants.js';
|
|
4
3
|
import { filterRecommendationControllers } from '../utils/recommendation-filter.js';
|
|
5
4
|
import { buildFactory, } from './build-factory.js';
|
|
6
5
|
export function fetchRecommendationStaticStateFactory(controllerDefinitions, options) {
|
|
7
|
-
// TODO: KIT-4619: no longer the right way to get the allowed recommendation keys
|
|
8
|
-
const getAllowedRecommendationKeys = (props) => {
|
|
9
|
-
if (props && 'controllers' in props) {
|
|
10
|
-
const enabledRecommendationControllers = filterObject(props.controllers, (value) => Boolean(value.enabled));
|
|
11
|
-
return Object.keys(enabledRecommendationControllers);
|
|
12
|
-
}
|
|
13
|
-
return [];
|
|
14
|
-
};
|
|
15
6
|
return async (...params) => {
|
|
16
7
|
const [props] = params;
|
|
17
|
-
const allowedRecommendationKeys =
|
|
8
|
+
const allowedRecommendationKeys = props.recommendations;
|
|
18
9
|
const solutionTypeBuild = await buildFactory(controllerDefinitions, options)(SolutionType.recommendation);
|
|
19
10
|
const { engine, controllers } = (await solutionTypeBuild(...params));
|
|
20
11
|
filterRecommendationControllers(controllers, controllerDefinitions ?? {}).refresh(allowedRecommendationKeys);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* Controller Wiring Utilities
|
|
3
|
-
*
|
|
4
|
-
* Transforms simple user configuration into complex internal controller structures.
|
|
5
|
-
*/
|
|
6
|
-
import { RecordValue, Schema } from '@coveo/bueno';
|
|
1
|
+
import { ArrayValue, RecordValue, Schema, StringValue } from '@coveo/bueno';
|
|
7
2
|
import { contextDefinition } from '../../../features/commerce/context/context-validation.js';
|
|
8
3
|
import { parametersDefinition } from '../../../features/commerce/parameters/parameters-schema.js';
|
|
9
|
-
import { requiredEmptyAllowedString } from '../../../utils/validate-payload.js';
|
|
4
|
+
import { nonEmptyString, requiredEmptyAllowedString, } from '../../../utils/validate-payload.js';
|
|
10
5
|
import { SolutionType } from '../types/controller-constants.js';
|
|
6
|
+
import { getRecommendationDefinitions, isRecommendationDefinition, } from './recommendation-filter.js';
|
|
11
7
|
const requiredDefinition = {
|
|
12
8
|
context: new RecordValue({
|
|
13
9
|
options: { required: true },
|
|
@@ -30,23 +26,31 @@ const searchDefinition = {
|
|
|
30
26
|
values: { query: requiredEmptyAllowedString, ...parametersDefinition },
|
|
31
27
|
}),
|
|
32
28
|
};
|
|
33
|
-
const recommendationsDefinition = {
|
|
29
|
+
const recommendationsDefinition = (recommendationName) => ({
|
|
34
30
|
...requiredDefinition,
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
recommendations: new ArrayValue({
|
|
32
|
+
each: new StringValue({
|
|
33
|
+
required: true,
|
|
34
|
+
constrainTo: recommendationName,
|
|
35
|
+
emptyAllowed: false,
|
|
36
|
+
}),
|
|
37
|
+
required: true,
|
|
38
|
+
}),
|
|
39
|
+
productId: nonEmptyString,
|
|
40
|
+
});
|
|
37
41
|
export const listingDefinitionSchema = new Schema(listingDefinition);
|
|
38
42
|
export const searchDefinitionSchema = new Schema(searchDefinition);
|
|
39
43
|
export const standaloneDefinitionSchema = new Schema(standaloneDefinition);
|
|
40
|
-
export const recommendationsDefinitionSchema = new Schema(recommendationsDefinition);
|
|
44
|
+
export const recommendationsDefinitionSchema = (recommendationName) => new Schema(recommendationsDefinition(recommendationName));
|
|
41
45
|
/**
|
|
42
46
|
* Validates the build configuration based on the solution type.
|
|
43
47
|
*/
|
|
44
|
-
function validateBuildConfig(solutionType, buildConfig) {
|
|
48
|
+
function validateBuildConfig(solutionType, controllerDefinitions, buildConfig) {
|
|
45
49
|
const validationMap = {
|
|
46
50
|
[SolutionType.listing]: listingDefinitionSchema,
|
|
47
51
|
[SolutionType.search]: searchDefinitionSchema,
|
|
48
52
|
[SolutionType.standalone]: standaloneDefinitionSchema,
|
|
49
|
-
[SolutionType.recommendation]: recommendationsDefinitionSchema,
|
|
53
|
+
[SolutionType.recommendation]: recommendationsDefinitionSchema(Object.keys(getRecommendationDefinitions(controllerDefinitions))),
|
|
50
54
|
};
|
|
51
55
|
const schema = validationMap[solutionType];
|
|
52
56
|
schema.validate(buildConfig);
|
|
@@ -95,7 +99,20 @@ class ControllerWirer {
|
|
|
95
99
|
};
|
|
96
100
|
}
|
|
97
101
|
wireRecommendations() {
|
|
98
|
-
|
|
102
|
+
if (!('recommendations' in this.buildConfig)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const recController in this.controllerDefinitions) {
|
|
106
|
+
if (isRecommendationDefinition(this.controllerDefinitions[recController])) {
|
|
107
|
+
this.controllerProps[recController] = {
|
|
108
|
+
initialState: {
|
|
109
|
+
...('productId' in this.buildConfig && {
|
|
110
|
+
productId: this.buildConfig.productId,
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
99
116
|
}
|
|
100
117
|
/**
|
|
101
118
|
* Wires all controllers based on solution type and controller definitions.
|
|
@@ -138,7 +155,7 @@ class ControllerWirer {
|
|
|
138
155
|
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
139
156
|
*/
|
|
140
157
|
export function wireControllerParams(solutionType, controllerDefinitions, buildConfig) {
|
|
141
|
-
validateBuildConfig(solutionType, buildConfig);
|
|
158
|
+
validateBuildConfig(solutionType, controllerDefinitions, buildConfig);
|
|
142
159
|
const controllerProps = buildConfig.controllers ?? {};
|
|
143
160
|
new ControllerWirer(buildConfig, controllerDefinitions, controllerProps).wire(solutionType);
|
|
144
161
|
return controllerProps;
|