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