@zengenti/contensis-react-base 3.0.2-beta.4 → 3.0.2-beta.40
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/README.md +2 -2
- package/cjs/{App-a2783f8b.js → App-7ff737fa.js} +161 -444
- package/cjs/App-7ff737fa.js.map +1 -0
- package/cjs/{login-e711a19e.js → ChangePassword.container-a617190b.js} +304 -191
- package/cjs/ChangePassword.container-a617190b.js.map +1 -0
- package/cjs/ContensisDeliveryApi-9e32960d.js +265 -0
- package/cjs/ContensisDeliveryApi-9e32960d.js.map +1 -0
- package/cjs/CookieConstants-000427db.js +10 -0
- package/cjs/CookieConstants-000427db.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-049e81e5.js} +27 -38
- package/cjs/RouteLoader-049e81e5.js.map +1 -0
- package/cjs/{ToJs-a9a8522b.js → ToJs-149fc5e1.js} +50 -4
- package/cjs/ToJs-149fc5e1.js.map +1 -0
- package/cjs/_commonjsHelpers-b3309d7b.js +11 -0
- package/cjs/_commonjsHelpers-b3309d7b.js.map +1 -0
- package/cjs/client.js +25 -30
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +158 -536
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +3555 -326
- 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-73a03ef4.js → reducers-9afb5f89.js} +10 -31
- package/{esm/reducers-aa8cef1e.js.map → cjs/reducers-9afb5f89.js.map} +1 -1
- package/cjs/redux.js +17 -18
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +7 -7
- 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-46b689d0.js} +86 -9
- package/cjs/selectors-46b689d0.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +34 -169
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +47 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-bf9ef45e.js → version-79a027cb.js} +55 -179
- package/cjs/version-79a027cb.js.map +1 -0
- package/cjs/version-afd4f77e.js +98 -0
- package/cjs/version-afd4f77e.js.map +1 -0
- package/esm/{App-17d1ac3c.js → App-ff944c78.js} +145 -427
- package/esm/App-ff944c78.js.map +1 -0
- package/esm/{login-551d243a.js → ChangePassword.container-ae0f9ce4.js} +286 -184
- package/esm/ChangePassword.container-ae0f9ce4.js.map +1 -0
- package/esm/ContensisDeliveryApi-c66b0cc3.js +259 -0
- package/esm/ContensisDeliveryApi-c66b0cc3.js.map +1 -0
- package/esm/CookieConstants-3d3b6531.js +6 -0
- package/esm/CookieConstants-3d3b6531.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-02eef6d9.js} +26 -37
- package/esm/RouteLoader-02eef6d9.js.map +1 -0
- package/esm/{ToJs-4e02a04d.js → ToJs-ae860aad.js} +50 -5
- package/esm/ToJs-ae860aad.js.map +1 -0
- package/esm/_commonjsHelpers-1789f0cf.js +8 -0
- package/esm/_commonjsHelpers-1789f0cf.js.map +1 -0
- package/esm/client.js +20 -25
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +151 -530
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +3557 -328
- 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-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
- package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
- package/esm/redux.js +9 -9
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +4 -4
- 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-01074974.js} +71 -9
- package/esm/selectors-01074974.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +22 -161
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/version-0fbd1b82.js +87 -0
- package/esm/version-0fbd1b82.js.map +1 -0
- package/esm/{version-72ca17f3.js → version-346a9787.js} +43 -162
- package/esm/version-346a9787.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/routing/util/queries.d.ts +3 -2
- 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/types.d.ts +21 -21
- package/models/search/redux/util.d.ts +2 -2
- package/models/search/search/ContensisDeliveryApi.d.ts +1 -1
- 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 +8 -0
- package/models/user/util/CookieHelper.class.d.ts +15 -3
- package/models/user/util/LoginHelper.class.d.ts +27 -23
- package/models/util/CachedDeliveryApi.d.ts +25 -0
- package/models/util/ContensisDeliveryApi.d.ts +20 -38
- package/models/util/LruCache.d.ts +12 -0
- 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-a2783f8b.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-e711a19e.js.map +0 -1
- package/cjs/sagas-8a20e424.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-bf9ef45e.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-17d1ac3c.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-551d243a.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-72ca17f3.js.map +0 -1
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var ContensisDeliveryApi = require('./ContensisDeliveryApi-9e32960d.js');
|
|
6
6
|
var contensisDeliveryApi = require('contensis-delivery-api');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactRedux = require('react-redux');
|
|
9
|
-
var sagas = require('./sagas-8a20e424.js');
|
|
10
9
|
var mapJson = require('jsonpath-mapper');
|
|
11
10
|
require('reselect');
|
|
12
11
|
require('deepmerge');
|
|
13
12
|
require('query-string');
|
|
13
|
+
var sagas = require('./sagas-e04b94c1.js');
|
|
14
14
|
require('immer');
|
|
15
15
|
require('deep-equal');
|
|
16
16
|
var contensisCoreApi = require('contensis-core-api');
|
|
@@ -27,31 +27,33 @@ var reactRouterDom = require('react-router-dom');
|
|
|
27
27
|
var reactRouterConfig = require('react-router-config');
|
|
28
28
|
var reactHelmet = require('react-helmet');
|
|
29
29
|
var styled = require('styled-components');
|
|
30
|
-
var serialize
|
|
30
|
+
var serialize = require('serialize-javascript');
|
|
31
31
|
var minifyCssString = require('minify-css-string');
|
|
32
32
|
var server$1 = require('@loadable/server');
|
|
33
33
|
var lodash = require('lodash');
|
|
34
|
+
var _commonjsHelpers = require('./_commonjsHelpers-b3309d7b.js');
|
|
34
35
|
var lodashClean = require('lodash-clean');
|
|
35
36
|
var reactCookie = require('react-cookie');
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var cookiesMiddleware = require('universal-cookie-express');
|
|
38
|
+
var version = require('./version-79a027cb.js');
|
|
39
|
+
var App = require('./App-7ff737fa.js');
|
|
40
|
+
var version$1 = require('./version-afd4f77e.js');
|
|
41
|
+
var selectors = require('./selectors-46b689d0.js');
|
|
39
42
|
var chalk = require('chalk');
|
|
40
|
-
require('
|
|
41
|
-
require('@redux-saga/core/effects');
|
|
43
|
+
require('./CookieConstants-000427db.js');
|
|
42
44
|
require('loglevel');
|
|
43
|
-
require('
|
|
44
|
-
require('./login-e711a19e.js');
|
|
45
|
-
require('./reducers-73a03ef4.js');
|
|
46
|
-
require('./ToJs-a9a8522b.js');
|
|
47
|
-
require('await-to-js');
|
|
48
|
-
require('js-cookie');
|
|
49
|
-
require('react-hot-loader');
|
|
50
|
-
require('./RouteLoader-3aa6456e.js');
|
|
45
|
+
require('@redux-saga/core/effects');
|
|
51
46
|
require('redux');
|
|
52
47
|
require('redux-thunk');
|
|
53
48
|
require('redux-saga');
|
|
54
49
|
require('redux-injectors');
|
|
50
|
+
require('./reducers-9afb5f89.js');
|
|
51
|
+
require('history');
|
|
52
|
+
require('await-to-js');
|
|
53
|
+
require('./ChangePassword.container-a617190b.js');
|
|
54
|
+
require('./ToJs-149fc5e1.js');
|
|
55
|
+
require('react-hot-loader');
|
|
56
|
+
require('./RouteLoader-049e81e5.js');
|
|
55
57
|
|
|
56
58
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
57
59
|
|
|
@@ -62,8 +64,9 @@ var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
|
62
64
|
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
63
65
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
64
66
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
65
|
-
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize
|
|
67
|
+
var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
66
68
|
var minifyCssString__default = /*#__PURE__*/_interopDefaultLegacy(minifyCssString);
|
|
69
|
+
var cookiesMiddleware__default = /*#__PURE__*/_interopDefaultLegacy(cookiesMiddleware);
|
|
67
70
|
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
68
71
|
|
|
69
72
|
/**
|
|
@@ -74,26 +77,20 @@ class Util {
|
|
|
74
77
|
if (fieldId) {
|
|
75
78
|
return entries === null || entries === void 0 ? void 0 : entries.map(e => {
|
|
76
79
|
var _e$fieldId, _e$fieldId2, _e$fieldId2$sys;
|
|
77
|
-
|
|
78
80
|
return Array.isArray(e === null || e === void 0 ? void 0 : e[fieldId]) ? e === null || e === void 0 ? void 0 : (_e$fieldId = e[fieldId]) === null || _e$fieldId === void 0 ? void 0 : _e$fieldId.map(f => {
|
|
79
81
|
var _f$sys;
|
|
80
|
-
|
|
81
82
|
return f === null || f === void 0 ? void 0 : (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
|
|
82
83
|
}) : (e === null || e === void 0 ? void 0 : (_e$fieldId2 = e[fieldId]) === null || _e$fieldId2 === void 0 ? void 0 : (_e$fieldId2$sys = _e$fieldId2.sys) === null || _e$fieldId2$sys === void 0 ? void 0 : _e$fieldId2$sys.id) || '';
|
|
83
84
|
}).flat();
|
|
84
85
|
}
|
|
85
|
-
|
|
86
86
|
return entries === null || entries === void 0 ? void 0 : entries.map(e => {
|
|
87
87
|
var _e$sys;
|
|
88
|
-
|
|
89
88
|
return (e === null || e === void 0 ? void 0 : (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
|
-
|
|
93
91
|
static GetItems(result) {
|
|
94
92
|
return this.GetResults(result) ? result.items : [];
|
|
95
93
|
}
|
|
96
|
-
|
|
97
94
|
static GetResults(result) {
|
|
98
95
|
if (result !== null && result !== void 0 && result.items) {
|
|
99
96
|
return result;
|
|
@@ -101,20 +98,18 @@ class Util {
|
|
|
101
98
|
return null;
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
|
-
|
|
105
101
|
}
|
|
106
102
|
const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId) => results.map(r => {
|
|
107
103
|
if (replaceContentTypeIds.some(c => c === r.sys.contentTypeId)) {
|
|
108
104
|
const resolvedParent = parentResults === null || parentResults === void 0 ? void 0 : parentResults.find(e => {
|
|
109
105
|
var _e$linkFieldId;
|
|
110
|
-
|
|
111
106
|
return (_e$linkFieldId = e[linkFieldId]) === null || _e$linkFieldId === void 0 ? void 0 : _e$linkFieldId.some(l => {
|
|
112
107
|
var _l$sys;
|
|
113
|
-
|
|
114
108
|
return ((_l$sys = l.sys) === null || _l$sys === void 0 ? void 0 : _l$sys.id) === r.sys.id;
|
|
115
109
|
});
|
|
116
110
|
});
|
|
117
|
-
if (resolvedParent) return {
|
|
111
|
+
if (resolvedParent) return {
|
|
112
|
+
...resolvedParent,
|
|
118
113
|
...r,
|
|
119
114
|
entryTitle: resolvedParent.entryTitle,
|
|
120
115
|
entryDescription: resolvedParent.entryDescription,
|
|
@@ -122,12 +117,10 @@ const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId
|
|
|
122
117
|
originalSys: r.sys
|
|
123
118
|
};else return r;
|
|
124
119
|
}
|
|
125
|
-
|
|
126
120
|
return r;
|
|
127
121
|
}).filter(r => r);
|
|
128
122
|
|
|
129
123
|
/* eslint-disable no-console */
|
|
130
|
-
|
|
131
124
|
/**
|
|
132
125
|
* Builds our complete Delivery API Query object from a set of provided arguments
|
|
133
126
|
* @param queryParams
|
|
@@ -152,13 +145,12 @@ const searchQuery = ({
|
|
|
152
145
|
const expressions$1 = [...sagas.defaultExpressions(versionStatus), ...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.customWhereExpressions(customWhere), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters), ...((sharedFilters === null || sharedFilters === void 0 ? void 0 : sharedFilters.length) > 0 ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters, true))] : []), ...sagas.termExpressions(searchTerm || '', weightedSearchFields || [])];
|
|
153
146
|
const query = new contensisCoreApi.Query(...expressions$1);
|
|
154
147
|
query.orderBy = sagas.orderByExpression(orderBy || []);
|
|
155
|
-
|
|
156
148
|
if (fields && fields.length > 0) {
|
|
157
149
|
query.fields = fields;
|
|
158
|
-
}
|
|
159
|
-
// (query as any).includeDeleted = true;
|
|
160
|
-
|
|
150
|
+
}
|
|
161
151
|
|
|
152
|
+
// (query as any).includeArchived = true;
|
|
153
|
+
// (query as any).includeDeleted = true;
|
|
162
154
|
query.pageIndex = pageIndex;
|
|
163
155
|
query.pageSize = pageSize;
|
|
164
156
|
return query;
|
|
@@ -181,7 +173,8 @@ const finalQuery = ({
|
|
|
181
173
|
webpageTemplates,
|
|
182
174
|
weightedSearchFields
|
|
183
175
|
}, children) => {
|
|
184
|
-
const expressions$1 = [...sagas.defaultExpressions(versionStatus), contensisCoreApi.Op.or(contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters || [])
|
|
176
|
+
const expressions$1 = [...sagas.defaultExpressions(versionStatus), contensisCoreApi.Op.or(contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters || [])
|
|
177
|
+
// Op.and(
|
|
185
178
|
// ...sharedFilters.map(sf =>
|
|
186
179
|
// Op.not(exp.fieldExpression(sf.key, true, 'exists')[0])
|
|
187
180
|
// ),
|
|
@@ -190,17 +183,17 @@ const finalQuery = ({
|
|
|
190
183
|
)] : [])), ...children.map(child => contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(child.contentTypeIds, child.webpageTemplates, child.assetTypes), ...sagas.filterExpressions(child.sharedFilters || []), ...sagas.filterExpressions(child.idFilters || [])))), ...sagas.termExpressions(searchTerm || '', weightedSearchFields || [])];
|
|
191
184
|
const query = new contensisCoreApi.Query(...expressions$1);
|
|
192
185
|
query.orderBy = sagas.orderByExpression(orderBy || []);
|
|
193
|
-
|
|
194
186
|
if (fields && fields.length > 0) {
|
|
195
187
|
query.fields = fields;
|
|
196
|
-
}
|
|
197
|
-
// (query as any).includeDeleted = true;
|
|
198
|
-
|
|
188
|
+
}
|
|
199
189
|
|
|
190
|
+
// (query as any).includeArchived = true;
|
|
191
|
+
// (query as any).includeDeleted = true;
|
|
200
192
|
query.pageIndex = pageIndex || 0;
|
|
201
193
|
query.pageSize = pageSize;
|
|
202
194
|
return query;
|
|
203
195
|
};
|
|
196
|
+
|
|
204
197
|
/**
|
|
205
198
|
* Create a filter expression from a provided filters configuration object
|
|
206
199
|
* and populate them based on the presence of that key in params, filter
|
|
@@ -209,13 +202,10 @@ const finalQuery = ({
|
|
|
209
202
|
* @param params request.query object from Express middleware
|
|
210
203
|
* @returns FilterExpression[] we can use to use with searchQuery function
|
|
211
204
|
*/
|
|
212
|
-
|
|
213
205
|
const makeFilterExpressions = (f, params) => {
|
|
214
206
|
const expressions = [];
|
|
215
|
-
|
|
216
207
|
for (const [paramKey, filterConfig] of Object.entries(f)) {
|
|
217
208
|
var _params$paramKey;
|
|
218
|
-
|
|
219
209
|
const filterValues = (_params$paramKey = params[paramKey]) === null || _params$paramKey === void 0 ? void 0 : _params$paramKey.split(',');
|
|
220
210
|
if (typeof filterValues !== 'undefined') expressions.push({
|
|
221
211
|
key: typeof filterConfig === 'object' ? filterConfig.fieldId : filterConfig,
|
|
@@ -224,7 +214,6 @@ const makeFilterExpressions = (f, params) => {
|
|
|
224
214
|
logicOperator: typeof filterConfig === 'object' && filterConfig.logicOperator ? filterConfig.logicOperator : 'or'
|
|
225
215
|
});
|
|
226
216
|
}
|
|
227
|
-
|
|
228
217
|
return expressions;
|
|
229
218
|
};
|
|
230
219
|
const makeDerivedIdsFilterExpression = (prevFieldId, entries, ownIds = false, alwaysApplyFilter = false) => {
|
|
@@ -252,12 +241,11 @@ const resolveParentEntries = async (parentContentTypeIds, replaceContentTypeIds,
|
|
|
252
241
|
});
|
|
253
242
|
query.fields = params.fields ? [...JSON.parse(params.fields), parentFieldId] : [];
|
|
254
243
|
if (debug) console.log(`\nResolve parent entries query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
|
|
255
|
-
const parentResults = await
|
|
244
|
+
const parentResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth || 0), params.projectId);
|
|
256
245
|
return mergeResults(results, Util.GetItems(parentResults), replaceContentTypeIds, parentFieldId);
|
|
257
246
|
};
|
|
258
247
|
|
|
259
248
|
/* eslint-disable no-console */
|
|
260
|
-
|
|
261
249
|
class QueryLevelResults {
|
|
262
250
|
constructor({
|
|
263
251
|
level: _level,
|
|
@@ -290,13 +278,11 @@ class QueryLevelResults {
|
|
|
290
278
|
this.firstResults = {};
|
|
291
279
|
this.finalQuery = new contensisDeliveryApi.Query();
|
|
292
280
|
this.finalResults = {};
|
|
293
|
-
|
|
294
281
|
this.AddChild = ({
|
|
295
282
|
child
|
|
296
283
|
}) => {
|
|
297
284
|
this.children.push(child);
|
|
298
285
|
};
|
|
299
|
-
|
|
300
286
|
this.RunFirstQuery = async () => {
|
|
301
287
|
const {
|
|
302
288
|
firstQuery: query,
|
|
@@ -304,18 +290,17 @@ class QueryLevelResults {
|
|
|
304
290
|
parent,
|
|
305
291
|
runFirstQuery
|
|
306
292
|
} = this;
|
|
307
|
-
|
|
308
293
|
if (parent !== null && parent !== void 0 && parent.validatedLinks.length) {
|
|
309
294
|
// add any idFilters derived from parent query results
|
|
310
295
|
appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, {
|
|
311
296
|
fieldId: `sys.id`
|
|
312
297
|
}])), Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from parent ${parent.level}`]))));
|
|
313
298
|
}
|
|
314
|
-
|
|
315
299
|
if (runFirstQuery) {
|
|
316
300
|
if (this.debug) console.log(`\nLevel ${this.level} - First query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
|
|
317
|
-
this.firstResults = await
|
|
301
|
+
this.firstResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, 0, params.projectId);
|
|
318
302
|
|
|
303
|
+
// mapResultsToValidatedLinks
|
|
319
304
|
for (const linkFieldId of this.linkFieldIds) {
|
|
320
305
|
this.validatedLinks.push({
|
|
321
306
|
contentTypeId: this.linkFields[linkFieldId].contentTypeId || '',
|
|
@@ -325,7 +310,6 @@ class QueryLevelResults {
|
|
|
325
310
|
}
|
|
326
311
|
}
|
|
327
312
|
};
|
|
328
|
-
|
|
329
313
|
this.RunFinalQuery = async () => {
|
|
330
314
|
const {
|
|
331
315
|
level,
|
|
@@ -334,31 +318,30 @@ class QueryLevelResults {
|
|
|
334
318
|
params,
|
|
335
319
|
runFinalQuery
|
|
336
320
|
} = this;
|
|
337
|
-
|
|
338
321
|
if (!children.some(c => c.returnEntries)) {
|
|
339
|
-
const firstChild = children === null || children === void 0 ? void 0 : children[0];
|
|
340
|
-
|
|
322
|
+
const firstChild = children === null || children === void 0 ? void 0 : children[0];
|
|
323
|
+
// add any idFilters derived from child query results
|
|
341
324
|
if (firstChild) appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, {
|
|
342
325
|
fieldId: `${vl.linkFieldId}.sys.id`
|
|
343
326
|
}])), Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from child ${firstChild.level}`]))));
|
|
344
327
|
}
|
|
345
|
-
|
|
346
328
|
if (level === 0 && this.returnEntries) {
|
|
347
329
|
// This is the final query to be run and response returned to the caller
|
|
348
330
|
// Only this bit cares about linkDepth, fields and pagination parameters
|
|
349
331
|
query.fields = JSON.parse(params.fields || '[]');
|
|
350
332
|
query.pageSize = params.pageSize;
|
|
351
|
-
query.pageIndex = params.pageIndex;
|
|
333
|
+
query.pageIndex = params.pageIndex;
|
|
334
|
+
// query.orderBy = params.orderBy;
|
|
352
335
|
}
|
|
353
336
|
|
|
354
337
|
if (runFinalQuery) {
|
|
355
338
|
if (this.debug) console.log(`\nLevel ${this.level} - Final query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
|
|
356
|
-
this.finalResults = await
|
|
357
|
-
if (this.parent) this.parent.runFinalQuery = true;
|
|
339
|
+
this.finalResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
|
|
340
|
+
if (this.parent) this.parent.runFinalQuery = true;
|
|
358
341
|
|
|
342
|
+
// mapResultsToValidatedLinks
|
|
359
343
|
for (const linkFieldId of ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.linkFieldIds) || []) {
|
|
360
344
|
var _this$parent, _this$parent2;
|
|
361
|
-
|
|
362
345
|
this.validatedLinks.push({
|
|
363
346
|
contentTypeId: ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.linkFields[linkFieldId].contentTypeId) || '',
|
|
364
347
|
linkFieldId,
|
|
@@ -367,17 +350,14 @@ class QueryLevelResults {
|
|
|
367
350
|
}
|
|
368
351
|
}
|
|
369
352
|
};
|
|
370
|
-
|
|
371
353
|
this.GetResultsEntries = () => {
|
|
372
354
|
var _finalResults$items;
|
|
373
|
-
|
|
374
355
|
const {
|
|
375
356
|
finalResults,
|
|
376
357
|
firstResults
|
|
377
358
|
} = this;
|
|
378
359
|
return finalResults !== null && finalResults !== void 0 && (_finalResults$items = finalResults.items) !== null && _finalResults$items !== void 0 && _finalResults$items.length ? finalResults.items : firstResults.items;
|
|
379
360
|
};
|
|
380
|
-
|
|
381
361
|
this.GetResults = () => {
|
|
382
362
|
const {
|
|
383
363
|
finalResults,
|
|
@@ -385,7 +365,6 @@ class QueryLevelResults {
|
|
|
385
365
|
} = this;
|
|
386
366
|
return typeof (finalResults === null || finalResults === void 0 ? void 0 : finalResults.totalCount) !== 'undefined' ? finalResults : firstResults;
|
|
387
367
|
};
|
|
388
|
-
|
|
389
368
|
this.level = _level;
|
|
390
369
|
this.contentTypeIds = contentTypeIds;
|
|
391
370
|
this.linkFields = linkFields;
|
|
@@ -422,11 +401,9 @@ class QueryLevelResults {
|
|
|
422
401
|
versionStatus: _params.versionStatus
|
|
423
402
|
});
|
|
424
403
|
}
|
|
425
|
-
|
|
426
404
|
}
|
|
427
405
|
|
|
428
406
|
/* eslint-disable no-console */
|
|
429
|
-
|
|
430
407
|
class LinkDepthSearchService {
|
|
431
408
|
constructor({
|
|
432
409
|
contentTypeId: _contentTypeId = '',
|
|
@@ -443,29 +420,27 @@ class LinkDepthSearchService {
|
|
|
443
420
|
this.params = void 0;
|
|
444
421
|
this.debug = void 0;
|
|
445
422
|
this.queryLevels = void 0;
|
|
446
|
-
|
|
447
423
|
this.DoSearch = async () => {
|
|
448
424
|
// Run queries "top-down" through each level of `linkField`
|
|
449
425
|
for (const queryLevel of this.queryLevels) {
|
|
450
426
|
await queryLevel.RunFirstQuery();
|
|
451
|
-
}
|
|
452
|
-
|
|
427
|
+
}
|
|
453
428
|
|
|
429
|
+
// Run queries "bottom-up" through each level of `linkField`
|
|
454
430
|
for (const queryLevel of [...this.queryLevels].reverse()) {
|
|
455
431
|
await queryLevel.RunFinalQuery();
|
|
456
|
-
}
|
|
457
|
-
// adding all levels to the query that have `returnEntries` set true
|
|
458
|
-
|
|
432
|
+
}
|
|
459
433
|
|
|
434
|
+
// Run a final query that will aggregate the results from all levels
|
|
435
|
+
// adding all levels to the query that have `returnEntries` set true
|
|
460
436
|
return await this.RunFinalQueries();
|
|
461
437
|
};
|
|
462
|
-
|
|
463
438
|
this.RunFinalQueries = async () => {
|
|
464
|
-
const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
|
|
439
|
+
const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
|
|
465
440
|
|
|
441
|
+
// Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
|
|
466
442
|
if (finalQueryLevels.length > 1 || finalQueryLevels.length === 1 && finalQueryLevels[0].level !== 0) {
|
|
467
443
|
var _params$orderBy;
|
|
468
|
-
|
|
469
444
|
// Build final query
|
|
470
445
|
const {
|
|
471
446
|
contentTypeIds,
|
|
@@ -480,9 +455,9 @@ class LinkDepthSearchService {
|
|
|
480
455
|
}
|
|
481
456
|
}, {
|
|
482
457
|
[vl.linkFieldId]: vl.entryIds.join(',') || 'no results for filter'
|
|
483
|
-
})).flat() || [];
|
|
458
|
+
})).flat() || [];
|
|
459
|
+
// This is the final query to be run and response returned to the caller
|
|
484
460
|
// Only this bit cares about linkDepth, fields and pagination parameters
|
|
485
|
-
|
|
486
461
|
const query = finalQuery({
|
|
487
462
|
contentTypeIds,
|
|
488
463
|
filters: makeFilterExpressions(filters, params),
|
|
@@ -490,7 +465,6 @@ class LinkDepthSearchService {
|
|
|
490
465
|
idFilters: derivedIdFilters,
|
|
491
466
|
fields: params.fields ? [...JSON.parse(params.fields), ...finalQueryLevels.map(l => {
|
|
492
467
|
var _l$parent;
|
|
493
|
-
|
|
494
468
|
return ((_l$parent = l.parent) === null || _l$parent === void 0 ? void 0 : _l$parent.linkFieldIds) || [];
|
|
495
469
|
}).flat()] : [],
|
|
496
470
|
orderBy: (_params$orderBy = params.orderBy) === null || _params$orderBy === void 0 ? void 0 : _params$orderBy.split(','),
|
|
@@ -500,7 +474,6 @@ class LinkDepthSearchService {
|
|
|
500
474
|
versionStatus: params.versionStatus
|
|
501
475
|
}, (finalQueryLevels === null || finalQueryLevels === void 0 ? void 0 : finalQueryLevels[0].children.filter(ql => ql.returnEntries).map(ql => {
|
|
502
476
|
var _ql$parent, _ql$parent2;
|
|
503
|
-
|
|
504
477
|
const entriesAtLevel = ql.GetResultsEntries() || ((_ql$parent = ql.parent) === null || _ql$parent === void 0 ? void 0 : _ql$parent.GetResultsEntries());
|
|
505
478
|
const previousIdsFilter = ql.returnEntries || !!ql.children.some(qc => qc.returnEntries) ? (_ql$parent2 = ql.parent) === null || _ql$parent2 === void 0 ? void 0 : _ql$parent2.linkFieldIds.map(fieldId => makeDerivedIdsFilterExpression(fieldId, entriesAtLevel, true, ql.runFinalQuery)).flat() : [];
|
|
506
479
|
return {
|
|
@@ -511,29 +484,28 @@ class LinkDepthSearchService {
|
|
|
511
484
|
};
|
|
512
485
|
})) || []);
|
|
513
486
|
if (this.debug) console.log(`\nFinal query: ${derivedIds.reduce((accumulator, object) => accumulator + object.entryIds.length, 0)} derived ids \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
|
|
514
|
-
const finalQueryResult = await
|
|
487
|
+
const finalQueryResult = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
|
|
488
|
+
|
|
489
|
+
// Resolve any parent entries
|
|
515
490
|
|
|
516
491
|
const resolveParentLevels = finalQueryLevels.filter(ql => ql.resolveFirstParent);
|
|
517
492
|
let entries = finalQueryResult.items;
|
|
518
|
-
|
|
519
493
|
for (const resolveParents of resolveParentLevels) {
|
|
520
494
|
var _resolveParents$paren, _resolveParents$paren2;
|
|
521
|
-
|
|
522
|
-
|
|
495
|
+
entries = await resolveParentEntries(((_resolveParents$paren = resolveParents.parent) === null || _resolveParents$paren === void 0 ? void 0 : _resolveParents$paren.contentTypeIds) || [], resolveParents.contentTypeIds, ((_resolveParents$paren2 = resolveParents.parent) === null || _resolveParents$paren2 === void 0 ? void 0 : _resolveParents$paren2.linkFieldIds[0]) || 'unknown', finalQueryResult.items,
|
|
496
|
+
// or entries?
|
|
523
497
|
this.params, this.debug);
|
|
524
498
|
}
|
|
525
|
-
|
|
526
|
-
|
|
499
|
+
return {
|
|
500
|
+
...finalQueryResult,
|
|
527
501
|
items: entries
|
|
528
502
|
};
|
|
529
503
|
} else {
|
|
530
504
|
var _this$queryLevels$fin;
|
|
531
|
-
|
|
532
505
|
if (this.debug) console.log(`\nNo further queries required\n`);
|
|
533
506
|
return (_this$queryLevels$fin = this.queryLevels.find(ql => ql.level === 0)) === null || _this$queryLevels$fin === void 0 ? void 0 : _this$queryLevels$fin.GetResults();
|
|
534
507
|
}
|
|
535
508
|
};
|
|
536
|
-
|
|
537
509
|
this.InitQueryLevels = () => {
|
|
538
510
|
const createChildQueryLevels = (linkFields, parentQueryLevel, level = 1) => {
|
|
539
511
|
return Object.entries(linkFields).map(([, {
|
|
@@ -566,7 +538,6 @@ class LinkDepthSearchService {
|
|
|
566
538
|
return [thisLevel, ...createChildQueryLevels(linkFields, thisLevel, level + 1)];
|
|
567
539
|
}).flat();
|
|
568
540
|
};
|
|
569
|
-
|
|
570
541
|
const {
|
|
571
542
|
contentTypeIds,
|
|
572
543
|
filters,
|
|
@@ -587,17 +558,17 @@ class LinkDepthSearchService {
|
|
|
587
558
|
params,
|
|
588
559
|
debug: this.debug
|
|
589
560
|
});
|
|
590
|
-
const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
|
|
561
|
+
const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
|
|
562
|
+
// return queryLevels;
|
|
563
|
+
|
|
591
564
|
// If we are only returning entries from level 0
|
|
592
565
|
// we can skip running the first query and finalQuery will suffice
|
|
593
|
-
|
|
594
566
|
if (queryLevels.find(ql => ql.returnEntries && ql.level !== 0)) return queryLevels;else return queryLevels.map(ql => {
|
|
595
|
-
ql.runFirstQuery = false;
|
|
596
|
-
|
|
567
|
+
ql.runFirstQuery = false;
|
|
568
|
+
// ql.runFinalQuery = false;
|
|
597
569
|
return ql;
|
|
598
570
|
});
|
|
599
571
|
};
|
|
600
|
-
|
|
601
572
|
this.contentTypeIds = Array.isArray(_contentTypeId) ? _contentTypeId : [_contentTypeId];
|
|
602
573
|
this.filters = _filters;
|
|
603
574
|
this.sharedFilters = _sharedFilters;
|
|
@@ -606,7 +577,6 @@ class LinkDepthSearchService {
|
|
|
606
577
|
this.debug = debug;
|
|
607
578
|
this.queryLevels = this.InitQueryLevels();
|
|
608
579
|
}
|
|
609
|
-
|
|
610
580
|
}
|
|
611
581
|
|
|
612
582
|
/**
|
|
@@ -626,10 +596,9 @@ const makeLinkDepthApi = (app, middlewareConfig) => {
|
|
|
626
596
|
if (!contentTypeId || !linkFields || !uri) return;
|
|
627
597
|
app.get(uri, makeLinkDepthMiddleware(middlewareConfig));
|
|
628
598
|
};
|
|
599
|
+
|
|
629
600
|
/** Create a content type hierarchy from supplied config and produces
|
|
630
601
|
* a RequestHandler function to serve our Express middleware */
|
|
631
|
-
|
|
632
|
-
|
|
633
602
|
const makeLinkDepthMiddleware = ({
|
|
634
603
|
contentTypeId,
|
|
635
604
|
filters = {},
|
|
@@ -645,8 +614,9 @@ const makeLinkDepthMiddleware = ({
|
|
|
645
614
|
urls.setCachingHeaders(res, {
|
|
646
615
|
cacheControl: 'private',
|
|
647
616
|
surrogateControl: '10'
|
|
648
|
-
});
|
|
617
|
+
});
|
|
649
618
|
|
|
619
|
+
// Gather all params from the request, we will use them at the right query levels later
|
|
650
620
|
const params = Object.fromEntries([...Object.entries(req.params), ...Object.entries(req.query)].map(([k, v]) => [k, v === null || v === void 0 ? void 0 : v.toString()]));
|
|
651
621
|
const result = await new LinkDepthSearchService({
|
|
652
622
|
contentTypeId,
|
|
@@ -664,35 +634,25 @@ const makeLinkDepthMiddleware = ({
|
|
|
664
634
|
res.json(error);
|
|
665
635
|
}
|
|
666
636
|
};
|
|
667
|
-
|
|
668
637
|
return linkDepthMiddleware;
|
|
669
638
|
} catch (error) {
|
|
670
639
|
// This will be an error building the middleware
|
|
671
640
|
// we can only serve what the error was as the request handler instead
|
|
672
641
|
console.error(error);
|
|
673
|
-
|
|
674
642
|
const errorMiddleware = async (req, res) => {
|
|
675
643
|
res.statusCode = 500;
|
|
676
644
|
res.json(JSON.stringify(error));
|
|
677
645
|
};
|
|
678
|
-
|
|
679
646
|
return errorMiddleware;
|
|
680
647
|
}
|
|
681
648
|
};
|
|
682
649
|
|
|
683
|
-
const servers$1 = SERVERS;
|
|
684
|
-
/* global
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
/* global PROJECT */
|
|
688
|
-
|
|
689
|
-
const alias = ALIAS;
|
|
690
|
-
/* global ALIAS */
|
|
691
|
-
|
|
692
|
-
const deliveryApiHostname = urls.url(alias, project).api;
|
|
650
|
+
const servers$1 = SERVERS; /* global SERVERS */
|
|
651
|
+
const project = PROJECT; /* global PROJECT */
|
|
652
|
+
const alias$1 = ALIAS; /* global ALIAS */
|
|
653
|
+
const deliveryApiHostname = urls.url(alias$1, project).api;
|
|
693
654
|
const assetProxy = httpProxy__default["default"].createProxyServer();
|
|
694
655
|
const deliveryProxy = httpProxy__default["default"].createProxyServer();
|
|
695
|
-
|
|
696
656
|
const reverseProxies = (app, reverseProxyPaths = []) => {
|
|
697
657
|
deliveryApiProxy(deliveryProxy, app);
|
|
698
658
|
app.all(reverseProxyPaths, (req, res) => {
|
|
@@ -732,8 +692,8 @@ const CacheDuration = {
|
|
|
732
692
|
static: '31536000',
|
|
733
693
|
// Believe it or not these two max ages are the same in runtime
|
|
734
694
|
expressStatic: '31557600h' // Believe it or not these two max ages are the same in runtime
|
|
735
|
-
|
|
736
695
|
};
|
|
696
|
+
|
|
737
697
|
const getCacheDuration = (status = 200) => {
|
|
738
698
|
if (status > 400) return CacheDuration[404];
|
|
739
699
|
return CacheDuration[200];
|
|
@@ -750,10 +710,8 @@ const bundleManipulationMiddleware = ({
|
|
|
750
710
|
const filename = path__default["default"].basename(req.path);
|
|
751
711
|
const modernBundle = filename.endsWith('.mjs');
|
|
752
712
|
const legacyBundle = filename.endsWith('.js');
|
|
753
|
-
|
|
754
713
|
if ((legacyBundle || modernBundle) && filename.startsWith('runtime.')) {
|
|
755
714
|
const jsRuntimeLocation = path__default["default"].resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
|
|
756
|
-
|
|
757
715
|
try {
|
|
758
716
|
const jsRuntimeBundle = fs__default["default"].readFileSync(jsRuntimeLocation, 'utf8');
|
|
759
717
|
const modifiedBundle = replaceStaticPath(jsRuntimeBundle, staticRoutePath);
|
|
@@ -776,7 +734,6 @@ const bundleManipulationMiddleware = ({
|
|
|
776
734
|
* @returns Response | next()
|
|
777
735
|
* A middleware function to resolve /dist/static/startup.js under a supplied startupScriptFilename variable
|
|
778
736
|
*/
|
|
779
|
-
|
|
780
737
|
const resolveStartupMiddleware = ({
|
|
781
738
|
appRootPath,
|
|
782
739
|
maxage,
|
|
@@ -785,7 +742,6 @@ const resolveStartupMiddleware = ({
|
|
|
785
742
|
}) => async (req, res, next) => {
|
|
786
743
|
if (startupScriptFilename !== 'startup.js' && req.path === `/${startupScriptFilename}`) {
|
|
787
744
|
let startupFileLocation = '';
|
|
788
|
-
|
|
789
745
|
try {
|
|
790
746
|
const startupFilePaths = [`dist/static/startup.js`, `dist/${staticFolderPath}/startup.js`];
|
|
791
747
|
let startupFilePath = '';
|
|
@@ -793,7 +749,8 @@ const resolveStartupMiddleware = ({
|
|
|
793
749
|
try {
|
|
794
750
|
fs__default["default"].accessSync(testPath);
|
|
795
751
|
startupFilePath = testPath;
|
|
796
|
-
} catch (ex) {
|
|
752
|
+
} catch (ex) {
|
|
753
|
+
// Do nothing
|
|
797
754
|
}
|
|
798
755
|
});
|
|
799
756
|
startupFileLocation = path__default["default"].resolve(appRootPath, startupFilePath);
|
|
@@ -830,7 +787,8 @@ const staticAssets = (app, {
|
|
|
830
787
|
maxage: CacheDuration.static,
|
|
831
788
|
startupScriptFilename: scripts.startup || startupScriptFilename,
|
|
832
789
|
staticFolderPath
|
|
833
|
-
}),
|
|
790
|
+
}),
|
|
791
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
834
792
|
express__default["default"].static(`dist/${staticFolderPath}`, {
|
|
835
793
|
// these maxage values are different in config but the same in runtime,
|
|
836
794
|
// this one is somehow converted and should end up being the same as CacheDuration.static
|
|
@@ -838,11 +796,8 @@ const staticAssets = (app, {
|
|
|
838
796
|
}));
|
|
839
797
|
};
|
|
840
798
|
|
|
841
|
-
const servers = SERVERS;
|
|
842
|
-
/* global
|
|
843
|
-
|
|
844
|
-
const projects = PROJECTS;
|
|
845
|
-
/* global PROJECTS */
|
|
799
|
+
const servers = SERVERS; /* global SERVERS */
|
|
800
|
+
const projects = PROJECTS; /* global PROJECTS */
|
|
846
801
|
|
|
847
802
|
const DisplayStartupConfiguration = config => {
|
|
848
803
|
/* eslint-disable no-console */
|
|
@@ -859,8 +814,6 @@ const DisplayStartupConfiguration = config => {
|
|
|
859
814
|
/* eslint-enable no-console */
|
|
860
815
|
};
|
|
861
816
|
|
|
862
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
863
|
-
|
|
864
817
|
/**
|
|
865
818
|
* Removes all key-value entries from the list cache.
|
|
866
819
|
*
|
|
@@ -1140,7 +1093,7 @@ var _stackHas = stackHas$1;
|
|
|
1140
1093
|
|
|
1141
1094
|
/** Detect free variable `global` from Node.js. */
|
|
1142
1095
|
|
|
1143
|
-
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
1096
|
+
var freeGlobal$1 = typeof _commonjsHelpers.commonjsGlobal == 'object' && _commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Object === Object && _commonjsHelpers.commonjsGlobal;
|
|
1144
1097
|
|
|
1145
1098
|
var _freeGlobal = freeGlobal$1;
|
|
1146
1099
|
|
|
@@ -3643,332 +3596,6 @@ function cloneDeep(value) {
|
|
|
3643
3596
|
|
|
3644
3597
|
var cloneDeep_1 = cloneDeep;
|
|
3645
3598
|
|
|
3646
|
-
/*!
|
|
3647
|
-
* cookie
|
|
3648
|
-
* Copyright(c) 2012-2014 Roman Shtylman
|
|
3649
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
3650
|
-
* MIT Licensed
|
|
3651
|
-
*/
|
|
3652
|
-
|
|
3653
|
-
/**
|
|
3654
|
-
* Module exports.
|
|
3655
|
-
* @public
|
|
3656
|
-
*/
|
|
3657
|
-
|
|
3658
|
-
var parse_1 = parse;
|
|
3659
|
-
var serialize_1 = serialize;
|
|
3660
|
-
|
|
3661
|
-
/**
|
|
3662
|
-
* Module variables.
|
|
3663
|
-
* @private
|
|
3664
|
-
*/
|
|
3665
|
-
|
|
3666
|
-
var decode = decodeURIComponent;
|
|
3667
|
-
var encode = encodeURIComponent;
|
|
3668
|
-
|
|
3669
|
-
/**
|
|
3670
|
-
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
3671
|
-
*
|
|
3672
|
-
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
3673
|
-
* field-vchar = VCHAR / obs-text
|
|
3674
|
-
* obs-text = %x80-FF
|
|
3675
|
-
*/
|
|
3676
|
-
|
|
3677
|
-
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
3678
|
-
|
|
3679
|
-
/**
|
|
3680
|
-
* Parse a cookie header.
|
|
3681
|
-
*
|
|
3682
|
-
* Parse the given cookie header string into an object
|
|
3683
|
-
* The object has the various cookies as keys(names) => values
|
|
3684
|
-
*
|
|
3685
|
-
* @param {string} str
|
|
3686
|
-
* @param {object} [options]
|
|
3687
|
-
* @return {object}
|
|
3688
|
-
* @public
|
|
3689
|
-
*/
|
|
3690
|
-
|
|
3691
|
-
function parse(str, options) {
|
|
3692
|
-
if (typeof str !== 'string') {
|
|
3693
|
-
throw new TypeError('argument str must be a string');
|
|
3694
|
-
}
|
|
3695
|
-
|
|
3696
|
-
var obj = {};
|
|
3697
|
-
var opt = options || {};
|
|
3698
|
-
var pairs = str.split(';');
|
|
3699
|
-
var dec = opt.decode || decode;
|
|
3700
|
-
|
|
3701
|
-
for (var i = 0; i < pairs.length; i++) {
|
|
3702
|
-
var pair = pairs[i];
|
|
3703
|
-
var index = pair.indexOf('=');
|
|
3704
|
-
|
|
3705
|
-
// skip things that don't look like key=value
|
|
3706
|
-
if (index < 0) {
|
|
3707
|
-
continue;
|
|
3708
|
-
}
|
|
3709
|
-
|
|
3710
|
-
var key = pair.substring(0, index).trim();
|
|
3711
|
-
|
|
3712
|
-
// only assign once
|
|
3713
|
-
if (undefined == obj[key]) {
|
|
3714
|
-
var val = pair.substring(index + 1, pair.length).trim();
|
|
3715
|
-
|
|
3716
|
-
// quoted values
|
|
3717
|
-
if (val[0] === '"') {
|
|
3718
|
-
val = val.slice(1, -1);
|
|
3719
|
-
}
|
|
3720
|
-
|
|
3721
|
-
obj[key] = tryDecode(val, dec);
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
|
|
3725
|
-
return obj;
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
/**
|
|
3729
|
-
* Serialize data into a cookie header.
|
|
3730
|
-
*
|
|
3731
|
-
* Serialize the a name value pair into a cookie string suitable for
|
|
3732
|
-
* http headers. An optional options object specified cookie parameters.
|
|
3733
|
-
*
|
|
3734
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
|
3735
|
-
* => "foo=bar; httpOnly"
|
|
3736
|
-
*
|
|
3737
|
-
* @param {string} name
|
|
3738
|
-
* @param {string} val
|
|
3739
|
-
* @param {object} [options]
|
|
3740
|
-
* @return {string}
|
|
3741
|
-
* @public
|
|
3742
|
-
*/
|
|
3743
|
-
|
|
3744
|
-
function serialize(name, val, options) {
|
|
3745
|
-
var opt = options || {};
|
|
3746
|
-
var enc = opt.encode || encode;
|
|
3747
|
-
|
|
3748
|
-
if (typeof enc !== 'function') {
|
|
3749
|
-
throw new TypeError('option encode is invalid');
|
|
3750
|
-
}
|
|
3751
|
-
|
|
3752
|
-
if (!fieldContentRegExp.test(name)) {
|
|
3753
|
-
throw new TypeError('argument name is invalid');
|
|
3754
|
-
}
|
|
3755
|
-
|
|
3756
|
-
var value = enc(val);
|
|
3757
|
-
|
|
3758
|
-
if (value && !fieldContentRegExp.test(value)) {
|
|
3759
|
-
throw new TypeError('argument val is invalid');
|
|
3760
|
-
}
|
|
3761
|
-
|
|
3762
|
-
var str = name + '=' + value;
|
|
3763
|
-
|
|
3764
|
-
if (null != opt.maxAge) {
|
|
3765
|
-
var maxAge = opt.maxAge - 0;
|
|
3766
|
-
|
|
3767
|
-
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
3768
|
-
throw new TypeError('option maxAge is invalid')
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
|
-
str += '; Max-Age=' + Math.floor(maxAge);
|
|
3772
|
-
}
|
|
3773
|
-
|
|
3774
|
-
if (opt.domain) {
|
|
3775
|
-
if (!fieldContentRegExp.test(opt.domain)) {
|
|
3776
|
-
throw new TypeError('option domain is invalid');
|
|
3777
|
-
}
|
|
3778
|
-
|
|
3779
|
-
str += '; Domain=' + opt.domain;
|
|
3780
|
-
}
|
|
3781
|
-
|
|
3782
|
-
if (opt.path) {
|
|
3783
|
-
if (!fieldContentRegExp.test(opt.path)) {
|
|
3784
|
-
throw new TypeError('option path is invalid');
|
|
3785
|
-
}
|
|
3786
|
-
|
|
3787
|
-
str += '; Path=' + opt.path;
|
|
3788
|
-
}
|
|
3789
|
-
|
|
3790
|
-
if (opt.expires) {
|
|
3791
|
-
if (typeof opt.expires.toUTCString !== 'function') {
|
|
3792
|
-
throw new TypeError('option expires is invalid');
|
|
3793
|
-
}
|
|
3794
|
-
|
|
3795
|
-
str += '; Expires=' + opt.expires.toUTCString();
|
|
3796
|
-
}
|
|
3797
|
-
|
|
3798
|
-
if (opt.httpOnly) {
|
|
3799
|
-
str += '; HttpOnly';
|
|
3800
|
-
}
|
|
3801
|
-
|
|
3802
|
-
if (opt.secure) {
|
|
3803
|
-
str += '; Secure';
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
|
-
if (opt.sameSite) {
|
|
3807
|
-
var sameSite = typeof opt.sameSite === 'string'
|
|
3808
|
-
? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
3809
|
-
|
|
3810
|
-
switch (sameSite) {
|
|
3811
|
-
case true:
|
|
3812
|
-
str += '; SameSite=Strict';
|
|
3813
|
-
break;
|
|
3814
|
-
case 'lax':
|
|
3815
|
-
str += '; SameSite=Lax';
|
|
3816
|
-
break;
|
|
3817
|
-
case 'strict':
|
|
3818
|
-
str += '; SameSite=Strict';
|
|
3819
|
-
break;
|
|
3820
|
-
case 'none':
|
|
3821
|
-
str += '; SameSite=None';
|
|
3822
|
-
break;
|
|
3823
|
-
default:
|
|
3824
|
-
throw new TypeError('option sameSite is invalid');
|
|
3825
|
-
}
|
|
3826
|
-
}
|
|
3827
|
-
|
|
3828
|
-
return str;
|
|
3829
|
-
}
|
|
3830
|
-
|
|
3831
|
-
/**
|
|
3832
|
-
* Try decoding a string using a decoding function.
|
|
3833
|
-
*
|
|
3834
|
-
* @param {string} str
|
|
3835
|
-
* @param {function} decode
|
|
3836
|
-
* @private
|
|
3837
|
-
*/
|
|
3838
|
-
|
|
3839
|
-
function tryDecode(str, decode) {
|
|
3840
|
-
try {
|
|
3841
|
-
return decode(str);
|
|
3842
|
-
} catch (e) {
|
|
3843
|
-
return str;
|
|
3844
|
-
}
|
|
3845
|
-
}
|
|
3846
|
-
|
|
3847
|
-
function hasDocumentCookie() {
|
|
3848
|
-
// Can we get/set cookies on document.cookie?
|
|
3849
|
-
return typeof document === 'object' && typeof document.cookie === 'string';
|
|
3850
|
-
}
|
|
3851
|
-
function parseCookies(cookies, options) {
|
|
3852
|
-
if (typeof cookies === 'string') {
|
|
3853
|
-
return parse_1(cookies, options);
|
|
3854
|
-
}
|
|
3855
|
-
else if (typeof cookies === 'object' && cookies !== null) {
|
|
3856
|
-
return cookies;
|
|
3857
|
-
}
|
|
3858
|
-
else {
|
|
3859
|
-
return {};
|
|
3860
|
-
}
|
|
3861
|
-
}
|
|
3862
|
-
function isParsingCookie(value, doNotParse) {
|
|
3863
|
-
if (typeof doNotParse === 'undefined') {
|
|
3864
|
-
// We guess if the cookie start with { or [, it has been serialized
|
|
3865
|
-
doNotParse =
|
|
3866
|
-
!value || (value[0] !== '{' && value[0] !== '[' && value[0] !== '"');
|
|
3867
|
-
}
|
|
3868
|
-
return !doNotParse;
|
|
3869
|
-
}
|
|
3870
|
-
function readCookie(value, options) {
|
|
3871
|
-
if (options === void 0) { options = {}; }
|
|
3872
|
-
var cleanValue = cleanupCookieValue(value);
|
|
3873
|
-
if (isParsingCookie(cleanValue, options.doNotParse)) {
|
|
3874
|
-
try {
|
|
3875
|
-
return JSON.parse(cleanValue);
|
|
3876
|
-
}
|
|
3877
|
-
catch (e) {
|
|
3878
|
-
// At least we tried
|
|
3879
|
-
}
|
|
3880
|
-
}
|
|
3881
|
-
// Ignore clean value if we failed the deserialization
|
|
3882
|
-
// It is not relevant anymore to trim those values
|
|
3883
|
-
return value;
|
|
3884
|
-
}
|
|
3885
|
-
function cleanupCookieValue(value) {
|
|
3886
|
-
// express prepend j: before serializing a cookie
|
|
3887
|
-
if (value && value[0] === 'j' && value[1] === ':') {
|
|
3888
|
-
return value.substr(2);
|
|
3889
|
-
}
|
|
3890
|
-
return value;
|
|
3891
|
-
}
|
|
3892
|
-
|
|
3893
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
3894
|
-
__assign = Object.assign || function(t) {
|
|
3895
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3896
|
-
s = arguments[i];
|
|
3897
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
3898
|
-
t[p] = s[p];
|
|
3899
|
-
}
|
|
3900
|
-
return t;
|
|
3901
|
-
};
|
|
3902
|
-
return __assign.apply(this, arguments);
|
|
3903
|
-
};
|
|
3904
|
-
var Cookies = /** @class */ (function () {
|
|
3905
|
-
function Cookies(cookies, options) {
|
|
3906
|
-
var _this = this;
|
|
3907
|
-
this.changeListeners = [];
|
|
3908
|
-
this.HAS_DOCUMENT_COOKIE = false;
|
|
3909
|
-
this.cookies = parseCookies(cookies, options);
|
|
3910
|
-
new Promise(function () {
|
|
3911
|
-
_this.HAS_DOCUMENT_COOKIE = hasDocumentCookie();
|
|
3912
|
-
}).catch(function () { });
|
|
3913
|
-
}
|
|
3914
|
-
Cookies.prototype._updateBrowserValues = function (parseOptions) {
|
|
3915
|
-
if (!this.HAS_DOCUMENT_COOKIE) {
|
|
3916
|
-
return;
|
|
3917
|
-
}
|
|
3918
|
-
this.cookies = parse_1(document.cookie, parseOptions);
|
|
3919
|
-
};
|
|
3920
|
-
Cookies.prototype._emitChange = function (params) {
|
|
3921
|
-
for (var i = 0; i < this.changeListeners.length; ++i) {
|
|
3922
|
-
this.changeListeners[i](params);
|
|
3923
|
-
}
|
|
3924
|
-
};
|
|
3925
|
-
Cookies.prototype.get = function (name, options, parseOptions) {
|
|
3926
|
-
if (options === void 0) { options = {}; }
|
|
3927
|
-
this._updateBrowserValues(parseOptions);
|
|
3928
|
-
return readCookie(this.cookies[name], options);
|
|
3929
|
-
};
|
|
3930
|
-
Cookies.prototype.getAll = function (options, parseOptions) {
|
|
3931
|
-
if (options === void 0) { options = {}; }
|
|
3932
|
-
this._updateBrowserValues(parseOptions);
|
|
3933
|
-
var result = {};
|
|
3934
|
-
for (var name_1 in this.cookies) {
|
|
3935
|
-
result[name_1] = readCookie(this.cookies[name_1], options);
|
|
3936
|
-
}
|
|
3937
|
-
return result;
|
|
3938
|
-
};
|
|
3939
|
-
Cookies.prototype.set = function (name, value, options) {
|
|
3940
|
-
var _a;
|
|
3941
|
-
if (typeof value === 'object') {
|
|
3942
|
-
value = JSON.stringify(value);
|
|
3943
|
-
}
|
|
3944
|
-
this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
|
|
3945
|
-
if (this.HAS_DOCUMENT_COOKIE) {
|
|
3946
|
-
document.cookie = serialize_1(name, value, options);
|
|
3947
|
-
}
|
|
3948
|
-
this._emitChange({ name: name, value: value, options: options });
|
|
3949
|
-
};
|
|
3950
|
-
Cookies.prototype.remove = function (name, options) {
|
|
3951
|
-
var finalOptions = (options = __assign(__assign({}, options), { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 }));
|
|
3952
|
-
this.cookies = __assign({}, this.cookies);
|
|
3953
|
-
delete this.cookies[name];
|
|
3954
|
-
if (this.HAS_DOCUMENT_COOKIE) {
|
|
3955
|
-
document.cookie = serialize_1(name, '', finalOptions);
|
|
3956
|
-
}
|
|
3957
|
-
this._emitChange({ name: name, value: undefined, options: options });
|
|
3958
|
-
};
|
|
3959
|
-
Cookies.prototype.addChangeListener = function (callback) {
|
|
3960
|
-
this.changeListeners.push(callback);
|
|
3961
|
-
};
|
|
3962
|
-
Cookies.prototype.removeChangeListener = function (callback) {
|
|
3963
|
-
var idx = this.changeListeners.indexOf(callback);
|
|
3964
|
-
if (idx >= 0) {
|
|
3965
|
-
this.changeListeners.splice(idx, 1);
|
|
3966
|
-
}
|
|
3967
|
-
};
|
|
3968
|
-
return Cookies;
|
|
3969
|
-
}());
|
|
3970
|
-
var Cookies$1 = Cookies;
|
|
3971
|
-
|
|
3972
3599
|
var stringifyAttributes = ((attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' '));
|
|
3973
3600
|
|
|
3974
3601
|
/* eslint-disable no-console */
|
|
@@ -3987,20 +3614,17 @@ const handleResponse = (request, response, content, send = 'send') => {
|
|
|
3987
3614
|
};
|
|
3988
3615
|
|
|
3989
3616
|
const readFileSync = path => fs__default["default"].readFileSync(path, 'utf8');
|
|
3990
|
-
|
|
3991
3617
|
const loadableBundleData = ({
|
|
3992
3618
|
stats,
|
|
3993
3619
|
templates
|
|
3994
3620
|
}, staticRoutePath, build) => {
|
|
3995
3621
|
const bundle = {};
|
|
3996
|
-
|
|
3997
3622
|
try {
|
|
3998
3623
|
bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
|
|
3999
3624
|
} catch (ex) {
|
|
4000
3625
|
// console.info(ex);
|
|
4001
3626
|
bundle.stats = null;
|
|
4002
3627
|
}
|
|
4003
|
-
|
|
4004
3628
|
try {
|
|
4005
3629
|
bundle.templates = {
|
|
4006
3630
|
templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
|
|
@@ -4011,18 +3635,15 @@ const loadableBundleData = ({
|
|
|
4011
3635
|
// console.info(ex);
|
|
4012
3636
|
bundle.templates = null;
|
|
4013
3637
|
}
|
|
4014
|
-
|
|
4015
3638
|
return bundle;
|
|
4016
3639
|
};
|
|
4017
3640
|
const loadableChunkExtractors = () => {
|
|
4018
3641
|
const commonLoadableExtractor = new server$1.ChunkExtractor({
|
|
4019
3642
|
stats: {}
|
|
4020
3643
|
});
|
|
4021
|
-
|
|
4022
3644
|
try {
|
|
4023
3645
|
let modern;
|
|
4024
3646
|
let legacy;
|
|
4025
|
-
|
|
4026
3647
|
try {
|
|
4027
3648
|
modern = new server$1.ChunkExtractor({
|
|
4028
3649
|
entrypoints: ['app'],
|
|
@@ -4032,7 +3653,6 @@ const loadableChunkExtractors = () => {
|
|
|
4032
3653
|
} catch (e) {
|
|
4033
3654
|
console.info('@loadable/server modern ChunkExtractor not available');
|
|
4034
3655
|
}
|
|
4035
|
-
|
|
4036
3656
|
try {
|
|
4037
3657
|
legacy = new server$1.ChunkExtractor({
|
|
4038
3658
|
entrypoints: ['app'],
|
|
@@ -4042,14 +3662,11 @@ const loadableChunkExtractors = () => {
|
|
|
4042
3662
|
} catch (e) {
|
|
4043
3663
|
console.info('@loadable/server legacy ChunkExtractor not available');
|
|
4044
3664
|
}
|
|
4045
|
-
|
|
4046
3665
|
commonLoadableExtractor.addChunk = chunk => {
|
|
4047
3666
|
var _modern, _legacy, _legacy2;
|
|
4048
|
-
|
|
4049
3667
|
(_modern = modern) === null || _modern === void 0 ? void 0 : _modern.addChunk(chunk);
|
|
4050
3668
|
if (typeof ((_legacy = legacy) === null || _legacy === void 0 ? void 0 : _legacy.stats.assetsByChunkName[chunk]) !== 'undefined') (_legacy2 = legacy) === null || _legacy2 === void 0 ? void 0 : _legacy2.addChunk(chunk);
|
|
4051
3669
|
};
|
|
4052
|
-
|
|
4053
3670
|
return {
|
|
4054
3671
|
commonLoadableExtractor,
|
|
4055
3672
|
modern,
|
|
@@ -4068,9 +3685,11 @@ const getBundleData = (config, staticRoutePath) => {
|
|
|
4068
3685
|
legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
|
|
4069
3686
|
modern: loadableBundleData(config, staticRoutePath, 'modern')
|
|
4070
3687
|
};
|
|
4071
|
-
if (!bundleData.default || bundleData.default
|
|
3688
|
+
if (!bundleData.default || Object.keys(bundleData.default || {}).length === 0) bundleData.default = bundleData.legacy || bundleData.modern;
|
|
4072
3689
|
return bundleData;
|
|
4073
|
-
};
|
|
3690
|
+
};
|
|
3691
|
+
|
|
3692
|
+
// export const buildBundleTags = (
|
|
4074
3693
|
// bundles,
|
|
4075
3694
|
// differentialBundles = false,
|
|
4076
3695
|
// staticRoutePath = 'static',
|
|
@@ -4095,17 +3714,18 @@ const getBundleData = (config, staticRoutePath) => {
|
|
|
4095
3714
|
// )}"></script>`;
|
|
4096
3715
|
// })
|
|
4097
3716
|
// .filter(f => f);
|
|
3717
|
+
|
|
4098
3718
|
// return bundleTags;
|
|
4099
3719
|
// };
|
|
4100
3720
|
|
|
4101
3721
|
const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
|
|
4102
|
-
let startupTag = '';
|
|
4103
|
-
|
|
4104
|
-
if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
3722
|
+
let startupTag = '';
|
|
3723
|
+
// Add the static startup script to the bundleTags
|
|
3724
|
+
if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
|
|
4105
3725
|
|
|
3726
|
+
// Get the script tags from their respective extractor instances
|
|
4106
3727
|
if (loadableExtractor) {
|
|
4107
3728
|
var _loadableExtractor$le, _loadableExtractor$mo;
|
|
4108
|
-
|
|
4109
3729
|
const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
|
|
4110
3730
|
nomodule: 'nomodule'
|
|
4111
3731
|
});
|
|
@@ -4115,19 +3735,25 @@ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') =
|
|
|
4115
3735
|
const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
|
|
4116
3736
|
return scriptTags;
|
|
4117
3737
|
}
|
|
4118
|
-
|
|
4119
3738
|
return startupTag;
|
|
4120
3739
|
};
|
|
4121
3740
|
|
|
3741
|
+
const alias = ALIAS; /* global ALIAS */
|
|
3742
|
+
|
|
4122
3743
|
const addStandardHeaders = (state, response, packagejson, groups) => {
|
|
4123
3744
|
if (state) {
|
|
4124
3745
|
try {
|
|
4125
3746
|
console.info('About to add headers');
|
|
4126
3747
|
const routingSurrogateKeys = selectors.selectSurrogateKeys(state);
|
|
4127
|
-
|
|
4128
|
-
|
|
3748
|
+
|
|
3749
|
+
// Check length of surrogate keys and prevent potential header overflow
|
|
3750
|
+
// errors in prod by replacing with `any-update` header that will indiscriminately
|
|
3751
|
+
// invalidate the SSR page cache when any content is updated
|
|
3752
|
+
const surrogateKeys = routingSurrogateKeys.length >= 2000 ? `${alias}_any-update` : routingSurrogateKeys.join(' ');
|
|
3753
|
+
const surrogateKeyHeader = `${packagejson.name}-app ${surrogateKeys}`;
|
|
3754
|
+
response.setHeader('surrogate-key', surrogateKeyHeader);
|
|
4129
3755
|
addVarnishAuthenticationHeaders(state, response, groups);
|
|
4130
|
-
response.setHeader('
|
|
3756
|
+
response.setHeader('surrogate-control', `max-age=${getCacheDuration(response.statusCode)}`);
|
|
4131
3757
|
} catch (e) {
|
|
4132
3758
|
console.info('Error Adding headers', e.message);
|
|
4133
3759
|
}
|
|
@@ -4141,14 +3767,12 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
|
4141
3767
|
const {
|
|
4142
3768
|
globalGroups,
|
|
4143
3769
|
allowedGroups
|
|
4144
|
-
} = groups;
|
|
4145
|
-
|
|
3770
|
+
} = groups;
|
|
3771
|
+
// console.info(globalGroups, allowedGroups);
|
|
4146
3772
|
let allGroups = Array.from(globalGroups && globalGroups[project] || {});
|
|
4147
|
-
|
|
4148
3773
|
if (stateEntry && selectors.getImmutableOrJS(stateEntry, ['authentication', 'isLoginRequired']) && allowedGroups && allowedGroups[project]) {
|
|
4149
3774
|
allGroups = [...allGroups, ...allowedGroups[project]];
|
|
4150
3775
|
}
|
|
4151
|
-
|
|
4152
3776
|
response.header('x-contensis-viewer-groups', allGroups.join('|'));
|
|
4153
3777
|
} catch (e) {
|
|
4154
3778
|
console.info('Error adding authentication header', e);
|
|
@@ -4168,18 +3792,18 @@ const getVersionInfo = staticFolderPath => {
|
|
|
4168
3792
|
};
|
|
4169
3793
|
|
|
4170
3794
|
/* eslint-disable no-console */
|
|
4171
|
-
const unhandledExceptionHandler = (handleExceptions = true) => {
|
|
4172
|
-
const exceptionTypes = handleExceptions === true ? ['uncaughtException', 'unhandledRejection', 'SIGTERM', 'SIGINT'] // Default exception types to add event listeners for
|
|
4173
|
-
: Array.isArray(handleExceptions) // In future we could accept an array of specific exception types to handle for a specific application?
|
|
4174
|
-
? handleExceptions : [];
|
|
4175
3795
|
|
|
3796
|
+
// Default exception types to add event listeners for
|
|
3797
|
+
const handleDefaultEvents = ['uncaughtException', 'unhandledRejection'];
|
|
3798
|
+
const unhandledExceptionHandler = (handleExceptions = handleDefaultEvents) => {
|
|
3799
|
+
const exceptionTypes = Array.isArray(handleExceptions) ? handleExceptions : handleExceptions === false ? [] : handleDefaultEvents;
|
|
4176
3800
|
for (const type of exceptionTypes) {
|
|
4177
3801
|
process.on(type, err => {
|
|
4178
3802
|
if (err && err instanceof Error) {
|
|
4179
3803
|
// Print a message to inform admins and developers the error should not be ignored
|
|
4180
3804
|
console.log(`${`[contensis-react-base] ❌ ${chalk__default["default"].red.bold(`${type} - ${err.message}`)}`}`);
|
|
4181
|
-
console.log(chalk__default["default"].gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`);
|
|
4182
|
-
|
|
3805
|
+
console.log(chalk__default["default"].gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`);
|
|
3806
|
+
// Log the error to server console
|
|
4183
3807
|
console.error(err);
|
|
4184
3808
|
}
|
|
4185
3809
|
});
|
|
@@ -4208,27 +3832,23 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4208
3832
|
const attributes = stringifyAttributes(scripts.attributes);
|
|
4209
3833
|
scripts.startup = scripts.startup || startupScriptFilename;
|
|
4210
3834
|
const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
|
|
4211
|
-
if (handleExceptions !== false) unhandledExceptionHandler(); // Create `process.on` event handlers for unhandled exceptions (Node v15+)
|
|
3835
|
+
if (handleExceptions !== false) unhandledExceptionHandler(handleExceptions); // Create `process.on` event handlers for unhandled exceptions (Node v15+)
|
|
4212
3836
|
|
|
4213
3837
|
const versionInfo = getVersionInfo(staticFolderPath);
|
|
4214
|
-
app.get('/*', async (request, response) => {
|
|
3838
|
+
app.get('/*', cookiesMiddleware__default["default"](), async (request, response) => {
|
|
4215
3839
|
const {
|
|
4216
3840
|
url
|
|
4217
3841
|
} = request;
|
|
4218
|
-
const cookies = new Cookies$1(request.headers.cookie);
|
|
4219
|
-
|
|
4220
3842
|
const matchedStaticRoute = () => reactRouterConfig.matchRoutes(routes.StaticRoutes, request.path);
|
|
4221
|
-
|
|
4222
3843
|
const isStaticRoute = () => matchedStaticRoute().length > 0;
|
|
3844
|
+
const staticRoute = isStaticRoute() && matchedStaticRoute()[0];
|
|
4223
3845
|
|
|
4224
|
-
|
|
4225
|
-
|
|
3846
|
+
// Allow certain routes to avoid SSR
|
|
4226
3847
|
const onlyDynamic = staticRoute && staticRoute.route.ssr === false;
|
|
4227
3848
|
const onlySSR = staticRoute && staticRoute.route.ssrOnly === true;
|
|
3849
|
+
const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false;
|
|
4228
3850
|
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
3851
|
+
// Determine functional params from QueryString and set access methods
|
|
4232
3852
|
const accessMethod = mapJson__default["default"](request.query, {
|
|
4233
3853
|
DYNAMIC: ({
|
|
4234
3854
|
dynamic
|
|
@@ -4243,26 +3863,32 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4243
3863
|
static: value
|
|
4244
3864
|
}) => normaliseQs(value) || onlySSR
|
|
4245
3865
|
});
|
|
4246
|
-
const context = {};
|
|
4247
|
-
|
|
4248
|
-
response.status(200);
|
|
3866
|
+
const context = {};
|
|
3867
|
+
// Track the current statusCode via the response object
|
|
3868
|
+
response.status(200);
|
|
4249
3869
|
|
|
3870
|
+
// Create a store (with a memory history) from our current url
|
|
4250
3871
|
const store = await version.createStore(withReducers, {}, App.history({
|
|
4251
3872
|
initialEntries: [url]
|
|
4252
|
-
}), stateType);
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
3873
|
+
}), stateType);
|
|
3874
|
+
|
|
3875
|
+
// dispatch any global and non-saga related actions before calling our JSX
|
|
3876
|
+
const versionStatus = ContensisDeliveryApi.deliveryApi.getServerSideVersionStatus(request);
|
|
3877
|
+
|
|
3878
|
+
// In server-side blocks world, the hostname requested by the client resides in the x-orig-host header
|
|
3879
|
+
// Because of this, we prioritize x-orig-host when setting our hostname
|
|
3880
|
+
const hostname = request.headers['x-orig-host'] || request.hostname;
|
|
3881
|
+
console.info(`Request for ${request.path} hostname: ${hostname} versionStatus: ${versionStatus}`);
|
|
3882
|
+
store.dispatch(version$1.setVersionStatus(versionStatus));
|
|
3883
|
+
store.dispatch(version$1.setVersion(versionInfo.commitRef, versionInfo.buildNo));
|
|
3884
|
+
const project = App.pickProject(hostname, request.query);
|
|
4259
3885
|
const groups = allowedGroups && allowedGroups[project];
|
|
4260
|
-
store.dispatch(
|
|
3886
|
+
store.dispatch(selectors.setCurrentProject(project, groups, hostname));
|
|
4261
3887
|
const loadableExtractor = loadableChunkExtractors();
|
|
4262
3888
|
const jsx = /*#__PURE__*/React__default["default"].createElement(server$1.ChunkExtractorManager, {
|
|
4263
3889
|
extractor: loadableExtractor.commonLoadableExtractor
|
|
4264
3890
|
}, /*#__PURE__*/React__default["default"].createElement(reactCookie.CookiesProvider, {
|
|
4265
|
-
cookies:
|
|
3891
|
+
cookies: request.universalCookies
|
|
4266
3892
|
}, /*#__PURE__*/React__default["default"].createElement(reactRedux.Provider, {
|
|
4267
3893
|
store: store
|
|
4268
3894
|
}, /*#__PURE__*/React__default["default"].createElement(reactRouterDom.StaticRouter, {
|
|
@@ -4276,23 +3902,25 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4276
3902
|
templateHTML = '',
|
|
4277
3903
|
templateHTMLFragment = '',
|
|
4278
3904
|
templateHTMLStatic = ''
|
|
4279
|
-
} = bundleData.default.templates || bundleData.legacy.templates || {};
|
|
3905
|
+
} = bundleData.default.templates || bundleData.legacy.templates || {};
|
|
4280
3906
|
|
|
3907
|
+
// Serve a blank HTML page with client scripts to load the app in the browser
|
|
4281
3908
|
if (accessMethod.DYNAMIC) {
|
|
4282
3909
|
// Dynamic doesn't need sagas
|
|
4283
|
-
server$2.renderToString(jsx);
|
|
4284
|
-
// and does not include any react-loadable code-split bundles
|
|
3910
|
+
server$2.renderToString(jsx);
|
|
4285
3911
|
|
|
3912
|
+
// Dynamic page render has only the necessary bundles to start up the app
|
|
3913
|
+
// and does not include any react-loadable code-split bundles
|
|
4286
3914
|
const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
|
|
4287
3915
|
const isDynamicHints = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.isDynamic = true;</script>`;
|
|
4288
|
-
const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints);
|
|
3916
|
+
const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints);
|
|
3917
|
+
// Dynamic pages always return a 200 so we can run
|
|
4289
3918
|
// the app and serve up all errors inside the client
|
|
4290
|
-
|
|
4291
3919
|
response.setHeader('Surrogate-Control', `max-age=${getCacheDuration(200)}`);
|
|
4292
3920
|
responseHandler(request, response, responseHtmlDynamic);
|
|
4293
|
-
}
|
|
4294
|
-
|
|
3921
|
+
}
|
|
4295
3922
|
|
|
3923
|
+
// Render the JSX server side and send response as per access method options
|
|
4296
3924
|
if (!accessMethod.DYNAMIC) {
|
|
4297
3925
|
store.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
|
|
4298
3926
|
const sheet = new styled.ServerStyleSheet();
|
|
@@ -4302,15 +3930,14 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4302
3930
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
4303
3931
|
let title = helmet.title.toString();
|
|
4304
3932
|
const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
|
|
4305
|
-
|
|
4306
3933
|
if (context.url) {
|
|
4307
3934
|
return response.redirect(context.statusCode || 302, context.url);
|
|
4308
3935
|
}
|
|
4309
|
-
|
|
4310
3936
|
const reduxState = store.getState();
|
|
4311
|
-
const styleTags = sheet.getStyleTags();
|
|
4312
|
-
// code-split bundles for any page components as well as core app bundles
|
|
3937
|
+
const styleTags = sheet.getStyleTags();
|
|
4313
3938
|
|
|
3939
|
+
// After running rootSaga there should be an additional react-loadable
|
|
3940
|
+
// code-split bundles for any page components as well as core app bundles
|
|
4314
3941
|
const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
|
|
4315
3942
|
let serialisedReduxData = serialize__default["default"](lodashClean.buildCleaner({
|
|
4316
3943
|
isArray: lodash.identity,
|
|
@@ -4322,7 +3949,6 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4322
3949
|
isString: lodash.identity,
|
|
4323
3950
|
isUndefined: lodash.noop
|
|
4324
3951
|
})(cloneDeep_1(reduxState)));
|
|
4325
|
-
|
|
4326
3952
|
if (context.statusCode !== 404) {
|
|
4327
3953
|
// For a request that returns a redux state object as a response
|
|
4328
3954
|
if (accessMethod.REDUX) {
|
|
@@ -4333,7 +3959,6 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4333
3959
|
responseHandler(request, response, serialisedReduxData, 'json');
|
|
4334
3960
|
return true;
|
|
4335
3961
|
}
|
|
4336
|
-
|
|
4337
3962
|
if (!disableSsrRedux) {
|
|
4338
3963
|
// window.versionStatus is not strictly required here and is added to support cases
|
|
4339
3964
|
// where a consumer may not be using the contensisVersionStatus in redux and calling
|
|
@@ -4341,41 +3966,40 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4341
3966
|
serialisedReduxData = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
|
|
4342
3967
|
}
|
|
4343
3968
|
}
|
|
4344
|
-
|
|
4345
|
-
if ((context.statusCode || 200) > 400) {
|
|
3969
|
+
if ((context.statusCode || 200) >= 404) {
|
|
4346
3970
|
accessMethod.STATIC = true;
|
|
4347
|
-
}
|
|
4348
|
-
|
|
3971
|
+
}
|
|
4349
3972
|
|
|
3973
|
+
// Responses
|
|
4350
3974
|
let responseHTML = '';
|
|
4351
|
-
if (context.statusCode === 404) title = '<title>404 page not found</title>';
|
|
3975
|
+
if (context.statusCode === 404) title = '<title>404 page not found</title>';
|
|
4352
3976
|
|
|
3977
|
+
// Static page served as a fragment
|
|
4353
3978
|
if (accessMethod.FRAGMENT && accessMethod.STATIC) {
|
|
4354
3979
|
responseHTML = minifyCssString__default["default"](styleTags) + html;
|
|
4355
|
-
}
|
|
4356
|
-
|
|
3980
|
+
}
|
|
4357
3981
|
|
|
3982
|
+
// Page fragment served with client scripts and redux data that hydrate the app client side
|
|
4358
3983
|
if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
|
|
4359
3984
|
responseHTML = templateHTMLFragment.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default["default"](styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', serialisedReduxData);
|
|
4360
|
-
}
|
|
4361
|
-
|
|
3985
|
+
}
|
|
4362
3986
|
|
|
3987
|
+
// Full HTML page served statically
|
|
4363
3988
|
if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
|
|
4364
3989
|
responseHTML = templateHTMLStatic.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default["default"](styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', '');
|
|
4365
|
-
}
|
|
4366
|
-
|
|
3990
|
+
}
|
|
4367
3991
|
|
|
3992
|
+
// Full HTML page served with client scripts and redux data that hydrate the app client side
|
|
4368
3993
|
if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
|
|
4369
3994
|
responseHTML = templateHTML.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', styleTags).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', serialisedReduxData);
|
|
4370
|
-
}
|
|
4371
|
-
|
|
3995
|
+
}
|
|
4372
3996
|
|
|
3997
|
+
// Set response.status from React StaticRouter
|
|
4373
3998
|
if (typeof context.statusCode === 'number') response.status(context.statusCode);
|
|
4374
3999
|
addStandardHeaders(reduxState, response, packagejson, {
|
|
4375
4000
|
allowedGroups,
|
|
4376
4001
|
globalGroups
|
|
4377
4002
|
});
|
|
4378
|
-
|
|
4379
4003
|
try {
|
|
4380
4004
|
// If react-helmet htmlAttributes are being used,
|
|
4381
4005
|
// replace the html tag with those attributes sepcified
|
|
@@ -4383,7 +4007,6 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4383
4007
|
if (htmlAttributes) {
|
|
4384
4008
|
responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
|
|
4385
4009
|
}
|
|
4386
|
-
|
|
4387
4010
|
responseHandler(request, response, responseHTML);
|
|
4388
4011
|
} catch (err) {
|
|
4389
4012
|
console.info(err.message);
|
|
@@ -4403,18 +4026,17 @@ const webApp = (app, ReactApp, config) => {
|
|
|
4403
4026
|
|
|
4404
4027
|
const app = express__default["default"]();
|
|
4405
4028
|
const server = http__default["default"].createServer(app);
|
|
4406
|
-
|
|
4407
4029
|
const start = (ReactApp, config, ServerFeatures) => {
|
|
4408
4030
|
global.PACKAGE_JSON = config.packagejson;
|
|
4409
4031
|
global.DISABLE_SSR_REDUX = config.disableSsrRedux;
|
|
4410
4032
|
global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
|
|
4411
4033
|
global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
|
|
4412
|
-
app.disable('x-powered-by');
|
|
4413
|
-
|
|
4034
|
+
app.disable('x-powered-by');
|
|
4035
|
+
// Output some information about the used build/startup configuration
|
|
4414
4036
|
DisplayStartupConfiguration(config);
|
|
4415
|
-
ServerFeatures(app);
|
|
4037
|
+
ServerFeatures(app);
|
|
4038
|
+
// Set-up local proxy for images from cms, and delivery api requests
|
|
4416
4039
|
// to save doing rewrites and extra code
|
|
4417
|
-
|
|
4418
4040
|
reverseProxies(app, config.reverseProxyPaths);
|
|
4419
4041
|
staticAssets(app, config);
|
|
4420
4042
|
webApp(app, ReactApp, config);
|
|
@@ -4428,11 +4050,11 @@ const start = (ReactApp, config, ServerFeatures) => {
|
|
|
4428
4050
|
app.on('stop', () => {
|
|
4429
4051
|
server.close(function () {
|
|
4430
4052
|
console.info('GoodBye :(');
|
|
4053
|
+
process.exit();
|
|
4431
4054
|
});
|
|
4432
4055
|
});
|
|
4433
4056
|
});
|
|
4434
4057
|
};
|
|
4435
|
-
|
|
4436
4058
|
var internalServer = {
|
|
4437
4059
|
app,
|
|
4438
4060
|
apiProxy: deliveryProxy,
|