-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(navigation): add injectable transforms to magento driver (#2774)
- Loading branch information
Showing
6 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './token'; | ||
export * from './type'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// workaround https://github.com/graycoreio/daffodil/issues/1667 | ||
import { createMultiInjectionToken } from '@daffodil/core'; | ||
import { DaffNavigationTree } from '@daffodil/navigation'; | ||
|
||
import { MagentoNavigationTreeTransform } from './type'; | ||
|
||
export const { | ||
/** | ||
* A multi-provider injection token for providing navigation tree transform logic in the Magento driver. | ||
* It is run after the standard transforms and passed both the current transformed Daffodil navigation and the Magento navigation. | ||
*/ | ||
token: MAGENTO_NAVIGATION_TREE_TRANSFORMS, | ||
/** | ||
* Provides navigation tree transforms for the Magento navigation driver. | ||
* | ||
* See {@link MAGENTO_NAVIGATION_TREE_TRANSFORMS}. | ||
* | ||
* ```ts | ||
* providers: [ | ||
* ...magentoProvideNavigationTreeTransforms( | ||
* myNavigationTreeTransform | ||
* ) | ||
* ] | ||
* ``` | ||
*/ | ||
provider: magentoProvideNavigationTreeTransforms, | ||
} = createMultiInjectionToken<MagentoNavigationTreeTransform>('MAGENTO_NAVIGATION_TREE_TRANSFORMS'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { DaffNavigationTree } from '@daffodil/navigation'; | ||
|
||
import { CategoryNode } from '../models/public_api'; | ||
|
||
/** | ||
* A transform for the Magento driver that can add extra fields or otherwise modify the navigation driver response. | ||
*/ | ||
export type MagentoNavigationTreeTransform<T extends CategoryNode = CategoryNode, V extends DaffNavigationTree = DaffNavigationTree> = | ||
(daffTree: DaffNavigationTree, magentoCategoryNode: T) => V; |