@coveo/quantic 3.29.4 → 3.29.5-pre.0a9e457670
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/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +10 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/search-analytics.d.ts +3 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api.d.ts +28 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/tests/stream-answer-api-state-mock.d.ts +12 -12
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/sort/headless-core-sort.d.ts +0 -12
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-selectors.d.ts +4 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/fetch-static-state.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/build.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/engine.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.d.ts +8 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/build-factory.d.ts +4 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +2 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts +2 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +2 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +73 -7
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/controller-definitions.d.ts +35 -112
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/controller-inference.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +15 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +2 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/utilities.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/controller-wiring.d.ts +51 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/engine-wiring.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/recommendations/guards.d.ts +13 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/recommendations/recommendation-helpers.d.ts +18 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/validation/controller-validation.d.ts +11 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/fetch-static-state.d.ts +1 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/utilities.d.ts +0 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts +0 -8
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-ssr-controller-definitions.d.ts +12 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/headless.js +12 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +11 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +9 -7
- package/package.json +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/generated-answer-stream.d.ts +0 -15
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api-state.d.ts +0 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/recommendation-filter.d.ts +0 -11
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
2
|
import type { InvalidControllerDefinition } from '../../common/errors.js';
|
|
3
3
|
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
|
-
import type { EngineDefinitionBuildResult } from '../../common/types/engine.js';
|
|
5
4
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
6
5
|
import type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers } from '../../common/types/inference.js';
|
|
7
|
-
import type { HasKey,
|
|
6
|
+
import type { HasKey, HasRequiredKeys, OptionsTuple } from '../../common/types/utilities.js';
|
|
7
|
+
import type { CartDefinition } from '../controllers/cart/headless-cart.ssr.js';
|
|
8
|
+
import type { ContextDefinition } from '../controllers/context/headless-context.ssr.js';
|
|
9
|
+
import type { ParameterManagerDefinition } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
|
|
8
10
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
9
11
|
import { type recommendationInternalOptionKey, SolutionType } from './controller-constants.js';
|
|
10
12
|
import type { ListingAndStandaloneController, ListingOnlyController, NonRecommendationController, RecommendationOnlyController, SearchAndListingController, SearchOnlyController, UniversalController } from './controller-scopes.js';
|
|
11
13
|
import type { Kind } from './kind.js';
|
|
12
|
-
|
|
13
|
-
export type
|
|
14
|
-
/**
|
|
15
|
-
* Toggle to enable or disable the recommendation controller.
|
|
16
|
-
* When set to `true`, the controller will perform a recommendation request server-side.
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
enabled?: boolean;
|
|
21
|
-
};
|
|
14
|
+
import type { HasSolutionType } from './utilities.js';
|
|
15
|
+
export type { HydratedState, OptionsTuple, InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, };
|
|
22
16
|
export interface ControllerDefinitionWithoutProps<TController extends Controller> {
|
|
23
17
|
/**
|
|
24
18
|
* Creates an instance of the given controller.
|
|
@@ -53,123 +47,52 @@ export type ControllerDefinition<TController extends Controller> = SolutionTypeA
|
|
|
53
47
|
export interface ControllerDefinitionsMap<TController extends Controller> {
|
|
54
48
|
[customName: string]: ControllerDefinition<TController>;
|
|
55
49
|
}
|
|
50
|
+
type BakedInControllerDefinitions = {
|
|
51
|
+
parameterManager: ParameterManagerDefinition<{
|
|
52
|
+
listing: true;
|
|
53
|
+
search: true;
|
|
54
|
+
}>;
|
|
55
|
+
context: ContextDefinition;
|
|
56
|
+
cart: CartDefinition;
|
|
57
|
+
};
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
59
|
+
* Map of baked-in controllers
|
|
58
60
|
*/
|
|
59
|
-
export type
|
|
61
|
+
export type BakedInControllers = {
|
|
62
|
+
[K in keyof BakedInControllerDefinitions]: BakedInControllerDefinitions[K]['buildWithProps'];
|
|
63
|
+
};
|
|
60
64
|
/**
|
|
61
|
-
*
|
|
65
|
+
* A dynamically filtered map of baked-in controller definitions based on solution type compatibility.
|
|
62
66
|
*
|
|
63
|
-
* This type
|
|
64
|
-
*
|
|
67
|
+
* This type automatically includes only the baked-in controllers that are available for the specified
|
|
68
|
+
* solution type by checking each controller's `SolutionTypeAvailability` configuration. Controllers
|
|
69
|
+
* that don't support the given solution type are excluded from the resulting type.
|
|
65
70
|
*
|
|
66
|
-
* @template
|
|
67
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
68
|
-
* @template TSolutionType - The type of solution.
|
|
69
|
-
*
|
|
70
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
71
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
72
|
-
* 2. The controller properties have optional options (HasOptionalKeys<ConditionalControllerProps<...>> is true).
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* Given the following controller definitions:
|
|
76
|
-
* ```
|
|
77
|
-
* const {recommendationEngineDefinition} = defineCommerceEngine({
|
|
78
|
-
* controllers: {
|
|
79
|
-
* popularViewed: defineRecommendations({
|
|
80
|
-
* options: {slotId: 'slot-id'}
|
|
81
|
-
* })
|
|
82
|
-
* }
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* The following code will not throw an error since the 'popularViewed' controller props are optional
|
|
87
|
-
* ```
|
|
88
|
-
* recommendationEngineDefinition.fetchStaticState({
|
|
89
|
-
* controllers: {
|
|
90
|
-
* popularViewed: {enabled: true, productId: 'some-product-id'} // This is optional
|
|
91
|
-
* }
|
|
92
|
-
* })
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* The following code (with no arguments) is also valid because the 'popularViewed' controller props are optional, and there are no other required controller props in the engine definition.
|
|
96
|
-
* ```
|
|
97
|
-
* recommendationEngineDefinition.fetchStaticState()
|
|
98
|
-
* ```
|
|
71
|
+
* @template TSolutionType - The target solution type to filter controllers for
|
|
99
72
|
*/
|
|
100
|
-
type
|
|
101
|
-
[K in keyof
|
|
73
|
+
export type FilteredBakedInControllers<TSolutionType extends SolutionType> = {
|
|
74
|
+
[K in keyof BakedInControllers as HasSolutionType<BakedInControllerDefinitions[K], TSolutionType> extends true ? K : never]: BakedInControllers[K];
|
|
102
75
|
};
|
|
103
76
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* @template TControllers - A map of controller definitions.
|
|
107
|
-
* @template TControllersPropsMap - A map of controller properties.
|
|
108
|
-
* @template TSolutionType - The type of solution being used.
|
|
109
|
-
*
|
|
110
|
-
* The type iterates over the controller keys (defined in the engine definition) and includes only those keys where:
|
|
111
|
-
* 1. The controller can be used for a specific solution type (HasKey<TControllers[K], TSolutionType> is not 'never').
|
|
112
|
-
* 2. The controller properties have required options (HasRequiredKeys<ConditionalControllerProps<...>> is true).
|
|
77
|
+
* Map of controller definitions available to the commerce engine definition.
|
|
113
78
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* Given the following controller definitions:
|
|
118
|
-
* ```
|
|
119
|
-
* const {standaloneEngineDefinition} = defineCommerceEngine({
|
|
120
|
-
* controllers: {cart: defineCart()},
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* The following code will not throw an error since the 'cart' controller props are required for the standalone engine definition:
|
|
125
|
-
* ```
|
|
126
|
-
* standaloneEngineDefinition.fetchStaticState({
|
|
127
|
-
* controllers: {
|
|
128
|
-
* cart: {initialState: {items: []}},
|
|
129
|
-
* },
|
|
130
|
-
* })
|
|
131
|
-
* ```
|
|
79
|
+
* This type combines user-defined controllers with the system's baked-in controllers
|
|
80
|
+
* (parameterManager, context, and cart).
|
|
132
81
|
*
|
|
82
|
+
* @template TControllerDefinitions - The controller definitions map
|
|
133
83
|
*/
|
|
134
|
-
type
|
|
135
|
-
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : HasRequiredKeys<ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>> extends false ? never : 'controllers']: ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>;
|
|
136
|
-
};
|
|
137
|
-
type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
84
|
+
export type AugmentedControllerDefinition<TControllerDefinitions extends ControllerDefinitionsMap<Controller>> = TControllerDefinitions & BakedInControllerDefinitions;
|
|
138
85
|
/**
|
|
139
|
-
* This type
|
|
140
|
-
*
|
|
141
|
-
* It works by checking if the controller definition includes the `recommendationInternalOptionKey`.
|
|
142
|
-
*
|
|
143
|
-
* - If the key is present, the controller props are made optional.
|
|
144
|
-
* - If the key is absent, the controller props are required.
|
|
145
|
-
*
|
|
146
|
-
* Example:
|
|
147
|
-
*
|
|
148
|
-
* ```typescript
|
|
149
|
-
* type ControllerProps = InferControllerPropsFromDefinition<{
|
|
150
|
-
* recommendation: defineRecommendation({}),
|
|
151
|
-
* cart: defineCart(),
|
|
152
|
-
* }>;
|
|
153
|
-
*
|
|
154
|
-
* // In this example:
|
|
155
|
-
* // - The `recommendation` controller props are optional.
|
|
156
|
-
* // - The `cart` controller props are required.
|
|
157
|
-
*
|
|
158
|
-
* const props: ControllerProps = {
|
|
159
|
-
* cart: {initialState: {items: []}},
|
|
160
|
-
* // recommendation props can be omitted
|
|
161
|
-
* };
|
|
162
|
-
* ```
|
|
86
|
+
* This type defines the required and optional controller props for the engine definition.
|
|
163
87
|
*/
|
|
164
|
-
type
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
[I in keyof TControllersPropsMap as I extends K ? IsRecommendationController<TControllers[I]> extends never ? I : never : never]: TControllersPropsMap[I];
|
|
88
|
+
export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
|
|
89
|
+
type RequiredEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = {
|
|
90
|
+
[K in keyof TControllers as HasKey<TControllers[K], TSolutionType> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? HasRequiredKeys<DefaultControllerProps<TControllers, TControllersPropsMap, K>> extends false ? never : 'controllers' : never]: DefaultControllerProps<TControllers, TControllersPropsMap, K>;
|
|
168
91
|
};
|
|
92
|
+
export type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
|
|
169
93
|
type DefaultControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
|
|
170
94
|
[I in keyof TControllersPropsMap as I extends K ? I : never]: TControllersPropsMap[I];
|
|
171
95
|
};
|
|
172
|
-
type ConditionalControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType, K extends keyof TControllers> = TSolutionType extends SolutionType.recommendation ? RecommendationControllerProps<TControllers, TControllersPropsMap, K> : DefaultControllerProps<TControllers, TControllersPropsMap, K>;
|
|
173
96
|
export interface ControllerDefinitionOption {
|
|
174
97
|
/**
|
|
175
98
|
* Whether the controller will be used in a product listing context.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
2
|
import type { HasKey, HasKeys } from '../../common/types/utilities.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { ControllerDefinition, ControllerDefinitionsMap, ControllerDefinitionWithoutProps, ControllerDefinitionWithProps, InferControllerStaticStateFromController
|
|
3
|
+
import type { SolutionType } from './controller-constants.js';
|
|
4
|
+
import type { ControllerDefinition, ControllerDefinitionsMap, ControllerDefinitionWithoutProps, ControllerDefinitionWithProps, InferControllerStaticStateFromController } from './controller-definitions.js';
|
|
5
5
|
export type InferStaticState<T extends {
|
|
6
6
|
fetchStaticState(...args: unknown[]): Promise<unknown>;
|
|
7
7
|
}> = Awaited<ReturnType<T['fetchStaticState']>>;
|
|
8
8
|
export type InferHydratedState<T extends {
|
|
9
9
|
hydrateStaticState(...args: unknown[]): Promise<unknown>;
|
|
10
10
|
}> = Awaited<ReturnType<T['hydrateStaticState']>>;
|
|
11
|
-
type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ?
|
|
11
|
+
type InferControllerPropsFromDefinition<TController extends ControllerDefinition<Controller>> = TController extends ControllerDefinitionWithProps<Controller, infer Props> ? Props : TController extends ControllerDefinitionWithoutProps<Controller> ? {} : unknown;
|
|
12
12
|
export type InferControllerPropsMapFromDefinitions<TControllers extends ControllerDefinitionsMap<Controller>> = {
|
|
13
13
|
[K in keyof TControllers as HasKeys<InferControllerPropsFromDefinition<TControllers[K]>> extends false ? never : K]: InferControllerPropsFromDefinition<TControllers[K]>;
|
|
14
14
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
|
-
import type { CommerceEngineOptions } from '../../../app/commerce-engine/commerce-engine.js';
|
|
3
2
|
import type { EngineConfiguration } from '../../../app/engine-configuration.js';
|
|
4
3
|
import type { NavigatorContextProvider } from '../../../app/navigator-context-provider.js';
|
|
5
4
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
6
|
-
import type { ControllerStaticStateMap } from '../../common/types/controllers.js';
|
|
5
|
+
import type { ControllerStaticStateMap, ControllersMap } from '../../common/types/controllers.js';
|
|
7
6
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
8
7
|
import type { Build } from './build.js';
|
|
9
8
|
import type { SolutionType } from './controller-constants.js';
|
|
10
|
-
import type { ControllerDefinitionsMap } from './controller-definitions.js';
|
|
9
|
+
import type { BakedInControllers, ControllerDefinitionsMap } from './controller-definitions.js';
|
|
11
10
|
import type { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitionsWithSolutionType, InferControllersMapFromDefinition } from './controller-inference.js';
|
|
12
|
-
import type { FetchStaticState
|
|
11
|
+
import type { FetchStaticState } from './fetch-static-state.js';
|
|
13
12
|
import type { HydrateStaticState, HydrateStaticStateOptions } from './hydrate-static-state.js';
|
|
14
|
-
export type { HydrateStaticState, HydrateStaticStateOptions, FetchStaticState
|
|
13
|
+
export type { HydrateStaticState, HydrateStaticStateOptions, FetchStaticState };
|
|
15
14
|
export interface EngineStaticState<TSearchAction extends UnknownAction, TControllers extends ControllerStaticStateMap> {
|
|
16
15
|
searchActions: TSearchAction[];
|
|
17
16
|
controllers: TControllers;
|
|
18
17
|
}
|
|
18
|
+
type ReservedControllerNames = 'context' | 'parameterManager' | 'cart';
|
|
19
|
+
type ValidateControllerNames<T extends ControllerDefinitionsMap<Controller>> = {
|
|
20
|
+
[K in keyof T]: K extends ReservedControllerNames ? `ERROR: Controller name "${K & string}" is reserved and cannot be used. Reserved names are: context, parameterManager, cart. Please choose a different controller name.` : T[K];
|
|
21
|
+
};
|
|
19
22
|
export type EngineDefinitionOptions<TOptions extends {
|
|
20
23
|
configuration: EngineConfiguration;
|
|
21
24
|
}, TControllers extends ControllerDefinitionsMap<Controller>> = TOptions & {
|
|
22
25
|
/**
|
|
23
26
|
* The controllers to initialize with the commerce engine.
|
|
24
27
|
*/
|
|
25
|
-
controllers?: TControllers
|
|
28
|
+
controllers?: ValidateControllerNames<TControllers>;
|
|
26
29
|
};
|
|
27
30
|
export interface CommerceEngineDefinition<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> {
|
|
28
31
|
/**
|
|
@@ -50,15 +53,19 @@ export interface CommerceEngineDefinition<TControllers extends ControllerDefinit
|
|
|
50
53
|
*/
|
|
51
54
|
setAccessToken: (accessToken: string) => void;
|
|
52
55
|
}
|
|
56
|
+
export interface CommerceEngineDefinitionBuildResult<TControllers extends ControllersMap> {
|
|
57
|
+
engine: SSRCommerceEngine;
|
|
58
|
+
controllers: TControllers & BakedInControllers;
|
|
59
|
+
}
|
|
53
60
|
export type CommerceControllerDefinitionsMap = ControllerDefinitionsMap<Controller>;
|
|
54
61
|
type Definition<TControllerDefinitions extends CommerceControllerDefinitionsMap> = CommerceEngineDefinition<TControllerDefinitions, SolutionType>;
|
|
55
62
|
export type FetchStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['fetchStaticState'];
|
|
56
63
|
export type HydrateStaticStateFunction<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Definition<TControllerDefinitions>['hydrateStaticState'];
|
|
57
|
-
export type BuildParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<Build<
|
|
64
|
+
export type BuildParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<Build<InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>, InferControllerPropsMapFromDefinitions<TControllerDefinitions>, TControllerDefinitions, SolutionType>>;
|
|
58
65
|
export type FetchStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<FetchStaticStateFunction<TControllerDefinitions>>;
|
|
59
66
|
export type HydrateStaticStateParameters<TControllerDefinitions extends CommerceControllerDefinitionsMap> = Parameters<HydrateStaticStateFunction<TControllerDefinitions>>;
|
|
60
67
|
type Controllers<TControllerDefinitions extends CommerceControllerDefinitionsMap> = InferControllersMapFromDefinition<TControllerDefinitions, SolutionType>;
|
|
61
68
|
export type BuildResult<TControllerDefinitions extends CommerceControllerDefinitionsMap> = {
|
|
62
69
|
engine: SSRCommerceEngine;
|
|
63
|
-
controllers: Controllers<TControllerDefinitions
|
|
70
|
+
controllers: Controllers<TControllerDefinitions> & BakedInControllers;
|
|
64
71
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { UnknownAction } from '@reduxjs/toolkit';
|
|
2
2
|
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
3
3
|
import type { ControllerStaticStateMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
|
+
import type { BuildConfig } from './build.js';
|
|
4
5
|
import type { SolutionType } from './controller-constants.js';
|
|
5
|
-
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
6
|
+
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, FilteredBakedInControllers, OptionsTuple } from './controller-definitions.js';
|
|
6
7
|
import type { EngineStaticState } from './engine.js';
|
|
7
|
-
export type FetchStaticStateOptions = {};
|
|
8
8
|
/**
|
|
9
9
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
10
10
|
*
|
|
11
11
|
* Useful for static generation and server-side rendering.
|
|
12
12
|
*/
|
|
13
|
-
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<
|
|
13
|
+
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TControllersDefinitionsMap, TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<EngineStaticState<TSearchAction, TControllersStaticState & FilteredBakedInControllers<TSolutionType>> & BuildConfig<TControllersDefinitionsMap, TSolutionType>>;
|
|
@@ -3,6 +3,7 @@ import type { Controller } from '../../../controllers/controller/headless-contro
|
|
|
3
3
|
import type { ControllersMap, ControllersPropsMap } from '../../common/types/controllers.js';
|
|
4
4
|
import type { HydratedState } from '../../common/types/hydrate-static-state.js';
|
|
5
5
|
import type { SSRCommerceEngine } from '../factories/build-factory.js';
|
|
6
|
+
import type { BuildConfig } from './build.js';
|
|
6
7
|
import type { SolutionType } from './controller-constants.js';
|
|
7
8
|
import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption, OptionsTuple } from './controller-definitions.js';
|
|
8
9
|
export interface HydrateStaticStateOptions<TSearchAction> {
|
|
@@ -13,4 +14,4 @@ export interface HydrateStaticStateOptions<TSearchAction> {
|
|
|
13
14
|
*
|
|
14
15
|
* Useful when hydrating a server-side-rendered engine.
|
|
15
16
|
*/
|
|
16
|
-
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<HydrateStaticStateOptions<TSearchAction> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
17
|
+
export type HydrateStaticState<TControllers extends ControllersMap, TSearchAction extends UnknownAction, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<HydrateStaticStateOptions<TSearchAction> & BuildConfig<TControllersDefinitionsMap, TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<HydratedState<SSRCommerceEngine, TControllers>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SolutionType } from './controller-constants.js';
|
|
2
|
+
export type HasSolutionType<TDefinition, TSolutionType extends SolutionType> = TDefinition extends {
|
|
3
|
+
[K in TSolutionType]: true;
|
|
4
|
+
} ? true : TDefinition extends {
|
|
5
|
+
[K in TSolutionType]: false;
|
|
6
|
+
} ? false : false;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller Wiring Utilities
|
|
3
|
+
*
|
|
4
|
+
* Transforms simple user configuration into complex internal controller structures.
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from '@coveo/bueno';
|
|
7
|
+
import type { ControllersPropsMap } from '../../common/types/controllers.js';
|
|
8
|
+
import type { BuildConfig } from '../types/build.js';
|
|
9
|
+
import { SolutionType } from '../types/controller-constants.js';
|
|
10
|
+
import type { InferControllerPropsMapFromDefinitions } from '../types/controller-inference.js';
|
|
11
|
+
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
12
|
+
export declare const listingDefinitionSchema: Schema<{
|
|
13
|
+
language: string;
|
|
14
|
+
country: string;
|
|
15
|
+
currency: import("@coveo/relay-event-types").CurrencyCodeISO4217;
|
|
16
|
+
url: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const searchDefinitionSchema: Schema<{
|
|
19
|
+
query: string;
|
|
20
|
+
language: string;
|
|
21
|
+
country: string;
|
|
22
|
+
currency: import("@coveo/relay-event-types").CurrencyCodeISO4217;
|
|
23
|
+
url: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const standaloneDefinitionSchema: Schema<{
|
|
26
|
+
language: string;
|
|
27
|
+
country: string;
|
|
28
|
+
currency: import("@coveo/relay-event-types").CurrencyCodeISO4217;
|
|
29
|
+
url: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const recommendationsDefinitionSchema: (recommendationName: string[]) => Schema<{
|
|
32
|
+
recommendations: import("@coveo/bueno").PrimitivesValues[] | null | undefined;
|
|
33
|
+
productId: string;
|
|
34
|
+
language: string;
|
|
35
|
+
country: string;
|
|
36
|
+
currency: import("@coveo/relay-event-types").CurrencyCodeISO4217;
|
|
37
|
+
url: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Converts simple user configuration (URL, language, currency, query) into the
|
|
41
|
+
* nested structure required by the internal {@link Build} method. Automatically generates
|
|
42
|
+
* appropriate controllers (context, cart, parameterManager) transparently.
|
|
43
|
+
*
|
|
44
|
+
* @param solutionType - The type of solution (search, listing, recommendation, standalone)
|
|
45
|
+
* @param controllerDefinitions - Map of controller definitions to be initialized
|
|
46
|
+
* @param buildConfig - Simple configuration object with simplified controller properties
|
|
47
|
+
* @returns Formatted and validated controller properties map defined for the controller in the definition
|
|
48
|
+
*/
|
|
49
|
+
export declare function wireControllerParams<TControllerDefinitions extends CommerceControllerDefinitionsMap>(solutionType: SolutionType, controllerDefinitions: TControllerDefinitions, buildConfig: BuildConfig<TControllerDefinitions, SolutionType> & {
|
|
50
|
+
controllers?: ControllersPropsMap;
|
|
51
|
+
}): InferControllerPropsMapFromDefinitions<TControllerDefinitions>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommerceEngineConfiguration } from '../../../app/commerce-engine/commerce-engine.js';
|
|
2
|
+
import type { CommerceEngineDefinitionOptions } from '../factories/build-factory.js';
|
|
3
|
+
import type { CommonBuildConfig } from '../types/build.js';
|
|
4
|
+
import type { CommerceControllerDefinitionsMap } from '../types/engine.js';
|
|
5
|
+
export declare function extendEngineConfiguration<TControllerDefinitions extends CommerceControllerDefinitionsMap>(configuration: CommerceEngineDefinitionOptions<TControllerDefinitions>['configuration'], commonBuildOptions: CommonBuildConfig): CommerceEngineConfiguration;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Recommendations } from '../../../../controllers/commerce/recommendations/headless-recommendations.js';
|
|
2
|
+
import type { Controller } from '../../../../controllers/controller/headless-controller.js';
|
|
3
|
+
import type { RecommendationsDefinitionMeta } from '../../controllers/recommendations/headless-recommendations.ssr.js';
|
|
4
|
+
import type { ControllerDefinition } from '../../types/controller-definitions.js';
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a controller definition is a recommendation controller.
|
|
7
|
+
* A recommendation controller must have both the recommendation flag and a slotId.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isRecommendationDefinition<C extends ControllerDefinition<Controller>>(controllerDefinition: C): controllerDefinition is C & RecommendationsDefinitionMeta;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if a controller instance is a recommendation controller.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isRecommendationController(controller: Controller): controller is Recommendations;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Controller } from '../../../../controllers/controller/headless-controller.js';
|
|
2
|
+
import type { RecommendationsDefinitionMeta } from '../../controllers/recommendations/headless-recommendations.ssr.js';
|
|
3
|
+
import type { ControllerDefinition, ControllerDefinitionsMap } from '../../types/controller-definitions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts recommendation controller definitions from a controller definitions map.
|
|
6
|
+
*
|
|
7
|
+
* @param controllerDefinitions - Map of controller definitions
|
|
8
|
+
* @returns Object containing only the recommendation controller definitions
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRecommendationDefinitions(controllerDefinitions: ControllerDefinitionsMap<Controller>): Record<string, ControllerDefinition<Controller> & RecommendationsDefinitionMeta>;
|
|
11
|
+
/**
|
|
12
|
+
* Refreshes the specified recommendation controllers.
|
|
13
|
+
*
|
|
14
|
+
* @param controllers - Record of controller instances
|
|
15
|
+
* @param controllerDefinitions - Map of controller definitions
|
|
16
|
+
* @param controllerNames - Array of recommendation controller names to refresh
|
|
17
|
+
*/
|
|
18
|
+
export declare function refreshRecommendationControllers<TControllerDefinitions extends ControllerDefinitionsMap<Controller>>(controllers: Record<string, Controller>, recommendationDefinitions: TControllerDefinitions, controllerNames?: string[]): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Controller } from '../../../controllers/controller/headless-controller.js';
|
|
2
|
+
import type { RecommendationsDefinitionMeta } from '../controllers/recommendations/headless-recommendations.ssr.js';
|
|
3
|
+
import type { ControllerDefinition } from '../types/controller-definitions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Validates that each slotId is unique across recommendation controllers.
|
|
6
|
+
*
|
|
7
|
+
* @param controllerDefinitions - Map of controller definitions to validate
|
|
8
|
+
* @throws {MultipleRecommendationError} When duplicate slotIds are found
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateUniqueRecommendationSlotIds(recommendationDefinitions: Record<string, ControllerDefinition<Controller> & RecommendationsDefinitionMeta>): void;
|
|
11
|
+
export declare const validateControllerNames: (controllers: Record<string, unknown>) => void;
|
|
@@ -2,11 +2,9 @@ import type { UnknownAction } from '@reduxjs/toolkit';
|
|
|
2
2
|
import type { ControllerStaticStateMap, ControllersPropsMap } from './controllers.js';
|
|
3
3
|
import type { EngineDefinitionControllersPropsOption, EngineStaticState } from './engine.js';
|
|
4
4
|
import type { OptionsTuple } from './utilities.js';
|
|
5
|
-
type FetchStaticStateOptions = {};
|
|
6
5
|
/**
|
|
7
6
|
* Executes only the initial search for a given configuration, then returns a resumable snapshot of engine state along with the state of the controllers.
|
|
8
7
|
*
|
|
9
8
|
* Useful for static generation and server-side rendering.
|
|
10
9
|
*/
|
|
11
|
-
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap> = (...params: OptionsTuple<
|
|
12
|
-
export {};
|
|
10
|
+
export type FetchStaticState<TSearchAction extends UnknownAction, TControllersStaticState extends ControllerStaticStateMap, TControllersProps extends ControllersPropsMap> = (...params: OptionsTuple<EngineDefinitionControllersPropsOption<TControllersProps>>) => Promise<EngineStaticState<TSearchAction, TControllersStaticState>>;
|
|
@@ -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
|
};
|
package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { BaseQueryFn, CombinedState, FetchArgs, FetchBaseQueryError, QueryDefinition, RetryOptions } from '@reduxjs/toolkit/query';
|
|
2
|
-
import type { GeneratedAnswerStream } from '../api/knowledge/generated-answer-stream.js';
|
|
3
|
-
import type { SearchRequest } from '../api/search/search/search-request.js';
|
|
4
1
|
import type { StateWithHistory } from '../app/undoable.js';
|
|
5
2
|
import type { AdvancedSearchQueriesState } from '../features/advanced-search-queries/advanced-search-queries-state.js';
|
|
6
3
|
import type { AttachedResultsState } from '../features/attached-results/attached-results-state.js';
|
|
@@ -441,8 +438,3 @@ export interface InsightUserActionsSection {
|
|
|
441
438
|
export interface ManualRangeSection {
|
|
442
439
|
manualNumericFacetSet: ManualNumericFacetSetState;
|
|
443
440
|
}
|
|
444
|
-
export interface GetAnswerQuerySection {
|
|
445
|
-
answer: CombinedState<{
|
|
446
|
-
getAnswer: QueryDefinition<Partial<SearchRequest>, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {} & RetryOptions, {}>, never, GeneratedAnswerStream, 'answer'>;
|
|
447
|
-
}, never, 'answer'>;
|
|
448
|
-
}
|
|
@@ -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/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare function sortFacets<T extends {
|
|
|
9
9
|
facetId: string;
|
|
10
10
|
}>(facets: T[], sortOrder: string[]): T[];
|
|
11
11
|
export declare const sortCriteriaMap: Record<string, SortCriteria>;
|
|
12
|
-
export declare function getFacets(state: StateNeededBySearchRequest): (import("../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../features/facets/range-facets/
|
|
12
|
+
export declare function getFacets(state: StateNeededBySearchRequest): (import("../features/facets/facet-set/interfaces/request.js").FacetRequest | import("../features/facets/category-facet-set/interfaces/request.js").CategoryFacetRequest | import("../features/facets/range-facets/numeric-facet-set/interfaces/request.js").NumericFacetRequest | import("../features/facets/range-facets/date-facet-set/interfaces/request.js").DateFacetRequest)[];
|
|
13
13
|
export {};
|