@zengenti/contensis-react-base 3.0.0-beta.7 → 3.0.0-beta.70

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 (165) hide show
  1. package/README.md +1 -1
  2. package/cjs/{App-3324f784.js → App-0c10c9fa.js} +210 -175
  3. package/cjs/App-0c10c9fa.js.map +1 -0
  4. package/cjs/{RouteLoader-c7957b14.js → RouteLoader-2675e1c9.js} +31 -23
  5. package/cjs/RouteLoader-2675e1c9.js.map +1 -0
  6. package/cjs/ToJs-a9a8522b.js +129 -0
  7. package/cjs/ToJs-a9a8522b.js.map +1 -0
  8. package/cjs/VersionInfo-4c9dfa6a.js +181 -0
  9. package/cjs/VersionInfo-4c9dfa6a.js.map +1 -0
  10. package/cjs/{actions-a24bf46e.js → actions-8dc9e8de.js} +5 -4
  11. package/cjs/actions-8dc9e8de.js.map +1 -0
  12. package/cjs/client.js +17 -22
  13. package/cjs/client.js.map +1 -1
  14. package/cjs/contensis-react-base.js +3698 -142
  15. package/cjs/contensis-react-base.js.map +1 -1
  16. package/cjs/forms.js +181 -100
  17. package/cjs/forms.js.map +1 -1
  18. package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
  19. package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
  20. package/cjs/{login-c810cc4c.js → login-6b9de6a1.js} +92 -55
  21. package/cjs/login-6b9de6a1.js.map +1 -0
  22. package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
  23. package/cjs/reducers-3a4f8971.js.map +1 -0
  24. package/cjs/redux.js +6 -5
  25. package/cjs/redux.js.map +1 -1
  26. package/cjs/routing.js +5 -4
  27. package/cjs/routing.js.map +1 -1
  28. package/cjs/sagas-24f5607f.js +2052 -0
  29. package/cjs/sagas-24f5607f.js.map +1 -0
  30. package/cjs/search.js +283 -1909
  31. package/cjs/search.js.map +1 -1
  32. package/cjs/{selectors-0ec95076.js → selectors-656da4b7.js} +8 -3
  33. package/cjs/selectors-656da4b7.js.map +1 -0
  34. package/cjs/user.js +21 -12
  35. package/cjs/user.js.map +1 -1
  36. package/cjs/util.js +55 -212
  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-085d203d.js → version-eba6d09b.js} +5 -5
  41. package/cjs/version-eba6d09b.js.map +1 -0
  42. package/esm/{App-1b05ab11.js → App-d7b18a4f.js} +210 -176
  43. package/esm/App-d7b18a4f.js.map +1 -0
  44. package/esm/{RouteLoader-e5f0e8cb.js → RouteLoader-f96a61c1.js} +31 -23
  45. package/esm/RouteLoader-f96a61c1.js.map +1 -0
  46. package/esm/ToJs-affd73f1.js +99 -0
  47. package/esm/ToJs-affd73f1.js.map +1 -0
  48. package/esm/VersionInfo-f5403b09.js +172 -0
  49. package/esm/VersionInfo-f5403b09.js.map +1 -0
  50. package/esm/{actions-927d9698.js → actions-fcfc8704.js} +5 -4
  51. package/esm/actions-fcfc8704.js.map +1 -0
  52. package/esm/client.js +18 -23
  53. package/esm/client.js.map +1 -1
  54. package/esm/contensis-react-base.js +3698 -143
  55. package/esm/contensis-react-base.js.map +1 -1
  56. package/esm/forms.js +182 -102
  57. package/esm/forms.js.map +1 -1
  58. package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
  59. package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
  60. package/esm/{login-f8ba3aeb.js → login-ca2dc2f7.js} +92 -55
  61. package/esm/login-ca2dc2f7.js.map +1 -0
  62. package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
  63. package/esm/reducers-8e5d6232.js.map +1 -0
  64. package/esm/redux.js +8 -7
  65. package/esm/redux.js.map +1 -1
  66. package/esm/routing.js +5 -4
  67. package/esm/routing.js.map +1 -1
  68. package/esm/sagas-489c29ca.js +1966 -0
  69. package/esm/sagas-489c29ca.js.map +1 -0
  70. package/esm/search.js +243 -1850
  71. package/esm/search.js.map +1 -1
  72. package/esm/{selectors-b98d5c76.js → selectors-337be432.js} +7 -4
  73. package/esm/selectors-337be432.js.map +1 -0
  74. package/esm/user.js +23 -14
  75. package/esm/user.js.map +1 -1
  76. package/esm/util.js +54 -209
  77. package/esm/util.js.map +1 -1
  78. package/esm/version-6dd7b2cd.js +15 -0
  79. package/esm/version-6dd7b2cd.js.map +1 -0
  80. package/esm/{version-16aa83eb.js → version-c7268214.js} +33 -22
  81. package/esm/version-c7268214.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/selectors/navigation.d.ts +2 -1
  87. package/models/routing/components/RouteLoader.d.ts +2 -19
  88. package/models/routing/redux/actions.d.ts +1 -1
  89. package/models/routing/redux/selectors.d.ts +1 -1
  90. package/models/routing/routes.d.ts +9 -3
  91. package/models/routing/util/expressions.d.ts +3 -2
  92. package/models/routing/util/queries.d.ts +1 -1
  93. package/models/search/containers/withListing.d.ts +1 -1
  94. package/models/search/containers/withSearch.d.ts +1 -1
  95. package/models/search/hooks/useFacets.hook.d.ts +3 -0
  96. package/models/search/hooks/useListing.hook.d.ts +3 -0
  97. package/models/search/hooks/useMinilist.hook.d.ts +2 -9
  98. package/models/search/index.d.ts +4 -1
  99. package/models/search/models/Queries.d.ts +8 -5
  100. package/models/search/models/Search.d.ts +60 -28
  101. package/models/search/models/SearchActions.d.ts +4 -3
  102. package/models/search/models/SearchProps.d.ts +52 -7
  103. package/models/search/models/SearchState.d.ts +5 -1
  104. package/models/search/models/index.d.ts +3 -1
  105. package/models/search/redux/actions.d.ts +2 -1
  106. package/models/search/redux/reducers.d.ts +230 -314
  107. package/models/search/redux/sagas.d.ts +5 -5
  108. package/models/search/redux/selectors.d.ts +19 -22
  109. package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
  110. package/models/search/search/expressions.d.ts +3 -6
  111. package/models/search/{redux → search}/queries.d.ts +0 -0
  112. package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
  113. package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
  114. package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
  115. package/models/search/transformations/index.d.ts +3 -0
  116. package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
  117. package/models/search/transformations/state-to-searchuri.d.ts +2 -13
  118. package/models/server/features/linkdepth-api/api.d.ts +12 -0
  119. package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
  120. package/models/server/middleware/bundleManipulation.d.ts +2 -1
  121. package/models/server/util/getVersionInfo.d.ts +1 -0
  122. package/models/server/util/headers.d.ts +3 -2
  123. package/models/user/components/Login.d.ts +1 -2
  124. package/models/user/components/LoginForm.d.ts +1 -2
  125. package/models/user/hocs/withLogin.d.ts +4 -2
  126. package/models/user/hocs/withRegistration.d.ts +4 -2
  127. package/models/user/hooks/useChangePassword.d.ts +5 -5
  128. package/models/user/hooks/useForgotPassword.d.ts +6 -6
  129. package/models/user/hooks/useLogin.d.ts +9 -45
  130. package/models/user/hooks/useRegistration.d.ts +4 -4
  131. package/models/user/redux/reducers.d.ts +4 -5
  132. package/models/user/redux/sagas/login.d.ts +11 -8
  133. package/models/user/redux/selectors.d.ts +33 -71
  134. package/models/user/util/LoginHelper.class.d.ts +4 -3
  135. package/models/util/ContensisDeliveryApi.d.ts +1 -3
  136. package/models/util/json-mapper.d.ts +9 -3
  137. package/models/util/merge.d.ts +1 -0
  138. package/package-lock.json +2427 -4114
  139. package/package.json +59 -55
  140. package/cjs/App-3324f784.js.map +0 -1
  141. package/cjs/RouteLoader-c7957b14.js.map +0 -1
  142. package/cjs/ToJs-a38fa20e.js +0 -230
  143. package/cjs/ToJs-a38fa20e.js.map +0 -1
  144. package/cjs/actions-a24bf46e.js.map +0 -1
  145. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  146. package/cjs/login-c810cc4c.js.map +0 -1
  147. package/cjs/reducers-fde41d6b.js.map +0 -1
  148. package/cjs/selectors-0ec95076.js.map +0 -1
  149. package/cjs/version-085d203d.js.map +0 -1
  150. package/cjs/version-4f0f5fa6.js.map +0 -1
  151. package/esm/App-1b05ab11.js.map +0 -1
  152. package/esm/RouteLoader-e5f0e8cb.js.map +0 -1
  153. package/esm/ToJs-879a5a85.js +0 -199
  154. package/esm/ToJs-879a5a85.js.map +0 -1
  155. package/esm/actions-927d9698.js.map +0 -1
  156. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  157. package/esm/login-f8ba3aeb.js.map +0 -1
  158. package/esm/reducers-d6c0edb1.js.map +0 -1
  159. package/esm/selectors-b98d5c76.js.map +0 -1
  160. package/esm/version-16aa83eb.js.map +0 -1
  161. package/esm/version-3833e8b5.js +0 -15
  162. package/esm/version-3833e8b5.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
@@ -1,28 +1,24 @@
1
1
  import { createBrowserHistory, createMemoryHistory } from 'history';
2
2
  import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
3
- import { Client, Op, Query } from 'contensis-delivery-api';
4
- import { a as setSurrogateKeys, S as SET_NAVIGATION_PATH, b as SET_ROUTE, U as UPDATE_LOADING_STATE, c as SET_ENTRY, d as SET_ANCESTORS, e as SET_SIBLINGS, f as setRoute } from './actions-927d9698.js';
5
- import { r as reduxStore, G as GET_NODE_TREE, h as hasNavigationTree, S as SET_NODE_TREE, b as GET_NODE_TREE_ERROR, i as injectRedux } from './version-16aa83eb.js';
6
- import { s as selectVersionStatus } from './version-3833e8b5.js';
7
- import { a as selectCurrentProject, s as selectRouteEntry, b as selectCurrentNode, c as selectCurrentAncestors, d as selectRouteEntryEntryId, e as selectRouteEntryLanguage, f as selectMappedEntry, q as queryParams, h as selectCurrentSearch } from './selectors-b98d5c76.js';
8
3
  import * as log from 'loglevel';
9
- import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-f8ba3aeb.js';
4
+ import { Client, Op, Query } from 'contensis-delivery-api';
5
+ import { a as setSurrogateKeys, S as SET_NAVIGATION_PATH, b as SET_ROUTE, U as UPDATE_LOADING_STATE, c as SET_ENTRY, d as SET_ANCESTORS, e as SET_SIBLINGS, f as setRoute } from './actions-fcfc8704.js';
6
+ import { r as reduxStore, G as GET_NODE_TREE, h as hasNavigationTree, S as SET_NODE_TREE, b as GET_NODE_TREE_ERROR, i as injectRedux } from './version-c7268214.js';
7
+ import { s as selectVersionStatus } from './version-6dd7b2cd.js';
8
+ import { b as selectCurrentProject, a as selectRouteEntry, c as selectCurrentNode, d as selectCurrentAncestors, e as selectCurrentSiblings, f as selectRouteEntryEntryId, h as selectRouteEntryLanguage, i as selectMappedEntry, q as queryParams, j as selectCurrentSearch } from './selectors-337be432.js';
9
+ import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-ca2dc2f7.js';
10
10
  import { to } from 'await-to-js';
11
- import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-d6c0edb1.js';
12
- import { s as selectClientCredentials } from './ToJs-879a5a85.js';
11
+ import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-8e5d6232.js';
12
+ import { s as selectClientCredentials } from './ToJs-affd73f1.js';
13
13
  import React from 'react';
14
14
  import 'react-hot-loader';
15
15
  import 'jsonpath-mapper';
16
16
  import 'query-string';
17
- import { R as RouteLoader } from './RouteLoader-e5f0e8cb.js';
18
-
19
- const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
20
- const history = (options = {}) => selectedHistory(options);
21
- const browserHistory = selectedHistory();
17
+ import { R as RouteLoader } from './RouteLoader-f96a61c1.js';
22
18
 
23
19
  const storeSurrogateKeys = response => {
24
20
  const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
25
- if (keys) reduxStore.dispatch(setSurrogateKeys(keys));
21
+ if (keys) reduxStore === null || reduxStore === void 0 ? void 0 : reduxStore.dispatch(setSurrogateKeys(keys, response.url));
26
22
  };
27
23
 
28
24
  const getClientConfig = project => {
@@ -33,7 +29,7 @@ const getClientConfig = project => {
33
29
 
34
30
  if (project) {
35
31
  config.projectId = project;
36
- } // // we only want the surrogate key header in a server context
32
+ } // we only want the surrogate key header in a server context
37
33
 
38
34
 
39
35
  if (typeof window === 'undefined') {
@@ -211,6 +207,11 @@ class CachedSearch {
211
207
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
212
208
  }
213
209
 
210
+ searchUsingPost(query, linkDepth = 0, project = '', env) {
211
+ const client = Client.create(getClientConfig(project));
212
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
213
+ }
214
+
214
215
  get(id, linkDepth, versionStatus, project, env) {
215
216
  const client = Client.create(getClientConfig(project));
216
217
  client.clientConfig.versionStatus = versionStatus;
@@ -267,32 +268,14 @@ class CachedSearch {
267
268
  return this.cache.get(key);
268
269
  }
269
270
 
270
- extendTaxonomyNode(node) {
271
- let id = this.getTaxonomyId(node);
272
- this.taxonomyLookup[id] = node.key;
273
- return { ...node,
274
- id,
275
- children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
276
- };
277
- }
278
-
279
- getTaxonomyId(node) {
280
- if (node.key) {
281
- let parts = node.key.split('/');
282
- return parts[parts.length - 1];
283
- }
284
-
285
- return '';
286
- }
287
-
288
- getTaxonomyKey(id) {
289
- return this.taxonomyLookup[id];
290
- }
291
-
292
271
  }
293
272
 
294
273
  const cachedSearch = new CachedSearch();
295
274
 
275
+ const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
276
+ const history = (options = {}) => selectedHistory(options);
277
+ const browserHistory = selectedHistory();
278
+
296
279
  const navigationSagas = [takeEvery(GET_NODE_TREE, ensureNodeTreeSaga)];
297
280
  function* ensureNodeTreeSaga(action) {
298
281
  const state = yield select();
@@ -317,6 +300,7 @@ function* ensureNodeTreeSaga(action) {
317
300
  }
318
301
  }
319
302
  } catch (ex) {
303
+ log.error(...['Error running ensureNodeTreeSaga:', ex]);
320
304
  yield put({
321
305
  type: GET_NODE_TREE_ERROR,
322
306
  error: ex.toString()
@@ -379,7 +363,7 @@ function* getRouteSaga(action) {
379
363
  let entry = null;
380
364
 
381
365
  try {
382
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
366
+ var _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
383
367
 
384
368
  const {
385
369
  withEvents,
@@ -393,7 +377,9 @@ function* getRouteSaga(action) {
393
377
 
394
378
  let pathNode = null,
395
379
  ancestors = null,
396
- siblings = null; // These variables are the return values from
380
+ children = [],
381
+ siblings = null;
382
+ let contentTypeMapping = {}; // These variables are the return values from
397
383
  // calls to withEvents.onRouteLoad and onRouteLoaded
398
384
 
399
385
  let appsays,
@@ -401,13 +387,9 @@ function* getRouteSaga(action) {
401
387
 
402
388
  if (withEvents && withEvents.onRouteLoad) {
403
389
  appsays = yield withEvents.onRouteLoad(action);
404
- } // if appsays customNavigation: true, we will set doNavigation to false
405
- // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
406
- // if appsays nothing we will set doNavigation to true and continue to do navigation calls
407
-
390
+ }
408
391
 
409
- const doNavigation = !appsays || (appsays && appsays.customNavigation === true ? false : appsays && appsays.customNavigation || true);
410
- const entryLinkDepth = appsays && appsays.entryLinkDepth || 3;
392
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
411
393
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
412
394
  const state = yield select();
413
395
  const routeEntry = selectRouteEntry(state, 'js');
@@ -415,8 +397,8 @@ function* getRouteSaga(action) {
415
397
  const currentPath = action.path; //selectCurrentPath(state);
416
398
 
417
399
  const deliveryApiStatus = selectVersionStatus(state);
418
- const project = selectCurrentProject(state);
419
- const isHome = currentPath === '/';
400
+ const project = selectCurrentProject(state); // const isHome = currentPath === '/';
401
+
420
402
  const isPreview = currentPath && currentPath.startsWith('/preview/');
421
403
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
422
404
 
@@ -441,130 +423,92 @@ function* getRouteSaga(action) {
441
423
  type: UPDATE_LOADING_STATE,
442
424
  isLoading: false
443
425
  });
444
- } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors));
426
+ } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
445
427
  } else {
446
- // Handle homepage
447
- if (isHome) {
448
- pathNode = yield cachedSearch.getRootNode({
428
+ // Handle preview routes
429
+ if (isPreview) {
430
+ let splitPath = currentPath.split('/');
431
+ let entryGuid = splitPath[2];
432
+ let language = defaultLang;
433
+
434
+ if (splitPath.length >= 3) {
435
+ //set lang key if available in the path, else use default lang
436
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
437
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
438
+ // for previewing entries as it gives a response of []
439
+ // -- apparently it is not correct to request latest content
440
+ // with Node API
441
+
442
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
443
+ id: entryGuid,
444
+ language,
445
+ linkDepth: entryLinkDepth
446
+ });
447
+
448
+ if (previewEntry) {
449
+ pathNode = {
450
+ entry: previewEntry
451
+ };
452
+ ({
453
+ entry
454
+ } = pathNode || {});
455
+ }
456
+ }
457
+ } else {
458
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
459
+
460
+ // Handle all other routes
461
+ pathNode = yield cachedSearch.getNode({
449
462
  depth: 0,
450
- entryFields: '*',
451
- entryLinkDepth,
463
+ path: currentPath,
464
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
465
+ entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
452
466
  language: defaultLang,
453
467
  versionStatus: deliveryApiStatus
454
468
  }, project);
455
469
  ({
456
470
  entry
457
471
  } = pathNode || {});
458
- } else {
459
- // Handle preview routes
460
- if (isPreview) {
461
- let splitPath = currentPath.split('/');
462
- let entryGuid = splitPath[2];
463
- let language = defaultLang;
464
-
465
- if (splitPath.length >= 3) {
466
- //set lang key if available in the path, else use default lang
467
- //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
468
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
469
- // for previewing entries as it gives a response of []
470
- // -- apparently it is not correct to request latest content
471
- // with Node API
472
-
473
- let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
474
- id: entryGuid,
475
- language,
476
- linkDepth: entryLinkDepth
477
- });
478
-
479
- if (previewEntry) {
480
- pathNode = {
481
- entry: previewEntry
482
- };
483
- ({
484
- entry
485
- } = pathNode || {});
486
- }
487
- }
488
- } else {
489
- // Handle all other routes
490
- const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
491
- pathNode = yield cachedSearch.getNode({
492
- depth: childrenDepth,
493
- path: currentPath,
494
- entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
495
- entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
496
- language: defaultLang,
497
- versionStatus: deliveryApiStatus
498
- }, project);
499
- ({
500
- entry
501
- } = pathNode || {});
502
-
503
- if (setContentTypeLimits && pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
504
- // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
505
- // at a specified depth with specified fields
506
- const {
507
- fields,
508
- linkDepth,
509
- nodeOptions = {}
510
- } = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
511
- const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
512
- const payload = yield cachedSearch.search(query, linkDepth || entryLinkDepth || 0, project);
513
-
514
- if (payload && payload.items && payload.items.length > 0) {
515
- pathNode.entry = entry = payload.items[0];
516
- }
517
-
518
- if (childrenDepth > 0 || nodeOptions.children) {
519
- const childrenOptions = nodeOptions.children || {}; // We need to make a separate call for child nodes if the first node query has been
520
- // limited by linkDepth or fields[]
521
-
522
- const childNodes = yield cachedSearch.getChildren({
523
- id: pathNode.id,
524
- entryFields: childrenOptions.fields || fields || '*',
525
- entryLinkDepth: childrenOptions.linkDepth || linkDepth || entryLinkDepth || 0,
526
- language: defaultLang,
527
- versionStatus: deliveryApiStatus
528
- });
529
-
530
- if (childNodes) {
531
- pathNode.children = childNodes;
532
- }
533
- }
534
- }
535
- }
536
472
 
537
- if (pathNode && pathNode.id) {
538
- if (doNavigation === true || doNavigation.ancestors) {
539
- try {
540
- ancestors = yield cachedSearch.getAncestors({
541
- id: pathNode.id,
542
- language: defaultLang,
543
- versionStatus: deliveryApiStatus
544
- }, project);
545
- } catch (ex) {
546
- log.info('Problem fetching ancestors', ex);
547
- }
548
- }
549
-
550
- if (doNavigation === true || doNavigation.siblings) {
551
- try {
552
- siblings = yield cachedSearch.getSiblings({
553
- id: pathNode.id,
554
- language: defaultLang,
555
- versionStatus: deliveryApiStatus
556
- }, project);
557
- } catch (ex) {
558
- log.info('Problem fetching siblings', ex);
559
- }
473
+ 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) {
474
+ var _payload$items;
475
+
476
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
477
+ // and current node's ordinates at a specified depth with specified fields
478
+ contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
479
+ const {
480
+ fields,
481
+ linkDepth
482
+ } = contentTypeMapping;
483
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
484
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
485
+
486
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
487
+ pathNode.entry = entry = payload.items[0];
560
488
  }
561
489
  }
562
- }
490
+ } // make calls to fetch node ancestors, children,
491
+ // siblings or entire node tree
492
+
493
+
494
+ [ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
495
+ appsays,
496
+ contentTypeMapping,
497
+ language: defaultLang,
498
+ path: currentPath,
499
+ pathNode,
500
+ project,
501
+ versionStatus: deliveryApiStatus
502
+ });
503
+ if (children) pathNode.children = children;
563
504
  }
564
505
 
565
- const contentTypeMapping = 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
506
+ const {
507
+ entryMapper,
508
+ injectRedux
509
+ } = 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
566
510
 
567
- if (contentTypeMapping.injectRedux) yield call(reduxInjectorSaga, contentTypeMapping.injectRedux);
511
+ if (injectRedux) yield call(reduxInjectorSaga, injectRedux);
568
512
 
569
513
  if (withEvents && withEvents.onRouteLoaded) {
570
514
  // Check if the app has provided a requireLogin boolean flag or groups array
@@ -584,16 +528,6 @@ function* getRouteSaga(action) {
584
528
  });
585
529
  }
586
530
 
587
- if (pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
588
- entry = pathNode.entry;
589
- const {
590
- entryMapper
591
- } = contentTypeMapping;
592
- yield call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, appsays && appsays.refetchNode);
593
- } else {
594
- if (staticRoute) yield call(setRouteEntry, null, pathNode, ancestors, siblings);else yield call(do404);
595
- }
596
-
597
531
  if (!appsays || !appsays.preventScrollTop) {
598
532
  // Scroll into View
599
533
  if (typeof window !== 'undefined') {
@@ -603,13 +537,13 @@ function* getRouteSaga(action) {
603
537
  }
604
538
  }
605
539
 
606
- if (!hasNavigationTree(state) && (doNavigation === true || doNavigation.tree)) if (typeof window !== 'undefined') {
607
- yield put({
608
- type: GET_NODE_TREE,
609
- treeDepth: doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree
610
- });
540
+ 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) {
541
+ var _appsays;
542
+
543
+ entry = pathNode.entry;
544
+ yield call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
611
545
  } else {
612
- yield call(ensureNodeTreeSaga);
546
+ if (staticRoute) yield call(setRouteEntry, null, pathNode, ancestors, siblings);else yield call(do404);
613
547
  }
614
548
  } catch (e) {
615
549
  log.error(...['Error running route saga:', e, e.stack]);
@@ -617,6 +551,106 @@ function* getRouteSaga(action) {
617
551
  }
618
552
  }
619
553
 
554
+ function* resolveCurrentNodeOrdinates({
555
+ appsays,
556
+ contentTypeMapping,
557
+ language,
558
+ path,
559
+ pathNode,
560
+ project,
561
+ versionStatus
562
+ }) {
563
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
564
+ // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
565
+ // if appsays nothing we will set doNavigation to true and continue to do navigation calls
566
+
567
+ const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
568
+ const {
569
+ entryLinkDepth = 0,
570
+ fields,
571
+ linkDepth,
572
+ nodeOptions = {}
573
+ } = contentTypeMapping;
574
+
575
+ if (pathNode && pathNode.id) {
576
+ if (doNavigation === true || doNavigation.ancestors) {
577
+ apiCall[0] = function* getAncestors() {
578
+ try {
579
+ return yield cachedSearch.getAncestors({
580
+ id: pathNode.id,
581
+ language,
582
+ versionStatus
583
+ }, project);
584
+ } catch (ex) {
585
+ log.info('Problem fetching ancestors', ex);
586
+ return [];
587
+ }
588
+ };
589
+ }
590
+
591
+ const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
592
+
593
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
594
+ const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
595
+
596
+ apiCall[1] = function* getChildren() {
597
+ try {
598
+ return yield cachedSearch.getNode({
599
+ depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
600
+ path,
601
+ entryFields: childrenOptions.fields || fields || undefined,
602
+ entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
603
+ language,
604
+ versionStatus
605
+ }, project);
606
+ } catch (ex) {
607
+ log.info('Problem fetching children', ex);
608
+ return [];
609
+ }
610
+ };
611
+ }
612
+
613
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
614
+ apiCall[2] = function* getSiblings() {
615
+ try {
616
+ var _nodeOptions$siblings, _nodeOptions$siblings2;
617
+
618
+ return yield cachedSearch.getSiblings({
619
+ id: pathNode.id,
620
+ entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
621
+ 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,
622
+ includeInMenu: true,
623
+ language,
624
+ versionStatus
625
+ }, project);
626
+ } catch (ex) {
627
+ log.info('Problem fetching siblings', ex);
628
+ return [];
629
+ }
630
+ };
631
+ }
632
+ }
633
+
634
+ const isTreeLoaded = yield select(hasNavigationTree);
635
+ if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
636
+ const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
637
+
638
+ if (typeof window !== 'undefined') {
639
+ return yield put({
640
+ type: GET_NODE_TREE,
641
+ treeDepth
642
+ });
643
+ } else {
644
+ return yield call(ensureNodeTreeSaga, {
645
+ treeDepth
646
+ });
647
+ }
648
+ };
649
+ const [loadAncestors, loadChildren, loadSiblings, loadTree] = apiCall;
650
+ const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
651
+ return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
652
+ }
653
+
620
654
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
621
655
  const entrySys = entry && entry.sys || {};
622
656
  const currentEntryId = yield select(selectRouteEntryEntryId);
@@ -951,7 +985,7 @@ function* changePasswordSaga(action) {
951
985
  yield put({
952
986
  type: CHANGE_USER_PASSWORD_SENDING
953
987
  });
954
- const clientCredentials = yield select(selectClientCredentials);
988
+ const clientCredentials = yield select(selectClientCredentials, 'js');
955
989
  const client = yield getManagementApiClient({ ...clientCredentials
956
990
  });
957
991
  const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
@@ -1039,5 +1073,5 @@ const AppRoot = props => {
1039
1073
  return /*#__PURE__*/React.createElement(RouteLoader, props);
1040
1074
  };
1041
1075
 
1042
- export { AppRoot as A, browserHistory as b, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1043
- //# sourceMappingURL=App-1b05ab11.js.map
1076
+ export { AppRoot as A, browserHistory as b, cachedSearch as c, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1077
+ //# sourceMappingURL=App-d7b18a4f.js.map