@zengenti/contensis-react-base 3.0.0-beta.6 → 3.0.0-beta.62

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 (164) hide show
  1. package/README.md +4 -4
  2. package/cjs/{App-3324f784.js → App-6e2518eb.js} +204 -174
  3. package/cjs/App-6e2518eb.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 +16 -21
  13. package/cjs/client.js.map +1 -1
  14. package/cjs/contensis-react-base.js +3583 -38
  15. package/cjs/contensis-react-base.js.map +1 -1
  16. package/cjs/forms.js +4114 -195
  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-8cf21563.js +2038 -0
  29. package/cjs/sagas-8cf21563.js.map +1 -0
  30. package/cjs/search.js +280 -1907
  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-b3e55cdf.js} +28 -20
  39. package/cjs/version-b3e55cdf.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-5efba16c.js} +204 -175
  43. package/esm/App-5efba16c.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 +17 -22
  53. package/esm/client.js.map +1 -1
  54. package/esm/contensis-react-base.js +3581 -37
  55. package/esm/contensis-react-base.js.map +1 -1
  56. package/esm/forms.js +4114 -198
  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-a22fc54a.js +1952 -0
  69. package/esm/sagas-a22fc54a.js.map +1 -0
  70. package/esm/search.js +240 -1848
  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-16aa83eb.js → version-470f0b15.js} +27 -20
  79. package/esm/version-470f0b15.js.map +1 -0
  80. package/esm/version-6dd7b2cd.js +15 -0
  81. package/esm/version-6dd7b2cd.js.map +1 -0
  82. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  83. package/models/forms/index.d.ts +2 -0
  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/headers.d.ts +3 -2
  122. package/models/user/components/Login.d.ts +1 -2
  123. package/models/user/components/LoginForm.d.ts +1 -2
  124. package/models/user/hocs/withLogin.d.ts +4 -2
  125. package/models/user/hocs/withRegistration.d.ts +4 -2
  126. package/models/user/hooks/useChangePassword.d.ts +5 -5
  127. package/models/user/hooks/useForgotPassword.d.ts +6 -6
  128. package/models/user/hooks/useLogin.d.ts +9 -45
  129. package/models/user/hooks/useRegistration.d.ts +4 -4
  130. package/models/user/redux/reducers.d.ts +4 -5
  131. package/models/user/redux/sagas/login.d.ts +11 -8
  132. package/models/user/redux/selectors.d.ts +33 -71
  133. package/models/user/util/LoginHelper.class.d.ts +4 -3
  134. package/models/util/ContensisDeliveryApi.d.ts +1 -3
  135. package/models/util/json-mapper.d.ts +9 -3
  136. package/models/util/merge.d.ts +1 -0
  137. package/package-lock.json +2690 -3400
  138. package/package.json +60 -55
  139. package/cjs/App-3324f784.js.map +0 -1
  140. package/cjs/RouteLoader-c7957b14.js.map +0 -1
  141. package/cjs/ToJs-a38fa20e.js +0 -230
  142. package/cjs/ToJs-a38fa20e.js.map +0 -1
  143. package/cjs/actions-a24bf46e.js.map +0 -1
  144. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  145. package/cjs/login-c810cc4c.js.map +0 -1
  146. package/cjs/reducers-fde41d6b.js.map +0 -1
  147. package/cjs/selectors-0ec95076.js.map +0 -1
  148. package/cjs/version-085d203d.js.map +0 -1
  149. package/cjs/version-4f0f5fa6.js.map +0 -1
  150. package/esm/App-1b05ab11.js.map +0 -1
  151. package/esm/RouteLoader-e5f0e8cb.js.map +0 -1
  152. package/esm/ToJs-879a5a85.js +0 -199
  153. package/esm/ToJs-879a5a85.js.map +0 -1
  154. package/esm/actions-927d9698.js.map +0 -1
  155. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  156. package/esm/login-f8ba3aeb.js.map +0 -1
  157. package/esm/reducers-d6c0edb1.js.map +0 -1
  158. package/esm/selectors-b98d5c76.js.map +0 -1
  159. package/esm/version-16aa83eb.js.map +0 -1
  160. package/esm/version-3833e8b5.js +0 -15
  161. package/esm/version-3833e8b5.js.map +0 -1
  162. package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
  163. package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
  164. 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
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';
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-fcfc8704.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-470f0b15.js';
6
+ import { s as selectVersionStatus } from './version-6dd7b2cd.js';
7
+ 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';
8
8
  import * as log from 'loglevel';
9
- import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-f8ba3aeb.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();
@@ -379,7 +362,7 @@ function* getRouteSaga(action) {
379
362
  let entry = null;
380
363
 
381
364
  try {
382
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
365
+ var _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
383
366
 
384
367
  const {
385
368
  withEvents,
@@ -393,7 +376,9 @@ function* getRouteSaga(action) {
393
376
 
394
377
  let pathNode = null,
395
378
  ancestors = null,
396
- siblings = null; // These variables are the return values from
379
+ children = [],
380
+ siblings = null;
381
+ let contentTypeMapping = {}; // These variables are the return values from
397
382
  // calls to withEvents.onRouteLoad and onRouteLoaded
398
383
 
399
384
  let appsays,
@@ -401,13 +386,9 @@ function* getRouteSaga(action) {
401
386
 
402
387
  if (withEvents && withEvents.onRouteLoad) {
403
388
  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
-
389
+ }
408
390
 
409
- const doNavigation = !appsays || (appsays && appsays.customNavigation === true ? false : appsays && appsays.customNavigation || true);
410
- const entryLinkDepth = appsays && appsays.entryLinkDepth || 3;
391
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
411
392
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
412
393
  const state = yield select();
413
394
  const routeEntry = selectRouteEntry(state, 'js');
@@ -415,8 +396,8 @@ function* getRouteSaga(action) {
415
396
  const currentPath = action.path; //selectCurrentPath(state);
416
397
 
417
398
  const deliveryApiStatus = selectVersionStatus(state);
418
- const project = selectCurrentProject(state);
419
- const isHome = currentPath === '/';
399
+ const project = selectCurrentProject(state); // const isHome = currentPath === '/';
400
+
420
401
  const isPreview = currentPath && currentPath.startsWith('/preview/');
421
402
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
422
403
 
@@ -441,130 +422,92 @@ function* getRouteSaga(action) {
441
422
  type: UPDATE_LOADING_STATE,
442
423
  isLoading: false
443
424
  });
444
- } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors));
425
+ } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
445
426
  } else {
446
- // Handle homepage
447
- if (isHome) {
448
- pathNode = yield cachedSearch.getRootNode({
427
+ // Handle preview routes
428
+ if (isPreview) {
429
+ let splitPath = currentPath.split('/');
430
+ let entryGuid = splitPath[2];
431
+ let language = defaultLang;
432
+
433
+ if (splitPath.length >= 3) {
434
+ //set lang key if available in the path, else use default lang
435
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
436
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
437
+ // for previewing entries as it gives a response of []
438
+ // -- apparently it is not correct to request latest content
439
+ // with Node API
440
+
441
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
442
+ id: entryGuid,
443
+ language,
444
+ linkDepth: entryLinkDepth
445
+ });
446
+
447
+ if (previewEntry) {
448
+ pathNode = {
449
+ entry: previewEntry
450
+ };
451
+ ({
452
+ entry
453
+ } = pathNode || {});
454
+ }
455
+ }
456
+ } else {
457
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
458
+
459
+ // Handle all other routes
460
+ pathNode = yield cachedSearch.getNode({
449
461
  depth: 0,
450
- entryFields: '*',
451
- entryLinkDepth,
462
+ path: currentPath,
463
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
464
+ entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
452
465
  language: defaultLang,
453
466
  versionStatus: deliveryApiStatus
454
467
  }, project);
455
468
  ({
456
469
  entry
457
470
  } = 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
-
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
471
 
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
- }
472
+ 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) {
473
+ var _payload$items;
474
+
475
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
476
+ // and current node's ordinates at a specified depth with specified fields
477
+ contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
478
+ const {
479
+ fields,
480
+ linkDepth
481
+ } = contentTypeMapping;
482
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
483
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
484
+
485
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
486
+ pathNode.entry = entry = payload.items[0];
560
487
  }
561
488
  }
562
- }
489
+ } // make calls to fetch node ancestors, children,
490
+ // siblings or entire node tree
491
+
492
+
493
+ [ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
494
+ appsays,
495
+ contentTypeMapping,
496
+ language: defaultLang,
497
+ path: currentPath,
498
+ pathNode,
499
+ project,
500
+ versionStatus: deliveryApiStatus
501
+ });
502
+ if (children) pathNode.children = children;
563
503
  }
564
504
 
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
505
+ const {
506
+ entryMapper,
507
+ injectRedux
508
+ } = 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
509
 
567
- if (contentTypeMapping.injectRedux) yield call(reduxInjectorSaga, contentTypeMapping.injectRedux);
510
+ if (injectRedux) yield call(reduxInjectorSaga, injectRedux);
568
511
 
569
512
  if (withEvents && withEvents.onRouteLoaded) {
570
513
  // Check if the app has provided a requireLogin boolean flag or groups array
@@ -584,16 +527,6 @@ function* getRouteSaga(action) {
584
527
  });
585
528
  }
586
529
 
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
530
  if (!appsays || !appsays.preventScrollTop) {
598
531
  // Scroll into View
599
532
  if (typeof window !== 'undefined') {
@@ -603,13 +536,13 @@ function* getRouteSaga(action) {
603
536
  }
604
537
  }
605
538
 
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
- });
539
+ 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) {
540
+ var _appsays;
541
+
542
+ entry = pathNode.entry;
543
+ yield call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
611
544
  } else {
612
- yield call(ensureNodeTreeSaga);
545
+ if (staticRoute) yield call(setRouteEntry, null, pathNode, ancestors, siblings);else yield call(do404);
613
546
  }
614
547
  } catch (e) {
615
548
  log.error(...['Error running route saga:', e, e.stack]);
@@ -617,6 +550,102 @@ function* getRouteSaga(action) {
617
550
  }
618
551
  }
619
552
 
553
+ function* resolveCurrentNodeOrdinates({
554
+ appsays,
555
+ contentTypeMapping,
556
+ language,
557
+ path,
558
+ pathNode,
559
+ project,
560
+ versionStatus
561
+ }) {
562
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
563
+ // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
564
+ // if appsays nothing we will set doNavigation to true and continue to do navigation calls
565
+
566
+ const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
567
+ const {
568
+ entryLinkDepth = 0,
569
+ fields,
570
+ linkDepth,
571
+ nodeOptions = {}
572
+ } = contentTypeMapping;
573
+
574
+ if (pathNode && pathNode.id) {
575
+ if (doNavigation === true || doNavigation.ancestors) {
576
+ apiCall[0] = function* getAncestors() {
577
+ try {
578
+ return yield cachedSearch.getAncestors({
579
+ id: pathNode.id,
580
+ language,
581
+ versionStatus
582
+ }, project);
583
+ } catch (ex) {
584
+ log.info('Problem fetching ancestors', ex);
585
+ return [];
586
+ }
587
+ };
588
+ }
589
+
590
+ const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
591
+
592
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
593
+ const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
594
+
595
+ apiCall[1] = function* getChildren() {
596
+ try {
597
+ return yield cachedSearch.getNode({
598
+ depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
599
+ path,
600
+ entryFields: childrenOptions.fields || fields || undefined,
601
+ entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
602
+ language,
603
+ versionStatus
604
+ }, project);
605
+ } catch (ex) {
606
+ log.info('Problem fetching children', ex);
607
+ return [];
608
+ }
609
+ };
610
+ }
611
+
612
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
613
+ apiCall[2] = function* getSiblings() {
614
+ try {
615
+ var _nodeOptions$siblings, _nodeOptions$siblings2;
616
+
617
+ return yield cachedSearch.getSiblings({
618
+ id: pathNode.id,
619
+ entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
620
+ 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,
621
+ includeInMenu: true,
622
+ language,
623
+ versionStatus
624
+ }, project);
625
+ } catch (ex) {
626
+ log.info('Problem fetching siblings', ex);
627
+ return [];
628
+ }
629
+ };
630
+ }
631
+ }
632
+
633
+ const isTreeLoaded = yield select(hasNavigationTree);
634
+ if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
635
+ if (typeof window !== 'undefined') {
636
+ return yield put({
637
+ type: GET_NODE_TREE,
638
+ treeDepth: doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree
639
+ });
640
+ } else {
641
+ return yield call(ensureNodeTreeSaga);
642
+ }
643
+ };
644
+ const [loadAncestors, loadChildren, loadSiblings, loadTree] = apiCall;
645
+ const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
646
+ return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
647
+ }
648
+
620
649
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
621
650
  const entrySys = entry && entry.sys || {};
622
651
  const currentEntryId = yield select(selectRouteEntryEntryId);
@@ -951,7 +980,7 @@ function* changePasswordSaga(action) {
951
980
  yield put({
952
981
  type: CHANGE_USER_PASSWORD_SENDING
953
982
  });
954
- const clientCredentials = yield select(selectClientCredentials);
983
+ const clientCredentials = yield select(selectClientCredentials, 'js');
955
984
  const client = yield getManagementApiClient({ ...clientCredentials
956
985
  });
957
986
  const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
@@ -1039,5 +1068,5 @@ const AppRoot = props => {
1039
1068
  return /*#__PURE__*/React.createElement(RouteLoader, props);
1040
1069
  };
1041
1070
 
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
1071
+ export { AppRoot as A, browserHistory as b, cachedSearch as c, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1072
+ //# sourceMappingURL=App-5efba16c.js.map