@coveo/quantic 3.29.6 → 3.29.7-pre.0e2721db97

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.
Files changed (100) hide show
  1. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +4 -2
  2. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/controller-definitions.d.ts +3 -0
  3. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce-next.index.d.ts +11 -11
  4. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +1 -1
  5. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controller-utils.d.ts +1 -2
  6. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/breadcrumb-manager/headless-core-breadcrumb-manager.ssr.d.ts +3 -2
  7. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/cart/headless-cart.ssr.d.ts +1 -2
  8. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/context/headless-context.ssr.d.ts +2 -3
  9. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/did-you-mean/headless-did-you-mean.ssr.d.ts +2 -1
  10. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/filter-suggestions/headless-filter-suggestions-generator.ssr.d.ts +1 -2
  11. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/generator/headless-commerce-facet-generator.ssr.d.ts +3 -2
  12. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/instant-products/headless-instant-products.ssr.d.ts +1 -2
  13. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/pagination/headless-core-commerce-pagination.ssr.d.ts +3 -2
  14. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/parameter-manager/headless-core-parameter-manager.ssr.d.ts +3 -13
  15. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/product-list/headless-product-list.ssr.d.ts +3 -2
  16. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/product-view/headless-product-view.ssr.d.ts +1 -3
  17. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/recent-queries-list/headless-recent-queries-list.ssr.d.ts +1 -2
  18. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/recommendations/headless-recommendations.ssr.d.ts +8 -4
  19. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/search-box/headless-search-box.ssr.d.ts +1 -2
  20. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/sort/headless-core-commerce-sort.ssr.d.ts +3 -2
  21. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/standalone-search-box/headless-standalone-search-box.ssr.d.ts +1 -2
  22. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/summary/headless-core-summary.ssr.d.ts +3 -2
  23. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/triggers/headless-notify-trigger.ssr.d.ts +1 -2
  24. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/triggers/headless-query-trigger.ssr.d.ts +1 -2
  25. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/controllers/triggers/headless-redirection-trigger.ssr.d.ts +1 -2
  26. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/engine/commerce-engine.ssr.d.ts +1 -2
  27. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/build-factory.d.ts +1 -5
  28. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/hydrated-state-factory.d.ts +3 -3
  29. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/recommendation-hydrated-state-factory.d.ts +1 -2
  30. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/recommendation-static-state-factory.d.ts +1 -2
  31. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/factories/static-state-factory.d.ts +1 -2
  32. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +60 -16
  33. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/controller-definitions.d.ts +10 -170
  34. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/controller-inference.d.ts +5 -10
  35. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +7 -5
  36. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/fetch-static-state.d.ts +2 -2
  37. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/hydrate-static-state.d.ts +5 -4
  38. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/controller-wiring.d.ts +29 -2
  39. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/engine-wiring.d.ts +2 -3
  40. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/utils/recommendation-filter.d.ts +14 -1
  41. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/controller-inference.d.ts +6 -0
  42. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/controllers.d.ts +0 -24
  43. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/engine.d.ts +2 -44
  44. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/utilities.d.ts +0 -3
  45. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/{common → search}/controller-utils.d.ts +3 -3
  46. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.d.ts +1 -1
  47. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/context/headless-context.ssr.d.ts +1 -1
  48. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/dictionary-field-context/headless-dictionary-field-context.ssr.d.ts +1 -1
  49. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/did-you-mean/headless-did-you-mean.ssr.d.ts +1 -1
  50. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facet-manager/headless-facet-manager.ssr.d.ts +1 -1
  51. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.d.ts +1 -1
  52. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/category-facet/headless-category-facet.ssr.d.ts +1 -1
  53. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/facet/headless-facet.ssr.d.ts +1 -1
  54. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/range-facet/date-facet/headless-date-facet.ssr.d.ts +1 -1
  55. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/range-facet/date-facet/headless-date-filter.ssr.d.ts +1 -1
  56. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.d.ts +1 -1
  57. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.d.ts +1 -1
  58. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.d.ts +1 -1
  59. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/field-suggestions/facet/headless-field-suggestions.ssr.d.ts +1 -1
  60. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/folded-result-list/headless-folded-result-list.ssr.d.ts +1 -1
  61. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/history-manager/headless-history-manager.ssr.d.ts +1 -1
  62. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/instant-results/instant-results.ssr.d.ts +1 -1
  63. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/pager/headless-pager.ssr.d.ts +1 -1
  64. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/query-error/headless-query-error.ssr.d.ts +1 -1
  65. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/query-summary/headless-query-summary.ssr.d.ts +1 -1
  66. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/quickview/headless-quickview.ssr.d.ts +1 -1
  67. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/recent-queries-list/headless-recent-queries-list.ssr.d.ts +1 -1
  68. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/recent-results-list/headless-recent-results-list.ssr.d.ts +1 -1
  69. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/relevance-inspector/headless-relevance-inspector.ssr.d.ts +1 -1
  70. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/result-list/headless-result-list.ssr.d.ts +1 -1
  71. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/results-per-page/headless-results-per-page.ssr.d.ts +1 -1
  72. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/search-box/headless-search-box.ssr.d.ts +1 -1
  73. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.d.ts +1 -1
  74. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/search-status/headless-search-status.ssr.d.ts +1 -1
  75. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/smart-snippet/headless-smart-snippet.ssr.d.ts +1 -1
  76. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.d.ts +1 -1
  77. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/sort/headless-sort.ssr.d.ts +1 -1
  78. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/standalone-search-box/headless-standalone-search-box.ssr.d.ts +1 -1
  79. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/static-filter/headless-static-filter.ssr.d.ts +1 -1
  80. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/tab/headless-tab.ssr.d.ts +1 -1
  81. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/tab-manager/headless-tab-manager.ssr.d.ts +1 -1
  82. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/triggers/headless-execute-trigger.ssr.d.ts +1 -1
  83. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/triggers/headless-notify-trigger.ssr.d.ts +1 -1
  84. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/triggers/headless-query-trigger.ssr.d.ts +1 -1
  85. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/triggers/headless-redirection-trigger.ssr.d.ts +1 -1
  86. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/controllers/url-manager/headless-url-manager.ssr.d.ts +1 -1
  87. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +6 -13
  88. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/build.d.ts +12 -0
  89. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/controller-definition.d.ts +28 -0
  90. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/{common/types/inference.d.ts → search/types/controller-inference.d.ts} +3 -6
  91. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/engine.d.ts +52 -0
  92. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/{common → search}/types/fetch-static-state.d.ts +5 -4
  93. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/{common → search}/types/hydrate-static-state.d.ts +5 -6
  94. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next.index.d.ts +6 -4
  95. package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-ssr-controller-definitions.d.ts +13 -1
  96. package/force-app/main/default/staticresources/coveoheadless/headless.js +4 -2
  97. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +4 -2
  98. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +4 -2
  99. package/package.json +2 -2
  100. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/types/build.d.ts +0 -12
@@ -1,6 +1,7 @@
1
1
  import type { CorePaginationOptions, Pagination, PaginationOptions, PaginationProps, PaginationState } from '../../../../controllers/commerce/core/pagination/headless-core-commerce-pagination.js';
2
- import type { ControllerDefinitionOption, SubControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
2
+ import type { SearchAndListingControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { Pagination, PaginationProps, PaginationState, PaginationOptions, CorePaginationOptions, };
4
+ export type PaginationDefinition = SearchAndListingControllerDefinitionWithoutProps<Pagination>;
4
5
  /**
5
6
  * Defines a `Pagination` controller instance.
6
7
  * @group Definers
@@ -8,4 +9,4 @@ export type { Pagination, PaginationProps, PaginationState, PaginationOptions, C
8
9
  * @param props - The configurable `Pagination` properties.
9
10
  * @returns The `Pagination` controller definition.
10
11
  */
11
- export declare function definePagination<TOptions extends ControllerDefinitionOption | undefined>(props?: PaginationProps & TOptions): SubControllerDefinitionWithoutProps<Pagination, TOptions>;
12
+ export declare function definePagination(props?: PaginationProps): PaginationDefinition;
@@ -2,25 +2,15 @@ import type { ParameterManager, ParameterManagerProps, ParameterManagerState } f
2
2
  import type { Parameters } from '../../../../features/commerce/parameters/parameters-actions.js';
3
3
  import type { ProductListingParameters } from '../../../../features/commerce/product-listing-parameters/product-listing-parameters-actions.js';
4
4
  import type { CommerceSearchParameters } from '../../../../features/commerce/search-parameters/search-parameters-actions.js';
5
- import type { ControllerDefinitionOption, SubControllerDefinitionWithProps } from '../../types/controller-definitions.js';
5
+ import type { SearchAndListingControllerDefinitionWithProps } from '../../types/controller-definitions.js';
6
6
  export type { ParameterManager, ParameterManagerProps, ParameterManagerState, Parameters, ProductListingParameters, CommerceSearchParameters, };
7
- export type ParameterManagerDefinition<TOptions extends ControllerDefinitionOption | undefined> = SubControllerDefinitionWithProps<ParameterManager<MappedParameterTypes<TOptions>>, TOptions, SSRParameterManagerProps<MappedParameterTypes<TOptions>>>;
7
+ export type ParameterManagerDefinition = SearchAndListingControllerDefinitionWithProps<ParameterManager<ProductListingParameters | CommerceSearchParameters>, SSRParameterManagerProps<ProductListingParameters | CommerceSearchParameters>>;
8
8
  /**
9
9
  * Defines a `ParameterManager` controller instance.
10
10
  * @group Definers
11
11
  *
12
12
  * @returns The `ParameterManager` controller definition.
13
13
  */
14
- export declare function defineParameterManager<TOptions extends ControllerDefinitionOption | undefined>(options?: TOptions): ParameterManagerDefinition<TOptions>;
14
+ export declare function defineParameterManager(): ParameterManagerDefinition;
15
15
  export interface SSRParameterManagerProps<T extends Parameters> extends Omit<ParameterManagerProps<T>, 'excludeDefaultParameters'> {
16
16
  }
17
- type MappedParameterTypes<TOptions extends ControllerDefinitionOption | undefined> = TOptions extends {
18
- listing: true;
19
- search: true;
20
- } | undefined ? ProductListingParameters | CommerceSearchParameters : TOptions extends {
21
- listing: true;
22
- search: false;
23
- } ? ProductListingParameters : TOptions extends {
24
- listing: false;
25
- search: true;
26
- } ? CommerceSearchParameters : never;
@@ -1,12 +1,13 @@
1
1
  import { type ProductListing, type ProductListingState } from '../../../../controllers/commerce/product-listing/headless-product-listing.js';
2
2
  import { type Search } from '../../../../controllers/commerce/search/headless-search.js';
3
- import type { ControllerDefinitionOption, SubControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
+ import type { SearchAndListingControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
4
4
  export type { Search, ProductListing, ProductListingState as ProductListState };
5
5
  export type ProductList = Pick<ProductListing | Search, 'state' | 'subscribe' | 'interactiveProduct' | 'promoteChildToParent'>;
6
+ export type ProductListDefinition = SearchAndListingControllerDefinitionWithoutProps<ProductList>;
6
7
  /**
7
8
  * Defines a `ProductList` controller instance.
8
9
  * @group Definers
9
10
  *
10
11
  * @returns The `ProductList` controller definition.
11
12
  */
12
- export declare function defineProductList<TOptions extends ControllerDefinitionOption | undefined>(options?: TOptions): SubControllerDefinitionWithoutProps<ProductList, TOptions>;
13
+ export declare function defineProductList(): ProductListDefinition;
@@ -1,8 +1,7 @@
1
1
  import { type ProductView as BaseProductView } from '../../../../controllers/commerce/product-view/headless-product-view.js';
2
2
  import { type Controller } from '../../../../controllers/controller/headless-controller.js';
3
3
  import type { NonRecommendationControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
4
- interface ProductViewDefinition extends NonRecommendationControllerDefinitionWithoutProps<ProductView> {
5
- }
4
+ export type ProductViewDefinition = NonRecommendationControllerDefinitionWithoutProps<ProductView>;
6
5
  /**
7
6
  * Defines a `ProductView` controller instance.
8
7
  *
@@ -17,4 +16,3 @@ interface ProductViewDefinition extends NonRecommendationControllerDefinitionWit
17
16
  export declare function defineProductView(): ProductViewDefinition;
18
17
  export interface ProductView extends BaseProductView, Controller {
19
18
  }
20
- export {};
@@ -1,8 +1,7 @@
1
1
  import { type RecentQueriesList, type RecentQueriesListInitialState, type RecentQueriesListOptions, type RecentQueriesListProps, type RecentQueriesState } from '../../../../controllers/commerce/recent-queries-list/headless-recent-queries-list.js';
2
2
  import type { NonRecommendationControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { RecentQueriesListInitialState, RecentQueriesListOptions, RecentQueriesState, RecentQueriesList, RecentQueriesListProps, };
4
- export interface RecentQueriesListDefinition extends NonRecommendationControllerDefinitionWithoutProps<RecentQueriesList> {
5
- }
4
+ export type RecentQueriesListDefinition = NonRecommendationControllerDefinitionWithoutProps<RecentQueriesList>;
6
5
  /**
7
6
  * Defines the `RecentQueriesList` controller for the purpose of server-side rendering.
8
7
  * @group Definers
@@ -1,11 +1,13 @@
1
- import { type Recommendations, type RecommendationsOptions, type RecommendationsProps, type RecommendationsState } from '../../../../controllers/commerce/recommendations/headless-recommendations.js';
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]: {} & RecommendationsProps['options'];
6
+ [recommendationInternalOptionKey]: {} & RecommendationsOptions;
7
7
  };
8
- export interface RecommendationsDefinition extends RecommendationOnlyControllerDefinitionWithProps<Recommendations, Partial<RecommendationsOptions>> {
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: RecommendationsProps): RecommendationsDefinition & RecommendationsDefinitionMeta;
19
+ export declare function defineRecommendations(props: {
20
+ options: Omit<RecommendationsOptions, 'productId'>;
21
+ }): RecommendationsDefinition & RecommendationsDefinitionMeta;
@@ -1,8 +1,7 @@
1
1
  import { type CoreSearchBox, type SearchBox, type SearchBoxOptions, type SearchBoxProps, type SearchBoxState, type Suggestion } from '../../../../controllers/commerce/search-box/headless-search-box.js';
2
2
  import type { SearchOnlyControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { CoreSearchBox, SearchBox, SearchBoxProps, SearchBoxState, SearchBoxOptions, Suggestion, };
4
- export interface SearchBoxDefinition extends SearchOnlyControllerDefinitionWithoutProps<SearchBox> {
5
- }
4
+ export type SearchBoxDefinition = SearchOnlyControllerDefinitionWithoutProps<SearchBox>;
6
5
  /**
7
6
  * Defines a `SearchBox` controller instance.
8
7
  * @group Definers
@@ -1,6 +1,7 @@
1
1
  import type { Sort, SortProps, SortState } from '../../../../controllers/commerce/core/sort/headless-core-commerce-sort.js';
2
- import type { ControllerDefinitionOption, SubControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
2
+ import type { SearchAndListingControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { Sort, SortProps, SortState };
4
+ export type SortDefinition = SearchAndListingControllerDefinitionWithoutProps<Sort>;
4
5
  /**
5
6
  * Defines a `Sort` controller instance.
6
7
  * @group Definers
@@ -8,4 +9,4 @@ export type { Sort, SortProps, SortState };
8
9
  * @param props - The configurable `Sort` properties.
9
10
  * @returns The `Sort` controller definition.
10
11
  */
11
- export declare function defineSort<TOptions extends ControllerDefinitionOption | undefined>(props?: SortProps & TOptions): SubControllerDefinitionWithoutProps<Sort, TOptions>;
12
+ export declare function defineSort(props?: SortProps): SortDefinition;
@@ -2,8 +2,7 @@ import { type StandaloneSearchBox, type StandaloneSearchBoxState } from '../../.
2
2
  import type { StandaloneSearchBoxProps } from '../../../../controllers/standalone-search-box/headless-standalone-search-box.js';
3
3
  import type { ListingAndStandaloneControllerWithoutProps } from '../../types/controller-definitions.js';
4
4
  export type { StandaloneSearchBoxState, StandaloneSearchBox, StandaloneSearchBoxProps, };
5
- export interface StandaloneSearchBoxDefinition extends ListingAndStandaloneControllerWithoutProps<StandaloneSearchBox> {
6
- }
5
+ export type StandaloneSearchBoxDefinition = ListingAndStandaloneControllerWithoutProps<StandaloneSearchBox>;
7
6
  /**
8
7
  * Defines the `StandaloneSearchBox` controller for the purpose of server-side rendering.
9
8
  * @group Definers
@@ -2,12 +2,13 @@ import type { Summary, SummaryState } from '../../../../controllers/commerce/cor
2
2
  import type { ProductListingSummaryState } from '../../../../controllers/commerce/product-listing/summary/headless-product-listing-summary.js';
3
3
  import type { RecommendationsSummaryState } from '../../../../controllers/commerce/recommendations/summary/headless-recommendations-summary.js';
4
4
  import type { SearchSummaryState } from '../../../../controllers/commerce/search/summary/headless-search-summary.js';
5
- import type { ControllerDefinitionOption, SubControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
5
+ import type { SearchAndListingControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
6
6
  export type { Summary, ProductListingSummaryState, RecommendationsSummaryState, SearchSummaryState, SummaryState, };
7
+ export type SummaryDefinition = SearchAndListingControllerDefinitionWithoutProps<Summary<ProductListingSummaryState | SearchSummaryState | RecommendationsSummaryState>>;
7
8
  /**
8
9
  * Defines a `Summary` controller instance.
9
10
  * @group Definers
10
11
  *
11
12
  * @returns The `Summary` controller definition.
12
13
  */
13
- export declare function defineSummary<TOptions extends ControllerDefinitionOption | undefined>(options?: TOptions): SubControllerDefinitionWithoutProps<Summary<ProductListingSummaryState | SearchSummaryState | RecommendationsSummaryState>, TOptions>;
14
+ export declare function defineSummary(): SummaryDefinition;
@@ -1,8 +1,7 @@
1
1
  import type { NotifyTrigger, NotifyTriggerState } from '../../../../controllers/core/triggers/headless-core-notify-trigger.js';
2
2
  import type { SearchAndListingControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { NotifyTrigger, NotifyTriggerState };
4
- export interface NotifyTriggerDefinition extends SearchAndListingControllerDefinitionWithoutProps<NotifyTrigger> {
5
- }
4
+ export type NotifyTriggerDefinition = SearchAndListingControllerDefinitionWithoutProps<NotifyTrigger>;
6
5
  /**
7
6
  * Defines the `NotifyTrigger` controller for the purpose of server-side rendering.
8
7
  * @group Definers
@@ -2,8 +2,7 @@ import type { QueryTrigger } from '../../../../controllers/core/triggers/headles
2
2
  import type { SearchOnlyControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { QueryTriggerState } from '../../../../controllers/core/triggers/headless-core-query-trigger.js';
4
4
  export type { QueryTrigger };
5
- export interface QueryTriggerDefinition extends SearchOnlyControllerDefinitionWithoutProps<QueryTrigger> {
6
- }
5
+ export type QueryTriggerDefinition = SearchOnlyControllerDefinitionWithoutProps<QueryTrigger>;
7
6
  /**
8
7
  * Defines the `QueryTrigger` controller for the purpose of server-side rendering.
9
8
  * @group Definers
@@ -1,8 +1,7 @@
1
1
  import type { RedirectionTrigger, RedirectionTriggerState } from '../../../../controllers/core/triggers/headless-core-redirection-trigger.js';
2
2
  import type { SearchOnlyControllerDefinitionWithoutProps } from '../../types/controller-definitions.js';
3
3
  export type { RedirectionTrigger, RedirectionTriggerState };
4
- export interface RedirectionTriggerDefinition extends SearchOnlyControllerDefinitionWithoutProps<RedirectionTrigger> {
5
- }
4
+ export type RedirectionTriggerDefinition = SearchOnlyControllerDefinitionWithoutProps<RedirectionTrigger>;
6
5
  /**
7
6
  * Defines the `RedirectionTrigger` controller for the purpose of server-side rendering.
8
7
  * @group Definers
@@ -2,10 +2,9 @@
2
2
  * Utility functions to be used for Commerce Server Side Rendering.
3
3
  */
4
4
  import type { Controller } from '../../../controllers/controller/headless-controller.js';
5
- import type { CommerceEngineDefinitionOptions } from '../factories/build-factory.js';
6
5
  import { SolutionType } from '../types/controller-constants.js';
7
6
  import type { ControllerDefinitionsMap } from '../types/controller-definitions.js';
8
- import type { CommerceEngineDefinition } from '../types/engine.js';
7
+ import type { CommerceEngineDefinition, CommerceEngineDefinitionOptions } from '../types/engine.js';
9
8
  /**
10
9
  * Initializes a Commerce engine definition in SSR with given controllers definitions and commerce engine config.
11
10
  * @param options - The commerce engine definition
@@ -1,10 +1,7 @@
1
1
  import type { Action } from '@reduxjs/toolkit';
2
2
  import { type CommerceEngine } from '../../../app/commerce-engine/commerce-engine.js';
3
- import type { Controller } from '../../../controllers/controller/headless-controller.js';
4
- import type { SSRCommerceEngineOptions } from '../types/build.js';
5
3
  import { SolutionType } from '../types/controller-constants.js';
6
- import type { ControllerDefinitionsMap } from '../types/controller-definitions.js';
7
- import type { BuildParameters, CommerceControllerDefinitionsMap, EngineDefinitionOptions } from '../types/engine.js';
4
+ import type { BuildParameters, CommerceControllerDefinitionsMap, CommerceEngineDefinitionOptions } from '../types/engine.js';
8
5
  /**
9
6
  * The SSR commerce engine.
10
7
  *
@@ -16,7 +13,6 @@ export interface SSRCommerceEngine extends CommerceEngine {
16
13
  */
17
14
  waitForRequestCompletedAction(): Promise<Action>[];
18
15
  }
19
- export type CommerceEngineDefinitionOptions<TControllers extends ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>> = EngineDefinitionOptions<SSRCommerceEngineOptions, TControllers>;
20
16
  export declare const buildFactory: <TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions, options: CommerceEngineDefinitionOptions<TControllerDefinitions>) => <T extends SolutionType>(solutionType: T) => (...[buildOptions]: BuildParameters<TControllerDefinitions>) => Promise<{
21
17
  engine: SSRCommerceEngine;
22
18
  controllers: import("../types/controller-inference.js").InferControllersMapFromDefinition<TControllerDefinitions, T>;
@@ -1,4 +1,4 @@
1
1
  import type { SolutionType } from '../types/controller-constants.js';
2
- import type { CommerceControllerDefinitionsMap, HydrateStaticStateFunction } from '../types/engine.js';
3
- import { type CommerceEngineDefinitionOptions } from './build-factory.js';
4
- export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType: SolutionType) => HydrateStaticStateFunction<TControllerDefinitions>;
2
+ import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
3
+ import type { CommerceControllerDefinitionsMap, CommerceEngineDefinitionOptions, HydrateStaticStateFunction } from '../types/engine.js';
4
+ export declare function hydratedStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType: SolutionType) => HydrateStaticStateFunction<TControllerDefinitions>;
@@ -1,3 +1,2 @@
1
- import type { CommerceControllerDefinitionsMap, HydrateStaticStateFunction } from '../types/engine.js';
2
- import { type CommerceEngineDefinitionOptions } from './build-factory.js';
1
+ import type { CommerceControllerDefinitionsMap, CommerceEngineDefinitionOptions, HydrateStaticStateFunction } from '../types/engine.js';
3
2
  export declare function hydratedRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: TControllerDefinitions, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): HydrateStaticStateFunction<TControllerDefinitions>;
@@ -1,4 +1,3 @@
1
1
  import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
2
- import type { CommerceControllerDefinitionsMap, FetchStaticStateFunction } from '../types/engine.js';
3
- import { type CommerceEngineDefinitionOptions } from './build-factory.js';
2
+ import type { CommerceControllerDefinitionsMap, CommerceEngineDefinitionOptions, FetchStaticStateFunction } from '../types/engine.js';
4
3
  export declare function fetchRecommendationStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): FetchStaticStateFunction<TControllerDefinitions>;
@@ -1,5 +1,4 @@
1
1
  import { SolutionType } from '../types/controller-constants.js';
2
2
  import type { AugmentedControllerDefinition } from '../types/controller-definitions.js';
3
- import type { CommerceControllerDefinitionsMap, FetchStaticStateFunction } from '../types/engine.js';
4
- import { type CommerceEngineDefinitionOptions } from './build-factory.js';
3
+ import type { CommerceControllerDefinitionsMap, CommerceEngineDefinitionOptions, FetchStaticStateFunction } from '../types/engine.js';
5
4
  export declare function fetchStaticStateFactory<TControllerDefinitions extends CommerceControllerDefinitionsMap>(controllerDefinitions: AugmentedControllerDefinition<TControllerDefinitions>, options: CommerceEngineDefinitionOptions<TControllerDefinitions>): (solutionType: SolutionType) => FetchStaticStateFunction<TControllerDefinitions>;
@@ -1,45 +1,89 @@
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
- import type { OptionsTuple } from '../../common/types/utilities.js';
4
+ import type { HasKey, OptionsTuple } from '../../common/types/utilities.js';
6
5
  import type { CartInitialState } from '../controllers/cart/headless-cart.ssr.js';
7
- import type { UserLocation } from '../controllers/context/headless-context.ssr.js';
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
- import type { ControllerDefinitionsMap, EngineDefinitionControllersPropsOption } from './controller-definitions.js';
9
+ import type { CommerceEngineDefinitionControllersPropsOption, ControllerDefinitionsMap, IsRecommendationController } from './controller-definitions.js';
11
10
  import type { CommerceEngineDefinitionBuildResult } from './engine.js';
12
11
  export interface SearchBuildConfig extends CommonBuildConfig {
13
12
  searchParams: ParameterManagerState<Parameters & {
14
13
  query: string;
15
14
  }>['parameters'];
16
15
  }
17
- export interface RecommendationBuildConfig extends CommonBuildConfig {
18
- recommendations?: [];
19
- }
20
16
  export interface ListingBuildConfig extends CommonBuildConfig {
21
17
  }
22
18
  export interface StandaloneBuildConfig extends CommonBuildConfig {
23
19
  }
24
20
  export interface CommonBuildConfig {
25
- context: {
26
- url: string;
27
- language: string;
28
- country: string;
29
- currency: CurrencyCodeISO4217;
30
- location?: UserLocation;
31
- };
21
+ context: ContextOptions;
32
22
  searchParams?: ParameterManagerState<Parameters>['parameters'];
33
23
  cart?: CartInitialState;
34
24
  }
35
- 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;
36
25
  /**
37
26
  * Commerce engine options for SSR scenarios where context is defined when fetching static state.
38
27
  */
39
28
  export type SSRCommerceEngineOptions = Omit<CommerceEngineOptions, 'configuration'> & {
40
29
  configuration: Omit<CommerceEngineOptions['configuration'], 'context'>;
41
30
  };
31
+ /**
32
+ * The `RecommendationBuildConfig` type defines the shape of the configuration object required when fetching static state for recommendations.
33
+ *
34
+ * The `recommendations` property is a string array containing the names of the recommendation controllers
35
+ * that were defined in your engine definition. This allows you to specify which recommendation controllers
36
+ * should be included in the SSR request.
37
+ *
38
+ * For example, on a storefront homepage, it might make sense to display a carousel of popular products.
39
+ * However, showing recommendations based on items frequently bought together may not be relevant in that context and should not be retrieved unnecessarily.
40
+ *
41
+ * @example
42
+ * Given the following engine definition:
43
+ *
44
+ * ```ts
45
+ * const {recommendationEngineDefinition} = defineCommerceEngine({
46
+ * controllers: {
47
+ * popularProducts: defineRecommendations({options: {slotId: '...'}}),
48
+ * frequentlyBought: defineRecommendations({options: {slotId: '...'}}),
49
+ * // ...other controllers
50
+ * },
51
+ * });
52
+ *
53
+ * // When fetching static state for recommendations:
54
+ * const staticState = await recommendationEngineDefinition.fetchStaticState({
55
+ * recommendations: ['popularProducts'],
56
+ * // ...other config
57
+ * });
58
+ * ```
59
+ *
60
+ * In this example, only the `popularProducts` recommendation controller will be included in the SSR request.
61
+ */
62
+ export type RecommendationBuildConfig<TControllers extends ControllerDefinitionsMap<Controller>> = CommonBuildConfig & {
63
+ /**
64
+ * The unique identifier of the product to use for seeded recommendations.
65
+ */
66
+ productId?: string;
67
+ /**
68
+ * An array of recommendation controller names from your engine definition to include in the SSR request.
69
+ * Each name corresponds to a key used when defining recommendation controllers in your engine definition.
70
+ * If not specified, no recommendation requests will be executed.
71
+ */
72
+ recommendations: Array<Extract<keyof TControllers, {
73
+ [K in keyof TControllers]: HasKey<TControllers[K], SolutionType.recommendation> extends never ? never : IsRecommendationController<TControllers[K]> extends never ? never : K;
74
+ }[keyof TControllers]>>;
75
+ };
76
+ export interface ListingBuildConfig extends CommonBuildConfig {
77
+ }
78
+ export interface StandaloneBuildConfig extends CommonBuildConfig {
79
+ }
80
+ export interface CommonBuildConfig {
81
+ context: ContextOptions;
82
+ searchParams?: ParameterManagerState<Parameters>['parameters'];
83
+ cart?: CartInitialState;
84
+ }
85
+ export type BuildConfig<TControllers extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = TSolutionType extends SolutionType.search ? SearchBuildConfig : TSolutionType extends SolutionType.listing ? ListingBuildConfig : TSolutionType extends SolutionType.recommendation ? RecommendationBuildConfig<TControllers> : TSolutionType extends SolutionType.standalone ? CommonBuildConfig : never;
42
86
  /**
43
87
  * @internal
44
88
  */
45
- export type Build<TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TSolutionType> & EngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<CommerceEngineDefinitionBuildResult<TControllersMap>>;
89
+ export type Build<TControllersMap extends ControllersMap, TControllersProps extends ControllersPropsMap, TControllersDefinitionsMap extends ControllerDefinitionsMap<Controller>, TSolutionType extends SolutionType> = (...params: OptionsTuple<BuildConfig<TControllersDefinitionsMap, TSolutionType> & CommerceEngineDefinitionControllersPropsOption<TControllersDefinitionsMap, TControllersProps, TSolutionType>>) => Promise<CommerceEngineDefinitionBuildResult<TControllersMap>>;
@@ -1,27 +1,17 @@
1
1
  import type { Controller } from '../../../controllers/controller/headless-controller.js';
2
- import type { InvalidControllerDefinition } from '../../common/errors.js';
2
+ import type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers } from '../../common/types/controller-inference.js';
3
3
  import type { ControllersPropsMap } from '../../common/types/controllers.js';
4
- import type { HydratedState } from '../../common/types/hydrate-static-state.js';
5
- import type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers } from '../../common/types/inference.js';
6
- import type { HasKey, HasOptionalKeys, HasRequiredKeys, OptionsTuple } from '../../common/types/utilities.js';
4
+ import type { HasKey, HasRequiredKeys, OptionsTuple } from '../../common/types/utilities.js';
7
5
  import type { CartDefinition } from '../controllers/cart/headless-cart.ssr.js';
8
6
  import type { ContextDefinition } from '../controllers/context/headless-context.ssr.js';
9
7
  import type { ParameterManagerDefinition } from '../controllers/parameter-manager/headless-core-parameter-manager.ssr.js';
10
8
  import type { SSRCommerceEngine } from '../factories/build-factory.js';
11
9
  import { type recommendationInternalOptionKey, SolutionType } from './controller-constants.js';
12
- import type { ListingAndStandaloneController, ListingOnlyController, NonRecommendationController, RecommendationOnlyController, SearchAndListingController, SearchOnlyController, UniversalController } from './controller-scopes.js';
10
+ import type { ListingAndStandaloneController, NonRecommendationController, RecommendationOnlyController, SearchAndListingController, SearchOnlyController, UniversalController } from './controller-scopes.js';
11
+ import type { HydratedState } from './hydrate-static-state.js';
13
12
  import type { Kind } from './kind.js';
14
13
  import type { HasSolutionType } from './utilities.js';
15
14
  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
15
  export interface ControllerDefinitionWithoutProps<TController extends Controller> {
26
16
  /**
27
17
  * Creates an instance of the given controller.
@@ -57,10 +47,7 @@ export interface ControllerDefinitionsMap<TController extends Controller> {
57
47
  [customName: string]: ControllerDefinition<TController>;
58
48
  }
59
49
  type BakedInControllerDefinitions = {
60
- parameterManager: ParameterManagerDefinition<{
61
- listing: true;
62
- search: true;
63
- }>;
50
+ parameterManager: ParameterManagerDefinition;
64
51
  context: ContextDefinition;
65
52
  cart: CartDefinition;
66
53
  };
@@ -92,167 +79,20 @@ export type FilteredBakedInControllers<TSolutionType extends SolutionType> = {
92
79
  */
93
80
  export type AugmentedControllerDefinition<TControllerDefinitions extends ControllerDefinitionsMap<Controller>> = TControllerDefinitions & BakedInControllerDefinitions;
94
81
  /**
95
- * This type defines the required and optional controller props for the engine definition.
96
- */
97
- export type EngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = OptionalEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType> & RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
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
- *
82
+ * This type defines the required and optional controller props for the commerce engine definition.
171
83
  */
84
+ export type CommerceEngineDefinitionControllersPropsOption<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, TSolutionType extends SolutionType> = RequiredEngineDefinitionControllersPropsOption<TControllers, TControllersPropsMap, TSolutionType>;
172
85
  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<ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>> extends false ? never : 'controllers']: ConditionalControllerProps<TControllers, TControllersPropsMap, TSolutionType, K>;
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];
86
+ [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
87
  };
88
+ export type IsRecommendationController<TController extends ControllerDefinition<Controller>> = HasKey<TController, typeof recommendationInternalOptionKey>;
207
89
  type DefaultControllerProps<TControllers extends ControllerDefinitionsMap<Controller>, TControllersPropsMap extends ControllersPropsMap, K extends keyof TControllers> = {
208
90
  [I in keyof TControllersPropsMap as I extends K ? I : never]: TControllersPropsMap[I];
209
91
  };
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
- export interface ControllerDefinitionOption {
212
- /**
213
- * Whether the controller will be used in a product listing context.
214
- * @defaultValue true
215
- */
216
- listing?: boolean;
217
- /**
218
- * Whether the controller will be used in a search page context.
219
- * @defaultValue true
220
- */
221
- search?: boolean;
222
- }
223
92
  export type SearchOnlyControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & SearchOnlyController;
224
- type SearchOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & SearchOnlyController;
225
93
  export type ListingAndStandaloneControllerWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & ListingAndStandaloneController;
226
- type ListingOnlyControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & ListingOnlyController;
227
- type ListingOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & ListingOnlyController;
228
94
  export type RecommendationOnlyControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & RecommendationOnlyController;
229
95
  export type NonRecommendationControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & NonRecommendationController;
230
96
  export type UniversalControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & UniversalController;
231
97
  export type SearchAndListingControllerDefinitionWithoutProps<TController extends Controller> = ControllerDefinitionWithoutProps<TController> & SearchAndListingController;
232
- type SearchAndListingControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & SearchAndListingController;
233
- export type SubControllerDefinitionWithoutProps<TController extends Controller, TDefinition extends ControllerDefinitionOption | undefined> = TDefinition extends {
234
- listing?: true;
235
- search?: true;
236
- } | undefined ? SearchAndListingControllerDefinitionWithoutProps<TController> : TDefinition extends {
237
- listing?: true;
238
- search?: false;
239
- } ? ListingOnlyControllerDefinitionWithoutProps<TController> : TDefinition extends {
240
- listing?: false;
241
- search?: true;
242
- } ? SearchOnlyControllerDefinitionWithoutProps<TController> : TDefinition extends {
243
- listing: false;
244
- search: false;
245
- } ? InvalidControllerDefinition : never;
246
- export type SubControllerDefinitionWithProps<TController extends Controller, TDefinition extends ControllerDefinitionOption | undefined, TProps> = TDefinition extends {
247
- listing?: true;
248
- search?: true;
249
- } | undefined ? SearchAndListingControllerDefinitionWithProps<TController, TProps> : TDefinition extends {
250
- listing?: true;
251
- search?: false;
252
- } ? ListingOnlyControllerDefinitionWithProps<TController, TProps> : TDefinition extends {
253
- listing?: false;
254
- search?: true;
255
- } ? SearchOnlyControllerDefinitionWithProps<TController, TProps> : TDefinition extends {
256
- listing: false;
257
- search: false;
258
- } ? InvalidControllerDefinition : never;
98
+ export type SearchAndListingControllerDefinitionWithProps<TController extends Controller, TProps> = ControllerDefinitionWithProps<TController, TProps> & SearchAndListingController;