@zengenti/contensis-react-base 3.0.0-beta.9 → 3.0.1-beta.1

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 +128 -1
  2. package/cjs/{App-5d20127f.js → App-c5698b06.js} +229 -182
  3. package/cjs/App-c5698b06.js.map +1 -0
  4. package/cjs/{RouteLoader-df3de0cb.js → RouteLoader-3aa6456e.js} +47 -28
  5. package/cjs/RouteLoader-3aa6456e.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 +3956 -136
  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-65d26804.js → fromJSLeaveImmer-e74c673c.js} +2 -2
  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-bf00e6d7.js → version-78dfc3bd.js} +35 -23
  39. package/cjs/version-78dfc3bd.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-4224ba21.js → App-069378e0.js} +229 -183
  43. package/esm/App-069378e0.js.map +1 -0
  44. package/esm/{RouteLoader-027215f2.js → RouteLoader-5171c63f.js} +47 -28
  45. package/esm/RouteLoader-5171c63f.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 +3954 -135
  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-e2f0f331.js → fromJSLeaveImmer-0114ffcf.js} +2 -2
  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-3b4fe08d.js → version-e3a5ec66.js} +34 -23
  81. package/esm/version-e3a5ec66.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 +22 -4
  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 +61 -56
  144. package/CHANGELOG.md +0 -293
  145. package/cjs/App-5d20127f.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-65d26804.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-bf00e6d7.js.map +0 -1
  154. package/esm/App-4224ba21.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-e2f0f331.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-3b4fe08d.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
@@ -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-bf00e6d7.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-78dfc3bd.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-3aa6456e.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
 
@@ -206,6 +218,7 @@ class LruCache {
206
218
 
207
219
  remove(key) {
208
220
  let node = this.map[key];
221
+ if (!node) return; // This is sometimes null and crashes the container without this check
209
222
 
210
223
  if (node.prev) {
211
224
  node.prev.next = node.next;
@@ -236,6 +249,11 @@ class CachedSearch {
236
249
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
237
250
  }
238
251
 
252
+ searchUsingPost(query, linkDepth = 0, project = '', env) {
253
+ const client = contensisDeliveryApi.Client.create(getClientConfig(project));
254
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
255
+ }
256
+
239
257
  get(id, linkDepth, versionStatus, project, env) {
240
258
  const client = contensisDeliveryApi.Client.create(getClientConfig(project));
241
259
  client.clientConfig.versionStatus = versionStatus;
@@ -292,32 +310,14 @@ class CachedSearch {
292
310
  return this.cache.get(key);
293
311
  }
294
312
 
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
313
  }
318
314
 
319
315
  const cachedSearch = new CachedSearch();
320
316
 
317
+ const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
318
+ const history = (options = {}) => selectedHistory(options);
319
+ const browserHistory = selectedHistory();
320
+
321
321
  const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
322
322
  function* ensureNodeTreeSaga(action) {
323
323
  const state = yield effects.select();
@@ -342,6 +342,7 @@ function* ensureNodeTreeSaga(action) {
342
342
  }
343
343
  }
344
344
  } catch (ex) {
345
+ log__namespace.error(...['Error running ensureNodeTreeSaga:', ex]);
345
346
  yield effects.put({
346
347
  type: version.GET_NODE_TREE_ERROR,
347
348
  error: ex.toString()
@@ -404,7 +405,7 @@ function* getRouteSaga(action) {
404
405
  let entry = null;
405
406
 
406
407
  try {
407
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
408
+ var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
408
409
 
409
410
  const {
410
411
  withEvents,
@@ -418,7 +419,9 @@ function* getRouteSaga(action) {
418
419
 
419
420
  let pathNode = null,
420
421
  ancestors = null,
421
- siblings = null; // These variables are the return values from
422
+ children = [],
423
+ siblings = null;
424
+ let contentTypeMapping = {}; // These variables are the return values from
422
425
  // calls to withEvents.onRouteLoad and onRouteLoaded
423
426
 
424
427
  let appsays,
@@ -426,22 +429,20 @@ function* getRouteSaga(action) {
426
429
 
427
430
  if (withEvents && withEvents.onRouteLoad) {
428
431
  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
-
432
+ }
433
433
 
434
- const doNavigation = !appsays || (appsays && appsays.customNavigation === true ? false : appsays && appsays.customNavigation || true);
435
- const entryLinkDepth = appsays && appsays.entryLinkDepth || 3;
436
- const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
434
+ const staticRouteLinkDepth = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 ? void 0 : (_staticRoute$route$pa = _staticRoute$route.params) === null || _staticRoute$route$pa === void 0 ? void 0 : _staticRoute$route$pa.linkDepth;
435
+ const staticRouteFields = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 ? void 0 : (_staticRoute$route2$p = _staticRoute$route2.params) === null || _staticRoute$route2$p === void 0 ? void 0 : _staticRoute$route2$p.fields;
436
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
437
+ const setContentTypeLimits = (typeof staticRouteLinkDepth === 'undefined' || !staticRouteFields) && !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
437
438
  const state = yield effects.select();
438
439
  const routeEntry = selectors.selectRouteEntry(state, 'js');
439
440
  const routeNode = selectors.selectCurrentNode(state, 'js');
440
441
  const currentPath = action.path; //selectCurrentPath(state);
441
442
 
442
443
  const deliveryApiStatus = version$1.selectVersionStatus(state);
443
- const project = selectors.selectCurrentProject(state);
444
- const isHome = currentPath === '/';
444
+ const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
445
+
445
446
  const isPreview = currentPath && currentPath.startsWith('/preview/');
446
447
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
447
448
 
@@ -466,130 +467,89 @@ function* getRouteSaga(action) {
466
467
  type: actions.UPDATE_LOADING_STATE,
467
468
  isLoading: false
468
469
  });
469
- } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors));
470
+ } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
470
471
  } else {
471
- // Handle homepage
472
- if (isHome) {
473
- pathNode = yield cachedSearch.getRootNode({
472
+ // Handle preview routes
473
+ if (isPreview) {
474
+ let splitPath = currentPath.split('/');
475
+ let entryGuid = splitPath[2];
476
+ let language = defaultLang;
477
+
478
+ if (splitPath.length >= 3) {
479
+ //set lang key if available in the path, else use default lang
480
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
481
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
482
+ // for previewing entries as it gives a response of []
483
+ // -- apparently it is not correct to request latest content
484
+ // with Node API
485
+
486
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
487
+ id: entryGuid,
488
+ language,
489
+ linkDepth: entryLinkDepth
490
+ });
491
+
492
+ if (previewEntry) {
493
+ pathNode = {
494
+ entry: previewEntry
495
+ };
496
+ ({
497
+ entry
498
+ } = pathNode || {});
499
+ }
500
+ }
501
+ } else {
502
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
503
+
504
+ // Handle all other routes
505
+ pathNode = yield cachedSearch.getNode({
474
506
  depth: 0,
475
- entryFields: '*',
476
- entryLinkDepth,
507
+ path: currentPath,
508
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : staticRouteFields || '*',
509
+ entryLinkDepth: setContentTypeLimits ? 0 : typeof staticRouteLinkDepth !== 'undefined' ? staticRouteLinkDepth : entryLinkDepth,
477
510
  language: defaultLang,
478
511
  versionStatus: deliveryApiStatus
479
512
  }, project);
480
513
  ({
481
514
  entry
482
515
  } = 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
516
 
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
- }
517
+ 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) {
518
+ var _payload$items;
519
+
520
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
521
+ // and current node's ordinates at a specified depth with specified fields
522
+ contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
523
+ const {
524
+ fields,
525
+ linkDepth
526
+ } = contentTypeMapping;
527
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
528
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
529
+
530
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
531
+ pathNode.entry = entry = payload.items[0];
585
532
  }
586
533
  }
587
- }
534
+ } // make calls to fetch node ancestors, children,
535
+ // siblings or entire node tree
536
+
537
+
538
+ [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
539
+ appsays,
540
+ contentTypeMapping,
541
+ language: defaultLang,
542
+ path: currentPath,
543
+ pathNode,
544
+ project,
545
+ versionStatus: deliveryApiStatus
546
+ });
547
+ if (children) pathNode.children = children;
588
548
  }
589
549
 
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
550
+ const resolvedContentTypeMapping = 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 (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.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 _staticRoute$route3, _staticRoute$route3$f, _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, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.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-5d20127f.js.map
1120
+ //# sourceMappingURL=App-c5698b06.js.map