@zengenti/contensis-react-base 4.0.0-beta.6 → 4.0.0-beta.61

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 (208) hide show
  1. package/README.md +14 -1
  2. package/cjs/{App-vZrUfVgQ.js → App-TTUKj85f.js} +498 -104
  3. package/cjs/App-TTUKj85f.js.map +1 -0
  4. package/cjs/{ChangePassword.container-ECjEXixF.js → ChangePassword.container-C4Du3Wb1.js} +57 -50
  5. package/cjs/ChangePassword.container-C4Du3Wb1.js.map +1 -0
  6. package/cjs/{SSRContext-DVj_QAC1.js → ContensisDeliveryApi-gN3_MHEl.js} +32 -74
  7. package/cjs/ContensisDeliveryApi-gN3_MHEl.js.map +1 -0
  8. package/cjs/CookieConstants-DfPiWCRZ.js +12 -0
  9. package/cjs/CookieConstants-DfPiWCRZ.js.map +1 -0
  10. package/{esm/CookieHelper.class-FTURFpz3.js → cjs/CookieHelper.class-Det3qfdU.js} +4 -6
  11. package/cjs/CookieHelper.class-Det3qfdU.js.map +1 -0
  12. package/cjs/{RouteLoader-D5Yg7EB5.js → RouteLoader-BM8DyfcF.js} +17 -9
  13. package/cjs/RouteLoader-BM8DyfcF.js.map +1 -0
  14. package/cjs/SSRContext-DotLlTQc.js +116 -0
  15. package/cjs/SSRContext-DotLlTQc.js.map +1 -0
  16. package/cjs/ToJs-BsWqWjdm.js +23 -0
  17. package/cjs/ToJs-BsWqWjdm.js.map +1 -0
  18. package/cjs/{VersionInfo-B_dKCubg.js → VersionInfo-zFPsvS8q.js} +3 -25
  19. package/cjs/VersionInfo-zFPsvS8q.js.map +1 -0
  20. package/cjs/client.js +62 -64
  21. package/cjs/client.js.map +1 -1
  22. package/cjs/contensis-react-base.js +246 -135
  23. package/cjs/contensis-react-base.js.map +1 -1
  24. package/cjs/i18n.js +75 -0
  25. package/cjs/i18n.js.map +1 -0
  26. package/cjs/{ToJs-C9jwV7YB.js → matchGroups-dqONU-vY.js} +2 -22
  27. package/cjs/matchGroups-dqONU-vY.js.map +1 -0
  28. package/cjs/redux.js +8 -6
  29. package/cjs/redux.js.map +1 -1
  30. package/cjs/routing.js +15 -7
  31. package/cjs/routing.js.map +1 -1
  32. package/cjs/{sagas-CbZhaRNd.js → sagas-OfBUtx74.js} +523 -370
  33. package/cjs/sagas-OfBUtx74.js.map +1 -0
  34. package/cjs/search.js +54 -29
  35. package/cjs/search.js.map +1 -1
  36. package/cjs/{selectors-wCs5fHD4.js → selectors-BrxJ8-F8.js} +27 -6
  37. package/cjs/selectors-BrxJ8-F8.js.map +1 -0
  38. package/cjs/selectors-DAQR0uZa.js +18 -0
  39. package/cjs/selectors-DAQR0uZa.js.map +1 -0
  40. package/cjs/slice-5xJMH24n.js +69 -0
  41. package/cjs/slice-5xJMH24n.js.map +1 -0
  42. package/cjs/{store-D07FOXvM.js → store-Dn7vP6G0.js} +52 -4
  43. package/cjs/store-Dn7vP6G0.js.map +1 -0
  44. package/cjs/urls-DGZlAs0y.js +25 -0
  45. package/cjs/urls-DGZlAs0y.js.map +1 -0
  46. package/cjs/user.js +20 -17
  47. package/cjs/user.js.map +1 -1
  48. package/cjs/util-wQwG9vit.js +148 -0
  49. package/cjs/util-wQwG9vit.js.map +1 -0
  50. package/cjs/util.js +80 -22
  51. package/cjs/util.js.map +1 -1
  52. package/cjs/{version-B7XFkBhY.js → version-2FamXHhj.js} +15 -16
  53. package/cjs/version-2FamXHhj.js.map +1 -0
  54. package/cjs/{version-CM-bJ62L.js → version-rFG9Y6_B.js} +2 -2
  55. package/cjs/{version-CM-bJ62L.js.map → version-rFG9Y6_B.js.map} +1 -1
  56. package/esm/{App-DLZweVSp.js → App-DaHtrw85.js} +458 -65
  57. package/esm/App-DaHtrw85.js.map +1 -0
  58. package/esm/{ChangePassword.container-BgzIy8dA.js → ChangePassword.container-CUBtn82K.js} +19 -13
  59. package/esm/ChangePassword.container-CUBtn82K.js.map +1 -0
  60. package/esm/{SSRContext-BE8ElZ3X.js → ContensisDeliveryApi-CvEoOLCl.js} +30 -67
  61. package/esm/ContensisDeliveryApi-CvEoOLCl.js.map +1 -0
  62. package/esm/CookieConstants-DEmbwzYr.js +7 -0
  63. package/esm/CookieConstants-DEmbwzYr.js.map +1 -0
  64. package/{cjs/CookieHelper.class-C3Eqoze9.js → esm/CookieHelper.class-C6rTRl_1.js} +2 -14
  65. package/esm/CookieHelper.class-C6rTRl_1.js.map +1 -0
  66. package/esm/{RouteLoader-xeQBXywk.js → RouteLoader-BwDPahRW.js} +14 -6
  67. package/esm/RouteLoader-BwDPahRW.js.map +1 -0
  68. package/esm/SSRContext-CYxBWky3.js +106 -0
  69. package/esm/SSRContext-CYxBWky3.js.map +1 -0
  70. package/esm/ToJs-BnRRHk6f.js +17 -0
  71. package/esm/ToJs-BnRRHk6f.js.map +1 -0
  72. package/esm/{VersionInfo-Cno7K0OA.js → VersionInfo-By2ZCZOh.js} +4 -24
  73. package/esm/VersionInfo-By2ZCZOh.js.map +1 -0
  74. package/esm/client.js +62 -63
  75. package/esm/client.js.map +1 -1
  76. package/esm/contensis-react-base.js +239 -130
  77. package/esm/contensis-react-base.js.map +1 -1
  78. package/esm/i18n.js +64 -0
  79. package/esm/i18n.js.map +1 -0
  80. package/esm/{ToJs-CNzfvyxJ.js → matchGroups-_w8BwzCC.js} +3 -18
  81. package/esm/matchGroups-_w8BwzCC.js.map +1 -0
  82. package/esm/redux.js +11 -8
  83. package/esm/redux.js.map +1 -1
  84. package/esm/routing.js +14 -7
  85. package/esm/routing.js.map +1 -1
  86. package/esm/{sagas-xJU-zOpn.js → sagas-BZWjx5by.js} +511 -357
  87. package/esm/sagas-BZWjx5by.js.map +1 -0
  88. package/esm/search.js +73 -47
  89. package/esm/search.js.map +1 -1
  90. package/esm/{selectors-DO2ocdOp.js → selectors-8ROQrTd7.js} +25 -7
  91. package/esm/selectors-8ROQrTd7.js.map +1 -0
  92. package/esm/selectors-DcmvOeX2.js +10 -0
  93. package/esm/selectors-DcmvOeX2.js.map +1 -0
  94. package/esm/slice-C6JLQik8.js +63 -0
  95. package/esm/slice-C6JLQik8.js.map +1 -0
  96. package/esm/{store-3u0RzHZ0.js → store-DSjRYsM2.js} +52 -5
  97. package/esm/store-DSjRYsM2.js.map +1 -0
  98. package/esm/urls-tLxo_skx.js +22 -0
  99. package/esm/urls-tLxo_skx.js.map +1 -0
  100. package/esm/user.js +9 -6
  101. package/esm/user.js.map +1 -1
  102. package/esm/util-BafFLYzn.js +136 -0
  103. package/esm/util-BafFLYzn.js.map +1 -0
  104. package/esm/util.js +58 -14
  105. package/esm/util.js.map +1 -1
  106. package/esm/{version-BlsI7hX2.js → version-B75wA6Te.js} +16 -16
  107. package/esm/version-B75wA6Te.js.map +1 -0
  108. package/esm/{version-wnf-TITV.js → version-BQAL8sQO.js} +2 -2
  109. package/esm/{version-wnf-TITV.js.map → version-BQAL8sQO.js.map} +1 -1
  110. package/i18n/package.json +5 -0
  111. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  112. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +0 -1
  113. package/models/i18n/index.d.ts +5 -0
  114. package/models/i18n/redux/sagas.d.ts +19 -0
  115. package/models/i18n/redux/selectors.d.ts +11 -0
  116. package/models/i18n/redux/slice.d.ts +198 -0
  117. package/models/i18n/routes.d.ts +8 -0
  118. package/models/i18n/useI18n.hook.d.ts +20 -0
  119. package/models/index.d.ts +1 -0
  120. package/models/models/AppState.d.ts +2 -0
  121. package/models/models/ContentTypeMapping.d.ts +5 -0
  122. package/models/models/Locales.d.ts +11 -0
  123. package/models/models/MatchedRoute.d.ts +5 -1
  124. package/models/models/RouteComponent.d.ts +0 -1
  125. package/models/models/SSRContext.d.ts +4 -4
  126. package/models/models/StaticRoute.d.ts +11 -0
  127. package/models/models/WithEvents.d.ts +8 -0
  128. package/models/models/config/AppConfig.d.ts +2 -0
  129. package/models/models/config/I18n.d.ts +38 -0
  130. package/models/models/config/ServerConfig.d.ts +14 -0
  131. package/models/redux/index.d.ts +2 -1
  132. package/models/redux/sagas/index.d.ts +3 -1
  133. package/models/redux/sagas/injector.d.ts +13 -0
  134. package/models/redux/store/injectors/index.d.ts +26 -0
  135. package/models/redux/store/injectors/inject.d.ts +24 -0
  136. package/models/redux/store/injectors/util.d.ts +2 -0
  137. package/models/redux/store/store.d.ts +13 -4
  138. package/models/redux/util.d.ts +1 -1
  139. package/models/routing/components/RouteLoader.d.ts +3 -3
  140. package/models/routing/httpContext.d.ts +0 -1
  141. package/models/routing/index.d.ts +1 -0
  142. package/models/routing/redux/actions.d.ts +1 -1
  143. package/models/routing/redux/invokeSearch.d.ts +22 -0
  144. package/models/routing/redux/selectors.d.ts +47 -4
  145. package/models/routing/util/expressions.d.ts +1 -1
  146. package/models/routing/util/find-contenttype-mapping.d.ts +3 -1
  147. package/models/search/containers/withListing.d.ts +1 -1
  148. package/models/search/containers/withSearch.d.ts +1 -1
  149. package/models/search/models/Queries.d.ts +3 -5
  150. package/models/search/models/Search.d.ts +43 -13
  151. package/models/search/models/SearchActions.d.ts +61 -18
  152. package/models/search/models/SearchProps.d.ts +11 -10
  153. package/models/search/models/SearchState.d.ts +23 -2
  154. package/models/search/models/SearchUtil.d.ts +3 -3
  155. package/models/search/redux/getIn.d.ts +2 -2
  156. package/models/search/redux/reducers.d.ts +3 -4
  157. package/models/search/redux/sagas.d.ts +13 -14
  158. package/models/search/redux/schema.d.ts +3 -3
  159. package/models/search/redux/selectors.d.ts +64 -42
  160. package/models/search/redux/util.d.ts +10 -1
  161. package/models/search/search/ContensisDeliveryApi.d.ts +6 -26
  162. package/models/search/search/expressions.d.ts +6 -4
  163. package/models/search/search/util.d.ts +9 -7
  164. package/models/search/transformations/state-to-queryparams.mapper.d.ts +1 -1
  165. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  166. package/models/server/features/response-handler/render-stream.d.ts +2 -4
  167. package/models/server/features/static-assets/index.d.ts +4 -3
  168. package/models/server/internalServer.d.ts +1 -2
  169. package/models/server/middleware/subsiteDebug.d.ts +11 -0
  170. package/models/server/root.d.ts +3 -0
  171. package/models/server/util/bundles.d.ts +9 -9
  172. package/models/server/util/jsx.d.ts +2 -14
  173. package/models/user/hocs/withRegistration.d.ts +1 -1
  174. package/models/util/CachedDeliveryApi.d.ts +8 -2
  175. package/models/util/ContensisDeliveryApi.d.ts +2 -4
  176. package/models/util/NoSSR.d.ts +6 -0
  177. package/models/util/SSRContext.d.ts +3 -19
  178. package/models/util/donotuse_useHistory.d.ts +6 -0
  179. package/models/util/errors.d.ts +16 -0
  180. package/models/util/index.d.ts +7 -2
  181. package/models/util/subsite.d.ts +12 -0
  182. package/models/util/urls.d.ts +1 -2
  183. package/models/util/useIsClient.d.ts +6 -0
  184. package/package.json +39 -38
  185. package/cjs/App-vZrUfVgQ.js.map +0 -1
  186. package/cjs/ChangePassword.container-ECjEXixF.js.map +0 -1
  187. package/cjs/CookieHelper.class-C3Eqoze9.js.map +0 -1
  188. package/cjs/RouteLoader-D5Yg7EB5.js.map +0 -1
  189. package/cjs/SSRContext-DVj_QAC1.js.map +0 -1
  190. package/cjs/ToJs-C9jwV7YB.js.map +0 -1
  191. package/cjs/VersionInfo-B_dKCubg.js.map +0 -1
  192. package/cjs/sagas-CbZhaRNd.js.map +0 -1
  193. package/cjs/selectors-wCs5fHD4.js.map +0 -1
  194. package/cjs/store-D07FOXvM.js.map +0 -1
  195. package/cjs/version-B7XFkBhY.js.map +0 -1
  196. package/esm/App-DLZweVSp.js.map +0 -1
  197. package/esm/ChangePassword.container-BgzIy8dA.js.map +0 -1
  198. package/esm/CookieHelper.class-FTURFpz3.js.map +0 -1
  199. package/esm/RouteLoader-xeQBXywk.js.map +0 -1
  200. package/esm/SSRContext-BE8ElZ3X.js.map +0 -1
  201. package/esm/ToJs-CNzfvyxJ.js.map +0 -1
  202. package/esm/VersionInfo-Cno7K0OA.js.map +0 -1
  203. package/esm/sagas-xJU-zOpn.js.map +0 -1
  204. package/esm/selectors-DO2ocdOp.js.map +0 -1
  205. package/esm/store-3u0RzHZ0.js.map +0 -1
  206. package/esm/version-BlsI7hX2.js.map +0 -1
  207. package/models/redux/store/injectors.d.ts +0 -31
  208. package/models/search/search/ToJs.d.ts +0 -4
@@ -3,21 +3,33 @@
3
3
  var history$1 = require('history');
4
4
  var effects = require('@redux-saga/core/effects');
5
5
  var log = require('loglevel');
6
- var store = require('./store-D07FOXvM.js');
7
- var version = require('./version-B7XFkBhY.js');
6
+ var store = require('./store-Dn7vP6G0.js');
7
+ var version = require('./version-2FamXHhj.js');
8
8
  var to = require('await-to-js');
9
- var selectors = require('./selectors-wCs5fHD4.js');
10
- var version$1 = require('./version-CM-bJ62L.js');
11
- var ChangePassword_container = require('./ChangePassword.container-ECjEXixF.js');
9
+ var contensisDeliveryApi = require('contensis-delivery-api');
10
+ var slice = require('./slice-5xJMH24n.js');
11
+ var selectors$1 = require('./selectors-BrxJ8-F8.js');
12
+ var version$1 = require('./version-rFG9Y6_B.js');
13
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-gN3_MHEl.js');
12
14
  var React = require('react');
13
15
  require('react-cookie');
14
16
  require('react-redux');
17
+ require('./VersionInfo-zFPsvS8q.js');
18
+ require('react-helmet-async');
15
19
  require('jsonpath-mapper');
16
- var contensisDeliveryApi = require('contensis-delivery-api');
17
- var ToJs = require('./ToJs-C9jwV7YB.js');
18
- require('query-string');
19
20
  require('react-router-dom');
20
- var RouteLoader = require('./RouteLoader-D5Yg7EB5.js');
21
+ var selectors = require('./selectors-DAQR0uZa.js');
22
+ var ChangePassword_container = require('./ChangePassword.container-C4Du3Wb1.js');
23
+ require('./sagas-OfBUtx74.js');
24
+ require('reselect');
25
+ require('immer');
26
+ require('deep-equal');
27
+ require('deepmerge');
28
+ var util = require('./util-wQwG9vit.js');
29
+ require('contensis-core-api');
30
+ var matchGroups = require('./matchGroups-dqONU-vY.js');
31
+ var RouteLoader = require('./RouteLoader-BM8DyfcF.js');
32
+ require('query-string');
21
33
 
22
34
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
35
 
@@ -43,6 +55,60 @@ var log__namespace = /*#__PURE__*/_interopNamespace(log);
43
55
  var to__default = /*#__PURE__*/_interopDefault(to);
44
56
  var React__default = /*#__PURE__*/_interopDefault(React);
45
57
 
58
+ const isApiError = e => !!e && typeof e === 'object' && 'status' in e && 'statusText' in e;
59
+ const isPlainError = e => !!e && typeof e === 'object' && 'message' in e && typeof e.message === 'string';
60
+ const logError = (prefix, e) => {
61
+ var _e$data;
62
+ const message = isApiError(e) ? `${prefix} ${e.status} "${((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.message) || ''}" url: ${e.url || ''}` : isPlainError(e) ? `${prefix} "${(e === null || e === void 0 ? void 0 : e.message) || e}"${e !== null && e !== void 0 && e.stack ? `\n${e.stack}` : ''}` : `${prefix} "${e}"`;
63
+ log.error(message);
64
+ };
65
+ const shorten = (str, maxLength = 120, endWeight = 0.6) => {
66
+ if (!str || str.length <= maxLength) return str;
67
+ const charsToShow = maxLength - 3;
68
+ const back = Math.floor(charsToShow * endWeight);
69
+ const front = charsToShow - back;
70
+ return `${str.slice(0, front)}...${str.slice(str.length - back)}`;
71
+ };
72
+
73
+ const deparameterise = path => {
74
+ return path.replace(/\/:\w+\??/g, '');
75
+ };
76
+
77
+ /** Create static routes for routes with specified locales */
78
+ const createLocaleRoutes = routes => {
79
+ const localeRoutes = {};
80
+ for (const route of routes.StaticRoutes) {
81
+ // If the route has defined locales, create entries for each locale
82
+ if (route.i18n && route.path) {
83
+ for (const [language, path] of Object.entries(route.i18n)) {
84
+ // We already have a locale route, so just append the language and path
85
+ const deparameterisedPath = deparameterise(route.path);
86
+ const deparameterisedLocalePath = deparameterise(path);
87
+ if (localeRoutes[deparameterisedPath]) localeRoutes[deparameterisedPath][language] = deparameterisedLocalePath;
88
+ // Otherwise, create a new entry for this route path
89
+ else localeRoutes[deparameterisedPath] = {
90
+ [language]: deparameterisedLocalePath
91
+ };
92
+ if (deparameterise(route.path) !== deparameterisedLocalePath) {
93
+ // I think we are OK to mutate here as this is only run once on app init
94
+ // we can change this if needed later
95
+ routes.StaticRoutes.push({
96
+ ...route,
97
+ path,
98
+ // Add the path with any parameters included
99
+ language,
100
+ i18n: undefined
101
+ });
102
+ } else {
103
+ // Just set the language on the existing route instead of creating a duplicate
104
+ route.language = language;
105
+ }
106
+ }
107
+ }
108
+ }
109
+ return localeRoutes;
110
+ };
111
+
46
112
  // Create a history depending on the environment
47
113
  const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
48
114
  const history = (options = {}) => selectedHistory(options);
@@ -55,12 +121,17 @@ function* ensureNodeTreeSaga(action) {
55
121
  language,
56
122
  project,
57
123
  versionStatus,
124
+ subsitePath,
58
125
  treeDepth
59
126
  } = action;
60
127
  const state = yield effects.select();
61
128
  try {
62
129
  if (!version.hasNavigationTree(state)) {
63
- const nodes = yield api.getRootNode({
130
+ const nodes = subsitePath ? yield api.getNode({
131
+ path: subsitePath,
132
+ depth: treeDepth || 0,
133
+ language
134
+ }, project) : yield api.getRootNode({
64
135
  depth: treeDepth || 0,
65
136
  language
66
137
  }, versionStatus, project);
@@ -84,6 +155,238 @@ function* ensureNodeTreeSaga(action) {
84
155
  }
85
156
  }
86
157
 
158
+ const i18nSagas = [effects.takeEvery(slice.actions.INIT_LOCALES.type, getProjectLanguages), effects.takeEvery(slice.actions.UPDATE_LANGUAGE.type, updateLanguage), effects.takeEvery(slice.actions.SET_LANGUAGE.type, setLanguageRoute)];
159
+
160
+ /**
161
+ * Resolve the current route language based on the entry, node, static route or path
162
+ * Is called directly from the routing saga as soon as an entry or node has been fetched
163
+ */
164
+ function* resolveCurrentRouteLanguage({
165
+ entry,
166
+ node
167
+ }) {
168
+ var _entry$sys, _staticRoute$route;
169
+ const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
170
+ const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
171
+ let nextLanguage = currentLanguage;
172
+ if (entry !== null && entry !== void 0 && (_entry$sys = entry.sys) !== null && _entry$sys !== void 0 && _entry$sys.language) nextLanguage = entry.sys.language;else if (node !== null && node !== void 0 && node.language) nextLanguage = node.language;else if (staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route = staticRoute.route) !== null && _staticRoute$route !== void 0 && _staticRoute$route.language) nextLanguage = staticRoute.route.language;else {
173
+ var _currentPath$split$fi;
174
+ // attempt to infer language from the path
175
+ const currentPath = yield effects.select(selectors$1.selectCurrentPath);
176
+
177
+ // path is normally lowercase
178
+ const firstPathSegment = (_currentPath$split$fi = currentPath.split('/').find(segment => segment.length)) === null || _currentPath$split$fi === void 0 ? void 0 : _currentPath$split$fi.toLowerCase();
179
+ const locales = yield effects.select(selectors.selectLocales);
180
+ const matchedLanguage = Object.keys(locales).find(lang => lang.toLowerCase() === firstPathSegment);
181
+ // matched a supported language in the path
182
+ if (matchedLanguage) nextLanguage = matchedLanguage;else
183
+ // falling back to primary language
184
+ nextLanguage = yield effects.select(selectors.selectPrimaryLanguage);
185
+ }
186
+ if (nextLanguage && nextLanguage !== currentLanguage) {
187
+ const dictionary = yield effects.call(resolveDictionaryForLanguage, nextLanguage);
188
+ yield effects.put(slice.actions.SET_LANGUAGE({
189
+ language: nextLanguage,
190
+ dictionary
191
+ }));
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Resolve the current dictionary for route language either using a supplied resolver
197
+ * function or directly derive from the locales stored in state
198
+ * Is called directly any time the language is changed
199
+ */
200
+ function* resolveDictionaryForLanguage(language) {
201
+ let dictionary = yield effects.select(selectors.selectDictionary);
202
+ // try and resolve a dictionary for this language
203
+ const resolver = yield effects.select(selectors.selectDictionaryResolver);
204
+ if (typeof resolver === 'function') {
205
+ try {
206
+ // dynamic import of dictionary file
207
+ const loadedDictionary = yield effects.call(resolver, language);
208
+ dictionary = loadedDictionary;
209
+ } catch (error) {
210
+ console.error(`No dictionary resolved for language ${language}`, error);
211
+ }
212
+ } else {
213
+ // Load dictionary from locales in state
214
+ const locales = yield effects.select(selectors.selectLocales);
215
+ if (locales && locales[language]) {
216
+ dictionary = locales[language];
217
+ }
218
+ }
219
+ return dictionary;
220
+ }
221
+
222
+ /**
223
+ * Side effects triggered from updating the language via dispatched action
224
+ * in language switching components, including resolving the next route,
225
+ * update the dictionary and subsequently redirect if needed
226
+ */
227
+ function* updateLanguage({
228
+ payload: {
229
+ language,
230
+ redirect,
231
+ fallbackPath
232
+ }
233
+ }) {
234
+ const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
235
+ if (language === currentLanguage) {
236
+ // no change needed
237
+ return;
238
+ } else {
239
+ const dictionary = language !== currentLanguage ? yield effects.call(resolveDictionaryForLanguage, language) : yield effects.select(selectors.selectDictionary);
240
+ const uri = yield effects.call(resolveNextLanguageRoute, {
241
+ language,
242
+ redirect,
243
+ fallbackPath
244
+ });
245
+ yield effects.put(slice.actions.SET_LANGUAGE({
246
+ language,
247
+ dictionary: dictionary != null ? dictionary : undefined,
248
+ redirect: redirect !== false ? uri : undefined
249
+ }));
250
+ }
251
+ }
252
+
253
+ /** Handle any route redirection after we have set the language */
254
+ function* setLanguageRoute({
255
+ payload
256
+ }) {
257
+ if (payload !== null && payload !== void 0 && payload.redirect) {
258
+ const currentPath = yield effects.select(selectors$1.selectCurrentPath);
259
+ if (payload.redirect === currentPath) {
260
+ // already on the correct path, no need to redirect
261
+ return;
262
+ }
263
+ yield effects.put(selectors$1.setRoute(payload.redirect));
264
+ }
265
+ }
266
+
267
+ /** Determine the correct route uri when the language changes */
268
+ function* resolveNextLanguageRoute({
269
+ language,
270
+ redirect,
271
+ fallbackPath
272
+ }) {
273
+ // have they supplied the route to go to?
274
+ if (typeof redirect === 'string') {
275
+ return redirect;
276
+ }
277
+
278
+ // is this an entry or a static route?
279
+ const availableLanguages = yield effects.select(selectors$1.selectRouteEntryAvailableLanguages);
280
+ if (availableLanguages.find(l => l.toLowerCase() === language.toLowerCase())) {
281
+ // if entry, get the uri for this language variation from the api
282
+ const entryUri = yield effects.call(getEntryUriForLanguage, {
283
+ entryId: yield effects.select(selectors$1.selectRouteEntryID),
284
+ language
285
+ });
286
+ if (entryUri) {
287
+ return entryUri;
288
+ }
289
+ }
290
+
291
+ // if static route, get the uri from the routes config
292
+ const staticRouteUri = yield effects.call(getStaticRouteUri, {
293
+ language
294
+ });
295
+ if (staticRouteUri) {
296
+ return staticRouteUri;
297
+ }
298
+
299
+ // if all else fails, fallback to the supplied fallback path or homepage
300
+ return fallbackPath || `/${language.toLowerCase()}`;
301
+ }
302
+
303
+ /** Check any current static route for a language variation we have stored in i18n.routes */
304
+ function* getStaticRouteUri({
305
+ language
306
+ }) {
307
+ const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
308
+ if (staticRoute !== null && staticRoute !== void 0 && staticRoute.route.path) {
309
+ var _Object$entries$find;
310
+ // Routes can have parameters such as `/:facet?` we need to deparameterise
311
+ // so we can check against our stored locale routes
312
+ const deparameterisedPath = deparameterise(staticRoute.route.path);
313
+ const localeRoutes = yield effects.select(selectors.selectLocaleRoutes);
314
+ const originalPath = (_Object$entries$find = Object.entries(localeRoutes || {}).find(([, locales]) => Object.values(locales).includes(deparameterisedPath))) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
315
+ const routeLocales = localeRoutes[deparameterisedPath] || localeRoutes[originalPath || ''];
316
+ const routeUri = routeLocales === null || routeLocales === void 0 ? void 0 : routeLocales[language];
317
+ return routeUri;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Run when the app initiates locales, populating supported languages from the config
323
+ * or fetching from the project if not provided
324
+ */
325
+ function* getProjectLanguages({
326
+ payload
327
+ }) {
328
+ const stateLocales = yield effects.select(selectors.selectLocales);
329
+ if (stateLocales && Object.keys(stateLocales).length > 0)
330
+ // Locales already set in state, no need to fetch again
331
+ return;
332
+ const locales = {};
333
+ let primaryLanguage = payload.primaryLanguage;
334
+ const supportedLanguages = [...(payload.supportedLanguages || [])];
335
+ if (supportedLanguages !== null && supportedLanguages !== void 0 && supportedLanguages.length) {
336
+ // If supported languages are provided in config, use these
337
+ for (const supportedLanguage of supportedLanguages) {
338
+ locales[supportedLanguage] = {};
339
+ }
340
+ } else {
341
+ // Fallback to getting languages from the project
342
+ const [error, project] = yield to__default.default(ContensisDeliveryApi.cachedSearch.getClient().project.get());
343
+ if (error) {
344
+ console.error('Problem fetching project languages:', error);
345
+ } else if (project) {
346
+ var _project$primaryLangu;
347
+ for (const supportedLanguage of project.supportedLanguages || []) {
348
+ locales[supportedLanguage] = {};
349
+ supportedLanguages.push(supportedLanguage);
350
+ }
351
+ // Set primary language from project if we have it
352
+ primaryLanguage = (_project$primaryLangu = project.primaryLanguage) != null ? _project$primaryLangu : primaryLanguage;
353
+ }
354
+ }
355
+ if (Object.keys(locales).length === 0) {
356
+ // Ensure at least the primary language is included
357
+ locales[payload.primaryLanguage] = {};
358
+ supportedLanguages.push(payload.primaryLanguage);
359
+ }
360
+
361
+ // Only commit if we have locales to set or we will end up in an infinite loop
362
+ if (Object.keys(locales).length) yield effects.put(slice.actions.SET_LOCALES({
363
+ ...payload,
364
+ primaryLanguage,
365
+ supportedLanguages,
366
+ locales
367
+ }));
368
+ }
369
+
370
+ /**
371
+ * Run a Delivery API query to get the uri for the chosen language variation of this entryId
372
+ * */
373
+ function* getEntryUriForLanguage({
374
+ entryId,
375
+ language
376
+ }) {
377
+ try {
378
+ const versionStatus = yield effects.select(version$1.selectVersionStatus);
379
+ const query = new contensisDeliveryApi.Query(contensisDeliveryApi.Op.equalTo('sys.id', entryId), contensisDeliveryApi.Op.equalTo('sys.language', language), contensisDeliveryApi.Op.equalTo('sys.versionStatus', versionStatus));
380
+ query.fields = ['sys.uri'];
381
+ query.pageSize = 1;
382
+ const result = yield ContensisDeliveryApi.cachedSearch.search(query);
383
+ return result.items.length ? result.items[0].sys.uri : null;
384
+ } catch (error) {
385
+ console.error('Error fetching language variations:', error);
386
+ yield effects.put(slice.actions.GET_ENTRY_URI_ERROR(error));
387
+ }
388
+ }
389
+
87
390
  const sys = {
88
391
  versionStatus: 'sys.versionStatus'
89
392
  };
@@ -106,7 +409,88 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fie
106
409
  return query;
107
410
  };
108
411
 
109
- const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
412
+ function* reduxInjectorSaga(injectorFn) {
413
+ if (typeof injectorFn === 'function') {
414
+ const {
415
+ key,
416
+ reducer,
417
+ saga
418
+ } = yield injectorFn();
419
+ version.injectRedux({
420
+ key,
421
+ reducer,
422
+ saga
423
+ });
424
+ }
425
+ }
426
+
427
+ /**
428
+ * @description Asynchronously load and inject assets related to Search
429
+ */
430
+ const importSearchAssets = () => Promise.resolve().then(function () { return require('./search.js'); });
431
+
432
+ /**
433
+ * Invokes the Search saga if:
434
+ * - `searchOptions` is present on `staticRoute` or `contentTypeRoute`
435
+ * - `searchOptions` is provided by the consumer app
436
+ * - and path starts with one of `onPaths: ['/search']`
437
+ * - or a `facet` or `listingType` is present in provided `searchOptions`
438
+ *
439
+ * A `config` is required if we want to inject the redux reducer here, sagas are injected automatically
440
+ */
441
+ function* handleSearchSaga({
442
+ location,
443
+ params,
444
+ routeSearchOptions,
445
+ searchOptions,
446
+ ssr
447
+ }) {
448
+ // Merge supplied mappers with route-supplied mappers taking precedence
449
+ const mappers = {
450
+ results: e => e,
451
+ ...((searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.mappers) || {}),
452
+ ...((routeSearchOptions === null || routeSearchOptions === void 0 ? void 0 : routeSearchOptions.mappers) || {})
453
+ };
454
+
455
+ // Merge all other search options with route-supplied options taking precedence
456
+ const {
457
+ onPaths = ['/search'],
458
+ ...searchOpts
459
+ } = {
460
+ ...(routeSearchOptions || {}),
461
+ ...(searchOptions || {})
462
+ };
463
+
464
+ // Check do we meet conditions to run the search saga
465
+ const invokeSearch = onPaths.find(p => location.pathname.startsWith(p)) || searchOpts.composition || searchOpts.facet || searchOpts.listingType;
466
+
467
+ // An empty routeSearchOptions object can be used to import assets and load config for a minilist
468
+ const importAssets = routeSearchOptions;
469
+ if (importAssets || invokeSearch) {
470
+ // Async load search assets
471
+ const {
472
+ reducer,
473
+ sagas,
474
+ setRouteFilters
475
+ } = yield importSearchAssets();
476
+
477
+ // Inject search reducer and sagas
478
+ yield effects.call(reduxInjectorSaga, async () => ({
479
+ key: 'search',
480
+ reducer: searchOpts.config && reducer(searchOpts.config),
481
+ saga: sagas
482
+ }));
483
+ if (invokeSearch) yield effects.call(setRouteFilters, {
484
+ params,
485
+ ssr,
486
+ ...searchOpts,
487
+ mappers
488
+ });
489
+ }
490
+ }
491
+
492
+ const error = (e, message) => logError(`[routeSaga]${message ? ` ${message}` : ''}`, e);
493
+ const routingSagas = [effects.takeEvery(selectors$1.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors$1.SET_ROUTE, setRouteSaga)];
110
494
 
111
495
  /**
112
496
  * To navigate / push a specific route via redux middleware
@@ -124,7 +508,7 @@ function* setRouteSaga(action) {
124
508
  function* getRouteSaga(action) {
125
509
  let entry = null;
126
510
  try {
127
- var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
511
+ var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4, _pathNode5;
128
512
  const {
129
513
  withEvents,
130
514
  routes: {
@@ -133,7 +517,8 @@ function* getRouteSaga(action) {
133
517
  staticRoute,
134
518
  // get api instance from ssr context that is connected to the specific request in ssr
135
519
  ssr: {
136
- api
520
+ api,
521
+ subsitePath
137
522
  }
138
523
  } = action;
139
524
 
@@ -150,7 +535,8 @@ function* getRouteSaga(action) {
150
535
  // These variables are the return values from
151
536
  // calls to withEvents.onRouteLoad and onRouteLoaded
152
537
  let appsays,
153
- requireLogin = false;
538
+ requireLogin = false,
539
+ searchOptions = false;
154
540
  if (withEvents && withEvents.onRouteLoad) {
155
541
  appsays = yield withEvents.onRouteLoad(action);
156
542
  }
@@ -168,14 +554,16 @@ function* getRouteSaga(action) {
168
554
  const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
169
555
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
170
556
  const state = yield effects.select();
171
- const routeEntry = selectors.selectRouteEntry(state, 'js');
172
- const routeNode = selectors.selectCurrentNode(state, 'js');
557
+ const routeEntry = selectors$1.selectRouteEntry(state, 'js');
558
+ const routeNode = selectors$1.selectCurrentNode(state, 'js');
173
559
  const currentPath = action.path; //selectCurrentPath(state);
560
+ const contentPath = action.contentPath;
174
561
  const deliveryApiStatus = version$1.selectVersionStatus(state);
175
- const project = selectors.selectCurrentProject(state);
562
+ const project = selectors$1.selectCurrentProject(state);
176
563
  // const isHome = currentPath === '/';
177
564
  const isPreview = currentPath && currentPath.startsWith('/preview/');
178
- const defaultLang = appsays && appsays.defaultLang || 'en-GB';
565
+ const currentLanguage = selectors.selectCurrentLanguage(state);
566
+ const defaultLang = appsays && appsays.defaultLang || currentLanguage || 'en-GB';
179
567
  if (!isPreview && ((_appsays2 = appsays) !== null && _appsays2 !== void 0 && _appsays2.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && ((_appsays3 = appsays) === null || _appsays3 === void 0 ? void 0 : _appsays3.refetchNode) !== true)) {
180
568
  var _staticRoute$route5;
181
569
  // To prevent erroneous 404s and wasted network calls, this covers
@@ -188,18 +576,11 @@ function* getRouteSaga(action) {
188
576
  entry: null
189
577
  };
190
578
  pathNode.entry = entry = routeEntry;
191
- //Do nothing, the entry is allready the right one.
192
- // yield put({
193
- // type: SET_ENTRY,
194
- // entry,
195
- // node: routeNode,
196
- // isLoading: false,
197
- // });
198
579
  yield effects.put({
199
- type: selectors.UPDATE_LOADING_STATE,
580
+ type: selectors$1.UPDATE_LOADING_STATE,
200
581
  isLoading: false
201
582
  });
202
- } else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
583
+ } else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors$1.selectCurrentNode), yield effects.select(selectors$1.selectCurrentAncestors), yield effects.select(selectors$1.selectCurrentSiblings));
203
584
  } else {
204
585
  var _staticRoute$route6;
205
586
  // Handle preview routes
@@ -215,7 +596,6 @@ function* getRouteSaga(action) {
215
596
  // for previewing entries as it gives a response of []
216
597
  // -- apparently it is not correct to request latest content
217
598
  // with Node API
218
-
219
599
  let previewEntry = yield api.getClient(deliveryApiStatus, project).entries.get({
220
600
  id: entryGuid,
221
601
  language,
@@ -238,11 +618,13 @@ function* getRouteSaga(action) {
238
618
  // Resolve the complete entry with the node if we are setting limits in a static route
239
619
  [nodeError, pathNode] = yield to__default.default(api.getNode({
240
620
  depth: 0,
241
- path: currentPath,
621
+ path: contentPath,
242
622
  entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
243
623
  entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
244
624
  entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
245
- language: defaultLang,
625
+ // language parameter is not used when resolving a node by path
626
+ // https://www.contensis.com/help-and-docs/apis/delivery-http/navigation/nodes/get-a-node-by-path
627
+ // language: defaultLang,
246
628
  versionStatus: deliveryApiStatus
247
629
  }, project));
248
630
  if (nodeError) {
@@ -309,25 +691,43 @@ function* getRouteSaga(action) {
309
691
  appsays,
310
692
  contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
311
693
  language: defaultLang,
312
- path: currentPath,
694
+ path: contentPath,
313
695
  pathNode,
314
696
  project,
697
+ subsitePath,
315
698
  versionStatus: deliveryApiStatus
316
699
  });
317
700
  if (children) pathNode.children = children;
318
701
  }
319
- const resolvedContentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, (_pathNode3 = pathNode) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.entry) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.sys) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.contentTypeId) || {};
702
+
703
+ // We initially listened for SET_ENTRY to complete before
704
+ // resolving the current route language, but this meant
705
+ // that the language change was not captured in time for the SSR response
706
+ yield effects.call(resolveCurrentRouteLanguage, {
707
+ entry: (_pathNode3 = pathNode) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.entry,
708
+ node: pathNode
709
+ });
710
+ const contentTypeRoute = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, (_pathNode4 = pathNode) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.entry) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.sys) === null || _pathNode4 === void 0 ? void 0 : _pathNode4.contentTypeId);
320
711
 
321
712
  // Inject redux { key, reducer, saga } provided by ContentTypeMapping
322
- if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
713
+ if (contentTypeRoute !== null && contentTypeRoute !== void 0 && contentTypeRoute.injectRedux) yield effects.call(reduxInjectorSaga, contentTypeRoute.injectRedux);
714
+
715
+ // Have we defined search options in the route configuration (for triggering search)
716
+ const routeSearchOptions = ChangePassword_container.getSearchOptions(staticRoute, contentTypeRoute);
717
+ const params = util.routeParams(staticRoute, action.location);
323
718
  if (withEvents && withEvents.onRouteLoaded) {
324
719
  // Check if the app has provided a requireLogin boolean flag or groups array
325
720
  // in addition to checking if requireLogin is set in the route definition
721
+ // The app can provide an object to invoke the search saga
326
722
  ({
327
- requireLogin
723
+ requireLogin,
724
+ searchOptions
328
725
  } = (yield withEvents.onRouteLoaded({
329
726
  ...action,
330
- entry
727
+ contentTypeRoute,
728
+ entry,
729
+ params,
730
+ searchOptions: routeSearchOptions
331
731
  })) || {});
332
732
  }
333
733
  if (requireLogin !== false) {
@@ -338,19 +738,25 @@ function* getRouteSaga(action) {
338
738
  requireLogin
339
739
  });
340
740
  }
741
+ if (searchOptions || routeSearchOptions) yield effects.call(handleSearchSaga, {
742
+ ...action,
743
+ params,
744
+ routeSearchOptions,
745
+ searchOptions
746
+ });
341
747
  if (!appsays || !appsays.preventScrollTop) {
342
748
  // Scroll into View
343
749
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
344
750
  }
345
- if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
751
+ if ((_pathNode5 = pathNode) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.entry) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.sys) !== null && _pathNode5 !== void 0 && _pathNode5.id) {
346
752
  var _appsays4;
347
753
  entry = pathNode.entry;
348
- yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || resolvedContentTypeMapping.entryMapper, false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
754
+ yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || (contentTypeRoute === null || contentTypeRoute === void 0 ? void 0 : contentTypeRoute.entryMapper), false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
349
755
  } else {
350
756
  if (staticRoute) yield effects.call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield effects.call(do404);
351
757
  }
352
758
  } catch (e) {
353
- log__namespace.error(...['Error running route saga:', e, e.stack]);
759
+ error(e);
354
760
  yield effects.call(do500, e);
355
761
  }
356
762
  }
@@ -363,6 +769,7 @@ function* resolveCurrentNodeOrdinates(action) {
363
769
  path,
364
770
  pathNode,
365
771
  project,
772
+ subsitePath,
366
773
  versionStatus
367
774
  } = action;
368
775
  const apiCall = [() => null, () => null, () => null, () => null];
@@ -385,10 +792,11 @@ function* resolveCurrentNodeOrdinates(action) {
385
792
  return yield api.getAncestors({
386
793
  id: pathNode.id,
387
794
  language,
388
- versionStatus
795
+ versionStatus,
796
+ startLevel: (subsitePath || '').split('/').length
389
797
  }, project);
390
798
  } catch (ex) {
391
- log__namespace.info('Problem fetching ancestors', ex);
799
+ error(ex, 'Problem fetching ancestors');
392
800
  return [];
393
801
  }
394
802
  };
@@ -408,7 +816,7 @@ function* resolveCurrentNodeOrdinates(action) {
408
816
  versionStatus
409
817
  }, project);
410
818
  } catch (ex) {
411
- log__namespace.info('Problem fetching children', ex);
819
+ error(ex, 'Problem fetching children');
412
820
  return [];
413
821
  }
414
822
  };
@@ -427,7 +835,7 @@ function* resolveCurrentNodeOrdinates(action) {
427
835
  versionStatus
428
836
  }, project);
429
837
  } catch (ex) {
430
- log__namespace.info('Problem fetching siblings', ex);
838
+ error(ex, 'Problem fetching siblings');
431
839
  return [];
432
840
  }
433
841
  };
@@ -459,16 +867,16 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
459
867
  // Update a window global to provide the preview toolbar
460
868
  // an updated entry id in client-side navigation
461
869
  if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
462
- const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
463
- const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
464
- const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
870
+ const currentEntryId = yield effects.select(selectors$1.selectRouteEntryEntryId);
871
+ const currentEntryLang = yield effects.select(selectors$1.selectRouteEntryLanguage);
872
+ const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors$1.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
465
873
  ...node,
466
874
  entry,
467
875
  ancestors,
468
876
  siblings
469
877
  });
470
878
  yield effects.all([effects.put({
471
- type: selectors.SET_ENTRY,
879
+ type: selectors$1.SET_ENTRY,
472
880
  id: entrySys.id,
473
881
  currentPath,
474
882
  entry,
@@ -476,10 +884,10 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
476
884
  node,
477
885
  notFound
478
886
  }), ancestors && effects.put({
479
- type: selectors.SET_ANCESTORS,
887
+ type: selectors$1.SET_ANCESTORS,
480
888
  ancestors
481
889
  }), siblings && effects.put({
482
- type: selectors.SET_SIBLINGS,
890
+ type: selectors$1.SET_SIBLINGS,
483
891
  siblings
484
892
  })]);
485
893
  }
@@ -491,7 +899,7 @@ function* mapRouteEntry(entryMapper, node) {
491
899
  return mappedEntry;
492
900
  }
493
901
  } catch (e) {
494
- log__namespace.error(...['Error running entryMapper:', e, e.stack]);
902
+ error(e, 'Error in entryMapper:');
495
903
  throw e;
496
904
  }
497
905
  return;
@@ -499,14 +907,14 @@ function* mapRouteEntry(entryMapper, node) {
499
907
  function* do404() {
500
908
  yield effects.call(clientReloadHitServer);
501
909
  yield effects.put({
502
- type: selectors.SET_ENTRY,
910
+ type: selectors$1.SET_ENTRY,
503
911
  id: null,
504
912
  entry: null,
505
913
  notFound: true
506
914
  });
507
915
  }
508
916
  function* clientReloadHitServer() {
509
- const stateEntry = yield effects.select(selectors.selectRouteEntry);
917
+ const stateEntry = yield effects.select(selectors$1.selectRouteEntry);
510
918
 
511
919
  // If in client and there is a stateEntry.sys field reload the page,
512
920
  // on the 2nd load stateEntry.sys should be null at this point,
@@ -517,7 +925,7 @@ function* clientReloadHitServer() {
517
925
  }
518
926
  function* do500(error) {
519
927
  yield effects.put({
520
- type: selectors.SET_ENTRY,
928
+ type: selectors$1.SET_ENTRY,
521
929
  id: null,
522
930
  entry: null,
523
931
  notFound: true,
@@ -526,22 +934,8 @@ function* do500(error) {
526
934
  statusCode: error && error.status ? error.status : 500
527
935
  });
528
936
  }
529
- function* reduxInjectorSaga(injectorFn) {
530
- if (typeof injectorFn === 'function') {
531
- const {
532
- key,
533
- reducer,
534
- saga
535
- } = yield injectorFn();
536
- version.injectRedux({
537
- key,
538
- reducer,
539
- saga
540
- });
541
- }
542
- }
543
937
 
544
- const registerSagas = [effects.takeEvery(selectors.REGISTER_USER, registerSaga), effects.takeEvery(selectors.REGISTER_USER_SUCCESS, redirectSaga)];
938
+ const registerSagas = [effects.takeEvery(selectors$1.REGISTER_USER, registerSaga), effects.takeEvery(selectors$1.REGISTER_USER_SUCCESS, redirectSaga)];
545
939
  function* registerSaga({
546
940
  user,
547
941
  mappers
@@ -573,13 +967,13 @@ function* registerSaga({
573
967
  }
574
968
  // Update user object with mappedResponse or responseBody
575
969
  yield effects.put({
576
- type: selectors.REGISTER_USER_SUCCESS,
970
+ type: selectors$1.REGISTER_USER_SUCCESS,
577
971
  user: mappedResponse || responseBody
578
972
  });
579
973
  } else {
580
974
  // OK response but unable to parse the response body
581
975
  yield effects.put({
582
- type: selectors.REGISTER_USER_FAILED,
976
+ type: selectors$1.REGISTER_USER_FAILED,
583
977
  error: {
584
978
  message: 'Unable to parse the created user from the register service response'
585
979
  }
@@ -597,18 +991,18 @@ function* registerSaga({
597
991
  error.status = response.status;
598
992
  }
599
993
  yield effects.put({
600
- type: selectors.REGISTER_USER_FAILED,
994
+ type: selectors$1.REGISTER_USER_FAILED,
601
995
  error
602
996
  });
603
997
  }
604
998
  }
605
999
  function* redirectSaga() {
606
1000
  // Check if querystring contains a redirect_uri
607
- const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
1001
+ const currentQs = selectors$1.queryParams(yield effects.select(selectors$1.selectCurrentSearch));
608
1002
  const redirectUri = currentQs.redirect_uri || currentQs.redirect;
609
1003
 
610
1004
  // We must use redux based navigation to preserve the registration state
611
- if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
1005
+ if (redirectUri) yield effects.put(selectors$1.setRoute(redirectUri));
612
1006
  }
613
1007
 
614
1008
  const PAP_URL = 'https://pap.zengenti.com';
@@ -676,11 +1070,11 @@ async function api(url, options) {
676
1070
  });
677
1071
  }
678
1072
 
679
- const resetPasswordSagas = [effects.takeEvery(selectors.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors.CHANGE_USER_PASSWORD, changePasswordSaga)];
1073
+ const resetPasswordSagas = [effects.takeEvery(selectors$1.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors$1.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors$1.CHANGE_USER_PASSWORD, changePasswordSaga)];
680
1074
  function* requestPasswordResetSaga(action) {
681
1075
  const userEmailObject = action.userEmailObject;
682
1076
  yield effects.put({
683
- type: selectors.REQUEST_USER_PASSWORD_RESET_SENDING
1077
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_SENDING
684
1078
  });
685
1079
  if (userEmailObject && userEmailObject.userEmail) {
686
1080
  try {
@@ -688,29 +1082,29 @@ function* requestPasswordResetSaga(action) {
688
1082
  if (passwordResetRequestResponse) {
689
1083
  if (!passwordResetRequestResponse.error) {
690
1084
  yield effects.put({
691
- type: selectors.REQUEST_USER_PASSWORD_RESET_SUCCESS
1085
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_SUCCESS
692
1086
  });
693
1087
  } else {
694
1088
  yield effects.put({
695
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1089
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
696
1090
  error: passwordResetRequestResponse.error.message
697
1091
  });
698
1092
  }
699
1093
  } else {
700
1094
  yield effects.put({
701
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1095
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
702
1096
  error: 'No response from server'
703
1097
  });
704
1098
  }
705
1099
  } catch (error) {
706
1100
  yield effects.put({
707
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1101
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
708
1102
  error: error && error.toString()
709
1103
  });
710
1104
  }
711
1105
  } else {
712
1106
  yield effects.put({
713
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1107
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
714
1108
  error: 'Invalid object'
715
1109
  });
716
1110
  }
@@ -718,7 +1112,7 @@ function* requestPasswordResetSaga(action) {
718
1112
  function* resetPasswordSaga(action) {
719
1113
  const resetPasswordObject = action.resetPasswordObject;
720
1114
  yield effects.put({
721
- type: selectors.RESET_USER_PASSWORD_SENDING
1115
+ type: selectors$1.RESET_USER_PASSWORD_SENDING
722
1116
  });
723
1117
  if (resetPasswordObject.token && resetPasswordObject.password) {
724
1118
  try {
@@ -726,30 +1120,30 @@ function* resetPasswordSaga(action) {
726
1120
  if (resetPasswordResponse) {
727
1121
  if (!resetPasswordResponse.error) {
728
1122
  yield effects.put({
729
- type: selectors.RESET_USER_PASSWORD_SUCCESS
1123
+ type: selectors$1.RESET_USER_PASSWORD_SUCCESS
730
1124
  });
731
1125
  } else {
732
1126
  const error = resetPasswordResponse.error.data && resetPasswordResponse.error.data.length > 0 && resetPasswordResponse.error.data[0].message || resetPasswordResponse.error.message;
733
1127
  yield effects.put({
734
- type: selectors.RESET_USER_PASSWORD_ERROR,
1128
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
735
1129
  error
736
1130
  });
737
1131
  }
738
1132
  } else {
739
1133
  yield effects.put({
740
- type: selectors.RESET_USER_PASSWORD_ERROR,
1134
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
741
1135
  error: 'No response from server'
742
1136
  });
743
1137
  }
744
1138
  } catch (error) {
745
1139
  yield effects.put({
746
- type: selectors.RESET_USER_PASSWORD_ERROR,
1140
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
747
1141
  error: error && error.toString()
748
1142
  });
749
1143
  }
750
1144
  } else {
751
1145
  yield effects.put({
752
- type: selectors.RESET_USER_PASSWORD_ERROR,
1146
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
753
1147
  error: 'Invalid object'
754
1148
  });
755
1149
  }
@@ -761,7 +1155,7 @@ function* resetPasswordSaga(action) {
761
1155
  function* changePasswordSaga(action) {
762
1156
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
763
1157
  yield effects.put({
764
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1158
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
765
1159
  error: 'Invalid action object sent to changePassword saga'
766
1160
  });
767
1161
  return;
@@ -773,9 +1167,9 @@ function* changePasswordSaga(action) {
773
1167
  new: action.newPassword
774
1168
  };
775
1169
  yield effects.put({
776
- type: selectors.CHANGE_USER_PASSWORD_SENDING
1170
+ type: selectors$1.CHANGE_USER_PASSWORD_SENDING
777
1171
  });
778
- const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
1172
+ const clientCredentials = yield effects.select(matchGroups.selectClientCredentials, 'js');
779
1173
  const client = yield ChangePassword_container.getManagementApiClient({
780
1174
  ...clientCredentials
781
1175
  });
@@ -784,22 +1178,17 @@ function* changePasswordSaga(action) {
784
1178
  var _err$data, _err$data2;
785
1179
  const error = (err === null || err === void 0 || (_err$data = err.data) === null || _err$data === void 0 || (_err$data = _err$data.data) === null || _err$data === void 0 ? void 0 : _err$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 || (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
786
1180
  yield effects.put({
787
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1181
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
788
1182
  error
789
1183
  });
790
1184
  return;
791
1185
  }
792
-
793
- // // eslint-disable-next-line no-console
794
- // console.log(changePasswordObject);
795
- // // eslint-disable-next-line no-console
796
- // console.log(userCredentialsObject);
797
1186
  yield effects.put({
798
- type: selectors.CHANGE_USER_PASSWORD_SUCCESS
1187
+ type: selectors$1.CHANGE_USER_PASSWORD_SUCCESS
799
1188
  });
800
1189
  } catch (error) {
801
1190
  yield effects.put({
802
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1191
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
803
1192
  error: error && error.toString()
804
1193
  });
805
1194
  }
@@ -807,13 +1196,16 @@ function* changePasswordSaga(action) {
807
1196
 
808
1197
  const userSagas = [...ChangePassword_container.loginSagas, ...registerSagas, ...resetPasswordSagas];
809
1198
 
810
- // index.js
811
- function rootSaga (featureSagas = []) {
812
- return function* rootSaga() {
813
- const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
814
- yield effects.all([...subSagas, ...featureSagas]);
815
- };
816
- }
1199
+ var rootSaga = (featureSagas = []) => {
1200
+ return [...i18nSagas, ...routingSagas, ...navigationSagas, ...userSagas, ...featureSagas];
1201
+ };
1202
+
1203
+ // export default function (featureSagas: Effect[] = []) {
1204
+ // return function* rootSaga() {
1205
+ // const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
1206
+ // yield all([...subSagas, ...featureSagas]);
1207
+ // };
1208
+ // }
817
1209
 
818
1210
  const servers = SERVERS; /* global SERVERS */
819
1211
  const alias = servers.alias.toLowerCase();
@@ -860,7 +1252,9 @@ const AppRoot = props => {
860
1252
 
861
1253
  exports.AppRoot = AppRoot;
862
1254
  exports.browserHistory = browserHistory;
1255
+ exports.createLocaleRoutes = createLocaleRoutes;
863
1256
  exports.history = history;
864
1257
  exports.pickProject = pickProject;
865
1258
  exports.rootSaga = rootSaga;
866
- //# sourceMappingURL=App-vZrUfVgQ.js.map
1259
+ exports.shorten = shorten;
1260
+ //# sourceMappingURL=App-TTUKj85f.js.map