@zengenti/contensis-react-base 3.0.0-beta.8 → 3.0.0-beta.80

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 (166) hide show
  1. package/README.md +1 -1
  2. package/cjs/{App-e3200f18.js → App-5a34ea98.js} +228 -181
  3. package/cjs/App-5a34ea98.js.map +1 -0
  4. package/cjs/{RouteLoader-df3de0cb.js → RouteLoader-2675e1c9.js} +31 -23
  5. package/cjs/RouteLoader-2675e1c9.js.map +1 -0
  6. package/cjs/{ToJs-697ace9f.js → ToJs-a9a8522b.js} +39 -34
  7. package/cjs/ToJs-a9a8522b.js.map +1 -0
  8. package/cjs/{actions-a24bf46e.js → actions-8dc9e8de.js} +5 -4
  9. package/cjs/actions-8dc9e8de.js.map +1 -0
  10. package/cjs/client.js +22 -44
  11. package/cjs/client.js.map +1 -1
  12. package/cjs/contensis-react-base.js +3955 -135
  13. package/cjs/contensis-react-base.js.map +1 -1
  14. package/cjs/forms.js +547 -580
  15. package/cjs/forms.js.map +1 -1
  16. package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
  17. package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
  18. package/cjs/{login-bc55ee33.js → login-6b9de6a1.js} +92 -55
  19. package/cjs/login-6b9de6a1.js.map +1 -0
  20. package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
  21. package/cjs/reducers-3a4f8971.js.map +1 -0
  22. package/cjs/redux.js +6 -5
  23. package/cjs/redux.js.map +1 -1
  24. package/cjs/routing.js +5 -4
  25. package/cjs/routing.js.map +1 -1
  26. package/cjs/sagas-594b5ecd.js +2090 -0
  27. package/cjs/sagas-594b5ecd.js.map +1 -0
  28. package/cjs/search.js +296 -1915
  29. package/cjs/search.js.map +1 -1
  30. package/cjs/{selectors-0ec95076.js → selectors-656da4b7.js} +8 -3
  31. package/cjs/selectors-656da4b7.js.map +1 -0
  32. package/cjs/setCachingHeaders-ee619bdf.js +12 -0
  33. package/cjs/setCachingHeaders-ee619bdf.js.map +1 -0
  34. package/cjs/user.js +21 -12
  35. package/cjs/user.js.map +1 -1
  36. package/cjs/util.js +17 -17
  37. package/cjs/util.js.map +1 -1
  38. package/cjs/{version-4f0f5fa6.js → version-330551f5.js} +34 -22
  39. package/cjs/version-330551f5.js.map +1 -0
  40. package/cjs/{version-be0c7b7a.js → version-eba6d09b.js} +2 -2
  41. package/{esm/version-ad2ec52c.js.map → cjs/version-eba6d09b.js.map} +1 -1
  42. package/esm/{App-f9e7d03b.js → App-a973f962.js} +228 -182
  43. package/esm/App-a973f962.js.map +1 -0
  44. package/esm/{RouteLoader-027215f2.js → RouteLoader-f607a134.js} +31 -23
  45. package/esm/RouteLoader-f607a134.js.map +1 -0
  46. package/esm/{ToJs-46761960.js → ToJs-4e02a04d.js} +38 -32
  47. package/esm/ToJs-4e02a04d.js.map +1 -0
  48. package/esm/{actions-b949ef5c.js → actions-180948dd.js} +5 -4
  49. package/esm/actions-180948dd.js.map +1 -0
  50. package/esm/client.js +24 -27
  51. package/esm/client.js.map +1 -1
  52. package/esm/contensis-react-base.js +3953 -134
  53. package/esm/contensis-react-base.js.map +1 -1
  54. package/esm/forms.js +547 -583
  55. package/esm/forms.js.map +1 -1
  56. package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
  57. package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
  58. package/esm/{login-6eab4c94.js → login-508cac0f.js} +92 -55
  59. package/esm/login-508cac0f.js.map +1 -0
  60. package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
  61. package/esm/reducers-8e5d6232.js.map +1 -0
  62. package/esm/redux.js +8 -7
  63. package/esm/redux.js.map +1 -1
  64. package/esm/routing.js +5 -4
  65. package/esm/routing.js.map +1 -1
  66. package/esm/sagas-1f2b2aa0.js +2000 -0
  67. package/esm/sagas-1f2b2aa0.js.map +1 -0
  68. package/esm/search.js +252 -1856
  69. package/esm/search.js.map +1 -1
  70. package/esm/{selectors-8fca7fb2.js → selectors-a5e5835b.js} +9 -6
  71. package/esm/selectors-a5e5835b.js.map +1 -0
  72. package/esm/setCachingHeaders-d49060e1.js +10 -0
  73. package/esm/setCachingHeaders-d49060e1.js.map +1 -0
  74. package/esm/user.js +23 -14
  75. package/esm/user.js.map +1 -1
  76. package/esm/util.js +17 -17
  77. package/esm/util.js.map +1 -1
  78. package/esm/{version-ad2ec52c.js → version-2485e2fb.js} +2 -2
  79. package/{cjs/version-be0c7b7a.js.map → esm/version-2485e2fb.js.map} +1 -1
  80. package/esm/{version-612d9ef0.js → version-c776a92b.js} +33 -22
  81. package/esm/version-c776a92b.js.map +1 -0
  82. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  83. package/models/forms/index.d.ts +3 -1
  84. package/models/index.d.ts +1 -0
  85. package/models/redux/appstate.d.ts +5 -10
  86. package/models/redux/sagas/navigation.d.ts +1 -1
  87. package/models/redux/selectors/navigation.d.ts +2 -1
  88. package/models/routing/components/RouteLoader.d.ts +2 -19
  89. package/models/routing/redux/actions.d.ts +1 -1
  90. package/models/routing/redux/selectors.d.ts +1 -1
  91. package/models/routing/routes.d.ts +9 -3
  92. package/models/routing/util/expressions.d.ts +3 -2
  93. package/models/routing/util/queries.d.ts +1 -1
  94. package/models/search/containers/withListing.d.ts +1 -1
  95. package/models/search/containers/withSearch.d.ts +1 -1
  96. package/models/search/hooks/useFacets.hook.d.ts +3 -0
  97. package/models/search/hooks/useListing.hook.d.ts +3 -0
  98. package/models/search/hooks/useMinilist.hook.d.ts +2 -9
  99. package/models/search/index.d.ts +6 -2
  100. package/models/search/models/Queries.d.ts +8 -5
  101. package/models/search/models/Search.d.ts +60 -28
  102. package/models/search/models/SearchActions.d.ts +9 -5
  103. package/models/search/models/SearchProps.d.ts +52 -7
  104. package/models/search/models/SearchState.d.ts +5 -1
  105. package/models/search/models/index.d.ts +3 -1
  106. package/models/search/redux/actions.d.ts +5 -2
  107. package/models/search/redux/reducers.d.ts +230 -314
  108. package/models/search/redux/sagas.d.ts +11 -7
  109. package/models/search/redux/selectors.d.ts +21 -24
  110. package/models/search/redux/util.d.ts +1 -0
  111. package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
  112. package/models/search/search/expressions.d.ts +5 -8
  113. package/models/search/{redux → search}/queries.d.ts +0 -0
  114. package/models/search/search/util.d.ts +14 -0
  115. package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
  116. package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
  117. package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
  118. package/models/search/transformations/index.d.ts +3 -0
  119. package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
  120. package/models/search/transformations/state-to-searchuri.d.ts +2 -13
  121. package/models/server/features/linkdepth-api/LinkDepthSearchService.d.ts +24 -0
  122. package/models/server/features/linkdepth-api/QueryLevelResults.d.ts +50 -0
  123. package/models/server/features/linkdepth-api/api.d.ts +12 -0
  124. package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
  125. package/models/server/features/linkdepth-api/search.d.ts +31 -0
  126. package/models/server/features/linkdepth-api/util.d.ts +11 -0
  127. package/models/server/middleware/bundleManipulation.d.ts +2 -1
  128. package/models/server/util/bundles.d.ts +17 -21
  129. package/models/server/util/getVersionInfo.d.ts +1 -0
  130. package/models/server/util/headers.d.ts +3 -2
  131. package/models/user/components/Login.d.ts +1 -2
  132. package/models/user/components/LoginForm.d.ts +1 -2
  133. package/models/user/hocs/withLogin.d.ts +4 -2
  134. package/models/user/hocs/withRegistration.d.ts +2 -0
  135. package/models/user/hooks/useLogin.d.ts +5 -3
  136. package/models/user/redux/reducers.d.ts +4 -5
  137. package/models/user/redux/sagas/login.d.ts +11 -8
  138. package/models/user/redux/selectors.d.ts +12 -6
  139. package/models/user/util/LoginHelper.class.d.ts +4 -3
  140. package/models/util/ContensisDeliveryApi.d.ts +4 -4
  141. package/models/util/json-mapper.d.ts +9 -3
  142. package/models/util/merge.d.ts +1 -0
  143. package/package.json +60 -55
  144. package/CHANGELOG.md +0 -293
  145. package/cjs/App-e3200f18.js.map +0 -1
  146. package/cjs/RouteLoader-df3de0cb.js.map +0 -1
  147. package/cjs/ToJs-697ace9f.js.map +0 -1
  148. package/cjs/actions-a24bf46e.js.map +0 -1
  149. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  150. package/cjs/login-bc55ee33.js.map +0 -1
  151. package/cjs/reducers-fde41d6b.js.map +0 -1
  152. package/cjs/selectors-0ec95076.js.map +0 -1
  153. package/cjs/version-4f0f5fa6.js.map +0 -1
  154. package/esm/App-f9e7d03b.js.map +0 -1
  155. package/esm/RouteLoader-027215f2.js.map +0 -1
  156. package/esm/ToJs-46761960.js.map +0 -1
  157. package/esm/actions-b949ef5c.js.map +0 -1
  158. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  159. package/esm/login-6eab4c94.js.map +0 -1
  160. package/esm/reducers-d6c0edb1.js.map +0 -1
  161. package/esm/selectors-8fca7fb2.js.map +0 -1
  162. package/esm/version-612d9ef0.js.map +0 -1
  163. package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
  164. package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
  165. package/models/server/features/caching/cacheHashing.d.ts +0 -1
  166. package/package-lock.json +0 -14093
package/README.md CHANGED
@@ -14,7 +14,7 @@ Many projects upgrading to v3.0 of `contensis-react-base` are likely to be using
14
14
 
15
15
  You will need to upgrade your version of Storybook to be >= 6.1 which has support for React 17. [Further reading](https://storybook.js.org/blog/storybook-6-1/)
16
16
 
17
- TLDR: Storybook have provided a simple way to upgrade. Run `npx sb upgrade` when upgrading to v2.6 of `contensis-react-base`. You should also ensure you are running the latest version of webpack or webpack@4 to prevent futher errors when loading Storybook.
17
+ TLDR: Storybook have provided a simple way to upgrade. Run `npx sb upgrade` when upgrading to v3.0 of `contensis-react-base`. You should also ensure you are running the latest version of webpack or webpack@4 to prevent futher errors when loading Storybook.
18
18
 
19
19
  If you are still getting react errors after this, check your project for other dependencies to remove/update that rely on older versions of react
20
20
 
@@ -2,21 +2,21 @@
2
2
 
3
3
  var history$1 = require('history');
4
4
  var effects = require('@redux-saga/core/effects');
5
- var contensisDeliveryApi = require('contensis-delivery-api');
6
- var actions = require('./actions-a24bf46e.js');
7
- var version = require('./version-4f0f5fa6.js');
8
- var version$1 = require('./version-be0c7b7a.js');
9
- var selectors = require('./selectors-0ec95076.js');
10
5
  var log = require('loglevel');
11
- var login = require('./login-bc55ee33.js');
6
+ var contensisDeliveryApi = require('contensis-delivery-api');
7
+ var queryString = require('query-string');
8
+ var actions = require('./actions-8dc9e8de.js');
9
+ var version = require('./version-330551f5.js');
10
+ var version$1 = require('./version-eba6d09b.js');
11
+ var selectors = require('./selectors-656da4b7.js');
12
+ var login = require('./login-6b9de6a1.js');
12
13
  var awaitToJs = require('await-to-js');
13
- var reducers = require('./reducers-fde41d6b.js');
14
- var ToJs = require('./ToJs-697ace9f.js');
14
+ var reducers = require('./reducers-3a4f8971.js');
15
+ var ToJs = require('./ToJs-a9a8522b.js');
15
16
  var React = require('react');
16
17
  require('react-hot-loader');
17
18
  require('jsonpath-mapper');
18
- require('query-string');
19
- var RouteLoader = require('./RouteLoader-df3de0cb.js');
19
+ var RouteLoader = require('./RouteLoader-2675e1c9.js');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
@@ -41,13 +41,9 @@ function _interopNamespace(e) {
41
41
  var log__namespace = /*#__PURE__*/_interopNamespace(log);
42
42
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
 
44
- const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
45
- const history = (options = {}) => selectedHistory(options);
46
- const browserHistory = selectedHistory();
47
-
48
44
  const storeSurrogateKeys = response => {
49
45
  const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
50
- if (keys) version.reduxStore.dispatch(actions.setSurrogateKeys(keys));
46
+ if (keys) version.reduxStore === null || version.reduxStore === void 0 ? void 0 : version.reduxStore.dispatch(actions.setSurrogateKeys(keys, response.url));
51
47
  };
52
48
 
53
49
  const getClientConfig = project => {
@@ -58,7 +54,7 @@ const getClientConfig = project => {
58
54
 
59
55
  if (project) {
60
56
  config.projectId = project;
61
- } // // we only want the surrogate key header in a server context
57
+ } // we only want the surrogate key header in a server context
62
58
 
63
59
 
64
60
  if (typeof window === 'undefined') {
@@ -83,7 +79,15 @@ const getClientConfig = project => {
83
79
  class DeliveryApi {
84
80
  constructor() {
85
81
  this.getClientSideVersionStatus = () => {
86
- if (typeof window != 'undefined') {
82
+ if (typeof window !== 'undefined') {
83
+ // Allow overriding versionStatus with the querystring
84
+ const {
85
+ versionStatus
86
+ } = queryString.parse(window.location.search);
87
+ if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
88
+
89
+ if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
90
+
87
91
  const currentHostname = window.location.hostname;
88
92
  return this.getVersionStatusFromHostname(currentHostname);
89
93
  }
@@ -91,6 +95,14 @@ class DeliveryApi {
91
95
  return null;
92
96
  };
93
97
 
98
+ this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
99
+
100
+ this.getVersionStatusFromHeaders = headers => {
101
+ const versionStatusHeader = headers['x-entry-versionstatus'];
102
+ if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
103
+ return null;
104
+ };
105
+
94
106
  this.getVersionStatusFromHostname = currentHostname => {
95
107
  if (currentHostname.indexOf('localhost') > -1) return 'latest';
96
108
 
@@ -236,6 +248,11 @@ class CachedSearch {
236
248
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
237
249
  }
238
250
 
251
+ searchUsingPost(query, linkDepth = 0, project = '', env) {
252
+ const client = contensisDeliveryApi.Client.create(getClientConfig(project));
253
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
254
+ }
255
+
239
256
  get(id, linkDepth, versionStatus, project, env) {
240
257
  const client = contensisDeliveryApi.Client.create(getClientConfig(project));
241
258
  client.clientConfig.versionStatus = versionStatus;
@@ -292,32 +309,14 @@ class CachedSearch {
292
309
  return this.cache.get(key);
293
310
  }
294
311
 
295
- extendTaxonomyNode(node) {
296
- let id = this.getTaxonomyId(node);
297
- this.taxonomyLookup[id] = node.key;
298
- return { ...node,
299
- id,
300
- children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
301
- };
302
- }
303
-
304
- getTaxonomyId(node) {
305
- if (node.key) {
306
- let parts = node.key.split('/');
307
- return parts[parts.length - 1];
308
- }
309
-
310
- return '';
311
- }
312
-
313
- getTaxonomyKey(id) {
314
- return this.taxonomyLookup[id];
315
- }
316
-
317
312
  }
318
313
 
319
314
  const cachedSearch = new CachedSearch();
320
315
 
316
+ const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
317
+ const history = (options = {}) => selectedHistory(options);
318
+ const browserHistory = selectedHistory();
319
+
321
320
  const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
322
321
  function* ensureNodeTreeSaga(action) {
323
322
  const state = yield effects.select();
@@ -342,6 +341,7 @@ function* ensureNodeTreeSaga(action) {
342
341
  }
343
342
  }
344
343
  } catch (ex) {
344
+ log__namespace.error(...['Error running ensureNodeTreeSaga:', ex]);
345
345
  yield effects.put({
346
346
  type: version.GET_NODE_TREE_ERROR,
347
347
  error: ex.toString()
@@ -404,7 +404,7 @@ function* getRouteSaga(action) {
404
404
  let entry = null;
405
405
 
406
406
  try {
407
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
407
+ var _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
408
408
 
409
409
  const {
410
410
  withEvents,
@@ -418,7 +418,9 @@ function* getRouteSaga(action) {
418
418
 
419
419
  let pathNode = null,
420
420
  ancestors = null,
421
- siblings = null; // These variables are the return values from
421
+ children = [],
422
+ siblings = null;
423
+ let contentTypeMapping = {}; // These variables are the return values from
422
424
  // calls to withEvents.onRouteLoad and onRouteLoaded
423
425
 
424
426
  let appsays,
@@ -426,13 +428,9 @@ function* getRouteSaga(action) {
426
428
 
427
429
  if (withEvents && withEvents.onRouteLoad) {
428
430
  appsays = yield withEvents.onRouteLoad(action);
429
- } // if appsays customNavigation: true, we will set doNavigation to false
430
- // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
431
- // if appsays nothing we will set doNavigation to true and continue to do navigation calls
432
-
431
+ }
433
432
 
434
- const doNavigation = !appsays || (appsays && appsays.customNavigation === true ? false : appsays && appsays.customNavigation || true);
435
- const entryLinkDepth = appsays && appsays.entryLinkDepth || 3;
433
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
436
434
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
437
435
  const state = yield effects.select();
438
436
  const routeEntry = selectors.selectRouteEntry(state, 'js');
@@ -440,8 +438,8 @@ function* getRouteSaga(action) {
440
438
  const currentPath = action.path; //selectCurrentPath(state);
441
439
 
442
440
  const deliveryApiStatus = version$1.selectVersionStatus(state);
443
- const project = selectors.selectCurrentProject(state);
444
- const isHome = currentPath === '/';
441
+ const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
442
+
445
443
  const isPreview = currentPath && currentPath.startsWith('/preview/');
446
444
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
447
445
 
@@ -466,130 +464,92 @@ function* getRouteSaga(action) {
466
464
  type: actions.UPDATE_LOADING_STATE,
467
465
  isLoading: false
468
466
  });
469
- } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors));
467
+ } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
470
468
  } else {
471
- // Handle homepage
472
- if (isHome) {
473
- pathNode = yield cachedSearch.getRootNode({
469
+ // Handle preview routes
470
+ if (isPreview) {
471
+ let splitPath = currentPath.split('/');
472
+ let entryGuid = splitPath[2];
473
+ let language = defaultLang;
474
+
475
+ if (splitPath.length >= 3) {
476
+ //set lang key if available in the path, else use default lang
477
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
478
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
479
+ // for previewing entries as it gives a response of []
480
+ // -- apparently it is not correct to request latest content
481
+ // with Node API
482
+
483
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
484
+ id: entryGuid,
485
+ language,
486
+ linkDepth: entryLinkDepth
487
+ });
488
+
489
+ if (previewEntry) {
490
+ pathNode = {
491
+ entry: previewEntry
492
+ };
493
+ ({
494
+ entry
495
+ } = pathNode || {});
496
+ }
497
+ }
498
+ } else {
499
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
500
+
501
+ // Handle all other routes
502
+ pathNode = yield cachedSearch.getNode({
474
503
  depth: 0,
475
- entryFields: '*',
476
- entryLinkDepth,
504
+ path: currentPath,
505
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
506
+ entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
477
507
  language: defaultLang,
478
508
  versionStatus: deliveryApiStatus
479
509
  }, project);
480
510
  ({
481
511
  entry
482
512
  } = pathNode || {});
483
- } else {
484
- // Handle preview routes
485
- if (isPreview) {
486
- let splitPath = currentPath.split('/');
487
- let entryGuid = splitPath[2];
488
- let language = defaultLang;
489
-
490
- if (splitPath.length >= 3) {
491
- //set lang key if available in the path, else use default lang
492
- //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
493
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
494
- // for previewing entries as it gives a response of []
495
- // -- apparently it is not correct to request latest content
496
- // with Node API
497
-
498
- let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
499
- id: entryGuid,
500
- language,
501
- linkDepth: entryLinkDepth
502
- });
503
-
504
- if (previewEntry) {
505
- pathNode = {
506
- entry: previewEntry
507
- };
508
- ({
509
- entry
510
- } = pathNode || {});
511
- }
512
- }
513
- } else {
514
- // Handle all other routes
515
- const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
516
- pathNode = yield cachedSearch.getNode({
517
- depth: childrenDepth,
518
- path: currentPath,
519
- entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
520
- entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
521
- language: defaultLang,
522
- versionStatus: deliveryApiStatus
523
- }, project);
524
- ({
525
- entry
526
- } = pathNode || {});
527
-
528
- if (setContentTypeLimits && pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
529
- // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
530
- // at a specified depth with specified fields
531
- const {
532
- fields,
533
- linkDepth,
534
- nodeOptions = {}
535
- } = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
536
- const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
537
- const payload = yield cachedSearch.search(query, linkDepth || entryLinkDepth || 0, project);
538
-
539
- if (payload && payload.items && payload.items.length > 0) {
540
- pathNode.entry = entry = payload.items[0];
541
- }
542
-
543
- if (childrenDepth > 0 || nodeOptions.children) {
544
- const childrenOptions = nodeOptions.children || {}; // We need to make a separate call for child nodes if the first node query has been
545
- // limited by linkDepth or fields[]
546
-
547
- const childNodes = yield cachedSearch.getChildren({
548
- id: pathNode.id,
549
- entryFields: childrenOptions.fields || fields || '*',
550
- entryLinkDepth: childrenOptions.linkDepth || linkDepth || entryLinkDepth || 0,
551
- language: defaultLang,
552
- versionStatus: deliveryApiStatus
553
- });
554
-
555
- if (childNodes) {
556
- pathNode.children = childNodes;
557
- }
558
- }
559
- }
560
- }
561
513
 
562
- if (pathNode && pathNode.id) {
563
- if (doNavigation === true || doNavigation.ancestors) {
564
- try {
565
- ancestors = yield cachedSearch.getAncestors({
566
- id: pathNode.id,
567
- language: defaultLang,
568
- versionStatus: deliveryApiStatus
569
- }, project);
570
- } catch (ex) {
571
- log__namespace.info('Problem fetching ancestors', ex);
572
- }
573
- }
574
-
575
- if (doNavigation === true || doNavigation.siblings) {
576
- try {
577
- siblings = yield cachedSearch.getSiblings({
578
- id: pathNode.id,
579
- language: defaultLang,
580
- versionStatus: deliveryApiStatus
581
- }, project);
582
- } catch (ex) {
583
- log__namespace.info('Problem fetching siblings', ex);
584
- }
514
+ if (setContentTypeLimits && (_pathNode = pathNode) !== null && _pathNode !== void 0 && (_pathNode$entry = _pathNode.entry) !== null && _pathNode$entry !== void 0 && (_pathNode$entry$sys = _pathNode$entry.sys) !== null && _pathNode$entry$sys !== void 0 && _pathNode$entry$sys.id) {
515
+ var _payload$items;
516
+
517
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
518
+ // and current node's ordinates at a specified depth with specified fields
519
+ contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
520
+ const {
521
+ fields,
522
+ linkDepth
523
+ } = contentTypeMapping;
524
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
525
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
526
+
527
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
528
+ pathNode.entry = entry = payload.items[0];
585
529
  }
586
530
  }
587
- }
531
+ } // make calls to fetch node ancestors, children,
532
+ // siblings or entire node tree
533
+
534
+
535
+ [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
536
+ appsays,
537
+ contentTypeMapping,
538
+ language: defaultLang,
539
+ path: currentPath,
540
+ pathNode,
541
+ project,
542
+ versionStatus: deliveryApiStatus
543
+ });
544
+ if (children) pathNode.children = children;
588
545
  }
589
546
 
590
- const contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, (_pathNode = pathNode) === null || _pathNode === void 0 ? void 0 : (_pathNode$entry = _pathNode.entry) === null || _pathNode$entry === void 0 ? void 0 : (_pathNode$entry$sys = _pathNode$entry.sys) === null || _pathNode$entry$sys === void 0 ? void 0 : _pathNode$entry$sys.contentTypeId) || {}; // Inject redux { key, reducer, saga } provided by ContentTypeMapping
547
+ const {
548
+ entryMapper,
549
+ injectRedux
550
+ } = login.findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {}; // Inject redux { key, reducer, saga } provided by ContentTypeMapping
591
551
 
592
- if (contentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, contentTypeMapping.injectRedux);
552
+ if (injectRedux) yield effects.call(reduxInjectorSaga, injectRedux);
593
553
 
594
554
  if (withEvents && withEvents.onRouteLoaded) {
595
555
  // Check if the app has provided a requireLogin boolean flag or groups array
@@ -609,37 +569,123 @@ function* getRouteSaga(action) {
609
569
  });
610
570
  }
611
571
 
612
- if (pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
572
+ if (!appsays || !appsays.preventScrollTop) {
573
+ // Scroll into View
574
+ if (typeof window !== 'undefined') window.scrollTo(0, 0);
575
+ }
576
+
577
+ if ((_pathNode3 = pathNode) !== null && _pathNode3 !== void 0 && (_pathNode3$entry = _pathNode3.entry) !== null && _pathNode3$entry !== void 0 && (_pathNode3$entry$sys = _pathNode3$entry.sys) !== null && _pathNode3$entry$sys !== void 0 && _pathNode3$entry$sys.id) {
578
+ var _appsays;
579
+
613
580
  entry = pathNode.entry;
614
- const {
615
- entryMapper
616
- } = contentTypeMapping;
617
- yield effects.call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, appsays && appsays.refetchNode);
581
+ yield effects.call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
618
582
  } else {
619
583
  if (staticRoute) yield effects.call(setRouteEntry, null, pathNode, ancestors, siblings);else yield effects.call(do404);
620
584
  }
585
+ } catch (e) {
586
+ log__namespace.error(...['Error running route saga:', e, e.stack]);
587
+ yield effects.call(do500, e);
588
+ }
589
+ }
621
590
 
622
- if (!appsays || !appsays.preventScrollTop) {
623
- // Scroll into View
624
- if (typeof window !== 'undefined') {
625
- window.scroll({
626
- top: 0
627
- });
628
- }
591
+ function* resolveCurrentNodeOrdinates({
592
+ appsays,
593
+ contentTypeMapping,
594
+ language,
595
+ path,
596
+ pathNode,
597
+ project,
598
+ versionStatus
599
+ }) {
600
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
601
+ // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
602
+ // if appsays nothing we will set doNavigation to true and continue to do navigation calls
603
+
604
+ const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
605
+ const {
606
+ entryLinkDepth = 0,
607
+ fields,
608
+ linkDepth,
609
+ nodeOptions = {}
610
+ } = contentTypeMapping;
611
+
612
+ if (pathNode && pathNode.id) {
613
+ if (doNavigation === true || doNavigation.ancestors) {
614
+ apiCall[0] = function* getAncestors() {
615
+ try {
616
+ return yield cachedSearch.getAncestors({
617
+ id: pathNode.id,
618
+ language,
619
+ versionStatus
620
+ }, project);
621
+ } catch (ex) {
622
+ log__namespace.info('Problem fetching ancestors', ex);
623
+ return [];
624
+ }
625
+ };
629
626
  }
630
627
 
631
- if (!version.hasNavigationTree(state) && (doNavigation === true || doNavigation.tree)) if (typeof window !== 'undefined') {
632
- yield effects.put({
628
+ const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
629
+
630
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
631
+ const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
632
+
633
+ apiCall[1] = function* getChildren() {
634
+ try {
635
+ return yield cachedSearch.getNode({
636
+ depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
637
+ path,
638
+ entryFields: childrenOptions.fields || fields || undefined,
639
+ entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
640
+ language,
641
+ versionStatus
642
+ }, project);
643
+ } catch (ex) {
644
+ log__namespace.info('Problem fetching children', ex);
645
+ return [];
646
+ }
647
+ };
648
+ }
649
+
650
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
651
+ apiCall[2] = function* getSiblings() {
652
+ try {
653
+ var _nodeOptions$siblings, _nodeOptions$siblings2;
654
+
655
+ return yield cachedSearch.getSiblings({
656
+ id: pathNode.id,
657
+ entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
658
+ entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
659
+ includeInMenu: true,
660
+ language,
661
+ versionStatus
662
+ }, project);
663
+ } catch (ex) {
664
+ log__namespace.info('Problem fetching siblings', ex);
665
+ return [];
666
+ }
667
+ };
668
+ }
669
+ }
670
+
671
+ const isTreeLoaded = yield effects.select(version.hasNavigationTree);
672
+ if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
673
+ const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
674
+
675
+ if (typeof window !== 'undefined') {
676
+ return yield effects.put({
633
677
  type: version.GET_NODE_TREE,
634
- treeDepth: doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree
678
+ treeDepth
635
679
  });
636
680
  } else {
637
- yield effects.call(ensureNodeTreeSaga);
681
+ return yield effects.call(ensureNodeTreeSaga, {
682
+ treeDepth
683
+ });
638
684
  }
639
- } catch (e) {
640
- log__namespace.error(...['Error running route saga:', e, e.stack]);
641
- yield effects.call(do500, e);
642
- }
685
+ };
686
+ const [loadAncestors, loadChildren, loadSiblings, loadTree] = apiCall;
687
+ const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
688
+ return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
643
689
  }
644
690
 
645
691
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
@@ -976,7 +1022,7 @@ function* changePasswordSaga(action) {
976
1022
  yield effects.put({
977
1023
  type: reducers.CHANGE_USER_PASSWORD_SENDING
978
1024
  });
979
- const clientCredentials = yield effects.select(ToJs.selectClientCredentials);
1025
+ const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
980
1026
  const client = yield login.getManagementApiClient({ ...clientCredentials
981
1027
  });
982
1028
  const [err, res] = yield awaitToJs.to(client.security.users.updatePassword(changePasswordObject));
@@ -1066,8 +1112,9 @@ const AppRoot = props => {
1066
1112
 
1067
1113
  exports.AppRoot = AppRoot;
1068
1114
  exports.browserHistory = browserHistory;
1115
+ exports.cachedSearch = cachedSearch;
1069
1116
  exports.deliveryApi = deliveryApi;
1070
1117
  exports.history = history;
1071
1118
  exports.pickProject = pickProject;
1072
1119
  exports.rootSaga = rootSaga;
1073
- //# sourceMappingURL=App-e3200f18.js.map
1120
+ //# sourceMappingURL=App-5a34ea98.js.map