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

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 (206) hide show
  1. package/README.md +14 -1
  2. package/cjs/{App-vZrUfVgQ.js → App-Dr56ZsQj.js} +476 -99
  3. package/cjs/App-Dr56ZsQj.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-Bbt-nG3v.js} +13 -8
  13. package/cjs/RouteLoader-Bbt-nG3v.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 +235 -127
  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-DVIwGZmd.js +25 -0
  45. package/cjs/urls-DVIwGZmd.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-CrCf7gso.js} +436 -60
  57. package/esm/App-CrCf7gso.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-BpHhiAlL.js} +10 -5
  67. package/esm/RouteLoader-BpHhiAlL.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 +227 -121
  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-DfCisos-.js +22 -0
  99. package/esm/urls-DfCisos-.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 +3 -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/index.d.ts +6 -1
  180. package/models/util/subsite.d.ts +12 -0
  181. package/models/util/useIsClient.d.ts +6 -0
  182. package/package.json +39 -38
  183. package/cjs/App-vZrUfVgQ.js.map +0 -1
  184. package/cjs/ChangePassword.container-ECjEXixF.js.map +0 -1
  185. package/cjs/CookieHelper.class-C3Eqoze9.js.map +0 -1
  186. package/cjs/RouteLoader-D5Yg7EB5.js.map +0 -1
  187. package/cjs/SSRContext-DVj_QAC1.js.map +0 -1
  188. package/cjs/ToJs-C9jwV7YB.js.map +0 -1
  189. package/cjs/VersionInfo-B_dKCubg.js.map +0 -1
  190. package/cjs/sagas-CbZhaRNd.js.map +0 -1
  191. package/cjs/selectors-wCs5fHD4.js.map +0 -1
  192. package/cjs/store-D07FOXvM.js.map +0 -1
  193. package/cjs/version-B7XFkBhY.js.map +0 -1
  194. package/esm/App-DLZweVSp.js.map +0 -1
  195. package/esm/ChangePassword.container-BgzIy8dA.js.map +0 -1
  196. package/esm/CookieHelper.class-FTURFpz3.js.map +0 -1
  197. package/esm/RouteLoader-xeQBXywk.js.map +0 -1
  198. package/esm/SSRContext-BE8ElZ3X.js.map +0 -1
  199. package/esm/ToJs-CNzfvyxJ.js.map +0 -1
  200. package/esm/VersionInfo-Cno7K0OA.js.map +0 -1
  201. package/esm/sagas-xJU-zOpn.js.map +0 -1
  202. package/esm/selectors-DO2ocdOp.js.map +0 -1
  203. package/esm/store-3u0RzHZ0.js.map +0 -1
  204. package/esm/version-BlsI7hX2.js.map +0 -1
  205. package/models/redux/store/injectors.d.ts +0 -31
  206. 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-Bbt-nG3v.js');
32
+ require('query-string');
21
33
 
22
34
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
35
 
@@ -43,6 +55,45 @@ 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 deparameterise = path => {
59
+ return path.replace(/\/:\w+\??/g, '');
60
+ };
61
+
62
+ /** Create static routes for routes with specified locales */
63
+ const createLocaleRoutes = routes => {
64
+ const localeRoutes = {};
65
+ for (const route of routes.StaticRoutes) {
66
+ // If the route has defined locales, create entries for each locale
67
+ if (route.i18n && route.path) {
68
+ for (const [language, path] of Object.entries(route.i18n)) {
69
+ // We already have a locale route, so just append the language and path
70
+ const deparameterisedPath = deparameterise(route.path);
71
+ const deparameterisedLocalePath = deparameterise(path);
72
+ if (localeRoutes[deparameterisedPath]) localeRoutes[deparameterisedPath][language] = deparameterisedLocalePath;
73
+ // Otherwise, create a new entry for this route path
74
+ else localeRoutes[deparameterisedPath] = {
75
+ [language]: deparameterisedLocalePath
76
+ };
77
+ if (deparameterise(route.path) !== deparameterisedLocalePath) {
78
+ // I think we are OK to mutate here as this is only run once on app init
79
+ // we can change this if needed later
80
+ routes.StaticRoutes.push({
81
+ ...route,
82
+ path,
83
+ // Add the path with any parameters included
84
+ language,
85
+ i18n: undefined
86
+ });
87
+ } else {
88
+ // Just set the language on the existing route instead of creating a duplicate
89
+ route.language = language;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ return localeRoutes;
95
+ };
96
+
46
97
  // Create a history depending on the environment
47
98
  const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
48
99
  const history = (options = {}) => selectedHistory(options);
@@ -55,12 +106,17 @@ function* ensureNodeTreeSaga(action) {
55
106
  language,
56
107
  project,
57
108
  versionStatus,
109
+ subsitePath,
58
110
  treeDepth
59
111
  } = action;
60
112
  const state = yield effects.select();
61
113
  try {
62
114
  if (!version.hasNavigationTree(state)) {
63
- const nodes = yield api.getRootNode({
115
+ const nodes = subsitePath ? yield api.getNode({
116
+ path: subsitePath,
117
+ depth: treeDepth || 0,
118
+ language
119
+ }, project) : yield api.getRootNode({
64
120
  depth: treeDepth || 0,
65
121
  language
66
122
  }, versionStatus, project);
@@ -84,6 +140,238 @@ function* ensureNodeTreeSaga(action) {
84
140
  }
85
141
  }
86
142
 
143
+ 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)];
144
+
145
+ /**
146
+ * Resolve the current route language based on the entry, node, static route or path
147
+ * Is called directly from the routing saga as soon as an entry or node has been fetched
148
+ */
149
+ function* resolveCurrentRouteLanguage({
150
+ entry,
151
+ node
152
+ }) {
153
+ var _entry$sys, _staticRoute$route;
154
+ const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
155
+ const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
156
+ let nextLanguage = currentLanguage;
157
+ 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 {
158
+ var _currentPath$split$fi;
159
+ // attempt to infer language from the path
160
+ const currentPath = yield effects.select(selectors$1.selectCurrentPath);
161
+
162
+ // path is normally lowercase
163
+ const firstPathSegment = (_currentPath$split$fi = currentPath.split('/').find(segment => segment.length)) === null || _currentPath$split$fi === void 0 ? void 0 : _currentPath$split$fi.toLowerCase();
164
+ const locales = yield effects.select(selectors.selectLocales);
165
+ const matchedLanguage = Object.keys(locales).find(lang => lang.toLowerCase() === firstPathSegment);
166
+ // matched a supported language in the path
167
+ if (matchedLanguage) nextLanguage = matchedLanguage;else
168
+ // falling back to primary language
169
+ nextLanguage = yield effects.select(selectors.selectPrimaryLanguage);
170
+ }
171
+ if (nextLanguage && nextLanguage !== currentLanguage) {
172
+ const dictionary = yield effects.call(resolveDictionaryForLanguage, nextLanguage);
173
+ yield effects.put(slice.actions.SET_LANGUAGE({
174
+ language: nextLanguage,
175
+ dictionary
176
+ }));
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Resolve the current dictionary for route language either using a supplied resolver
182
+ * function or directly derive from the locales stored in state
183
+ * Is called directly any time the language is changed
184
+ */
185
+ function* resolveDictionaryForLanguage(language) {
186
+ let dictionary = yield effects.select(selectors.selectDictionary);
187
+ // try and resolve a dictionary for this language
188
+ const resolver = yield effects.select(selectors.selectDictionaryResolver);
189
+ if (typeof resolver === 'function') {
190
+ try {
191
+ // dynamic import of dictionary file
192
+ const loadedDictionary = yield effects.call(resolver, language);
193
+ dictionary = loadedDictionary;
194
+ } catch (error) {
195
+ console.error(`No dictionary resolved for language ${language}`, error);
196
+ }
197
+ } else {
198
+ // Load dictionary from locales in state
199
+ const locales = yield effects.select(selectors.selectLocales);
200
+ if (locales && locales[language]) {
201
+ dictionary = locales[language];
202
+ }
203
+ }
204
+ return dictionary;
205
+ }
206
+
207
+ /**
208
+ * Side effects triggered from updating the language via dispatched action
209
+ * in language switching components, including resolving the next route,
210
+ * update the dictionary and subsequently redirect if needed
211
+ */
212
+ function* updateLanguage({
213
+ payload: {
214
+ language,
215
+ redirect,
216
+ fallbackPath
217
+ }
218
+ }) {
219
+ const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
220
+ if (language === currentLanguage) {
221
+ // no change needed
222
+ return;
223
+ } else {
224
+ const dictionary = language !== currentLanguage ? yield effects.call(resolveDictionaryForLanguage, language) : yield effects.select(selectors.selectDictionary);
225
+ const uri = yield effects.call(resolveNextLanguageRoute, {
226
+ language,
227
+ redirect,
228
+ fallbackPath
229
+ });
230
+ yield effects.put(slice.actions.SET_LANGUAGE({
231
+ language,
232
+ dictionary: dictionary != null ? dictionary : undefined,
233
+ redirect: redirect !== false ? uri : undefined
234
+ }));
235
+ }
236
+ }
237
+
238
+ /** Handle any route redirection after we have set the language */
239
+ function* setLanguageRoute({
240
+ payload
241
+ }) {
242
+ if (payload !== null && payload !== void 0 && payload.redirect) {
243
+ const currentPath = yield effects.select(selectors$1.selectCurrentPath);
244
+ if (payload.redirect === currentPath) {
245
+ // already on the correct path, no need to redirect
246
+ return;
247
+ }
248
+ yield effects.put(selectors$1.setRoute(payload.redirect));
249
+ }
250
+ }
251
+
252
+ /** Determine the correct route uri when the language changes */
253
+ function* resolveNextLanguageRoute({
254
+ language,
255
+ redirect,
256
+ fallbackPath
257
+ }) {
258
+ // have they supplied the route to go to?
259
+ if (typeof redirect === 'string') {
260
+ return redirect;
261
+ }
262
+
263
+ // is this an entry or a static route?
264
+ const availableLanguages = yield effects.select(selectors$1.selectRouteEntryAvailableLanguages);
265
+ if (availableLanguages.find(l => l.toLowerCase() === language.toLowerCase())) {
266
+ // if entry, get the uri for this language variation from the api
267
+ const entryUri = yield effects.call(getEntryUriForLanguage, {
268
+ entryId: yield effects.select(selectors$1.selectRouteEntryID),
269
+ language
270
+ });
271
+ if (entryUri) {
272
+ return entryUri;
273
+ }
274
+ }
275
+
276
+ // if static route, get the uri from the routes config
277
+ const staticRouteUri = yield effects.call(getStaticRouteUri, {
278
+ language
279
+ });
280
+ if (staticRouteUri) {
281
+ return staticRouteUri;
282
+ }
283
+
284
+ // if all else fails, fallback to the supplied fallback path or homepage
285
+ return fallbackPath || `/${language.toLowerCase()}`;
286
+ }
287
+
288
+ /** Check any current static route for a language variation we have stored in i18n.routes */
289
+ function* getStaticRouteUri({
290
+ language
291
+ }) {
292
+ const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
293
+ if (staticRoute !== null && staticRoute !== void 0 && staticRoute.route.path) {
294
+ var _Object$entries$find;
295
+ // Routes can have parameters such as `/:facet?` we need to deparameterise
296
+ // so we can check against our stored locale routes
297
+ const deparameterisedPath = deparameterise(staticRoute.route.path);
298
+ const localeRoutes = yield effects.select(selectors.selectLocaleRoutes);
299
+ 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];
300
+ const routeLocales = localeRoutes[deparameterisedPath] || localeRoutes[originalPath || ''];
301
+ const routeUri = routeLocales === null || routeLocales === void 0 ? void 0 : routeLocales[language];
302
+ return routeUri;
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Run when the app initiates locales, populating supported languages from the config
308
+ * or fetching from the project if not provided
309
+ */
310
+ function* getProjectLanguages({
311
+ payload
312
+ }) {
313
+ const stateLocales = yield effects.select(selectors.selectLocales);
314
+ if (stateLocales && Object.keys(stateLocales).length > 0)
315
+ // Locales already set in state, no need to fetch again
316
+ return;
317
+ const locales = {};
318
+ let primaryLanguage = payload.primaryLanguage;
319
+ const supportedLanguages = [...(payload.supportedLanguages || [])];
320
+ if (supportedLanguages !== null && supportedLanguages !== void 0 && supportedLanguages.length) {
321
+ // If supported languages are provided in config, use these
322
+ for (const supportedLanguage of supportedLanguages) {
323
+ locales[supportedLanguage] = {};
324
+ }
325
+ } else {
326
+ // Fallback to getting languages from the project
327
+ const [error, project] = yield to__default.default(ContensisDeliveryApi.cachedSearch.getClient().project.get());
328
+ if (error) {
329
+ console.error('Problem fetching project languages:', error);
330
+ } else if (project) {
331
+ var _project$primaryLangu;
332
+ for (const supportedLanguage of project.supportedLanguages || []) {
333
+ locales[supportedLanguage] = {};
334
+ supportedLanguages.push(supportedLanguage);
335
+ }
336
+ // Set primary language from project if we have it
337
+ primaryLanguage = (_project$primaryLangu = project.primaryLanguage) != null ? _project$primaryLangu : primaryLanguage;
338
+ }
339
+ }
340
+ if (Object.keys(locales).length === 0) {
341
+ // Ensure at least the primary language is included
342
+ locales[payload.primaryLanguage] = {};
343
+ supportedLanguages.push(payload.primaryLanguage);
344
+ }
345
+
346
+ // Only commit if we have locales to set or we will end up in an infinite loop
347
+ if (Object.keys(locales).length) yield effects.put(slice.actions.SET_LOCALES({
348
+ ...payload,
349
+ primaryLanguage,
350
+ supportedLanguages,
351
+ locales
352
+ }));
353
+ }
354
+
355
+ /**
356
+ * Run a Delivery API query to get the uri for the chosen language variation of this entryId
357
+ * */
358
+ function* getEntryUriForLanguage({
359
+ entryId,
360
+ language
361
+ }) {
362
+ try {
363
+ const versionStatus = yield effects.select(version$1.selectVersionStatus);
364
+ const query = new contensisDeliveryApi.Query(contensisDeliveryApi.Op.equalTo('sys.id', entryId), contensisDeliveryApi.Op.equalTo('sys.language', language), contensisDeliveryApi.Op.equalTo('sys.versionStatus', versionStatus));
365
+ query.fields = ['sys.uri'];
366
+ query.pageSize = 1;
367
+ const result = yield ContensisDeliveryApi.cachedSearch.search(query);
368
+ return result.items.length ? result.items[0].sys.uri : null;
369
+ } catch (error) {
370
+ console.error('Error fetching language variations:', error);
371
+ yield effects.put(slice.actions.GET_ENTRY_URI_ERROR(error));
372
+ }
373
+ }
374
+
87
375
  const sys = {
88
376
  versionStatus: 'sys.versionStatus'
89
377
  };
@@ -106,7 +394,87 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fie
106
394
  return query;
107
395
  };
108
396
 
109
- const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
397
+ function* reduxInjectorSaga(injectorFn) {
398
+ if (typeof injectorFn === 'function') {
399
+ const {
400
+ key,
401
+ reducer,
402
+ saga
403
+ } = yield injectorFn();
404
+ version.injectRedux({
405
+ key,
406
+ reducer,
407
+ saga
408
+ });
409
+ }
410
+ }
411
+
412
+ /**
413
+ * @description Asynchronously load and inject assets related to Search
414
+ */
415
+ const importSearchAssets = () => Promise.resolve().then(function () { return require('./search.js'); });
416
+
417
+ /**
418
+ * Invokes the Search saga if:
419
+ * - `searchOptions` is present on `staticRoute` or `contentTypeRoute`
420
+ * - `searchOptions` is provided by the consumer app
421
+ * - and path starts with one of `onPaths: ['/search']`
422
+ * - or a `facet` or `listingType` is present in provided `searchOptions`
423
+ *
424
+ * A `config` is required if we want to inject the redux reducer here, sagas are injected automatically
425
+ */
426
+ function* handleSearchSaga({
427
+ location,
428
+ params,
429
+ routeSearchOptions,
430
+ searchOptions,
431
+ ssr
432
+ }) {
433
+ // Merge supplied mappers with route-supplied mappers taking precedence
434
+ const mappers = {
435
+ results: e => e,
436
+ ...((searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.mappers) || {}),
437
+ ...((routeSearchOptions === null || routeSearchOptions === void 0 ? void 0 : routeSearchOptions.mappers) || {})
438
+ };
439
+
440
+ // Merge all other search options with route-supplied options taking precedence
441
+ const {
442
+ onPaths = ['/search'],
443
+ ...searchOpts
444
+ } = {
445
+ ...(routeSearchOptions || {}),
446
+ ...(searchOptions || {})
447
+ };
448
+
449
+ // Check do we meet conditions to run the search saga
450
+ const invokeSearch = onPaths.find(p => location.pathname.startsWith(p)) || searchOpts.composition || searchOpts.facet || searchOpts.listingType;
451
+
452
+ // An empty routeSearchOptions object can be used to import assets and load config for a minilist
453
+ const importAssets = routeSearchOptions;
454
+ if (importAssets || invokeSearch) {
455
+ // Async load search assets
456
+ const {
457
+ reducer,
458
+ sagas,
459
+ setRouteFilters
460
+ } = yield importSearchAssets();
461
+
462
+ // Inject search reducer and sagas
463
+ yield effects.call(reduxInjectorSaga, async () => ({
464
+ key: 'search',
465
+ reducer: searchOpts.config && reducer(searchOpts.config),
466
+ saga: sagas
467
+ }));
468
+ if (invokeSearch) yield effects.call(setRouteFilters, {
469
+ params,
470
+ ssr,
471
+ ...searchOpts,
472
+ mappers
473
+ });
474
+ }
475
+ }
476
+
477
+ const routingSagas = [effects.takeEvery(selectors$1.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors$1.SET_ROUTE, setRouteSaga)];
110
478
 
111
479
  /**
112
480
  * To navigate / push a specific route via redux middleware
@@ -124,7 +492,7 @@ function* setRouteSaga(action) {
124
492
  function* getRouteSaga(action) {
125
493
  let entry = null;
126
494
  try {
127
- var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
495
+ var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4, _pathNode5;
128
496
  const {
129
497
  withEvents,
130
498
  routes: {
@@ -133,7 +501,8 @@ function* getRouteSaga(action) {
133
501
  staticRoute,
134
502
  // get api instance from ssr context that is connected to the specific request in ssr
135
503
  ssr: {
136
- api
504
+ api,
505
+ subsitePath
137
506
  }
138
507
  } = action;
139
508
 
@@ -150,7 +519,8 @@ function* getRouteSaga(action) {
150
519
  // These variables are the return values from
151
520
  // calls to withEvents.onRouteLoad and onRouteLoaded
152
521
  let appsays,
153
- requireLogin = false;
522
+ requireLogin = false,
523
+ searchOptions = false;
154
524
  if (withEvents && withEvents.onRouteLoad) {
155
525
  appsays = yield withEvents.onRouteLoad(action);
156
526
  }
@@ -168,14 +538,16 @@ function* getRouteSaga(action) {
168
538
  const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
169
539
  const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
170
540
  const state = yield effects.select();
171
- const routeEntry = selectors.selectRouteEntry(state, 'js');
172
- const routeNode = selectors.selectCurrentNode(state, 'js');
541
+ const routeEntry = selectors$1.selectRouteEntry(state, 'js');
542
+ const routeNode = selectors$1.selectCurrentNode(state, 'js');
173
543
  const currentPath = action.path; //selectCurrentPath(state);
544
+ const contentPath = action.contentPath;
174
545
  const deliveryApiStatus = version$1.selectVersionStatus(state);
175
- const project = selectors.selectCurrentProject(state);
546
+ const project = selectors$1.selectCurrentProject(state);
176
547
  // const isHome = currentPath === '/';
177
548
  const isPreview = currentPath && currentPath.startsWith('/preview/');
178
- const defaultLang = appsays && appsays.defaultLang || 'en-GB';
549
+ const currentLanguage = selectors.selectCurrentLanguage(state);
550
+ const defaultLang = appsays && appsays.defaultLang || currentLanguage || 'en-GB';
179
551
  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
552
  var _staticRoute$route5;
181
553
  // To prevent erroneous 404s and wasted network calls, this covers
@@ -188,18 +560,11 @@ function* getRouteSaga(action) {
188
560
  entry: null
189
561
  };
190
562
  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
563
  yield effects.put({
199
- type: selectors.UPDATE_LOADING_STATE,
564
+ type: selectors$1.UPDATE_LOADING_STATE,
200
565
  isLoading: false
201
566
  });
202
- } else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
567
+ } 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
568
  } else {
204
569
  var _staticRoute$route6;
205
570
  // Handle preview routes
@@ -215,7 +580,6 @@ function* getRouteSaga(action) {
215
580
  // for previewing entries as it gives a response of []
216
581
  // -- apparently it is not correct to request latest content
217
582
  // with Node API
218
-
219
583
  let previewEntry = yield api.getClient(deliveryApiStatus, project).entries.get({
220
584
  id: entryGuid,
221
585
  language,
@@ -238,11 +602,13 @@ function* getRouteSaga(action) {
238
602
  // Resolve the complete entry with the node if we are setting limits in a static route
239
603
  [nodeError, pathNode] = yield to__default.default(api.getNode({
240
604
  depth: 0,
241
- path: currentPath,
605
+ path: contentPath,
242
606
  entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
243
607
  entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
244
608
  entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
245
- language: defaultLang,
609
+ // language parameter is not used when resolving a node by path
610
+ // https://www.contensis.com/help-and-docs/apis/delivery-http/navigation/nodes/get-a-node-by-path
611
+ // language: defaultLang,
246
612
  versionStatus: deliveryApiStatus
247
613
  }, project));
248
614
  if (nodeError) {
@@ -309,25 +675,43 @@ function* getRouteSaga(action) {
309
675
  appsays,
310
676
  contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
311
677
  language: defaultLang,
312
- path: currentPath,
678
+ path: contentPath,
313
679
  pathNode,
314
680
  project,
681
+ subsitePath,
315
682
  versionStatus: deliveryApiStatus
316
683
  });
317
684
  if (children) pathNode.children = children;
318
685
  }
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) || {};
686
+
687
+ // We initially listened for SET_ENTRY to complete before
688
+ // resolving the current route language, but this meant
689
+ // that the language change was not captured in time for the SSR response
690
+ yield effects.call(resolveCurrentRouteLanguage, {
691
+ entry: (_pathNode3 = pathNode) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.entry,
692
+ node: pathNode
693
+ });
694
+ 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
695
 
321
696
  // Inject redux { key, reducer, saga } provided by ContentTypeMapping
322
- if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
697
+ if (contentTypeRoute !== null && contentTypeRoute !== void 0 && contentTypeRoute.injectRedux) yield effects.call(reduxInjectorSaga, contentTypeRoute.injectRedux);
698
+
699
+ // Have we defined search options in the route configuration (for triggering search)
700
+ const routeSearchOptions = ChangePassword_container.getSearchOptions(staticRoute, contentTypeRoute);
701
+ const params = util.routeParams(staticRoute, action.location);
323
702
  if (withEvents && withEvents.onRouteLoaded) {
324
703
  // Check if the app has provided a requireLogin boolean flag or groups array
325
704
  // in addition to checking if requireLogin is set in the route definition
705
+ // The app can provide an object to invoke the search saga
326
706
  ({
327
- requireLogin
707
+ requireLogin,
708
+ searchOptions
328
709
  } = (yield withEvents.onRouteLoaded({
329
710
  ...action,
330
- entry
711
+ contentTypeRoute,
712
+ entry,
713
+ params,
714
+ searchOptions: routeSearchOptions
331
715
  })) || {});
332
716
  }
333
717
  if (requireLogin !== false) {
@@ -338,14 +722,20 @@ function* getRouteSaga(action) {
338
722
  requireLogin
339
723
  });
340
724
  }
725
+ if (searchOptions || routeSearchOptions) yield effects.call(handleSearchSaga, {
726
+ ...action,
727
+ params,
728
+ routeSearchOptions,
729
+ searchOptions
730
+ });
341
731
  if (!appsays || !appsays.preventScrollTop) {
342
732
  // Scroll into View
343
733
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
344
734
  }
345
- if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
735
+ if ((_pathNode5 = pathNode) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.entry) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.sys) !== null && _pathNode5 !== void 0 && _pathNode5.id) {
346
736
  var _appsays4;
347
737
  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);
738
+ 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
739
  } else {
350
740
  if (staticRoute) yield effects.call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield effects.call(do404);
351
741
  }
@@ -363,6 +753,7 @@ function* resolveCurrentNodeOrdinates(action) {
363
753
  path,
364
754
  pathNode,
365
755
  project,
756
+ subsitePath,
366
757
  versionStatus
367
758
  } = action;
368
759
  const apiCall = [() => null, () => null, () => null, () => null];
@@ -385,7 +776,8 @@ function* resolveCurrentNodeOrdinates(action) {
385
776
  return yield api.getAncestors({
386
777
  id: pathNode.id,
387
778
  language,
388
- versionStatus
779
+ versionStatus,
780
+ startLevel: (subsitePath || '').split('/').length
389
781
  }, project);
390
782
  } catch (ex) {
391
783
  log__namespace.info('Problem fetching ancestors', ex);
@@ -459,16 +851,16 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
459
851
  // Update a window global to provide the preview toolbar
460
852
  // an updated entry id in client-side navigation
461
853
  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, {
854
+ const currentEntryId = yield effects.select(selectors$1.selectRouteEntryEntryId);
855
+ const currentEntryLang = yield effects.select(selectors$1.selectRouteEntryLanguage);
856
+ const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors$1.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
465
857
  ...node,
466
858
  entry,
467
859
  ancestors,
468
860
  siblings
469
861
  });
470
862
  yield effects.all([effects.put({
471
- type: selectors.SET_ENTRY,
863
+ type: selectors$1.SET_ENTRY,
472
864
  id: entrySys.id,
473
865
  currentPath,
474
866
  entry,
@@ -476,10 +868,10 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
476
868
  node,
477
869
  notFound
478
870
  }), ancestors && effects.put({
479
- type: selectors.SET_ANCESTORS,
871
+ type: selectors$1.SET_ANCESTORS,
480
872
  ancestors
481
873
  }), siblings && effects.put({
482
- type: selectors.SET_SIBLINGS,
874
+ type: selectors$1.SET_SIBLINGS,
483
875
  siblings
484
876
  })]);
485
877
  }
@@ -499,14 +891,14 @@ function* mapRouteEntry(entryMapper, node) {
499
891
  function* do404() {
500
892
  yield effects.call(clientReloadHitServer);
501
893
  yield effects.put({
502
- type: selectors.SET_ENTRY,
894
+ type: selectors$1.SET_ENTRY,
503
895
  id: null,
504
896
  entry: null,
505
897
  notFound: true
506
898
  });
507
899
  }
508
900
  function* clientReloadHitServer() {
509
- const stateEntry = yield effects.select(selectors.selectRouteEntry);
901
+ const stateEntry = yield effects.select(selectors$1.selectRouteEntry);
510
902
 
511
903
  // If in client and there is a stateEntry.sys field reload the page,
512
904
  // on the 2nd load stateEntry.sys should be null at this point,
@@ -517,7 +909,7 @@ function* clientReloadHitServer() {
517
909
  }
518
910
  function* do500(error) {
519
911
  yield effects.put({
520
- type: selectors.SET_ENTRY,
912
+ type: selectors$1.SET_ENTRY,
521
913
  id: null,
522
914
  entry: null,
523
915
  notFound: true,
@@ -526,22 +918,8 @@ function* do500(error) {
526
918
  statusCode: error && error.status ? error.status : 500
527
919
  });
528
920
  }
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
921
 
544
- const registerSagas = [effects.takeEvery(selectors.REGISTER_USER, registerSaga), effects.takeEvery(selectors.REGISTER_USER_SUCCESS, redirectSaga)];
922
+ const registerSagas = [effects.takeEvery(selectors$1.REGISTER_USER, registerSaga), effects.takeEvery(selectors$1.REGISTER_USER_SUCCESS, redirectSaga)];
545
923
  function* registerSaga({
546
924
  user,
547
925
  mappers
@@ -573,13 +951,13 @@ function* registerSaga({
573
951
  }
574
952
  // Update user object with mappedResponse or responseBody
575
953
  yield effects.put({
576
- type: selectors.REGISTER_USER_SUCCESS,
954
+ type: selectors$1.REGISTER_USER_SUCCESS,
577
955
  user: mappedResponse || responseBody
578
956
  });
579
957
  } else {
580
958
  // OK response but unable to parse the response body
581
959
  yield effects.put({
582
- type: selectors.REGISTER_USER_FAILED,
960
+ type: selectors$1.REGISTER_USER_FAILED,
583
961
  error: {
584
962
  message: 'Unable to parse the created user from the register service response'
585
963
  }
@@ -597,18 +975,18 @@ function* registerSaga({
597
975
  error.status = response.status;
598
976
  }
599
977
  yield effects.put({
600
- type: selectors.REGISTER_USER_FAILED,
978
+ type: selectors$1.REGISTER_USER_FAILED,
601
979
  error
602
980
  });
603
981
  }
604
982
  }
605
983
  function* redirectSaga() {
606
984
  // Check if querystring contains a redirect_uri
607
- const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
985
+ const currentQs = selectors$1.queryParams(yield effects.select(selectors$1.selectCurrentSearch));
608
986
  const redirectUri = currentQs.redirect_uri || currentQs.redirect;
609
987
 
610
988
  // We must use redux based navigation to preserve the registration state
611
- if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
989
+ if (redirectUri) yield effects.put(selectors$1.setRoute(redirectUri));
612
990
  }
613
991
 
614
992
  const PAP_URL = 'https://pap.zengenti.com';
@@ -676,11 +1054,11 @@ async function api(url, options) {
676
1054
  });
677
1055
  }
678
1056
 
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)];
1057
+ 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
1058
  function* requestPasswordResetSaga(action) {
681
1059
  const userEmailObject = action.userEmailObject;
682
1060
  yield effects.put({
683
- type: selectors.REQUEST_USER_PASSWORD_RESET_SENDING
1061
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_SENDING
684
1062
  });
685
1063
  if (userEmailObject && userEmailObject.userEmail) {
686
1064
  try {
@@ -688,29 +1066,29 @@ function* requestPasswordResetSaga(action) {
688
1066
  if (passwordResetRequestResponse) {
689
1067
  if (!passwordResetRequestResponse.error) {
690
1068
  yield effects.put({
691
- type: selectors.REQUEST_USER_PASSWORD_RESET_SUCCESS
1069
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_SUCCESS
692
1070
  });
693
1071
  } else {
694
1072
  yield effects.put({
695
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1073
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
696
1074
  error: passwordResetRequestResponse.error.message
697
1075
  });
698
1076
  }
699
1077
  } else {
700
1078
  yield effects.put({
701
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1079
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
702
1080
  error: 'No response from server'
703
1081
  });
704
1082
  }
705
1083
  } catch (error) {
706
1084
  yield effects.put({
707
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1085
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
708
1086
  error: error && error.toString()
709
1087
  });
710
1088
  }
711
1089
  } else {
712
1090
  yield effects.put({
713
- type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
1091
+ type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
714
1092
  error: 'Invalid object'
715
1093
  });
716
1094
  }
@@ -718,7 +1096,7 @@ function* requestPasswordResetSaga(action) {
718
1096
  function* resetPasswordSaga(action) {
719
1097
  const resetPasswordObject = action.resetPasswordObject;
720
1098
  yield effects.put({
721
- type: selectors.RESET_USER_PASSWORD_SENDING
1099
+ type: selectors$1.RESET_USER_PASSWORD_SENDING
722
1100
  });
723
1101
  if (resetPasswordObject.token && resetPasswordObject.password) {
724
1102
  try {
@@ -726,30 +1104,30 @@ function* resetPasswordSaga(action) {
726
1104
  if (resetPasswordResponse) {
727
1105
  if (!resetPasswordResponse.error) {
728
1106
  yield effects.put({
729
- type: selectors.RESET_USER_PASSWORD_SUCCESS
1107
+ type: selectors$1.RESET_USER_PASSWORD_SUCCESS
730
1108
  });
731
1109
  } else {
732
1110
  const error = resetPasswordResponse.error.data && resetPasswordResponse.error.data.length > 0 && resetPasswordResponse.error.data[0].message || resetPasswordResponse.error.message;
733
1111
  yield effects.put({
734
- type: selectors.RESET_USER_PASSWORD_ERROR,
1112
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
735
1113
  error
736
1114
  });
737
1115
  }
738
1116
  } else {
739
1117
  yield effects.put({
740
- type: selectors.RESET_USER_PASSWORD_ERROR,
1118
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
741
1119
  error: 'No response from server'
742
1120
  });
743
1121
  }
744
1122
  } catch (error) {
745
1123
  yield effects.put({
746
- type: selectors.RESET_USER_PASSWORD_ERROR,
1124
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
747
1125
  error: error && error.toString()
748
1126
  });
749
1127
  }
750
1128
  } else {
751
1129
  yield effects.put({
752
- type: selectors.RESET_USER_PASSWORD_ERROR,
1130
+ type: selectors$1.RESET_USER_PASSWORD_ERROR,
753
1131
  error: 'Invalid object'
754
1132
  });
755
1133
  }
@@ -761,7 +1139,7 @@ function* resetPasswordSaga(action) {
761
1139
  function* changePasswordSaga(action) {
762
1140
  if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
763
1141
  yield effects.put({
764
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1142
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
765
1143
  error: 'Invalid action object sent to changePassword saga'
766
1144
  });
767
1145
  return;
@@ -773,9 +1151,9 @@ function* changePasswordSaga(action) {
773
1151
  new: action.newPassword
774
1152
  };
775
1153
  yield effects.put({
776
- type: selectors.CHANGE_USER_PASSWORD_SENDING
1154
+ type: selectors$1.CHANGE_USER_PASSWORD_SENDING
777
1155
  });
778
- const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
1156
+ const clientCredentials = yield effects.select(matchGroups.selectClientCredentials, 'js');
779
1157
  const client = yield ChangePassword_container.getManagementApiClient({
780
1158
  ...clientCredentials
781
1159
  });
@@ -784,22 +1162,17 @@ function* changePasswordSaga(action) {
784
1162
  var _err$data, _err$data2;
785
1163
  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
1164
  yield effects.put({
787
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1165
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
788
1166
  error
789
1167
  });
790
1168
  return;
791
1169
  }
792
-
793
- // // eslint-disable-next-line no-console
794
- // console.log(changePasswordObject);
795
- // // eslint-disable-next-line no-console
796
- // console.log(userCredentialsObject);
797
1170
  yield effects.put({
798
- type: selectors.CHANGE_USER_PASSWORD_SUCCESS
1171
+ type: selectors$1.CHANGE_USER_PASSWORD_SUCCESS
799
1172
  });
800
1173
  } catch (error) {
801
1174
  yield effects.put({
802
- type: selectors.CHANGE_USER_PASSWORD_ERROR,
1175
+ type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
803
1176
  error: error && error.toString()
804
1177
  });
805
1178
  }
@@ -807,13 +1180,16 @@ function* changePasswordSaga(action) {
807
1180
 
808
1181
  const userSagas = [...ChangePassword_container.loginSagas, ...registerSagas, ...resetPasswordSagas];
809
1182
 
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
- }
1183
+ var rootSaga = (featureSagas = []) => {
1184
+ return [...i18nSagas, ...routingSagas, ...navigationSagas, ...userSagas, ...featureSagas];
1185
+ };
1186
+
1187
+ // export default function (featureSagas: Effect[] = []) {
1188
+ // return function* rootSaga() {
1189
+ // const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
1190
+ // yield all([...subSagas, ...featureSagas]);
1191
+ // };
1192
+ // }
817
1193
 
818
1194
  const servers = SERVERS; /* global SERVERS */
819
1195
  const alias = servers.alias.toLowerCase();
@@ -860,7 +1236,8 @@ const AppRoot = props => {
860
1236
 
861
1237
  exports.AppRoot = AppRoot;
862
1238
  exports.browserHistory = browserHistory;
1239
+ exports.createLocaleRoutes = createLocaleRoutes;
863
1240
  exports.history = history;
864
1241
  exports.pickProject = pickProject;
865
1242
  exports.rootSaga = rootSaga;
866
- //# sourceMappingURL=App-vZrUfVgQ.js.map
1243
+ //# sourceMappingURL=App-Dr56ZsQj.js.map