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

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