@coveo/headless 3.29.2-pre.326946f8df → 3.29.2-pre.34abdcbabf
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/controller-utils.d.ts +7 -5
- 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 +5 -4
- package/dist/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +5 -2
- package/dist/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts +3 -1
- package/dist/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts +12 -2
- package/dist/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +7 -2
- package/dist/definitions/ssr-next/commerce/types/build.d.ts +55 -10
- 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/engine.d.ts +5 -12
- 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 +15 -2
- 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 +12 -11
- package/dist/esm/ssr-next/commerce/factories/hydrated-state-factory.js +0 -3
- package/dist/esm/ssr-next/commerce/factories/recommendation-hydrated-state-factory.js +1 -4
- package/dist/esm/ssr-next/commerce/factories/recommendation-static-state-factory.js +2 -11
- 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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
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.34abdcbabf";
|
|
1310
1310
|
var COVEO_FRAMEWORK = ["@coveo/atomic", "@coveo/quantic"];
|
|
1311
1311
|
|
|
1312
1312
|
// src/api/analytics/analytics-selectors.ts
|
|
@@ -2,13 +2,15 @@ import type { UnknownAction } from '@reduxjs/toolkit';
|
|
|
2
2
|
import type { Controller } from '../../controllers/controller/headless-controller.js';
|
|
3
3
|
import type { SSRCommerceEngine } from './factories/build-factory.js';
|
|
4
4
|
import type { SolutionType } from './types/controller-constants.js';
|
|
5
|
-
import type { ControllerDefinitionOption, ControllerDefinitionsMap } from './types/controller-definitions.js';
|
|
5
|
+
import type { ControllerDefinitionOption, ControllerDefinitionsMap, FilteredBakedInControllers } from './types/controller-definitions.js';
|
|
6
6
|
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition } from './types/controller-inference.js';
|
|
7
|
-
|
|
8
|
-
export declare function createStaticState<TSearchAction extends UnknownAction, TControllerDefinitions extends ControllerDefinitionsMap<Controller>>({ searchActions, controllers, }: {
|
|
7
|
+
export declare function createStaticState<TSearchAction extends UnknownAction, TControllerDefinitions extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>({ searchActions, controllers, }: {
|
|
9
8
|
searchActions: TSearchAction[];
|
|
10
|
-
controllers:
|
|
11
|
-
}):
|
|
9
|
+
controllers: Record<string, Controller>;
|
|
10
|
+
}): {
|
|
11
|
+
controllers: InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllerDefinitions, TSolutionType> & FilteredBakedInControllers<TSolutionType>;
|
|
12
|
+
searchActions: TSearchAction[];
|
|
13
|
+
};
|
|
12
14
|
export declare function buildControllerDefinitions<TControllerDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType>({ definitionsMap, engine, solutionType, propsMap, }: {
|
|
13
15
|
definitionsMap: TControllerDefinitionsMap;
|
|
14
16
|
engine: SSRCommerceEngine;
|
|
@@ -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;
|
|
@@ -3,8 +3,9 @@ import { type CommerceEngine } from '../../../app/commerce-engine/commerce-engin
|
|
|
3
3
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
4
4
|
import type { SSRCommerceEngineOptions } from '../types/build.js';
|
|
5
5
|
import { SolutionType } from '../types/controller-constants.js';
|
|
6
|
-
import type { ControllerDefinitionsMap } from '../types/controller-definitions.js';
|
|
7
|
-
import type {
|
|
6
|
+
import type { AugmentedControllerDefinition, BakedInControllers, ControllerDefinitionsMap } from '../types/controller-definitions.js';
|
|
7
|
+
import type { InferControllersMapFromDefinition } from '../types/controller-inference.js';
|
|
8
|
+
import type { CommerceControllerDefinitionsMap, EngineDefinitionOptions, FetchStaticStateParameters, HydrateStaticStateParameters } from '../types/engine.js';
|
|
8
9
|
/**
|
|
9
10
|
* The SSR commerce engine.
|
|
10
11
|
*
|
|
@@ -17,7 +18,7 @@ export interface SSRCommerceEngine extends CommerceEngine {
|
|
|
17
18
|
waitForRequestCompletedAction(): Promise<Action>[];
|
|
18
19
|
}
|
|
19
20
|
export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<SSRCommerceEngineOptions, TControllers>;
|
|
20
|
-
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
21
|
+
export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => <TSolutionType extends SolutionType>(solutionType: TSolutionType) => (...[buildOptions]: FetchStaticStateParameters<TControllerDefinitions, TSolutionType> | HydrateStaticStateParameters<TControllerDefinitions, TSolutionType>) => Promise<{
|
|
21
22
|
engine: SSRCommerceEngine;
|
|
22
|
-
controllers:
|
|
23
|
+
controllers: InferControllersMapFromDefinition<TControllerDefinitions, TSolutionType> & BakedInControllers;
|
|
23
24
|
}>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { SolutionType } from '../types/controller-constants.js';
|
|
2
2
|
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
3
|
-
import type { CommerceControllerDefinitionsMap,
|
|
3
|
+
import type { CommerceControllerDefinitionsMap, HydrateStaticStateParameters } from '../types/engine.js';
|
|
4
4
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
5
|
-
export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType:
|
|
5
|
+
export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): <TSolutionType extends SolutionType>(solutionType: TSolutionType) => (...params: HydrateStaticStateParameters<TControllerDefinitions, TSolutionType>) => Promise<{
|
|
6
|
+
engine: import("./build-factory.js").SSRCommerceEngine;
|
|
7
|
+
controllers: import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions, TSolutionType> & import("../types/controller-definitions.js").BakedInControllers;
|
|
8
|
+
}>;
|
package/dist/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
2
|
+
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
1
3
|
import type { CommerceControllerDefinitionsMap, HydrateStaticStateFunction } from '../types/engine.js';
|
|
2
4
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
3
|
-
export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions
|
|
5
|
+
export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): HydrateStaticStateFunction<TControllerDefinitions, SolutionType.recommendation>;
|
package/dist/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
1
3
|
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
2
|
-
import type { CommerceControllerDefinitionsMap,
|
|
4
|
+
import type { CommerceControllerDefinitionsMap, FetchStaticStateParameters } from '../types/engine.js';
|
|
3
5
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
4
|
-
export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>):
|
|
6
|
+
export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (...params: FetchStaticStateParameters<TControllerDefinitions, SolutionType.recommendation>) => Promise<{
|
|
7
|
+
controllers: import("../types/controller-inference.js").InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllerDefinitions, SolutionType.recommendation> & import("../types/controller-definitions.js").FilteredBakedInControllers<SolutionType.recommendation>;
|
|
8
|
+
searchActions: UnknownAction[];
|
|
9
|
+
context: import("../../../commerce.index.js").ContextOptions;
|
|
10
|
+
searchParams?: import("../../../commerce.index.js").ParameterManagerState<import("../../../commerce.index.js").Parameters>["parameters"];
|
|
11
|
+
cart?: import("../../../commerce.index.js").CartInitialState;
|
|
12
|
+
productId?: string;
|
|
13
|
+
recommendations: Extract<keyof TControllerDefinitions, { [K in keyof TControllerDefinitions]: import("../../common/types/utilities.js").HasKey<TControllerDefinitions[K], SolutionType.recommendation> extends never ? never : import("../../common/types/utilities.js").HasKey<TControllerDefinitions[K], typeof import("../types/controller-constants.js").recommendationInternalOptionKey> extends never ? never : K; }[keyof TControllerDefinitions]>[];
|
|
14
|
+
}>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
+
import type { BuildConfig } from '../types/build.js';
|
|
1
3
|
import { SolutionType } from '../types/controller-constants.js';
|
|
2
4
|
import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
|
|
3
|
-
import type { CommerceControllerDefinitionsMap,
|
|
5
|
+
import type { CommerceControllerDefinitionsMap, FetchStaticStateParameters } from '../types/engine.js';
|
|
4
6
|
import { type CommerceEngineDefinitionOptions } from './build-factory.js';
|
|
5
|
-
export declare function fetchStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType:
|
|
7
|
+
export declare function fetchStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): <TSolutionType extends SolutionType>(solutionType: TSolutionType) => (...params: FetchStaticStateParameters<TControllerDefinitions, TSolutionType>) => Promise<BuildConfig<TControllerDefinitions, TSolutionType> & {
|
|
8
|
+
controllers: import("../types/controller-inference.js").InferControllerStaticStateMapFromDefinitionsWithSolutionType<TControllerDefinitions, TSolutionType> & import("../types/controller-definitions.js").FilteredBakedInControllers<TSolutionType>;
|
|
9
|
+
searchActions: UnknownAction[];
|
|
10
|
+
}>;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { OptionsTuple } from '../../common/types/utilities.js';
|
|
3
|
+
import type { HasKey } from '../../common/types/utilities.js';
|
|
5
4
|
import type { CartInitialState } from '../controllers/cart/headless-cart.ssr.js';
|
|
6
5
|
import type { ContextOptions } from '../controllers/context/headless-context.ssr.js';
|
|
7
6
|
import type { ParameterManagerState, Parameters } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
8
7
|
import type { SolutionType } from './controller-constants.js';
|
|
9
|
-
import type { ControllerDefinitionsMap,
|
|
10
|
-
import type { CommerceEngineDefinitionBuildResult } from './engine.js';
|
|
8
|
+
import type { ControllerDefinitionsMap, IsRecommendationController } from './controller-definitions.js';
|
|
11
9
|
export interface SearchBuildConfig extends CommonBuildConfig {
|
|
12
10
|
searchParams: ParameterManagerState<Parameters & {
|
|
13
11
|
query: string;
|
|
14
12
|
}>['parameters'];
|
|
15
13
|
}
|
|
16
|
-
export interface RecommendationBuildConfig extends CommonBuildConfig {
|
|
17
|
-
recommendations?: [];
|
|
18
|
-
}
|
|
19
14
|
export interface ListingBuildConfig extends CommonBuildConfig {
|
|
20
15
|
}
|
|
21
16
|
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
@@ -25,7 +20,6 @@ export interface CommonBuildConfig {
|
|
|
25
20
|
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
26
21
|
cart?: CartInitialState;
|
|
27
22
|
}
|
|
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
23
|
/**
|
|
30
24
|
* Commerce engine options for SSR scenarios where context is defined when fetching static state.
|
|
31
25
|
*/
|
|
@@ -33,6 +27,57 @@ export type SSRCommerceEngineOptions = Omit<CommerceEngineOptions, 'configuratio
|
|
|
33
27
|
configuration: Omit<CommerceEngineOptions['configuration'], 'context'>;
|
|
34
28
|
};
|
|
35
29
|
/**
|
|
36
|
-
*
|
|
30
|
+
* The `RecommendationBuildConfig` type defines the shape of the configuration object required when fetching static state for recommendations.
|
|
31
|
+
*
|
|
32
|
+
* The `recommendations` property is a string array containing the names of the recommendation controllers
|
|
33
|
+
* that were defined in your engine definition. This allows you to specify which recommendation controllers
|
|
34
|
+
* should be included in the SSR request.
|
|
35
|
+
*
|
|
36
|
+
* For example, on a storefront homepage, it might make sense to display a carousel of popular products.
|
|
37
|
+
* However, showing recommendations based on items frequently bought together may not be relevant in that context and should not be retrieved unnecessarily.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* Given the following engine definition:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
44
|
+
* controllers: {
|
|
45
|
+
* popularProducts: defineRecommendations({options: {slotId: '...'}}),
|
|
46
|
+
* frequentlyBought: defineRecommendations({options: {slotId: '...'}}),
|
|
47
|
+
* // ...other controllers
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // When fetching static state for recommendations:
|
|
52
|
+
* const staticState = await recommendationEngineDefinition.fetchStaticState({
|
|
53
|
+
* recommendations: ['popularProducts'],
|
|
54
|
+
* // ...other config
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* In this example, only the `popularProducts` recommendation controller will be included in the SSR request.
|
|
37
59
|
*/
|
|
38
|
-
export type
|
|
60
|
+
export type RecommendationBuildConfig<TControllers extends ControllerDefinitionsMap<Controller>> = CommonBuildConfig & {
|
|
61
|
+
/**
|
|
62
|
+
* The unique identifier of the product to use for seeded recommendations.
|
|
63
|
+
*/
|
|
64
|
+
productId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* An array of recommendation controller names from your engine definition to include in the SSR request.
|
|
67
|
+
* Each name corresponds to a key used when defining recommendation controllers in your engine definition.
|
|
68
|
+
* If not specified, no recommendation requests will be executed.
|
|
69
|
+
*/
|
|
70
|
+
recommendations: Array<Extract<keyof TControllers, {
|
|
71
|
+
[K in keyof TControllers]: HasKey<TControllers[K], SolutionType.recommendation> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? never : K;
|
|
72
|
+
}[keyof TControllers]>>;
|
|
73
|
+
};
|
|
74
|
+
export interface ListingBuildConfig extends CommonBuildConfig {
|
|
75
|
+
}
|
|
76
|
+
export interface StandaloneBuildConfig extends CommonBuildConfig {
|
|
77
|
+
}
|
|
78
|
+
export interface CommonBuildConfig {
|
|
79
|
+
context: ContextOptions;
|
|
80
|
+
searchParams?: ParameterManagerState<Parameters>['parameters'];
|
|
81
|
+
cart?: CartInitialState;
|
|
82
|
+
}
|
|
83
|
+
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;
|
|
@@ -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
|
};
|
|
@@ -4,7 +4,6 @@ import type { NavigatorContextProvider } from '../../../app/navigator-context-pr
|
|
|
4
4
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
5
5
|
import type { ControllerStaticStateMap, ControllersMap } from '../../common/types/controllers.js';
|
|
6
6
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
7
|
-
import type { Build } from './build.js';
|
|
8
7
|
import type { SolutionType } from './controller-constants.js';
|
|
9
8
|
import type { BakedInControllers, ControllerDefinitionsMap } from './controller-definitions.js';
|
|
10
9
|
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition } from './controller-inference.js';
|
|
@@ -58,14 +57,8 @@ export interface CommerceEngineDefinitionBuildResult<TControllers extends Contro
|
|
|
58
57
|
controllers: TControllers & BakedInControllers;
|
|
59
58
|
}
|
|
60
59
|
export type CommerceControllerDefinitionsMap = ControllerDefinitionsMap<Controller>;
|
|
61
|
-
type Definition<TControllerDefinitions extends CommerceControllerDefinitionsMap> = CommerceEngineDefinition<TControllerDefinitions,
|
|
62
|
-
|
|
63
|
-
export type HydrateStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['hydrateStaticState'];
|
|
64
|
-
export type
|
|
65
|
-
export type
|
|
66
|
-
export type HydrateStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<HydrateStaticStateFunction<TControllerDefinitions>>;
|
|
67
|
-
type Controllers<TControllerDefinitions extends CommerceControllerDefinitionsMap> = InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>;
|
|
68
|
-
export type BuildResult<TControllerDefinitions extends CommerceControllerDefinitionsMap> = {
|
|
69
|
-
engine: SSRCommerceEngine;
|
|
70
|
-
controllers: Controllers<TControllerDefinitions> & BakedInControllers;
|
|
71
|
-
};
|
|
60
|
+
type Definition<TControllerDefinitions extends CommerceControllerDefinitionsMap, TSolutionType extends SolutionType> = CommerceEngineDefinition<TControllerDefinitions, TSolutionType>;
|
|
61
|
+
type FetchStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap, TSolutionType extends SolutionType> = Definition<TControllerDefinitions, TSolutionType>['fetchStaticState'];
|
|
62
|
+
export type HydrateStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap, TSolutionType extends SolutionType> = Definition<TControllerDefinitions, TSolutionType>['hydrateStaticState'];
|
|
63
|
+
export type FetchStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap, TSolutionType extends SolutionType> = Parameters<FetchStaticStateFunction<TControllerDefinitions, TSolutionType>>;
|
|
64
|
+
export type HydrateStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap, TSolutionType extends SolutionType> = Parameters<HydrateStaticStateFunction<TControllerDefinitions, TSolutionType>>;
|
|
@@ -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.
|
|
@@ -7,5 +20,5 @@ export declare function filterRecommendationControllers<TControllerDefinitions e
|
|
|
7
20
|
* @param controllers - A record of all controllers where the key is the controller name and the value is the controller instance.
|
|
8
21
|
* @param controllerNames - A list of all recommendation controllers to refresh
|
|
9
22
|
*/
|
|
10
|
-
refresh(whitelist?:
|
|
23
|
+
refresh(whitelist?: Array<keyof TControllerDefinitions>): void;
|
|
11
24
|
};
|
|
@@ -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
|
};
|