diff --git a/docs/web-components-migration-guide/WKNG Request Pipeline.png b/docs/web-components-migration-guide/WKNG Request Pipeline.png
deleted file mode 100644
index ad3d7fff..00000000
Binary files a/docs/web-components-migration-guide/WKNG Request Pipeline.png and /dev/null differ
diff --git a/docs/web-components-migration-guide/migrationGuide.md b/docs/web-components-migration-guide/migrationGuide.md
index f080ab75..f5b86f02 100644
--- a/docs/web-components-migration-guide/migrationGuide.md
+++ b/docs/web-components-migration-guide/migrationGuide.md
@@ -1,12 +1,13 @@
-# WKNG Migration Guide
+# Web Components Migration Guide
This is a migration guide which should help you update your Shopware module to the WebComponents from v4 to v5
-if for some reason you do not want to use our ready-made module.
+if for some reason you do not want to use our ready-made module. It is not a step-by-step guide to walk you through the migration.
+Skim through the document in its entirety first to get an overview of all changes before starting to work through each topic in detail.
## Overview
-WKNG is undergoing a complete rewrite of its core.
+Web Components has undergone a complete rewrite of its core.
The new library more closely reflects the FactFinder REST API with as few abstractions as possible.
This shall reduce the number of concepts required to learn while simultaneously increase transparency of the data flow.
@@ -17,6 +18,13 @@ You can (and should) always consult FactFinder's API documentation for details.
### Backward compatibility
FactFinder versions prior to NG (`v5` API) are no longer supported.
+Going forward, the latest version of Web Components will only support the latest API version of FactFinder.
+
+
+### Diagram of request/response pipelines
+
+There is now more focus on the request/response pipelines which shall provide more clarity of the data flow.
+See the end of this migration guide for a visual representation of these pipelines.
## Including the library
@@ -32,7 +40,7 @@ This shall emphasize that the core and the custom elements initialize separately
```js
document.addEventListener(`ffCoreReady`, ({ factfinder, init, initialSearch }) => {
-
+
});
```
@@ -59,7 +67,7 @@ Depending on whether the application is configured to be a category page or regu
Make sure to always use this function for the initial search request as it provides different handling of the browser history than a regular search request.
```js
-initialSearch({ query: `deck chair` });
+initialSearch({ query: `deck chair` }, { userId: `user123` });
```
You can always pass a _SearchParams_ object to `initialSearch`, even when the application is configured to category page.
@@ -74,109 +82,109 @@ The core's structure is as follows.
```js
factfinder: {
request: {
- campaignPage: (Required CampaignPageParams, Optional WKRequestOptions) => FF CampaignsResult,
- campaignProduct: (Required CampaignProductParams, Optional WKRequestOptions) => FF CampaignsResult,
- campaignShoppingCart: (Required CampaignShoppingCartParams, Optional WKRequestOptions) => FF CampaignsResult,
- navigation: (Required NavigationParams, Optional WKNavigationOptions) => (FF Result),
- navigationCategory: (Required NavigationCategoryParams, Optional WKRequestOptions) => (FF CategoryNavigation),
- predictiveBasket: Required PredictiveBasketParams, Optional WKRequestOptions) => FF PredictiveBasketResult,
- recommendation: (Required RecommendationParams, Optional WKRequestOptions) => FF RecommendationResultWithFieldRoles,
- records: (Required RecordsParams, Optional WKRequestOptions) => FF FlatRecordsResult,
- search: (Required SearchParams, Optional WKSearchOptions) => FF Result,
- similar: (Required SimilarParams, Optional WKRequestOptions) => FF SimilarProductsWithFieldRoles,
- suggest: (Required SuggestParams, Optional WKRequestOptions) => FF SuggestionResult,
+ campaignPage: (Required CampaignPageParams, Optional RequestOptions) => Promise CampaignsResult,
+ campaignProduct: (Required CampaignProductParams, Optional RequestOptions) => Promise CampaignsResult,
+ campaignShoppingCart: (Required CampaignShoppingCartParams, Optional RequestOptions) => Promise CampaignsResult,
+ navigation: (Required NavigationParams, Optional NavigationOptions) => Promise Result,
+ navigationCategory: (Required NavigationCategoryParams, Optional RequestOptions) => Promise CategoryNavigation,
+ predictiveBasket: Required PredictiveBasketParams, Optional RequestOptions) => Promise PredictiveBasketResult,
+ recommendation: (Required RecommendationParams, Optional RequestOptions) => Promise RecommendationResultWithFieldRoles,
+ records: (Required RecordsParams, Optional RequestOptions) => Promise FlatRecordsResult,
+ search: (Required SearchParams, Optional SearchOptions) => Promise Result,
+ similar: (Required SimilarParams, Optional RequestOptions) => Promise SimilarProductsWithFieldRoles,
+ suggest: (Required SuggestParams, Optional RequestOptions) => Promise SuggestionResult,
before: {
- campaignPage: CancellableSubscriber RequestInfoCampaignPage => WK SubscriberID,
- campaignProduct: CancellableSubscriber RequestInfoCampaignProduct => WK SubscriberID,
- campaignShoppingCart: CancellableSubscriber RequestInfoCampaignShoppingCart => WK SubscriberID,
- compare: CancellableSubscriber RequestInfoCompare => WK SubscriberID,
- navigation: CancellableSubscriber RequestInfoNavigation => WK SubscriberID,
- navigationCategory: CancellableSubscriber RequestInfoNavigationCategory => WK SubscriberID,
- predictiveBasket: CancellableSubscriber RequestInfoPredictiveBasket => WK SubscriberID,
- recommendation: CancellableSubscriber RequestInfoRecommendation => WK SubscriberID,
- records: CancellableSubscriber RequestInfoRecords => WK SubscriberID,
- search: CancellableSubscriber RequestInfoSearch => WK SubscriberID,
- similar: CancellableSubscriber RequestInfoSimilar => WK SubscriberID,
- suggest: CancellableSubscriber RequestInfoSuggest => WK SubscriberID,
+ campaignPage: CancellableSubscriber RequestInfoCampaignPage => SubscriberID,
+ campaignProduct: CancellableSubscriber RequestInfoCampaignProduct => SubscriberID,
+ campaignShoppingCart: CancellableSubscriber RequestInfoCampaignShoppingCart => SubscriberID,
+ compare: CancellableSubscriber RequestInfoCompare => SubscriberID,
+ navigation: CancellableSubscriber RequestInfoNavigation => SubscriberID,
+ navigationCategory: CancellableSubscriber RequestInfoNavigationCategory => SubscriberID,
+ predictiveBasket: CancellableSubscriber RequestInfoPredictiveBasket => SubscriberID,
+ recommendation: CancellableSubscriber RequestInfoRecommendation => SubscriberID,
+ records: CancellableSubscriber RequestInfoRecords => SubscriberID,
+ search: CancellableSubscriber RequestInfoSearch => SubscriberID,
+ similar: CancellableSubscriber RequestInfoSimilar => SubscriberID,
+ suggest: CancellableSubscriber RequestInfoSuggest => SubscriberID,
},
},
response: {
- subscribeCampaignPage: Subscriber CampaignsResult => WK SubscriberID,
- subscribeCampaignProduct: Subscriber CampaignsResult => WK SubscriberID,
- subscribeCampaignRedirect: CancellableSubscriber ({ campaign: Campaign, result: Result }) => WK SubscriberID,
- subscribeCampaignShoppingCart: Subscriber CampaignsResult => WK SubscriberID,
- subscribeNavigation: Subscriber Result => WK SubscriberID,
- subscribeNavigationCategory: Subscriber CategoryNavigation => WK SubscriberID,
- subscribePredictiveBasket: Subscriber PredictiveBasketResult => WK SubscriberID,
- subscribeRecommendation: Subscriber RecommendationResultWithFieldRoles => WK SubscriberID,
- subscribeRecords: Subscriber FlatRecordsResult => WK SubscriberID,
- subscribeSearch: Subscriber Result => WK SubscriberID,
- subscribeSimilar: Subscriber SimilarProductsWithFieldRoles => WK SubscriberID,
- subscribeSuggest: Subscriber SuggestionResult => WK SubscriberID,
- subscribeSearchAndNavigation: Subscriber Result => WK SubscriberID,
+ subscribeCampaignPage: Subscriber CampaignsResult => SubscriberID,
+ subscribeCampaignProduct: Subscriber CampaignsResult => SubscriberID,
+ subscribeCampaignRedirect: CancellableSubscriber ({ campaign: Campaign, result: Result }) => SubscriberID,
+ subscribeCampaignShoppingCart: Subscriber CampaignsResult => SubscriberID,
+ subscribeNavigation: Subscriber Result => SubscriberID,
+ subscribeNavigationCategory: Subscriber CategoryNavigation => SubscriberID,
+ subscribePredictiveBasket: Subscriber PredictiveBasketResult => SubscriberID,
+ subscribeRecommendation: Subscriber RecommendationResultWithFieldRoles => SubscriberID,
+ subscribeRecords: Subscriber FlatRecordsResult => SubscriberID,
+ subscribeSearch: Subscriber Result => SubscriberID,
+ subscribeSimilar: Subscriber SimilarProductsWithFieldRoles => SubscriberID,
+ subscribeSuggest: Subscriber SuggestionResult => SubscriberID,
+ subscribeSearchAndNavigation: Subscriber Result => SubscriberID,
unsubscribe: SubscriberID => Boolean,
- transformCampaignPage: Transformer CampaignsResult => WK undefined,
- transformCampaignProduct: Transformer CampaignsResult => WK undefined,
- transformCampaignShoppingCart: Transformer CampaignsResult => WK undefined,
- transformCompare: Transformer CompareResult => WK undefined,
- transformNavigation: Transformer Result => WK undefined,
- transformNavigationCategory: Transformer CategoryNavigation => WK undefined,
- transformPredictiveBasket: Transformer PredictiveBasketResult => WK undefined,
- transformRecommendation: Transformer RecommendationResultWithFieldRoles => WK undefined,
- transformRecords: Transformer FlatRecordsResult => WK undefined,
- transformSearch: Transformer Result => WK undefined,
- transformSimilar: Transformer SimilarProductsWithFieldRoles => WK undefined,
- transformSuggest: Transformer SuggestionResult => WK undefined,
+ transformCampaignPage: Transformer CampaignsResult => undefined,
+ transformCampaignProduct: Transformer CampaignsResult => undefined,
+ transformCampaignShoppingCart: Transformer CampaignsResult => undefined,
+ transformCompare: Transformer CompareResult => undefined,
+ transformNavigation: Transformer Result => undefined,
+ transformNavigationCategory: Transformer CategoryNavigation => undefined,
+ transformPredictiveBasket: Transformer PredictiveBasketResult => undefined,
+ transformRecommendation: Transformer RecommendationResultWithFieldRoles => undefined,
+ transformRecords: Transformer FlatRecordsResult => undefined,
+ transformSearch: Transformer Result => undefined,
+ transformSimilar: Transformer SimilarProductsWithFieldRoles => undefined,
+ transformSuggest: Transformer SuggestionResult => undefined,
dispatch: {
- navigation: (Result, Maybe RequestInfoNavigation) => WK Result,
- navigationBeforeTransform: (Result, Maybe RequestInfoNavigation) => WK Result,
- search: (Result, Maybe RequestInfoSearch) => WK Result,
- searchBeforeTransform: (Result, Maybe RequestInfoSearch) => WK Result,
- suggest: (SuggestionResult, Maybe RequestInfoSuggest) => WK SuggestionResult,
- ssrNavigation: (Result, Maybe RequestInfoNavigation) => WK Result,
- ssrSearch: (Result, Maybe RequestInfoSearch) => WK Result,
+ navigation: (Result, Optional RequestInfoNavigation) => Result,
+ navigationBeforeTransform: (Result, Optional RequestInfoNavigation) => Result,
+ search: (Result, Optional RequestInfoSearch) => Result,
+ searchBeforeTransform: (Result, Optional RequestInfoSearch) => Result,
+ suggest: (SuggestionResult, Optional RequestInfoSuggest) => SuggestionResult,
+ ssrNavigation: (Result, Optional RequestInfoNavigation) => Result,
+ ssrSearch: (Result, Optional RequestInfoSearch) => Result,
},
},
tracking: {
- cart: (Required (NonEmptyArray CartOrCheckoutEvent), Optional WKRequestOptions) => FF undefined,
- checkout: (Required (NonEmptyArray CartOrCheckoutEvent), Optional WKRequestOptions) => FF undefined,
- click: (Required (NonEmptyArray ClickEvent), Optional WKRequestOptions) => FF undefined,
- landingPageClick: (Required (NonEmptyArray LandingPageClickEvent), Optional WKRequestOptions) => FF undefined,
- login: (Required (NonEmptyArray LoginEvent), Optional WKRequestOptions) => FF undefined,
- predbasketClick: (Required (NonEmptyArray PredBasketClickEvent), Optional WKRequestOptions) => FF undefined,
- recommendationClick: (Required (NonEmptyArray RecommendationClickEvent), Optional WKRequestOptions) => FF undefined,
+ cart: (Required (NonEmptyArray CartOrCheckoutEvent), Optional RequestOptions) => Promise undefined,
+ checkout: (Required (NonEmptyArray CartOrCheckoutEvent), Optional RequestOptions) => Promise undefined,
+ click: (Required (NonEmptyArray ClickEvent), Optional RequestOptions) => Promise undefined,
+ landingPageClick: (Required (NonEmptyArray LandingPageClickEvent), Optional RequestOptions) => Promise undefined,
+ login: (Required (NonEmptyArray LoginEvent), Optional RequestOptions) => Promise undefined,
+ predbasketClick: (Required (NonEmptyArray PredBasketClickEvent), Optional RequestOptions) => Promise undefined,
+ recommendationClick: (Required (NonEmptyArray RecommendationClickEvent), Optional RequestOptions) => Promise undefined,
before: {
- cart: CancellableSubscriber RequestInfoTrackCartOrCheckout => WK SubscriberID,
- checkout: CancellableSubscriber RequestInfoTrackCartOrCheckout => WK SubscriberID,
- click: CancellableSubscriber RequestInfoTrackClick => WK SubscriberID,
- landingPageClick: CancellableSubscriber RequestInfoTrackLandingPageClick => WK SubscriberID,
- login: CancellableSubscriber RequestInfoTrackLogin => WK SubscriberID,
- predbasketClick: CancellableSubscriber RequestInfoTrackPredBasketClick => WK SubscriberID,
- recommendationClick: CancellableSubscriber RequestInfoTrackRecommendationClick => WK SubscriberID,
+ cart: CancellableSubscriber RequestInfoTrackCartOrCheckout => SubscriberID,
+ checkout: CancellableSubscriber RequestInfoTrackCartOrCheckout => SubscriberID,
+ click: CancellableSubscriber RequestInfoTrackClick => SubscriberID,
+ landingPageClick: CancellableSubscriber RequestInfoTrackLandingPageClick => SubscriberID,
+ login: CancellableSubscriber RequestInfoTrackLogin => SubscriberID,
+ predbasketClick: CancellableSubscriber RequestInfoTrackPredBasketClick => SubscriberID,
+ recommendationClick: CancellableSubscriber RequestInfoTrackRecommendationClick => SubscriberID,
},
},
config: {
- get: () => WK Config
- setFFParams: ffParams => WK undefined,
- setAppConfig: appConfig => WK undefined,
+ get: () => Config
+ setFFParams: ffParams => undefined,
+ setAppConfig: appConfig => undefined,
},
notifications: {
- setSuggestClickListener: (origin) => Boolean,
- setSuggestDetailListener: (origin) => undefined,
- setSuggestUnmappedListener: (origin) => undefined,
+ addSuggestClickListener: CancellableSubscriber Origin => undefined,
+ setSuggestDetailListener: Subscriber Origin => undefined,
+ setSuggestUnmappedListener: Subscriber Origin => undefined,
},
routing: {
setNavigateListener: ((url, origin) => Boolean) => undefined,
setUrlParamOptionsListener: (() => UrlParamMappingOptions) => undefined,
sandboxed: {
- restoreHistory: (historyPayload) => undefined,
- setHistoryWriteListener: ((historyPayload) => undefined) => undefined,
+ restoreHistory: historyPayload => undefined,
+ setHistoryWriteListener: (historyPayload => undefined) => undefined,
setSessionReadWriteListeners: ({ read, write }) => undefined,
},
},
utils: {
env: {
- searchParamsFromUrl: (options) => SearchParams,
+ searchParamsFromUrl: options => SearchParams,
},
filterBuilders: {
categoryFilter: (name, path) => Filter,
@@ -197,7 +205,7 @@ Methods in this namespace reflect the relevant FactFinder REST API endpoints.
They are used for initiating requests to FactFinder.
This replaces `EventAggregator.addFFEvent(ffEvent)`.
-These methods take a required parameter which is equivalent to the FactFinder API specification for POST requests and an optional parameter to define various options to the request's behaviour.
+These methods take a required parameter which is equivalent to the FactFinder API specification for POST requests and an optional parameter to define various options to the request pipeline's behaviour.
All methods in this namespace return a `Promise` that resolves to the relevant result after the request/response pipeline has completed.
Note that this `Promise` rejects on server responses that are not `200`.
@@ -223,7 +231,6 @@ It is also useful if you need to interrupt the automatic pipeline processing and
Methods in this namespace are used to deal with the response part of the pipeline after the request returns from FactFinder.
-
#### Dispatching manually
You can manually invoke the response pipeline by sending data through the various entry points in the `response.dispatch` namespace.
@@ -310,11 +317,12 @@ factfinder.config.setAppConfig({
});
```
+
### Routing
The `routing` namespace has been introduced to the global `factfinder` object.
It contains various tools to deal with routing related topics.
-It also contains a sub-namespace `routing.sandboxed`, when you run Web Components in sandbox mode, that enables you to manually deal with all environment interactions that Web Components would usually do automatically.
+It also contains a sub-namespace `routing.sandboxed` that, when you run Web Components in sandbox mode, enables you to manually deal with all environment interactions that Web Components would usually do automatically.
`setNavigateListener` allows you to register a listener that is invoked whenever Web Components arrives at a point where it would navigate to a new page.
For example after clicking on a product suggestion that leads to a product detail page.
@@ -325,7 +333,7 @@ You can interrupt Web Components' attempt to navigate and handle it as your envi
factfinder.routing.setNavigateListener((url, origin) => {
// `url` is the URL to which Web Components is about to navigate to.
window.location.href = `/my/custom/target`;
- return false; // To interrupt pipeline and prevent redundant requests to FactFinder.
+ return false; // To prevent navigation by Web Components.
});
```
@@ -347,7 +355,8 @@ factfinder.routing.setUrlParamOptionsListener(() => ({
}));
```
-See _Customise URL parameters_ for more details.
+See _Customize URL parameters_ for more details.
+
## Initialization of the Web Components application
@@ -356,7 +365,7 @@ The event occurs on the `document` object when the library's core finishes its i
Call the `init` function and pass it a **config object** with all parameters your application requires.
-The following example shows the minimum setup.
+The following example shows the **minimum setup**.
```js
document.addEventListener(`ffCoreReady`, ({ factfinder, init, initialSearch }) => {
@@ -420,7 +429,7 @@ document.addEventListener(`ffCoreReady`, ({ factfinder, init, initialSearch }) =
#### Session ID
-If `sid` is empty, a new random session ID will be generated by Web Components and preserved across page loads.
+If `sid` is empty and Web Components is unable to determine a session ID from the environment, a new random session ID will be generated and preserved across page loads.
Usually, you never have to set it.
You only need to set it if you want to force a particular session ID.
@@ -433,7 +442,7 @@ None of these parameters are sent to FactFinder.
The `appConfig` section itself and all of its fields are optional.
You only need to specify the fields you want to set.
-The following example shows all available fields and their default value.
+The following example shows all available fields and their default values.
```js
document.addEventListener(`ffCoreReady`, ({ factfinder, init, initialSearch }) => {
@@ -457,7 +466,7 @@ document.addEventListener(`ffCoreReady`, ({ factfinder, init, initialSearch }) =
#### Category page
This property takes an array of `Filter` objects as defined by the FactFinder API.
-When this property is set, Web Components considers the current page a category page and behaves accordingly.
+When this property is set, Web Components considers the current page to be a category page and behaves accordingly.
Examples of this behavior are:
- usage of the `/navigation` API endpoint instead of `/search`
@@ -487,7 +496,11 @@ They must be different or the template engine will not be able to interpret the
Make sure to choose tags that do not occur anywhere else.
```js
-factfinder.config.dataBindingTags = [`[[`, `]]`];
+init({
+ appConfig: {
+ dataBindingTags: [`[[`, `]]`],
+ },
+});
```
```html