@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.4
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/LICENSE +7 -0
- package/README.md +18 -478
- package/cjs/{App-b56aca04.js → App-DXro6av4.js} +215 -234
- package/cjs/App-DXro6av4.js.map +1 -0
- package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-ECjEXixF.js} +209 -286
- package/cjs/ChangePassword.container-ECjEXixF.js.map +1 -0
- package/cjs/CookieHelper.class-C3Eqoze9.js +471 -0
- package/cjs/CookieHelper.class-C3Eqoze9.js.map +1 -0
- package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-BFc-Wl6M.js} +55 -68
- package/cjs/RouteLoader-BFc-Wl6M.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-4fcf049d.js → SSRContext-CFeZxG9H.js} +165 -119
- package/cjs/SSRContext-CFeZxG9H.js.map +1 -0
- package/cjs/{ToJs-a8d8f3f0.js → ToJs-C9jwV7YB.js} +26 -80
- package/cjs/ToJs-C9jwV7YB.js.map +1 -0
- package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
- package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/cjs/client.js +67 -65
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +387 -3294
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
- package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
- package/cjs/redux.js +19 -20
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +13 -6
- package/cjs/routing.js.map +1 -1
- package/cjs/sagas-CbZhaRNd.js +6010 -0
- package/cjs/sagas-CbZhaRNd.js.map +1 -0
- package/cjs/search.js +105 -305
- package/cjs/search.js.map +1 -1
- package/cjs/selectors-wCs5fHD4.js +460 -0
- package/cjs/selectors-wCs5fHD4.js.map +1 -0
- package/cjs/{version-34d91f68.js → store-D07FOXvM.js} +44 -114
- package/cjs/store-D07FOXvM.js.map +1 -0
- package/cjs/{urls-6fcaf4c6.js → urls-DVIwGZmd.js} +1 -1
- package/{esm/urls-eac9a747.js.map → cjs/urls-DVIwGZmd.js.map} +1 -1
- package/cjs/user.js +12 -20
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +109 -116
- package/cjs/util.js.map +1 -1
- package/cjs/{version-a410c88e.js → version-B7XFkBhY.js} +19 -22
- package/{esm/version-9f29becb.js.map → cjs/version-B7XFkBhY.js.map} +1 -1
- package/cjs/version-CM-bJ62L.js +20 -0
- package/cjs/version-CM-bJ62L.js.map +1 -0
- package/esm/{App-83107d7e.js → App-CIlf4cl4.js} +176 -195
- package/esm/App-CIlf4cl4.js.map +1 -0
- package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-C0tFq0Tf.js} +191 -250
- package/esm/ChangePassword.container-C0tFq0Tf.js.map +1 -0
- package/esm/CookieHelper.class-FTURFpz3.js +464 -0
- package/esm/CookieHelper.class-FTURFpz3.js.map +1 -0
- package/esm/{RouteLoader-29fd689a.js → RouteLoader-D7HmVx5l.js} +40 -53
- package/esm/RouteLoader-D7HmVx5l.js.map +1 -0
- package/esm/{ContensisDeliveryApi-fe57a037.js → SSRContext-CkiWIvde.js} +159 -120
- package/esm/SSRContext-CkiWIvde.js.map +1 -0
- package/esm/{ToJs-df57f31d.js → ToJs-CpPNdcXS.js} +24 -77
- package/esm/ToJs-CpPNdcXS.js.map +1 -0
- package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
- package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/esm/client.js +55 -53
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +318 -3223
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
- package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
- package/esm/redux.js +10 -9
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +13 -4
- package/esm/routing.js.map +1 -1
- package/esm/sagas-xJU-zOpn.js +5916 -0
- package/esm/sagas-xJU-zOpn.js.map +1 -0
- package/esm/search.js +113 -311
- package/esm/search.js.map +1 -1
- package/esm/selectors-CBdCY0u3.js +396 -0
- package/esm/selectors-CBdCY0u3.js.map +1 -0
- package/esm/{version-3d9911e2.js → store-v2gyr6u2.js} +38 -85
- package/esm/store-v2gyr6u2.js.map +1 -0
- package/esm/{urls-eac9a747.js → urls-DfCisos-.js} +1 -1
- package/{cjs/urls-6fcaf4c6.js.map → esm/urls-DfCisos-.js.map} +1 -1
- package/esm/user.js +7 -13
- package/esm/user.js.map +1 -1
- package/esm/util.js +67 -75
- package/esm/util.js.map +1 -1
- package/esm/version-D773TD9j.js +15 -0
- package/esm/version-D773TD9j.js.map +1 -0
- package/esm/{version-9f29becb.js → version-DvjTUbcA.js} +6 -9
- package/{cjs/version-a410c88e.js.map → esm/version-DvjTUbcA.js.map} +1 -1
- package/models/app/App.d.ts +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +4 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
- package/models/client/client.d.ts +1 -1
- package/models/index.d.ts +1 -2
- package/models/models/AppRouteProps.d.ts +11 -0
- package/models/{redux/appstate.d.ts → models/AppState.d.ts} +3 -3
- package/models/models/ContentTypeMapping.d.ts +89 -0
- package/models/models/EntryMapper.d.ts +3 -0
- package/models/models/GetRouteActionArgs.d.ts +15 -0
- package/models/models/MatchedRoute.d.ts +4 -0
- package/models/models/ReduxInjector.d.ts +5 -0
- package/models/models/RequireLogin.d.ts +6 -0
- package/models/models/RouteComponent.d.ts +4 -0
- package/models/models/RouteComponentProps.d.ts +9 -0
- package/models/models/RouteLoaderProps.d.ts +9 -0
- package/models/models/RouteNode.d.ts +5 -0
- package/models/models/SSRContext.d.ts +11 -0
- package/models/models/StaticRoute.d.ts +61 -0
- package/models/models/WithEvents.d.ts +58 -0
- package/models/models/config/AppConfig.d.ts +12 -0
- package/models/{config.d.ts → models/config/ServerConfig.d.ts} +3 -12
- package/models/models/config/StateType.d.ts +1 -0
- package/models/models/config/index.d.ts +3 -0
- package/models/models/index.d.ts +16 -0
- package/models/redux/actions/index.d.ts +2 -2
- package/models/redux/sagas/navigation.d.ts +1 -3
- package/models/redux/selectors/index.d.ts +2 -2
- package/models/redux/store/injectors.d.ts +16 -4
- package/models/redux/store/store.d.ts +10 -4
- package/models/redux/types/index.d.ts +2 -2
- package/models/redux/types/navigation.d.ts +3 -3
- package/models/redux/types/version.d.ts +2 -2
- package/models/routing/components/Redirect.d.ts +1 -1
- package/models/routing/components/RouteLoader.d.ts +1 -1
- package/models/routing/components/StaticRouteLoader.d.ts +1 -1
- package/models/routing/components/Status.d.ts +1 -1
- package/models/routing/redux/actions.d.ts +3 -4
- package/models/routing/redux/selectors.d.ts +2 -2
- package/models/routing/redux/types.d.ts +11 -11
- package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
- package/models/routing/util/queries.d.ts +2 -2
- package/models/search/containers/withListing.d.ts +4 -1
- package/models/search/containers/withSearch.d.ts +4 -1
- package/models/search/models/Queries.d.ts +4 -2
- package/models/search/models/Search.d.ts +8 -1
- package/models/search/models/SearchActions.d.ts +3 -2
- package/models/search/models/SearchState.d.ts +5 -1
- package/models/search/redux/reducers.d.ts +2 -257
- package/models/search/redux/schema.d.ts +1 -1
- package/models/search/redux/selectors.d.ts +5 -5
- package/models/search/search/ContensisDeliveryApi.d.ts +2 -2
- package/models/search/search/ToJs.d.ts +1 -1
- package/models/search/search/expressions.d.ts +3 -3
- package/models/search/search/util.d.ts +17 -2
- package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
- package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
- package/models/server/features/linkdepth-api/search.d.ts +1 -1
- package/models/server/features/static-assets/index.d.ts +1 -1
- package/models/server/internalServer.d.ts +1 -1
- package/models/server/util/bundles.d.ts +1 -1
- package/models/server/util/headers.d.ts +1 -1
- package/models/server/webApp.d.ts +1 -1
- package/models/user/components/Login.d.ts +1 -1
- package/models/user/components/LoginForm.d.ts +6 -6
- package/models/user/components/LogoutForm.d.ts +4 -4
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/user/hocs/withLogin.d.ts +4 -4
- package/models/user/hocs/withRegistration.d.ts +6 -3
- package/models/user/hooks/useLogin.d.ts +4 -4
- package/models/user/redux/actions.d.ts +7 -6
- package/models/user/redux/sagas/index.d.ts +1 -1
- package/models/user/redux/sagas/login.d.ts +5 -17
- package/models/user/redux/selectors.d.ts +1 -2
- package/models/user/redux/types.d.ts +21 -21
- package/models/user/state.d.ts +12 -0
- package/models/user/transformations/mapClientCredentials.d.ts +3 -1
- package/models/user/util/ContensisManagementApi.d.ts +10 -9
- package/models/user/util/CookieConstants.d.ts +1 -0
- package/models/user/util/CookieHelper.class.d.ts +8 -4
- package/models/user/util/LoginHelper.class.d.ts +25 -37
- package/models/user/util/OidcUserManager.d.ts +1 -1
- package/models/user/util/matchGroups.d.ts +1 -1
- package/models/util/CachedDeliveryApi.d.ts +11 -10
- package/models/util/ContensisDeliveryApi.d.ts +11 -7
- package/models/util/SSRContext.d.ts +29 -0
- package/models/util/index.d.ts +1 -0
- package/models/util/json-mapper.d.ts +4 -5
- package/package.json +71 -92
- package/cjs/App-b56aca04.js.map +0 -1
- package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
- package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
- package/cjs/CookieConstants-000427db.js +0 -10
- package/cjs/CookieConstants-000427db.js.map +0 -1
- package/cjs/RouteLoader-c06dccd5.js.map +0 -1
- package/cjs/ToJs-a8d8f3f0.js.map +0 -1
- package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
- package/cjs/forms.js +0 -5998
- package/cjs/forms.js.map +0 -1
- package/cjs/reducers-73a03ef4.js +0 -257
- package/cjs/reducers-73a03ef4.js.map +0 -1
- package/cjs/sagas-570f23ba.js +0 -2175
- package/cjs/sagas-570f23ba.js.map +0 -1
- package/cjs/selectors-14caa813.js +0 -228
- package/cjs/selectors-14caa813.js.map +0 -1
- package/cjs/version-34d91f68.js.map +0 -1
- package/esm/App-83107d7e.js.map +0 -1
- package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
- package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
- package/esm/CookieConstants-3d3b6531.js +0 -6
- package/esm/CookieConstants-3d3b6531.js.map +0 -1
- package/esm/RouteLoader-29fd689a.js.map +0 -1
- package/esm/ToJs-df57f31d.js.map +0 -1
- package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
- package/esm/forms.js +0 -5984
- package/esm/forms.js.map +0 -1
- package/esm/reducers-aa8cef1e.js +0 -234
- package/esm/reducers-aa8cef1e.js.map +0 -1
- package/esm/sagas-07e82e18.js +0 -2083
- package/esm/sagas-07e82e18.js.map +0 -1
- package/esm/selectors-691caf02.js +0 -186
- package/esm/selectors-691caf02.js.map +0 -1
- package/esm/version-3d9911e2.js.map +0 -1
- package/models/forms/index.d.ts +0 -1
- package/models/routing/routes.d.ts +0 -133
|
@@ -1,40 +1,43 @@
|
|
|
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 { h as hasNavigationTree, i as injectRedux } from './version-9f29becb.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-691caf02.js';
|
|
4
|
+
import { G as GET_NODE_TREE, b as SET_NODE_TREE, d as GET_NODE_TREE_ERROR } from './store-v2gyr6u2.js';
|
|
5
|
+
import { h as hasNavigationTree, i as injectRedux } from './version-DvjTUbcA.js';
|
|
8
6
|
import to, { to as to$1 } from 'await-to-js';
|
|
9
|
-
import {
|
|
7
|
+
import { y as SET_NAVIGATION_PATH, x as SET_ROUTE, j as selectRouteEntry, C as selectCurrentNode, f as selectCurrentProject, z as UPDATE_LOADING_STATE, D as selectCurrentAncestors, E as selectCurrentSiblings, F as selectRouteEntryEntryId, G as selectRouteEntryLanguage, n as selectMappedEntry, A as SET_ENTRY, B as SET_ANCESTORS, w as SET_SIBLINGS, R as REGISTER_USER, H as REGISTER_USER_SUCCESS, I as REGISTER_USER_FAILED, J as queryParams, K as selectCurrentSearch, L as setRoute, M as REQUEST_USER_PASSWORD_RESET, N as RESET_USER_PASSWORD, O as CHANGE_USER_PASSWORD, P as REQUEST_USER_PASSWORD_RESET_SENDING, Q as REQUEST_USER_PASSWORD_RESET_SUCCESS, T as REQUEST_USER_PASSWORD_RESET_ERROR, V as RESET_USER_PASSWORD_SENDING, W as RESET_USER_PASSWORD_SUCCESS, X as RESET_USER_PASSWORD_ERROR, Y as CHANGE_USER_PASSWORD_ERROR, Z as CHANGE_USER_PASSWORD_SENDING, _ as CHANGE_USER_PASSWORD_SUCCESS } from './selectors-CBdCY0u3.js';
|
|
8
|
+
import { s as selectVersionStatus } from './version-D773TD9j.js';
|
|
9
|
+
import { h as handleRequiresLoginSaga, L as LoginHelper, i as findContentTypeMapping, j as getManagementApiClient, k as loginSagas } from './ChangePassword.container-C0tFq0Tf.js';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import 'react-cookie';
|
|
12
12
|
import 'react-redux';
|
|
13
13
|
import 'jsonpath-mapper';
|
|
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-aa8cef1e.js';
|
|
15
14
|
import { Op, Query } from 'contensis-delivery-api';
|
|
16
|
-
import {
|
|
15
|
+
import { l as selectClientCredentials } from './ToJs-CpPNdcXS.js';
|
|
17
16
|
import 'query-string';
|
|
18
17
|
import 'react-router-dom';
|
|
19
|
-
import {
|
|
18
|
+
import { a as RouteLoader } from './RouteLoader-D7HmVx5l.js';
|
|
20
19
|
|
|
20
|
+
// Create a history depending on the environment
|
|
21
21
|
const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
|
|
22
22
|
const history = (options = {}) => selectedHistory(options);
|
|
23
23
|
const browserHistory = selectedHistory();
|
|
24
24
|
|
|
25
25
|
const navigationSagas = [takeEvery(GET_NODE_TREE, ensureNodeTreeSaga)];
|
|
26
26
|
function* ensureNodeTreeSaga(action) {
|
|
27
|
+
const {
|
|
28
|
+
api,
|
|
29
|
+
language,
|
|
30
|
+
project,
|
|
31
|
+
versionStatus,
|
|
32
|
+
treeDepth
|
|
33
|
+
} = action;
|
|
27
34
|
const state = yield select();
|
|
28
|
-
|
|
29
35
|
try {
|
|
30
36
|
if (!hasNavigationTree(state)) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
language: action.language
|
|
36
|
-
});
|
|
37
|
-
|
|
37
|
+
const nodes = yield api.getRootNode({
|
|
38
|
+
depth: treeDepth || 0,
|
|
39
|
+
language
|
|
40
|
+
}, versionStatus, project);
|
|
38
41
|
if (nodes) {
|
|
39
42
|
yield put({
|
|
40
43
|
type: SET_NODE_TREE,
|
|
@@ -56,23 +59,10 @@ function* ensureNodeTreeSaga(action) {
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
const sys = {
|
|
59
|
-
contentTypeId: 'sys.contentTypeId',
|
|
60
|
-
dataFormat: 'sys.dataFormat',
|
|
61
|
-
filename: 'sys.properties.filename',
|
|
62
|
-
id: 'sys.id',
|
|
63
|
-
includeInSearch: 'sys.metadata.includeInSearch',
|
|
64
|
-
slug: 'sys.slug',
|
|
65
|
-
uri: 'sys.uri',
|
|
66
62
|
versionStatus: 'sys.versionStatus'
|
|
67
63
|
};
|
|
68
64
|
const Fields = {
|
|
69
|
-
|
|
70
|
-
entryDescription: 'entryDescription',
|
|
71
|
-
keywords: 'keywords',
|
|
72
|
-
sys,
|
|
73
|
-
contentTypeId: 'sys.contentTypeId',
|
|
74
|
-
wildcard: '*'
|
|
75
|
-
};
|
|
65
|
+
sys};
|
|
76
66
|
|
|
77
67
|
const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
78
68
|
if (!field || !value) return [];
|
|
@@ -81,21 +71,21 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
|
81
71
|
const defaultExpressions = versionStatus => {
|
|
82
72
|
return [Op.equalTo(Fields.sys.versionStatus, versionStatus)];
|
|
83
73
|
};
|
|
84
|
-
|
|
85
74
|
const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [Op[operator](field, arr[0])] : [Op.in(field, ...arr)];
|
|
86
75
|
|
|
87
|
-
const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
|
|
88
|
-
const query = new Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...defaultExpressions(versionStatus)]);
|
|
76
|
+
const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fields = [], fieldLinkDepths, versionStatus = 'published') => {
|
|
77
|
+
const query = new Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...(contentTypeId ? fieldExpression('sys.contentTypeId', contentTypeId) : fieldExpression('sys.dataFormat', 'entry')), ...defaultExpressions(versionStatus)]);
|
|
89
78
|
query.fields = fields;
|
|
79
|
+
query.fieldLinkDepths = fieldLinkDepths;
|
|
90
80
|
return query;
|
|
91
81
|
};
|
|
92
82
|
|
|
93
83
|
const routingSagas = [takeEvery(SET_NAVIGATION_PATH, getRouteSaga), takeEvery(SET_ROUTE, setRouteSaga)];
|
|
84
|
+
|
|
94
85
|
/**
|
|
95
86
|
* To navigate / push a specific route via redux middleware
|
|
96
87
|
* @param {path, state} action
|
|
97
88
|
*/
|
|
98
|
-
|
|
99
89
|
function* setRouteSaga(action) {
|
|
100
90
|
yield put({
|
|
101
91
|
type: 'CALL_HISTORY_METHOD',
|
|
@@ -105,87 +95,97 @@ function* setRouteSaga(action) {
|
|
|
105
95
|
}
|
|
106
96
|
});
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
function* getRouteSaga(action) {
|
|
110
99
|
let entry = null;
|
|
111
|
-
|
|
112
100
|
try {
|
|
113
|
-
var _staticRoute$route, _staticRoute$
|
|
114
|
-
|
|
101
|
+
var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
|
|
115
102
|
const {
|
|
116
103
|
withEvents,
|
|
117
104
|
routes: {
|
|
118
105
|
ContentTypeMappings = {}
|
|
119
106
|
} = {},
|
|
120
107
|
staticRoute,
|
|
121
|
-
|
|
108
|
+
// get api instance from ssr context that is connected to the specific request in ssr
|
|
109
|
+
ssr: {
|
|
110
|
+
api
|
|
111
|
+
}
|
|
122
112
|
} = action;
|
|
123
|
-
const api = cachedSearchWithCookies(cookies.raw); // Inject redux { key, reducer, saga } provided by staticRoute
|
|
124
113
|
|
|
125
|
-
|
|
114
|
+
// Inject redux { key, reducer, saga } provided by staticRoute
|
|
115
|
+
if (staticRoute && staticRoute.route.injectRedux) yield call(reduxInjectorSaga, staticRoute.route.injectRedux);
|
|
126
116
|
|
|
117
|
+
// Variables we will pass to setRouteEntry
|
|
127
118
|
let pathNode = null,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let contentTypeMapping = {};
|
|
132
|
-
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
119
|
+
ancestors = null,
|
|
120
|
+
children = [],
|
|
121
|
+
siblings = null;
|
|
122
|
+
let contentTypeMapping = {};
|
|
133
123
|
|
|
124
|
+
// These variables are the return values from
|
|
125
|
+
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
134
126
|
let appsays,
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
requireLogin = false;
|
|
137
128
|
if (withEvents && withEvents.onRouteLoad) {
|
|
138
129
|
appsays = yield withEvents.onRouteLoad(action);
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
// We could improve this further with a reusable mapper
|
|
133
|
+
// function to return these params given a static route
|
|
134
|
+
// or matching a content type mapping we could call at various points
|
|
135
|
+
// enabling us to mix and match and prioritise inputs if there are multiple
|
|
136
|
+
let linkDepth = staticRoute === null || staticRoute === void 0 || (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 || (_staticRoute$route = _staticRoute$route.fetchNode) === null || _staticRoute$route === void 0 ? void 0 : _staticRoute$route.linkDepth;
|
|
137
|
+
let fields = staticRoute === null || staticRoute === void 0 || (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 || (_staticRoute$route2 = _staticRoute$route2.fetchNode) === null || _staticRoute$route2 === void 0 ? void 0 : _staticRoute$route2.fields;
|
|
138
|
+
let fieldLinkDepths = staticRoute === null || staticRoute === void 0 || (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 || (_staticRoute$route3 = _staticRoute$route3.fetchNode) === null || _staticRoute$route3 === void 0 ? void 0 : _staticRoute$route3.fieldLinkDepths;
|
|
139
|
+
let entryMapper = staticRoute === null || staticRoute === void 0 || (_staticRoute$route4 = staticRoute.route) === null || _staticRoute$route4 === void 0 || (_staticRoute$route4 = _staticRoute$route4.fetchNode) === null || _staticRoute$route4 === void 0 ? void 0 : _staticRoute$route4.entryMapper;
|
|
143
140
|
const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
|
|
144
|
-
const
|
|
141
|
+
const entryFieldLinkDepths = (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.entryFieldLinkDepths;
|
|
142
|
+
const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
|
|
143
|
+
const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
|
|
145
144
|
const state = yield select();
|
|
146
145
|
const routeEntry = selectRouteEntry(state, 'js');
|
|
147
146
|
const routeNode = selectCurrentNode(state, 'js');
|
|
148
147
|
const currentPath = action.path; //selectCurrentPath(state);
|
|
149
|
-
|
|
150
148
|
const deliveryApiStatus = selectVersionStatus(state);
|
|
151
|
-
const project = selectCurrentProject(state);
|
|
152
|
-
|
|
149
|
+
const project = selectCurrentProject(state);
|
|
150
|
+
// const isHome = currentPath === '/';
|
|
153
151
|
const isPreview = currentPath && currentPath.startsWith('/preview/');
|
|
154
152
|
const defaultLang = appsays && appsays.defaultLang || 'en-GB';
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
if (!isPreview && ((_appsays2 = appsays) !== null && _appsays2 !== void 0 && _appsays2.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && ((_appsays3 = appsays) === null || _appsays3 === void 0 ? void 0 : _appsays3.refetchNode) !== true)) {
|
|
154
|
+
var _staticRoute$route5;
|
|
157
155
|
// To prevent erroneous 404s and wasted network calls, this covers
|
|
158
156
|
// - appsays customRouting and does SET_ENTRY etc. via the consuming app
|
|
159
157
|
// - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
|
|
160
158
|
// - standard Contensis SiteView Routing where we already have that entry in state
|
|
161
|
-
if (routeEntry && (!staticRoute || staticRoute
|
|
162
|
-
pathNode = {
|
|
159
|
+
if (routeEntry && (!staticRoute || staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route5 = staticRoute.route) !== null && _staticRoute$route5 !== void 0 && _staticRoute$route5.fetchNode)) {
|
|
160
|
+
pathNode = {
|
|
161
|
+
...routeNode,
|
|
163
162
|
entry: null
|
|
164
163
|
};
|
|
165
|
-
pathNode.entry = entry = routeEntry;
|
|
164
|
+
pathNode.entry = entry = routeEntry;
|
|
165
|
+
//Do nothing, the entry is allready the right one.
|
|
166
166
|
// yield put({
|
|
167
167
|
// type: SET_ENTRY,
|
|
168
168
|
// entry,
|
|
169
169
|
// node: routeNode,
|
|
170
170
|
// isLoading: false,
|
|
171
171
|
// });
|
|
172
|
-
|
|
173
172
|
yield put({
|
|
174
173
|
type: UPDATE_LOADING_STATE,
|
|
175
174
|
isLoading: false
|
|
176
175
|
});
|
|
177
176
|
} else yield call(setRouteEntry, currentPath, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
|
|
178
177
|
} else {
|
|
178
|
+
var _staticRoute$route6;
|
|
179
179
|
// Handle preview routes
|
|
180
180
|
if (isPreview) {
|
|
181
181
|
let splitPath = currentPath.split('/');
|
|
182
182
|
let entryGuid = splitPath[2];
|
|
183
183
|
let language = defaultLang;
|
|
184
|
-
|
|
185
184
|
if (splitPath.length >= 3) {
|
|
186
185
|
//set lang key if available in the path, else use default lang
|
|
187
186
|
//assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
|
|
188
|
-
if (splitPath.length == 4) language = splitPath[3];
|
|
187
|
+
if (splitPath.length == 4) language = splitPath[3];
|
|
188
|
+
// According to product dev we cannot use Node API
|
|
189
189
|
// for previewing entries as it gives a response of []
|
|
190
190
|
// -- apparently it is not correct to request latest content
|
|
191
191
|
// with Node API
|
|
@@ -195,7 +195,6 @@ function* getRouteSaga(action) {
|
|
|
195
195
|
language,
|
|
196
196
|
linkDepth: entryLinkDepth
|
|
197
197
|
});
|
|
198
|
-
|
|
199
198
|
if (previewEntry) {
|
|
200
199
|
pathNode = {
|
|
201
200
|
entry: previewEntry
|
|
@@ -206,29 +205,30 @@ function* getRouteSaga(action) {
|
|
|
206
205
|
}
|
|
207
206
|
}
|
|
208
207
|
} else {
|
|
209
|
-
var _pathNode,
|
|
210
|
-
|
|
208
|
+
var _pathNode, _pathNode2;
|
|
211
209
|
// Handle all other routes
|
|
212
210
|
let nodeError = undefined;
|
|
211
|
+
// Resolve a stub of route node if we are setting limits in content type mappings
|
|
212
|
+
// Resolve the complete entry with the node if we are setting limits in a static route
|
|
213
213
|
[nodeError, pathNode] = yield to(api.getNode({
|
|
214
214
|
depth: 0,
|
|
215
215
|
path: currentPath,
|
|
216
|
-
entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] :
|
|
217
|
-
entryLinkDepth:
|
|
216
|
+
entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
|
|
217
|
+
entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
|
|
218
|
+
entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
|
|
218
219
|
language: defaultLang,
|
|
219
220
|
versionStatus: deliveryApiStatus
|
|
220
221
|
}, project));
|
|
221
|
-
|
|
222
222
|
if (nodeError) {
|
|
223
223
|
if ([401, 403].includes(nodeError.status)) {
|
|
224
224
|
// Capture specific auth errors with the delivery api
|
|
225
225
|
// and fire the user down the handleRequiresLoginSaga
|
|
226
226
|
// If auth was successful via a refreshToken we need to reload the page
|
|
227
227
|
// to run this getRouteSaga again with the security token cookie
|
|
228
|
-
const userLoggedIn = yield call(handleRequiresLoginSaga, {
|
|
228
|
+
const userLoggedIn = yield call(handleRequiresLoginSaga, {
|
|
229
|
+
...action,
|
|
229
230
|
requireLogin: true
|
|
230
231
|
});
|
|
231
|
-
|
|
232
232
|
if (userLoggedIn && nodeError.status === 401) {
|
|
233
233
|
// Reload the route so we can re-run the routing request now the
|
|
234
234
|
// authentication cookies are written
|
|
@@ -247,31 +247,41 @@ function* getRouteSaga(action) {
|
|
|
247
247
|
entry
|
|
248
248
|
} = pathNode || {});
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
// Try resolve a content type mapping
|
|
251
|
+
if ((_pathNode = pathNode) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.entry) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.sys) !== null && _pathNode !== void 0 && _pathNode.id && pathNode.entry.sys.contentTypeId) {
|
|
253
252
|
// Get fields[] and linkDepth from ContentTypeMapping to get the entry data
|
|
254
253
|
// and current node's ordinates at a specified depth with specified fields
|
|
255
|
-
contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId)
|
|
256
|
-
|
|
254
|
+
contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Run a second search query if we aren't setting limits from a static route
|
|
258
|
+
// but we are setting limits from a content type mapping, now we have a handle
|
|
259
|
+
// on a contentTypeId from the resolve node, we can apply the right limits when
|
|
260
|
+
// fetching the entry
|
|
261
|
+
if (!setStaticRouteLimits && setContentTypeLimits && (_pathNode2 = pathNode) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.entry) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.sys) !== null && _pathNode2 !== void 0 && _pathNode2.id) {
|
|
262
|
+
var _payload$items;
|
|
263
|
+
// Now we have a handle on a content type mapping we can
|
|
264
|
+
// reassign the query limiting variables if we haven't
|
|
265
|
+
// already set them in a static route
|
|
266
|
+
if (!setStaticRouteLimits) ({
|
|
267
|
+
fieldLinkDepths,
|
|
257
268
|
fields,
|
|
258
269
|
linkDepth
|
|
259
|
-
} = contentTypeMapping;
|
|
260
|
-
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
|
|
270
|
+
} = contentTypeMapping || {});
|
|
271
|
+
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, pathNode.entry.sys.contentTypeId, fields, fieldLinkDepths, deliveryApiStatus);
|
|
261
272
|
const payload = yield api.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
|
|
262
|
-
|
|
263
|
-
if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
273
|
+
if ((payload === null || payload === void 0 || (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
264
274
|
pathNode.entry = entry = payload.items[0];
|
|
265
275
|
}
|
|
266
276
|
}
|
|
267
|
-
}
|
|
268
|
-
// siblings or entire node tree
|
|
269
|
-
|
|
277
|
+
}
|
|
270
278
|
|
|
279
|
+
// make calls to fetch node ancestors, children,
|
|
280
|
+
// siblings or entire node tree
|
|
271
281
|
[ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
|
|
272
282
|
api,
|
|
273
283
|
appsays,
|
|
274
|
-
contentTypeMapping,
|
|
284
|
+
contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
|
|
275
285
|
language: defaultLang,
|
|
276
286
|
path: currentPath,
|
|
277
287
|
pathNode,
|
|
@@ -280,39 +290,36 @@ function* getRouteSaga(action) {
|
|
|
280
290
|
});
|
|
281
291
|
if (children) pathNode.children = children;
|
|
282
292
|
}
|
|
293
|
+
const resolvedContentTypeMapping = findContentTypeMapping(ContentTypeMappings, (_pathNode3 = pathNode) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.entry) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.sys) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.contentTypeId) || {};
|
|
283
294
|
|
|
284
|
-
|
|
285
|
-
|
|
295
|
+
// Inject redux { key, reducer, saga } provided by ContentTypeMapping
|
|
286
296
|
if (resolvedContentTypeMapping.injectRedux) yield call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
|
|
287
|
-
|
|
288
297
|
if (withEvents && withEvents.onRouteLoaded) {
|
|
289
298
|
// Check if the app has provided a requireLogin boolean flag or groups array
|
|
290
299
|
// in addition to checking if requireLogin is set in the route definition
|
|
291
300
|
({
|
|
292
301
|
requireLogin
|
|
293
|
-
} = (yield withEvents.onRouteLoaded({
|
|
302
|
+
} = (yield withEvents.onRouteLoaded({
|
|
303
|
+
...action,
|
|
294
304
|
entry
|
|
295
305
|
})) || {});
|
|
296
306
|
}
|
|
297
|
-
|
|
298
307
|
if (requireLogin !== false) {
|
|
299
308
|
// Do not call the login feature saga if requireLogin is false
|
|
300
|
-
yield call(handleRequiresLoginSaga, {
|
|
309
|
+
yield call(handleRequiresLoginSaga, {
|
|
310
|
+
...action,
|
|
301
311
|
entry,
|
|
302
312
|
requireLogin
|
|
303
313
|
});
|
|
304
314
|
}
|
|
305
|
-
|
|
306
315
|
if (!appsays || !appsays.preventScrollTop) {
|
|
307
316
|
// Scroll into View
|
|
308
317
|
if (typeof window !== 'undefined') window.scrollTo(0, 0);
|
|
309
318
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
var _staticRoute$route3, _staticRoute$route3$f, _appsays;
|
|
313
|
-
|
|
319
|
+
if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
|
|
320
|
+
var _appsays4;
|
|
314
321
|
entry = pathNode.entry;
|
|
315
|
-
yield call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings,
|
|
322
|
+
yield call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || resolvedContentTypeMapping.entryMapper, false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
|
|
316
323
|
} else {
|
|
317
324
|
if (staticRoute) yield call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield call(do404);
|
|
318
325
|
}
|
|
@@ -321,29 +328,30 @@ function* getRouteSaga(action) {
|
|
|
321
328
|
yield call(do500, e);
|
|
322
329
|
}
|
|
323
330
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
const apiCall = [() => null, () => null, () => null, () => null];
|
|
331
|
+
function* resolveCurrentNodeOrdinates(action) {
|
|
332
|
+
const {
|
|
333
|
+
api,
|
|
334
|
+
appsays,
|
|
335
|
+
contentTypeMapping,
|
|
336
|
+
language,
|
|
337
|
+
path,
|
|
338
|
+
pathNode,
|
|
339
|
+
project,
|
|
340
|
+
versionStatus
|
|
341
|
+
} = action;
|
|
342
|
+
const apiCall = [() => null, () => null, () => null, () => null];
|
|
343
|
+
|
|
344
|
+
// if appsays customNavigation: true, we will set doNavigation to false
|
|
336
345
|
// if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
|
|
337
346
|
// if appsays nothing we will set doNavigation to true and continue to do navigation calls
|
|
338
|
-
|
|
339
347
|
const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
|
|
340
348
|
const {
|
|
341
349
|
entryLinkDepth = 0,
|
|
350
|
+
fieldLinkDepths,
|
|
342
351
|
fields,
|
|
343
352
|
linkDepth,
|
|
344
353
|
nodeOptions = {}
|
|
345
354
|
} = contentTypeMapping;
|
|
346
|
-
|
|
347
355
|
if (pathNode && pathNode.id) {
|
|
348
356
|
if (doNavigation === true || doNavigation.ancestors) {
|
|
349
357
|
apiCall[0] = function* getAncestors() {
|
|
@@ -359,17 +367,15 @@ function* resolveCurrentNodeOrdinates({
|
|
|
359
367
|
}
|
|
360
368
|
};
|
|
361
369
|
}
|
|
362
|
-
|
|
363
370
|
const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
|
|
364
|
-
|
|
365
371
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
|
|
366
|
-
const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
367
|
-
|
|
372
|
+
const childrenOptions = !nodeOptions.children || typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
368
373
|
apiCall[1] = function* getChildren() {
|
|
369
374
|
try {
|
|
370
375
|
return yield api.getNode({
|
|
371
376
|
depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
|
|
372
377
|
path,
|
|
378
|
+
entryFieldLinkDepths: childrenOptions.fieldLinkDepths || fieldLinkDepths,
|
|
373
379
|
entryFields: childrenOptions.fields || fields || undefined,
|
|
374
380
|
entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
|
|
375
381
|
language,
|
|
@@ -381,16 +387,15 @@ function* resolveCurrentNodeOrdinates({
|
|
|
381
387
|
}
|
|
382
388
|
};
|
|
383
389
|
}
|
|
384
|
-
|
|
385
390
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
|
|
386
391
|
apiCall[2] = function* getSiblings() {
|
|
387
392
|
try {
|
|
388
|
-
var _nodeOptions$siblings, _nodeOptions$siblings2;
|
|
389
|
-
|
|
393
|
+
var _nodeOptions$siblings, _nodeOptions$siblings2, _nodeOptions$siblings3;
|
|
390
394
|
return yield api.getSiblings({
|
|
391
395
|
id: pathNode.id,
|
|
392
|
-
|
|
393
|
-
|
|
396
|
+
entryFieldLinkDepths: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fieldLinkDepths) || fieldLinkDepths,
|
|
397
|
+
entryFields: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.fields) || fields || undefined,
|
|
398
|
+
entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings3 = nodeOptions.siblings) === null || _nodeOptions$siblings3 === void 0 ? void 0 : _nodeOptions$siblings3.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
|
|
394
399
|
includeInMenu: true,
|
|
395
400
|
language,
|
|
396
401
|
versionStatus
|
|
@@ -402,20 +407,18 @@ function* resolveCurrentNodeOrdinates({
|
|
|
402
407
|
};
|
|
403
408
|
}
|
|
404
409
|
}
|
|
405
|
-
|
|
406
410
|
const isTreeLoaded = yield select(hasNavigationTree);
|
|
407
411
|
if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
|
|
408
412
|
const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
|
|
409
|
-
|
|
410
413
|
if (typeof window !== 'undefined') {
|
|
411
414
|
return yield put({
|
|
412
415
|
type: GET_NODE_TREE,
|
|
413
|
-
|
|
416
|
+
...action,
|
|
414
417
|
treeDepth
|
|
415
418
|
});
|
|
416
419
|
} else {
|
|
417
420
|
return yield call(ensureNodeTreeSaga, {
|
|
418
|
-
|
|
421
|
+
...action,
|
|
419
422
|
treeDepth
|
|
420
423
|
});
|
|
421
424
|
}
|
|
@@ -424,15 +427,16 @@ function* resolveCurrentNodeOrdinates({
|
|
|
424
427
|
const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
|
|
425
428
|
return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
|
|
426
429
|
}
|
|
427
|
-
|
|
428
430
|
function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
|
|
429
|
-
const entrySys = entry && entry.sys || {};
|
|
430
|
-
// an updated entry id in client-side navigation
|
|
431
|
+
const entrySys = entry && entry.sys || {};
|
|
431
432
|
|
|
433
|
+
// Update a window global to provide the preview toolbar
|
|
434
|
+
// an updated entry id in client-side navigation
|
|
432
435
|
if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
|
|
433
436
|
const currentEntryId = yield select(selectRouteEntryEntryId);
|
|
434
437
|
const currentEntryLang = yield select(selectRouteEntryLanguage);
|
|
435
|
-
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
438
|
+
const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
439
|
+
...node,
|
|
436
440
|
entry,
|
|
437
441
|
ancestors,
|
|
438
442
|
siblings
|
|
@@ -453,7 +457,6 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
|
|
|
453
457
|
siblings
|
|
454
458
|
})]);
|
|
455
459
|
}
|
|
456
|
-
|
|
457
460
|
function* mapRouteEntry(entryMapper, node) {
|
|
458
461
|
try {
|
|
459
462
|
if (typeof entryMapper === 'function') {
|
|
@@ -463,11 +466,10 @@ function* mapRouteEntry(entryMapper, node) {
|
|
|
463
466
|
}
|
|
464
467
|
} catch (e) {
|
|
465
468
|
log.error(...['Error running entryMapper:', e, e.stack]);
|
|
469
|
+
throw e;
|
|
466
470
|
}
|
|
467
|
-
|
|
468
471
|
return;
|
|
469
472
|
}
|
|
470
|
-
|
|
471
473
|
function* do404() {
|
|
472
474
|
yield call(clientReloadHitServer);
|
|
473
475
|
yield put({
|
|
@@ -477,17 +479,16 @@ function* do404() {
|
|
|
477
479
|
notFound: true
|
|
478
480
|
});
|
|
479
481
|
}
|
|
480
|
-
|
|
481
482
|
function* clientReloadHitServer() {
|
|
482
|
-
const stateEntry = yield select(selectRouteEntry);
|
|
483
|
+
const stateEntry = yield select(selectRouteEntry);
|
|
484
|
+
|
|
485
|
+
// If in client and there is a stateEntry.sys field reload the page,
|
|
483
486
|
// on the 2nd load stateEntry.sys should be null at this point,
|
|
484
487
|
// we do not wish to reload again and get stuck in an infinite reloading loop
|
|
485
|
-
|
|
486
488
|
if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
|
|
487
489
|
window.location.reload();
|
|
488
490
|
}
|
|
489
491
|
}
|
|
490
|
-
|
|
491
492
|
function* do500(error) {
|
|
492
493
|
yield put({
|
|
493
494
|
type: SET_ENTRY,
|
|
@@ -499,7 +500,6 @@ function* do500(error) {
|
|
|
499
500
|
statusCode: error && error.status ? error.status : 500
|
|
500
501
|
});
|
|
501
502
|
}
|
|
502
|
-
|
|
503
503
|
function* reduxInjectorSaga(injectorFn) {
|
|
504
504
|
if (typeof injectorFn === 'function') {
|
|
505
505
|
const {
|
|
@@ -516,19 +516,18 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
const registerSagas = [takeEvery(REGISTER_USER, registerSaga), takeEvery(REGISTER_USER_SUCCESS, redirectSaga)];
|
|
519
|
-
|
|
520
519
|
function* registerSaga({
|
|
521
520
|
user,
|
|
522
521
|
mappers
|
|
523
522
|
}) {
|
|
524
|
-
let requestBody = user;
|
|
523
|
+
let requestBody = user;
|
|
524
|
+
// Allow use of request mapper to take a user object
|
|
525
525
|
// of any format and return the payload for the api request
|
|
526
|
-
|
|
527
526
|
if (mappers && mappers.request && typeof mappers.request === 'function') {
|
|
528
527
|
requestBody = yield mappers.request(user);
|
|
529
|
-
}
|
|
530
|
-
|
|
528
|
+
}
|
|
531
529
|
|
|
530
|
+
// Make POST call to register API
|
|
532
531
|
const response = yield fetch('/account/register', {
|
|
533
532
|
method: 'POST',
|
|
534
533
|
headers: {
|
|
@@ -537,19 +536,16 @@ function* registerSaga({
|
|
|
537
536
|
},
|
|
538
537
|
body: JSON.stringify(requestBody)
|
|
539
538
|
});
|
|
540
|
-
|
|
541
539
|
if (response.ok) {
|
|
542
540
|
let mappedResponse;
|
|
543
541
|
const [, responseBody] = yield to$1(response.json());
|
|
544
|
-
|
|
545
542
|
if (responseBody) {
|
|
546
543
|
// Allow use of response mapper to convert the successful user object
|
|
547
544
|
// from the api response body into a user object of any format
|
|
548
545
|
if (mappers && mappers.response && typeof mappers.response === 'function') {
|
|
549
546
|
mappedResponse = yield mappers.response(responseBody);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
547
|
+
}
|
|
548
|
+
// Update user object with mappedResponse or responseBody
|
|
553
549
|
yield put({
|
|
554
550
|
type: REGISTER_USER_SUCCESS,
|
|
555
551
|
user: mappedResponse || responseBody
|
|
@@ -568,25 +564,24 @@ function* registerSaga({
|
|
|
568
564
|
// or status codes echoed from the responses received from
|
|
569
565
|
// management api when registering the user
|
|
570
566
|
const [, errorResponse] = yield to$1(response.json());
|
|
571
|
-
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
572
|
-
|
|
567
|
+
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
568
|
+
// Get something meaningful from the response if there is no message in the body
|
|
573
569
|
if (!error.message) {
|
|
574
570
|
error.message = `Registration service: ${response.statusText}`;
|
|
575
571
|
error.status = response.status;
|
|
576
572
|
}
|
|
577
|
-
|
|
578
573
|
yield put({
|
|
579
574
|
type: REGISTER_USER_FAILED,
|
|
580
575
|
error
|
|
581
576
|
});
|
|
582
577
|
}
|
|
583
578
|
}
|
|
584
|
-
|
|
585
579
|
function* redirectSaga() {
|
|
586
580
|
// Check if querystring contains a redirect_uri
|
|
587
581
|
const currentQs = queryParams(yield select(selectCurrentSearch));
|
|
588
|
-
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
582
|
+
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
589
583
|
|
|
584
|
+
// We must use redux based navigation to preserve the registration state
|
|
590
585
|
if (redirectUri) yield put(setRoute(redirectUri));
|
|
591
586
|
}
|
|
592
587
|
|
|
@@ -604,36 +599,36 @@ const BASE_OPTIONS = {
|
|
|
604
599
|
};
|
|
605
600
|
class UserHelper {
|
|
606
601
|
static async GetUsersEnvironments(securityToken) {
|
|
607
|
-
const options = {
|
|
602
|
+
const options = {
|
|
603
|
+
...BASE_OPTIONS,
|
|
608
604
|
headers: {
|
|
609
605
|
'x-security-token': securityToken
|
|
610
606
|
}
|
|
611
607
|
};
|
|
612
608
|
return await UserHelper.get(USER_ENVS_URL, options);
|
|
613
609
|
}
|
|
614
|
-
|
|
615
610
|
static async ResendUserVerification(userEmail) {
|
|
616
|
-
const options = {
|
|
611
|
+
const options = {
|
|
612
|
+
...BASE_OPTIONS
|
|
617
613
|
};
|
|
618
614
|
return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
|
|
619
615
|
}
|
|
620
|
-
|
|
621
616
|
static async RequestPasswordReset(userEmailObject) {
|
|
622
|
-
const options = {
|
|
617
|
+
const options = {
|
|
618
|
+
...BASE_OPTIONS,
|
|
623
619
|
body: JSON.stringify(userEmailObject)
|
|
624
620
|
};
|
|
625
621
|
options.method = 'POST';
|
|
626
622
|
return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
|
|
627
623
|
}
|
|
628
|
-
|
|
629
624
|
static async ResetPassword(resetPasswordObject) {
|
|
630
|
-
const options = {
|
|
625
|
+
const options = {
|
|
626
|
+
...BASE_OPTIONS,
|
|
631
627
|
body: JSON.stringify(resetPasswordObject)
|
|
632
628
|
};
|
|
633
629
|
options.method = 'POST';
|
|
634
630
|
return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
|
|
635
631
|
}
|
|
636
|
-
|
|
637
632
|
static async get(url, options = BASE_OPTIONS) {
|
|
638
633
|
try {
|
|
639
634
|
const responseBody = await api(url, options);
|
|
@@ -646,9 +641,7 @@ class UserHelper {
|
|
|
646
641
|
};
|
|
647
642
|
}
|
|
648
643
|
}
|
|
649
|
-
|
|
650
644
|
}
|
|
651
|
-
|
|
652
645
|
async function api(url, options) {
|
|
653
646
|
return fetch(url, options).then(async response => {
|
|
654
647
|
return response.json().then(data => data);
|
|
@@ -658,17 +651,14 @@ async function api(url, options) {
|
|
|
658
651
|
}
|
|
659
652
|
|
|
660
653
|
const resetPasswordSagas = [takeEvery(REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), takeEvery(RESET_USER_PASSWORD, resetPasswordSaga), takeEvery(CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
661
|
-
|
|
662
654
|
function* requestPasswordResetSaga(action) {
|
|
663
655
|
const userEmailObject = action.userEmailObject;
|
|
664
656
|
yield put({
|
|
665
657
|
type: REQUEST_USER_PASSWORD_RESET_SENDING
|
|
666
658
|
});
|
|
667
|
-
|
|
668
659
|
if (userEmailObject && userEmailObject.userEmail) {
|
|
669
660
|
try {
|
|
670
661
|
const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
|
|
671
|
-
|
|
672
662
|
if (passwordResetRequestResponse) {
|
|
673
663
|
if (!passwordResetRequestResponse.error) {
|
|
674
664
|
yield put({
|
|
@@ -699,17 +689,14 @@ function* requestPasswordResetSaga(action) {
|
|
|
699
689
|
});
|
|
700
690
|
}
|
|
701
691
|
}
|
|
702
|
-
|
|
703
692
|
function* resetPasswordSaga(action) {
|
|
704
693
|
const resetPasswordObject = action.resetPasswordObject;
|
|
705
694
|
yield put({
|
|
706
695
|
type: RESET_USER_PASSWORD_SENDING
|
|
707
696
|
});
|
|
708
|
-
|
|
709
697
|
if (resetPasswordObject.token && resetPasswordObject.password) {
|
|
710
698
|
try {
|
|
711
699
|
const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
|
|
712
|
-
|
|
713
700
|
if (resetPasswordResponse) {
|
|
714
701
|
if (!resetPasswordResponse.error) {
|
|
715
702
|
yield put({
|
|
@@ -740,11 +727,11 @@ function* resetPasswordSaga(action) {
|
|
|
740
727
|
error: 'Invalid object'
|
|
741
728
|
});
|
|
742
729
|
}
|
|
743
|
-
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// userId
|
|
744
733
|
// existingPassword
|
|
745
734
|
// newPassword
|
|
746
|
-
|
|
747
|
-
|
|
748
735
|
function* changePasswordSaga(action) {
|
|
749
736
|
if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
|
|
750
737
|
yield put({
|
|
@@ -753,7 +740,6 @@ function* changePasswordSaga(action) {
|
|
|
753
740
|
});
|
|
754
741
|
return;
|
|
755
742
|
}
|
|
756
|
-
|
|
757
743
|
try {
|
|
758
744
|
const changePasswordObject = {
|
|
759
745
|
userId: action.userId,
|
|
@@ -764,25 +750,24 @@ function* changePasswordSaga(action) {
|
|
|
764
750
|
type: CHANGE_USER_PASSWORD_SENDING
|
|
765
751
|
});
|
|
766
752
|
const clientCredentials = yield select(selectClientCredentials, 'js');
|
|
767
|
-
const client = yield getManagementApiClient({
|
|
753
|
+
const client = yield getManagementApiClient({
|
|
754
|
+
...clientCredentials
|
|
768
755
|
});
|
|
769
756
|
const [err, res] = yield to$1(client.security.users.updatePassword(changePasswordObject));
|
|
770
|
-
|
|
771
757
|
if (err) {
|
|
772
|
-
var _err$data, _err$
|
|
773
|
-
|
|
774
|
-
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);
|
|
758
|
+
var _err$data, _err$data2;
|
|
759
|
+
const error = (err === null || err === void 0 || (_err$data = err.data) === null || _err$data === void 0 || (_err$data = _err$data.data) === null || _err$data === void 0 ? void 0 : _err$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 || (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
|
|
775
760
|
yield put({
|
|
776
761
|
type: CHANGE_USER_PASSWORD_ERROR,
|
|
777
762
|
error
|
|
778
763
|
});
|
|
779
764
|
return;
|
|
780
|
-
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// // eslint-disable-next-line no-console
|
|
781
768
|
// console.log(changePasswordObject);
|
|
782
769
|
// // eslint-disable-next-line no-console
|
|
783
770
|
// console.log(userCredentialsObject);
|
|
784
|
-
|
|
785
|
-
|
|
786
771
|
yield put({
|
|
787
772
|
type: CHANGE_USER_PASSWORD_SUCCESS
|
|
788
773
|
});
|
|
@@ -804,35 +789,32 @@ function rootSaga (featureSagas = []) {
|
|
|
804
789
|
};
|
|
805
790
|
}
|
|
806
791
|
|
|
807
|
-
const servers = SERVERS;
|
|
808
|
-
/* global SERVERS */
|
|
809
|
-
|
|
792
|
+
const servers = SERVERS; /* global SERVERS */
|
|
810
793
|
const alias = servers.alias.toLowerCase();
|
|
811
|
-
const publicUri = PUBLIC_URI;
|
|
812
|
-
/* global
|
|
794
|
+
const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
|
|
795
|
+
const projects = PROJECTS; /* global PROJECTS */
|
|
813
796
|
|
|
814
|
-
const projects = PROJECTS;
|
|
815
|
-
/* global PROJECTS */
|
|
816
797
|
// return a projectId via the request hostname
|
|
817
|
-
|
|
818
798
|
const pickProject = (hostname, query) => {
|
|
819
799
|
// if localhost we can only infer via a querystring, and take your word for it
|
|
820
800
|
if (hostname == 'localhost') {
|
|
821
801
|
return query && query.p || projects[0].id;
|
|
822
|
-
}
|
|
823
|
-
|
|
802
|
+
}
|
|
824
803
|
|
|
804
|
+
// if hostname is the actual public uri we can return the first project from the list
|
|
825
805
|
if (hostname == publicUri) {
|
|
826
806
|
return projects[0].id;
|
|
827
807
|
}
|
|
808
|
+
let project = 'unknown';
|
|
828
809
|
|
|
829
|
-
|
|
810
|
+
// // go through all the defined projects
|
|
830
811
|
// Object.entries(projects).map(([, p]) => {
|
|
812
|
+
const p = projects[0];
|
|
831
813
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
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;
|
|
835
816
|
|
|
817
|
+
// the url structure is different for website (we don't prefix)
|
|
836
818
|
if (p.id.startsWith('website')) {
|
|
837
819
|
// check for internal and external hostnames
|
|
838
820
|
// we check live and preview distinctly so our rule does not clash with
|
|
@@ -841,9 +823,8 @@ const pickProject = (hostname, query) => {
|
|
|
841
823
|
} else {
|
|
842
824
|
// check for internal and external hostnames, prefixed with the projectId
|
|
843
825
|
if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
|
|
826
|
+
}
|
|
827
|
+
// });
|
|
847
828
|
return project === 'unknown' ? p.id : project;
|
|
848
829
|
};
|
|
849
830
|
|
|
@@ -852,4 +833,4 @@ const AppRoot = props => {
|
|
|
852
833
|
};
|
|
853
834
|
|
|
854
835
|
export { AppRoot as A, browserHistory as b, history as h, pickProject as p, rootSaga as r };
|
|
855
|
-
//# sourceMappingURL=App-
|
|
836
|
+
//# sourceMappingURL=App-CIlf4cl4.js.map
|