@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
@@ -2,15 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var App = require('./App-ee485b92.js');
5
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-c079b03a.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');
@@ -33,25 +33,25 @@ var server$1 = require('@loadable/server');
33
33
  var lodash = require('lodash');
34
34
  var lodashClean = require('lodash-clean');
35
35
  var reactCookie = require('react-cookie');
36
- var version = require('./version-78dfc3bd.js');
37
- var actions = require('./actions-8dc9e8de.js');
38
- var selectors = require('./selectors-656da4b7.js');
36
+ var version = require('./version-4077e706.js');
37
+ var App = require('./App-21a7d836.js');
38
+ var version$1 = require('./version-fe28099e.js');
39
+ var selectors = require('./selectors-bcca60f4.js');
39
40
  var chalk = require('chalk');
40
- require('history');
41
- require('@redux-saga/core/effects');
42
41
  require('loglevel');
43
- require('./version-eba6d09b.js');
44
- require('./login-840860bc.js');
45
- require('./reducers-3a4f8971.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');
42
+ require('@redux-saga/core/effects');
51
43
  require('redux');
52
44
  require('redux-thunk');
53
45
  require('redux-saga');
54
46
  require('redux-injectors');
47
+ require('./reducers-9afb5f89.js');
48
+ require('history');
49
+ require('./login-2a6b5be0.js');
50
+ require('./ToJs-6e9cfa69.js');
51
+ require('await-to-js');
52
+ require('js-cookie');
53
+ require('react-hot-loader');
54
+ require('./RouteLoader-7f0d107a.js');
55
55
 
56
56
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
57
57
 
@@ -74,26 +74,20 @@ class Util {
74
74
  if (fieldId) {
75
75
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
76
76
  var _e$fieldId, _e$fieldId2, _e$fieldId2$sys;
77
-
78
77
  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
78
  var _f$sys;
80
-
81
79
  return f === null || f === void 0 ? void 0 : (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
82
80
  }) : (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
81
  }).flat();
84
82
  }
85
-
86
83
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
87
84
  var _e$sys;
88
-
89
85
  return (e === null || e === void 0 ? void 0 : (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
90
86
  });
91
87
  }
92
-
93
88
  static GetItems(result) {
94
89
  return this.GetResults(result) ? result.items : [];
95
90
  }
96
-
97
91
  static GetResults(result) {
98
92
  if (result !== null && result !== void 0 && result.items) {
99
93
  return result;
@@ -101,20 +95,18 @@ class Util {
101
95
  return null;
102
96
  }
103
97
  }
104
-
105
98
  }
106
99
  const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId) => results.map(r => {
107
100
  if (replaceContentTypeIds.some(c => c === r.sys.contentTypeId)) {
108
101
  const resolvedParent = parentResults === null || parentResults === void 0 ? void 0 : parentResults.find(e => {
109
102
  var _e$linkFieldId;
110
-
111
103
  return (_e$linkFieldId = e[linkFieldId]) === null || _e$linkFieldId === void 0 ? void 0 : _e$linkFieldId.some(l => {
112
104
  var _l$sys;
113
-
114
105
  return ((_l$sys = l.sys) === null || _l$sys === void 0 ? void 0 : _l$sys.id) === r.sys.id;
115
106
  });
116
107
  });
117
- if (resolvedParent) return { ...resolvedParent,
108
+ if (resolvedParent) return {
109
+ ...resolvedParent,
118
110
  ...r,
119
111
  entryTitle: resolvedParent.entryTitle,
120
112
  entryDescription: resolvedParent.entryDescription,
@@ -122,12 +114,10 @@ const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId
122
114
  originalSys: r.sys
123
115
  };else return r;
124
116
  }
125
-
126
117
  return r;
127
118
  }).filter(r => r);
128
119
 
129
120
  /* eslint-disable no-console */
130
-
131
121
  /**
132
122
  * Builds our complete Delivery API Query object from a set of provided arguments
133
123
  * @param queryParams
@@ -152,13 +142,12 @@ const searchQuery = ({
152
142
  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
143
  const query = new contensisCoreApi.Query(...expressions$1);
154
144
  query.orderBy = sagas.orderByExpression(orderBy || []);
155
-
156
145
  if (fields && fields.length > 0) {
157
146
  query.fields = fields;
158
- } // (query as any).includeArchived = true;
159
- // (query as any).includeDeleted = true;
160
-
147
+ }
161
148
 
149
+ // (query as any).includeArchived = true;
150
+ // (query as any).includeDeleted = true;
162
151
  query.pageIndex = pageIndex;
163
152
  query.pageSize = pageSize;
164
153
  return query;
@@ -181,7 +170,8 @@ const finalQuery = ({
181
170
  webpageTemplates,
182
171
  weightedSearchFields
183
172
  }, 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 || []) // Op.and(
173
+ 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 || [])
174
+ // Op.and(
185
175
  // ...sharedFilters.map(sf =>
186
176
  // Op.not(exp.fieldExpression(sf.key, true, 'exists')[0])
187
177
  // ),
@@ -190,17 +180,17 @@ const finalQuery = ({
190
180
  )] : [])), ...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
181
  const query = new contensisCoreApi.Query(...expressions$1);
192
182
  query.orderBy = sagas.orderByExpression(orderBy || []);
193
-
194
183
  if (fields && fields.length > 0) {
195
184
  query.fields = fields;
196
- } // (query as any).includeArchived = true;
197
- // (query as any).includeDeleted = true;
198
-
185
+ }
199
186
 
187
+ // (query as any).includeArchived = true;
188
+ // (query as any).includeDeleted = true;
200
189
  query.pageIndex = pageIndex || 0;
201
190
  query.pageSize = pageSize;
202
191
  return query;
203
192
  };
193
+
204
194
  /**
205
195
  * Create a filter expression from a provided filters configuration object
206
196
  * and populate them based on the presence of that key in params, filter
@@ -209,13 +199,10 @@ const finalQuery = ({
209
199
  * @param params request.query object from Express middleware
210
200
  * @returns FilterExpression[] we can use to use with searchQuery function
211
201
  */
212
-
213
202
  const makeFilterExpressions = (f, params) => {
214
203
  const expressions = [];
215
-
216
204
  for (const [paramKey, filterConfig] of Object.entries(f)) {
217
205
  var _params$paramKey;
218
-
219
206
  const filterValues = (_params$paramKey = params[paramKey]) === null || _params$paramKey === void 0 ? void 0 : _params$paramKey.split(',');
220
207
  if (typeof filterValues !== 'undefined') expressions.push({
221
208
  key: typeof filterConfig === 'object' ? filterConfig.fieldId : filterConfig,
@@ -224,7 +211,6 @@ const makeFilterExpressions = (f, params) => {
224
211
  logicOperator: typeof filterConfig === 'object' && filterConfig.logicOperator ? filterConfig.logicOperator : 'or'
225
212
  });
226
213
  }
227
-
228
214
  return expressions;
229
215
  };
230
216
  const makeDerivedIdsFilterExpression = (prevFieldId, entries, ownIds = false, alwaysApplyFilter = false) => {
@@ -252,12 +238,11 @@ const resolveParentEntries = async (parentContentTypeIds, replaceContentTypeIds,
252
238
  });
253
239
  query.fields = params.fields ? [...JSON.parse(params.fields), parentFieldId] : [];
254
240
  if (debug) console.log(`\nResolve parent entries query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
255
- const parentResults = await App.cachedSearch.searchUsingPost(query, Number(params.linkDepth || 0), params.projectId);
241
+ const parentResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth || 0), params.projectId);
256
242
  return mergeResults(results, Util.GetItems(parentResults), replaceContentTypeIds, parentFieldId);
257
243
  };
258
244
 
259
245
  /* eslint-disable no-console */
260
-
261
246
  class QueryLevelResults {
262
247
  constructor({
263
248
  level: _level,
@@ -290,13 +275,11 @@ class QueryLevelResults {
290
275
  this.firstResults = {};
291
276
  this.finalQuery = new contensisDeliveryApi.Query();
292
277
  this.finalResults = {};
293
-
294
278
  this.AddChild = ({
295
279
  child
296
280
  }) => {
297
281
  this.children.push(child);
298
282
  };
299
-
300
283
  this.RunFirstQuery = async () => {
301
284
  const {
302
285
  firstQuery: query,
@@ -304,18 +287,17 @@ class QueryLevelResults {
304
287
  parent,
305
288
  runFirstQuery
306
289
  } = this;
307
-
308
290
  if (parent !== null && parent !== void 0 && parent.validatedLinks.length) {
309
291
  // add any idFilters derived from parent query results
310
292
  appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, {
311
293
  fieldId: `sys.id`
312
294
  }])), Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from parent ${parent.level}`]))));
313
295
  }
314
-
315
296
  if (runFirstQuery) {
316
297
  if (this.debug) console.log(`\nLevel ${this.level} - First query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
317
- this.firstResults = await App.cachedSearch.searchUsingPost(query, 0, params.projectId); // mapResultsToValidatedLinks
298
+ this.firstResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, 0, params.projectId);
318
299
 
300
+ // mapResultsToValidatedLinks
319
301
  for (const linkFieldId of this.linkFieldIds) {
320
302
  this.validatedLinks.push({
321
303
  contentTypeId: this.linkFields[linkFieldId].contentTypeId || '',
@@ -325,7 +307,6 @@ class QueryLevelResults {
325
307
  }
326
308
  }
327
309
  };
328
-
329
310
  this.RunFinalQuery = async () => {
330
311
  const {
331
312
  level,
@@ -334,31 +315,30 @@ class QueryLevelResults {
334
315
  params,
335
316
  runFinalQuery
336
317
  } = this;
337
-
338
318
  if (!children.some(c => c.returnEntries)) {
339
- const firstChild = children === null || children === void 0 ? void 0 : children[0]; // add any idFilters derived from child query results
340
-
319
+ const firstChild = children === null || children === void 0 ? void 0 : children[0];
320
+ // add any idFilters derived from child query results
341
321
  if (firstChild) appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, {
342
322
  fieldId: `${vl.linkFieldId}.sys.id`
343
323
  }])), Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from child ${firstChild.level}`]))));
344
324
  }
345
-
346
325
  if (level === 0 && this.returnEntries) {
347
326
  // This is the final query to be run and response returned to the caller
348
327
  // Only this bit cares about linkDepth, fields and pagination parameters
349
328
  query.fields = JSON.parse(params.fields || '[]');
350
329
  query.pageSize = params.pageSize;
351
- query.pageIndex = params.pageIndex; // query.orderBy = params.orderBy;
330
+ query.pageIndex = params.pageIndex;
331
+ // query.orderBy = params.orderBy;
352
332
  }
353
333
 
354
334
  if (runFinalQuery) {
355
335
  if (this.debug) console.log(`\nLevel ${this.level} - Final query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
356
- this.finalResults = await App.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
357
- if (this.parent) this.parent.runFinalQuery = true; // mapResultsToValidatedLinks
336
+ this.finalResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
337
+ if (this.parent) this.parent.runFinalQuery = true;
358
338
 
339
+ // mapResultsToValidatedLinks
359
340
  for (const linkFieldId of ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.linkFieldIds) || []) {
360
341
  var _this$parent, _this$parent2;
361
-
362
342
  this.validatedLinks.push({
363
343
  contentTypeId: ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.linkFields[linkFieldId].contentTypeId) || '',
364
344
  linkFieldId,
@@ -367,17 +347,14 @@ class QueryLevelResults {
367
347
  }
368
348
  }
369
349
  };
370
-
371
350
  this.GetResultsEntries = () => {
372
351
  var _finalResults$items;
373
-
374
352
  const {
375
353
  finalResults,
376
354
  firstResults
377
355
  } = this;
378
356
  return finalResults !== null && finalResults !== void 0 && (_finalResults$items = finalResults.items) !== null && _finalResults$items !== void 0 && _finalResults$items.length ? finalResults.items : firstResults.items;
379
357
  };
380
-
381
358
  this.GetResults = () => {
382
359
  const {
383
360
  finalResults,
@@ -385,7 +362,6 @@ class QueryLevelResults {
385
362
  } = this;
386
363
  return typeof (finalResults === null || finalResults === void 0 ? void 0 : finalResults.totalCount) !== 'undefined' ? finalResults : firstResults;
387
364
  };
388
-
389
365
  this.level = _level;
390
366
  this.contentTypeIds = contentTypeIds;
391
367
  this.linkFields = linkFields;
@@ -422,11 +398,9 @@ class QueryLevelResults {
422
398
  versionStatus: _params.versionStatus
423
399
  });
424
400
  }
425
-
426
401
  }
427
402
 
428
403
  /* eslint-disable no-console */
429
-
430
404
  class LinkDepthSearchService {
431
405
  constructor({
432
406
  contentTypeId: _contentTypeId = '',
@@ -443,29 +417,27 @@ class LinkDepthSearchService {
443
417
  this.params = void 0;
444
418
  this.debug = void 0;
445
419
  this.queryLevels = void 0;
446
-
447
420
  this.DoSearch = async () => {
448
421
  // Run queries "top-down" through each level of `linkField`
449
422
  for (const queryLevel of this.queryLevels) {
450
423
  await queryLevel.RunFirstQuery();
451
- } // Run queries "bottom-up" through each level of `linkField`
452
-
424
+ }
453
425
 
426
+ // Run queries "bottom-up" through each level of `linkField`
454
427
  for (const queryLevel of [...this.queryLevels].reverse()) {
455
428
  await queryLevel.RunFinalQuery();
456
- } // Run a final query that will aggregate the results from all levels
457
- // adding all levels to the query that have `returnEntries` set true
458
-
429
+ }
459
430
 
431
+ // Run a final query that will aggregate the results from all levels
432
+ // adding all levels to the query that have `returnEntries` set true
460
433
  return await this.RunFinalQueries();
461
434
  };
462
-
463
435
  this.RunFinalQueries = async () => {
464
- 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
436
+ const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
465
437
 
438
+ // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
466
439
  if (finalQueryLevels.length > 1 || finalQueryLevels.length === 1 && finalQueryLevels[0].level !== 0) {
467
440
  var _params$orderBy;
468
-
469
441
  // Build final query
470
442
  const {
471
443
  contentTypeIds,
@@ -480,9 +452,9 @@ class LinkDepthSearchService {
480
452
  }
481
453
  }, {
482
454
  [vl.linkFieldId]: vl.entryIds.join(',') || 'no results for filter'
483
- })).flat() || []; // This is the final query to be run and response returned to the caller
455
+ })).flat() || [];
456
+ // This is the final query to be run and response returned to the caller
484
457
  // Only this bit cares about linkDepth, fields and pagination parameters
485
-
486
458
  const query = finalQuery({
487
459
  contentTypeIds,
488
460
  filters: makeFilterExpressions(filters, params),
@@ -490,7 +462,6 @@ class LinkDepthSearchService {
490
462
  idFilters: derivedIdFilters,
491
463
  fields: params.fields ? [...JSON.parse(params.fields), ...finalQueryLevels.map(l => {
492
464
  var _l$parent;
493
-
494
465
  return ((_l$parent = l.parent) === null || _l$parent === void 0 ? void 0 : _l$parent.linkFieldIds) || [];
495
466
  }).flat()] : [],
496
467
  orderBy: (_params$orderBy = params.orderBy) === null || _params$orderBy === void 0 ? void 0 : _params$orderBy.split(','),
@@ -500,7 +471,6 @@ class LinkDepthSearchService {
500
471
  versionStatus: params.versionStatus
501
472
  }, (finalQueryLevels === null || finalQueryLevels === void 0 ? void 0 : finalQueryLevels[0].children.filter(ql => ql.returnEntries).map(ql => {
502
473
  var _ql$parent, _ql$parent2;
503
-
504
474
  const entriesAtLevel = ql.GetResultsEntries() || ((_ql$parent = ql.parent) === null || _ql$parent === void 0 ? void 0 : _ql$parent.GetResultsEntries());
505
475
  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
476
  return {
@@ -511,29 +481,28 @@ class LinkDepthSearchService {
511
481
  };
512
482
  })) || []);
513
483
  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 App.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId); // Resolve any parent entries
484
+ const finalQueryResult = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
485
+
486
+ // Resolve any parent entries
515
487
 
516
488
  const resolveParentLevels = finalQueryLevels.filter(ql => ql.resolveFirstParent);
517
489
  let entries = finalQueryResult.items;
518
-
519
490
  for (const resolveParents of resolveParentLevels) {
520
491
  var _resolveParents$paren, _resolveParents$paren2;
521
-
522
- 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?
492
+ 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,
493
+ // or entries?
523
494
  this.params, this.debug);
524
495
  }
525
-
526
- return { ...finalQueryResult,
496
+ return {
497
+ ...finalQueryResult,
527
498
  items: entries
528
499
  };
529
500
  } else {
530
501
  var _this$queryLevels$fin;
531
-
532
502
  if (this.debug) console.log(`\nNo further queries required\n`);
533
503
  return (_this$queryLevels$fin = this.queryLevels.find(ql => ql.level === 0)) === null || _this$queryLevels$fin === void 0 ? void 0 : _this$queryLevels$fin.GetResults();
534
504
  }
535
505
  };
536
-
537
506
  this.InitQueryLevels = () => {
538
507
  const createChildQueryLevels = (linkFields, parentQueryLevel, level = 1) => {
539
508
  return Object.entries(linkFields).map(([, {
@@ -566,7 +535,6 @@ class LinkDepthSearchService {
566
535
  return [thisLevel, ...createChildQueryLevels(linkFields, thisLevel, level + 1)];
567
536
  }).flat();
568
537
  };
569
-
570
538
  const {
571
539
  contentTypeIds,
572
540
  filters,
@@ -587,17 +555,17 @@ class LinkDepthSearchService {
587
555
  params,
588
556
  debug: this.debug
589
557
  });
590
- const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)]; // return queryLevels;
558
+ const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
559
+ // return queryLevels;
560
+
591
561
  // If we are only returning entries from level 0
592
562
  // we can skip running the first query and finalQuery will suffice
593
-
594
563
  if (queryLevels.find(ql => ql.returnEntries && ql.level !== 0)) return queryLevels;else return queryLevels.map(ql => {
595
- ql.runFirstQuery = false; // ql.runFinalQuery = false;
596
-
564
+ ql.runFirstQuery = false;
565
+ // ql.runFinalQuery = false;
597
566
  return ql;
598
567
  });
599
568
  };
600
-
601
569
  this.contentTypeIds = Array.isArray(_contentTypeId) ? _contentTypeId : [_contentTypeId];
602
570
  this.filters = _filters;
603
571
  this.sharedFilters = _sharedFilters;
@@ -606,7 +574,6 @@ class LinkDepthSearchService {
606
574
  this.debug = debug;
607
575
  this.queryLevels = this.InitQueryLevels();
608
576
  }
609
-
610
577
  }
611
578
 
612
579
  /**
@@ -626,10 +593,9 @@ const makeLinkDepthApi = (app, middlewareConfig) => {
626
593
  if (!contentTypeId || !linkFields || !uri) return;
627
594
  app.get(uri, makeLinkDepthMiddleware(middlewareConfig));
628
595
  };
596
+
629
597
  /** Create a content type hierarchy from supplied config and produces
630
598
  * a RequestHandler function to serve our Express middleware */
631
-
632
-
633
599
  const makeLinkDepthMiddleware = ({
634
600
  contentTypeId,
635
601
  filters = {},
@@ -645,8 +611,9 @@ const makeLinkDepthMiddleware = ({
645
611
  urls.setCachingHeaders(res, {
646
612
  cacheControl: 'private',
647
613
  surrogateControl: '10'
648
- }); // Gather all params from the request, we will use them at the right query levels later
614
+ });
649
615
 
616
+ // Gather all params from the request, we will use them at the right query levels later
650
617
  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
618
  const result = await new LinkDepthSearchService({
652
619
  contentTypeId,
@@ -664,35 +631,25 @@ const makeLinkDepthMiddleware = ({
664
631
  res.json(error);
665
632
  }
666
633
  };
667
-
668
634
  return linkDepthMiddleware;
669
635
  } catch (error) {
670
636
  // This will be an error building the middleware
671
637
  // we can only serve what the error was as the request handler instead
672
638
  console.error(error);
673
-
674
639
  const errorMiddleware = async (req, res) => {
675
640
  res.statusCode = 500;
676
641
  res.json(JSON.stringify(error));
677
642
  };
678
-
679
643
  return errorMiddleware;
680
644
  }
681
645
  };
682
646
 
683
- const servers$1 = SERVERS;
684
- /* global SERVERS */
685
-
686
- const project = PROJECT;
687
- /* global PROJECT */
688
-
689
- const alias = ALIAS;
690
- /* global ALIAS */
691
-
647
+ const servers$1 = SERVERS; /* global SERVERS */
648
+ const project = PROJECT; /* global PROJECT */
649
+ const alias = ALIAS; /* global ALIAS */
692
650
  const deliveryApiHostname = urls.url(alias, project).api;
693
651
  const assetProxy = httpProxy__default["default"].createProxyServer();
694
652
  const deliveryProxy = httpProxy__default["default"].createProxyServer();
695
-
696
653
  const reverseProxies = (app, reverseProxyPaths = []) => {
697
654
  deliveryApiProxy(deliveryProxy, app);
698
655
  app.all(reverseProxyPaths, (req, res) => {
@@ -732,8 +689,8 @@ const CacheDuration = {
732
689
  static: '31536000',
733
690
  // Believe it or not these two max ages are the same in runtime
734
691
  expressStatic: '31557600h' // Believe it or not these two max ages are the same in runtime
735
-
736
692
  };
693
+
737
694
  const getCacheDuration = (status = 200) => {
738
695
  if (status > 400) return CacheDuration[404];
739
696
  return CacheDuration[200];
@@ -750,10 +707,8 @@ const bundleManipulationMiddleware = ({
750
707
  const filename = path__default["default"].basename(req.path);
751
708
  const modernBundle = filename.endsWith('.mjs');
752
709
  const legacyBundle = filename.endsWith('.js');
753
-
754
710
  if ((legacyBundle || modernBundle) && filename.startsWith('runtime.')) {
755
711
  const jsRuntimeLocation = path__default["default"].resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
756
-
757
712
  try {
758
713
  const jsRuntimeBundle = fs__default["default"].readFileSync(jsRuntimeLocation, 'utf8');
759
714
  const modifiedBundle = replaceStaticPath(jsRuntimeBundle, staticRoutePath);
@@ -776,7 +731,6 @@ const bundleManipulationMiddleware = ({
776
731
  * @returns Response | next()
777
732
  * A middleware function to resolve /dist/static/startup.js under a supplied startupScriptFilename variable
778
733
  */
779
-
780
734
  const resolveStartupMiddleware = ({
781
735
  appRootPath,
782
736
  maxage,
@@ -785,7 +739,6 @@ const resolveStartupMiddleware = ({
785
739
  }) => async (req, res, next) => {
786
740
  if (startupScriptFilename !== 'startup.js' && req.path === `/${startupScriptFilename}`) {
787
741
  let startupFileLocation = '';
788
-
789
742
  try {
790
743
  const startupFilePaths = [`dist/static/startup.js`, `dist/${staticFolderPath}/startup.js`];
791
744
  let startupFilePath = '';
@@ -793,7 +746,8 @@ const resolveStartupMiddleware = ({
793
746
  try {
794
747
  fs__default["default"].accessSync(testPath);
795
748
  startupFilePath = testPath;
796
- } catch (ex) {// Do nothing
749
+ } catch (ex) {
750
+ // Do nothing
797
751
  }
798
752
  });
799
753
  startupFileLocation = path__default["default"].resolve(appRootPath, startupFilePath);
@@ -830,7 +784,8 @@ const staticAssets = (app, {
830
784
  maxage: CacheDuration.static,
831
785
  startupScriptFilename: scripts.startup || startupScriptFilename,
832
786
  staticFolderPath
833
- }), // eslint-disable-next-line import/no-named-as-default-member
787
+ }),
788
+ // eslint-disable-next-line import/no-named-as-default-member
834
789
  express__default["default"].static(`dist/${staticFolderPath}`, {
835
790
  // these maxage values are different in config but the same in runtime,
836
791
  // this one is somehow converted and should end up being the same as CacheDuration.static
@@ -838,11 +793,8 @@ const staticAssets = (app, {
838
793
  }));
839
794
  };
840
795
 
841
- const servers = SERVERS;
842
- /* global SERVERS */
843
-
844
- const projects = PROJECTS;
845
- /* global PROJECTS */
796
+ const servers = SERVERS; /* global SERVERS */
797
+ const projects = PROJECTS; /* global PROJECTS */
846
798
 
847
799
  const DisplayStartupConfiguration = config => {
848
800
  /* eslint-disable no-console */
@@ -3987,20 +3939,17 @@ const handleResponse = (request, response, content, send = 'send') => {
3987
3939
  };
3988
3940
 
3989
3941
  const readFileSync = path => fs__default["default"].readFileSync(path, 'utf8');
3990
-
3991
3942
  const loadableBundleData = ({
3992
3943
  stats,
3993
3944
  templates
3994
3945
  }, staticRoutePath, build) => {
3995
3946
  const bundle = {};
3996
-
3997
3947
  try {
3998
3948
  bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
3999
3949
  } catch (ex) {
4000
3950
  // console.info(ex);
4001
3951
  bundle.stats = null;
4002
3952
  }
4003
-
4004
3953
  try {
4005
3954
  bundle.templates = {
4006
3955
  templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
@@ -4011,18 +3960,15 @@ const loadableBundleData = ({
4011
3960
  // console.info(ex);
4012
3961
  bundle.templates = null;
4013
3962
  }
4014
-
4015
3963
  return bundle;
4016
3964
  };
4017
3965
  const loadableChunkExtractors = () => {
4018
3966
  const commonLoadableExtractor = new server$1.ChunkExtractor({
4019
3967
  stats: {}
4020
3968
  });
4021
-
4022
3969
  try {
4023
3970
  let modern;
4024
3971
  let legacy;
4025
-
4026
3972
  try {
4027
3973
  modern = new server$1.ChunkExtractor({
4028
3974
  entrypoints: ['app'],
@@ -4032,7 +3978,6 @@ const loadableChunkExtractors = () => {
4032
3978
  } catch (e) {
4033
3979
  console.info('@loadable/server modern ChunkExtractor not available');
4034
3980
  }
4035
-
4036
3981
  try {
4037
3982
  legacy = new server$1.ChunkExtractor({
4038
3983
  entrypoints: ['app'],
@@ -4042,14 +3987,11 @@ const loadableChunkExtractors = () => {
4042
3987
  } catch (e) {
4043
3988
  console.info('@loadable/server legacy ChunkExtractor not available');
4044
3989
  }
4045
-
4046
3990
  commonLoadableExtractor.addChunk = chunk => {
4047
3991
  var _modern, _legacy, _legacy2;
4048
-
4049
3992
  (_modern = modern) === null || _modern === void 0 ? void 0 : _modern.addChunk(chunk);
4050
3993
  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
3994
  };
4052
-
4053
3995
  return {
4054
3996
  commonLoadableExtractor,
4055
3997
  modern,
@@ -4070,7 +4012,9 @@ const getBundleData = (config, staticRoutePath) => {
4070
4012
  };
4071
4013
  if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
4072
4014
  return bundleData;
4073
- }; // export const buildBundleTags = (
4015
+ };
4016
+
4017
+ // export const buildBundleTags = (
4074
4018
  // bundles,
4075
4019
  // differentialBundles = false,
4076
4020
  // staticRoutePath = 'static',
@@ -4095,17 +4039,18 @@ const getBundleData = (config, staticRoutePath) => {
4095
4039
  // )}"></script>`;
4096
4040
  // })
4097
4041
  // .filter(f => f);
4042
+
4098
4043
  // return bundleTags;
4099
4044
  // };
4100
4045
 
4101
4046
  const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
4102
- let startupTag = ''; // Add the static startup script to the bundleTags
4103
-
4104
- 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
4047
+ let startupTag = '';
4048
+ // Add the static startup script to the bundleTags
4049
+ if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
4105
4050
 
4051
+ // Get the script tags from their respective extractor instances
4106
4052
  if (loadableExtractor) {
4107
4053
  var _loadableExtractor$le, _loadableExtractor$mo;
4108
-
4109
4054
  const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
4110
4055
  nomodule: 'nomodule'
4111
4056
  });
@@ -4115,7 +4060,6 @@ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') =
4115
4060
  const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
4116
4061
  return scriptTags;
4117
4062
  }
4118
-
4119
4063
  return startupTag;
4120
4064
  };
4121
4065
 
@@ -4141,14 +4085,12 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
4141
4085
  const {
4142
4086
  globalGroups,
4143
4087
  allowedGroups
4144
- } = groups; // console.info(globalGroups, allowedGroups);
4145
-
4088
+ } = groups;
4089
+ // console.info(globalGroups, allowedGroups);
4146
4090
  let allGroups = Array.from(globalGroups && globalGroups[project] || {});
4147
-
4148
4091
  if (stateEntry && selectors.getImmutableOrJS(stateEntry, ['authentication', 'isLoginRequired']) && allowedGroups && allowedGroups[project]) {
4149
4092
  allGroups = [...allGroups, ...allowedGroups[project]];
4150
4093
  }
4151
-
4152
4094
  response.header('x-contensis-viewer-groups', allGroups.join('|'));
4153
4095
  } catch (e) {
4154
4096
  console.info('Error adding authentication header', e);
@@ -4172,14 +4114,13 @@ const unhandledExceptionHandler = (handleExceptions = true) => {
4172
4114
  const exceptionTypes = handleExceptions === true ? ['uncaughtException', 'unhandledRejection', 'SIGTERM', 'SIGINT'] // Default exception types to add event listeners for
4173
4115
  : Array.isArray(handleExceptions) // In future we could accept an array of specific exception types to handle for a specific application?
4174
4116
  ? handleExceptions : [];
4175
-
4176
4117
  for (const type of exceptionTypes) {
4177
4118
  process.on(type, err => {
4178
4119
  if (err && err instanceof Error) {
4179
4120
  // Print a message to inform admins and developers the error should not be ignored
4180
4121
  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`); // Log the error to server console
4182
-
4122
+ 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`);
4123
+ // Log the error to server console
4183
4124
  console.error(err);
4184
4125
  }
4185
4126
  });
@@ -4216,19 +4157,16 @@ const webApp = (app, ReactApp, config) => {
4216
4157
  url
4217
4158
  } = request;
4218
4159
  const cookies = new Cookies$1(request.headers.cookie);
4219
-
4220
4160
  const matchedStaticRoute = () => reactRouterConfig.matchRoutes(routes.StaticRoutes, request.path);
4221
-
4222
4161
  const isStaticRoute = () => matchedStaticRoute().length > 0;
4162
+ const staticRoute = isStaticRoute() && matchedStaticRoute()[0];
4223
4163
 
4224
- const staticRoute = isStaticRoute() && matchedStaticRoute()[0]; // Allow certain routes to avoid SSR
4225
-
4164
+ // Allow certain routes to avoid SSR
4226
4165
  const onlyDynamic = staticRoute && staticRoute.route.ssr === false;
4227
4166
  const onlySSR = staticRoute && staticRoute.route.ssrOnly === true;
4167
+ const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false;
4228
4168
 
4229
- const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false; // Determine functional params from QueryString and set access methods
4230
-
4231
-
4169
+ // Determine functional params from QueryString and set access methods
4232
4170
  const accessMethod = mapJson__default["default"](request.query, {
4233
4171
  DYNAMIC: ({
4234
4172
  dynamic
@@ -4243,21 +4181,23 @@ const webApp = (app, ReactApp, config) => {
4243
4181
  static: value
4244
4182
  }) => normaliseQs(value) || onlySSR
4245
4183
  });
4246
- const context = {}; // Track the current statusCode via the response object
4247
-
4248
- response.status(200); // Create a store (with a memory history) from our current url
4184
+ const context = {};
4185
+ // Track the current statusCode via the response object
4186
+ response.status(200);
4249
4187
 
4188
+ // Create a store (with a memory history) from our current url
4250
4189
  const store = await version.createStore(withReducers, {}, App.history({
4251
4190
  initialEntries: [url]
4252
- }), stateType); // dispatch any global and non-saga related actions before calling our JSX
4191
+ }), stateType);
4253
4192
 
4254
- const versionStatus = App.deliveryApi.getServerSideVersionStatus(request);
4193
+ // dispatch any global and non-saga related actions before calling our JSX
4194
+ const versionStatus = ContensisDeliveryApi.deliveryApi.getServerSideVersionStatus(request);
4255
4195
  console.info(`Request for ${request.path} hostname: ${request.hostname} versionStatus: ${versionStatus}`);
4256
- store.dispatch(version.setVersionStatus(versionStatus));
4257
- store.dispatch(version.setVersion(versionInfo.commitRef, versionInfo.buildNo));
4196
+ store.dispatch(version$1.setVersionStatus(versionStatus));
4197
+ store.dispatch(version$1.setVersion(versionInfo.commitRef, versionInfo.buildNo));
4258
4198
  const project = App.pickProject(request.hostname, request.query);
4259
4199
  const groups = allowedGroups && allowedGroups[project];
4260
- store.dispatch(actions.setCurrentProject(project, groups, request.hostname));
4200
+ store.dispatch(selectors.setCurrentProject(project, groups, request.hostname));
4261
4201
  const loadableExtractor = loadableChunkExtractors();
4262
4202
  const jsx = /*#__PURE__*/React__default["default"].createElement(server$1.ChunkExtractorManager, {
4263
4203
  extractor: loadableExtractor.commonLoadableExtractor
@@ -4276,23 +4216,25 @@ const webApp = (app, ReactApp, config) => {
4276
4216
  templateHTML = '',
4277
4217
  templateHTMLFragment = '',
4278
4218
  templateHTMLStatic = ''
4279
- } = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
4219
+ } = bundleData.default.templates || bundleData.legacy.templates || {};
4280
4220
 
4221
+ // Serve a blank HTML page with client scripts to load the app in the browser
4281
4222
  if (accessMethod.DYNAMIC) {
4282
4223
  // Dynamic doesn't need sagas
4283
- server$2.renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
4284
- // and does not include any react-loadable code-split bundles
4224
+ server$2.renderToString(jsx);
4285
4225
 
4226
+ // Dynamic page render has only the necessary bundles to start up the app
4227
+ // and does not include any react-loadable code-split bundles
4286
4228
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4287
4229
  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); // Dynamic pages always return a 200 so we can run
4230
+ const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints);
4231
+ // Dynamic pages always return a 200 so we can run
4289
4232
  // the app and serve up all errors inside the client
4290
-
4291
4233
  response.setHeader('Surrogate-Control', `max-age=${getCacheDuration(200)}`);
4292
4234
  responseHandler(request, response, responseHtmlDynamic);
4293
- } // Render the JSX server side and send response as per access method options
4294
-
4235
+ }
4295
4236
 
4237
+ // Render the JSX server side and send response as per access method options
4296
4238
  if (!accessMethod.DYNAMIC) {
4297
4239
  store.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
4298
4240
  const sheet = new styled.ServerStyleSheet();
@@ -4302,15 +4244,14 @@ const webApp = (app, ReactApp, config) => {
4302
4244
  const htmlAttributes = helmet.htmlAttributes.toString();
4303
4245
  let title = helmet.title.toString();
4304
4246
  const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
4305
-
4306
4247
  if (context.url) {
4307
4248
  return response.redirect(context.statusCode || 302, context.url);
4308
4249
  }
4309
-
4310
4250
  const reduxState = store.getState();
4311
- const styleTags = sheet.getStyleTags(); // After running rootSaga there should be an additional react-loadable
4312
- // code-split bundles for any page components as well as core app bundles
4251
+ const styleTags = sheet.getStyleTags();
4313
4252
 
4253
+ // After running rootSaga there should be an additional react-loadable
4254
+ // code-split bundles for any page components as well as core app bundles
4314
4255
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4315
4256
  let serialisedReduxData = serialize__default["default"](lodashClean.buildCleaner({
4316
4257
  isArray: lodash.identity,
@@ -4322,7 +4263,6 @@ const webApp = (app, ReactApp, config) => {
4322
4263
  isString: lodash.identity,
4323
4264
  isUndefined: lodash.noop
4324
4265
  })(cloneDeep_1(reduxState)));
4325
-
4326
4266
  if (context.statusCode !== 404) {
4327
4267
  // For a request that returns a redux state object as a response
4328
4268
  if (accessMethod.REDUX) {
@@ -4333,7 +4273,6 @@ const webApp = (app, ReactApp, config) => {
4333
4273
  responseHandler(request, response, serialisedReduxData, 'json');
4334
4274
  return true;
4335
4275
  }
4336
-
4337
4276
  if (!disableSsrRedux) {
4338
4277
  // window.versionStatus is not strictly required here and is added to support cases
4339
4278
  // where a consumer may not be using the contensisVersionStatus in redux and calling
@@ -4341,41 +4280,40 @@ const webApp = (app, ReactApp, config) => {
4341
4280
  serialisedReduxData = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
4342
4281
  }
4343
4282
  }
4344
-
4345
4283
  if ((context.statusCode || 200) > 400) {
4346
4284
  accessMethod.STATIC = true;
4347
- } // Responses
4348
-
4285
+ }
4349
4286
 
4287
+ // Responses
4350
4288
  let responseHTML = '';
4351
- if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
4289
+ if (context.statusCode === 404) title = '<title>404 page not found</title>';
4352
4290
 
4291
+ // Static page served as a fragment
4353
4292
  if (accessMethod.FRAGMENT && accessMethod.STATIC) {
4354
4293
  responseHTML = minifyCssString__default["default"](styleTags) + html;
4355
- } // Page fragment served with client scripts and redux data that hydrate the app client side
4356
-
4294
+ }
4357
4295
 
4296
+ // Page fragment served with client scripts and redux data that hydrate the app client side
4358
4297
  if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
4359
4298
  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
- } // Full HTML page served statically
4361
-
4299
+ }
4362
4300
 
4301
+ // Full HTML page served statically
4363
4302
  if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
4364
4303
  responseHTML = templateHTMLStatic.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default["default"](styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', '');
4365
- } // Full HTML page served with client scripts and redux data that hydrate the app client side
4366
-
4304
+ }
4367
4305
 
4306
+ // Full HTML page served with client scripts and redux data that hydrate the app client side
4368
4307
  if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
4369
4308
  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
- } // Set response.status from React StaticRouter
4371
-
4309
+ }
4372
4310
 
4311
+ // Set response.status from React StaticRouter
4373
4312
  if (typeof context.statusCode === 'number') response.status(context.statusCode);
4374
4313
  addStandardHeaders(reduxState, response, packagejson, {
4375
4314
  allowedGroups,
4376
4315
  globalGroups
4377
4316
  });
4378
-
4379
4317
  try {
4380
4318
  // If react-helmet htmlAttributes are being used,
4381
4319
  // replace the html tag with those attributes sepcified
@@ -4383,7 +4321,6 @@ const webApp = (app, ReactApp, config) => {
4383
4321
  if (htmlAttributes) {
4384
4322
  responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
4385
4323
  }
4386
-
4387
4324
  responseHandler(request, response, responseHTML);
4388
4325
  } catch (err) {
4389
4326
  console.info(err.message);
@@ -4403,18 +4340,18 @@ const webApp = (app, ReactApp, config) => {
4403
4340
 
4404
4341
  const app = express__default["default"]();
4405
4342
  const server = http__default["default"].createServer(app);
4406
-
4407
4343
  const start = (ReactApp, config, ServerFeatures) => {
4408
4344
  global.PACKAGE_JSON = config.packagejson;
4409
4345
  global.DISABLE_SSR_REDUX = config.disableSsrRedux;
4410
4346
  global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
4411
4347
  global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
4412
- app.disable('x-powered-by'); // Output some information about the used build/startup configuration
4348
+ app.disable('x-powered-by');
4413
4349
 
4350
+ // Output some information about the used build/startup configuration
4414
4351
  DisplayStartupConfiguration(config);
4415
- ServerFeatures(app); // Set-up local proxy for images from cms, and delivery api requests
4352
+ ServerFeatures(app);
4353
+ // Set-up local proxy for images from cms, and delivery api requests
4416
4354
  // to save doing rewrites and extra code
4417
-
4418
4355
  reverseProxies(app, config.reverseProxyPaths);
4419
4356
  staticAssets(app, config);
4420
4357
  webApp(app, ReactApp, config);
@@ -4432,7 +4369,6 @@ const start = (ReactApp, config, ServerFeatures) => {
4432
4369
  });
4433
4370
  });
4434
4371
  };
4435
-
4436
4372
  var internalServer = {
4437
4373
  app,
4438
4374
  apiProxy: deliveryProxy,