@zengenti/contensis-react-base 3.0.2-beta.3 → 3.0.2-beta.30

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