@zengenti/contensis-react-base 3.0.2-beta.4 → 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 (98) hide show
  1. package/cjs/{App-a2783f8b.js → App-2a7a16ad.js} +110 -429
  2. package/cjs/App-2a7a16ad.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 +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-e711a19e.js → login-2ea569cc.js} +60 -112
  18. package/cjs/{login-e711a19e.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 +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-8a20e424.js → sagas-6d12e7ca.js} +182 -282
  26. package/{esm/sagas-e576b6f6.js.map → cjs/sagas-6d12e7ca.js.map} +1 -1
  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-bf9ef45e.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-17d1ac3c.js → App-4fb1fc44.js} +92 -409
  41. package/esm/App-4fb1fc44.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 +11 -153
  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-551d243a.js → login-bffb081f.js} +59 -111
  57. package/esm/{login-551d243a.js.map → login-bffb081f.js.map} +1 -1
  58. package/esm/{reducers-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
  59. package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
  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-e576b6f6.js → sagas-53d2aefb.js} +134 -235
  65. package/{cjs/sagas-8a20e424.js.map → esm/sagas-53d2aefb.js.map} +1 -1
  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-72ca17f3.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/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
  80. package/models/user/components.styled/Login.styled.d.ts +1 -1
  81. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  82. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  83. package/models/util/index.d.ts +1 -0
  84. package/package.json +2 -2
  85. package/cjs/App-a2783f8b.js.map +0 -1
  86. package/cjs/actions-8dc9e8de.js +0 -87
  87. package/cjs/actions-8dc9e8de.js.map +0 -1
  88. package/cjs/selectors-656da4b7.js.map +0 -1
  89. package/cjs/version-bf9ef45e.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-17d1ac3c.js.map +0 -1
  93. package/esm/actions-180948dd.js +0 -72
  94. package/esm/actions-180948dd.js.map +0 -1
  95. package/esm/selectors-a5e5835b.js.map +0 -1
  96. package/esm/version-2485e2fb.js +0 -15
  97. package/esm/version-2485e2fb.js.map +0 -1
  98. package/esm/version-72ca17f3.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-72ca17f3.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-551d243a.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-bffb081f.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-aa8cef1e.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,15 +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
- const entrySys = entry && entry.sys || {}; // Update a window global to provide the preview toolbar
668
- // an updated entry id in client-side navigation
372
+ const entrySys = entry && entry.sys || {};
669
373
 
374
+ // Update a window global to provide the preview toolbar
375
+ // an updated entry id in client-side navigation
670
376
  if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
671
377
  const currentEntryId = yield select(selectRouteEntryEntryId);
672
378
  const currentEntryLang = yield select(selectRouteEntryLanguage);
673
- 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,
674
381
  entry,
675
382
  ancestors,
676
383
  siblings
@@ -690,7 +397,6 @@ function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound
690
397
  siblings
691
398
  })]);
692
399
  }
693
-
694
400
  function* mapRouteEntry(entryMapper, node) {
695
401
  try {
696
402
  if (typeof entryMapper === 'function') {
@@ -701,10 +407,8 @@ function* mapRouteEntry(entryMapper, node) {
701
407
  } catch (e) {
702
408
  log.error(...['Error running entryMapper:', e, e.stack]);
703
409
  }
704
-
705
410
  return;
706
411
  }
707
-
708
412
  function* do404() {
709
413
  yield call(clientReloadHitServer);
710
414
  yield put({
@@ -714,17 +418,16 @@ function* do404() {
714
418
  notFound: true
715
419
  });
716
420
  }
717
-
718
421
  function* clientReloadHitServer() {
719
- 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,
720
425
  // on the 2nd load stateEntry.sys should be null at this point,
721
426
  // we do not wish to reload again and get stuck in an infinite reloading loop
722
-
723
427
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
724
428
  window.location.reload();
725
429
  }
726
430
  }
727
-
728
431
  function* do500(error) {
729
432
  yield put({
730
433
  type: SET_ENTRY,
@@ -736,7 +439,6 @@ function* do500(error) {
736
439
  statusCode: error && error.status ? error.status : 500
737
440
  });
738
441
  }
739
-
740
442
  function* reduxInjectorSaga(injectorFn) {
741
443
  if (typeof injectorFn === 'function') {
742
444
  const {
@@ -753,19 +455,18 @@ function* reduxInjectorSaga(injectorFn) {
753
455
  }
754
456
 
755
457
  const registerSagas = [takeEvery(REGISTER_USER, registerSaga), takeEvery(REGISTER_USER_SUCCESS, redirectSaga)];
756
-
757
458
  function* registerSaga({
758
459
  user,
759
460
  mappers
760
461
  }) {
761
- 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
762
464
  // of any format and return the payload for the api request
763
-
764
465
  if (mappers && mappers.request && typeof mappers.request === 'function') {
765
466
  requestBody = yield mappers.request(user);
766
- } // Make POST call to register API
767
-
467
+ }
768
468
 
469
+ // Make POST call to register API
769
470
  const response = yield fetch('/account/register', {
770
471
  method: 'POST',
771
472
  headers: {
@@ -774,19 +475,16 @@ function* registerSaga({
774
475
  },
775
476
  body: JSON.stringify(requestBody)
776
477
  });
777
-
778
478
  if (response.ok) {
779
479
  let mappedResponse;
780
480
  const [, responseBody] = yield to(response.json());
781
-
782
481
  if (responseBody) {
783
482
  // Allow use of response mapper to convert the successful user object
784
483
  // from the api response body into a user object of any format
785
484
  if (mappers && mappers.response && typeof mappers.response === 'function') {
786
485
  mappedResponse = yield mappers.response(responseBody);
787
- } // Update user object with mappedResponse or responseBody
788
-
789
-
486
+ }
487
+ // Update user object with mappedResponse or responseBody
790
488
  yield put({
791
489
  type: REGISTER_USER_SUCCESS,
792
490
  user: mappedResponse || responseBody
@@ -805,25 +503,24 @@ function* registerSaga({
805
503
  // or status codes echoed from the responses received from
806
504
  // management api when registering the user
807
505
  const [, errorResponse] = yield to(response.json());
808
- const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
809
-
506
+ const error = errorResponse && errorResponse.error || errorResponse || {};
507
+ // Get something meaningful from the response if there is no message in the body
810
508
  if (!error.message) {
811
509
  error.message = `Registration service: ${response.statusText}`;
812
510
  error.status = response.status;
813
511
  }
814
-
815
512
  yield put({
816
513
  type: REGISTER_USER_FAILED,
817
514
  error
818
515
  });
819
516
  }
820
517
  }
821
-
822
518
  function* redirectSaga() {
823
519
  // Check if querystring contains a redirect_uri
824
520
  const currentQs = queryParams(yield select(selectCurrentSearch));
825
- 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;
826
522
 
523
+ // We must use redux based navigation to preserve the registration state
827
524
  if (redirectUri) yield put(setRoute(redirectUri));
828
525
  }
829
526
 
@@ -841,36 +538,36 @@ const BASE_OPTIONS = {
841
538
  };
842
539
  class UserHelper {
843
540
  static async GetUsersEnvironments(securityToken) {
844
- const options = { ...BASE_OPTIONS,
541
+ const options = {
542
+ ...BASE_OPTIONS,
845
543
  headers: {
846
544
  'x-security-token': securityToken
847
545
  }
848
546
  };
849
547
  return await UserHelper.get(USER_ENVS_URL, options);
850
548
  }
851
-
852
549
  static async ResendUserVerification(userEmail) {
853
- const options = { ...BASE_OPTIONS
550
+ const options = {
551
+ ...BASE_OPTIONS
854
552
  };
855
553
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
856
554
  }
857
-
858
555
  static async RequestPasswordReset(userEmailObject) {
859
- const options = { ...BASE_OPTIONS,
556
+ const options = {
557
+ ...BASE_OPTIONS,
860
558
  body: JSON.stringify(userEmailObject)
861
559
  };
862
560
  options.method = 'POST';
863
561
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
864
562
  }
865
-
866
563
  static async ResetPassword(resetPasswordObject) {
867
- const options = { ...BASE_OPTIONS,
564
+ const options = {
565
+ ...BASE_OPTIONS,
868
566
  body: JSON.stringify(resetPasswordObject)
869
567
  };
870
568
  options.method = 'POST';
871
569
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
872
570
  }
873
-
874
571
  static async get(url, options = BASE_OPTIONS) {
875
572
  try {
876
573
  const responseBody = await api(url, options);
@@ -883,9 +580,7 @@ class UserHelper {
883
580
  };
884
581
  }
885
582
  }
886
-
887
583
  }
888
-
889
584
  async function api(url, options) {
890
585
  return fetch(url, options).then(async response => {
891
586
  return response.json().then(data => data);
@@ -895,17 +590,14 @@ async function api(url, options) {
895
590
  }
896
591
 
897
592
  const resetPasswordSagas = [takeEvery(REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), takeEvery(RESET_USER_PASSWORD, resetPasswordSaga), takeEvery(CHANGE_USER_PASSWORD, changePasswordSaga)];
898
-
899
593
  function* requestPasswordResetSaga(action) {
900
594
  const userEmailObject = action.userEmailObject;
901
595
  yield put({
902
596
  type: REQUEST_USER_PASSWORD_RESET_SENDING
903
597
  });
904
-
905
598
  if (userEmailObject && userEmailObject.userEmail) {
906
599
  try {
907
600
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
908
-
909
601
  if (passwordResetRequestResponse) {
910
602
  if (!passwordResetRequestResponse.error) {
911
603
  yield put({
@@ -936,17 +628,14 @@ function* requestPasswordResetSaga(action) {
936
628
  });
937
629
  }
938
630
  }
939
-
940
631
  function* resetPasswordSaga(action) {
941
632
  const resetPasswordObject = action.resetPasswordObject;
942
633
  yield put({
943
634
  type: RESET_USER_PASSWORD_SENDING
944
635
  });
945
-
946
636
  if (resetPasswordObject.token && resetPasswordObject.password) {
947
637
  try {
948
638
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
949
-
950
639
  if (resetPasswordResponse) {
951
640
  if (!resetPasswordResponse.error) {
952
641
  yield put({
@@ -977,11 +666,11 @@ function* resetPasswordSaga(action) {
977
666
  error: 'Invalid object'
978
667
  });
979
668
  }
980
- } // userId
669
+ }
670
+
671
+ // userId
981
672
  // existingPassword
982
673
  // newPassword
983
-
984
-
985
674
  function* changePasswordSaga(action) {
986
675
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
987
676
  yield put({
@@ -990,7 +679,6 @@ function* changePasswordSaga(action) {
990
679
  });
991
680
  return;
992
681
  }
993
-
994
682
  try {
995
683
  const changePasswordObject = {
996
684
  userId: action.userId,
@@ -1001,25 +689,24 @@ function* changePasswordSaga(action) {
1001
689
  type: CHANGE_USER_PASSWORD_SENDING
1002
690
  });
1003
691
  const clientCredentials = yield select(selectClientCredentials, 'js');
1004
- const client = yield getManagementApiClient({ ...clientCredentials
692
+ const client = yield getManagementApiClient({
693
+ ...clientCredentials
1005
694
  });
1006
695
  const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
1007
-
1008
696
  if (err) {
1009
697
  var _err$data, _err$data$data, _err$data2;
1010
-
1011
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);
1012
699
  yield put({
1013
700
  type: CHANGE_USER_PASSWORD_ERROR,
1014
701
  error
1015
702
  });
1016
703
  return;
1017
- } // // eslint-disable-next-line no-console
704
+ }
705
+
706
+ // // eslint-disable-next-line no-console
1018
707
  // console.log(changePasswordObject);
1019
708
  // // eslint-disable-next-line no-console
1020
709
  // console.log(userCredentialsObject);
1021
-
1022
-
1023
710
  yield put({
1024
711
  type: CHANGE_USER_PASSWORD_SUCCESS
1025
712
  });
@@ -1041,35 +728,32 @@ function rootSaga (featureSagas = []) {
1041
728
  };
1042
729
  }
1043
730
 
1044
- const servers = SERVERS;
1045
- /* global SERVERS */
1046
-
731
+ const servers = SERVERS; /* global SERVERS */
1047
732
  const alias = servers.alias.toLowerCase();
1048
- const publicUri = PUBLIC_URI;
1049
- /* global PUBLIC_URI */
733
+ const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
734
+ const projects = PROJECTS; /* global PROJECTS */
1050
735
 
1051
- const projects = PROJECTS;
1052
- /* global PROJECTS */
1053
736
  // return a projectId via the request hostname
1054
-
1055
737
  const pickProject = (hostname, query) => {
1056
738
  // if localhost we can only infer via a querystring, and take your word for it
1057
739
  if (hostname == 'localhost') {
1058
740
  return query && query.p || projects[0].id;
1059
- } // if hostname is the actual public uri we can return the first project from the list
1060
-
741
+ }
1061
742
 
743
+ // if hostname is the actual public uri we can return the first project from the list
1062
744
  if (hostname == publicUri) {
1063
745
  return projects[0].id;
1064
746
  }
747
+ let project = 'unknown';
1065
748
 
1066
- let project = 'unknown'; // // go through all the defined projects
749
+ // // go through all the defined projects
1067
750
  // Object.entries(projects).map(([, p]) => {
751
+ const p = projects[0];
1068
752
 
1069
- const p = projects[0]; // check if we're accessing via the project's public uri
1070
-
1071
- 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;
1072
755
 
756
+ // the url structure is different for website (we don't prefix)
1073
757
  if (p.id.startsWith('website')) {
1074
758
  // check for internal and external hostnames
1075
759
  // we check live and preview distinctly so our rule does not clash with
@@ -1078,9 +762,8 @@ const pickProject = (hostname, query) => {
1078
762
  } else {
1079
763
  // check for internal and external hostnames, prefixed with the projectId
1080
764
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
1081
- } // });
1082
-
1083
-
765
+ }
766
+ // });
1084
767
  return project === 'unknown' ? p.id : project;
1085
768
  };
1086
769
 
@@ -1088,5 +771,5 @@ const AppRoot = props => {
1088
771
  return /*#__PURE__*/React.createElement(RouteLoader, props);
1089
772
  };
1090
773
 
1091
- export { AppRoot as A, browserHistory as b, cachedSearch as c, deliveryApi as d, history as h, pickProject as p, rootSaga as r };
1092
- //# sourceMappingURL=App-17d1ac3c.js.map
774
+ export { AppRoot as A, browserHistory as b, history as h, pickProject as p, rootSaga as r };
775
+ //# sourceMappingURL=App-4fb1fc44.js.map