@zengenti/contensis-react-base 3.0.2-beta.5 → 3.0.2-beta.6

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 (84) hide show
  1. package/cjs/{App-48706fde.js → App-2a7a16ad.js} +89 -133
  2. package/{esm/App-e058aa68.js.map → cjs/App-2a7a16ad.js.map} +1 -1
  3. package/cjs/{ContensisDeliveryApi-cfdefe17.js → ContensisDeliveryApi-de88df2a.js} +13 -66
  4. package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
  5. package/cjs/{RouteLoader-fcd1e4f1.js → RouteLoader-47d70a26.js} +22 -35
  6. package/{esm/RouteLoader-e46234cc.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
  7. package/cjs/{ToJs-d962c80f.js → ToJs-61c03582.js} +3 -4
  8. package/cjs/{ToJs-d962c80f.js.map → ToJs-61c03582.js.map} +1 -1
  9. package/cjs/client.js +11 -18
  10. package/cjs/client.js.map +1 -1
  11. package/cjs/contensis-react-base.js +113 -177
  12. package/cjs/contensis-react-base.js.map +1 -1
  13. package/cjs/forms.js +11 -153
  14. package/cjs/forms.js.map +1 -1
  15. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
  16. package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
  17. package/cjs/{login-dfcea036.js → login-2ea569cc.js} +59 -110
  18. package/cjs/{login-dfcea036.js.map → login-2ea569cc.js.map} +1 -1
  19. package/cjs/{reducers-73a03ef4.js → reducers-9afb5f89.js} +10 -31
  20. package/{esm/reducers-aa8cef1e.js.map → cjs/reducers-9afb5f89.js.map} +1 -1
  21. package/cjs/redux.js +5 -4
  22. package/cjs/redux.js.map +1 -1
  23. package/cjs/routing.js +3 -3
  24. package/cjs/{sagas-8a20e424.js → sagas-6d12e7ca.js} +182 -282
  25. package/{esm/sagas-e576b6f6.js.map → cjs/sagas-6d12e7ca.js.map} +1 -1
  26. package/cjs/search.js +56 -82
  27. package/cjs/search.js.map +1 -1
  28. package/cjs/{selectors-fa607198.js → selectors-c76c2676.js} +1 -6
  29. package/cjs/selectors-c76c2676.js.map +1 -0
  30. package/cjs/urls-6fcaf4c6.js.map +1 -1
  31. package/cjs/user.js +4 -12
  32. package/cjs/user.js.map +1 -1
  33. package/cjs/util.js +35 -55
  34. package/cjs/util.js.map +1 -1
  35. package/cjs/{version-7ce96442.js → version-38afaf2a.js} +24 -58
  36. package/{esm/version-03d555b7.js.map → cjs/version-38afaf2a.js.map} +1 -1
  37. package/cjs/{version-d6e26cc4.js → version-886f49d8.js} +3 -6
  38. package/cjs/{version-d6e26cc4.js.map → version-886f49d8.js.map} +1 -1
  39. package/esm/{App-e058aa68.js → App-4fb1fc44.js} +89 -133
  40. package/{cjs/App-48706fde.js.map → esm/App-4fb1fc44.js.map} +1 -1
  41. package/esm/{ContensisDeliveryApi-8abcf222.js → ContensisDeliveryApi-ad06857d.js} +13 -66
  42. package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
  43. package/esm/{RouteLoader-e46234cc.js → RouteLoader-f5d5f733.js} +22 -35
  44. package/{cjs/RouteLoader-fcd1e4f1.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
  45. package/esm/{ToJs-502f7a11.js → ToJs-0066e629.js} +3 -4
  46. package/esm/{ToJs-502f7a11.js.map → ToJs-0066e629.js.map} +1 -1
  47. package/esm/client.js +12 -19
  48. package/esm/client.js.map +1 -1
  49. package/esm/contensis-react-base.js +114 -178
  50. package/esm/contensis-react-base.js.map +1 -1
  51. package/esm/forms.js +11 -153
  52. package/esm/forms.js.map +1 -1
  53. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
  54. package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
  55. package/esm/{login-a950263f.js → login-bffb081f.js} +59 -110
  56. package/esm/{login-a950263f.js.map → login-bffb081f.js.map} +1 -1
  57. package/esm/{reducers-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
  58. package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
  59. package/esm/redux.js +8 -7
  60. package/esm/redux.js.map +1 -1
  61. package/esm/routing.js +3 -3
  62. package/esm/{sagas-e576b6f6.js → sagas-53d2aefb.js} +134 -235
  63. package/{cjs/sagas-8a20e424.js.map → esm/sagas-53d2aefb.js.map} +1 -1
  64. package/esm/search.js +57 -83
  65. package/esm/search.js.map +1 -1
  66. package/esm/{selectors-78355a01.js → selectors-3f0d804d.js} +1 -6
  67. package/esm/selectors-3f0d804d.js.map +1 -0
  68. package/esm/urls-eac9a747.js.map +1 -1
  69. package/esm/user.js +6 -14
  70. package/esm/user.js.map +1 -1
  71. package/esm/util.js +35 -55
  72. package/esm/util.js.map +1 -1
  73. package/esm/{version-03d555b7.js → version-dd31c7f0.js} +24 -58
  74. package/{cjs/version-7ce96442.js.map → esm/version-dd31c7f0.js.map} +1 -1
  75. package/esm/{version-5ce7dbce.js → version-f4629693.js} +3 -6
  76. package/esm/{version-5ce7dbce.js.map → version-f4629693.js.map} +1 -1
  77. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
  78. package/models/user/components.styled/Login.styled.d.ts +1 -1
  79. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  80. package/package.json +2 -2
  81. package/cjs/ContensisDeliveryApi-cfdefe17.js.map +0 -1
  82. package/cjs/selectors-fa607198.js.map +0 -1
  83. package/esm/ContensisDeliveryApi-8abcf222.js.map +0 -1
  84. package/esm/selectors-78355a01.js.map +0 -1
@@ -3,20 +3,20 @@
3
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-cfdefe17.js');
7
- var version = require('./version-7ce96442.js');
8
- var version$1 = require('./version-d6e26cc4.js');
9
- var selectors = require('./selectors-fa607198.js');
10
- var login = require('./login-dfcea036.js');
6
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-de88df2a.js');
7
+ var version = require('./version-38afaf2a.js');
8
+ var version$1 = require('./version-886f49d8.js');
9
+ var selectors = require('./selectors-c76c2676.js');
10
+ var login = require('./login-2ea569cc.js');
11
11
  var contensisDeliveryApi = require('contensis-delivery-api');
12
12
  var awaitToJs = require('await-to-js');
13
- var reducers = require('./reducers-73a03ef4.js');
14
- var ToJs = require('./ToJs-d962c80f.js');
13
+ var reducers = require('./reducers-9afb5f89.js');
14
+ var ToJs = require('./ToJs-61c03582.js');
15
15
  var React = require('react');
16
16
  require('react-hot-loader');
17
17
  require('jsonpath-mapper');
18
18
  require('query-string');
19
- var RouteLoader = require('./RouteLoader-fcd1e4f1.js');
19
+ var RouteLoader = require('./RouteLoader-47d70a26.js');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
@@ -41,6 +41,7 @@ function _interopNamespace(e) {
41
41
  var log__namespace = /*#__PURE__*/_interopNamespace(log);
42
42
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
 
44
+ // Create a history depending on the environment
44
45
  const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
45
46
  const history = (options = {}) => selectedHistory(options);
46
47
  const browserHistory = selectedHistory();
@@ -48,7 +49,6 @@ const browserHistory = selectedHistory();
48
49
  const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
49
50
  function* ensureNodeTreeSaga(action) {
50
51
  const state = yield effects.select();
51
-
52
52
  try {
53
53
  if (!version$1.hasNavigationTree(state)) {
54
54
  const deliveryApiVersionStatus = yield effects.select(version.selectVersionStatus);
@@ -56,7 +56,6 @@ function* ensureNodeTreeSaga(action) {
56
56
  const nodes = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
57
57
  depth: action.treeDepth || 0
58
58
  });
59
-
60
59
  if (nodes) {
61
60
  yield effects.put({
62
61
  type: version.SET_NODE_TREE,
@@ -103,7 +102,6 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
103
102
  const defaultExpressions = versionStatus => {
104
103
  return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
105
104
  };
106
-
107
105
  const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
108
106
 
109
107
  const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
@@ -113,11 +111,11 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
113
111
  };
114
112
 
115
113
  const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
114
+
116
115
  /**
117
116
  * To navigate / push a specific route via redux middleware
118
117
  * @param {path, state} action
119
118
  */
120
-
121
119
  function* setRouteSaga(action) {
122
120
  yield effects.put({
123
121
  type: 'CALL_HISTORY_METHOD',
@@ -127,37 +125,35 @@ function* setRouteSaga(action) {
127
125
  }
128
126
  });
129
127
  }
130
-
131
128
  function* getRouteSaga(action) {
132
129
  let entry = null;
133
-
134
130
  try {
135
131
  var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
136
-
137
132
  const {
138
133
  withEvents,
139
134
  routes: {
140
135
  ContentTypeMappings = {}
141
136
  } = {},
142
137
  staticRoute
143
- } = action; // Inject redux { key, reducer, saga } provided by staticRoute
138
+ } = action;
144
139
 
145
- 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);
146
142
 
143
+ // Variables we will pass to setRouteEntry
147
144
  let pathNode = null,
148
- ancestors = null,
149
- children = [],
150
- siblings = null;
151
- let contentTypeMapping = {}; // These variables are the return values from
152
- // calls to withEvents.onRouteLoad and onRouteLoaded
145
+ ancestors = null,
146
+ children = [],
147
+ siblings = null;
148
+ let contentTypeMapping = {};
153
149
 
150
+ // These variables are the return values from
151
+ // calls to withEvents.onRouteLoad and onRouteLoaded
154
152
  let appsays,
155
- requireLogin = false;
156
-
153
+ requireLogin = false;
157
154
  if (withEvents && withEvents.onRouteLoad) {
158
155
  appsays = yield withEvents.onRouteLoad(action);
159
156
  }
160
-
161
157
  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;
162
158
  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;
163
159
  const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
@@ -166,30 +162,29 @@ function* getRouteSaga(action) {
166
162
  const routeEntry = selectors.selectRouteEntry(state, 'js');
167
163
  const routeNode = selectors.selectCurrentNode(state, 'js');
168
164
  const currentPath = action.path; //selectCurrentPath(state);
169
-
170
165
  const deliveryApiStatus = version.selectVersionStatus(state);
171
- const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
172
-
166
+ const project = selectors.selectCurrentProject(state);
167
+ // const isHome = currentPath === '/';
173
168
  const isPreview = currentPath && currentPath.startsWith('/preview/');
174
169
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
175
-
176
170
  if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
177
171
  // To prevent erroneous 404s and wasted network calls, this covers
178
172
  // - appsays customRouting and does SET_ENTRY etc. via the consuming app
179
173
  // - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
180
174
  // - standard Contensis SiteView Routing where we already have that entry in state
181
175
  if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
182
- pathNode = { ...routeNode,
176
+ pathNode = {
177
+ ...routeNode,
183
178
  entry: null
184
179
  };
185
- pathNode.entry = entry = routeEntry; //Do nothing, the entry is allready the right one.
180
+ pathNode.entry = entry = routeEntry;
181
+ //Do nothing, the entry is allready the right one.
186
182
  // yield put({
187
183
  // type: SET_ENTRY,
188
184
  // entry,
189
185
  // node: routeNode,
190
186
  // isLoading: false,
191
187
  // });
192
-
193
188
  yield effects.put({
194
189
  type: selectors.UPDATE_LOADING_STATE,
195
190
  isLoading: false
@@ -201,11 +196,11 @@ function* getRouteSaga(action) {
201
196
  let splitPath = currentPath.split('/');
202
197
  let entryGuid = splitPath[2];
203
198
  let language = defaultLang;
204
-
205
199
  if (splitPath.length >= 3) {
206
200
  //set lang key if available in the path, else use default lang
207
201
  //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
208
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
202
+ if (splitPath.length == 4) language = splitPath[3];
203
+ // According to product dev we cannot use Node API
209
204
  // for previewing entries as it gives a response of []
210
205
  // -- apparently it is not correct to request latest content
211
206
  // with Node API
@@ -215,7 +210,6 @@ function* getRouteSaga(action) {
215
210
  language,
216
211
  linkDepth: entryLinkDepth
217
212
  });
218
-
219
213
  if (previewEntry) {
220
214
  pathNode = {
221
215
  entry: previewEntry
@@ -227,7 +221,6 @@ function* getRouteSaga(action) {
227
221
  }
228
222
  } else {
229
223
  var _pathNode, _pathNode$entry, _pathNode$entry$sys;
230
-
231
224
  // Handle all other routes
232
225
  pathNode = yield ContensisDeliveryApi.cachedSearch.getNode({
233
226
  depth: 0,
@@ -240,10 +233,8 @@ function* getRouteSaga(action) {
240
233
  ({
241
234
  entry
242
235
  } = pathNode || {});
243
-
244
236
  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) {
245
237
  var _payload$items;
246
-
247
238
  // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
248
239
  // and current node's ordinates at a specified depth with specified fields
249
240
  contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
@@ -253,15 +244,14 @@ function* getRouteSaga(action) {
253
244
  } = contentTypeMapping;
254
245
  const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
255
246
  const payload = yield ContensisDeliveryApi.cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
256
-
257
247
  if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
258
248
  pathNode.entry = entry = payload.items[0];
259
249
  }
260
250
  }
261
- } // make calls to fetch node ancestors, children,
262
- // siblings or entire node tree
263
-
251
+ }
264
252
 
253
+ // make calls to fetch node ancestors, children,
254
+ // siblings or entire node tree
265
255
  [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
266
256
  appsays,
267
257
  contentTypeMapping,
@@ -273,37 +263,34 @@ function* getRouteSaga(action) {
273
263
  });
274
264
  if (children) pathNode.children = children;
275
265
  }
266
+ const resolvedContentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {};
276
267
 
277
- const resolvedContentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {}; // Inject redux { key, reducer, saga } provided by ContentTypeMapping
278
-
268
+ // Inject redux { key, reducer, saga } provided by ContentTypeMapping
279
269
  if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
280
-
281
270
  if (withEvents && withEvents.onRouteLoaded) {
282
271
  // Check if the app has provided a requireLogin boolean flag or groups array
283
272
  // in addition to checking if requireLogin is set in the route definition
284
273
  ({
285
274
  requireLogin
286
- } = (yield withEvents.onRouteLoaded({ ...action,
275
+ } = (yield withEvents.onRouteLoaded({
276
+ ...action,
287
277
  entry
288
278
  })) || {});
289
279
  }
290
-
291
280
  if (requireLogin !== false) {
292
281
  // Do not call the login feature saga if requireLogin is false
293
- yield effects.call(login.handleRequiresLoginSaga, { ...action,
282
+ yield effects.call(login.handleRequiresLoginSaga, {
283
+ ...action,
294
284
  entry,
295
285
  requireLogin
296
286
  });
297
287
  }
298
-
299
288
  if (!appsays || !appsays.preventScrollTop) {
300
289
  // Scroll into View
301
290
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
302
291
  }
303
-
304
292
  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) {
305
293
  var _staticRoute$route3, _staticRoute$route3$f, _appsays;
306
-
307
294
  entry = pathNode.entry;
308
295
  yield effects.call(setRouteEntry, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
309
296
  } else {
@@ -314,7 +301,6 @@ function* getRouteSaga(action) {
314
301
  yield effects.call(do500, e);
315
302
  }
316
303
  }
317
-
318
304
  function* resolveCurrentNodeOrdinates({
319
305
  appsays,
320
306
  contentTypeMapping,
@@ -324,10 +310,11 @@ function* resolveCurrentNodeOrdinates({
324
310
  project,
325
311
  versionStatus
326
312
  }) {
327
- const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
313
+ const apiCall = [() => null, () => null, () => null, () => null];
314
+
315
+ // if appsays customNavigation: true, we will set doNavigation to false
328
316
  // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
329
317
  // if appsays nothing we will set doNavigation to true and continue to do navigation calls
330
-
331
318
  const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
332
319
  const {
333
320
  entryLinkDepth = 0,
@@ -335,7 +322,6 @@ function* resolveCurrentNodeOrdinates({
335
322
  linkDepth,
336
323
  nodeOptions = {}
337
324
  } = contentTypeMapping;
338
-
339
325
  if (pathNode && pathNode.id) {
340
326
  if (doNavigation === true || doNavigation.ancestors) {
341
327
  apiCall[0] = function* getAncestors() {
@@ -351,12 +337,9 @@ function* resolveCurrentNodeOrdinates({
351
337
  }
352
338
  };
353
339
  }
354
-
355
340
  const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
356
-
357
341
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
358
342
  const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
359
-
360
343
  apiCall[1] = function* getChildren() {
361
344
  try {
362
345
  return yield ContensisDeliveryApi.cachedSearch.getNode({
@@ -373,12 +356,10 @@ function* resolveCurrentNodeOrdinates({
373
356
  }
374
357
  };
375
358
  }
376
-
377
359
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
378
360
  apiCall[2] = function* getSiblings() {
379
361
  try {
380
362
  var _nodeOptions$siblings, _nodeOptions$siblings2;
381
-
382
363
  return yield ContensisDeliveryApi.cachedSearch.getSiblings({
383
364
  id: pathNode.id,
384
365
  entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
@@ -394,11 +375,9 @@ function* resolveCurrentNodeOrdinates({
394
375
  };
395
376
  }
396
377
  }
397
-
398
378
  const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
399
379
  if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
400
380
  const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
401
-
402
381
  if (typeof window !== 'undefined') {
403
382
  return yield effects.put({
404
383
  type: version.GET_NODE_TREE,
@@ -414,15 +393,16 @@ function* resolveCurrentNodeOrdinates({
414
393
  const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
415
394
  return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
416
395
  }
417
-
418
396
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
419
- const entrySys = entry && entry.sys || {}; // Update a window global to provide the preview toolbar
420
- // an updated entry id in client-side navigation
397
+ const entrySys = entry && entry.sys || {};
421
398
 
399
+ // Update a window global to provide the preview toolbar
400
+ // an updated entry id in client-side navigation
422
401
  if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
423
402
  const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
424
403
  const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
425
- const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, { ...node,
404
+ const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
405
+ ...node,
426
406
  entry,
427
407
  ancestors,
428
408
  siblings
@@ -442,7 +422,6 @@ function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound
442
422
  siblings
443
423
  })]);
444
424
  }
445
-
446
425
  function* mapRouteEntry(entryMapper, node) {
447
426
  try {
448
427
  if (typeof entryMapper === 'function') {
@@ -453,10 +432,8 @@ function* mapRouteEntry(entryMapper, node) {
453
432
  } catch (e) {
454
433
  log__namespace.error(...['Error running entryMapper:', e, e.stack]);
455
434
  }
456
-
457
435
  return;
458
436
  }
459
-
460
437
  function* do404() {
461
438
  yield effects.call(clientReloadHitServer);
462
439
  yield effects.put({
@@ -466,17 +443,16 @@ function* do404() {
466
443
  notFound: true
467
444
  });
468
445
  }
469
-
470
446
  function* clientReloadHitServer() {
471
- const stateEntry = yield effects.select(selectors.selectRouteEntry); // If in client and there is a stateEntry.sys field reload the page,
447
+ const stateEntry = yield effects.select(selectors.selectRouteEntry);
448
+
449
+ // If in client and there is a stateEntry.sys field reload the page,
472
450
  // on the 2nd load stateEntry.sys should be null at this point,
473
451
  // we do not wish to reload again and get stuck in an infinite reloading loop
474
-
475
452
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
476
453
  window.location.reload();
477
454
  }
478
455
  }
479
-
480
456
  function* do500(error) {
481
457
  yield effects.put({
482
458
  type: selectors.SET_ENTRY,
@@ -488,7 +464,6 @@ function* do500(error) {
488
464
  statusCode: error && error.status ? error.status : 500
489
465
  });
490
466
  }
491
-
492
467
  function* reduxInjectorSaga(injectorFn) {
493
468
  if (typeof injectorFn === 'function') {
494
469
  const {
@@ -505,19 +480,18 @@ function* reduxInjectorSaga(injectorFn) {
505
480
  }
506
481
 
507
482
  const registerSagas = [effects.takeEvery(reducers.REGISTER_USER, registerSaga), effects.takeEvery(reducers.REGISTER_USER_SUCCESS, redirectSaga)];
508
-
509
483
  function* registerSaga({
510
484
  user,
511
485
  mappers
512
486
  }) {
513
- let requestBody = user; // Allow use of request mapper to take a user object
487
+ let requestBody = user;
488
+ // Allow use of request mapper to take a user object
514
489
  // of any format and return the payload for the api request
515
-
516
490
  if (mappers && mappers.request && typeof mappers.request === 'function') {
517
491
  requestBody = yield mappers.request(user);
518
- } // Make POST call to register API
519
-
492
+ }
520
493
 
494
+ // Make POST call to register API
521
495
  const response = yield fetch('/account/register', {
522
496
  method: 'POST',
523
497
  headers: {
@@ -526,19 +500,16 @@ function* registerSaga({
526
500
  },
527
501
  body: JSON.stringify(requestBody)
528
502
  });
529
-
530
503
  if (response.ok) {
531
504
  let mappedResponse;
532
505
  const [, responseBody] = yield awaitToJs.to(response.json());
533
-
534
506
  if (responseBody) {
535
507
  // Allow use of response mapper to convert the successful user object
536
508
  // from the api response body into a user object of any format
537
509
  if (mappers && mappers.response && typeof mappers.response === 'function') {
538
510
  mappedResponse = yield mappers.response(responseBody);
539
- } // Update user object with mappedResponse or responseBody
540
-
541
-
511
+ }
512
+ // Update user object with mappedResponse or responseBody
542
513
  yield effects.put({
543
514
  type: reducers.REGISTER_USER_SUCCESS,
544
515
  user: mappedResponse || responseBody
@@ -557,25 +528,24 @@ function* registerSaga({
557
528
  // or status codes echoed from the responses received from
558
529
  // management api when registering the user
559
530
  const [, errorResponse] = yield awaitToJs.to(response.json());
560
- const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
561
-
531
+ const error = errorResponse && errorResponse.error || errorResponse || {};
532
+ // Get something meaningful from the response if there is no message in the body
562
533
  if (!error.message) {
563
534
  error.message = `Registration service: ${response.statusText}`;
564
535
  error.status = response.status;
565
536
  }
566
-
567
537
  yield effects.put({
568
538
  type: reducers.REGISTER_USER_FAILED,
569
539
  error
570
540
  });
571
541
  }
572
542
  }
573
-
574
543
  function* redirectSaga() {
575
544
  // Check if querystring contains a redirect_uri
576
545
  const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
577
- const redirectUri = currentQs.redirect_uri || currentQs.redirect; // We must use redux based navigation to preserve the registration state
546
+ const redirectUri = currentQs.redirect_uri || currentQs.redirect;
578
547
 
548
+ // We must use redux based navigation to preserve the registration state
579
549
  if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
580
550
  }
581
551
 
@@ -593,36 +563,36 @@ const BASE_OPTIONS = {
593
563
  };
594
564
  class UserHelper {
595
565
  static async GetUsersEnvironments(securityToken) {
596
- const options = { ...BASE_OPTIONS,
566
+ const options = {
567
+ ...BASE_OPTIONS,
597
568
  headers: {
598
569
  'x-security-token': securityToken
599
570
  }
600
571
  };
601
572
  return await UserHelper.get(USER_ENVS_URL, options);
602
573
  }
603
-
604
574
  static async ResendUserVerification(userEmail) {
605
- const options = { ...BASE_OPTIONS
575
+ const options = {
576
+ ...BASE_OPTIONS
606
577
  };
607
578
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
608
579
  }
609
-
610
580
  static async RequestPasswordReset(userEmailObject) {
611
- const options = { ...BASE_OPTIONS,
581
+ const options = {
582
+ ...BASE_OPTIONS,
612
583
  body: JSON.stringify(userEmailObject)
613
584
  };
614
585
  options.method = 'POST';
615
586
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
616
587
  }
617
-
618
588
  static async ResetPassword(resetPasswordObject) {
619
- const options = { ...BASE_OPTIONS,
589
+ const options = {
590
+ ...BASE_OPTIONS,
620
591
  body: JSON.stringify(resetPasswordObject)
621
592
  };
622
593
  options.method = 'POST';
623
594
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
624
595
  }
625
-
626
596
  static async get(url, options = BASE_OPTIONS) {
627
597
  try {
628
598
  const responseBody = await api(url, options);
@@ -635,9 +605,7 @@ class UserHelper {
635
605
  };
636
606
  }
637
607
  }
638
-
639
608
  }
640
-
641
609
  async function api(url, options) {
642
610
  return fetch(url, options).then(async response => {
643
611
  return response.json().then(data => data);
@@ -647,17 +615,14 @@ async function api(url, options) {
647
615
  }
648
616
 
649
617
  const resetPasswordSagas = [effects.takeEvery(reducers.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(reducers.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(reducers.CHANGE_USER_PASSWORD, changePasswordSaga)];
650
-
651
618
  function* requestPasswordResetSaga(action) {
652
619
  const userEmailObject = action.userEmailObject;
653
620
  yield effects.put({
654
621
  type: reducers.REQUEST_USER_PASSWORD_RESET_SENDING
655
622
  });
656
-
657
623
  if (userEmailObject && userEmailObject.userEmail) {
658
624
  try {
659
625
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
660
-
661
626
  if (passwordResetRequestResponse) {
662
627
  if (!passwordResetRequestResponse.error) {
663
628
  yield effects.put({
@@ -688,17 +653,14 @@ function* requestPasswordResetSaga(action) {
688
653
  });
689
654
  }
690
655
  }
691
-
692
656
  function* resetPasswordSaga(action) {
693
657
  const resetPasswordObject = action.resetPasswordObject;
694
658
  yield effects.put({
695
659
  type: reducers.RESET_USER_PASSWORD_SENDING
696
660
  });
697
-
698
661
  if (resetPasswordObject.token && resetPasswordObject.password) {
699
662
  try {
700
663
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
701
-
702
664
  if (resetPasswordResponse) {
703
665
  if (!resetPasswordResponse.error) {
704
666
  yield effects.put({
@@ -729,11 +691,11 @@ function* resetPasswordSaga(action) {
729
691
  error: 'Invalid object'
730
692
  });
731
693
  }
732
- } // userId
694
+ }
695
+
696
+ // userId
733
697
  // existingPassword
734
698
  // newPassword
735
-
736
-
737
699
  function* changePasswordSaga(action) {
738
700
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
739
701
  yield effects.put({
@@ -742,7 +704,6 @@ function* changePasswordSaga(action) {
742
704
  });
743
705
  return;
744
706
  }
745
-
746
707
  try {
747
708
  const changePasswordObject = {
748
709
  userId: action.userId,
@@ -753,25 +714,24 @@ function* changePasswordSaga(action) {
753
714
  type: reducers.CHANGE_USER_PASSWORD_SENDING
754
715
  });
755
716
  const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
756
- const client = yield login.getManagementApiClient({ ...clientCredentials
717
+ const client = yield login.getManagementApiClient({
718
+ ...clientCredentials
757
719
  });
758
720
  const [err, res] = yield awaitToJs.to(client.security.users.updatePassword(changePasswordObject));
759
-
760
721
  if (err) {
761
722
  var _err$data, _err$data$data, _err$data2;
762
-
763
723
  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);
764
724
  yield effects.put({
765
725
  type: reducers.CHANGE_USER_PASSWORD_ERROR,
766
726
  error
767
727
  });
768
728
  return;
769
- } // // eslint-disable-next-line no-console
729
+ }
730
+
731
+ // // eslint-disable-next-line no-console
770
732
  // console.log(changePasswordObject);
771
733
  // // eslint-disable-next-line no-console
772
734
  // console.log(userCredentialsObject);
773
-
774
-
775
735
  yield effects.put({
776
736
  type: reducers.CHANGE_USER_PASSWORD_SUCCESS
777
737
  });
@@ -793,35 +753,32 @@ function rootSaga (featureSagas = []) {
793
753
  };
794
754
  }
795
755
 
796
- const servers = SERVERS;
797
- /* global SERVERS */
798
-
756
+ const servers = SERVERS; /* global SERVERS */
799
757
  const alias = servers.alias.toLowerCase();
800
- const publicUri = PUBLIC_URI;
801
- /* global PUBLIC_URI */
758
+ const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
759
+ const projects = PROJECTS; /* global PROJECTS */
802
760
 
803
- const projects = PROJECTS;
804
- /* global PROJECTS */
805
761
  // return a projectId via the request hostname
806
-
807
762
  const pickProject = (hostname, query) => {
808
763
  // if localhost we can only infer via a querystring, and take your word for it
809
764
  if (hostname == 'localhost') {
810
765
  return query && query.p || projects[0].id;
811
- } // if hostname is the actual public uri we can return the first project from the list
812
-
766
+ }
813
767
 
768
+ // if hostname is the actual public uri we can return the first project from the list
814
769
  if (hostname == publicUri) {
815
770
  return projects[0].id;
816
771
  }
772
+ let project = 'unknown';
817
773
 
818
- let project = 'unknown'; // // go through all the defined projects
774
+ // // go through all the defined projects
819
775
  // Object.entries(projects).map(([, p]) => {
776
+ const p = projects[0];
820
777
 
821
- const p = projects[0]; // check if we're accessing via the project's public uri
822
-
823
- if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
778
+ // check if we're accessing via the project's public uri
779
+ if (hostname.includes(p.publicUri)) project = p.id;
824
780
 
781
+ // the url structure is different for website (we don't prefix)
825
782
  if (p.id.startsWith('website')) {
826
783
  // check for internal and external hostnames
827
784
  // we check live and preview distinctly so our rule does not clash with
@@ -830,9 +787,8 @@ const pickProject = (hostname, query) => {
830
787
  } else {
831
788
  // check for internal and external hostnames, prefixed with the projectId
832
789
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
833
- } // });
834
-
835
-
790
+ }
791
+ // });
836
792
  return project === 'unknown' ? p.id : project;
837
793
  };
838
794
 
@@ -845,4 +801,4 @@ exports.browserHistory = browserHistory;
845
801
  exports.history = history;
846
802
  exports.pickProject = pickProject;
847
803
  exports.rootSaga = rootSaga;
848
- //# sourceMappingURL=App-48706fde.js.map
804
+ //# sourceMappingURL=App-2a7a16ad.js.map