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

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 (98) hide show
  1. package/cjs/{App-cf7e3103.js → App-b56aca04.js} +139 -93
  2. package/{esm/App-6e8e803b.js.map → cjs/App-b56aca04.js.map} +1 -1
  3. package/cjs/{ChangePassword.container-a617190b.js → ChangePassword.container-ae35785e.js} +120 -62
  4. package/{esm/ChangePassword.container-ae0f9ce4.js.map → cjs/ChangePassword.container-ae35785e.js.map} +1 -1
  5. package/cjs/{ContensisDeliveryApi-9e32960d.js → ContensisDeliveryApi-4fcf049d.js} +71 -17
  6. package/{esm/ContensisDeliveryApi-c66b0cc3.js.map → cjs/ContensisDeliveryApi-4fcf049d.js.map} +1 -1
  7. package/cjs/CookieConstants-000427db.js.map +1 -1
  8. package/cjs/{RouteLoader-3e284fd6.js → RouteLoader-c06dccd5.js} +182 -63
  9. package/cjs/RouteLoader-c06dccd5.js.map +1 -0
  10. package/cjs/{ToJs-149fc5e1.js → ToJs-a8d8f3f0.js} +14 -6
  11. package/cjs/{ToJs-149fc5e1.js.map → ToJs-a8d8f3f0.js.map} +1 -1
  12. package/cjs/client.js +20 -14
  13. package/cjs/client.js.map +1 -1
  14. package/cjs/contensis-react-base.js +275 -139
  15. package/cjs/contensis-react-base.js.map +1 -1
  16. package/cjs/forms.js +717 -228
  17. package/cjs/forms.js.map +1 -1
  18. package/cjs/{fromJSLeaveImmer-7c363211.js → fromJSLeaveImmer-e74c673c.js} +4 -1
  19. package/cjs/{fromJSLeaveImmer-7c363211.js.map → fromJSLeaveImmer-e74c673c.js.map} +1 -1
  20. package/cjs/{reducers-9afb5f89.js → reducers-73a03ef4.js} +31 -10
  21. package/cjs/{reducers-9afb5f89.js.map → reducers-73a03ef4.js.map} +1 -1
  22. package/cjs/redux.js +4 -5
  23. package/cjs/redux.js.map +1 -1
  24. package/cjs/routing.js +6 -4
  25. package/cjs/routing.js.map +1 -1
  26. package/cjs/{sagas-e04b94c1.js → sagas-570f23ba.js} +286 -187
  27. package/cjs/{sagas-e04b94c1.js.map → sagas-570f23ba.js.map} +1 -1
  28. package/cjs/search.js +82 -56
  29. package/cjs/search.js.map +1 -1
  30. package/cjs/{selectors-46b689d0.js → selectors-14caa813.js} +6 -1
  31. package/cjs/selectors-14caa813.js.map +1 -0
  32. package/cjs/urls-6fcaf4c6.js.map +1 -1
  33. package/cjs/user.js +9 -4
  34. package/cjs/user.js.map +1 -1
  35. package/cjs/util.js +55 -35
  36. package/cjs/util.js.map +1 -1
  37. package/cjs/{version-79a027cb.js → version-34d91f68.js} +60 -26
  38. package/cjs/version-34d91f68.js.map +1 -0
  39. package/cjs/{version-afd4f77e.js → version-a410c88e.js} +6 -3
  40. package/cjs/{version-afd4f77e.js.map → version-a410c88e.js.map} +1 -1
  41. package/esm/{App-6e8e803b.js → App-83107d7e.js} +137 -91
  42. package/{cjs/App-cf7e3103.js.map → esm/App-83107d7e.js.map} +1 -1
  43. package/esm/{ChangePassword.container-ae0f9ce4.js → ChangePassword.container-76fd5e9b.js} +120 -62
  44. package/{cjs/ChangePassword.container-a617190b.js.map → esm/ChangePassword.container-76fd5e9b.js.map} +1 -1
  45. package/esm/{ContensisDeliveryApi-c66b0cc3.js → ContensisDeliveryApi-fe57a037.js} +71 -17
  46. package/{cjs/ContensisDeliveryApi-9e32960d.js.map → esm/ContensisDeliveryApi-fe57a037.js.map} +1 -1
  47. package/esm/CookieConstants-3d3b6531.js.map +1 -1
  48. package/esm/RouteLoader-29fd689a.js +310 -0
  49. package/esm/RouteLoader-29fd689a.js.map +1 -0
  50. package/esm/{ToJs-ae860aad.js → ToJs-df57f31d.js} +14 -6
  51. package/esm/{ToJs-ae860aad.js.map → ToJs-df57f31d.js.map} +1 -1
  52. package/esm/client.js +21 -15
  53. package/esm/client.js.map +1 -1
  54. package/esm/contensis-react-base.js +270 -136
  55. package/esm/contensis-react-base.js.map +1 -1
  56. package/esm/forms.js +717 -228
  57. package/esm/forms.js.map +1 -1
  58. package/esm/{fromJSLeaveImmer-e2dacd63.js → fromJSLeaveImmer-0114ffcf.js} +4 -1
  59. package/esm/{fromJSLeaveImmer-e2dacd63.js.map → fromJSLeaveImmer-0114ffcf.js.map} +1 -1
  60. package/esm/{reducers-3d5c37d1.js → reducers-aa8cef1e.js} +31 -10
  61. package/esm/{reducers-3d5c37d1.js.map → reducers-aa8cef1e.js.map} +1 -1
  62. package/esm/redux.js +7 -8
  63. package/esm/redux.js.map +1 -1
  64. package/esm/routing.js +3 -4
  65. package/esm/routing.js.map +1 -1
  66. package/esm/{sagas-933a8fc8.js → sagas-07e82e18.js} +239 -139
  67. package/esm/{sagas-933a8fc8.js.map → sagas-07e82e18.js.map} +1 -1
  68. package/esm/search.js +83 -57
  69. package/esm/search.js.map +1 -1
  70. package/esm/{selectors-01074974.js → selectors-691caf02.js} +6 -1
  71. package/esm/selectors-691caf02.js.map +1 -0
  72. package/esm/urls-eac9a747.js.map +1 -1
  73. package/esm/user.js +11 -6
  74. package/esm/user.js.map +1 -1
  75. package/esm/util.js +55 -35
  76. package/esm/util.js.map +1 -1
  77. package/esm/{version-346a9787.js → version-3d9911e2.js} +60 -26
  78. package/esm/version-3d9911e2.js.map +1 -0
  79. package/esm/{version-0fbd1b82.js → version-9f29becb.js} +6 -3
  80. package/esm/{version-0fbd1b82.js.map → version-9f29becb.js.map} +1 -1
  81. package/models/redux/appstate.d.ts +2 -3
  82. package/models/redux/store/history.d.ts +2 -2
  83. package/models/routing/components/Redirect.d.ts +5 -0
  84. package/models/routing/components/StaticRouteLoader.d.ts +6 -0
  85. package/models/routing/httpContext.d.ts +7 -0
  86. package/models/routing/index.d.ts +3 -0
  87. package/models/routing/redux/actions.d.ts +2 -3
  88. package/models/routing/routes.d.ts +11 -5
  89. package/models/util/ContensisDeliveryApi.d.ts +0 -1
  90. package/models/util/mergeStaticRoutes.d.ts +1 -0
  91. package/package.json +3 -5
  92. package/cjs/RouteLoader-3e284fd6.js.map +0 -1
  93. package/cjs/selectors-46b689d0.js.map +0 -1
  94. package/cjs/version-79a027cb.js.map +0 -1
  95. package/esm/RouteLoader-e3c5505f.js +0 -196
  96. package/esm/RouteLoader-e3c5505f.js.map +0 -1
  97. package/esm/selectors-01074974.js.map +0 -1
  98. package/esm/version-346a9787.js.map +0 -1
@@ -1,23 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var history$1 = require('history');
3
+ var require$$1 = require('history');
4
4
  var effects = require('@redux-saga/core/effects');
5
5
  var log = require('loglevel');
6
- var ContensisDeliveryApi = require('./ContensisDeliveryApi-9e32960d.js');
7
- var version = require('./version-79a027cb.js');
8
- var version$1 = require('./version-afd4f77e.js');
9
- var selectors = require('./selectors-46b689d0.js');
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');
10
10
  var to = require('await-to-js');
11
- var ChangePassword_container = require('./ChangePassword.container-a617190b.js');
11
+ var ChangePassword_container = require('./ChangePassword.container-ae35785e.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-9afb5f89.js');
16
+ var reducers = require('./reducers-73a03ef4.js');
17
17
  var contensisDeliveryApi = require('contensis-delivery-api');
18
- var ToJs = require('./ToJs-149fc5e1.js');
18
+ var ToJs = require('./ToJs-a8d8f3f0.js');
19
19
  require('query-string');
20
- var RouteLoader = require('./RouteLoader-3e284fd6.js');
20
+ require('react-router-dom');
21
+ var RouteLoader = require('./RouteLoader-c06dccd5.js');
21
22
 
22
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
24
 
@@ -43,14 +44,14 @@ var log__namespace = /*#__PURE__*/_interopNamespace(log);
43
44
  var to__default = /*#__PURE__*/_interopDefaultLegacy(to);
44
45
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
46
 
46
- // Create a history depending on the environment
47
- const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
47
+ const selectedHistory = typeof window !== 'undefined' ? require$$1.createBrowserHistory : require$$1.createMemoryHistory;
48
48
  const history = (options = {}) => selectedHistory(options);
49
49
  const browserHistory = selectedHistory();
50
50
 
51
51
  const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
52
52
  function* ensureNodeTreeSaga(action) {
53
53
  const state = yield effects.select();
54
+
54
55
  try {
55
56
  if (!version$1.hasNavigationTree(state)) {
56
57
  const deliveryApiVersionStatus = yield effects.select(version.selectVersionStatus);
@@ -59,6 +60,7 @@ function* ensureNodeTreeSaga(action) {
59
60
  depth: action.treeDepth || 0,
60
61
  language: action.language
61
62
  });
63
+
62
64
  if (nodes) {
63
65
  yield effects.put({
64
66
  type: version.SET_NODE_TREE,
@@ -105,6 +107,7 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
105
107
  const defaultExpressions = versionStatus => {
106
108
  return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
107
109
  };
110
+
108
111
  const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
109
112
 
110
113
  const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
@@ -114,11 +117,11 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
114
117
  };
115
118
 
116
119
  const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
117
-
118
120
  /**
119
121
  * To navigate / push a specific route via redux middleware
120
122
  * @param {path, state} action
121
123
  */
124
+
122
125
  function* setRouteSaga(action) {
123
126
  yield effects.put({
124
127
  type: 'CALL_HISTORY_METHOD',
@@ -128,10 +131,13 @@ function* setRouteSaga(action) {
128
131
  }
129
132
  });
130
133
  }
134
+
131
135
  function* getRouteSaga(action) {
132
136
  let entry = null;
137
+
133
138
  try {
134
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
+
135
141
  const {
136
142
  withEvents,
137
143
  routes: {
@@ -140,25 +146,24 @@ function* getRouteSaga(action) {
140
146
  staticRoute,
141
147
  cookies
142
148
  } = action;
143
- const api = ContensisDeliveryApi.cachedSearchWithCookies(cookies.raw);
149
+ const api = ContensisDeliveryApi.cachedSearchWithCookies(cookies.raw); // Inject redux { key, reducer, saga } provided by staticRoute
144
150
 
145
- // Inject redux { key, reducer, saga } provided by staticRoute
146
- if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux);
151
+ if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux); // Variables we will pass to setRouteEntry
147
152
 
148
- // Variables we will pass to setRouteEntry
149
153
  let pathNode = null,
150
- ancestors = null,
151
- children = [],
152
- siblings = null;
153
- let contentTypeMapping = {};
154
-
155
- // These variables are the return values from
154
+ ancestors = null,
155
+ children = [],
156
+ siblings = null;
157
+ let contentTypeMapping = {}; // These variables are the return values from
156
158
  // calls to withEvents.onRouteLoad and onRouteLoaded
159
+
157
160
  let appsays,
158
- requireLogin = false;
161
+ requireLogin = false;
162
+
159
163
  if (withEvents && withEvents.onRouteLoad) {
160
164
  appsays = yield withEvents.onRouteLoad(action);
161
165
  }
166
+
162
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;
163
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;
164
169
  const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
@@ -167,29 +172,30 @@ function* getRouteSaga(action) {
167
172
  const routeEntry = selectors.selectRouteEntry(state, 'js');
168
173
  const routeNode = selectors.selectCurrentNode(state, 'js');
169
174
  const currentPath = action.path; //selectCurrentPath(state);
175
+
170
176
  const deliveryApiStatus = version.selectVersionStatus(state);
171
- const project = selectors.selectCurrentProject(state);
172
- // const isHome = currentPath === '/';
177
+ const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
178
+
173
179
  const isPreview = currentPath && currentPath.startsWith('/preview/');
174
180
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
181
+
175
182
  if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
176
183
  // To prevent erroneous 404s and wasted network calls, this covers
177
184
  // - appsays customRouting and does SET_ENTRY etc. via the consuming app
178
185
  // - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
179
186
  // - standard Contensis SiteView Routing where we already have that entry in state
180
187
  if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
181
- pathNode = {
182
- ...routeNode,
188
+ pathNode = { ...routeNode,
183
189
  entry: null
184
190
  };
185
- pathNode.entry = entry = routeEntry;
186
- //Do nothing, the entry is allready the right one.
191
+ pathNode.entry = entry = routeEntry; //Do nothing, the entry is allready the right one.
187
192
  // yield put({
188
193
  // type: SET_ENTRY,
189
194
  // entry,
190
195
  // node: routeNode,
191
196
  // isLoading: false,
192
197
  // });
198
+
193
199
  yield effects.put({
194
200
  type: selectors.UPDATE_LOADING_STATE,
195
201
  isLoading: false
@@ -201,11 +207,11 @@ function* getRouteSaga(action) {
201
207
  let splitPath = currentPath.split('/');
202
208
  let entryGuid = splitPath[2];
203
209
  let language = defaultLang;
210
+
204
211
  if (splitPath.length >= 3) {
205
212
  //set lang key if available in the path, else use default lang
206
213
  //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
207
- if (splitPath.length == 4) language = splitPath[3];
208
- // According to product dev we cannot use Node API
214
+ if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
209
215
  // for previewing entries as it gives a response of []
210
216
  // -- apparently it is not correct to request latest content
211
217
  // with Node API
@@ -215,6 +221,7 @@ function* getRouteSaga(action) {
215
221
  language,
216
222
  linkDepth: entryLinkDepth
217
223
  });
224
+
218
225
  if (previewEntry) {
219
226
  pathNode = {
220
227
  entry: previewEntry
@@ -226,6 +233,7 @@ function* getRouteSaga(action) {
226
233
  }
227
234
  } else {
228
235
  var _pathNode, _pathNode$entry, _pathNode$entry$sys;
236
+
229
237
  // Handle all other routes
230
238
  let nodeError = undefined;
231
239
  [nodeError, pathNode] = yield to__default["default"](api.getNode({
@@ -236,16 +244,17 @@ function* getRouteSaga(action) {
236
244
  language: defaultLang,
237
245
  versionStatus: deliveryApiStatus
238
246
  }, project));
247
+
239
248
  if (nodeError) {
240
249
  if ([401, 403].includes(nodeError.status)) {
241
250
  // Capture specific auth errors with the delivery api
242
251
  // and fire the user down the handleRequiresLoginSaga
243
252
  // If auth was successful via a refreshToken we need to reload the page
244
253
  // to run this getRouteSaga again with the security token cookie
245
- const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
246
- ...action,
254
+ const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, { ...action,
247
255
  requireLogin: true
248
256
  });
257
+
249
258
  if (userLoggedIn && nodeError.status === 401) {
250
259
  // Reload the route so we can re-run the routing request now the
251
260
  // authentication cookies are written
@@ -263,8 +272,10 @@ function* getRouteSaga(action) {
263
272
  } else ({
264
273
  entry
265
274
  } = pathNode || {});
275
+
266
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) {
267
277
  var _payload$items;
278
+
268
279
  // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
269
280
  // and current node's ordinates at a specified depth with specified fields
270
281
  contentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
@@ -274,14 +285,15 @@ function* getRouteSaga(action) {
274
285
  } = contentTypeMapping;
275
286
  const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
276
287
  const payload = yield api.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
288
+
277
289
  if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
278
290
  pathNode.entry = entry = payload.items[0];
279
291
  }
280
292
  }
281
- }
282
-
283
- // make calls to fetch node ancestors, children,
293
+ } // make calls to fetch node ancestors, children,
284
294
  // siblings or entire node tree
295
+
296
+
285
297
  [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
286
298
  api,
287
299
  appsays,
@@ -294,34 +306,37 @@ function* getRouteSaga(action) {
294
306
  });
295
307
  if (children) pathNode.children = children;
296
308
  }
297
- 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) || {};
298
309
 
299
- // Inject redux { key, reducer, saga } provided by ContentTypeMapping
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
+
300
312
  if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
313
+
301
314
  if (withEvents && withEvents.onRouteLoaded) {
302
315
  // Check if the app has provided a requireLogin boolean flag or groups array
303
316
  // in addition to checking if requireLogin is set in the route definition
304
317
  ({
305
318
  requireLogin
306
- } = (yield withEvents.onRouteLoaded({
307
- ...action,
319
+ } = (yield withEvents.onRouteLoaded({ ...action,
308
320
  entry
309
321
  })) || {});
310
322
  }
323
+
311
324
  if (requireLogin !== false) {
312
325
  // Do not call the login feature saga if requireLogin is false
313
- yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
314
- ...action,
326
+ yield effects.call(ChangePassword_container.handleRequiresLoginSaga, { ...action,
315
327
  entry,
316
328
  requireLogin
317
329
  });
318
330
  }
331
+
319
332
  if (!appsays || !appsays.preventScrollTop) {
320
333
  // Scroll into View
321
334
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
322
335
  }
336
+
323
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) {
324
338
  var _staticRoute$route3, _staticRoute$route3$f, _appsays;
339
+
325
340
  entry = pathNode.entry;
326
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);
327
342
  } else {
@@ -332,6 +347,7 @@ function* getRouteSaga(action) {
332
347
  yield effects.call(do500, e);
333
348
  }
334
349
  }
350
+
335
351
  function* resolveCurrentNodeOrdinates({
336
352
  api,
337
353
  appsays,
@@ -342,11 +358,10 @@ function* resolveCurrentNodeOrdinates({
342
358
  project,
343
359
  versionStatus
344
360
  }) {
345
- const apiCall = [() => null, () => null, () => null, () => null];
346
-
347
- // if appsays customNavigation: true, we will set doNavigation to false
361
+ const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
348
362
  // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
349
363
  // if appsays nothing we will set doNavigation to true and continue to do navigation calls
364
+
350
365
  const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
351
366
  const {
352
367
  entryLinkDepth = 0,
@@ -354,6 +369,7 @@ function* resolveCurrentNodeOrdinates({
354
369
  linkDepth,
355
370
  nodeOptions = {}
356
371
  } = contentTypeMapping;
372
+
357
373
  if (pathNode && pathNode.id) {
358
374
  if (doNavigation === true || doNavigation.ancestors) {
359
375
  apiCall[0] = function* getAncestors() {
@@ -369,9 +385,12 @@ function* resolveCurrentNodeOrdinates({
369
385
  }
370
386
  };
371
387
  }
388
+
372
389
  const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
390
+
373
391
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
374
392
  const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
393
+
375
394
  apiCall[1] = function* getChildren() {
376
395
  try {
377
396
  return yield api.getNode({
@@ -388,10 +407,12 @@ function* resolveCurrentNodeOrdinates({
388
407
  }
389
408
  };
390
409
  }
410
+
391
411
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
392
412
  apiCall[2] = function* getSiblings() {
393
413
  try {
394
414
  var _nodeOptions$siblings, _nodeOptions$siblings2;
415
+
395
416
  return yield api.getSiblings({
396
417
  id: pathNode.id,
397
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,
@@ -407,9 +428,11 @@ function* resolveCurrentNodeOrdinates({
407
428
  };
408
429
  }
409
430
  }
431
+
410
432
  const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
411
433
  if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
412
434
  const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
435
+
413
436
  if (typeof window !== 'undefined') {
414
437
  return yield effects.put({
415
438
  type: version.GET_NODE_TREE,
@@ -427,16 +450,15 @@ function* resolveCurrentNodeOrdinates({
427
450
  const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
428
451
  return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
429
452
  }
430
- function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
431
- const entrySys = entry && entry.sys || {};
432
453
 
433
- // Update a window global to provide the preview toolbar
454
+ 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
434
456
  // an updated entry id in client-side navigation
457
+
435
458
  if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
436
459
  const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
437
460
  const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
438
- const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
439
- ...node,
461
+ const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, { ...node,
440
462
  entry,
441
463
  ancestors,
442
464
  siblings
@@ -457,6 +479,7 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
457
479
  siblings
458
480
  })]);
459
481
  }
482
+
460
483
  function* mapRouteEntry(entryMapper, node) {
461
484
  try {
462
485
  if (typeof entryMapper === 'function') {
@@ -467,8 +490,10 @@ function* mapRouteEntry(entryMapper, node) {
467
490
  } catch (e) {
468
491
  log__namespace.error(...['Error running entryMapper:', e, e.stack]);
469
492
  }
493
+
470
494
  return;
471
495
  }
496
+
472
497
  function* do404() {
473
498
  yield effects.call(clientReloadHitServer);
474
499
  yield effects.put({
@@ -478,16 +503,17 @@ function* do404() {
478
503
  notFound: true
479
504
  });
480
505
  }
481
- function* clientReloadHitServer() {
482
- const stateEntry = yield effects.select(selectors.selectRouteEntry);
483
506
 
484
- // If in client and there is a stateEntry.sys field reload the page,
507
+ function* clientReloadHitServer() {
508
+ const stateEntry = yield effects.select(selectors.selectRouteEntry); // If in client and there is a stateEntry.sys field reload the page,
485
509
  // on the 2nd load stateEntry.sys should be null at this point,
486
510
  // we do not wish to reload again and get stuck in an infinite reloading loop
511
+
487
512
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
488
513
  window.location.reload();
489
514
  }
490
515
  }
516
+
491
517
  function* do500(error) {
492
518
  yield effects.put({
493
519
  type: selectors.SET_ENTRY,
@@ -499,6 +525,7 @@ function* do500(error) {
499
525
  statusCode: error && error.status ? error.status : 500
500
526
  });
501
527
  }
528
+
502
529
  function* reduxInjectorSaga(injectorFn) {
503
530
  if (typeof injectorFn === 'function') {
504
531
  const {
@@ -515,18 +542,19 @@ function* reduxInjectorSaga(injectorFn) {
515
542
  }
516
543
 
517
544
  const registerSagas = [effects.takeEvery(reducers.REGISTER_USER, registerSaga), effects.takeEvery(reducers.REGISTER_USER_SUCCESS, redirectSaga)];
545
+
518
546
  function* registerSaga({
519
547
  user,
520
548
  mappers
521
549
  }) {
522
- let requestBody = user;
523
- // Allow use of request mapper to take a user object
550
+ let requestBody = user; // Allow use of request mapper to take a user object
524
551
  // of any format and return the payload for the api request
552
+
525
553
  if (mappers && mappers.request && typeof mappers.request === 'function') {
526
554
  requestBody = yield mappers.request(user);
527
- }
555
+ } // Make POST call to register API
556
+
528
557
 
529
- // Make POST call to register API
530
558
  const response = yield fetch('/account/register', {
531
559
  method: 'POST',
532
560
  headers: {
@@ -535,16 +563,19 @@ function* registerSaga({
535
563
  },
536
564
  body: JSON.stringify(requestBody)
537
565
  });
566
+
538
567
  if (response.ok) {
539
568
  let mappedResponse;
540
569
  const [, responseBody] = yield to.to(response.json());
570
+
541
571
  if (responseBody) {
542
572
  // Allow use of response mapper to convert the successful user object
543
573
  // from the api response body into a user object of any format
544
574
  if (mappers && mappers.response && typeof mappers.response === 'function') {
545
575
  mappedResponse = yield mappers.response(responseBody);
546
- }
547
- // Update user object with mappedResponse or responseBody
576
+ } // Update user object with mappedResponse or responseBody
577
+
578
+
548
579
  yield effects.put({
549
580
  type: reducers.REGISTER_USER_SUCCESS,
550
581
  user: mappedResponse || responseBody
@@ -563,24 +594,25 @@ function* registerSaga({
563
594
  // or status codes echoed from the responses received from
564
595
  // management api when registering the user
565
596
  const [, errorResponse] = yield to.to(response.json());
566
- const error = errorResponse && errorResponse.error || errorResponse || {};
567
- // Get something meaningful from the response if there is no message in the body
597
+ const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
598
+
568
599
  if (!error.message) {
569
600
  error.message = `Registration service: ${response.statusText}`;
570
601
  error.status = response.status;
571
602
  }
603
+
572
604
  yield effects.put({
573
605
  type: reducers.REGISTER_USER_FAILED,
574
606
  error
575
607
  });
576
608
  }
577
609
  }
610
+
578
611
  function* redirectSaga() {
579
612
  // Check if querystring contains a redirect_uri
580
613
  const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
581
- const redirectUri = currentQs.redirect_uri || currentQs.redirect;
614
+ const redirectUri = currentQs.redirect_uri || currentQs.redirect; // We must use redux based navigation to preserve the registration state
582
615
 
583
- // We must use redux based navigation to preserve the registration state
584
616
  if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
585
617
  }
586
618
 
@@ -598,36 +630,36 @@ const BASE_OPTIONS = {
598
630
  };
599
631
  class UserHelper {
600
632
  static async GetUsersEnvironments(securityToken) {
601
- const options = {
602
- ...BASE_OPTIONS,
633
+ const options = { ...BASE_OPTIONS,
603
634
  headers: {
604
635
  'x-security-token': securityToken
605
636
  }
606
637
  };
607
638
  return await UserHelper.get(USER_ENVS_URL, options);
608
639
  }
640
+
609
641
  static async ResendUserVerification(userEmail) {
610
- const options = {
611
- ...BASE_OPTIONS
642
+ const options = { ...BASE_OPTIONS
612
643
  };
613
644
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
614
645
  }
646
+
615
647
  static async RequestPasswordReset(userEmailObject) {
616
- const options = {
617
- ...BASE_OPTIONS,
648
+ const options = { ...BASE_OPTIONS,
618
649
  body: JSON.stringify(userEmailObject)
619
650
  };
620
651
  options.method = 'POST';
621
652
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
622
653
  }
654
+
623
655
  static async ResetPassword(resetPasswordObject) {
624
- const options = {
625
- ...BASE_OPTIONS,
656
+ const options = { ...BASE_OPTIONS,
626
657
  body: JSON.stringify(resetPasswordObject)
627
658
  };
628
659
  options.method = 'POST';
629
660
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
630
661
  }
662
+
631
663
  static async get(url, options = BASE_OPTIONS) {
632
664
  try {
633
665
  const responseBody = await api(url, options);
@@ -640,7 +672,9 @@ class UserHelper {
640
672
  };
641
673
  }
642
674
  }
675
+
643
676
  }
677
+
644
678
  async function api(url, options) {
645
679
  return fetch(url, options).then(async response => {
646
680
  return response.json().then(data => data);
@@ -650,14 +684,17 @@ async function api(url, options) {
650
684
  }
651
685
 
652
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
+
653
688
  function* requestPasswordResetSaga(action) {
654
689
  const userEmailObject = action.userEmailObject;
655
690
  yield effects.put({
656
691
  type: reducers.REQUEST_USER_PASSWORD_RESET_SENDING
657
692
  });
693
+
658
694
  if (userEmailObject && userEmailObject.userEmail) {
659
695
  try {
660
696
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
697
+
661
698
  if (passwordResetRequestResponse) {
662
699
  if (!passwordResetRequestResponse.error) {
663
700
  yield effects.put({
@@ -688,14 +725,17 @@ function* requestPasswordResetSaga(action) {
688
725
  });
689
726
  }
690
727
  }
728
+
691
729
  function* resetPasswordSaga(action) {
692
730
  const resetPasswordObject = action.resetPasswordObject;
693
731
  yield effects.put({
694
732
  type: reducers.RESET_USER_PASSWORD_SENDING
695
733
  });
734
+
696
735
  if (resetPasswordObject.token && resetPasswordObject.password) {
697
736
  try {
698
737
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
738
+
699
739
  if (resetPasswordResponse) {
700
740
  if (!resetPasswordResponse.error) {
701
741
  yield effects.put({
@@ -726,11 +766,11 @@ function* resetPasswordSaga(action) {
726
766
  error: 'Invalid object'
727
767
  });
728
768
  }
729
- }
730
-
731
- // userId
769
+ } // userId
732
770
  // existingPassword
733
771
  // newPassword
772
+
773
+
734
774
  function* changePasswordSaga(action) {
735
775
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
736
776
  yield effects.put({
@@ -739,6 +779,7 @@ function* changePasswordSaga(action) {
739
779
  });
740
780
  return;
741
781
  }
782
+
742
783
  try {
743
784
  const changePasswordObject = {
744
785
  userId: action.userId,
@@ -749,24 +790,25 @@ function* changePasswordSaga(action) {
749
790
  type: reducers.CHANGE_USER_PASSWORD_SENDING
750
791
  });
751
792
  const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
752
- const client = yield ChangePassword_container.getManagementApiClient({
753
- ...clientCredentials
793
+ const client = yield ChangePassword_container.getManagementApiClient({ ...clientCredentials
754
794
  });
755
795
  const [err, res] = yield to.to(client.security.users.updatePassword(changePasswordObject));
796
+
756
797
  if (err) {
757
798
  var _err$data, _err$data$data, _err$data2;
799
+
758
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);
759
801
  yield effects.put({
760
802
  type: reducers.CHANGE_USER_PASSWORD_ERROR,
761
803
  error
762
804
  });
763
805
  return;
764
- }
765
-
766
- // // eslint-disable-next-line no-console
806
+ } // // eslint-disable-next-line no-console
767
807
  // console.log(changePasswordObject);
768
808
  // // eslint-disable-next-line no-console
769
809
  // console.log(userCredentialsObject);
810
+
811
+
770
812
  yield effects.put({
771
813
  type: reducers.CHANGE_USER_PASSWORD_SUCCESS
772
814
  });
@@ -788,32 +830,35 @@ function rootSaga (featureSagas = []) {
788
830
  };
789
831
  }
790
832
 
791
- const servers = SERVERS; /* global SERVERS */
833
+ const servers = SERVERS;
834
+ /* global SERVERS */
835
+
792
836
  const alias = servers.alias.toLowerCase();
793
- const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
794
- const projects = PROJECTS; /* global PROJECTS */
837
+ const publicUri = PUBLIC_URI;
838
+ /* global PUBLIC_URI */
795
839
 
840
+ const projects = PROJECTS;
841
+ /* global PROJECTS */
796
842
  // return a projectId via the request hostname
843
+
797
844
  const pickProject = (hostname, query) => {
798
845
  // if localhost we can only infer via a querystring, and take your word for it
799
846
  if (hostname == 'localhost') {
800
847
  return query && query.p || projects[0].id;
801
- }
848
+ } // if hostname is the actual public uri we can return the first project from the list
849
+
802
850
 
803
- // if hostname is the actual public uri we can return the first project from the list
804
851
  if (hostname == publicUri) {
805
852
  return projects[0].id;
806
853
  }
807
- let project = 'unknown';
808
854
 
809
- // // go through all the defined projects
855
+ let project = 'unknown'; // // go through all the defined projects
810
856
  // Object.entries(projects).map(([, p]) => {
811
- const p = projects[0];
812
857
 
813
- // check if we're accessing via the project's public uri
814
- if (hostname.includes(p.publicUri)) project = p.id;
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)
815
861
 
816
- // the url structure is different for website (we don't prefix)
817
862
  if (p.id.startsWith('website')) {
818
863
  // check for internal and external hostnames
819
864
  // we check live and preview distinctly so our rule does not clash with
@@ -822,8 +867,9 @@ const pickProject = (hostname, query) => {
822
867
  } else {
823
868
  // check for internal and external hostnames, prefixed with the projectId
824
869
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
825
- }
826
- // });
870
+ } // });
871
+
872
+
827
873
  return project === 'unknown' ? p.id : project;
828
874
  };
829
875
 
@@ -836,4 +882,4 @@ exports.browserHistory = browserHistory;
836
882
  exports.history = history;
837
883
  exports.pickProject = pickProject;
838
884
  exports.rootSaga = rootSaga;
839
- //# sourceMappingURL=App-cf7e3103.js.map
885
+ //# sourceMappingURL=App-b56aca04.js.map