@zengenti/contensis-react-base 3.0.2-beta.1 → 3.0.2-beta.10

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 (101) hide show
  1. package/cjs/{App-ee485b92.js → App-81a45001.js} +111 -427
  2. package/cjs/App-81a45001.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-de88df2a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-47d70a26.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-61c03582.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-61c03582.js.map} +1 -1
  9. package/cjs/client.js +20 -27
  10. package/cjs/client.js.map +1 -1
  11. package/cjs/contensis-react-base.js +124 -188
  12. package/cjs/contensis-react-base.js.map +1 -1
  13. package/cjs/forms.js +15 -154
  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-840860bc.js → login-51b66359.js} +64 -113
  18. package/cjs/login-51b66359.js.map +1 -0
  19. package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
  20. package/cjs/reducers-9afb5f89.js.map +1 -0
  21. package/cjs/redux.js +17 -17
  22. package/cjs/redux.js.map +1 -1
  23. package/cjs/routing.js +6 -7
  24. package/cjs/routing.js.map +1 -1
  25. package/cjs/{sagas-e2a34262.js → sagas-6d12e7ca.js} +183 -282
  26. package/cjs/sagas-6d12e7ca.js.map +1 -0
  27. package/cjs/search.js +56 -82
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-c76c2676.js} +84 -7
  30. package/cjs/selectors-c76c2676.js.map +1 -0
  31. package/cjs/urls-6fcaf4c6.js.map +1 -1
  32. package/cjs/user.js +4 -13
  33. package/cjs/user.js.map +1 -1
  34. package/cjs/util.js +45 -53
  35. package/cjs/util.js.map +1 -1
  36. package/cjs/{version-78dfc3bd.js → version-38afaf2a.js} +45 -158
  37. package/cjs/version-38afaf2a.js.map +1 -0
  38. package/cjs/version-886f49d8.js +98 -0
  39. package/cjs/version-886f49d8.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-5f914483.js} +93 -407
  41. package/esm/App-5f914483.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-ad06857d.js +227 -0
  43. package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-f5d5f733.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-0066e629.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-0066e629.js.map} +1 -1
  48. package/esm/client.js +15 -22
  49. package/esm/client.js.map +1 -1
  50. package/esm/contensis-react-base.js +119 -183
  51. package/esm/contensis-react-base.js.map +1 -1
  52. package/esm/forms.js +15 -154
  53. package/esm/forms.js.map +1 -1
  54. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
  55. package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
  56. package/esm/{login-57395c9c.js → login-4d07c2de.js} +63 -112
  57. package/esm/login-4d07c2de.js.map +1 -0
  58. package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
  59. package/esm/reducers-3d5c37d1.js.map +1 -0
  60. package/esm/redux.js +9 -8
  61. package/esm/redux.js.map +1 -1
  62. package/esm/routing.js +3 -4
  63. package/esm/routing.js.map +1 -1
  64. package/esm/{sagas-bb925ef4.js → sagas-53d2aefb.js} +135 -235
  65. package/esm/sagas-53d2aefb.js.map +1 -0
  66. package/esm/search.js +57 -83
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-3f0d804d.js} +70 -7
  69. package/esm/selectors-3f0d804d.js.map +1 -0
  70. package/esm/urls-eac9a747.js.map +1 -1
  71. package/esm/user.js +6 -15
  72. package/esm/user.js.map +1 -1
  73. package/esm/util.js +42 -53
  74. package/esm/util.js.map +1 -1
  75. package/esm/{version-e3a5ec66.js → version-dd31c7f0.js} +32 -141
  76. package/esm/version-dd31c7f0.js.map +1 -0
  77. package/esm/version-f4629693.js +87 -0
  78. package/esm/version-f4629693.js.map +1 -0
  79. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  80. package/models/util/index.d.ts +1 -0
  81. package/package.json +1 -1
  82. package/cjs/App-ee485b92.js.map +0 -1
  83. package/cjs/actions-8dc9e8de.js +0 -87
  84. package/cjs/actions-8dc9e8de.js.map +0 -1
  85. package/cjs/login-840860bc.js.map +0 -1
  86. package/cjs/reducers-3a4f8971.js.map +0 -1
  87. package/cjs/sagas-e2a34262.js.map +0 -1
  88. package/cjs/selectors-656da4b7.js.map +0 -1
  89. package/cjs/version-78dfc3bd.js.map +0 -1
  90. package/cjs/version-eba6d09b.js +0 -20
  91. package/cjs/version-eba6d09b.js.map +0 -1
  92. package/esm/App-640239d2.js.map +0 -1
  93. package/esm/actions-180948dd.js +0 -72
  94. package/esm/actions-180948dd.js.map +0 -1
  95. package/esm/login-57395c9c.js.map +0 -1
  96. package/esm/reducers-8e5d6232.js.map +0 -1
  97. package/esm/sagas-bb925ef4.js.map +0 -1
  98. package/esm/selectors-a5e5835b.js.map +0 -1
  99. package/esm/version-2485e2fb.js +0 -15
  100. package/esm/version-2485e2fb.js.map +0 -1
  101. package/esm/version-e3a5ec66.js.map +0 -1
@@ -1,294 +1,22 @@
1
1
  import { createBrowserHistory, createMemoryHistory } from 'history';
2
2
  import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
3
3
  import * as log from 'loglevel';
4
- import { Client, Op, Query } from 'contensis-delivery-api';
5
- import { parse } from 'query-string';
6
- import { a as setSurrogateKeys, S as SET_NAVIGATION_PATH, b as SET_ROUTE, U as UPDATE_LOADING_STATE, c as SET_ENTRY, d as SET_ANCESTORS, e as SET_SIBLINGS, f as setRoute } from './actions-180948dd.js';
7
- import { r as reduxStore, G as GET_NODE_TREE, h as hasNavigationTree, S as SET_NODE_TREE, b as GET_NODE_TREE_ERROR, i as injectRedux } from './version-e3a5ec66.js';
8
- import { s as selectVersionStatus } from './version-2485e2fb.js';
9
- import { b as selectCurrentProject, a as selectRouteEntry, c as selectCurrentNode, d as selectCurrentAncestors, e as selectCurrentSiblings, f as selectRouteEntryEntryId, h as selectRouteEntryLanguage, i as selectMappedEntry, q as queryParams, j as selectCurrentSearch } from './selectors-a5e5835b.js';
10
- import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-57395c9c.js';
4
+ import { d as deliveryApi, c as cachedSearch } from './ContensisDeliveryApi-ad06857d.js';
5
+ import { G as GET_NODE_TREE, s as selectVersionStatus, S as SET_NODE_TREE, a as GET_NODE_TREE_ERROR } from './version-dd31c7f0.js';
6
+ import { h as hasNavigationTree, i as injectRedux } from './version-f4629693.js';
7
+ import { b as selectCurrentProject, S as SET_NAVIGATION_PATH, d as SET_ROUTE, a as selectRouteEntry, e as selectCurrentNode, U as UPDATE_LOADING_STATE, f as selectCurrentAncestors, h as selectCurrentSiblings, i as selectRouteEntryEntryId, j as selectRouteEntryLanguage, k as selectMappedEntry, l as SET_ENTRY, m as SET_ANCESTORS, n as SET_SIBLINGS, q as queryParams, o as selectCurrentSearch, p as setRoute } from './selectors-3f0d804d.js';
8
+ import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-4d07c2de.js';
9
+ import { Op, Query } from 'contensis-delivery-api';
11
10
  import { to } from 'await-to-js';
12
- import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-8e5d6232.js';
13
- import { s as selectClientCredentials } from './ToJs-4e02a04d.js';
11
+ import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-3d5c37d1.js';
12
+ import { s as selectClientCredentials } from './ToJs-0066e629.js';
14
13
  import React from 'react';
15
14
  import 'react-hot-loader';
16
15
  import 'jsonpath-mapper';
17
- import { R as RouteLoader } from './RouteLoader-5171c63f.js';
18
-
19
- const storeSurrogateKeys = response => {
20
- const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
21
- if (keys) reduxStore === null || reduxStore === void 0 ? void 0 : reduxStore.dispatch(setSurrogateKeys(keys, response.url));
22
- };
23
-
24
- const getClientConfig = project => {
25
- let config = DELIVERY_API_CONFIG;
26
- /* global DELIVERY_API_CONFIG */
27
-
28
- config.responseHandler = {};
29
-
30
- if (project) {
31
- config.projectId = project;
32
- } // we only want the surrogate key header in a server context
33
-
34
-
35
- if (typeof window === 'undefined') {
36
- config.defaultHeaders = {
37
- 'x-require-surrogate-key': true
38
- };
39
- config.responseHandler[200] = storeSurrogateKeys;
40
- }
41
-
42
- if (typeof window !== 'undefined' && PROXY_DELIVERY_API
43
- /* global PROXY_DELIVERY_API */
44
- ) {
45
- // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
46
- config.rootUrl = '';
47
-
48
- config.responseHandler[404] = () => null;
49
- }
50
-
51
- return config;
52
- };
53
-
54
- class DeliveryApi {
55
- constructor() {
56
- this.getClientSideVersionStatus = () => {
57
- if (typeof window !== 'undefined') {
58
- // Allow overriding versionStatus with the querystring
59
- const {
60
- versionStatus
61
- } = parse(window.location.search);
62
- if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
63
-
64
- if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
65
-
66
- const currentHostname = window.location.hostname;
67
- return this.getVersionStatusFromHostname(currentHostname);
68
- }
69
-
70
- return null;
71
- };
72
-
73
- this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
74
-
75
- this.getVersionStatusFromHeaders = headers => {
76
- const versionStatusHeader = headers['x-entry-versionstatus'];
77
- if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
78
- return null;
79
- };
80
-
81
- this.getVersionStatusFromHostname = currentHostname => {
82
- if (currentHostname.indexOf('localhost') > -1) return 'latest';
83
-
84
- if (currentHostname.endsWith('contensis.cloud')) {
85
- if (currentHostname.indexOf('preview.') > -1) {
86
- return 'latest';
87
- } else {
88
- return 'published';
89
- }
90
- }
91
-
92
- if (currentHostname.endsWith('cloud.contensis.com')) {
93
- if (currentHostname.indexOf('preview-') > -1) {
94
- return 'latest';
95
- } else {
96
- return 'published';
97
- }
98
- }
99
-
100
- return 'published';
101
- };
102
-
103
- this.search = (query, linkDepth, project, env) => {
104
- const client = Client.create(getClientConfig(project));
105
- return client.entries.search(query, typeof linkDepth !== 'undefined' ? linkDepth : 1);
106
- };
107
-
108
- this.getClient = (deliveryApiStatus = 'published', project, env) => {
109
- const baseConfig = getClientConfig(project);
110
- baseConfig.versionStatus = deliveryApiStatus;
111
- return Client.create(baseConfig);
112
- };
113
-
114
- this.getEntry = (id, linkDepth = 0, deliveryApiStatus = 'published', project, env) => {
115
- const baseConfig = getClientConfig(project);
116
- baseConfig.versionStatus = deliveryApiStatus;
117
- const client = Client.create(baseConfig); // return client.entries.get(id, linkDepth);
118
-
119
- return client.entries.get({
120
- id,
121
- linkDepth
122
- });
123
- };
124
- }
125
-
126
- }
127
-
128
- const deliveryApi = new DeliveryApi();
129
-
130
- class CacheNode {
131
- constructor(key, value) {
132
- this.key = key;
133
- this.value = value;
134
- this.next = null;
135
- this.prev = null;
136
- }
137
-
138
- }
139
-
140
- class LruCache {
141
- constructor(limit = 100) {
142
- this.map = {};
143
- this.head = null;
144
- this.tail = null;
145
- this.limit = limit || 100;
146
- this.size = 0;
147
- }
148
-
149
- get(key) {
150
- if (this.map[key]) {
151
- let value = this.map[key].value;
152
- let node = new CacheNode(key, value);
153
- this.remove(key);
154
- this.setHead(node);
155
- return value;
156
- }
157
- }
158
-
159
- set(key, value) {
160
- let node = new CacheNode(key, value);
161
-
162
- if (this.map[key]) {
163
- this.remove(key);
164
- } else {
165
- if (this.size >= this.limit) {
166
- delete this.map[this.tail.key];
167
- this.size--;
168
- this.tail = this.tail.prev;
169
- this.tail.next = null;
170
- }
171
- }
172
-
173
- this.setHead(node);
174
- }
175
-
176
- setHead(node) {
177
- node.next = this.head;
178
- node.prev = null;
179
-
180
- if (this.head) {
181
- this.head.prev = node;
182
- }
183
-
184
- this.head = node;
185
-
186
- if (!this.tail) {
187
- this.tail = node;
188
- }
189
-
190
- this.size++;
191
- this.map[node.key] = node;
192
- }
193
-
194
- remove(key) {
195
- let node = this.map[key];
196
- if (!node) return; // This is sometimes null and crashes the container without this check
197
-
198
- if (node.prev) {
199
- node.prev.next = node.next;
200
- } else {
201
- this.head = node.next;
202
- }
203
-
204
- if (node.next) {
205
- node.next.prev = node.prev;
206
- } else {
207
- this.tail = node.prev;
208
- }
209
-
210
- delete this.map[key];
211
- this.size--;
212
- }
213
-
214
- }
215
-
216
- class CachedSearch {
217
- constructor() {
218
- this.cache = new LruCache();
219
- this.taxonomyLookup = {};
220
- }
221
-
222
- search(query, linkDepth, project, env) {
223
- const client = Client.create(getClientConfig(project));
224
- return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
225
- }
226
-
227
- searchUsingPost(query, linkDepth = 0, project = '', env) {
228
- const client = Client.create(getClientConfig(project));
229
- return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
230
- }
231
-
232
- get(id, linkDepth, versionStatus, project, env) {
233
- const client = Client.create(getClientConfig(project));
234
- client.clientConfig.versionStatus = versionStatus;
235
- return this.request(id, () => client.entries.get({
236
- id,
237
- linkDepth
238
- }));
239
- }
240
-
241
- getContentType(id, project, env) {
242
- const client = Client.create(getClientConfig(project));
243
- return this.request(`[CONTENT TYPE] ${id} ${project}`, () => client.contentTypes.get(id));
244
- }
245
-
246
- getTaxonomyNode(key, project, env) {
247
- const client = Client.create(getClientConfig(project));
248
- return this.request(`[TAXONOMY NODE] ${key}`, () => client.taxonomy.resolveChildren(key).then(node => this.extendTaxonomyNode(node)));
249
- }
250
-
251
- getRootNode(options, project, env) {
252
- const client = Client.create(getClientConfig(project));
253
- return this.request(`${project} / ${JSON.stringify(options)}`, () => client.nodes.getRoot(options));
254
- }
255
-
256
- getNode(options, project, env) {
257
- const client = Client.create(getClientConfig(project));
258
- return this.request(`${project} ${options && options.path || options} ${JSON.stringify(options)}`, () => client.nodes.get(options));
259
- }
260
-
261
- getAncestors(options, project, env) {
262
- const client = Client.create(getClientConfig(project));
263
- return this.request(`${project} [A] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getAncestors(options));
264
- }
265
-
266
- getChildren(options, project, env) {
267
- const client = Client.create(getClientConfig(project));
268
- return this.request(`${project} [C] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getChildren(options));
269
- }
270
-
271
- getSiblings(options, project, env) {
272
- const client = Client.create(getClientConfig(project));
273
- return this.request(`${project} [S] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getSiblings(options));
274
- }
275
-
276
- request(key, execute) {
277
- if (!this.cache.get(key) || typeof window == 'undefined') {
278
- let promise = execute();
279
- this.cache.set(key, promise);
280
- promise.catch(() => {
281
- this.cache.remove(key);
282
- });
283
- }
284
-
285
- return this.cache.get(key);
286
- }
287
-
288
- }
289
-
290
- const cachedSearch = new CachedSearch();
16
+ import 'query-string';
17
+ import { R as RouteLoader } from './RouteLoader-f5d5f733.js';
291
18
 
19
+ // Create a history depending on the environment
292
20
  const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
293
21
  const history = (options = {}) => selectedHistory(options);
294
22
  const browserHistory = selectedHistory();
@@ -296,7 +24,6 @@ const browserHistory = selectedHistory();
296
24
  const navigationSagas = [takeEvery(GET_NODE_TREE, ensureNodeTreeSaga)];
297
25
  function* ensureNodeTreeSaga(action) {
298
26
  const state = yield select();
299
-
300
27
  try {
301
28
  if (!hasNavigationTree(state)) {
302
29
  const deliveryApiVersionStatus = yield select(selectVersionStatus);
@@ -304,7 +31,6 @@ function* ensureNodeTreeSaga(action) {
304
31
  const nodes = yield deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
305
32
  depth: action.treeDepth || 0
306
33
  });
307
-
308
34
  if (nodes) {
309
35
  yield put({
310
36
  type: SET_NODE_TREE,
@@ -351,7 +77,6 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
351
77
  const defaultExpressions = versionStatus => {
352
78
  return [Op.equalTo(Fields.sys.versionStatus, versionStatus)];
353
79
  };
354
-
355
80
  const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [Op[operator](field, arr[0])] : [Op.in(field, ...arr)];
356
81
 
357
82
  const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
@@ -361,11 +86,11 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
361
86
  };
362
87
 
363
88
  const routingSagas = [takeEvery(SET_NAVIGATION_PATH, getRouteSaga), takeEvery(SET_ROUTE, setRouteSaga)];
89
+
364
90
  /**
365
91
  * To navigate / push a specific route via redux middleware
366
92
  * @param {path, state} action
367
93
  */
368
-
369
94
  function* setRouteSaga(action) {
370
95
  yield put({
371
96
  type: 'CALL_HISTORY_METHOD',
@@ -375,37 +100,35 @@ function* setRouteSaga(action) {
375
100
  }
376
101
  });
377
102
  }
378
-
379
103
  function* getRouteSaga(action) {
380
104
  let entry = null;
381
-
382
105
  try {
383
106
  var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
384
-
385
107
  const {
386
108
  withEvents,
387
109
  routes: {
388
110
  ContentTypeMappings = {}
389
111
  } = {},
390
112
  staticRoute
391
- } = action; // Inject redux { key, reducer, saga } provided by staticRoute
113
+ } = action;
392
114
 
393
- if (staticRoute && staticRoute.route.injectRedux) yield call(reduxInjectorSaga, staticRoute.route.injectRedux); // Variables we will pass to setRouteEntry
115
+ // Inject redux { key, reducer, saga } provided by staticRoute
116
+ if (staticRoute && staticRoute.route.injectRedux) yield call(reduxInjectorSaga, staticRoute.route.injectRedux);
394
117
 
118
+ // Variables we will pass to setRouteEntry
395
119
  let pathNode = null,
396
- ancestors = null,
397
- children = [],
398
- siblings = null;
399
- let contentTypeMapping = {}; // These variables are the return values from
400
- // calls to withEvents.onRouteLoad and onRouteLoaded
120
+ ancestors = null,
121
+ children = [],
122
+ siblings = null;
123
+ let contentTypeMapping = {};
401
124
 
125
+ // These variables are the return values from
126
+ // calls to withEvents.onRouteLoad and onRouteLoaded
402
127
  let appsays,
403
- requireLogin = false;
404
-
128
+ requireLogin = false;
405
129
  if (withEvents && withEvents.onRouteLoad) {
406
130
  appsays = yield withEvents.onRouteLoad(action);
407
131
  }
408
-
409
132
  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;
410
133
  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;
411
134
  const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
@@ -414,30 +137,29 @@ function* getRouteSaga(action) {
414
137
  const routeEntry = selectRouteEntry(state, 'js');
415
138
  const routeNode = selectCurrentNode(state, 'js');
416
139
  const currentPath = action.path; //selectCurrentPath(state);
417
-
418
140
  const deliveryApiStatus = selectVersionStatus(state);
419
- const project = selectCurrentProject(state); // const isHome = currentPath === '/';
420
-
141
+ const project = selectCurrentProject(state);
142
+ // const isHome = currentPath === '/';
421
143
  const isPreview = currentPath && currentPath.startsWith('/preview/');
422
144
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
423
-
424
145
  if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
425
146
  // To prevent erroneous 404s and wasted network calls, this covers
426
147
  // - appsays customRouting and does SET_ENTRY etc. via the consuming app
427
148
  // - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
428
149
  // - standard Contensis SiteView Routing where we already have that entry in state
429
150
  if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
430
- pathNode = { ...routeNode,
151
+ pathNode = {
152
+ ...routeNode,
431
153
  entry: null
432
154
  };
433
- pathNode.entry = entry = routeEntry; //Do nothing, the entry is allready the right one.
155
+ pathNode.entry = entry = routeEntry;
156
+ //Do nothing, the entry is allready the right one.
434
157
  // yield put({
435
158
  // type: SET_ENTRY,
436
159
  // entry,
437
160
  // node: routeNode,
438
161
  // isLoading: false,
439
162
  // });
440
-
441
163
  yield put({
442
164
  type: UPDATE_LOADING_STATE,
443
165
  isLoading: false
@@ -449,11 +171,11 @@ function* getRouteSaga(action) {
449
171
  let splitPath = currentPath.split('/');
450
172
  let entryGuid = splitPath[2];
451
173
  let language = defaultLang;
452
-
453
174
  if (splitPath.length >= 3) {
454
175
  //set lang key if available in the path, else use default lang
455
176
  //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
456
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
177
+ if (splitPath.length == 4) language = splitPath[3];
178
+ // According to product dev we cannot use Node API
457
179
  // for previewing entries as it gives a response of []
458
180
  // -- apparently it is not correct to request latest content
459
181
  // with Node API
@@ -463,7 +185,6 @@ function* getRouteSaga(action) {
463
185
  language,
464
186
  linkDepth: entryLinkDepth
465
187
  });
466
-
467
188
  if (previewEntry) {
468
189
  pathNode = {
469
190
  entry: previewEntry
@@ -475,7 +196,6 @@ function* getRouteSaga(action) {
475
196
  }
476
197
  } else {
477
198
  var _pathNode, _pathNode$entry, _pathNode$entry$sys;
478
-
479
199
  // Handle all other routes
480
200
  pathNode = yield cachedSearch.getNode({
481
201
  depth: 0,
@@ -488,10 +208,8 @@ function* getRouteSaga(action) {
488
208
  ({
489
209
  entry
490
210
  } = pathNode || {});
491
-
492
211
  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) {
493
212
  var _payload$items;
494
-
495
213
  // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
496
214
  // and current node's ordinates at a specified depth with specified fields
497
215
  contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
@@ -501,15 +219,14 @@ function* getRouteSaga(action) {
501
219
  } = contentTypeMapping;
502
220
  const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
503
221
  const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
504
-
505
222
  if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
506
223
  pathNode.entry = entry = payload.items[0];
507
224
  }
508
225
  }
509
- } // make calls to fetch node ancestors, children,
510
- // siblings or entire node tree
511
-
226
+ }
512
227
 
228
+ // make calls to fetch node ancestors, children,
229
+ // siblings or entire node tree
513
230
  [ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
514
231
  appsays,
515
232
  contentTypeMapping,
@@ -521,37 +238,34 @@ function* getRouteSaga(action) {
521
238
  });
522
239
  if (children) pathNode.children = children;
523
240
  }
241
+ const resolvedContentTypeMapping = 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) || {};
524
242
 
525
- const resolvedContentTypeMapping = 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
526
-
243
+ // Inject redux { key, reducer, saga } provided by ContentTypeMapping
527
244
  if (resolvedContentTypeMapping.injectRedux) yield call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
528
-
529
245
  if (withEvents && withEvents.onRouteLoaded) {
530
246
  // Check if the app has provided a requireLogin boolean flag or groups array
531
247
  // in addition to checking if requireLogin is set in the route definition
532
248
  ({
533
249
  requireLogin
534
- } = (yield withEvents.onRouteLoaded({ ...action,
250
+ } = (yield withEvents.onRouteLoaded({
251
+ ...action,
535
252
  entry
536
253
  })) || {});
537
254
  }
538
-
539
255
  if (requireLogin !== false) {
540
256
  // Do not call the login feature saga if requireLogin is false
541
- yield call(handleRequiresLoginSaga, { ...action,
257
+ yield call(handleRequiresLoginSaga, {
258
+ ...action,
542
259
  entry,
543
260
  requireLogin
544
261
  });
545
262
  }
546
-
547
263
  if (!appsays || !appsays.preventScrollTop) {
548
264
  // Scroll into View
549
265
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
550
266
  }
551
-
552
267
  if ((_pathNode3 = pathNode) !== null && _pathNode3 !== void 0 && (_pathNode3$entry = _pathNode3.entry) !== null && _pathNode3$entry !== void 0 && (_pathNode3$entry$sys = _pathNode3$entry.sys) !== null && _pathNode3$entry$sys !== void 0 && _pathNode3$entry$sys.id) {
553
268
  var _staticRoute$route3, _staticRoute$route3$f, _appsays;
554
-
555
269
  entry = pathNode.entry;
556
270
  yield 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);
557
271
  } else {
@@ -562,7 +276,6 @@ function* getRouteSaga(action) {
562
276
  yield call(do500, e);
563
277
  }
564
278
  }
565
-
566
279
  function* resolveCurrentNodeOrdinates({
567
280
  appsays,
568
281
  contentTypeMapping,
@@ -572,10 +285,11 @@ function* resolveCurrentNodeOrdinates({
572
285
  project,
573
286
  versionStatus
574
287
  }) {
575
- const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
288
+ const apiCall = [() => null, () => null, () => null, () => null];
289
+
290
+ // if appsays customNavigation: true, we will set doNavigation to false
576
291
  // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
577
292
  // if appsays nothing we will set doNavigation to true and continue to do navigation calls
578
-
579
293
  const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
580
294
  const {
581
295
  entryLinkDepth = 0,
@@ -583,7 +297,6 @@ function* resolveCurrentNodeOrdinates({
583
297
  linkDepth,
584
298
  nodeOptions = {}
585
299
  } = contentTypeMapping;
586
-
587
300
  if (pathNode && pathNode.id) {
588
301
  if (doNavigation === true || doNavigation.ancestors) {
589
302
  apiCall[0] = function* getAncestors() {
@@ -599,12 +312,9 @@ function* resolveCurrentNodeOrdinates({
599
312
  }
600
313
  };
601
314
  }
602
-
603
315
  const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
604
-
605
316
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
606
317
  const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
607
-
608
318
  apiCall[1] = function* getChildren() {
609
319
  try {
610
320
  return yield cachedSearch.getNode({
@@ -621,12 +331,10 @@ function* resolveCurrentNodeOrdinates({
621
331
  }
622
332
  };
623
333
  }
624
-
625
334
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
626
335
  apiCall[2] = function* getSiblings() {
627
336
  try {
628
337
  var _nodeOptions$siblings, _nodeOptions$siblings2;
629
-
630
338
  return yield cachedSearch.getSiblings({
631
339
  id: pathNode.id,
632
340
  entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
@@ -642,11 +350,9 @@ function* resolveCurrentNodeOrdinates({
642
350
  };
643
351
  }
644
352
  }
645
-
646
353
  const isTreeLoaded = yield select(hasNavigationTree);
647
354
  if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
648
355
  const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
649
-
650
356
  if (typeof window !== 'undefined') {
651
357
  return yield put({
652
358
  type: GET_NODE_TREE,
@@ -662,12 +368,16 @@ function* resolveCurrentNodeOrdinates({
662
368
  const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
663
369
  return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
664
370
  }
665
-
666
371
  function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
667
372
  const entrySys = entry && entry.sys || {};
373
+
374
+ // Update a window global to provide the preview toolbar
375
+ // an updated entry id in client-side navigation
376
+ if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
668
377
  const currentEntryId = yield select(selectRouteEntryEntryId);
669
378
  const currentEntryLang = yield select(selectRouteEntryLanguage);
670
- const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, { ...node,
379
+ const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
380
+ ...node,
671
381
  entry,
672
382
  ancestors,
673
383
  siblings
@@ -687,7 +397,6 @@ function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound
687
397
  siblings
688
398
  })]);
689
399
  }
690
-
691
400
  function* mapRouteEntry(entryMapper, node) {
692
401
  try {
693
402
  if (typeof entryMapper === 'function') {
@@ -698,10 +407,8 @@ function* mapRouteEntry(entryMapper, node) {
698
407
  } catch (e) {
699
408
  log.error(...['Error running entryMapper:', e, e.stack]);
700
409
  }
701
-
702
410
  return;
703
411
  }
704
-
705
412
  function* do404() {
706
413
  yield call(clientReloadHitServer);
707
414
  yield put({
@@ -711,17 +418,16 @@ function* do404() {
711
418
  notFound: true
712
419
  });
713
420
  }
714
-
715
421
  function* clientReloadHitServer() {
716
- const stateEntry = yield select(selectRouteEntry); // If in client and there is a stateEntry.sys field reload the page,
422
+ const stateEntry = yield select(selectRouteEntry);
423
+
424
+ // If in client and there is a stateEntry.sys field reload the page,
717
425
  // on the 2nd load stateEntry.sys should be null at this point,
718
426
  // we do not wish to reload again and get stuck in an infinite reloading loop
719
-
720
427
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
721
428
  window.location.reload();
722
429
  }
723
430
  }
724
-
725
431
  function* do500(error) {
726
432
  yield put({
727
433
  type: SET_ENTRY,
@@ -733,7 +439,6 @@ function* do500(error) {
733
439
  statusCode: error && error.status ? error.status : 500
734
440
  });
735
441
  }
736
-
737
442
  function* reduxInjectorSaga(injectorFn) {
738
443
  if (typeof injectorFn === 'function') {
739
444
  const {
@@ -750,19 +455,18 @@ function* reduxInjectorSaga(injectorFn) {
750
455
  }
751
456
 
752
457
  const registerSagas = [takeEvery(REGISTER_USER, registerSaga), takeEvery(REGISTER_USER_SUCCESS, redirectSaga)];
753
-
754
458
  function* registerSaga({
755
459
  user,
756
460
  mappers
757
461
  }) {
758
- let requestBody = user; // Allow use of request mapper to take a user object
462
+ let requestBody = user;
463
+ // Allow use of request mapper to take a user object
759
464
  // of any format and return the payload for the api request
760
-
761
465
  if (mappers && mappers.request && typeof mappers.request === 'function') {
762
466
  requestBody = yield mappers.request(user);
763
- } // Make POST call to register API
764
-
467
+ }
765
468
 
469
+ // Make POST call to register API
766
470
  const response = yield fetch('/account/register', {
767
471
  method: 'POST',
768
472
  headers: {
@@ -771,19 +475,16 @@ function* registerSaga({
771
475
  },
772
476
  body: JSON.stringify(requestBody)
773
477
  });
774
-
775
478
  if (response.ok) {
776
479
  let mappedResponse;
777
480
  const [, responseBody] = yield to(response.json());
778
-
779
481
  if (responseBody) {
780
482
  // Allow use of response mapper to convert the successful user object
781
483
  // from the api response body into a user object of any format
782
484
  if (mappers && mappers.response && typeof mappers.response === 'function') {
783
485
  mappedResponse = yield mappers.response(responseBody);
784
- } // Update user object with mappedResponse or responseBody
785
-
786
-
486
+ }
487
+ // Update user object with mappedResponse or responseBody
787
488
  yield put({
788
489
  type: REGISTER_USER_SUCCESS,
789
490
  user: mappedResponse || responseBody
@@ -802,25 +503,24 @@ function* registerSaga({
802
503
  // or status codes echoed from the responses received from
803
504
  // management api when registering the user
804
505
  const [, errorResponse] = yield to(response.json());
805
- const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
806
-
506
+ const error = errorResponse && errorResponse.error || errorResponse || {};
507
+ // Get something meaningful from the response if there is no message in the body
807
508
  if (!error.message) {
808
509
  error.message = `Registration service: ${response.statusText}`;
809
510
  error.status = response.status;
810
511
  }
811
-
812
512
  yield put({
813
513
  type: REGISTER_USER_FAILED,
814
514
  error
815
515
  });
816
516
  }
817
517
  }
818
-
819
518
  function* redirectSaga() {
820
519
  // Check if querystring contains a redirect_uri
821
520
  const currentQs = queryParams(yield select(selectCurrentSearch));
822
- const redirectUri = currentQs.redirect_uri || currentQs.redirect; // We must use redux based navigation to preserve the registration state
521
+ const redirectUri = currentQs.redirect_uri || currentQs.redirect;
823
522
 
523
+ // We must use redux based navigation to preserve the registration state
824
524
  if (redirectUri) yield put(setRoute(redirectUri));
825
525
  }
826
526
 
@@ -838,36 +538,36 @@ const BASE_OPTIONS = {
838
538
  };
839
539
  class UserHelper {
840
540
  static async GetUsersEnvironments(securityToken) {
841
- const options = { ...BASE_OPTIONS,
541
+ const options = {
542
+ ...BASE_OPTIONS,
842
543
  headers: {
843
544
  'x-security-token': securityToken
844
545
  }
845
546
  };
846
547
  return await UserHelper.get(USER_ENVS_URL, options);
847
548
  }
848
-
849
549
  static async ResendUserVerification(userEmail) {
850
- const options = { ...BASE_OPTIONS
550
+ const options = {
551
+ ...BASE_OPTIONS
851
552
  };
852
553
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
853
554
  }
854
-
855
555
  static async RequestPasswordReset(userEmailObject) {
856
- const options = { ...BASE_OPTIONS,
556
+ const options = {
557
+ ...BASE_OPTIONS,
857
558
  body: JSON.stringify(userEmailObject)
858
559
  };
859
560
  options.method = 'POST';
860
561
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
861
562
  }
862
-
863
563
  static async ResetPassword(resetPasswordObject) {
864
- const options = { ...BASE_OPTIONS,
564
+ const options = {
565
+ ...BASE_OPTIONS,
865
566
  body: JSON.stringify(resetPasswordObject)
866
567
  };
867
568
  options.method = 'POST';
868
569
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
869
570
  }
870
-
871
571
  static async get(url, options = BASE_OPTIONS) {
872
572
  try {
873
573
  const responseBody = await api(url, options);
@@ -880,9 +580,7 @@ class UserHelper {
880
580
  };
881
581
  }
882
582
  }
883
-
884
583
  }
885
-
886
584
  async function api(url, options) {
887
585
  return fetch(url, options).then(async response => {
888
586
  return response.json().then(data => data);
@@ -892,17 +590,14 @@ async function api(url, options) {
892
590
  }
893
591
 
894
592
  const resetPasswordSagas = [takeEvery(REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), takeEvery(RESET_USER_PASSWORD, resetPasswordSaga), takeEvery(CHANGE_USER_PASSWORD, changePasswordSaga)];
895
-
896
593
  function* requestPasswordResetSaga(action) {
897
594
  const userEmailObject = action.userEmailObject;
898
595
  yield put({
899
596
  type: REQUEST_USER_PASSWORD_RESET_SENDING
900
597
  });
901
-
902
598
  if (userEmailObject && userEmailObject.userEmail) {
903
599
  try {
904
600
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
905
-
906
601
  if (passwordResetRequestResponse) {
907
602
  if (!passwordResetRequestResponse.error) {
908
603
  yield put({
@@ -933,17 +628,14 @@ function* requestPasswordResetSaga(action) {
933
628
  });
934
629
  }
935
630
  }
936
-
937
631
  function* resetPasswordSaga(action) {
938
632
  const resetPasswordObject = action.resetPasswordObject;
939
633
  yield put({
940
634
  type: RESET_USER_PASSWORD_SENDING
941
635
  });
942
-
943
636
  if (resetPasswordObject.token && resetPasswordObject.password) {
944
637
  try {
945
638
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
946
-
947
639
  if (resetPasswordResponse) {
948
640
  if (!resetPasswordResponse.error) {
949
641
  yield put({
@@ -974,11 +666,11 @@ function* resetPasswordSaga(action) {
974
666
  error: 'Invalid object'
975
667
  });
976
668
  }
977
- } // userId
669
+ }
670
+
671
+ // userId
978
672
  // existingPassword
979
673
  // newPassword
980
-
981
-
982
674
  function* changePasswordSaga(action) {
983
675
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
984
676
  yield put({
@@ -987,7 +679,6 @@ function* changePasswordSaga(action) {
987
679
  });
988
680
  return;
989
681
  }
990
-
991
682
  try {
992
683
  const changePasswordObject = {
993
684
  userId: action.userId,
@@ -998,25 +689,24 @@ function* changePasswordSaga(action) {
998
689
  type: CHANGE_USER_PASSWORD_SENDING
999
690
  });
1000
691
  const clientCredentials = yield select(selectClientCredentials, 'js');
1001
- const client = yield getManagementApiClient({ ...clientCredentials
692
+ const client = yield getManagementApiClient({
693
+ ...clientCredentials
1002
694
  });
1003
695
  const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
1004
-
1005
696
  if (err) {
1006
697
  var _err$data, _err$data$data, _err$data2;
1007
-
1008
698
  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);
1009
699
  yield put({
1010
700
  type: CHANGE_USER_PASSWORD_ERROR,
1011
701
  error
1012
702
  });
1013
703
  return;
1014
- } // // eslint-disable-next-line no-console
704
+ }
705
+
706
+ // // eslint-disable-next-line no-console
1015
707
  // console.log(changePasswordObject);
1016
708
  // // eslint-disable-next-line no-console
1017
709
  // console.log(userCredentialsObject);
1018
-
1019
-
1020
710
  yield put({
1021
711
  type: CHANGE_USER_PASSWORD_SUCCESS
1022
712
  });
@@ -1038,35 +728,32 @@ function rootSaga (featureSagas = []) {
1038
728
  };
1039
729
  }
1040
730
 
1041
- const servers = SERVERS;
1042
- /* global SERVERS */
1043
-
731
+ const servers = SERVERS; /* global SERVERS */
1044
732
  const alias = servers.alias.toLowerCase();
1045
- const publicUri = PUBLIC_URI;
1046
- /* global PUBLIC_URI */
733
+ const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
734
+ const projects = PROJECTS; /* global PROJECTS */
1047
735
 
1048
- const projects = PROJECTS;
1049
- /* global PROJECTS */
1050
736
  // return a projectId via the request hostname
1051
-
1052
737
  const pickProject = (hostname, query) => {
1053
738
  // if localhost we can only infer via a querystring, and take your word for it
1054
739
  if (hostname == 'localhost') {
1055
740
  return query && query.p || projects[0].id;
1056
- } // if hostname is the actual public uri we can return the first project from the list
1057
-
741
+ }
1058
742
 
743
+ // if hostname is the actual public uri we can return the first project from the list
1059
744
  if (hostname == publicUri) {
1060
745
  return projects[0].id;
1061
746
  }
747
+ let project = 'unknown';
1062
748
 
1063
- let project = 'unknown'; // // go through all the defined projects
749
+ // // go through all the defined projects
1064
750
  // Object.entries(projects).map(([, p]) => {
751
+ const p = projects[0];
1065
752
 
1066
- const p = projects[0]; // check if we're accessing via the project's public uri
1067
-
1068
- if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
753
+ // check if we're accessing via the project's public uri
754
+ if (hostname.includes(p.publicUri)) project = p.id;
1069
755
 
756
+ // the url structure is different for website (we don't prefix)
1070
757
  if (p.id.startsWith('website')) {
1071
758
  // check for internal and external hostnames
1072
759
  // we check live and preview distinctly so our rule does not clash with
@@ -1075,9 +762,8 @@ const pickProject = (hostname, query) => {
1075
762
  } else {
1076
763
  // check for internal and external hostnames, prefixed with the projectId
1077
764
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
1078
- } // });
1079
-
1080
-
765
+ }
766
+ // });
1081
767
  return project === 'unknown' ? p.id : project;
1082
768
  };
1083
769
 
@@ -1085,5 +771,5 @@ const AppRoot = props => {
1085
771
  return /*#__PURE__*/React.createElement(RouteLoader, props);
1086
772
  };
1087
773
 
1088
- export { AppRoot as A, browserHistory as b, cachedSearch as c, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1089
- //# sourceMappingURL=App-640239d2.js.map
774
+ export { AppRoot as A, browserHistory as b, history as h, pickProject as p, rootSaga as r };
775
+ //# sourceMappingURL=App-5f914483.js.map