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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/cjs/{App-ee485b92.js → App-21a7d836.js} +120 -432
  2. package/cjs/App-21a7d836.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.js.map} +1 -1
  9. package/cjs/client.js +20 -27
  10. package/cjs/client.js.map +1 -1
  11. package/cjs/contensis-react-base.js +124 -188
  12. package/cjs/contensis-react-base.js.map +1 -1
  13. package/cjs/forms.js +1488 -272
  14. package/cjs/forms.js.map +1 -1
  15. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
  16. package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
  17. package/cjs/{login-840860bc.js → login-2a6b5be0.js} +64 -113
  18. package/cjs/login-2a6b5be0.js.map +1 -0
  19. package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
  20. package/cjs/reducers-9afb5f89.js.map +1 -0
  21. package/cjs/redux.js +17 -17
  22. package/cjs/redux.js.map +1 -1
  23. package/cjs/routing.js +6 -7
  24. package/cjs/routing.js.map +1 -1
  25. package/cjs/{sagas-8a20e424.js → sagas-e04b94c1.js} +225 -301
  26. package/cjs/sagas-e04b94c1.js.map +1 -0
  27. package/cjs/search.js +68 -94
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
  30. package/cjs/selectors-bcca60f4.js.map +1 -0
  31. package/cjs/urls-6fcaf4c6.js.map +1 -1
  32. package/cjs/user.js +4 -13
  33. package/cjs/user.js.map +1 -1
  34. package/cjs/util.js +45 -53
  35. package/cjs/util.js.map +1 -1
  36. package/cjs/{version-78dfc3bd.js → version-4077e706.js} +50 -159
  37. package/cjs/version-4077e706.js.map +1 -0
  38. package/cjs/version-fe28099e.js +98 -0
  39. package/cjs/version-fe28099e.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
  41. package/esm/App-2af18a99.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
  43. package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.js.map} +1 -1
  48. package/esm/client.js +15 -22
  49. package/esm/client.js.map +1 -1
  50. package/esm/contensis-react-base.js +119 -183
  51. package/esm/contensis-react-base.js.map +1 -1
  52. package/esm/forms.js +1490 -274
  53. package/esm/forms.js.map +1 -1
  54. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
  55. package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
  56. package/esm/{login-57395c9c.js → login-71ff3fcb.js} +63 -112
  57. package/esm/login-71ff3fcb.js.map +1 -0
  58. package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
  59. package/esm/reducers-3d5c37d1.js.map +1 -0
  60. package/esm/redux.js +9 -8
  61. package/esm/redux.js.map +1 -1
  62. package/esm/routing.js +3 -4
  63. package/esm/routing.js.map +1 -1
  64. package/esm/{sagas-e576b6f6.js → sagas-933a8fc8.js} +177 -254
  65. package/esm/sagas-933a8fc8.js.map +1 -0
  66. package/esm/search.js +69 -95
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
  69. package/esm/selectors-74de49a3.js.map +1 -0
  70. package/esm/urls-eac9a747.js.map +1 -1
  71. package/esm/user.js +6 -15
  72. package/esm/user.js.map +1 -1
  73. package/esm/util.js +42 -53
  74. package/esm/util.js.map +1 -1
  75. package/esm/version-b15807c5.js +87 -0
  76. package/esm/version-b15807c5.js.map +1 -0
  77. package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
  78. package/esm/version-ef107106.js.map +1 -0
  79. package/models/redux/appstate.d.ts +1 -0
  80. package/models/routing/redux/selectors.d.ts +2 -1
  81. package/models/search/models/Queries.d.ts +2 -1
  82. package/models/search/models/Search.d.ts +2 -0
  83. package/models/search/models/SearchActions.d.ts +3 -3
  84. package/models/search/redux/actions.d.ts +6 -6
  85. package/models/search/redux/util.d.ts +1 -1
  86. package/models/search/search/expressions.d.ts +1 -1
  87. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  88. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  89. package/models/util/index.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/cjs/App-ee485b92.js.map +0 -1
  92. package/cjs/actions-8dc9e8de.js +0 -87
  93. package/cjs/actions-8dc9e8de.js.map +0 -1
  94. package/cjs/login-840860bc.js.map +0 -1
  95. package/cjs/reducers-3a4f8971.js.map +0 -1
  96. package/cjs/sagas-8a20e424.js.map +0 -1
  97. package/cjs/selectors-656da4b7.js.map +0 -1
  98. package/cjs/version-78dfc3bd.js.map +0 -1
  99. package/cjs/version-eba6d09b.js +0 -20
  100. package/cjs/version-eba6d09b.js.map +0 -1
  101. package/esm/App-640239d2.js.map +0 -1
  102. package/esm/actions-180948dd.js +0 -72
  103. package/esm/actions-180948dd.js.map +0 -1
  104. package/esm/login-57395c9c.js.map +0 -1
  105. package/esm/reducers-8e5d6232.js.map +0 -1
  106. package/esm/sagas-e576b6f6.js.map +0 -1
  107. package/esm/selectors-a5e5835b.js.map +0 -1
  108. package/esm/version-2485e2fb.js +0 -15
  109. package/esm/version-2485e2fb.js.map +0 -1
  110. package/esm/version-e3a5ec66.js.map +0 -1
@@ -1,13 +1,12 @@
1
- import { c as cachedSearch, h as history, d as deliveryApi, p as pickProject, r as rootSaga } from './App-640239d2.js';
2
- export { A as ReactApp } from './App-640239d2.js';
1
+ import { c as cachedSearch, d as deliveryApi } from './ContensisDeliveryApi-5660ee0e.js';
3
2
  import { Query as Query$1 } from 'contensis-delivery-api';
4
3
  import React from 'react';
5
4
  import { Provider } from 'react-redux';
6
- import { d as defaultExpressions, c as contentTypeIdExpression, f as filterExpressions, t as termExpressions, o as orderByExpression, a as customWhereExpressions } from './sagas-e576b6f6.js';
7
5
  import mapJson from 'jsonpath-mapper';
8
6
  import 'reselect';
9
7
  import 'deepmerge';
10
8
  import 'query-string';
9
+ import { d as defaultExpressions, c as contentTypeIdExpression, f as filterExpressions, t as termExpressions, o as orderByExpression, a as customWhereExpressions } from './sagas-933a8fc8.js';
11
10
  import 'immer';
12
11
  import 'deep-equal';
13
12
  import { Op, Query } from 'contensis-core-api';
@@ -30,25 +29,26 @@ import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
30
29
  import { identity, noop } from 'lodash';
31
30
  import { buildCleaner } from 'lodash-clean';
32
31
  import { CookiesProvider } from 'react-cookie';
33
- import { c as createStore, s as setVersionStatus, a as setVersion } from './version-e3a5ec66.js';
34
- import { s as setCurrentProject } from './actions-180948dd.js';
35
- import { s as selectSurrogateKeys, a as selectRouteEntry, b as selectCurrentProject, g as getImmutableOrJS } from './selectors-a5e5835b.js';
32
+ import { c as createStore } from './version-ef107106.js';
33
+ import { h as history, p as pickProject, r as rootSaga } from './App-2af18a99.js';
34
+ export { A as ReactApp } from './App-2af18a99.js';
35
+ import { s as setVersionStatus, a as setVersion } from './version-b15807c5.js';
36
+ import { s as selectSurrogateKeys, a as selectRouteEntry, b as selectCurrentProject, g as getImmutableOrJS, c as setCurrentProject } from './selectors-74de49a3.js';
36
37
  import chalk from 'chalk';
37
- import 'history';
38
- import '@redux-saga/core/effects';
39
38
  import 'loglevel';
40
- import './version-2485e2fb.js';
41
- import './login-57395c9c.js';
42
- import './reducers-8e5d6232.js';
43
- import './ToJs-4e02a04d.js';
44
- import 'await-to-js';
45
- import 'js-cookie';
46
- import 'react-hot-loader';
47
- import './RouteLoader-5171c63f.js';
39
+ import '@redux-saga/core/effects';
48
40
  import 'redux';
49
41
  import 'redux-thunk';
50
42
  import 'redux-saga';
51
43
  import 'redux-injectors';
44
+ import './reducers-3d5c37d1.js';
45
+ import 'history';
46
+ import './login-71ff3fcb.js';
47
+ import './ToJs-9b30636a.js';
48
+ import 'await-to-js';
49
+ import 'js-cookie';
50
+ import 'react-hot-loader';
51
+ import './RouteLoader-6eac364e.js';
52
52
 
53
53
  /**
54
54
  * Util class holds our search results helper boilerplate methods
@@ -58,26 +58,20 @@ class Util {
58
58
  if (fieldId) {
59
59
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
60
60
  var _e$fieldId, _e$fieldId2, _e$fieldId2$sys;
61
-
62
61
  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 => {
63
62
  var _f$sys;
64
-
65
63
  return f === null || f === void 0 ? void 0 : (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
66
64
  }) : (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) || '';
67
65
  }).flat();
68
66
  }
69
-
70
67
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
71
68
  var _e$sys;
72
-
73
69
  return (e === null || e === void 0 ? void 0 : (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
74
70
  });
75
71
  }
76
-
77
72
  static GetItems(result) {
78
73
  return this.GetResults(result) ? result.items : [];
79
74
  }
80
-
81
75
  static GetResults(result) {
82
76
  if (result !== null && result !== void 0 && result.items) {
83
77
  return result;
@@ -85,20 +79,18 @@ class Util {
85
79
  return null;
86
80
  }
87
81
  }
88
-
89
82
  }
90
83
  const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId) => results.map(r => {
91
84
  if (replaceContentTypeIds.some(c => c === r.sys.contentTypeId)) {
92
85
  const resolvedParent = parentResults === null || parentResults === void 0 ? void 0 : parentResults.find(e => {
93
86
  var _e$linkFieldId;
94
-
95
87
  return (_e$linkFieldId = e[linkFieldId]) === null || _e$linkFieldId === void 0 ? void 0 : _e$linkFieldId.some(l => {
96
88
  var _l$sys;
97
-
98
89
  return ((_l$sys = l.sys) === null || _l$sys === void 0 ? void 0 : _l$sys.id) === r.sys.id;
99
90
  });
100
91
  });
101
- if (resolvedParent) return { ...resolvedParent,
92
+ if (resolvedParent) return {
93
+ ...resolvedParent,
102
94
  ...r,
103
95
  entryTitle: resolvedParent.entryTitle,
104
96
  entryDescription: resolvedParent.entryDescription,
@@ -106,12 +98,10 @@ const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId
106
98
  originalSys: r.sys
107
99
  };else return r;
108
100
  }
109
-
110
101
  return r;
111
102
  }).filter(r => r);
112
103
 
113
104
  /* eslint-disable no-console */
114
-
115
105
  /**
116
106
  * Builds our complete Delivery API Query object from a set of provided arguments
117
107
  * @param queryParams
@@ -136,13 +126,12 @@ const searchQuery = ({
136
126
  const expressions$1 = [...defaultExpressions(versionStatus), ...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...customWhereExpressions(customWhere), ...filterExpressions(filters), ...filterExpressions(idFilters), ...((sharedFilters === null || sharedFilters === void 0 ? void 0 : sharedFilters.length) > 0 ? [Op.or(...filterExpressions(sharedFilters, true))] : []), ...termExpressions(searchTerm || '', weightedSearchFields || [])];
137
127
  const query = new Query(...expressions$1);
138
128
  query.orderBy = orderByExpression(orderBy || []);
139
-
140
129
  if (fields && fields.length > 0) {
141
130
  query.fields = fields;
142
- } // (query as any).includeArchived = true;
143
- // (query as any).includeDeleted = true;
144
-
131
+ }
145
132
 
133
+ // (query as any).includeArchived = true;
134
+ // (query as any).includeDeleted = true;
146
135
  query.pageIndex = pageIndex;
147
136
  query.pageSize = pageSize;
148
137
  return query;
@@ -165,7 +154,8 @@ const finalQuery = ({
165
154
  webpageTemplates,
166
155
  weightedSearchFields
167
156
  }, children) => {
168
- const expressions$1 = [...defaultExpressions(versionStatus), Op.or(Op.and(...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...filterExpressions(filters), ...filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [Op.or(...filterExpressions(sharedFilters || []) // Op.and(
157
+ const expressions$1 = [...defaultExpressions(versionStatus), Op.or(Op.and(...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...filterExpressions(filters), ...filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [Op.or(...filterExpressions(sharedFilters || [])
158
+ // Op.and(
169
159
  // ...sharedFilters.map(sf =>
170
160
  // Op.not(exp.fieldExpression(sf.key, true, 'exists')[0])
171
161
  // ),
@@ -174,17 +164,17 @@ const finalQuery = ({
174
164
  )] : [])), ...children.map(child => Op.and(...contentTypeIdExpression(child.contentTypeIds, child.webpageTemplates, child.assetTypes), ...filterExpressions(child.sharedFilters || []), ...filterExpressions(child.idFilters || [])))), ...termExpressions(searchTerm || '', weightedSearchFields || [])];
175
165
  const query = new Query(...expressions$1);
176
166
  query.orderBy = orderByExpression(orderBy || []);
177
-
178
167
  if (fields && fields.length > 0) {
179
168
  query.fields = fields;
180
- } // (query as any).includeArchived = true;
181
- // (query as any).includeDeleted = true;
182
-
169
+ }
183
170
 
171
+ // (query as any).includeArchived = true;
172
+ // (query as any).includeDeleted = true;
184
173
  query.pageIndex = pageIndex || 0;
185
174
  query.pageSize = pageSize;
186
175
  return query;
187
176
  };
177
+
188
178
  /**
189
179
  * Create a filter expression from a provided filters configuration object
190
180
  * and populate them based on the presence of that key in params, filter
@@ -193,13 +183,10 @@ const finalQuery = ({
193
183
  * @param params request.query object from Express middleware
194
184
  * @returns FilterExpression[] we can use to use with searchQuery function
195
185
  */
196
-
197
186
  const makeFilterExpressions = (f, params) => {
198
187
  const expressions = [];
199
-
200
188
  for (const [paramKey, filterConfig] of Object.entries(f)) {
201
189
  var _params$paramKey;
202
-
203
190
  const filterValues = (_params$paramKey = params[paramKey]) === null || _params$paramKey === void 0 ? void 0 : _params$paramKey.split(',');
204
191
  if (typeof filterValues !== 'undefined') expressions.push({
205
192
  key: typeof filterConfig === 'object' ? filterConfig.fieldId : filterConfig,
@@ -208,7 +195,6 @@ const makeFilterExpressions = (f, params) => {
208
195
  logicOperator: typeof filterConfig === 'object' && filterConfig.logicOperator ? filterConfig.logicOperator : 'or'
209
196
  });
210
197
  }
211
-
212
198
  return expressions;
213
199
  };
214
200
  const makeDerivedIdsFilterExpression = (prevFieldId, entries, ownIds = false, alwaysApplyFilter = false) => {
@@ -241,7 +227,6 @@ const resolveParentEntries = async (parentContentTypeIds, replaceContentTypeIds,
241
227
  };
242
228
 
243
229
  /* eslint-disable no-console */
244
-
245
230
  class QueryLevelResults {
246
231
  constructor({
247
232
  level: _level,
@@ -274,13 +259,11 @@ class QueryLevelResults {
274
259
  this.firstResults = {};
275
260
  this.finalQuery = new Query$1();
276
261
  this.finalResults = {};
277
-
278
262
  this.AddChild = ({
279
263
  child
280
264
  }) => {
281
265
  this.children.push(child);
282
266
  };
283
-
284
267
  this.RunFirstQuery = async () => {
285
268
  const {
286
269
  firstQuery: query,
@@ -288,18 +271,17 @@ class QueryLevelResults {
288
271
  parent,
289
272
  runFirstQuery
290
273
  } = this;
291
-
292
274
  if (parent !== null && parent !== void 0 && parent.validatedLinks.length) {
293
275
  // add any idFilters derived from parent query results
294
276
  appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, {
295
277
  fieldId: `sys.id`
296
278
  }])), Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from parent ${parent.level}`]))));
297
279
  }
298
-
299
280
  if (runFirstQuery) {
300
281
  if (this.debug) console.log(`\nLevel ${this.level} - First query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
301
- this.firstResults = await cachedSearch.searchUsingPost(query, 0, params.projectId); // mapResultsToValidatedLinks
282
+ this.firstResults = await cachedSearch.searchUsingPost(query, 0, params.projectId);
302
283
 
284
+ // mapResultsToValidatedLinks
303
285
  for (const linkFieldId of this.linkFieldIds) {
304
286
  this.validatedLinks.push({
305
287
  contentTypeId: this.linkFields[linkFieldId].contentTypeId || '',
@@ -309,7 +291,6 @@ class QueryLevelResults {
309
291
  }
310
292
  }
311
293
  };
312
-
313
294
  this.RunFinalQuery = async () => {
314
295
  const {
315
296
  level,
@@ -318,31 +299,30 @@ class QueryLevelResults {
318
299
  params,
319
300
  runFinalQuery
320
301
  } = this;
321
-
322
302
  if (!children.some(c => c.returnEntries)) {
323
- const firstChild = children === null || children === void 0 ? void 0 : children[0]; // add any idFilters derived from child query results
324
-
303
+ const firstChild = children === null || children === void 0 ? void 0 : children[0];
304
+ // add any idFilters derived from child query results
325
305
  if (firstChild) appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, {
326
306
  fieldId: `${vl.linkFieldId}.sys.id`
327
307
  }])), Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from child ${firstChild.level}`]))));
328
308
  }
329
-
330
309
  if (level === 0 && this.returnEntries) {
331
310
  // This is the final query to be run and response returned to the caller
332
311
  // Only this bit cares about linkDepth, fields and pagination parameters
333
312
  query.fields = JSON.parse(params.fields || '[]');
334
313
  query.pageSize = params.pageSize;
335
- query.pageIndex = params.pageIndex; // query.orderBy = params.orderBy;
314
+ query.pageIndex = params.pageIndex;
315
+ // query.orderBy = params.orderBy;
336
316
  }
337
317
 
338
318
  if (runFinalQuery) {
339
319
  if (this.debug) console.log(`\nLevel ${this.level} - Final query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
340
320
  this.finalResults = await cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
341
- if (this.parent) this.parent.runFinalQuery = true; // mapResultsToValidatedLinks
321
+ if (this.parent) this.parent.runFinalQuery = true;
342
322
 
323
+ // mapResultsToValidatedLinks
343
324
  for (const linkFieldId of ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.linkFieldIds) || []) {
344
325
  var _this$parent, _this$parent2;
345
-
346
326
  this.validatedLinks.push({
347
327
  contentTypeId: ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.linkFields[linkFieldId].contentTypeId) || '',
348
328
  linkFieldId,
@@ -351,17 +331,14 @@ class QueryLevelResults {
351
331
  }
352
332
  }
353
333
  };
354
-
355
334
  this.GetResultsEntries = () => {
356
335
  var _finalResults$items;
357
-
358
336
  const {
359
337
  finalResults,
360
338
  firstResults
361
339
  } = this;
362
340
  return finalResults !== null && finalResults !== void 0 && (_finalResults$items = finalResults.items) !== null && _finalResults$items !== void 0 && _finalResults$items.length ? finalResults.items : firstResults.items;
363
341
  };
364
-
365
342
  this.GetResults = () => {
366
343
  const {
367
344
  finalResults,
@@ -369,7 +346,6 @@ class QueryLevelResults {
369
346
  } = this;
370
347
  return typeof (finalResults === null || finalResults === void 0 ? void 0 : finalResults.totalCount) !== 'undefined' ? finalResults : firstResults;
371
348
  };
372
-
373
349
  this.level = _level;
374
350
  this.contentTypeIds = contentTypeIds;
375
351
  this.linkFields = linkFields;
@@ -406,11 +382,9 @@ class QueryLevelResults {
406
382
  versionStatus: _params.versionStatus
407
383
  });
408
384
  }
409
-
410
385
  }
411
386
 
412
387
  /* eslint-disable no-console */
413
-
414
388
  class LinkDepthSearchService {
415
389
  constructor({
416
390
  contentTypeId: _contentTypeId = '',
@@ -427,29 +401,27 @@ class LinkDepthSearchService {
427
401
  this.params = void 0;
428
402
  this.debug = void 0;
429
403
  this.queryLevels = void 0;
430
-
431
404
  this.DoSearch = async () => {
432
405
  // Run queries "top-down" through each level of `linkField`
433
406
  for (const queryLevel of this.queryLevels) {
434
407
  await queryLevel.RunFirstQuery();
435
- } // Run queries "bottom-up" through each level of `linkField`
436
-
408
+ }
437
409
 
410
+ // Run queries "bottom-up" through each level of `linkField`
438
411
  for (const queryLevel of [...this.queryLevels].reverse()) {
439
412
  await queryLevel.RunFinalQuery();
440
- } // Run a final query that will aggregate the results from all levels
441
- // adding all levels to the query that have `returnEntries` set true
442
-
413
+ }
443
414
 
415
+ // Run a final query that will aggregate the results from all levels
416
+ // adding all levels to the query that have `returnEntries` set true
444
417
  return await this.RunFinalQueries();
445
418
  };
446
-
447
419
  this.RunFinalQueries = async () => {
448
- const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false); // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
420
+ const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
449
421
 
422
+ // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
450
423
  if (finalQueryLevels.length > 1 || finalQueryLevels.length === 1 && finalQueryLevels[0].level !== 0) {
451
424
  var _params$orderBy;
452
-
453
425
  // Build final query
454
426
  const {
455
427
  contentTypeIds,
@@ -464,9 +436,9 @@ class LinkDepthSearchService {
464
436
  }
465
437
  }, {
466
438
  [vl.linkFieldId]: vl.entryIds.join(',') || 'no results for filter'
467
- })).flat() || []; // This is the final query to be run and response returned to the caller
439
+ })).flat() || [];
440
+ // This is the final query to be run and response returned to the caller
468
441
  // Only this bit cares about linkDepth, fields and pagination parameters
469
-
470
442
  const query = finalQuery({
471
443
  contentTypeIds,
472
444
  filters: makeFilterExpressions(filters, params),
@@ -474,7 +446,6 @@ class LinkDepthSearchService {
474
446
  idFilters: derivedIdFilters,
475
447
  fields: params.fields ? [...JSON.parse(params.fields), ...finalQueryLevels.map(l => {
476
448
  var _l$parent;
477
-
478
449
  return ((_l$parent = l.parent) === null || _l$parent === void 0 ? void 0 : _l$parent.linkFieldIds) || [];
479
450
  }).flat()] : [],
480
451
  orderBy: (_params$orderBy = params.orderBy) === null || _params$orderBy === void 0 ? void 0 : _params$orderBy.split(','),
@@ -484,7 +455,6 @@ class LinkDepthSearchService {
484
455
  versionStatus: params.versionStatus
485
456
  }, (finalQueryLevels === null || finalQueryLevels === void 0 ? void 0 : finalQueryLevels[0].children.filter(ql => ql.returnEntries).map(ql => {
486
457
  var _ql$parent, _ql$parent2;
487
-
488
458
  const entriesAtLevel = ql.GetResultsEntries() || ((_ql$parent = ql.parent) === null || _ql$parent === void 0 ? void 0 : _ql$parent.GetResultsEntries());
489
459
  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() : [];
490
460
  return {
@@ -495,29 +465,28 @@ class LinkDepthSearchService {
495
465
  };
496
466
  })) || []);
497
467
  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)}`);
498
- const finalQueryResult = await cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId); // Resolve any parent entries
468
+ const finalQueryResult = await cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
469
+
470
+ // Resolve any parent entries
499
471
 
500
472
  const resolveParentLevels = finalQueryLevels.filter(ql => ql.resolveFirstParent);
501
473
  let entries = finalQueryResult.items;
502
-
503
474
  for (const resolveParents of resolveParentLevels) {
504
475
  var _resolveParents$paren, _resolveParents$paren2;
505
-
506
- 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, // or entries?
476
+ 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,
477
+ // or entries?
507
478
  this.params, this.debug);
508
479
  }
509
-
510
- return { ...finalQueryResult,
480
+ return {
481
+ ...finalQueryResult,
511
482
  items: entries
512
483
  };
513
484
  } else {
514
485
  var _this$queryLevels$fin;
515
-
516
486
  if (this.debug) console.log(`\nNo further queries required\n`);
517
487
  return (_this$queryLevels$fin = this.queryLevels.find(ql => ql.level === 0)) === null || _this$queryLevels$fin === void 0 ? void 0 : _this$queryLevels$fin.GetResults();
518
488
  }
519
489
  };
520
-
521
490
  this.InitQueryLevels = () => {
522
491
  const createChildQueryLevels = (linkFields, parentQueryLevel, level = 1) => {
523
492
  return Object.entries(linkFields).map(([, {
@@ -550,7 +519,6 @@ class LinkDepthSearchService {
550
519
  return [thisLevel, ...createChildQueryLevels(linkFields, thisLevel, level + 1)];
551
520
  }).flat();
552
521
  };
553
-
554
522
  const {
555
523
  contentTypeIds,
556
524
  filters,
@@ -571,17 +539,17 @@ class LinkDepthSearchService {
571
539
  params,
572
540
  debug: this.debug
573
541
  });
574
- const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)]; // return queryLevels;
542
+ const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
543
+ // return queryLevels;
544
+
575
545
  // If we are only returning entries from level 0
576
546
  // we can skip running the first query and finalQuery will suffice
577
-
578
547
  if (queryLevels.find(ql => ql.returnEntries && ql.level !== 0)) return queryLevels;else return queryLevels.map(ql => {
579
- ql.runFirstQuery = false; // ql.runFinalQuery = false;
580
-
548
+ ql.runFirstQuery = false;
549
+ // ql.runFinalQuery = false;
581
550
  return ql;
582
551
  });
583
552
  };
584
-
585
553
  this.contentTypeIds = Array.isArray(_contentTypeId) ? _contentTypeId : [_contentTypeId];
586
554
  this.filters = _filters;
587
555
  this.sharedFilters = _sharedFilters;
@@ -590,7 +558,6 @@ class LinkDepthSearchService {
590
558
  this.debug = debug;
591
559
  this.queryLevels = this.InitQueryLevels();
592
560
  }
593
-
594
561
  }
595
562
 
596
563
  /**
@@ -610,10 +577,9 @@ const makeLinkDepthApi = (app, middlewareConfig) => {
610
577
  if (!contentTypeId || !linkFields || !uri) return;
611
578
  app.get(uri, makeLinkDepthMiddleware(middlewareConfig));
612
579
  };
580
+
613
581
  /** Create a content type hierarchy from supplied config and produces
614
582
  * a RequestHandler function to serve our Express middleware */
615
-
616
-
617
583
  const makeLinkDepthMiddleware = ({
618
584
  contentTypeId,
619
585
  filters = {},
@@ -629,8 +595,9 @@ const makeLinkDepthMiddleware = ({
629
595
  setCachingHeaders(res, {
630
596
  cacheControl: 'private',
631
597
  surrogateControl: '10'
632
- }); // Gather all params from the request, we will use them at the right query levels later
598
+ });
633
599
 
600
+ // Gather all params from the request, we will use them at the right query levels later
634
601
  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()]));
635
602
  const result = await new LinkDepthSearchService({
636
603
  contentTypeId,
@@ -648,35 +615,25 @@ const makeLinkDepthMiddleware = ({
648
615
  res.json(error);
649
616
  }
650
617
  };
651
-
652
618
  return linkDepthMiddleware;
653
619
  } catch (error) {
654
620
  // This will be an error building the middleware
655
621
  // we can only serve what the error was as the request handler instead
656
622
  console.error(error);
657
-
658
623
  const errorMiddleware = async (req, res) => {
659
624
  res.statusCode = 500;
660
625
  res.json(JSON.stringify(error));
661
626
  };
662
-
663
627
  return errorMiddleware;
664
628
  }
665
629
  };
666
630
 
667
- const servers$1 = SERVERS;
668
- /* global SERVERS */
669
-
670
- const project = PROJECT;
671
- /* global PROJECT */
672
-
673
- const alias = ALIAS;
674
- /* global ALIAS */
675
-
631
+ const servers$1 = SERVERS; /* global SERVERS */
632
+ const project = PROJECT; /* global PROJECT */
633
+ const alias = ALIAS; /* global ALIAS */
676
634
  const deliveryApiHostname = url(alias, project).api;
677
635
  const assetProxy = httpProxy.createProxyServer();
678
636
  const deliveryProxy = httpProxy.createProxyServer();
679
-
680
637
  const reverseProxies = (app, reverseProxyPaths = []) => {
681
638
  deliveryApiProxy(deliveryProxy, app);
682
639
  app.all(reverseProxyPaths, (req, res) => {
@@ -716,8 +673,8 @@ const CacheDuration = {
716
673
  static: '31536000',
717
674
  // Believe it or not these two max ages are the same in runtime
718
675
  expressStatic: '31557600h' // Believe it or not these two max ages are the same in runtime
719
-
720
676
  };
677
+
721
678
  const getCacheDuration = (status = 200) => {
722
679
  if (status > 400) return CacheDuration[404];
723
680
  return CacheDuration[200];
@@ -734,10 +691,8 @@ const bundleManipulationMiddleware = ({
734
691
  const filename = path.basename(req.path);
735
692
  const modernBundle = filename.endsWith('.mjs');
736
693
  const legacyBundle = filename.endsWith('.js');
737
-
738
694
  if ((legacyBundle || modernBundle) && filename.startsWith('runtime.')) {
739
695
  const jsRuntimeLocation = path.resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
740
-
741
696
  try {
742
697
  const jsRuntimeBundle = fs.readFileSync(jsRuntimeLocation, 'utf8');
743
698
  const modifiedBundle = replaceStaticPath(jsRuntimeBundle, staticRoutePath);
@@ -760,7 +715,6 @@ const bundleManipulationMiddleware = ({
760
715
  * @returns Response | next()
761
716
  * A middleware function to resolve /dist/static/startup.js under a supplied startupScriptFilename variable
762
717
  */
763
-
764
718
  const resolveStartupMiddleware = ({
765
719
  appRootPath,
766
720
  maxage,
@@ -769,7 +723,6 @@ const resolveStartupMiddleware = ({
769
723
  }) => async (req, res, next) => {
770
724
  if (startupScriptFilename !== 'startup.js' && req.path === `/${startupScriptFilename}`) {
771
725
  let startupFileLocation = '';
772
-
773
726
  try {
774
727
  const startupFilePaths = [`dist/static/startup.js`, `dist/${staticFolderPath}/startup.js`];
775
728
  let startupFilePath = '';
@@ -777,7 +730,8 @@ const resolveStartupMiddleware = ({
777
730
  try {
778
731
  fs.accessSync(testPath);
779
732
  startupFilePath = testPath;
780
- } catch (ex) {// Do nothing
733
+ } catch (ex) {
734
+ // Do nothing
781
735
  }
782
736
  });
783
737
  startupFileLocation = path.resolve(appRootPath, startupFilePath);
@@ -814,7 +768,8 @@ const staticAssets = (app, {
814
768
  maxage: CacheDuration.static,
815
769
  startupScriptFilename: scripts.startup || startupScriptFilename,
816
770
  staticFolderPath
817
- }), // eslint-disable-next-line import/no-named-as-default-member
771
+ }),
772
+ // eslint-disable-next-line import/no-named-as-default-member
818
773
  express.static(`dist/${staticFolderPath}`, {
819
774
  // these maxage values are different in config but the same in runtime,
820
775
  // this one is somehow converted and should end up being the same as CacheDuration.static
@@ -822,11 +777,8 @@ const staticAssets = (app, {
822
777
  }));
823
778
  };
824
779
 
825
- const servers = SERVERS;
826
- /* global SERVERS */
827
-
828
- const projects = PROJECTS;
829
- /* global PROJECTS */
780
+ const servers = SERVERS; /* global SERVERS */
781
+ const projects = PROJECTS; /* global PROJECTS */
830
782
 
831
783
  const DisplayStartupConfiguration = config => {
832
784
  /* eslint-disable no-console */
@@ -3971,20 +3923,17 @@ const handleResponse = (request, response, content, send = 'send') => {
3971
3923
  };
3972
3924
 
3973
3925
  const readFileSync = path => fs.readFileSync(path, 'utf8');
3974
-
3975
3926
  const loadableBundleData = ({
3976
3927
  stats,
3977
3928
  templates
3978
3929
  }, staticRoutePath, build) => {
3979
3930
  const bundle = {};
3980
-
3981
3931
  try {
3982
3932
  bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
3983
3933
  } catch (ex) {
3984
3934
  // console.info(ex);
3985
3935
  bundle.stats = null;
3986
3936
  }
3987
-
3988
3937
  try {
3989
3938
  bundle.templates = {
3990
3939
  templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
@@ -3995,18 +3944,15 @@ const loadableBundleData = ({
3995
3944
  // console.info(ex);
3996
3945
  bundle.templates = null;
3997
3946
  }
3998
-
3999
3947
  return bundle;
4000
3948
  };
4001
3949
  const loadableChunkExtractors = () => {
4002
3950
  const commonLoadableExtractor = new ChunkExtractor({
4003
3951
  stats: {}
4004
3952
  });
4005
-
4006
3953
  try {
4007
3954
  let modern;
4008
3955
  let legacy;
4009
-
4010
3956
  try {
4011
3957
  modern = new ChunkExtractor({
4012
3958
  entrypoints: ['app'],
@@ -4016,7 +3962,6 @@ const loadableChunkExtractors = () => {
4016
3962
  } catch (e) {
4017
3963
  console.info('@loadable/server modern ChunkExtractor not available');
4018
3964
  }
4019
-
4020
3965
  try {
4021
3966
  legacy = new ChunkExtractor({
4022
3967
  entrypoints: ['app'],
@@ -4026,14 +3971,11 @@ const loadableChunkExtractors = () => {
4026
3971
  } catch (e) {
4027
3972
  console.info('@loadable/server legacy ChunkExtractor not available');
4028
3973
  }
4029
-
4030
3974
  commonLoadableExtractor.addChunk = chunk => {
4031
3975
  var _modern, _legacy, _legacy2;
4032
-
4033
3976
  (_modern = modern) === null || _modern === void 0 ? void 0 : _modern.addChunk(chunk);
4034
3977
  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);
4035
3978
  };
4036
-
4037
3979
  return {
4038
3980
  commonLoadableExtractor,
4039
3981
  modern,
@@ -4054,7 +3996,9 @@ const getBundleData = (config, staticRoutePath) => {
4054
3996
  };
4055
3997
  if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
4056
3998
  return bundleData;
4057
- }; // export const buildBundleTags = (
3999
+ };
4000
+
4001
+ // export const buildBundleTags = (
4058
4002
  // bundles,
4059
4003
  // differentialBundles = false,
4060
4004
  // staticRoutePath = 'static',
@@ -4079,17 +4023,18 @@ const getBundleData = (config, staticRoutePath) => {
4079
4023
  // )}"></script>`;
4080
4024
  // })
4081
4025
  // .filter(f => f);
4026
+
4082
4027
  // return bundleTags;
4083
4028
  // };
4084
4029
 
4085
4030
  const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
4086
- let startupTag = ''; // Add the static startup script to the bundleTags
4087
-
4088
- if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`; // Get the script tags from their respective extractor instances
4031
+ let startupTag = '';
4032
+ // Add the static startup script to the bundleTags
4033
+ if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
4089
4034
 
4035
+ // Get the script tags from their respective extractor instances
4090
4036
  if (loadableExtractor) {
4091
4037
  var _loadableExtractor$le, _loadableExtractor$mo;
4092
-
4093
4038
  const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
4094
4039
  nomodule: 'nomodule'
4095
4040
  });
@@ -4099,7 +4044,6 @@ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') =
4099
4044
  const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
4100
4045
  return scriptTags;
4101
4046
  }
4102
-
4103
4047
  return startupTag;
4104
4048
  };
4105
4049
 
@@ -4125,14 +4069,12 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
4125
4069
  const {
4126
4070
  globalGroups,
4127
4071
  allowedGroups
4128
- } = groups; // console.info(globalGroups, allowedGroups);
4129
-
4072
+ } = groups;
4073
+ // console.info(globalGroups, allowedGroups);
4130
4074
  let allGroups = Array.from(globalGroups && globalGroups[project] || {});
4131
-
4132
4075
  if (stateEntry && getImmutableOrJS(stateEntry, ['authentication', 'isLoginRequired']) && allowedGroups && allowedGroups[project]) {
4133
4076
  allGroups = [...allGroups, ...allowedGroups[project]];
4134
4077
  }
4135
-
4136
4078
  response.header('x-contensis-viewer-groups', allGroups.join('|'));
4137
4079
  } catch (e) {
4138
4080
  console.info('Error adding authentication header', e);
@@ -4156,14 +4098,13 @@ const unhandledExceptionHandler = (handleExceptions = true) => {
4156
4098
  const exceptionTypes = handleExceptions === true ? ['uncaughtException', 'unhandledRejection', 'SIGTERM', 'SIGINT'] // Default exception types to add event listeners for
4157
4099
  : Array.isArray(handleExceptions) // In future we could accept an array of specific exception types to handle for a specific application?
4158
4100
  ? handleExceptions : [];
4159
-
4160
4101
  for (const type of exceptionTypes) {
4161
4102
  process.on(type, err => {
4162
4103
  if (err && err instanceof Error) {
4163
4104
  // Print a message to inform admins and developers the error should not be ignored
4164
4105
  console.log(`${`[contensis-react-base] ❌ ${chalk.red.bold(`${type} - ${err.message}`)}`}`);
4165
- console.log(chalk.gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`); // Log the error to server console
4166
-
4106
+ console.log(chalk.gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`);
4107
+ // Log the error to server console
4167
4108
  console.error(err);
4168
4109
  }
4169
4110
  });
@@ -4200,19 +4141,16 @@ const webApp = (app, ReactApp, config) => {
4200
4141
  url
4201
4142
  } = request;
4202
4143
  const cookies = new Cookies$1(request.headers.cookie);
4203
-
4204
4144
  const matchedStaticRoute = () => matchRoutes(routes.StaticRoutes, request.path);
4205
-
4206
4145
  const isStaticRoute = () => matchedStaticRoute().length > 0;
4146
+ const staticRoute = isStaticRoute() && matchedStaticRoute()[0];
4207
4147
 
4208
- const staticRoute = isStaticRoute() && matchedStaticRoute()[0]; // Allow certain routes to avoid SSR
4209
-
4148
+ // Allow certain routes to avoid SSR
4210
4149
  const onlyDynamic = staticRoute && staticRoute.route.ssr === false;
4211
4150
  const onlySSR = staticRoute && staticRoute.route.ssrOnly === true;
4151
+ const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false;
4212
4152
 
4213
- const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false; // Determine functional params from QueryString and set access methods
4214
-
4215
-
4153
+ // Determine functional params from QueryString and set access methods
4216
4154
  const accessMethod = mapJson(request.query, {
4217
4155
  DYNAMIC: ({
4218
4156
  dynamic
@@ -4227,14 +4165,16 @@ const webApp = (app, ReactApp, config) => {
4227
4165
  static: value
4228
4166
  }) => normaliseQs(value) || onlySSR
4229
4167
  });
4230
- const context = {}; // Track the current statusCode via the response object
4231
-
4232
- response.status(200); // Create a store (with a memory history) from our current url
4168
+ const context = {};
4169
+ // Track the current statusCode via the response object
4170
+ response.status(200);
4233
4171
 
4172
+ // Create a store (with a memory history) from our current url
4234
4173
  const store = await createStore(withReducers, {}, history({
4235
4174
  initialEntries: [url]
4236
- }), stateType); // dispatch any global and non-saga related actions before calling our JSX
4175
+ }), stateType);
4237
4176
 
4177
+ // dispatch any global and non-saga related actions before calling our JSX
4238
4178
  const versionStatus = deliveryApi.getServerSideVersionStatus(request);
4239
4179
  console.info(`Request for ${request.path} hostname: ${request.hostname} versionStatus: ${versionStatus}`);
4240
4180
  store.dispatch(setVersionStatus(versionStatus));
@@ -4260,23 +4200,25 @@ const webApp = (app, ReactApp, config) => {
4260
4200
  templateHTML = '',
4261
4201
  templateHTMLFragment = '',
4262
4202
  templateHTMLStatic = ''
4263
- } = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
4203
+ } = bundleData.default.templates || bundleData.legacy.templates || {};
4264
4204
 
4205
+ // Serve a blank HTML page with client scripts to load the app in the browser
4265
4206
  if (accessMethod.DYNAMIC) {
4266
4207
  // Dynamic doesn't need sagas
4267
- renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
4268
- // and does not include any react-loadable code-split bundles
4208
+ renderToString(jsx);
4269
4209
 
4210
+ // Dynamic page render has only the necessary bundles to start up the app
4211
+ // and does not include any react-loadable code-split bundles
4270
4212
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4271
4213
  const isDynamicHints = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.isDynamic = true;</script>`;
4272
- const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints); // Dynamic pages always return a 200 so we can run
4214
+ const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints);
4215
+ // Dynamic pages always return a 200 so we can run
4273
4216
  // the app and serve up all errors inside the client
4274
-
4275
4217
  response.setHeader('Surrogate-Control', `max-age=${getCacheDuration(200)}`);
4276
4218
  responseHandler(request, response, responseHtmlDynamic);
4277
- } // Render the JSX server side and send response as per access method options
4278
-
4219
+ }
4279
4220
 
4221
+ // Render the JSX server side and send response as per access method options
4280
4222
  if (!accessMethod.DYNAMIC) {
4281
4223
  store.runSaga(rootSaga(withSagas)).toPromise().then(() => {
4282
4224
  const sheet = new ServerStyleSheet();
@@ -4286,15 +4228,14 @@ const webApp = (app, ReactApp, config) => {
4286
4228
  const htmlAttributes = helmet.htmlAttributes.toString();
4287
4229
  let title = helmet.title.toString();
4288
4230
  const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
4289
-
4290
4231
  if (context.url) {
4291
4232
  return response.redirect(context.statusCode || 302, context.url);
4292
4233
  }
4293
-
4294
4234
  const reduxState = store.getState();
4295
- const styleTags = sheet.getStyleTags(); // After running rootSaga there should be an additional react-loadable
4296
- // code-split bundles for any page components as well as core app bundles
4235
+ const styleTags = sheet.getStyleTags();
4297
4236
 
4237
+ // After running rootSaga there should be an additional react-loadable
4238
+ // code-split bundles for any page components as well as core app bundles
4298
4239
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4299
4240
  let serialisedReduxData = serialize$1(buildCleaner({
4300
4241
  isArray: identity,
@@ -4306,7 +4247,6 @@ const webApp = (app, ReactApp, config) => {
4306
4247
  isString: identity,
4307
4248
  isUndefined: noop
4308
4249
  })(cloneDeep_1(reduxState)));
4309
-
4310
4250
  if (context.statusCode !== 404) {
4311
4251
  // For a request that returns a redux state object as a response
4312
4252
  if (accessMethod.REDUX) {
@@ -4317,7 +4257,6 @@ const webApp = (app, ReactApp, config) => {
4317
4257
  responseHandler(request, response, serialisedReduxData, 'json');
4318
4258
  return true;
4319
4259
  }
4320
-
4321
4260
  if (!disableSsrRedux) {
4322
4261
  // window.versionStatus is not strictly required here and is added to support cases
4323
4262
  // where a consumer may not be using the contensisVersionStatus in redux and calling
@@ -4325,41 +4264,40 @@ const webApp = (app, ReactApp, config) => {
4325
4264
  serialisedReduxData = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
4326
4265
  }
4327
4266
  }
4328
-
4329
4267
  if ((context.statusCode || 200) > 400) {
4330
4268
  accessMethod.STATIC = true;
4331
- } // Responses
4332
-
4269
+ }
4333
4270
 
4271
+ // Responses
4334
4272
  let responseHTML = '';
4335
- if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
4273
+ if (context.statusCode === 404) title = '<title>404 page not found</title>';
4336
4274
 
4275
+ // Static page served as a fragment
4337
4276
  if (accessMethod.FRAGMENT && accessMethod.STATIC) {
4338
4277
  responseHTML = minifyCssString(styleTags) + html;
4339
- } // Page fragment served with client scripts and redux data that hydrate the app client side
4340
-
4278
+ }
4341
4279
 
4280
+ // Page fragment served with client scripts and redux data that hydrate the app client side
4342
4281
  if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
4343
4282
  responseHTML = templateHTMLFragment.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString(styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', serialisedReduxData);
4344
- } // Full HTML page served statically
4345
-
4283
+ }
4346
4284
 
4285
+ // Full HTML page served statically
4347
4286
  if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
4348
4287
  responseHTML = templateHTMLStatic.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString(styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', '');
4349
- } // Full HTML page served with client scripts and redux data that hydrate the app client side
4350
-
4288
+ }
4351
4289
 
4290
+ // Full HTML page served with client scripts and redux data that hydrate the app client side
4352
4291
  if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
4353
4292
  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);
4354
- } // Set response.status from React StaticRouter
4355
-
4293
+ }
4356
4294
 
4295
+ // Set response.status from React StaticRouter
4357
4296
  if (typeof context.statusCode === 'number') response.status(context.statusCode);
4358
4297
  addStandardHeaders(reduxState, response, packagejson, {
4359
4298
  allowedGroups,
4360
4299
  globalGroups
4361
4300
  });
4362
-
4363
4301
  try {
4364
4302
  // If react-helmet htmlAttributes are being used,
4365
4303
  // replace the html tag with those attributes sepcified
@@ -4367,7 +4305,6 @@ const webApp = (app, ReactApp, config) => {
4367
4305
  if (htmlAttributes) {
4368
4306
  responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
4369
4307
  }
4370
-
4371
4308
  responseHandler(request, response, responseHTML);
4372
4309
  } catch (err) {
4373
4310
  console.info(err.message);
@@ -4387,18 +4324,18 @@ const webApp = (app, ReactApp, config) => {
4387
4324
 
4388
4325
  const app = express();
4389
4326
  const server = http.createServer(app);
4390
-
4391
4327
  const start = (ReactApp, config, ServerFeatures) => {
4392
4328
  global.PACKAGE_JSON = config.packagejson;
4393
4329
  global.DISABLE_SSR_REDUX = config.disableSsrRedux;
4394
4330
  global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
4395
4331
  global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
4396
- app.disable('x-powered-by'); // Output some information about the used build/startup configuration
4332
+ app.disable('x-powered-by');
4397
4333
 
4334
+ // Output some information about the used build/startup configuration
4398
4335
  DisplayStartupConfiguration(config);
4399
- ServerFeatures(app); // Set-up local proxy for images from cms, and delivery api requests
4336
+ ServerFeatures(app);
4337
+ // Set-up local proxy for images from cms, and delivery api requests
4400
4338
  // to save doing rewrites and extra code
4401
-
4402
4339
  reverseProxies(app, config.reverseProxyPaths);
4403
4340
  staticAssets(app, config);
4404
4341
  webApp(app, ReactApp, config);
@@ -4416,7 +4353,6 @@ const start = (ReactApp, config, ServerFeatures) => {
4416
4353
  });
4417
4354
  });
4418
4355
  };
4419
-
4420
4356
  var internalServer = {
4421
4357
  app,
4422
4358
  apiProxy: deliveryProxy,