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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +1 -1
  2. package/cjs/{App-e3200f18.js → App-5a34ea98.js} +228 -181
  3. package/cjs/App-5a34ea98.js.map +1 -0
  4. package/cjs/{RouteLoader-df3de0cb.js → RouteLoader-2675e1c9.js} +31 -23
  5. package/cjs/RouteLoader-2675e1c9.js.map +1 -0
  6. package/cjs/{ToJs-697ace9f.js → ToJs-a9a8522b.js} +39 -34
  7. package/cjs/ToJs-a9a8522b.js.map +1 -0
  8. package/cjs/{actions-a24bf46e.js → actions-8dc9e8de.js} +5 -4
  9. package/cjs/actions-8dc9e8de.js.map +1 -0
  10. package/cjs/client.js +22 -44
  11. package/cjs/client.js.map +1 -1
  12. package/cjs/contensis-react-base.js +3955 -135
  13. package/cjs/contensis-react-base.js.map +1 -1
  14. package/cjs/forms.js +547 -580
  15. package/cjs/forms.js.map +1 -1
  16. package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
  17. package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
  18. package/cjs/{login-bc55ee33.js → login-6b9de6a1.js} +92 -55
  19. package/cjs/login-6b9de6a1.js.map +1 -0
  20. package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
  21. package/cjs/reducers-3a4f8971.js.map +1 -0
  22. package/cjs/redux.js +6 -5
  23. package/cjs/redux.js.map +1 -1
  24. package/cjs/routing.js +5 -4
  25. package/cjs/routing.js.map +1 -1
  26. package/cjs/sagas-594b5ecd.js +2090 -0
  27. package/cjs/sagas-594b5ecd.js.map +1 -0
  28. package/cjs/search.js +296 -1915
  29. package/cjs/search.js.map +1 -1
  30. package/cjs/{selectors-0ec95076.js → selectors-656da4b7.js} +8 -3
  31. package/cjs/selectors-656da4b7.js.map +1 -0
  32. package/cjs/setCachingHeaders-ee619bdf.js +12 -0
  33. package/cjs/setCachingHeaders-ee619bdf.js.map +1 -0
  34. package/cjs/user.js +21 -12
  35. package/cjs/user.js.map +1 -1
  36. package/cjs/util.js +17 -17
  37. package/cjs/util.js.map +1 -1
  38. package/cjs/{version-4f0f5fa6.js → version-330551f5.js} +34 -22
  39. package/cjs/version-330551f5.js.map +1 -0
  40. package/cjs/{version-be0c7b7a.js → version-eba6d09b.js} +2 -2
  41. package/{esm/version-ad2ec52c.js.map → cjs/version-eba6d09b.js.map} +1 -1
  42. package/esm/{App-f9e7d03b.js → App-a973f962.js} +228 -182
  43. package/esm/App-a973f962.js.map +1 -0
  44. package/esm/{RouteLoader-027215f2.js → RouteLoader-f607a134.js} +31 -23
  45. package/esm/RouteLoader-f607a134.js.map +1 -0
  46. package/esm/{ToJs-46761960.js → ToJs-4e02a04d.js} +38 -32
  47. package/esm/ToJs-4e02a04d.js.map +1 -0
  48. package/esm/{actions-b949ef5c.js → actions-180948dd.js} +5 -4
  49. package/esm/actions-180948dd.js.map +1 -0
  50. package/esm/client.js +24 -27
  51. package/esm/client.js.map +1 -1
  52. package/esm/contensis-react-base.js +3953 -134
  53. package/esm/contensis-react-base.js.map +1 -1
  54. package/esm/forms.js +547 -583
  55. package/esm/forms.js.map +1 -1
  56. package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
  57. package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
  58. package/esm/{login-6eab4c94.js → login-508cac0f.js} +92 -55
  59. package/esm/login-508cac0f.js.map +1 -0
  60. package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
  61. package/esm/reducers-8e5d6232.js.map +1 -0
  62. package/esm/redux.js +8 -7
  63. package/esm/redux.js.map +1 -1
  64. package/esm/routing.js +5 -4
  65. package/esm/routing.js.map +1 -1
  66. package/esm/sagas-1f2b2aa0.js +2000 -0
  67. package/esm/sagas-1f2b2aa0.js.map +1 -0
  68. package/esm/search.js +252 -1856
  69. package/esm/search.js.map +1 -1
  70. package/esm/{selectors-8fca7fb2.js → selectors-a5e5835b.js} +9 -6
  71. package/esm/selectors-a5e5835b.js.map +1 -0
  72. package/esm/setCachingHeaders-d49060e1.js +10 -0
  73. package/esm/setCachingHeaders-d49060e1.js.map +1 -0
  74. package/esm/user.js +23 -14
  75. package/esm/user.js.map +1 -1
  76. package/esm/util.js +17 -17
  77. package/esm/util.js.map +1 -1
  78. package/esm/{version-ad2ec52c.js → version-2485e2fb.js} +2 -2
  79. package/{cjs/version-be0c7b7a.js.map → esm/version-2485e2fb.js.map} +1 -1
  80. package/esm/{version-612d9ef0.js → version-c776a92b.js} +33 -22
  81. package/esm/version-c776a92b.js.map +1 -0
  82. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  83. package/models/forms/index.d.ts +3 -1
  84. package/models/index.d.ts +1 -0
  85. package/models/redux/appstate.d.ts +5 -10
  86. package/models/redux/sagas/navigation.d.ts +1 -1
  87. package/models/redux/selectors/navigation.d.ts +2 -1
  88. package/models/routing/components/RouteLoader.d.ts +2 -19
  89. package/models/routing/redux/actions.d.ts +1 -1
  90. package/models/routing/redux/selectors.d.ts +1 -1
  91. package/models/routing/routes.d.ts +9 -3
  92. package/models/routing/util/expressions.d.ts +3 -2
  93. package/models/routing/util/queries.d.ts +1 -1
  94. package/models/search/containers/withListing.d.ts +1 -1
  95. package/models/search/containers/withSearch.d.ts +1 -1
  96. package/models/search/hooks/useFacets.hook.d.ts +3 -0
  97. package/models/search/hooks/useListing.hook.d.ts +3 -0
  98. package/models/search/hooks/useMinilist.hook.d.ts +2 -9
  99. package/models/search/index.d.ts +6 -2
  100. package/models/search/models/Queries.d.ts +8 -5
  101. package/models/search/models/Search.d.ts +60 -28
  102. package/models/search/models/SearchActions.d.ts +9 -5
  103. package/models/search/models/SearchProps.d.ts +52 -7
  104. package/models/search/models/SearchState.d.ts +5 -1
  105. package/models/search/models/index.d.ts +3 -1
  106. package/models/search/redux/actions.d.ts +5 -2
  107. package/models/search/redux/reducers.d.ts +230 -314
  108. package/models/search/redux/sagas.d.ts +11 -7
  109. package/models/search/redux/selectors.d.ts +21 -24
  110. package/models/search/redux/util.d.ts +1 -0
  111. package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
  112. package/models/search/search/expressions.d.ts +5 -8
  113. package/models/search/{redux → search}/queries.d.ts +0 -0
  114. package/models/search/search/util.d.ts +14 -0
  115. package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
  116. package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
  117. package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
  118. package/models/search/transformations/index.d.ts +3 -0
  119. package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
  120. package/models/search/transformations/state-to-searchuri.d.ts +2 -13
  121. package/models/server/features/linkdepth-api/LinkDepthSearchService.d.ts +24 -0
  122. package/models/server/features/linkdepth-api/QueryLevelResults.d.ts +50 -0
  123. package/models/server/features/linkdepth-api/api.d.ts +12 -0
  124. package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
  125. package/models/server/features/linkdepth-api/search.d.ts +31 -0
  126. package/models/server/features/linkdepth-api/util.d.ts +11 -0
  127. package/models/server/middleware/bundleManipulation.d.ts +2 -1
  128. package/models/server/util/bundles.d.ts +17 -21
  129. package/models/server/util/getVersionInfo.d.ts +1 -0
  130. package/models/server/util/headers.d.ts +3 -2
  131. package/models/user/components/Login.d.ts +1 -2
  132. package/models/user/components/LoginForm.d.ts +1 -2
  133. package/models/user/hocs/withLogin.d.ts +4 -2
  134. package/models/user/hocs/withRegistration.d.ts +2 -0
  135. package/models/user/hooks/useLogin.d.ts +5 -3
  136. package/models/user/redux/reducers.d.ts +4 -5
  137. package/models/user/redux/sagas/login.d.ts +11 -8
  138. package/models/user/redux/selectors.d.ts +12 -6
  139. package/models/user/util/LoginHelper.class.d.ts +4 -3
  140. package/models/util/ContensisDeliveryApi.d.ts +4 -4
  141. package/models/util/json-mapper.d.ts +9 -3
  142. package/models/util/merge.d.ts +1 -0
  143. package/package.json +60 -55
  144. package/CHANGELOG.md +0 -293
  145. package/cjs/App-e3200f18.js.map +0 -1
  146. package/cjs/RouteLoader-df3de0cb.js.map +0 -1
  147. package/cjs/ToJs-697ace9f.js.map +0 -1
  148. package/cjs/actions-a24bf46e.js.map +0 -1
  149. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  150. package/cjs/login-bc55ee33.js.map +0 -1
  151. package/cjs/reducers-fde41d6b.js.map +0 -1
  152. package/cjs/selectors-0ec95076.js.map +0 -1
  153. package/cjs/version-4f0f5fa6.js.map +0 -1
  154. package/esm/App-f9e7d03b.js.map +0 -1
  155. package/esm/RouteLoader-027215f2.js.map +0 -1
  156. package/esm/ToJs-46761960.js.map +0 -1
  157. package/esm/actions-b949ef5c.js.map +0 -1
  158. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  159. package/esm/login-6eab4c94.js.map +0 -1
  160. package/esm/reducers-d6c0edb1.js.map +0 -1
  161. package/esm/selectors-8fca7fb2.js.map +0 -1
  162. package/esm/version-612d9ef0.js.map +0 -1
  163. package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
  164. package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
  165. package/models/server/features/caching/cacheHashing.d.ts +0 -1
  166. package/package-lock.json +0 -14093
@@ -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-b949ef5c.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-612d9ef0.js';
6
- import { s as selectVersionStatus } from './version-ad2ec52c.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-8fca7fb2.js';
8
3
  import * as log from 'loglevel';
9
- import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-6eab4c94.js';
4
+ import { Client, Op, Query } from 'contensis-delivery-api';
5
+ import { parse } from 'query-string';
6
+ 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-180948dd.js';
7
+ 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-c776a92b.js';
8
+ import { s as selectVersionStatus } from './version-2485e2fb.js';
9
+ 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-a5e5835b.js';
10
+ import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-508cac0f.js';
10
11
  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-46761960.js';
12
+ 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';
13
+ import { s as selectClientCredentials } from './ToJs-4e02a04d.js';
13
14
  import React from 'react';
14
15
  import 'react-hot-loader';
15
16
  import 'jsonpath-mapper';
16
- import 'query-string';
17
- import { R as RouteLoader } from './RouteLoader-027215f2.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-f607a134.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') {
@@ -58,7 +54,15 @@ const getClientConfig = project => {
58
54
  class DeliveryApi {
59
55
  constructor() {
60
56
  this.getClientSideVersionStatus = () => {
61
- if (typeof window != 'undefined') {
57
+ if (typeof window !== 'undefined') {
58
+ // Allow overriding versionStatus with the querystring
59
+ const {
60
+ versionStatus
61
+ } = parse(window.location.search);
62
+ if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
63
+
64
+ if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
65
+
62
66
  const currentHostname = window.location.hostname;
63
67
  return this.getVersionStatusFromHostname(currentHostname);
64
68
  }
@@ -66,6 +70,14 @@ class DeliveryApi {
66
70
  return null;
67
71
  };
68
72
 
73
+ this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
74
+
75
+ this.getVersionStatusFromHeaders = headers => {
76
+ const versionStatusHeader = headers['x-entry-versionstatus'];
77
+ if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
78
+ return null;
79
+ };
80
+
69
81
  this.getVersionStatusFromHostname = currentHostname => {
70
82
  if (currentHostname.indexOf('localhost') > -1) return 'latest';
71
83
 
@@ -211,6 +223,11 @@ class CachedSearch {
211
223
  return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
212
224
  }
213
225
 
226
+ searchUsingPost(query, linkDepth = 0, project = '', env) {
227
+ const client = Client.create(getClientConfig(project));
228
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
229
+ }
230
+
214
231
  get(id, linkDepth, versionStatus, project, env) {
215
232
  const client = Client.create(getClientConfig(project));
216
233
  client.clientConfig.versionStatus = versionStatus;
@@ -267,32 +284,14 @@ class CachedSearch {
267
284
  return this.cache.get(key);
268
285
  }
269
286
 
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
287
  }
293
288
 
294
289
  const cachedSearch = new CachedSearch();
295
290
 
291
+ const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
292
+ const history = (options = {}) => selectedHistory(options);
293
+ const browserHistory = selectedHistory();
294
+
296
295
  const navigationSagas = [takeEvery(GET_NODE_TREE, ensureNodeTreeSaga)];
297
296
  function* ensureNodeTreeSaga(action) {
298
297
  const state = yield select();
@@ -317,6 +316,7 @@ function* ensureNodeTreeSaga(action) {
317
316
  }
318
317
  }
319
318
  } catch (ex) {
319
+ log.error(...['Error running ensureNodeTreeSaga:', ex]);
320
320
  yield put({
321
321
  type: GET_NODE_TREE_ERROR,
322
322
  error: ex.toString()
@@ -379,7 +379,7 @@ function* getRouteSaga(action) {
379
379
  let entry = null;
380
380
 
381
381
  try {
382
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
382
+ var _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
383
383
 
384
384
  const {
385
385
  withEvents,
@@ -393,7 +393,9 @@ function* getRouteSaga(action) {
393
393
 
394
394
  let pathNode = null,
395
395
  ancestors = null,
396
- siblings = null; // These variables are the return values from
396
+ children = [],
397
+ siblings = null;
398
+ let contentTypeMapping = {}; // These variables are the return values from
397
399
  // calls to withEvents.onRouteLoad and onRouteLoaded
398
400
 
399
401
  let appsays,
@@ -401,13 +403,9 @@ function* getRouteSaga(action) {
401
403
 
402
404
  if (withEvents && withEvents.onRouteLoad) {
403
405
  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
-
406
+ }
408
407
 
409
- const doNavigation = !appsays || (appsays && appsays.customNavigation === true ? false : appsays && appsays.customNavigation || true);
410
- const entryLinkDepth = appsays && appsays.entryLinkDepth || 3;
408
+ const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
411
409
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
412
410
  const state = yield select();
413
411
  const routeEntry = selectRouteEntry(state, 'js');
@@ -415,8 +413,8 @@ function* getRouteSaga(action) {
415
413
  const currentPath = action.path; //selectCurrentPath(state);
416
414
 
417
415
  const deliveryApiStatus = selectVersionStatus(state);
418
- const project = selectCurrentProject(state);
419
- const isHome = currentPath === '/';
416
+ const project = selectCurrentProject(state); // const isHome = currentPath === '/';
417
+
420
418
  const isPreview = currentPath && currentPath.startsWith('/preview/');
421
419
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
422
420
 
@@ -441,130 +439,92 @@ function* getRouteSaga(action) {
441
439
  type: UPDATE_LOADING_STATE,
442
440
  isLoading: false
443
441
  });
444
- } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors));
442
+ } else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
445
443
  } else {
446
- // Handle homepage
447
- if (isHome) {
448
- pathNode = yield cachedSearch.getRootNode({
444
+ // Handle preview routes
445
+ if (isPreview) {
446
+ let splitPath = currentPath.split('/');
447
+ let entryGuid = splitPath[2];
448
+ let language = defaultLang;
449
+
450
+ if (splitPath.length >= 3) {
451
+ //set lang key if available in the path, else use default lang
452
+ //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
453
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
454
+ // for previewing entries as it gives a response of []
455
+ // -- apparently it is not correct to request latest content
456
+ // with Node API
457
+
458
+ let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
459
+ id: entryGuid,
460
+ language,
461
+ linkDepth: entryLinkDepth
462
+ });
463
+
464
+ if (previewEntry) {
465
+ pathNode = {
466
+ entry: previewEntry
467
+ };
468
+ ({
469
+ entry
470
+ } = pathNode || {});
471
+ }
472
+ }
473
+ } else {
474
+ var _pathNode, _pathNode$entry, _pathNode$entry$sys;
475
+
476
+ // Handle all other routes
477
+ pathNode = yield cachedSearch.getNode({
449
478
  depth: 0,
450
- entryFields: '*',
451
- entryLinkDepth,
479
+ path: currentPath,
480
+ entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
481
+ entryLinkDepth: setContentTypeLimits ? 0 : entryLinkDepth,
452
482
  language: defaultLang,
453
483
  versionStatus: deliveryApiStatus
454
484
  }, project);
455
485
  ({
456
486
  entry
457
487
  } = 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
488
 
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
- }
489
+ 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) {
490
+ var _payload$items;
491
+
492
+ // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
493
+ // and current node's ordinates at a specified depth with specified fields
494
+ contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
495
+ const {
496
+ fields,
497
+ linkDepth
498
+ } = contentTypeMapping;
499
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
500
+ const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
501
+
502
+ if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
503
+ pathNode.entry = entry = payload.items[0];
560
504
  }
561
505
  }
562
- }
506
+ } // make calls to fetch node ancestors, children,
507
+ // siblings or entire node tree
508
+
509
+
510
+ [ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
511
+ appsays,
512
+ contentTypeMapping,
513
+ language: defaultLang,
514
+ path: currentPath,
515
+ pathNode,
516
+ project,
517
+ versionStatus: deliveryApiStatus
518
+ });
519
+ if (children) pathNode.children = children;
563
520
  }
564
521
 
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
522
+ const {
523
+ entryMapper,
524
+ injectRedux
525
+ } = 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
526
 
567
- if (contentTypeMapping.injectRedux) yield call(reduxInjectorSaga, contentTypeMapping.injectRedux);
527
+ if (injectRedux) yield call(reduxInjectorSaga, injectRedux);
568
528
 
569
529
  if (withEvents && withEvents.onRouteLoaded) {
570
530
  // Check if the app has provided a requireLogin boolean flag or groups array
@@ -584,37 +544,123 @@ function* getRouteSaga(action) {
584
544
  });
585
545
  }
586
546
 
587
- if (pathNode && pathNode.entry && pathNode.entry.sys && pathNode.entry.sys.id) {
547
+ if (!appsays || !appsays.preventScrollTop) {
548
+ // Scroll into View
549
+ if (typeof window !== 'undefined') window.scrollTo(0, 0);
550
+ }
551
+
552
+ 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) {
553
+ var _appsays;
554
+
588
555
  entry = pathNode.entry;
589
- const {
590
- entryMapper
591
- } = contentTypeMapping;
592
- yield call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, appsays && appsays.refetchNode);
556
+ yield call(setRouteEntry, entry, pathNode, ancestors, siblings, entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
593
557
  } else {
594
558
  if (staticRoute) yield call(setRouteEntry, null, pathNode, ancestors, siblings);else yield call(do404);
595
559
  }
560
+ } catch (e) {
561
+ log.error(...['Error running route saga:', e, e.stack]);
562
+ yield call(do500, e);
563
+ }
564
+ }
596
565
 
597
- if (!appsays || !appsays.preventScrollTop) {
598
- // Scroll into View
599
- if (typeof window !== 'undefined') {
600
- window.scroll({
601
- top: 0
602
- });
603
- }
566
+ function* resolveCurrentNodeOrdinates({
567
+ appsays,
568
+ contentTypeMapping,
569
+ language,
570
+ path,
571
+ pathNode,
572
+ project,
573
+ versionStatus
574
+ }) {
575
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
576
+ // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
577
+ // if appsays nothing we will set doNavigation to true and continue to do navigation calls
578
+
579
+ const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
580
+ const {
581
+ entryLinkDepth = 0,
582
+ fields,
583
+ linkDepth,
584
+ nodeOptions = {}
585
+ } = contentTypeMapping;
586
+
587
+ if (pathNode && pathNode.id) {
588
+ if (doNavigation === true || doNavigation.ancestors) {
589
+ apiCall[0] = function* getAncestors() {
590
+ try {
591
+ return yield cachedSearch.getAncestors({
592
+ id: pathNode.id,
593
+ language,
594
+ versionStatus
595
+ }, project);
596
+ } catch (ex) {
597
+ log.info('Problem fetching ancestors', ex);
598
+ return [];
599
+ }
600
+ };
604
601
  }
605
602
 
606
- if (!hasNavigationTree(state) && (doNavigation === true || doNavigation.tree)) if (typeof window !== 'undefined') {
607
- yield put({
603
+ const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
604
+
605
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
606
+ const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
607
+
608
+ apiCall[1] = function* getChildren() {
609
+ try {
610
+ return yield cachedSearch.getNode({
611
+ depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
612
+ path,
613
+ entryFields: childrenOptions.fields || fields || undefined,
614
+ entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
615
+ language,
616
+ versionStatus
617
+ }, project);
618
+ } catch (ex) {
619
+ log.info('Problem fetching children', ex);
620
+ return [];
621
+ }
622
+ };
623
+ }
624
+
625
+ if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
626
+ apiCall[2] = function* getSiblings() {
627
+ try {
628
+ var _nodeOptions$siblings, _nodeOptions$siblings2;
629
+
630
+ return yield cachedSearch.getSiblings({
631
+ id: pathNode.id,
632
+ entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
633
+ 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,
634
+ includeInMenu: true,
635
+ language,
636
+ versionStatus
637
+ }, project);
638
+ } catch (ex) {
639
+ log.info('Problem fetching siblings', ex);
640
+ return [];
641
+ }
642
+ };
643
+ }
644
+ }
645
+
646
+ const isTreeLoaded = yield select(hasNavigationTree);
647
+ if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
648
+ const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
649
+
650
+ if (typeof window !== 'undefined') {
651
+ return yield put({
608
652
  type: GET_NODE_TREE,
609
- treeDepth: doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree
653
+ treeDepth
610
654
  });
611
655
  } else {
612
- yield call(ensureNodeTreeSaga);
656
+ return yield call(ensureNodeTreeSaga, {
657
+ treeDepth
658
+ });
613
659
  }
614
- } catch (e) {
615
- log.error(...['Error running route saga:', e, e.stack]);
616
- yield call(do500, e);
617
- }
660
+ };
661
+ const [loadAncestors, loadChildren, loadSiblings, loadTree] = apiCall;
662
+ const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
663
+ return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
618
664
  }
619
665
 
620
666
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
@@ -951,7 +997,7 @@ function* changePasswordSaga(action) {
951
997
  yield put({
952
998
  type: CHANGE_USER_PASSWORD_SENDING
953
999
  });
954
- const clientCredentials = yield select(selectClientCredentials);
1000
+ const clientCredentials = yield select(selectClientCredentials, 'js');
955
1001
  const client = yield getManagementApiClient({ ...clientCredentials
956
1002
  });
957
1003
  const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
@@ -1039,5 +1085,5 @@ const AppRoot = props => {
1039
1085
  return /*#__PURE__*/React.createElement(RouteLoader, props);
1040
1086
  };
1041
1087
 
1042
- export { AppRoot as A, browserHistory as b, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1043
- //# sourceMappingURL=App-f9e7d03b.js.map
1088
+ export { AppRoot as A, browserHistory as b, cachedSearch as c, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1089
+ //# sourceMappingURL=App-a973f962.js.map