@coveo/headless 3.29.2-pre.3b655176de → 3.29.2-pre.401eb1851f
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/factories/hydrated-state-factory.d.ts +2 -1
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +2 -9
- 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 +2 -1
- package/dist/definitions/ssr-next/commerce/utils/controller-wiring.d.ts +32 -2
- package/dist/definitions/ssr-next/commerce/utils/engine-wiring.d.ts +1 -1
- package/dist/esm/ssr-next/commerce/factories/hydrated-state-factory.js +1 -3
- package/dist/esm/ssr-next/commerce/factories/recommendation-hydrated-state-factory.js +1 -3
- package/dist/esm/ssr-next/commerce/factories/recommendation-static-state-factory.js +6 -1
- package/dist/esm/ssr-next/commerce/factories/static-state-factory.js +4 -1
- package/dist/esm/ssr-next/commerce/utils/controller-wiring.js +144 -3
- package/dist/esm/ssr-next/commerce/utils/engine-wiring.js +9 -3
- 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 +2 -2
|
@@ -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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
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.401eb1851f";
|
|
1310
1310
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1311
1311
|
|
|
1312
1312
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -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>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { CurrencyCodeISO4217 } from '@coveo/relay-event-types';
|
|
2
1
|
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
4
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
5
4
|
import type { OptionsTuple } from '../../common/types/utilities.js';
|
|
6
5
|
import type { CartInitialState } from '../controllers/cart/headless-cart.ssr.js';
|
|
7
|
-
import type {
|
|
6
|
+
import type { ContextOptions } from '../controllers/context/headless-context.ssr.js';
|
|
8
7
|
import type { ParameterManagerState, Parameters } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
9
8
|
import type { SolutionType } from './controller-constants.js';
|
|
10
9
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption } from './controller-definitions.js';
|
|
@@ -22,13 +21,7 @@ export interface ListingBuildConfig extends CommonBuildConfig {
|
|
|
22
21
|
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
23
22
|
}
|
|
24
23
|
export interface CommonBuildConfig {
|
|
25
|
-
context:
|
|
26
|
-
url: string;
|
|
27
|
-
language: string;
|
|
28
|
-
country: string;
|
|
29
|
-
currency: CurrencyCodeISO4217;
|
|
30
|
-
location?: UserLocation;
|
|
31
|
-
};
|
|
24
|
+
context: ContextOptions;
|
|
32
25
|
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
33
26
|
cart?: CartInitialState;
|
|
34
27
|
}
|
|
@@ -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
|
|
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>>;
|
|
@@ -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<TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
@@ -1,8 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller Wiring Utilities
|
|
3
|
+
*
|
|
4
|
+
* Transforms simple user configuration into complex internal controller structures.
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from '@coveo/bueno';
|
|
1
7
|
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
2
8
|
import type { BuildConfig } from '../types/build.js';
|
|
3
|
-
import
|
|
9
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
4
10
|
import type { InferControllerPropsMapFromDefinitions } from '../types/controller-inference.js';
|
|
5
11
|
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
6
|
-
export declare
|
|
12
|
+
export declare const listingDefinitionSchema: Schema<{
|
|
13
|
+
searchParams: unknown;
|
|
14
|
+
context: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const searchDefinitionSchema: Schema<{
|
|
17
|
+
searchParams: unknown;
|
|
18
|
+
context: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const standaloneDefinitionSchema: Schema<{
|
|
21
|
+
context: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const recommendationsDefinitionSchema: Schema<{
|
|
24
|
+
context: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Converts simple user configuration (URL, language, currency, query) into the
|
|
28
|
+
* nested structure required by the internal {@link Build} method. Automatically generates
|
|
29
|
+
* appropriate controllers (context, cart, parameterManager) transparently.
|
|
30
|
+
*
|
|
31
|
+
* @param solutionType - The type of solution (search, listing, recommendation, standalone)
|
|
32
|
+
* @param controllerDefinitions - Map of controller definitions to be initialized
|
|
33
|
+
* @param buildConfig - Simple configuration object with simplified controller properties
|
|
34
|
+
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
35
|
+
*/
|
|
36
|
+
export declare function wireControllerParams<TControllerDefinitions extends CommerceControllerDefinitionsMap>(solutionType: SolutionType, controllerDefinitions: TControllerDefinitions, buildConfig: BuildConfig<SolutionType> & {
|
|
7
37
|
controllers?: ControllersPropsMap;
|
|
8
38
|
}): InferControllerPropsMapFromDefinitions<TControllerDefinitions>;
|
|
@@ -2,4 +2,4 @@ import type { CommerceEngineConfiguration } from '../../../app/commerce-engine/c
|
|
|
2
2
|
import type { CommerceEngineDefinitionOptions } from '../factories/build-factory.js';
|
|
3
3
|
import type { CommonBuildConfig } from '../types/build.js';
|
|
4
4
|
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
5
|
-
export declare function extendEngineConfiguration<TControllerDefinitions extends CommerceControllerDefinitionsMap>(
|
|
5
|
+
export declare function extendEngineConfiguration<TControllerDefinitions extends CommerceControllerDefinitionsMap>(configuration: CommerceEngineDefinitionOptions<TControllerDefinitions>['configuration'], commonBuildOptions: CommonBuildConfig): CommerceEngineConfiguration;
|
|
@@ -2,9 +2,7 @@ import { buildFactory, } from './build-factory.js';
|
|
|
2
2
|
export function hydratedStaticStateFactory(controllerDefinitions, options) {
|
|
3
3
|
return (solutionType) => async (...params) => {
|
|
4
4
|
const solutionTypeBuild = await buildFactory(controllerDefinitions, options)(solutionType);
|
|
5
|
-
const { engine, controllers } = await solutionTypeBuild(
|
|
6
|
-
// @ts-expect-error: TODO: KIT-4742: the wiring will fix also the type inconsistencies
|
|
7
|
-
...params);
|
|
5
|
+
const { engine, controllers } = await solutionTypeBuild(...params);
|
|
8
6
|
params[0].searchActions.forEach((action) => {
|
|
9
7
|
engine.dispatch(action);
|
|
10
8
|
});
|
|
@@ -3,9 +3,7 @@ import { buildFactory, } from './build-factory.js';
|
|
|
3
3
|
export function hydratedRecommendationStaticStateFactory(controllerDefinitions, options) {
|
|
4
4
|
return async (...params) => {
|
|
5
5
|
const solutionTypeBuild = await buildFactory(controllerDefinitions, options)(SolutionType.recommendation);
|
|
6
|
-
const { engine, controllers } = (await solutionTypeBuild(
|
|
7
|
-
// @ts-expect-error: TODO: KIT-4742: the wiring will fix also the type inconsistencies
|
|
8
|
-
...params));
|
|
6
|
+
const { engine, controllers } = (await solutionTypeBuild(...params));
|
|
9
7
|
params[0].searchActions.forEach((action) => {
|
|
10
8
|
engine.dispatch(action);
|
|
11
9
|
});
|
|
@@ -4,6 +4,7 @@ import { SolutionType } from '../types/controller-constants.js';
|
|
|
4
4
|
import { filterRecommendationControllers } from '../utils/recommendation-filter.js';
|
|
5
5
|
import { buildFactory, } from './build-factory.js';
|
|
6
6
|
export function fetchRecommendationStaticStateFactory(controllerDefinitions, options) {
|
|
7
|
+
// TODO: KIT-4619: no longer the right way to get the allowed recommendation keys
|
|
7
8
|
const getAllowedRecommendationKeys = (props) => {
|
|
8
9
|
if (props && 'controllers' in props) {
|
|
9
10
|
const enabledRecommendationControllers = filterObject(props.controllers, (value) => Boolean(value.enabled));
|
|
@@ -18,9 +19,13 @@ export function fetchRecommendationStaticStateFactory(controllerDefinitions, opt
|
|
|
18
19
|
const { engine, controllers } = (await solutionTypeBuild(...params));
|
|
19
20
|
filterRecommendationControllers(controllers, controllerDefinitions ?? {}).refresh(allowedRecommendationKeys);
|
|
20
21
|
const searchActions = await Promise.all(engine.waitForRequestCompletedAction());
|
|
21
|
-
|
|
22
|
+
const staticState = createStaticState({
|
|
22
23
|
searchActions,
|
|
23
24
|
controllers,
|
|
24
25
|
});
|
|
26
|
+
return {
|
|
27
|
+
...params[0], // TODO: KIT-4754: remove index access after no longer relying on OptionTuple type
|
|
28
|
+
...staticState,
|
|
29
|
+
};
|
|
25
30
|
};
|
|
26
31
|
}
|
|
@@ -27,6 +27,9 @@ export function fetchStaticStateFactory(controllerDefinitions, options) {
|
|
|
27
27
|
searchActions,
|
|
28
28
|
controllers,
|
|
29
29
|
});
|
|
30
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
...params[0], // TODO: KIT-4754: remove index access after no longer relying on OptionTuple type
|
|
32
|
+
...staticState,
|
|
33
|
+
};
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -1,4 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Controller Wiring Utilities
|
|
3
|
+
*
|
|
4
|
+
* Transforms simple user configuration into complex internal controller structures.
|
|
5
|
+
*/
|
|
6
|
+
import { RecordValue, Schema } from '@coveo/bueno';
|
|
7
|
+
import { contextDefinition } from '../../../features/commerce/context/context-validation.js';
|
|
8
|
+
import { parametersDefinition } from '../../../features/commerce/parameters/parameters-schema.js';
|
|
9
|
+
import { requiredEmptyAllowedString } from '../../../utils/validate-payload.js';
|
|
10
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
11
|
+
const requiredDefinition = {
|
|
12
|
+
context: new RecordValue({
|
|
13
|
+
options: { required: true },
|
|
14
|
+
values: contextDefinition,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
const listingDefinition = {
|
|
18
|
+
...requiredDefinition,
|
|
19
|
+
searchParams: new RecordValue({
|
|
20
|
+
values: parametersDefinition,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
const standaloneDefinition = {
|
|
24
|
+
...requiredDefinition,
|
|
25
|
+
};
|
|
26
|
+
const searchDefinition = {
|
|
27
|
+
...requiredDefinition,
|
|
28
|
+
searchParams: new RecordValue({
|
|
29
|
+
options: { required: true },
|
|
30
|
+
values: { query: requiredEmptyAllowedString, ...parametersDefinition },
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
const recommendationsDefinition = {
|
|
34
|
+
...requiredDefinition,
|
|
35
|
+
// recommendation: // TODO: KIT-4619: support array of recommendations
|
|
36
|
+
};
|
|
37
|
+
export const listingDefinitionSchema = new Schema(listingDefinition);
|
|
38
|
+
export const searchDefinitionSchema = new Schema(searchDefinition);
|
|
39
|
+
export const standaloneDefinitionSchema = new Schema(standaloneDefinition);
|
|
40
|
+
export const recommendationsDefinitionSchema = new Schema(recommendationsDefinition);
|
|
41
|
+
/**
|
|
42
|
+
* Validates the build configuration based on the solution type.
|
|
43
|
+
*/
|
|
44
|
+
function validateBuildConfig(solutionType, buildConfig) {
|
|
45
|
+
const validationMap = {
|
|
46
|
+
[SolutionType.listing]: listingDefinitionSchema,
|
|
47
|
+
[SolutionType.search]: searchDefinitionSchema,
|
|
48
|
+
[SolutionType.standalone]: standaloneDefinitionSchema,
|
|
49
|
+
[SolutionType.recommendation]: recommendationsDefinitionSchema,
|
|
50
|
+
};
|
|
51
|
+
const schema = validationMap[solutionType];
|
|
52
|
+
schema.validate(buildConfig);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Controller wiring class that handles the complete wiring process.
|
|
56
|
+
* Transforms simple user configuration into complex internal controller structures.
|
|
57
|
+
*/
|
|
58
|
+
class ControllerWirer {
|
|
59
|
+
buildConfig;
|
|
60
|
+
controllerDefinitions;
|
|
61
|
+
controllerProps;
|
|
62
|
+
constructor(buildConfig, controllerDefinitions, controllerProps) {
|
|
63
|
+
this.buildConfig = buildConfig;
|
|
64
|
+
this.controllerDefinitions = controllerDefinitions;
|
|
65
|
+
this.controllerProps = controllerProps;
|
|
66
|
+
}
|
|
67
|
+
wireParameterManager() {
|
|
68
|
+
if (!this.controllerDefinitions?.parameterManager)
|
|
69
|
+
return;
|
|
70
|
+
const { searchParams } = this.buildConfig;
|
|
71
|
+
const { query, ...rest } = searchParams || {};
|
|
72
|
+
const parameters = {
|
|
73
|
+
...(query && { q: query }),
|
|
74
|
+
...(rest && typeof rest === 'object' ? rest : {}),
|
|
75
|
+
};
|
|
76
|
+
this.controllerProps.parameterManager = {
|
|
77
|
+
initialState: { parameters },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
wireContext() {
|
|
81
|
+
if (!this.controllerDefinitions?.context)
|
|
82
|
+
return;
|
|
83
|
+
const { context } = this.buildConfig;
|
|
84
|
+
this.controllerProps.context = {
|
|
85
|
+
initialState: {
|
|
86
|
+
...context,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
wireCart() {
|
|
91
|
+
if (!this.controllerDefinitions?.cart || !this.buildConfig.cart)
|
|
92
|
+
return;
|
|
93
|
+
this.controllerProps.cart = {
|
|
94
|
+
initialState: this.buildConfig.cart,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
wireRecommendations() {
|
|
98
|
+
// TODO: KIT-4619: wire recommendations
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Wires all controllers based on solution type and controller definitions.
|
|
102
|
+
* Handles the complete wiring process in a sequential manner.
|
|
103
|
+
*/
|
|
104
|
+
wire(solutionType) {
|
|
105
|
+
// Wire common controllers that apply to all solution types
|
|
106
|
+
this.wireCart();
|
|
107
|
+
this.wireContext();
|
|
108
|
+
// Wire solution-specific controllers
|
|
109
|
+
switch (solutionType) {
|
|
110
|
+
case SolutionType.search:
|
|
111
|
+
case SolutionType.listing: {
|
|
112
|
+
this.wireParameterManager();
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case SolutionType.recommendation: {
|
|
116
|
+
this.wireRecommendations();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case SolutionType.standalone:
|
|
120
|
+
// No additional wiring needed for standalone
|
|
121
|
+
break;
|
|
122
|
+
default: {
|
|
123
|
+
// Exhaustive check - TypeScript will error if we miss a case
|
|
124
|
+
const _exhaustiveCheck = solutionType;
|
|
125
|
+
throw new Error(`Unsupported solution type: ${_exhaustiveCheck}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Converts simple user configuration (URL, language, currency, query) into the
|
|
132
|
+
* nested structure required by the internal {@link Build} method. Automatically generates
|
|
133
|
+
* appropriate controllers (context, cart, parameterManager) transparently.
|
|
134
|
+
*
|
|
135
|
+
* @param solutionType - The type of solution (search, listing, recommendation, standalone)
|
|
136
|
+
* @param controllerDefinitions - Map of controller definitions to be initialized
|
|
137
|
+
* @param buildConfig - Simple configuration object with simplified controller properties
|
|
138
|
+
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
139
|
+
*/
|
|
140
|
+
export function wireControllerParams(solutionType, controllerDefinitions, buildConfig) {
|
|
141
|
+
validateBuildConfig(solutionType, buildConfig);
|
|
142
|
+
const controllerProps = buildConfig.controllers ?? {};
|
|
143
|
+
new ControllerWirer(buildConfig, controllerDefinitions, controllerProps).wire(solutionType);
|
|
144
|
+
return controllerProps;
|
|
4
145
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export function extendEngineConfiguration(
|
|
2
|
-
|
|
3
|
-
return {
|
|
1
|
+
export function extendEngineConfiguration(configuration, commonBuildOptions) {
|
|
2
|
+
const { cart, context } = commonBuildOptions;
|
|
3
|
+
return {
|
|
4
|
+
...configuration,
|
|
5
|
+
context: {
|
|
6
|
+
...context,
|
|
7
|
+
},
|
|
8
|
+
cart,
|
|
9
|
+
};
|
|
4
10
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "3.29.2-pre.
|
|
1
|
+
export const VERSION = "3.29.2-pre.401eb1851f" || 'Test version';
|
|
2
2
|
export const COVEO_FRAMEWORK = ['@coveo/atomic', '@coveo/quantic'];
|