@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21

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 (110) hide show
  1. package/cjs/{App-ee485b92.js → App-21a7d836.js} +120 -432
  2. package/cjs/App-21a7d836.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.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 +1488 -272
  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-2a6b5be0.js} +64 -113
  18. package/cjs/login-2a6b5be0.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-8a20e424.js → sagas-e04b94c1.js} +225 -301
  26. package/cjs/sagas-e04b94c1.js.map +1 -0
  27. package/cjs/search.js +68 -94
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
  30. package/cjs/selectors-bcca60f4.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-4077e706.js} +50 -159
  37. package/cjs/version-4077e706.js.map +1 -0
  38. package/cjs/version-fe28099e.js +98 -0
  39. package/cjs/version-fe28099e.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
  41. package/esm/App-2af18a99.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
  43. package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.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 +1490 -274
  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-71ff3fcb.js} +63 -112
  57. package/esm/login-71ff3fcb.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-e576b6f6.js → sagas-933a8fc8.js} +177 -254
  65. package/esm/sagas-933a8fc8.js.map +1 -0
  66. package/esm/search.js +69 -95
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
  69. package/esm/selectors-74de49a3.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-b15807c5.js +87 -0
  76. package/esm/version-b15807c5.js.map +1 -0
  77. package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
  78. package/esm/version-ef107106.js.map +1 -0
  79. package/models/redux/appstate.d.ts +1 -0
  80. package/models/routing/redux/selectors.d.ts +2 -1
  81. package/models/search/models/Queries.d.ts +2 -1
  82. package/models/search/models/Search.d.ts +2 -0
  83. package/models/search/models/SearchActions.d.ts +3 -3
  84. package/models/search/redux/actions.d.ts +6 -6
  85. package/models/search/redux/util.d.ts +1 -1
  86. package/models/search/search/expressions.d.ts +1 -1
  87. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  88. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  89. package/models/util/index.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/cjs/App-ee485b92.js.map +0 -1
  92. package/cjs/actions-8dc9e8de.js +0 -87
  93. package/cjs/actions-8dc9e8de.js.map +0 -1
  94. package/cjs/login-840860bc.js.map +0 -1
  95. package/cjs/reducers-3a4f8971.js.map +0 -1
  96. package/cjs/sagas-8a20e424.js.map +0 -1
  97. package/cjs/selectors-656da4b7.js.map +0 -1
  98. package/cjs/version-78dfc3bd.js.map +0 -1
  99. package/cjs/version-eba6d09b.js +0 -20
  100. package/cjs/version-eba6d09b.js.map +0 -1
  101. package/esm/App-640239d2.js.map +0 -1
  102. package/esm/actions-180948dd.js +0 -72
  103. package/esm/actions-180948dd.js.map +0 -1
  104. package/esm/login-57395c9c.js.map +0 -1
  105. package/esm/reducers-8e5d6232.js.map +0 -1
  106. package/esm/sagas-e576b6f6.js.map +0 -1
  107. package/esm/selectors-a5e5835b.js.map +0 -1
  108. package/esm/version-2485e2fb.js +0 -15
  109. package/esm/version-2485e2fb.js.map +0 -1
  110. package/esm/version-e3a5ec66.js.map +0 -1
@@ -3,20 +3,20 @@
3
3
  var history$1 = require('history');
4
4
  var effects = require('@redux-saga/core/effects');
5
5
  var log = require('loglevel');
6
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-c079b03a.js');
7
+ var version = require('./version-4077e706.js');
8
+ var version$1 = require('./version-fe28099e.js');
9
+ var selectors = require('./selectors-bcca60f4.js');
10
+ var login = require('./login-2a6b5be0.js');
6
11
  var contensisDeliveryApi = require('contensis-delivery-api');
7
- var queryString = require('query-string');
8
- var actions = require('./actions-8dc9e8de.js');
9
- var version = require('./version-78dfc3bd.js');
10
- var version$1 = require('./version-eba6d09b.js');
11
- var selectors = require('./selectors-656da4b7.js');
12
- var login = require('./login-840860bc.js');
13
12
  var awaitToJs = require('await-to-js');
14
- var reducers = require('./reducers-3a4f8971.js');
15
- var ToJs = require('./ToJs-a9a8522b.js');
13
+ var reducers = require('./reducers-9afb5f89.js');
14
+ var ToJs = require('./ToJs-6e9cfa69.js');
16
15
  var React = require('react');
17
16
  require('react-hot-loader');
18
17
  require('jsonpath-mapper');
19
- var RouteLoader = require('./RouteLoader-3aa6456e.js');
18
+ require('query-string');
19
+ var RouteLoader = require('./RouteLoader-7f0d107a.js');
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
@@ -41,279 +41,7 @@ function _interopNamespace(e) {
41
41
  var log__namespace = /*#__PURE__*/_interopNamespace(log);
42
42
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
 
44
- const storeSurrogateKeys = response => {
45
- const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
46
- if (keys) version.reduxStore === null || version.reduxStore === void 0 ? void 0 : version.reduxStore.dispatch(actions.setSurrogateKeys(keys, response.url));
47
- };
48
-
49
- const getClientConfig = project => {
50
- let config = DELIVERY_API_CONFIG;
51
- /* global DELIVERY_API_CONFIG */
52
-
53
- config.responseHandler = {};
54
-
55
- if (project) {
56
- config.projectId = project;
57
- } // we only want the surrogate key header in a server context
58
-
59
-
60
- if (typeof window === 'undefined') {
61
- config.defaultHeaders = {
62
- 'x-require-surrogate-key': true
63
- };
64
- config.responseHandler[200] = storeSurrogateKeys;
65
- }
66
-
67
- if (typeof window !== 'undefined' && PROXY_DELIVERY_API
68
- /* global PROXY_DELIVERY_API */
69
- ) {
70
- // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
71
- config.rootUrl = '';
72
-
73
- config.responseHandler[404] = () => null;
74
- }
75
-
76
- return config;
77
- };
78
-
79
- class DeliveryApi {
80
- constructor() {
81
- this.getClientSideVersionStatus = () => {
82
- if (typeof window !== 'undefined') {
83
- // Allow overriding versionStatus with the querystring
84
- const {
85
- versionStatus
86
- } = queryString.parse(window.location.search);
87
- if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
88
-
89
- if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
90
-
91
- const currentHostname = window.location.hostname;
92
- return this.getVersionStatusFromHostname(currentHostname);
93
- }
94
-
95
- return null;
96
- };
97
-
98
- this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
99
-
100
- this.getVersionStatusFromHeaders = headers => {
101
- const versionStatusHeader = headers['x-entry-versionstatus'];
102
- if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
103
- return null;
104
- };
105
-
106
- this.getVersionStatusFromHostname = currentHostname => {
107
- if (currentHostname.indexOf('localhost') > -1) return 'latest';
108
-
109
- if (currentHostname.endsWith('contensis.cloud')) {
110
- if (currentHostname.indexOf('preview.') > -1) {
111
- return 'latest';
112
- } else {
113
- return 'published';
114
- }
115
- }
116
-
117
- if (currentHostname.endsWith('cloud.contensis.com')) {
118
- if (currentHostname.indexOf('preview-') > -1) {
119
- return 'latest';
120
- } else {
121
- return 'published';
122
- }
123
- }
124
-
125
- return 'published';
126
- };
127
-
128
- this.search = (query, linkDepth, project, env) => {
129
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
130
- return client.entries.search(query, typeof linkDepth !== 'undefined' ? linkDepth : 1);
131
- };
132
-
133
- this.getClient = (deliveryApiStatus = 'published', project, env) => {
134
- const baseConfig = getClientConfig(project);
135
- baseConfig.versionStatus = deliveryApiStatus;
136
- return contensisDeliveryApi.Client.create(baseConfig);
137
- };
138
-
139
- this.getEntry = (id, linkDepth = 0, deliveryApiStatus = 'published', project, env) => {
140
- const baseConfig = getClientConfig(project);
141
- baseConfig.versionStatus = deliveryApiStatus;
142
- const client = contensisDeliveryApi.Client.create(baseConfig); // return client.entries.get(id, linkDepth);
143
-
144
- return client.entries.get({
145
- id,
146
- linkDepth
147
- });
148
- };
149
- }
150
-
151
- }
152
-
153
- const deliveryApi = new DeliveryApi();
154
-
155
- class CacheNode {
156
- constructor(key, value) {
157
- this.key = key;
158
- this.value = value;
159
- this.next = null;
160
- this.prev = null;
161
- }
162
-
163
- }
164
-
165
- class LruCache {
166
- constructor(limit = 100) {
167
- this.map = {};
168
- this.head = null;
169
- this.tail = null;
170
- this.limit = limit || 100;
171
- this.size = 0;
172
- }
173
-
174
- get(key) {
175
- if (this.map[key]) {
176
- let value = this.map[key].value;
177
- let node = new CacheNode(key, value);
178
- this.remove(key);
179
- this.setHead(node);
180
- return value;
181
- }
182
- }
183
-
184
- set(key, value) {
185
- let node = new CacheNode(key, value);
186
-
187
- if (this.map[key]) {
188
- this.remove(key);
189
- } else {
190
- if (this.size >= this.limit) {
191
- delete this.map[this.tail.key];
192
- this.size--;
193
- this.tail = this.tail.prev;
194
- this.tail.next = null;
195
- }
196
- }
197
-
198
- this.setHead(node);
199
- }
200
-
201
- setHead(node) {
202
- node.next = this.head;
203
- node.prev = null;
204
-
205
- if (this.head) {
206
- this.head.prev = node;
207
- }
208
-
209
- this.head = node;
210
-
211
- if (!this.tail) {
212
- this.tail = node;
213
- }
214
-
215
- this.size++;
216
- this.map[node.key] = node;
217
- }
218
-
219
- remove(key) {
220
- let node = this.map[key];
221
- if (!node) return; // This is sometimes null and crashes the container without this check
222
-
223
- if (node.prev) {
224
- node.prev.next = node.next;
225
- } else {
226
- this.head = node.next;
227
- }
228
-
229
- if (node.next) {
230
- node.next.prev = node.prev;
231
- } else {
232
- this.tail = node.prev;
233
- }
234
-
235
- delete this.map[key];
236
- this.size--;
237
- }
238
-
239
- }
240
-
241
- class CachedSearch {
242
- constructor() {
243
- this.cache = new LruCache();
244
- this.taxonomyLookup = {};
245
- }
246
-
247
- search(query, linkDepth, project, env) {
248
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
249
- return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
250
- }
251
-
252
- searchUsingPost(query, linkDepth = 0, project = '', env) {
253
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
254
- return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
255
- }
256
-
257
- get(id, linkDepth, versionStatus, project, env) {
258
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
259
- client.clientConfig.versionStatus = versionStatus;
260
- return this.request(id, () => client.entries.get({
261
- id,
262
- linkDepth
263
- }));
264
- }
265
-
266
- getContentType(id, project, env) {
267
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
268
- return this.request(`[CONTENT TYPE] ${id} ${project}`, () => client.contentTypes.get(id));
269
- }
270
-
271
- getTaxonomyNode(key, project, env) {
272
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
273
- return this.request(`[TAXONOMY NODE] ${key}`, () => client.taxonomy.resolveChildren(key).then(node => this.extendTaxonomyNode(node)));
274
- }
275
-
276
- getRootNode(options, project, env) {
277
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
278
- return this.request(`${project} / ${JSON.stringify(options)}`, () => client.nodes.getRoot(options));
279
- }
280
-
281
- getNode(options, project, env) {
282
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
283
- return this.request(`${project} ${options && options.path || options} ${JSON.stringify(options)}`, () => client.nodes.get(options));
284
- }
285
-
286
- getAncestors(options, project, env) {
287
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
288
- return this.request(`${project} [A] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getAncestors(options));
289
- }
290
-
291
- getChildren(options, project, env) {
292
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
293
- return this.request(`${project} [C] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getChildren(options));
294
- }
295
-
296
- getSiblings(options, project, env) {
297
- const client = contensisDeliveryApi.Client.create(getClientConfig(project));
298
- return this.request(`${project} [S] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getSiblings(options));
299
- }
300
-
301
- request(key, execute) {
302
- if (!this.cache.get(key) || typeof window == 'undefined') {
303
- let promise = execute();
304
- this.cache.set(key, promise);
305
- promise.catch(() => {
306
- this.cache.remove(key);
307
- });
308
- }
309
-
310
- return this.cache.get(key);
311
- }
312
-
313
- }
314
-
315
- const cachedSearch = new CachedSearch();
316
-
44
+ // Create a history depending on the environment
317
45
  const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
318
46
  const history = (options = {}) => selectedHistory(options);
319
47
  const browserHistory = selectedHistory();
@@ -321,15 +49,14 @@ const browserHistory = selectedHistory();
321
49
  const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
322
50
  function* ensureNodeTreeSaga(action) {
323
51
  const state = yield effects.select();
324
-
325
52
  try {
326
- if (!version.hasNavigationTree(state)) {
327
- const deliveryApiVersionStatus = yield effects.select(version$1.selectVersionStatus);
53
+ if (!version$1.hasNavigationTree(state)) {
54
+ const deliveryApiVersionStatus = yield effects.select(version.selectVersionStatus);
328
55
  const project = yield effects.select(selectors.selectCurrentProject);
329
- const nodes = yield deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
330
- depth: action.treeDepth || 0
56
+ const nodes = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
57
+ depth: action.treeDepth || 0,
58
+ language: action.language
331
59
  });
332
-
333
60
  if (nodes) {
334
61
  yield effects.put({
335
62
  type: version.SET_NODE_TREE,
@@ -376,7 +103,6 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
376
103
  const defaultExpressions = versionStatus => {
377
104
  return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
378
105
  };
379
-
380
106
  const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
381
107
 
382
108
  const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
@@ -385,12 +111,12 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
385
111
  return query;
386
112
  };
387
113
 
388
- const routingSagas = [effects.takeEvery(actions.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(actions.SET_ROUTE, setRouteSaga)];
114
+ const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
115
+
389
116
  /**
390
117
  * To navigate / push a specific route via redux middleware
391
118
  * @param {path, state} action
392
119
  */
393
-
394
120
  function* setRouteSaga(action) {
395
121
  yield effects.put({
396
122
  type: 'CALL_HISTORY_METHOD',
@@ -400,37 +126,35 @@ function* setRouteSaga(action) {
400
126
  }
401
127
  });
402
128
  }
403
-
404
129
  function* getRouteSaga(action) {
405
130
  let entry = null;
406
-
407
131
  try {
408
132
  var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
409
-
410
133
  const {
411
134
  withEvents,
412
135
  routes: {
413
136
  ContentTypeMappings = {}
414
137
  } = {},
415
138
  staticRoute
416
- } = action; // Inject redux { key, reducer, saga } provided by staticRoute
139
+ } = action;
417
140
 
418
- if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux); // Variables we will pass to setRouteEntry
141
+ // Inject redux { key, reducer, saga } provided by staticRoute
142
+ if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux);
419
143
 
144
+ // Variables we will pass to setRouteEntry
420
145
  let pathNode = null,
421
- ancestors = null,
422
- children = [],
423
- siblings = null;
424
- let contentTypeMapping = {}; // These variables are the return values from
425
- // calls to withEvents.onRouteLoad and onRouteLoaded
146
+ ancestors = null,
147
+ children = [],
148
+ siblings = null;
149
+ let contentTypeMapping = {};
426
150
 
151
+ // These variables are the return values from
152
+ // calls to withEvents.onRouteLoad and onRouteLoaded
427
153
  let appsays,
428
- requireLogin = false;
429
-
154
+ requireLogin = false;
430
155
  if (withEvents && withEvents.onRouteLoad) {
431
156
  appsays = yield withEvents.onRouteLoad(action);
432
157
  }
433
-
434
158
  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;
435
159
  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;
436
160
  const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
@@ -439,56 +163,54 @@ function* getRouteSaga(action) {
439
163
  const routeEntry = selectors.selectRouteEntry(state, 'js');
440
164
  const routeNode = selectors.selectCurrentNode(state, 'js');
441
165
  const currentPath = action.path; //selectCurrentPath(state);
442
-
443
- const deliveryApiStatus = version$1.selectVersionStatus(state);
444
- const project = selectors.selectCurrentProject(state); // const isHome = currentPath === '/';
445
-
166
+ const deliveryApiStatus = version.selectVersionStatus(state);
167
+ const project = selectors.selectCurrentProject(state);
168
+ // const isHome = currentPath === '/';
446
169
  const isPreview = currentPath && currentPath.startsWith('/preview/');
447
170
  const defaultLang = appsays && appsays.defaultLang || 'en-GB';
448
-
449
171
  if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
450
172
  // To prevent erroneous 404s and wasted network calls, this covers
451
173
  // - appsays customRouting and does SET_ENTRY etc. via the consuming app
452
174
  // - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
453
175
  // - standard Contensis SiteView Routing where we already have that entry in state
454
176
  if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
455
- pathNode = { ...routeNode,
177
+ pathNode = {
178
+ ...routeNode,
456
179
  entry: null
457
180
  };
458
- pathNode.entry = entry = routeEntry; //Do nothing, the entry is allready the right one.
181
+ pathNode.entry = entry = routeEntry;
182
+ //Do nothing, the entry is allready the right one.
459
183
  // yield put({
460
184
  // type: SET_ENTRY,
461
185
  // entry,
462
186
  // node: routeNode,
463
187
  // isLoading: false,
464
188
  // });
465
-
466
189
  yield effects.put({
467
- type: actions.UPDATE_LOADING_STATE,
190
+ type: selectors.UPDATE_LOADING_STATE,
468
191
  isLoading: false
469
192
  });
470
- } else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
193
+ } else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
471
194
  } else {
472
195
  // Handle preview routes
473
196
  if (isPreview) {
474
197
  let splitPath = currentPath.split('/');
475
198
  let entryGuid = splitPath[2];
476
199
  let language = defaultLang;
477
-
478
200
  if (splitPath.length >= 3) {
479
201
  //set lang key if available in the path, else use default lang
480
202
  //assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
481
- if (splitPath.length == 4) language = splitPath[3]; // According to product dev we cannot use Node API
203
+ if (splitPath.length == 4) language = splitPath[3];
204
+ // According to product dev we cannot use Node API
482
205
  // for previewing entries as it gives a response of []
483
206
  // -- apparently it is not correct to request latest content
484
207
  // with Node API
485
208
 
486
- let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
209
+ let previewEntry = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiStatus, project).entries.get({
487
210
  id: entryGuid,
488
211
  language,
489
212
  linkDepth: entryLinkDepth
490
213
  });
491
-
492
214
  if (previewEntry) {
493
215
  pathNode = {
494
216
  entry: previewEntry
@@ -500,9 +222,8 @@ function* getRouteSaga(action) {
500
222
  }
501
223
  } else {
502
224
  var _pathNode, _pathNode$entry, _pathNode$entry$sys;
503
-
504
225
  // Handle all other routes
505
- pathNode = yield cachedSearch.getNode({
226
+ pathNode = yield ContensisDeliveryApi.cachedSearch.getNode({
506
227
  depth: 0,
507
228
  path: currentPath,
508
229
  entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : staticRouteFields || '*',
@@ -513,10 +234,8 @@ function* getRouteSaga(action) {
513
234
  ({
514
235
  entry
515
236
  } = pathNode || {});
516
-
517
237
  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) {
518
238
  var _payload$items;
519
-
520
239
  // Get fields[] and linkDepth from ContentTypeMapping to get the entry data
521
240
  // and current node's ordinates at a specified depth with specified fields
522
241
  contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
@@ -525,16 +244,15 @@ function* getRouteSaga(action) {
525
244
  linkDepth
526
245
  } = contentTypeMapping;
527
246
  const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
528
- const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
529
-
247
+ const payload = yield ContensisDeliveryApi.cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
530
248
  if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
531
249
  pathNode.entry = entry = payload.items[0];
532
250
  }
533
251
  }
534
- } // make calls to fetch node ancestors, children,
535
- // siblings or entire node tree
536
-
252
+ }
537
253
 
254
+ // make calls to fetch node ancestors, children,
255
+ // siblings or entire node tree
538
256
  [ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
539
257
  appsays,
540
258
  contentTypeMapping,
@@ -546,48 +264,44 @@ function* getRouteSaga(action) {
546
264
  });
547
265
  if (children) pathNode.children = children;
548
266
  }
267
+ const resolvedContentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {};
549
268
 
550
- const resolvedContentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {}; // Inject redux { key, reducer, saga } provided by ContentTypeMapping
551
-
269
+ // Inject redux { key, reducer, saga } provided by ContentTypeMapping
552
270
  if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
553
-
554
271
  if (withEvents && withEvents.onRouteLoaded) {
555
272
  // Check if the app has provided a requireLogin boolean flag or groups array
556
273
  // in addition to checking if requireLogin is set in the route definition
557
274
  ({
558
275
  requireLogin
559
- } = (yield withEvents.onRouteLoaded({ ...action,
276
+ } = (yield withEvents.onRouteLoaded({
277
+ ...action,
560
278
  entry
561
279
  })) || {});
562
280
  }
563
-
564
281
  if (requireLogin !== false) {
565
282
  // Do not call the login feature saga if requireLogin is false
566
- yield effects.call(login.handleRequiresLoginSaga, { ...action,
283
+ yield effects.call(login.handleRequiresLoginSaga, {
284
+ ...action,
567
285
  entry,
568
286
  requireLogin
569
287
  });
570
288
  }
571
-
572
289
  if (!appsays || !appsays.preventScrollTop) {
573
290
  // Scroll into View
574
291
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
575
292
  }
576
-
577
293
  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) {
578
294
  var _staticRoute$route3, _staticRoute$route3$f, _appsays;
579
-
580
295
  entry = pathNode.entry;
581
- yield effects.call(setRouteEntry, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
296
+ yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
582
297
  } else {
583
- if (staticRoute) yield effects.call(setRouteEntry, null, pathNode, ancestors, siblings);else yield effects.call(do404);
298
+ if (staticRoute) yield effects.call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield effects.call(do404);
584
299
  }
585
300
  } catch (e) {
586
301
  log__namespace.error(...['Error running route saga:', e, e.stack]);
587
302
  yield effects.call(do500, e);
588
303
  }
589
304
  }
590
-
591
305
  function* resolveCurrentNodeOrdinates({
592
306
  appsays,
593
307
  contentTypeMapping,
@@ -597,10 +311,11 @@ function* resolveCurrentNodeOrdinates({
597
311
  project,
598
312
  versionStatus
599
313
  }) {
600
- const apiCall = [() => null, () => null, () => null, () => null]; // if appsays customNavigation: true, we will set doNavigation to false
314
+ const apiCall = [() => null, () => null, () => null, () => null];
315
+
316
+ // if appsays customNavigation: true, we will set doNavigation to false
601
317
  // if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
602
318
  // if appsays nothing we will set doNavigation to true and continue to do navigation calls
603
-
604
319
  const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
605
320
  const {
606
321
  entryLinkDepth = 0,
@@ -608,12 +323,11 @@ function* resolveCurrentNodeOrdinates({
608
323
  linkDepth,
609
324
  nodeOptions = {}
610
325
  } = contentTypeMapping;
611
-
612
326
  if (pathNode && pathNode.id) {
613
327
  if (doNavigation === true || doNavigation.ancestors) {
614
328
  apiCall[0] = function* getAncestors() {
615
329
  try {
616
- return yield cachedSearch.getAncestors({
330
+ return yield ContensisDeliveryApi.cachedSearch.getAncestors({
617
331
  id: pathNode.id,
618
332
  language,
619
333
  versionStatus
@@ -624,15 +338,12 @@ function* resolveCurrentNodeOrdinates({
624
338
  }
625
339
  };
626
340
  }
627
-
628
341
  const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
629
-
630
342
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
631
343
  const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
632
-
633
344
  apiCall[1] = function* getChildren() {
634
345
  try {
635
- return yield cachedSearch.getNode({
346
+ return yield ContensisDeliveryApi.cachedSearch.getNode({
636
347
  depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
637
348
  path,
638
349
  entryFields: childrenOptions.fields || fields || undefined,
@@ -646,13 +357,11 @@ function* resolveCurrentNodeOrdinates({
646
357
  }
647
358
  };
648
359
  }
649
-
650
360
  if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
651
361
  apiCall[2] = function* getSiblings() {
652
362
  try {
653
363
  var _nodeOptions$siblings, _nodeOptions$siblings2;
654
-
655
- return yield cachedSearch.getSiblings({
364
+ return yield ContensisDeliveryApi.cachedSearch.getSiblings({
656
365
  id: pathNode.id,
657
366
  entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
658
367
  entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
@@ -667,18 +376,18 @@ function* resolveCurrentNodeOrdinates({
667
376
  };
668
377
  }
669
378
  }
670
-
671
- const isTreeLoaded = yield effects.select(version.hasNavigationTree);
379
+ const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
672
380
  if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
673
381
  const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
674
-
675
382
  if (typeof window !== 'undefined') {
676
383
  return yield effects.put({
677
384
  type: version.GET_NODE_TREE,
385
+ language,
678
386
  treeDepth
679
387
  });
680
388
  } else {
681
389
  return yield effects.call(ensureNodeTreeSaga, {
390
+ language,
682
391
  treeDepth
683
392
  });
684
393
  }
@@ -687,32 +396,36 @@ function* resolveCurrentNodeOrdinates({
687
396
  const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
688
397
  return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
689
398
  }
690
-
691
- function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
399
+ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
692
400
  const entrySys = entry && entry.sys || {};
401
+
402
+ // Update a window global to provide the preview toolbar
403
+ // an updated entry id in client-side navigation
404
+ if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
693
405
  const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
694
406
  const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
695
- const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, { ...node,
407
+ const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
408
+ ...node,
696
409
  entry,
697
410
  ancestors,
698
411
  siblings
699
412
  });
700
413
  yield effects.all([effects.put({
701
- type: actions.SET_ENTRY,
414
+ type: selectors.SET_ENTRY,
702
415
  id: entrySys.id,
416
+ currentPath,
703
417
  entry,
704
418
  mappedEntry,
705
419
  node,
706
420
  notFound
707
421
  }), ancestors && effects.put({
708
- type: actions.SET_ANCESTORS,
422
+ type: selectors.SET_ANCESTORS,
709
423
  ancestors
710
424
  }), siblings && effects.put({
711
- type: actions.SET_SIBLINGS,
425
+ type: selectors.SET_SIBLINGS,
712
426
  siblings
713
427
  })]);
714
428
  }
715
-
716
429
  function* mapRouteEntry(entryMapper, node) {
717
430
  try {
718
431
  if (typeof entryMapper === 'function') {
@@ -723,33 +436,30 @@ function* mapRouteEntry(entryMapper, node) {
723
436
  } catch (e) {
724
437
  log__namespace.error(...['Error running entryMapper:', e, e.stack]);
725
438
  }
726
-
727
439
  return;
728
440
  }
729
-
730
441
  function* do404() {
731
442
  yield effects.call(clientReloadHitServer);
732
443
  yield effects.put({
733
- type: actions.SET_ENTRY,
444
+ type: selectors.SET_ENTRY,
734
445
  id: null,
735
446
  entry: null,
736
447
  notFound: true
737
448
  });
738
449
  }
739
-
740
450
  function* clientReloadHitServer() {
741
- const stateEntry = yield effects.select(selectors.selectRouteEntry); // If in client and there is a stateEntry.sys field reload the page,
451
+ const stateEntry = yield effects.select(selectors.selectRouteEntry);
452
+
453
+ // If in client and there is a stateEntry.sys field reload the page,
742
454
  // on the 2nd load stateEntry.sys should be null at this point,
743
455
  // we do not wish to reload again and get stuck in an infinite reloading loop
744
-
745
456
  if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
746
457
  window.location.reload();
747
458
  }
748
459
  }
749
-
750
460
  function* do500(error) {
751
461
  yield effects.put({
752
- type: actions.SET_ENTRY,
462
+ type: selectors.SET_ENTRY,
753
463
  id: null,
754
464
  entry: null,
755
465
  notFound: true,
@@ -758,7 +468,6 @@ function* do500(error) {
758
468
  statusCode: error && error.status ? error.status : 500
759
469
  });
760
470
  }
761
-
762
471
  function* reduxInjectorSaga(injectorFn) {
763
472
  if (typeof injectorFn === 'function') {
764
473
  const {
@@ -766,7 +475,7 @@ function* reduxInjectorSaga(injectorFn) {
766
475
  reducer,
767
476
  saga
768
477
  } = yield injectorFn();
769
- version.injectRedux({
478
+ version$1.injectRedux({
770
479
  key,
771
480
  reducer,
772
481
  saga
@@ -775,19 +484,18 @@ function* reduxInjectorSaga(injectorFn) {
775
484
  }
776
485
 
777
486
  const registerSagas = [effects.takeEvery(reducers.REGISTER_USER, registerSaga), effects.takeEvery(reducers.REGISTER_USER_SUCCESS, redirectSaga)];
778
-
779
487
  function* registerSaga({
780
488
  user,
781
489
  mappers
782
490
  }) {
783
- let requestBody = user; // Allow use of request mapper to take a user object
491
+ let requestBody = user;
492
+ // Allow use of request mapper to take a user object
784
493
  // of any format and return the payload for the api request
785
-
786
494
  if (mappers && mappers.request && typeof mappers.request === 'function') {
787
495
  requestBody = yield mappers.request(user);
788
- } // Make POST call to register API
789
-
496
+ }
790
497
 
498
+ // Make POST call to register API
791
499
  const response = yield fetch('/account/register', {
792
500
  method: 'POST',
793
501
  headers: {
@@ -796,19 +504,16 @@ function* registerSaga({
796
504
  },
797
505
  body: JSON.stringify(requestBody)
798
506
  });
799
-
800
507
  if (response.ok) {
801
508
  let mappedResponse;
802
509
  const [, responseBody] = yield awaitToJs.to(response.json());
803
-
804
510
  if (responseBody) {
805
511
  // Allow use of response mapper to convert the successful user object
806
512
  // from the api response body into a user object of any format
807
513
  if (mappers && mappers.response && typeof mappers.response === 'function') {
808
514
  mappedResponse = yield mappers.response(responseBody);
809
- } // Update user object with mappedResponse or responseBody
810
-
811
-
515
+ }
516
+ // Update user object with mappedResponse or responseBody
812
517
  yield effects.put({
813
518
  type: reducers.REGISTER_USER_SUCCESS,
814
519
  user: mappedResponse || responseBody
@@ -827,26 +532,25 @@ function* registerSaga({
827
532
  // or status codes echoed from the responses received from
828
533
  // management api when registering the user
829
534
  const [, errorResponse] = yield awaitToJs.to(response.json());
830
- const error = errorResponse && errorResponse.error || errorResponse || {}; // Get something meaningful from the response if there is no message in the body
831
-
535
+ const error = errorResponse && errorResponse.error || errorResponse || {};
536
+ // Get something meaningful from the response if there is no message in the body
832
537
  if (!error.message) {
833
538
  error.message = `Registration service: ${response.statusText}`;
834
539
  error.status = response.status;
835
540
  }
836
-
837
541
  yield effects.put({
838
542
  type: reducers.REGISTER_USER_FAILED,
839
543
  error
840
544
  });
841
545
  }
842
546
  }
843
-
844
547
  function* redirectSaga() {
845
548
  // Check if querystring contains a redirect_uri
846
549
  const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
847
- const redirectUri = currentQs.redirect_uri || currentQs.redirect; // We must use redux based navigation to preserve the registration state
550
+ const redirectUri = currentQs.redirect_uri || currentQs.redirect;
848
551
 
849
- if (redirectUri) yield effects.put(actions.setRoute(redirectUri));
552
+ // We must use redux based navigation to preserve the registration state
553
+ if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
850
554
  }
851
555
 
852
556
  const PAP_URL = 'https://pap.zengenti.com';
@@ -863,36 +567,36 @@ const BASE_OPTIONS = {
863
567
  };
864
568
  class UserHelper {
865
569
  static async GetUsersEnvironments(securityToken) {
866
- const options = { ...BASE_OPTIONS,
570
+ const options = {
571
+ ...BASE_OPTIONS,
867
572
  headers: {
868
573
  'x-security-token': securityToken
869
574
  }
870
575
  };
871
576
  return await UserHelper.get(USER_ENVS_URL, options);
872
577
  }
873
-
874
578
  static async ResendUserVerification(userEmail) {
875
- const options = { ...BASE_OPTIONS
579
+ const options = {
580
+ ...BASE_OPTIONS
876
581
  };
877
582
  return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
878
583
  }
879
-
880
584
  static async RequestPasswordReset(userEmailObject) {
881
- const options = { ...BASE_OPTIONS,
585
+ const options = {
586
+ ...BASE_OPTIONS,
882
587
  body: JSON.stringify(userEmailObject)
883
588
  };
884
589
  options.method = 'POST';
885
590
  return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
886
591
  }
887
-
888
592
  static async ResetPassword(resetPasswordObject) {
889
- const options = { ...BASE_OPTIONS,
593
+ const options = {
594
+ ...BASE_OPTIONS,
890
595
  body: JSON.stringify(resetPasswordObject)
891
596
  };
892
597
  options.method = 'POST';
893
598
  return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
894
599
  }
895
-
896
600
  static async get(url, options = BASE_OPTIONS) {
897
601
  try {
898
602
  const responseBody = await api(url, options);
@@ -905,9 +609,7 @@ class UserHelper {
905
609
  };
906
610
  }
907
611
  }
908
-
909
612
  }
910
-
911
613
  async function api(url, options) {
912
614
  return fetch(url, options).then(async response => {
913
615
  return response.json().then(data => data);
@@ -917,17 +619,14 @@ async function api(url, options) {
917
619
  }
918
620
 
919
621
  const resetPasswordSagas = [effects.takeEvery(reducers.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(reducers.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(reducers.CHANGE_USER_PASSWORD, changePasswordSaga)];
920
-
921
622
  function* requestPasswordResetSaga(action) {
922
623
  const userEmailObject = action.userEmailObject;
923
624
  yield effects.put({
924
625
  type: reducers.REQUEST_USER_PASSWORD_RESET_SENDING
925
626
  });
926
-
927
627
  if (userEmailObject && userEmailObject.userEmail) {
928
628
  try {
929
629
  const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
930
-
931
630
  if (passwordResetRequestResponse) {
932
631
  if (!passwordResetRequestResponse.error) {
933
632
  yield effects.put({
@@ -958,17 +657,14 @@ function* requestPasswordResetSaga(action) {
958
657
  });
959
658
  }
960
659
  }
961
-
962
660
  function* resetPasswordSaga(action) {
963
661
  const resetPasswordObject = action.resetPasswordObject;
964
662
  yield effects.put({
965
663
  type: reducers.RESET_USER_PASSWORD_SENDING
966
664
  });
967
-
968
665
  if (resetPasswordObject.token && resetPasswordObject.password) {
969
666
  try {
970
667
  const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
971
-
972
668
  if (resetPasswordResponse) {
973
669
  if (!resetPasswordResponse.error) {
974
670
  yield effects.put({
@@ -999,11 +695,11 @@ function* resetPasswordSaga(action) {
999
695
  error: 'Invalid object'
1000
696
  });
1001
697
  }
1002
- } // userId
698
+ }
699
+
700
+ // userId
1003
701
  // existingPassword
1004
702
  // newPassword
1005
-
1006
-
1007
703
  function* changePasswordSaga(action) {
1008
704
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
1009
705
  yield effects.put({
@@ -1012,7 +708,6 @@ function* changePasswordSaga(action) {
1012
708
  });
1013
709
  return;
1014
710
  }
1015
-
1016
711
  try {
1017
712
  const changePasswordObject = {
1018
713
  userId: action.userId,
@@ -1023,25 +718,24 @@ function* changePasswordSaga(action) {
1023
718
  type: reducers.CHANGE_USER_PASSWORD_SENDING
1024
719
  });
1025
720
  const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
1026
- const client = yield login.getManagementApiClient({ ...clientCredentials
721
+ const client = yield login.getManagementApiClient({
722
+ ...clientCredentials
1027
723
  });
1028
724
  const [err, res] = yield awaitToJs.to(client.security.users.updatePassword(changePasswordObject));
1029
-
1030
725
  if (err) {
1031
726
  var _err$data, _err$data$data, _err$data2;
1032
-
1033
727
  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);
1034
728
  yield effects.put({
1035
729
  type: reducers.CHANGE_USER_PASSWORD_ERROR,
1036
730
  error
1037
731
  });
1038
732
  return;
1039
- } // // eslint-disable-next-line no-console
733
+ }
734
+
735
+ // // eslint-disable-next-line no-console
1040
736
  // console.log(changePasswordObject);
1041
737
  // // eslint-disable-next-line no-console
1042
738
  // console.log(userCredentialsObject);
1043
-
1044
-
1045
739
  yield effects.put({
1046
740
  type: reducers.CHANGE_USER_PASSWORD_SUCCESS
1047
741
  });
@@ -1063,35 +757,32 @@ function rootSaga (featureSagas = []) {
1063
757
  };
1064
758
  }
1065
759
 
1066
- const servers = SERVERS;
1067
- /* global SERVERS */
1068
-
760
+ const servers = SERVERS; /* global SERVERS */
1069
761
  const alias = servers.alias.toLowerCase();
1070
- const publicUri = PUBLIC_URI;
1071
- /* global PUBLIC_URI */
762
+ const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
763
+ const projects = PROJECTS; /* global PROJECTS */
1072
764
 
1073
- const projects = PROJECTS;
1074
- /* global PROJECTS */
1075
765
  // return a projectId via the request hostname
1076
-
1077
766
  const pickProject = (hostname, query) => {
1078
767
  // if localhost we can only infer via a querystring, and take your word for it
1079
768
  if (hostname == 'localhost') {
1080
769
  return query && query.p || projects[0].id;
1081
- } // if hostname is the actual public uri we can return the first project from the list
1082
-
770
+ }
1083
771
 
772
+ // if hostname is the actual public uri we can return the first project from the list
1084
773
  if (hostname == publicUri) {
1085
774
  return projects[0].id;
1086
775
  }
776
+ let project = 'unknown';
1087
777
 
1088
- let project = 'unknown'; // // go through all the defined projects
778
+ // // go through all the defined projects
1089
779
  // Object.entries(projects).map(([, p]) => {
780
+ const p = projects[0];
1090
781
 
1091
- const p = projects[0]; // check if we're accessing via the project's public uri
1092
-
1093
- if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
782
+ // check if we're accessing via the project's public uri
783
+ if (hostname.includes(p.publicUri)) project = p.id;
1094
784
 
785
+ // the url structure is different for website (we don't prefix)
1095
786
  if (p.id.startsWith('website')) {
1096
787
  // check for internal and external hostnames
1097
788
  // we check live and preview distinctly so our rule does not clash with
@@ -1100,9 +791,8 @@ const pickProject = (hostname, query) => {
1100
791
  } else {
1101
792
  // check for internal and external hostnames, prefixed with the projectId
1102
793
  if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
1103
- } // });
1104
-
1105
-
794
+ }
795
+ // });
1106
796
  return project === 'unknown' ? p.id : project;
1107
797
  };
1108
798
 
@@ -1112,9 +802,7 @@ const AppRoot = props => {
1112
802
 
1113
803
  exports.AppRoot = AppRoot;
1114
804
  exports.browserHistory = browserHistory;
1115
- exports.cachedSearch = cachedSearch;
1116
- exports.deliveryApi = deliveryApi;
1117
805
  exports.history = history;
1118
806
  exports.pickProject = pickProject;
1119
807
  exports.rootSaga = rootSaga;
1120
- //# sourceMappingURL=App-ee485b92.js.map
808
+ //# sourceMappingURL=App-21a7d836.js.map