Skip to content

Commit

Permalink
fix(headless): make CommerceEngineDefinitionOptions an optional gen…
Browse files Browse the repository at this point in the history
…eric type (#4703)

https://coveord.atlassian.net/browse/KIT-3713

The goal of this is for the implementer to not have to interact with the
`ControllerDefinitionsMap` & the `Controller` interface. These are
**internal** and bring more complexity to the implementer than anything
else. We can't simply remove that generic since it is used in
headless-react for inference but we can make it optional.

turns out this easier than I thought 😅. I did not think of simply making
it optional
  • Loading branch information
alexprudhomme authored Nov 26, 2024
1 parent 51708a0 commit 0768ce7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export interface SSRCommerceEngine extends CommerceEngine {
}

export type CommerceEngineDefinitionOptions<
TControllers extends ControllerDefinitionsMap<Controller>,
TControllers extends
ControllerDefinitionsMap<Controller> = ControllerDefinitionsMap<Controller>,
> = EngineDefinitionOptions<CommerceEngineOptions, TControllers>;

function isListingFetchCompletedAction(action: unknown): action is Action {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
Controller,
ControllerDefinitionsMap,
CommerceEngineDefinitionOptions,
defineProductList,
defineCart,
Expand All @@ -23,10 +21,6 @@ import {
defineRecommendations, //defineParameterManager,
} from '@coveo/headless-react/ssr-commerce';

type CommerceEngineConfig = CommerceEngineDefinitionOptions<
ControllerDefinitionsMap<Controller>
>;

export default {
// By default, the logger level is set to 'warn'. This level may not provide enough information for some server-side errors. To get more detailed error messages, set the logger level to a more verbose level, such as 'debug'.
// loggerOptions: {level: 'debug'},
Expand Down Expand Up @@ -65,4 +59,4 @@ export default {
facetGenerator: defineFacetGenerator(),
breadcrumbManager: defineBreadcrumbManager(),
},
} satisfies CommerceEngineConfig;
} satisfies CommerceEngineDefinitionOptions;

0 comments on commit 0768ce7

Please sign in to comment.