@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.3

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 (209) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +18 -478
  3. package/cjs/{App-b56aca04.js → App-BNcmM8rN.js} +215 -234
  4. package/cjs/App-BNcmM8rN.js.map +1 -0
  5. package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-642SYfpS.js} +209 -286
  6. package/cjs/ChangePassword.container-642SYfpS.js.map +1 -0
  7. package/cjs/CookieHelper.class-BoY5TrIi.js +562 -0
  8. package/cjs/CookieHelper.class-BoY5TrIi.js.map +1 -0
  9. package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-DvyYYyIE.js} +55 -68
  10. package/cjs/RouteLoader-DvyYYyIE.js.map +1 -0
  11. package/cjs/{ContensisDeliveryApi-4fcf049d.js → SSRContext-D66GKlH7.js} +165 -119
  12. package/cjs/SSRContext-D66GKlH7.js.map +1 -0
  13. package/cjs/{ToJs-a8d8f3f0.js → ToJs-C9jwV7YB.js} +26 -80
  14. package/cjs/ToJs-C9jwV7YB.js.map +1 -0
  15. package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
  16. package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
  17. package/cjs/client.js +67 -65
  18. package/cjs/client.js.map +1 -1
  19. package/cjs/contensis-react-base.js +386 -3293
  20. package/cjs/contensis-react-base.js.map +1 -1
  21. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
  22. package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
  23. package/cjs/redux.js +18 -19
  24. package/cjs/redux.js.map +1 -1
  25. package/cjs/routing.js +13 -6
  26. package/cjs/routing.js.map +1 -1
  27. package/cjs/sagas-CbZhaRNd.js +6010 -0
  28. package/cjs/sagas-CbZhaRNd.js.map +1 -0
  29. package/cjs/search.js +105 -305
  30. package/cjs/search.js.map +1 -1
  31. package/cjs/selectors-wCs5fHD4.js +460 -0
  32. package/cjs/selectors-wCs5fHD4.js.map +1 -0
  33. package/cjs/{version-34d91f68.js → store-CADDS7cV.js} +44 -111
  34. package/cjs/store-CADDS7cV.js.map +1 -0
  35. package/cjs/{urls-6fcaf4c6.js → urls-DVIwGZmd.js} +1 -1
  36. package/{esm/urls-eac9a747.js.map → cjs/urls-DVIwGZmd.js.map} +1 -1
  37. package/cjs/user.js +12 -20
  38. package/cjs/user.js.map +1 -1
  39. package/cjs/util.js +108 -115
  40. package/cjs/util.js.map +1 -1
  41. package/cjs/{version-a410c88e.js → version-ASZx0NDG.js} +19 -22
  42. package/{esm/version-9f29becb.js.map → cjs/version-ASZx0NDG.js.map} +1 -1
  43. package/cjs/version-CM-bJ62L.js +20 -0
  44. package/cjs/version-CM-bJ62L.js.map +1 -0
  45. package/esm/{App-83107d7e.js → App-CfIZbvU9.js} +176 -195
  46. package/esm/App-CfIZbvU9.js.map +1 -0
  47. package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-Q7bElOVz.js} +191 -250
  48. package/esm/ChangePassword.container-Q7bElOVz.js.map +1 -0
  49. package/esm/CookieHelper.class-DzleKOOc.js +555 -0
  50. package/esm/CookieHelper.class-DzleKOOc.js.map +1 -0
  51. package/esm/{RouteLoader-29fd689a.js → RouteLoader-qJA3UqTM.js} +40 -53
  52. package/esm/RouteLoader-qJA3UqTM.js.map +1 -0
  53. package/esm/{ContensisDeliveryApi-fe57a037.js → SSRContext-C743Oeli.js} +159 -120
  54. package/esm/SSRContext-C743Oeli.js.map +1 -0
  55. package/esm/{ToJs-df57f31d.js → ToJs-CpPNdcXS.js} +24 -77
  56. package/esm/ToJs-CpPNdcXS.js.map +1 -0
  57. package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
  58. package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
  59. package/esm/client.js +55 -53
  60. package/esm/client.js.map +1 -1
  61. package/esm/contensis-react-base.js +317 -3222
  62. package/esm/contensis-react-base.js.map +1 -1
  63. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
  64. package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
  65. package/esm/redux.js +9 -8
  66. package/esm/redux.js.map +1 -1
  67. package/esm/routing.js +13 -4
  68. package/esm/routing.js.map +1 -1
  69. package/esm/sagas-xJU-zOpn.js +5916 -0
  70. package/esm/sagas-xJU-zOpn.js.map +1 -0
  71. package/esm/search.js +113 -311
  72. package/esm/search.js.map +1 -1
  73. package/esm/selectors-CBdCY0u3.js +396 -0
  74. package/esm/selectors-CBdCY0u3.js.map +1 -0
  75. package/esm/{version-3d9911e2.js → store-uQZKjfA8.js} +36 -81
  76. package/esm/store-uQZKjfA8.js.map +1 -0
  77. package/esm/{urls-eac9a747.js → urls-DfCisos-.js} +1 -1
  78. package/{cjs/urls-6fcaf4c6.js.map → esm/urls-DfCisos-.js.map} +1 -1
  79. package/esm/user.js +7 -13
  80. package/esm/user.js.map +1 -1
  81. package/esm/util.js +66 -74
  82. package/esm/util.js.map +1 -1
  83. package/esm/{version-9f29becb.js → version-B9nPx4IF.js} +6 -9
  84. package/{cjs/version-a410c88e.js.map → esm/version-B9nPx4IF.js.map} +1 -1
  85. package/esm/version-D773TD9j.js +15 -0
  86. package/esm/version-D773TD9j.js.map +1 -0
  87. package/models/app/App.d.ts +1 -1
  88. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  89. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
  90. package/models/client/client.d.ts +1 -1
  91. package/models/index.d.ts +1 -2
  92. package/models/models/AppRouteProps.d.ts +11 -0
  93. package/models/models/ContentTypeMapping.d.ts +89 -0
  94. package/models/models/EntryMapper.d.ts +3 -0
  95. package/models/models/GetRouteActionArgs.d.ts +15 -0
  96. package/models/models/MatchedRoute.d.ts +4 -0
  97. package/models/models/ReduxInjector.d.ts +5 -0
  98. package/models/models/RequireLogin.d.ts +6 -0
  99. package/models/models/RouteComponent.d.ts +4 -0
  100. package/models/models/RouteComponentProps.d.ts +9 -0
  101. package/models/models/RouteLoaderProps.d.ts +9 -0
  102. package/models/models/RouteNode.d.ts +5 -0
  103. package/models/models/SSRContext.d.ts +11 -0
  104. package/models/models/StaticRoute.d.ts +60 -0
  105. package/models/models/WithEvents.d.ts +58 -0
  106. package/models/models/config/AppConfig.d.ts +12 -0
  107. package/models/{config.d.ts → models/config/ServerConfig.d.ts} +3 -12
  108. package/models/models/config/StateType.d.ts +1 -0
  109. package/models/models/config/index.d.ts +3 -0
  110. package/models/models/index.d.ts +16 -0
  111. package/models/redux/actions/index.d.ts +2 -2
  112. package/models/redux/sagas/navigation.d.ts +1 -3
  113. package/models/redux/selectors/index.d.ts +2 -2
  114. package/models/redux/store/injectors.d.ts +16 -4
  115. package/models/redux/store/store.d.ts +10 -4
  116. package/models/redux/types/index.d.ts +2 -2
  117. package/models/redux/types/navigation.d.ts +3 -3
  118. package/models/redux/types/version.d.ts +2 -2
  119. package/models/routing/components/Redirect.d.ts +1 -1
  120. package/models/routing/components/RouteLoader.d.ts +1 -1
  121. package/models/routing/components/StaticRouteLoader.d.ts +1 -1
  122. package/models/routing/components/Status.d.ts +1 -1
  123. package/models/routing/redux/actions.d.ts +3 -4
  124. package/models/routing/redux/selectors.d.ts +2 -2
  125. package/models/routing/redux/types.d.ts +11 -11
  126. package/models/routing/routes.d.ts +1 -1
  127. package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
  128. package/models/routing/util/queries.d.ts +2 -2
  129. package/models/search/models/Queries.d.ts +4 -2
  130. package/models/search/models/Search.d.ts +8 -1
  131. package/models/search/models/SearchActions.d.ts +3 -2
  132. package/models/search/models/SearchState.d.ts +5 -1
  133. package/models/search/redux/reducers.d.ts +2 -257
  134. package/models/search/redux/schema.d.ts +1 -1
  135. package/models/search/redux/selectors.d.ts +5 -5
  136. package/models/search/search/ContensisDeliveryApi.d.ts +2 -2
  137. package/models/search/search/ToJs.d.ts +1 -1
  138. package/models/search/search/expressions.d.ts +3 -3
  139. package/models/search/search/util.d.ts +17 -2
  140. package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
  141. package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
  142. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  143. package/models/server/features/static-assets/index.d.ts +1 -1
  144. package/models/server/internalServer.d.ts +1 -1
  145. package/models/server/util/bundles.d.ts +1 -1
  146. package/models/server/util/headers.d.ts +1 -1
  147. package/models/server/webApp.d.ts +1 -1
  148. package/models/user/components/Login.d.ts +1 -1
  149. package/models/user/components/LoginForm.d.ts +6 -6
  150. package/models/user/components/LogoutForm.d.ts +4 -4
  151. package/models/user/components.styled/Login.styled.d.ts +1 -1
  152. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  153. package/models/user/hocs/withLogin.d.ts +4 -4
  154. package/models/user/hooks/useLogin.d.ts +4 -4
  155. package/models/user/redux/actions.d.ts +7 -6
  156. package/models/user/redux/sagas/index.d.ts +1 -1
  157. package/models/user/redux/sagas/login.d.ts +5 -17
  158. package/models/user/redux/selectors.d.ts +1 -2
  159. package/models/user/redux/types.d.ts +21 -21
  160. package/models/user/state.d.ts +12 -0
  161. package/models/user/transformations/mapClientCredentials.d.ts +3 -1
  162. package/models/user/util/ContensisManagementApi.d.ts +10 -9
  163. package/models/user/util/CookieConstants.d.ts +1 -0
  164. package/models/user/util/CookieHelper.class.d.ts +8 -4
  165. package/models/user/util/LoginHelper.class.d.ts +25 -37
  166. package/models/user/util/OidcUserManager.d.ts +1 -1
  167. package/models/user/util/matchGroups.d.ts +1 -1
  168. package/models/util/CachedDeliveryApi.d.ts +11 -10
  169. package/models/util/ContensisDeliveryApi.d.ts +11 -7
  170. package/models/util/SSRContext.d.ts +29 -0
  171. package/models/util/index.d.ts +1 -0
  172. package/models/util/json-mapper.d.ts +4 -5
  173. package/package.json +71 -92
  174. package/cjs/App-b56aca04.js.map +0 -1
  175. package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
  176. package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
  177. package/cjs/CookieConstants-000427db.js +0 -10
  178. package/cjs/CookieConstants-000427db.js.map +0 -1
  179. package/cjs/RouteLoader-c06dccd5.js.map +0 -1
  180. package/cjs/ToJs-a8d8f3f0.js.map +0 -1
  181. package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
  182. package/cjs/forms.js +0 -5998
  183. package/cjs/forms.js.map +0 -1
  184. package/cjs/reducers-73a03ef4.js +0 -257
  185. package/cjs/reducers-73a03ef4.js.map +0 -1
  186. package/cjs/sagas-570f23ba.js +0 -2175
  187. package/cjs/sagas-570f23ba.js.map +0 -1
  188. package/cjs/selectors-14caa813.js +0 -228
  189. package/cjs/selectors-14caa813.js.map +0 -1
  190. package/cjs/version-34d91f68.js.map +0 -1
  191. package/esm/App-83107d7e.js.map +0 -1
  192. package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
  193. package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
  194. package/esm/CookieConstants-3d3b6531.js +0 -6
  195. package/esm/CookieConstants-3d3b6531.js.map +0 -1
  196. package/esm/RouteLoader-29fd689a.js.map +0 -1
  197. package/esm/ToJs-df57f31d.js.map +0 -1
  198. package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
  199. package/esm/forms.js +0 -5984
  200. package/esm/forms.js.map +0 -1
  201. package/esm/reducers-aa8cef1e.js +0 -234
  202. package/esm/reducers-aa8cef1e.js.map +0 -1
  203. package/esm/sagas-07e82e18.js +0 -2083
  204. package/esm/sagas-07e82e18.js.map +0 -1
  205. package/esm/selectors-691caf02.js +0 -186
  206. package/esm/selectors-691caf02.js.map +0 -1
  207. package/esm/version-3d9911e2.js.map +0 -1
  208. package/models/forms/index.d.ts +0 -1
  209. /package/models/{redux/appstate.d.ts → models/AppState.d.ts} +0 -0
@@ -1,26 +1,25 @@
1
1
  'use strict';
2
2
 
3
- var require$$1 = require('history');
3
+ var history$1 = require('history');
4
4
  var effects = require('@redux-saga/core/effects');
5
5
  var log = require('loglevel');
6
- var ContensisDeliveryApi = require('./ContensisDeliveryApi-4fcf049d.js');
7
- var version = require('./version-34d91f68.js');
8
- var version$1 = require('./version-a410c88e.js');
9
- var selectors = require('./selectors-14caa813.js');
6
+ var store = require('./store-CADDS7cV.js');
7
+ var version = require('./version-ASZx0NDG.js');
10
8
  var to = require('await-to-js');
11
- var ChangePassword_container = require('./ChangePassword.container-ae35785e.js');
9
+ var selectors = require('./selectors-wCs5fHD4.js');
10
+ var version$1 = require('./version-CM-bJ62L.js');
11
+ var ChangePassword_container = require('./ChangePassword.container-642SYfpS.js');
12
12
  var React = require('react');
13
13
  require('react-cookie');
14
14
  require('react-redux');
15
15
  require('jsonpath-mapper');
16
- var reducers = require('./reducers-73a03ef4.js');
17
16
  var contensisDeliveryApi = require('contensis-delivery-api');
18
- var ToJs = require('./ToJs-a8d8f3f0.js');
17
+ var ToJs = require('./ToJs-C9jwV7YB.js');
19
18
  require('query-string');
20
19
  require('react-router-dom');
21
- var RouteLoader = require('./RouteLoader-c06dccd5.js');
20
+ var RouteLoader = require('./RouteLoader-DvyYYyIE.js');
22
21
 
23
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
23
 
25
24
  function _interopNamespace(e) {
26
25
  if (e && e.__esModule) return e;
@@ -36,69 +35,60 @@ function _interopNamespace(e) {
36
35
  }
37
36
  });
38
37
  }
39
- n["default"] = e;
38
+ n.default = e;
40
39
  return Object.freeze(n);
41
40
  }
42
41
 
43
42
  var log__namespace = /*#__PURE__*/_interopNamespace(log);
44
- var to__default = /*#__PURE__*/_interopDefaultLegacy(to);
45
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
+ var to__default = /*#__PURE__*/_interopDefault(to);
44
+ var React__default = /*#__PURE__*/_interopDefault(React);
46
45
 
47
- const selectedHistory = typeof window !== 'undefined' ? require$$1.createBrowserHistory : require$$1.createMemoryHistory;
46
+ // Create a history depending on the environment
47
+ const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
48
48
  const history = (options = {}) => selectedHistory(options);
49
49
  const browserHistory = selectedHistory();
50
50
 
51
- const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
51
+ const navigationSagas = [effects.takeEvery(store.GET_NODE_TREE, ensureNodeTreeSaga)];
52
52
  function* ensureNodeTreeSaga(action) {
53
+ const {
54
+ api,
55
+ language,
56
+ project,
57
+ versionStatus,
58
+ treeDepth
59
+ } = action;
53
60
  const state = yield effects.select();
54
-
55
61
  try {
56
- if (!version$1.hasNavigationTree(state)) {
57
- const deliveryApiVersionStatus = yield effects.select(version.selectVersionStatus);
58
- const project = yield effects.select(selectors.selectCurrentProject);
59
- const nodes = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
60
- depth: action.treeDepth || 0,
61
- language: action.language
62
- });
63
-
62
+ if (!version.hasNavigationTree(state)) {
63
+ const nodes = yield api.getRootNode({
64
+ depth: treeDepth || 0,
65
+ language
66
+ }, versionStatus, project);
64
67
  if (nodes) {
65
68
  yield effects.put({
66
- type: version.SET_NODE_TREE,
69
+ type: store.SET_NODE_TREE,
67
70
  nodes
68
71
  });
69
72
  } else {
70
73
  yield effects.put({
71
- type: version.GET_NODE_TREE_ERROR
74
+ type: store.GET_NODE_TREE_ERROR
72
75
  });
73
76
  }
74
77
  }
75
78
  } catch (ex) {
76
79
  log__namespace.error(...['Error running ensureNodeTreeSaga:', ex]);
77
80
  yield effects.put({
78
- type: version.GET_NODE_TREE_ERROR,
81
+ type: store.GET_NODE_TREE_ERROR,
79
82
  error: ex.toString()
80
83
  });
81
84
  }
82
85
  }
83
86
 
84
87
  const sys = {
85
- contentTypeId: 'sys.contentTypeId',
86
- dataFormat: 'sys.dataFormat',
87
- filename: 'sys.properties.filename',
88
- id: 'sys.id',
89
- includeInSearch: 'sys.metadata.includeInSearch',
90
- slug: 'sys.slug',
91
- uri: 'sys.uri',
92
88
  versionStatus: 'sys.versionStatus'
93
89
  };
94
90
  const Fields = {
95
- entryTitle: 'entryTitle',
96
- entryDescription: 'entryDescription',
97
- keywords: 'keywords',
98
- sys,
99
- contentTypeId: 'sys.contentTypeId',
100
- wildcard: '*'
101
- };
91
+ sys};
102
92
 
103
93
  const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
104
94
  if (!field || !value) return [];
@@ -107,21 +97,21 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
107
97
  const defaultExpressions = versionStatus => {
108
98
  return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
109
99
  };
110
-
111
100
  const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
112
101
 
113
- const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
114
- const query = new contensisDeliveryApi.Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...defaultExpressions(versionStatus)]);
102
+ const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fields = [], fieldLinkDepths, versionStatus = 'published') => {
103
+ const query = new contensisDeliveryApi.Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...(contentTypeId ? fieldExpression('sys.contentTypeId', contentTypeId) : fieldExpression('sys.dataFormat', 'entry')), ...defaultExpressions(versionStatus)]);
115
104
  query.fields = fields;
105
+ query.fieldLinkDepths = fieldLinkDepths;
116
106
  return query;
117
107
  };
118
108
 
119
109
  const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
110
+
120
111
  /**
121
112
  * To navigate / push a specific route via redux middleware
122
113
  * @param {path, state} action
123
114
  */
124
-
125
115
  function* setRouteSaga(action) {
126
116
  yield effects.put({
127
117
  type: 'CALL_HISTORY_METHOD',
@@ -131,87 +121,97 @@ function* setRouteSaga(action) {
131
121
  }
132
122
  });
133
123
  }
134
-
135
124
  function* getRouteSaga(action) {
136
125
  let entry = null;
137
-
138
126
  try {
139
- var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
140
-
127
+ var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
141
128
  const {
142
129
  withEvents,
143
130
  routes: {
144
131
  ContentTypeMappings = {}
145
132
  } = {},
146
133
  staticRoute,
147
- cookies
134
+ // get api instance from ssr context that is connected to the specific request in ssr
135
+ ssr: {
136
+ api
137
+ }
148
138
  } = action;
149
- const api = ContensisDeliveryApi.cachedSearchWithCookies(cookies.raw); // Inject redux { key, reducer, saga } provided by staticRoute
150
139
 
151
- if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux); // Variables we will pass to setRouteEntry
140
+ // Inject redux { key, reducer, saga } provided by staticRoute
141
+ if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux);
152
142
 
143
+ // Variables we will pass to setRouteEntry
153
144
  let pathNode = null,
154
- ancestors = null,
155
- children = [],
156
- siblings = null;
157
- let contentTypeMapping = {}; // These variables are the return values from
158
- // calls to withEvents.onRouteLoad and onRouteLoaded
145
+ ancestors = null,
146
+ children = [],
147
+ siblings = null;
148
+ let contentTypeMapping = {};
159
149
 
150
+ // These variables are the return values from
151
+ // calls to withEvents.onRouteLoad and onRouteLoaded
160
152
  let appsays,
161
- requireLogin = false;
162
-
153
+ requireLogin = false;
163
154
  if (withEvents && withEvents.onRouteLoad) {
164
155
  appsays = yield withEvents.onRouteLoad(action);
165
156
  }
166
157
 
167
- const staticRouteLinkDepth = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 ? void 0 : (_staticRoute$route$pa = _staticRoute$route.params) === null || _staticRoute$route$pa === void 0 ? void 0 : _staticRoute$route$pa.linkDepth;
168
- const staticRouteFields = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 ? void 0 : (_staticRoute$route2$p = _staticRoute$route2.params) === null || _staticRoute$route2$p === void 0 ? void 0 : _staticRoute$route2$p.fields;
158
+ // We could improve this further with a reusable mapper
159
+ // function to return these params given a static route
160
+ // or matching a content type mapping we could call at various points
161
+ // enabling us to mix and match and prioritise inputs if there are multiple
162
+ let linkDepth = staticRoute === null || staticRoute === void 0 || (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 || (_staticRoute$route = _staticRoute$route.fetchNode) === null || _staticRoute$route === void 0 ? void 0 : _staticRoute$route.linkDepth;
163
+ let fields = staticRoute === null || staticRoute === void 0 || (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 || (_staticRoute$route2 = _staticRoute$route2.fetchNode) === null || _staticRoute$route2 === void 0 ? void 0 : _staticRoute$route2.fields;
164
+ let fieldLinkDepths = staticRoute === null || staticRoute === void 0 || (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 || (_staticRoute$route3 = _staticRoute$route3.fetchNode) === null || _staticRoute$route3 === void 0 ? void 0 : _staticRoute$route3.fieldLinkDepths;
165
+ let entryMapper = staticRoute === null || staticRoute === void 0 || (_staticRoute$route4 = staticRoute.route) === null || _staticRoute$route4 === void 0 || (_staticRoute$route4 = _staticRoute$route4.fetchNode) === null || _staticRoute$route4 === void 0 ? void 0 : _staticRoute$route4.entryMapper;
169
166
  const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
170
- const setContentTypeLimits = (typeof staticRouteLinkDepth === 'undefined' || !staticRouteFields) && !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions);
167
+ const entryFieldLinkDepths = (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.entryFieldLinkDepths;
168
+ const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
169
+ const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
171
170
  const state = yield effects.select();
172
171
  const routeEntry = selectors.selectRouteEntry(state, 'js');
173
172
  const routeNode = selectors.selectCurrentNode(state, 'js');
174
173
  const currentPath = action.path; //selectCurrentPath(state);
175
-
176
- const deliveryApiStatus = version.selectVersionStatus(state);
177
- const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
178
-
174
+ const deliveryApiStatus = version$1.selectVersionStatus(state);
175
+ const project = selectors.selectCurrentProject(state);
176
+ // const isHome = currentPath === '/';
179
177
  const isPreview = currentPath && currentPath.startsWith('/preview/');
180
178
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
181
-
182
- if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
179
+ if (!isPreview && ((_appsays2 = appsays) !== null && _appsays2 !== void 0 && _appsays2.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && ((_appsays3 = appsays) === null || _appsays3 === void 0 ? void 0 : _appsays3.refetchNode) !== true)) {
180
+ var _staticRoute$route5;
183
181
  // To prevent erroneous 404s and wasted network calls, this covers
184
182
  // - appsays customRouting and does SET_ENTRY etc. via the consuming app
185
183
  // - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
186
184
  // - standard Contensis SiteView Routing where we already have that entry in state
187
- if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
188
- pathNode = { ...routeNode,
185
+ if (routeEntry && (!staticRoute || staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route5 = staticRoute.route) !== null && _staticRoute$route5 !== void 0 && _staticRoute$route5.fetchNode)) {
186
+ pathNode = {
187
+ ...routeNode,
189
188
  entry: null
190
189
  };
191
- pathNode.entry = entry = routeEntry; //Do nothing, the entry is allready the right one.
190
+ pathNode.entry = entry = routeEntry;
191
+ //Do nothing, the entry is allready the right one.
192
192
  // yield put({
193
193
  // type: SET_ENTRY,
194
194
  // entry,
195
195
  // node: routeNode,
196
196
  // isLoading: false,
197
197
  // });
198
-
199
198
  yield effects.put({
200
199
  type: selectors.UPDATE_LOADING_STATE,
201
200
  isLoading: false
202
201
  });
203
202
  } else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
204
203
  } else {
204
+ var _staticRoute$route6;
205
205
  // Handle preview routes
206
206
  if (isPreview) {
207
207
  let splitPath = currentPath.split('/');
208
208
  let entryGuid = splitPath[2];
209
209
  let language = defaultLang;
210
-
211
210
  if (splitPath.length >= 3) {
212
211
  //set lang key if available in the path, else use default lang
213
212
  //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
214
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
213
+ if (splitPath.length == 4) language = splitPath[3];
214
+ // According to product dev we cannot use Node API
215
215
  // for previewing entries as it gives a response of []
216
216
  // -- apparently it is not correct to request latest content
217
217
  // with Node API
@@ -221,7 +221,6 @@ function* getRouteSaga(action) {
221
221
  language,
222
222
  linkDepth: entryLinkDepth
223
223
  });
224
-
225
224
  if (previewEntry) {
226
225
  pathNode = {
227
226
  entry: previewEntry
@@ -232,29 +231,30 @@ function* getRouteSaga(action) {
232
231
  }
233
232
  }
234
233
  } else {
235
- var _pathNode, _pathNode$entry, _pathNode$entry$sys;
236
-
234
+ var _pathNode, _pathNode2;
237
235
  // Handle all other routes
238
236
  let nodeError = undefined;
239
- [nodeError, pathNode] = yield to__default["default"](api.getNode({
237
+ // Resolve a stub of route node if we are setting limits in content type mappings
238
+ // Resolve the complete entry with the node if we are setting limits in a static route
239
+ [nodeError, pathNode] = yield to__default.default(api.getNode({
240
240
  depth: 0,
241
241
  path: currentPath,
242
- entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : staticRouteFields || '*',
243
- entryLinkDepth: setContentTypeLimits ? 0 : typeof staticRouteLinkDepth !== 'undefined' ? staticRouteLinkDepth : entryLinkDepth,
242
+ entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
243
+ entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
244
+ entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
244
245
  language: defaultLang,
245
246
  versionStatus: deliveryApiStatus
246
247
  }, project));
247
-
248
248
  if (nodeError) {
249
249
  if ([401, 403].includes(nodeError.status)) {
250
250
  // Capture specific auth errors with the delivery api
251
251
  // and fire the user down the handleRequiresLoginSaga
252
252
  // If auth was successful via a refreshToken we need to reload the page
253
253
  // to run this getRouteSaga again with the security token cookie
254
- const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, { ...action,
254
+ const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
255
+ ...action,
255
256
  requireLogin: true
256
257
  });
257
-
258
258
  if (userLoggedIn && nodeError.status === 401) {
259
259
  // Reload the route so we can re-run the routing request now the
260
260
  // authentication cookies are written
@@ -273,31 +273,41 @@ function* getRouteSaga(action) {
273
273
  entry
274
274
  } = pathNode || {});
275
275
 
276
- 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) {
277
- var _payload$items;
278
-
276
+ // Try resolve a content type mapping
277
+ if ((_pathNode = pathNode) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.entry) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.sys) !== null && _pathNode !== void 0 && _pathNode.id && pathNode.entry.sys.contentTypeId) {
279
278
  // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
280
279
  // and current node's ordinates at a specified depth with specified fields
281
- contentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
282
- const {
280
+ contentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId);
281
+ }
282
+
283
+ // Run a second search query if we aren't setting limits from a static route
284
+ // but we are setting limits from a content type mapping, now we have a handle
285
+ // on a contentTypeId from the resolve node, we can apply the right limits when
286
+ // fetching the entry
287
+ if (!setStaticRouteLimits && setContentTypeLimits && (_pathNode2 = pathNode) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.entry) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.sys) !== null && _pathNode2 !== void 0 && _pathNode2.id) {
288
+ var _payload$items;
289
+ // Now we have a handle on a content type mapping we can
290
+ // reassign the query limiting variables if we haven't
291
+ // already set them in a static route
292
+ if (!setStaticRouteLimits) ({
293
+ fieldLinkDepths,
283
294
  fields,
284
295
  linkDepth
285
- } = contentTypeMapping;
286
- const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
296
+ } = contentTypeMapping || {});
297
+ const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, pathNode.entry.sys.contentTypeId, fields, fieldLinkDepths, deliveryApiStatus);
287
298
  const payload = yield api.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
288
-
289
- if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
299
+ if ((payload === null || payload === void 0 || (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
290
300
  pathNode.entry = entry = payload.items[0];
291
301
  }
292
302
  }
293
- } // make calls to fetch node ancestors, children,
294
- // siblings or entire node tree
295
-
303
+ }
296
304
 
305
+ // make calls to fetch node ancestors, children,
306
+ // siblings or entire node tree
297
307
  [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
298
308
  api,
299
309
  appsays,
300
- contentTypeMapping,
310
+ contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
301
311
  language: defaultLang,
302
312
  path: currentPath,
303
313
  pathNode,
@@ -306,39 +316,36 @@ function* getRouteSaga(action) {
306
316
  });
307
317
  if (children) pathNode.children = children;
308
318
  }
319
+ const resolvedContentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, (_pathNode3 = pathNode) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.entry) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.sys) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.contentTypeId) || {};
309
320
 
310
- const resolvedContentTypeMapping = ChangePassword_container.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
311
-
321
+ // Inject redux { key, reducer, saga } provided by ContentTypeMapping
312
322
  if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
313
-
314
323
  if (withEvents && withEvents.onRouteLoaded) {
315
324
  // Check if the app has provided a requireLogin boolean flag or groups array
316
325
  // in addition to checking if requireLogin is set in the route definition
317
326
  ({
318
327
  requireLogin
319
- } = (yield withEvents.onRouteLoaded({ ...action,
328
+ } = (yield withEvents.onRouteLoaded({
329
+ ...action,
320
330
  entry
321
331
  })) || {});
322
332
  }
323
-
324
333
  if (requireLogin !== false) {
325
334
  // Do not call the login feature saga if requireLogin is false
326
- yield effects.call(ChangePassword_container.handleRequiresLoginSaga, { ...action,
335
+ yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
336
+ ...action,
327
337
  entry,
328
338
  requireLogin
329
339
  });
330
340
  }
331
-
332
341
  if (!appsays || !appsays.preventScrollTop) {
333
342
  // Scroll into View
334
343
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
335
344
  }
336
-
337
- 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) {
338
- var _staticRoute$route3, _staticRoute$route3$f, _appsays;
339
-
345
+ if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
346
+ var _appsays4;
340
347
  entry = pathNode.entry;
341
- yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
348
+ yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || resolvedContentTypeMapping.entryMapper, false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
342
349
  } else {
343
350
  if (staticRoute) yield effects.call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield effects.call(do404);
344
351
  }
@@ -347,29 +354,30 @@ function* getRouteSaga(action) {
347
354
  yield effects.call(do500, e);
348
355
  }
349
356
  }
350
-
351
- function* resolveCurrentNodeOrdinates({
352
- api,
353
- appsays,
354
- contentTypeMapping,
355
- language,
356
- path,
357
- pathNode,
358
- project,
359
- versionStatus
360
- }) {
361
- const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
357
+ function* resolveCurrentNodeOrdinates(action) {
358
+ const {
359
+ api,
360
+ appsays,
361
+ contentTypeMapping,
362
+ language,
363
+ path,
364
+ pathNode,
365
+ project,
366
+ versionStatus
367
+ } = action;
368
+ const apiCall = [() => null, () => null, () => null, () => null];
369
+
370
+ // if appsays customNavigation: true, we will set doNavigation to false
362
371
  // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
363
372
  // if appsays nothing we will set doNavigation to true and continue to do navigation calls
364
-
365
373
  const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
366
374
  const {
367
375
  entryLinkDepth = 0,
376
+ fieldLinkDepths,
368
377
  fields,
369
378
  linkDepth,
370
379
  nodeOptions = {}
371
380
  } = contentTypeMapping;
372
-
373
381
  if (pathNode && pathNode.id) {
374
382
  if (doNavigation === true || doNavigation.ancestors) {
375
383
  apiCall[0] = function* getAncestors() {
@@ -385,17 +393,15 @@ function* resolveCurrentNodeOrdinates({
385
393
  }
386
394
  };
387
395
  }
388
-
389
396
  const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
390
-
391
397
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
392
- const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
393
-
398
+ const childrenOptions = !nodeOptions.children || typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
394
399
  apiCall[1] = function* getChildren() {
395
400
  try {
396
401
  return yield api.getNode({
397
402
  depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
398
403
  path,
404
+ entryFieldLinkDepths: childrenOptions.fieldLinkDepths || fieldLinkDepths,
399
405
  entryFields: childrenOptions.fields || fields || undefined,
400
406
  entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
401
407
  language,
@@ -407,16 +413,15 @@ function* resolveCurrentNodeOrdinates({
407
413
  }
408
414
  };
409
415
  }
410
-
411
416
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
412
417
  apiCall[2] = function* getSiblings() {
413
418
  try {
414
- var _nodeOptions$siblings, _nodeOptions$siblings2;
415
-
419
+ var _nodeOptions$siblings, _nodeOptions$siblings2, _nodeOptions$siblings3;
416
420
  return yield api.getSiblings({
417
421
  id: pathNode.id,
418
- entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
419
- 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,
422
+ entryFieldLinkDepths: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fieldLinkDepths) || fieldLinkDepths,
423
+ entryFields: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.fields) || fields || undefined,
424
+ entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings3 = nodeOptions.siblings) === null || _nodeOptions$siblings3 === void 0 ? void 0 : _nodeOptions$siblings3.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
420
425
  includeInMenu: true,
421
426
  language,
422
427
  versionStatus
@@ -428,20 +433,18 @@ function* resolveCurrentNodeOrdinates({
428
433
  };
429
434
  }
430
435
  }
431
-
432
- const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
436
+ const isTreeLoaded = yield effects.select(version.hasNavigationTree);
433
437
  if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
434
438
  const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
435
-
436
439
  if (typeof window !== 'undefined') {
437
440
  return yield effects.put({
438
- type: version.GET_NODE_TREE,
439
- language,
441
+ type: store.GET_NODE_TREE,
442
+ ...action,
440
443
  treeDepth
441
444
  });
442
445
  } else {
443
446
  return yield effects.call(ensureNodeTreeSaga, {
444
- language,
447
+ ...action,
445
448
  treeDepth
446
449
  });
447
450
  }
@@ -450,15 +453,16 @@ function* resolveCurrentNodeOrdinates({
450
453
  const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
451
454
  return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
452
455
  }
453
-
454
456
  function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
455
- const entrySys = entry && entry.sys || {}; // Update a window global to provide the preview toolbar
456
- // an updated entry id in client-side navigation
457
+ const entrySys = entry && entry.sys || {};
457
458
 
459
+ // Update a window global to provide the preview toolbar
460
+ // an updated entry id in client-side navigation
458
461
  if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
459
462
  const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
460
463
  const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
461
- const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, { ...node,
464
+ const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
465
+ ...node,
462
466
  entry,
463
467
  ancestors,
464
468
  siblings
@@ -479,7 +483,6 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
479
483
  siblings
480
484
  })]);
481
485
  }
482
-
483
486
  function* mapRouteEntry(entryMapper, node) {
484
487
  try {
485
488
  if (typeof entryMapper === 'function') {
@@ -489,11 +492,10 @@ function* mapRouteEntry(entryMapper, node) {
489
492
  }
490
493
  } catch (e) {
491
494
  log__namespace.error(...['Error running entryMapper:', e, e.stack]);
495
+ throw e;
492
496
  }
493
-
494
497
  return;
495
498
  }
496
-
497
499
  function* do404() {
498
500
  yield effects.call(clientReloadHitServer);
499
501
  yield effects.put({
@@ -503,17 +505,16 @@ function* do404() {
503
505
  notFound: true
504
506
  });
505
507
  }
506
-
507
508
  function* clientReloadHitServer() {
508
- const stateEntry = yield effects.select(selectors.selectRouteEntry); // If in client and there is a stateEntry.sys field reload the page,
509
+ const stateEntry = yield effects.select(selectors.selectRouteEntry);
510
+
511
+ // If in client and there is a stateEntry.sys field reload the page,
509
512
  // on the 2nd load stateEntry.sys should be null at this point,
510
513
  // we do not wish to reload again and get stuck in an infinite reloading loop
511
-
512
514
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
513
515
  window.location.reload();
514
516
  }
515
517
  }
516
-
517
518
  function* do500(error) {
518
519
  yield effects.put({
519
520
  type: selectors.SET_ENTRY,
@@ -525,7 +526,6 @@ function* do500(error) {
525
526
  statusCode: error && error.status ? error.status : 500
526
527
  });
527
528
  }
528
-
529
529
  function* reduxInjectorSaga(injectorFn) {
530
530
  if (typeof injectorFn === 'function') {
531
531
  const {
@@ -533,7 +533,7 @@ function* reduxInjectorSaga(injectorFn) {
533
533
  reducer,
534
534
  saga
535
535
  } = yield injectorFn();
536
- version$1.injectRedux({
536
+ version.injectRedux({
537
537
  key,
538
538
  reducer,
539
539
  saga
@@ -541,20 +541,19 @@ function* reduxInjectorSaga(injectorFn) {
541
541
  }
542
542
  }
543
543
 
544
- const registerSagas = [effects.takeEvery(reducers.REGISTER_USER, registerSaga), effects.takeEvery(reducers.REGISTER_USER_SUCCESS, redirectSaga)];
545
-
544
+ const registerSagas = [effects.takeEvery(selectors.REGISTER_USER, registerSaga), effects.takeEvery(selectors.REGISTER_USER_SUCCESS, redirectSaga)];
546
545
  function* registerSaga({
547
546
  user,
548
547
  mappers
549
548
  }) {
550
- let requestBody = user; // Allow use of request mapper to take a user object
549
+ let requestBody = user;
550
+ // Allow use of request mapper to take a user object
551
551
  // of any format and return the payload for the api request
552
-
553
552
  if (mappers && mappers.request && typeof mappers.request === 'function') {
554
553
  requestBody = yield mappers.request(user);
555
- } // Make POST call to register API
556
-
554
+ }
557
555
 
556
+ // Make POST call to register API
558
557
  const response = yield fetch('/account/register', {
559
558
  method: 'POST',
560
559
  headers: {
@@ -563,27 +562,24 @@ function* registerSaga({
563
562
  },
564
563
  body: JSON.stringify(requestBody)
565
564
  });
566
-
567
565
  if (response.ok) {
568
566
  let mappedResponse;
569
567
  const [, responseBody] = yield to.to(response.json());
570
-
571
568
  if (responseBody) {
572
569
  // Allow use of response mapper to convert the successful user object
573
570
  // from the api response body into a user object of any format
574
571
  if (mappers && mappers.response && typeof mappers.response === 'function') {
575
572
  mappedResponse = yield mappers.response(responseBody);
576
- } // Update user object with mappedResponse or responseBody
577
-
578
-
573
+ }
574
+ // Update user object with mappedResponse or responseBody
579
575
  yield effects.put({
580
- type: reducers.REGISTER_USER_SUCCESS,
576
+ type: selectors.REGISTER_USER_SUCCESS,
581
577
  user: mappedResponse || responseBody
582
578
  });
583
579
  } else {
584
580
  // OK response but unable to parse the response body
585
581
  yield effects.put({
586
- type: reducers.REGISTER_USER_FAILED,
582
+ type: selectors.REGISTER_USER_FAILED,
587
583
  error: {
588
584
  message: 'Unable to parse the created user from the register service response'
589
585
  }
@@ -594,25 +590,24 @@ function* registerSaga({
594
590
  // or status codes echoed from the responses received from
595
591
  // management api when registering the user
596
592
  const [, errorResponse] = yield to.to(response.json());
597
- const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
598
-
593
+ const error = errorResponse && errorResponse.error || errorResponse || {};
594
+ // Get something meaningful from the response if there is no message in the body
599
595
  if (!error.message) {
600
596
  error.message = `Registration service: ${response.statusText}`;
601
597
  error.status = response.status;
602
598
  }
603
-
604
599
  yield effects.put({
605
- type: reducers.REGISTER_USER_FAILED,
600
+ type: selectors.REGISTER_USER_FAILED,
606
601
  error
607
602
  });
608
603
  }
609
604
  }
610
-
611
605
  function* redirectSaga() {
612
606
  // Check if querystring contains a redirect_uri
613
607
  const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
614
- const redirectUri = currentQs.redirect_uri || currentQs.redirect; // We must use redux based navigation to preserve the registration state
608
+ const redirectUri = currentQs.redirect_uri || currentQs.redirect;
615
609
 
610
+ // We must use redux based navigation to preserve the registration state
616
611
  if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
617
612
  }
618
613
 
@@ -630,36 +625,36 @@ const BASE_OPTIONS = {
630
625
  };
631
626
  class UserHelper {
632
627
  static async GetUsersEnvironments(securityToken) {
633
- const options = { ...BASE_OPTIONS,
628
+ const options = {
629
+ ...BASE_OPTIONS,
634
630
  headers: {
635
631
  'x-security-token': securityToken
636
632
  }
637
633
  };
638
634
  return await UserHelper.get(USER_ENVS_URL, options);
639
635
  }
640
-
641
636
  static async ResendUserVerification(userEmail) {
642
- const options = { ...BASE_OPTIONS
637
+ const options = {
638
+ ...BASE_OPTIONS
643
639
  };
644
640
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
645
641
  }
646
-
647
642
  static async RequestPasswordReset(userEmailObject) {
648
- const options = { ...BASE_OPTIONS,
643
+ const options = {
644
+ ...BASE_OPTIONS,
649
645
  body: JSON.stringify(userEmailObject)
650
646
  };
651
647
  options.method = 'POST';
652
648
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
653
649
  }
654
-
655
650
  static async ResetPassword(resetPasswordObject) {
656
- const options = { ...BASE_OPTIONS,
651
+ const options = {
652
+ ...BASE_OPTIONS,
657
653
  body: JSON.stringify(resetPasswordObject)
658
654
  };
659
655
  options.method = 'POST';
660
656
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
661
657
  }
662
-
663
658
  static async get(url, options = BASE_OPTIONS) {
664
659
  try {
665
660
  const responseBody = await api(url, options);
@@ -672,9 +667,7 @@ class UserHelper {
672
667
  };
673
668
  }
674
669
  }
675
-
676
670
  }
677
-
678
671
  async function api(url, options) {
679
672
  return fetch(url, options).then(async response => {
680
673
  return response.json().then(data => data);
@@ -683,103 +676,96 @@ async function api(url, options) {
683
676
  });
684
677
  }
685
678
 
686
- const resetPasswordSagas = [effects.takeEvery(reducers.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(reducers.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(reducers.CHANGE_USER_PASSWORD, changePasswordSaga)];
687
-
679
+ const resetPasswordSagas = [effects.takeEvery(selectors.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors.CHANGE_USER_PASSWORD, changePasswordSaga)];
688
680
  function* requestPasswordResetSaga(action) {
689
681
  const userEmailObject = action.userEmailObject;
690
682
  yield effects.put({
691
- type: reducers.REQUEST_USER_PASSWORD_RESET_SENDING
683
+ type: selectors.REQUEST_USER_PASSWORD_RESET_SENDING
692
684
  });
693
-
694
685
  if (userEmailObject && userEmailObject.userEmail) {
695
686
  try {
696
687
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
697
-
698
688
  if (passwordResetRequestResponse) {
699
689
  if (!passwordResetRequestResponse.error) {
700
690
  yield effects.put({
701
- type: reducers.REQUEST_USER_PASSWORD_RESET_SUCCESS
691
+ type: selectors.REQUEST_USER_PASSWORD_RESET_SUCCESS
702
692
  });
703
693
  } else {
704
694
  yield effects.put({
705
- type: reducers.REQUEST_USER_PASSWORD_RESET_ERROR,
695
+ type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
706
696
  error: passwordResetRequestResponse.error.message
707
697
  });
708
698
  }
709
699
  } else {
710
700
  yield effects.put({
711
- type: reducers.REQUEST_USER_PASSWORD_RESET_ERROR,
701
+ type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
712
702
  error: 'No response from server'
713
703
  });
714
704
  }
715
705
  } catch (error) {
716
706
  yield effects.put({
717
- type: reducers.REQUEST_USER_PASSWORD_RESET_ERROR,
707
+ type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
718
708
  error: error && error.toString()
719
709
  });
720
710
  }
721
711
  } else {
722
712
  yield effects.put({
723
- type: reducers.REQUEST_USER_PASSWORD_RESET_ERROR,
713
+ type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
724
714
  error: 'Invalid object'
725
715
  });
726
716
  }
727
717
  }
728
-
729
718
  function* resetPasswordSaga(action) {
730
719
  const resetPasswordObject = action.resetPasswordObject;
731
720
  yield effects.put({
732
- type: reducers.RESET_USER_PASSWORD_SENDING
721
+ type: selectors.RESET_USER_PASSWORD_SENDING
733
722
  });
734
-
735
723
  if (resetPasswordObject.token && resetPasswordObject.password) {
736
724
  try {
737
725
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
738
-
739
726
  if (resetPasswordResponse) {
740
727
  if (!resetPasswordResponse.error) {
741
728
  yield effects.put({
742
- type: reducers.RESET_USER_PASSWORD_SUCCESS
729
+ type: selectors.RESET_USER_PASSWORD_SUCCESS
743
730
  });
744
731
  } else {
745
732
  const error = resetPasswordResponse.error.data && resetPasswordResponse.error.data.length > 0 && resetPasswordResponse.error.data[0].message || resetPasswordResponse.error.message;
746
733
  yield effects.put({
747
- type: reducers.RESET_USER_PASSWORD_ERROR,
734
+ type: selectors.RESET_USER_PASSWORD_ERROR,
748
735
  error
749
736
  });
750
737
  }
751
738
  } else {
752
739
  yield effects.put({
753
- type: reducers.RESET_USER_PASSWORD_ERROR,
740
+ type: selectors.RESET_USER_PASSWORD_ERROR,
754
741
  error: 'No response from server'
755
742
  });
756
743
  }
757
744
  } catch (error) {
758
745
  yield effects.put({
759
- type: reducers.RESET_USER_PASSWORD_ERROR,
746
+ type: selectors.RESET_USER_PASSWORD_ERROR,
760
747
  error: error && error.toString()
761
748
  });
762
749
  }
763
750
  } else {
764
751
  yield effects.put({
765
- type: reducers.RESET_USER_PASSWORD_ERROR,
752
+ type: selectors.RESET_USER_PASSWORD_ERROR,
766
753
  error: 'Invalid object'
767
754
  });
768
755
  }
769
- } // userId
756
+ }
757
+
758
+ // userId
770
759
  // existingPassword
771
760
  // newPassword
772
-
773
-
774
761
  function* changePasswordSaga(action) {
775
762
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
776
763
  yield effects.put({
777
- type: reducers.CHANGE_USER_PASSWORD_ERROR,
764
+ type: selectors.CHANGE_USER_PASSWORD_ERROR,
778
765
  error: 'Invalid action object sent to changePassword saga'
779
766
  });
780
767
  return;
781
768
  }
782
-
783
769
  try {
784
770
  const changePasswordObject = {
785
771
  userId: action.userId,
@@ -787,34 +773,33 @@ function* changePasswordSaga(action) {
787
773
  new: action.newPassword
788
774
  };
789
775
  yield effects.put({
790
- type: reducers.CHANGE_USER_PASSWORD_SENDING
776
+ type: selectors.CHANGE_USER_PASSWORD_SENDING
791
777
  });
792
778
  const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
793
- const client = yield ChangePassword_container.getManagementApiClient({ ...clientCredentials
779
+ const client = yield ChangePassword_container.getManagementApiClient({
780
+ ...clientCredentials
794
781
  });
795
782
  const [err, res] = yield to.to(client.security.users.updatePassword(changePasswordObject));
796
-
797
783
  if (err) {
798
- var _err$data, _err$data$data, _err$data2;
799
-
800
- const error = (err === null || err === void 0 ? void 0 : (_err$data = err.data) === null || _err$data === void 0 ? void 0 : (_err$data$data = _err$data.data) === null || _err$data$data === void 0 ? void 0 : _err$data$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 ? void 0 : (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
784
+ var _err$data, _err$data2;
785
+ const error = (err === null || err === void 0 || (_err$data = err.data) === null || _err$data === void 0 || (_err$data = _err$data.data) === null || _err$data === void 0 ? void 0 : _err$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 || (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
801
786
  yield effects.put({
802
- type: reducers.CHANGE_USER_PASSWORD_ERROR,
787
+ type: selectors.CHANGE_USER_PASSWORD_ERROR,
803
788
  error
804
789
  });
805
790
  return;
806
- } // // eslint-disable-next-line no-console
791
+ }
792
+
793
+ // // eslint-disable-next-line no-console
807
794
  // console.log(changePasswordObject);
808
795
  // // eslint-disable-next-line no-console
809
796
  // console.log(userCredentialsObject);
810
-
811
-
812
797
  yield effects.put({
813
- type: reducers.CHANGE_USER_PASSWORD_SUCCESS
798
+ type: selectors.CHANGE_USER_PASSWORD_SUCCESS
814
799
  });
815
800
  } catch (error) {
816
801
  yield effects.put({
817
- type: reducers.CHANGE_USER_PASSWORD_ERROR,
802
+ type: selectors.CHANGE_USER_PASSWORD_ERROR,
818
803
  error: error && error.toString()
819
804
  });
820
805
  }
@@ -830,35 +815,32 @@ function rootSaga (featureSagas = []) {
830
815
  };
831
816
  }
832
817
 
833
- const servers = SERVERS;
834
- /* global SERVERS */
835
-
818
+ const servers = SERVERS; /* global SERVERS */
836
819
  const alias = servers.alias.toLowerCase();
837
- const publicUri = PUBLIC_URI;
838
- /* global PUBLIC_URI */
820
+ const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
821
+ const projects = PROJECTS; /* global PROJECTS */
839
822
 
840
- const projects = PROJECTS;
841
- /* global PROJECTS */
842
823
  // return a projectId via the request hostname
843
-
844
824
  const pickProject = (hostname, query) => {
845
825
  // if localhost we can only infer via a querystring, and take your word for it
846
826
  if (hostname == 'localhost') {
847
827
  return query && query.p || projects[0].id;
848
- } // if hostname is the actual public uri we can return the first project from the list
849
-
828
+ }
850
829
 
830
+ // if hostname is the actual public uri we can return the first project from the list
851
831
  if (hostname == publicUri) {
852
832
  return projects[0].id;
853
833
  }
834
+ let project = 'unknown';
854
835
 
855
- let project = 'unknown'; // // go through all the defined projects
836
+ // // go through all the defined projects
856
837
  // Object.entries(projects).map(([, p]) => {
838
+ const p = projects[0];
857
839
 
858
- const p = projects[0]; // check if we're accessing via the project's public uri
859
-
860
- if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
840
+ // check if we're accessing via the project's public uri
841
+ if (hostname.includes(p.publicUri)) project = p.id;
861
842
 
843
+ // the url structure is different for website (we don't prefix)
862
844
  if (p.id.startsWith('website')) {
863
845
  // check for internal and external hostnames
864
846
  // we check live and preview distinctly so our rule does not clash with
@@ -867,14 +849,13 @@ const pickProject = (hostname, query) => {
867
849
  } else {
868
850
  // check for internal and external hostnames, prefixed with the projectId
869
851
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
870
- } // });
871
-
872
-
852
+ }
853
+ // });
873
854
  return project === 'unknown' ? p.id : project;
874
855
  };
875
856
 
876
857
  const AppRoot = props => {
877
- return /*#__PURE__*/React__default["default"].createElement(RouteLoader.RouteLoader, props);
858
+ return /*#__PURE__*/React__default.default.createElement(RouteLoader.RouteLoader, props);
878
859
  };
879
860
 
880
861
  exports.AppRoot = AppRoot;
@@ -882,4 +863,4 @@ exports.browserHistory = browserHistory;
882
863
  exports.history = history;
883
864
  exports.pickProject = pickProject;
884
865
  exports.rootSaga = rootSaga;
885
- //# sourceMappingURL=App-b56aca04.js.map
866
+ //# sourceMappingURL=App-BNcmM8rN.js.map