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

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-e82ee728.js} +228 -182
  3. package/cjs/App-e82ee728.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-986d0bc6.js} +228 -183
  43. package/esm/App-986d0bc6.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
 
@@ -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 _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _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,22 +428,20 @@ 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;
436
- const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
433
+ 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;
434
+ 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;
435
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
436
+ const setContentTypeLimits = (typeof staticRouteLinkDepth === 'undefined' || !staticRouteFields) && !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
437
437
  const state = yield effects.select();
438
438
  const routeEntry = selectors.selectRouteEntry(state, 'js');
439
439
  const routeNode = selectors.selectCurrentNode(state, 'js');
440
440
  const currentPath = action.path; //selectCurrentPath(state);
441
441
 
442
442
  const deliveryApiStatus = version$1.selectVersionStatus(state);
443
- const project = selectors.selectCurrentProject(state);
444
- const isHome = currentPath === '/';
443
+ const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
444
+
445
445
  const isPreview = currentPath && currentPath.startsWith('/preview/');
446
446
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
447
447
 
@@ -466,130 +466,89 @@ function* getRouteSaga(action) {
466
466
  type: actions.UPDATE_LOADING_STATE,
467
467
  isLoading: false
468
468
  });
469
- } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors));
469
+ } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
470
470
  } else {
471
- // Handle homepage
472
- if (isHome) {
473
- pathNode = yield cachedSearch.getRootNode({
471
+ // Handle preview routes
472
+ if (isPreview) {
473
+ let splitPath = currentPath.split('/');
474
+ let entryGuid = splitPath[2];
475
+ let language = defaultLang;
476
+
477
+ if (splitPath.length >= 3) {
478
+ //set lang key if available in the path, else use default lang
479
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
480
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
481
+ // for previewing entries as it gives a response of []
482
+ // -- apparently it is not correct to request latest content
483
+ // with Node API
484
+
485
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
486
+ id: entryGuid,
487
+ language,
488
+ linkDepth: entryLinkDepth
489
+ });
490
+
491
+ if (previewEntry) {
492
+ pathNode = {
493
+ entry: previewEntry
494
+ };
495
+ ({
496
+ entry
497
+ } = pathNode || {});
498
+ }
499
+ }
500
+ } else {
501
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
502
+
503
+ // Handle all other routes
504
+ pathNode = yield cachedSearch.getNode({
474
505
  depth: 0,
475
- entryFields: '*',
476
- entryLinkDepth,
506
+ path: currentPath,
507
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : staticRouteFields || '*',
508
+ entryLinkDepth: setContentTypeLimits ? 0 : typeof staticRouteLinkDepth !== 'undefined' ? staticRouteLinkDepth : entryLinkDepth,
477
509
  language: defaultLang,
478
510
  versionStatus: deliveryApiStatus
479
511
  }, project);
480
512
  ({
481
513
  entry
482
514
  } = 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
515
 
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
- }
516
+ 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) {
517
+ var _payload$items;
518
+
519
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
520
+ // and current node's ordinates at a specified depth with specified fields
521
+ contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
522
+ const {
523
+ fields,
524
+ linkDepth
525
+ } = contentTypeMapping;
526
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
527
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
528
+
529
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
530
+ pathNode.entry = entry = payload.items[0];
585
531
  }
586
532
  }
587
- }
533
+ } // make calls to fetch node ancestors, children,
534
+ // siblings or entire node tree
535
+
536
+
537
+ [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
538
+ appsays,
539
+ contentTypeMapping,
540
+ language: defaultLang,
541
+ path: currentPath,
542
+ pathNode,
543
+ project,
544
+ versionStatus: deliveryApiStatus
545
+ });
546
+ if (children) pathNode.children = children;
588
547
  }
589
548
 
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
549
+ 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
550
 
592
- if (contentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, contentTypeMapping.injectRedux);
551
+ if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
593
552
 
594
553
  if (withEvents && withEvents.onRouteLoaded) {
595
554
  // Check if the app has provided a requireLogin boolean flag or groups array
@@ -609,37 +568,123 @@ function* getRouteSaga(action) {
609
568
  });
610
569
  }
611
570
 
612
- if (pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
571
+ if (!appsays || !appsays.preventScrollTop) {
572
+ // Scroll into View
573
+ if (typeof window !== 'undefined') window.scrollTo(0, 0);
574
+ }
575
+
576
+ 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) {
577
+ var _staticRoute$route3, _staticRoute$route3$f, _appsays;
578
+
613
579
  entry = pathNode.entry;
614
- const {
615
- entryMapper
616
- } = contentTypeMapping;
617
- yield effects.call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, appsays && appsays.refetchNode);
580
+ 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
581
  } else {
619
582
  if (staticRoute) yield effects.call(setRouteEntry, null, pathNode, ancestors, siblings);else yield effects.call(do404);
620
583
  }
584
+ } catch (e) {
585
+ log__namespace.error(...['Error running route saga:', e, e.stack]);
586
+ yield effects.call(do500, e);
587
+ }
588
+ }
621
589
 
622
- if (!appsays || !appsays.preventScrollTop) {
623
- // Scroll into View
624
- if (typeof window !== 'undefined') {
625
- window.scroll({
626
- top: 0
627
- });
628
- }
590
+ function* resolveCurrentNodeOrdinates({
591
+ appsays,
592
+ contentTypeMapping,
593
+ language,
594
+ path,
595
+ pathNode,
596
+ project,
597
+ versionStatus
598
+ }) {
599
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
600
+ // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
601
+ // if appsays nothing we will set doNavigation to true and continue to do navigation calls
602
+
603
+ const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
604
+ const {
605
+ entryLinkDepth = 0,
606
+ fields,
607
+ linkDepth,
608
+ nodeOptions = {}
609
+ } = contentTypeMapping;
610
+
611
+ if (pathNode && pathNode.id) {
612
+ if (doNavigation === true || doNavigation.ancestors) {
613
+ apiCall[0] = function* getAncestors() {
614
+ try {
615
+ return yield cachedSearch.getAncestors({
616
+ id: pathNode.id,
617
+ language,
618
+ versionStatus
619
+ }, project);
620
+ } catch (ex) {
621
+ log__namespace.info('Problem fetching ancestors', ex);
622
+ return [];
623
+ }
624
+ };
629
625
  }
630
626
 
631
- if (!version.hasNavigationTree(state) && (doNavigation === true || doNavigation.tree)) if (typeof window !== 'undefined') {
632
- yield effects.put({
627
+ const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
628
+
629
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
630
+ const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
631
+
632
+ apiCall[1] = function* getChildren() {
633
+ try {
634
+ return yield cachedSearch.getNode({
635
+ depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
636
+ path,
637
+ entryFields: childrenOptions.fields || fields || undefined,
638
+ entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
639
+ language,
640
+ versionStatus
641
+ }, project);
642
+ } catch (ex) {
643
+ log__namespace.info('Problem fetching children', ex);
644
+ return [];
645
+ }
646
+ };
647
+ }
648
+
649
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
650
+ apiCall[2] = function* getSiblings() {
651
+ try {
652
+ var _nodeOptions$siblings, _nodeOptions$siblings2;
653
+
654
+ return yield cachedSearch.getSiblings({
655
+ id: pathNode.id,
656
+ entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
657
+ 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,
658
+ includeInMenu: true,
659
+ language,
660
+ versionStatus
661
+ }, project);
662
+ } catch (ex) {
663
+ log__namespace.info('Problem fetching siblings', ex);
664
+ return [];
665
+ }
666
+ };
667
+ }
668
+ }
669
+
670
+ const isTreeLoaded = yield effects.select(version.hasNavigationTree);
671
+ if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
672
+ const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
673
+
674
+ if (typeof window !== 'undefined') {
675
+ return yield effects.put({
633
676
  type: version.GET_NODE_TREE,
634
- treeDepth: doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree
677
+ treeDepth
635
678
  });
636
679
  } else {
637
- yield effects.call(ensureNodeTreeSaga);
680
+ return yield effects.call(ensureNodeTreeSaga, {
681
+ treeDepth
682
+ });
638
683
  }
639
- } catch (e) {
640
- log__namespace.error(...['Error running route saga:', e, e.stack]);
641
- yield effects.call(do500, e);
642
- }
684
+ };
685
+ const [loadAncestors, loadChildren, loadSiblings, loadTree] = apiCall;
686
+ const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
687
+ return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
643
688
  }
644
689
 
645
690
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
@@ -976,7 +1021,7 @@ function* changePasswordSaga(action) {
976
1021
  yield effects.put({
977
1022
  type: reducers.CHANGE_USER_PASSWORD_SENDING
978
1023
  });
979
- const clientCredentials = yield effects.select(ToJs.selectClientCredentials);
1024
+ const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
980
1025
  const client = yield login.getManagementApiClient({ ...clientCredentials
981
1026
  });
982
1027
  const [err, res] = yield awaitToJs.to(client.security.users.updatePassword(changePasswordObject));
@@ -1066,8 +1111,9 @@ const AppRoot = props => {
1066
1111
 
1067
1112
  exports.AppRoot = AppRoot;
1068
1113
  exports.browserHistory = browserHistory;
1114
+ exports.cachedSearch = cachedSearch;
1069
1115
  exports.deliveryApi = deliveryApi;
1070
1116
  exports.history = history;
1071
1117
  exports.pickProject = pickProject;
1072
1118
  exports.rootSaga = rootSaga;
1073
- //# sourceMappingURL=App-5d20127f.js.map
1119
+ //# sourceMappingURL=App-e82ee728.js.map