@enonic/nextjs-adapter 3.2.1 → 3.3.0-B1

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 (288) hide show
  1. package/package.json +44 -25
  2. package/src/baseMappings.ts +9 -9
  3. package/src/common/ComponentRegistry.ts +2 -5
  4. package/src/common/constants.ts +4 -4
  5. package/src/common/env.ts +1 -1
  6. package/src/guillotine/applyProcessors.ts +3 -7
  7. package/src/guillotine/buildComponentTree.ts +1 -1
  8. package/src/guillotine/buildErrorResponse.ts +3 -3
  9. package/src/guillotine/buildPage.ts +2 -2
  10. package/src/guillotine/collectComponentDescriptors.ts +6 -13
  11. package/src/guillotine/combineMultipleQueries.ts +3 -6
  12. package/src/guillotine/createMetaData.ts +2 -2
  13. package/src/guillotine/fetchContent.ts +8 -14
  14. package/src/guillotine/fetchContentData.ts +4 -10
  15. package/src/guillotine/fetchContentPathsForAllLocales.ts +3 -3
  16. package/src/guillotine/fetchContentPathsForLocale.ts +7 -7
  17. package/src/guillotine/fetchFromApi.ts +8 -8
  18. package/src/guillotine/fetchGuillotine.ts +22 -9
  19. package/src/guillotine/fetchMetaData.ts +5 -5
  20. package/src/guillotine/getCleanContentPathArrayOrThrow400.ts +2 -2
  21. package/src/guillotine/getParentRegion.ts +2 -2
  22. package/src/guillotine/getQueryAndVariables.ts +5 -9
  23. package/src/guillotine/metadata/configQuery.ts +2 -2
  24. package/src/guillotine/parseComponentPath.ts +4 -7
  25. package/src/guillotine/processComponentConfig.ts +1 -1
  26. package/src/guillotine/restrictComponentsToPath.ts +1 -1
  27. package/src/i18n/LocaleContext.tsx +3 -3
  28. package/src/index.ts +3 -3
  29. package/src/types/component.ts +1 -1
  30. package/src/types/componentProps.ts +4 -3
  31. package/src/types/guillotine.ts +1 -1
  32. package/src/types/index.ts +3 -3
  33. package/src/utils/buildGuillotineRequestHeaders.ts +4 -7
  34. package/src/utils/fixDoubleSlashes.ts +1 -1
  35. package/src/utils/getLocaleMappings.ts +1 -1
  36. package/src/utils/getRenderMode.ts +2 -5
  37. package/src/views/BaseComponent.tsx +5 -5
  38. package/src/views/BaseContent.tsx +1 -1
  39. package/src/views/BaseMacro.tsx +1 -1
  40. package/src/views/PropsView.tsx +1 -1
  41. package/src/views/RichTextView.tsx +68 -25
  42. package/src/views/StaticContent.tsx +1 -1
  43. package/baseMappings.d.ts +0 -1
  44. package/baseMappings.js +0 -43
  45. package/baseMappings.js.map +0 -1
  46. package/client/getClientHydratedHtml.d.ts +0 -1
  47. package/client/getClientHydratedHtml.jsx +0 -9
  48. package/client/getClientHydratedHtml.jsx.map +0 -1
  49. package/client.d.ts +0 -1
  50. package/client.js +0 -3
  51. package/client.js.map +0 -1
  52. package/common/ComponentRegistry.d.ts +0 -34
  53. package/common/ComponentRegistry.js +0 -121
  54. package/common/ComponentRegistry.js.map +0 -1
  55. package/common/UrlProcessor.d.ts +0 -25
  56. package/common/UrlProcessor.js +0 -151
  57. package/common/UrlProcessor.js.map +0 -1
  58. package/common/constants.d.ts +0 -51
  59. package/common/constants.js +0 -86
  60. package/common/constants.js.map +0 -1
  61. package/common/env.d.ts +0 -12
  62. package/common/env.js +0 -30
  63. package/common/env.js.map +0 -1
  64. package/guillotine/applyProcessors.d.ts +0 -2
  65. package/guillotine/applyProcessors.js +0 -33
  66. package/guillotine/applyProcessors.js.map +0 -1
  67. package/guillotine/buildComponentTree.d.ts +0 -2
  68. package/guillotine/buildComponentTree.js +0 -45
  69. package/guillotine/buildComponentTree.js.map +0 -1
  70. package/guillotine/buildErrorResponse.d.ts +0 -3
  71. package/guillotine/buildErrorResponse.js +0 -27
  72. package/guillotine/buildErrorResponse.js.map +0 -1
  73. package/guillotine/buildPage.d.ts +0 -2
  74. package/guillotine/buildPage.js +0 -10
  75. package/guillotine/buildPage.js.map +0 -1
  76. package/guillotine/collectComponentDescriptors.d.ts +0 -6
  77. package/guillotine/collectComponentDescriptors.js +0 -43
  78. package/guillotine/collectComponentDescriptors.js.map +0 -1
  79. package/guillotine/combineMultipleQueries.d.ts +0 -2
  80. package/guillotine/combineMultipleQueries.js +0 -58
  81. package/guillotine/combineMultipleQueries.js.map +0 -1
  82. package/guillotine/createMetaData.d.ts +0 -18
  83. package/guillotine/createMetaData.js +0 -45
  84. package/guillotine/createMetaData.js.map +0 -1
  85. package/guillotine/fetchContent.d.ts +0 -9
  86. package/guillotine/fetchContent.js +0 -222
  87. package/guillotine/fetchContent.js.map +0 -1
  88. package/guillotine/fetchContentData.d.ts +0 -2
  89. package/guillotine/fetchContentData.js +0 -30
  90. package/guillotine/fetchContentData.js.map +0 -1
  91. package/guillotine/fetchContentPathsForAllLocales.d.ts +0 -2
  92. package/guillotine/fetchContentPathsForAllLocales.js +0 -21
  93. package/guillotine/fetchContentPathsForAllLocales.js.map +0 -1
  94. package/guillotine/fetchContentPathsForLocale.d.ts +0 -2
  95. package/guillotine/fetchContentPathsForLocale.js +0 -41
  96. package/guillotine/fetchContentPathsForLocale.js.map +0 -1
  97. package/guillotine/fetchFromApi.d.ts +0 -3
  98. package/guillotine/fetchFromApi.js +0 -76
  99. package/guillotine/fetchFromApi.js.map +0 -1
  100. package/guillotine/fetchGuillotine.d.ts +0 -3
  101. package/guillotine/fetchGuillotine.js +0 -62
  102. package/guillotine/fetchGuillotine.js.map +0 -1
  103. package/guillotine/fetchMetaData.d.ts +0 -2
  104. package/guillotine/fetchMetaData.js +0 -33
  105. package/guillotine/fetchMetaData.js.map +0 -1
  106. package/guillotine/getCleanContentPathArrayOrThrow400.d.ts +0 -2
  107. package/guillotine/getCleanContentPathArrayOrThrow400.js +0 -20
  108. package/guillotine/getCleanContentPathArrayOrThrow400.js.map +0 -1
  109. package/guillotine/getComponentConfig.d.ts +0 -2
  110. package/guillotine/getComponentConfig.js +0 -5
  111. package/guillotine/getComponentConfig.js.map +0 -1
  112. package/guillotine/getContentAndComponentPaths.d.ts +0 -1
  113. package/guillotine/getContentAndComponentPaths.js +0 -12
  114. package/guillotine/getContentAndComponentPaths.js.map +0 -1
  115. package/guillotine/getMetaData.d.ts +0 -2
  116. package/guillotine/getMetaData.js +0 -67
  117. package/guillotine/getMetaData.js.map +0 -1
  118. package/guillotine/getParentRegion.d.ts +0 -2
  119. package/guillotine/getParentRegion.js +0 -40
  120. package/guillotine/getParentRegion.js.map +0 -1
  121. package/guillotine/getQueryAndVariables.d.ts +0 -2
  122. package/guillotine/getQueryAndVariables.js +0 -32
  123. package/guillotine/getQueryAndVariables.js.map +0 -1
  124. package/guillotine/metadata/configQuery.d.ts +0 -2
  125. package/guillotine/metadata/configQuery.js +0 -36
  126. package/guillotine/metadata/configQuery.js.map +0 -1
  127. package/guillotine/metadata/richTextQuery.d.ts +0 -1
  128. package/guillotine/metadata/richTextQuery.js +0 -47
  129. package/guillotine/metadata/richTextQuery.js.map +0 -1
  130. package/guillotine/parseComponentPath.d.ts +0 -2
  131. package/guillotine/parseComponentPath.js +0 -22
  132. package/guillotine/parseComponentPath.js.map +0 -1
  133. package/guillotine/prefixFragmentCmpPath.d.ts +0 -1
  134. package/guillotine/prefixFragmentCmpPath.js +0 -13
  135. package/guillotine/prefixFragmentCmpPath.js.map +0 -1
  136. package/guillotine/processComponentConfig.d.ts +0 -2
  137. package/guillotine/processComponentConfig.js +0 -30
  138. package/guillotine/processComponentConfig.js.map +0 -1
  139. package/guillotine/restrictComponentsToPath.d.ts +0 -2
  140. package/guillotine/restrictComponentsToPath.js +0 -38
  141. package/guillotine/restrictComponentsToPath.js.map +0 -1
  142. package/guillotine/validateData.d.ts +0 -2
  143. package/guillotine/validateData.js +0 -7
  144. package/guillotine/validateData.js.map +0 -1
  145. package/guillotine/validateNotFound.d.ts +0 -2
  146. package/guillotine/validateNotFound.js +0 -16
  147. package/guillotine/validateNotFound.js.map +0 -1
  148. package/guillotine/validateShortcut.d.ts +0 -2
  149. package/guillotine/validateShortcut.js +0 -35
  150. package/guillotine/validateShortcut.js.map +0 -1
  151. package/i18n/LocaleContext.d.ts +0 -7
  152. package/i18n/LocaleContext.jsx +0 -50
  153. package/i18n/LocaleContext.jsx.map +0 -1
  154. package/i18n/i18n.d.ts +0 -12
  155. package/i18n/i18n.js +0 -59
  156. package/i18n/i18n.js.map +0 -1
  157. package/index.d.ts +0 -14
  158. package/index.js +0 -14
  159. package/index.js.map +0 -1
  160. package/query/Shortcut.d.ts +0 -1
  161. package/query/Shortcut.js +0 -19
  162. package/query/Shortcut.js.map +0 -1
  163. package/server/getServerRenderedHtml.d.ts +0 -1
  164. package/server/getServerRenderedHtml.js +0 -4
  165. package/server/getServerRenderedHtml.js.map +0 -1
  166. package/server.d.ts +0 -5
  167. package/server.js +0 -6
  168. package/server.js.map +0 -1
  169. package/types/component.d.ts +0 -92
  170. package/types/component.js +0 -2
  171. package/types/component.js.map +0 -1
  172. package/types/componentProps.d.ts +0 -106
  173. package/types/componentProps.js +0 -2
  174. package/types/componentProps.js.map +0 -1
  175. package/types/guillotine.d.ts +0 -344
  176. package/types/guillotine.js +0 -2
  177. package/types/guillotine.js.map +0 -1
  178. package/types/i18n.d.ts +0 -7
  179. package/types/i18n.js +0 -2
  180. package/types/i18n.js.map +0 -1
  181. package/types/index.d.ts +0 -47
  182. package/types/index.js +0 -3
  183. package/types/index.js.map +0 -1
  184. package/types/next.d.ts +0 -6
  185. package/types/next.js +0 -2
  186. package/types/next.js.map +0 -1
  187. package/types/util.d.ts +0 -3
  188. package/types/util.js +0 -3
  189. package/types/util.js.map +0 -1
  190. package/utils/addLineNumbers.d.ts +0 -1
  191. package/utils/addLineNumbers.js +0 -4
  192. package/utils/addLineNumbers.js.map +0 -1
  193. package/utils/buildGuillotineRequestHeaders.d.ts +0 -7
  194. package/utils/buildGuillotineRequestHeaders.js +0 -16
  195. package/utils/buildGuillotineRequestHeaders.js.map +0 -1
  196. package/utils/commonChars.d.ts +0 -1
  197. package/utils/commonChars.js +0 -17
  198. package/utils/commonChars.js.map +0 -1
  199. package/utils/enonicLog.d.ts +0 -5
  200. package/utils/enonicLog.js +0 -23
  201. package/utils/enonicLog.js.map +0 -1
  202. package/utils/fixDoubleSlashes.d.ts +0 -1
  203. package/utils/fixDoubleSlashes.js +0 -4
  204. package/utils/fixDoubleSlashes.js.map +0 -1
  205. package/utils/getAllLocales.d.ts +0 -1
  206. package/utils/getAllLocales.js +0 -5
  207. package/utils/getAllLocales.js.map +0 -1
  208. package/utils/getContentApiUrl.d.ts +0 -2
  209. package/utils/getContentApiUrl.js +0 -15
  210. package/utils/getContentApiUrl.js.map +0 -1
  211. package/utils/getLocaleMapping.d.ts +0 -2
  212. package/utils/getLocaleMapping.js +0 -19
  213. package/utils/getLocaleMapping.js.map +0 -1
  214. package/utils/getLocaleMappingByLocale.d.ts +0 -2
  215. package/utils/getLocaleMappingByLocale.js +0 -13
  216. package/utils/getLocaleMappingByLocale.js.map +0 -1
  217. package/utils/getLocaleMappingByProjectId.d.ts +0 -2
  218. package/utils/getLocaleMappingByProjectId.js +0 -16
  219. package/utils/getLocaleMappingByProjectId.js.map +0 -1
  220. package/utils/getLocaleMappings.d.ts +0 -2
  221. package/utils/getLocaleMappings.js +0 -30
  222. package/utils/getLocaleMappings.js.map +0 -1
  223. package/utils/getRenderMode.d.ts +0 -3
  224. package/utils/getRenderMode.js +0 -8
  225. package/utils/getRenderMode.js.map +0 -1
  226. package/utils/getRequestLocaleInfo.d.ts +0 -6
  227. package/utils/getRequestLocaleInfo.js +0 -29
  228. package/utils/getRequestLocaleInfo.js.map +0 -1
  229. package/utils/getXpBaseUrl.d.ts +0 -2
  230. package/utils/getXpBaseUrl.js +0 -8
  231. package/utils/getXpBaseUrl.js.map +0 -1
  232. package/utils/indent.d.ts +0 -1
  233. package/utils/indent.js +0 -5
  234. package/utils/indent.js.map +0 -1
  235. package/utils/sanitizeGraphqlName.d.ts +0 -1
  236. package/utils/sanitizeGraphqlName.js +0 -12
  237. package/utils/sanitizeGraphqlName.js.map +0 -1
  238. package/views/BaseComponent.d.ts +0 -20
  239. package/views/BaseComponent.jsx +0 -129
  240. package/views/BaseComponent.jsx.map +0 -1
  241. package/views/BaseContent.d.ts +0 -3
  242. package/views/BaseContent.jsx +0 -38
  243. package/views/BaseContent.jsx.map +0 -1
  244. package/views/BaseLayout.d.ts +0 -3
  245. package/views/BaseLayout.jsx +0 -24
  246. package/views/BaseLayout.jsx.map +0 -1
  247. package/views/BaseMacro.d.ts +0 -6
  248. package/views/BaseMacro.jsx +0 -100
  249. package/views/BaseMacro.jsx.map +0 -1
  250. package/views/BasePage.d.ts +0 -3
  251. package/views/BasePage.jsx +0 -34
  252. package/views/BasePage.jsx.map +0 -1
  253. package/views/BasePart.d.ts +0 -3
  254. package/views/BasePart.jsx +0 -24
  255. package/views/BasePart.jsx.map +0 -1
  256. package/views/Empty.d.ts +0 -2
  257. package/views/Empty.jsx +0 -4
  258. package/views/Empty.jsx.map +0 -1
  259. package/views/Fragment.d.ts +0 -3
  260. package/views/Fragment.jsx +0 -30
  261. package/views/Fragment.jsx.map +0 -1
  262. package/views/MainView.d.ts +0 -3
  263. package/views/MainView.jsx +0 -14
  264. package/views/MainView.jsx.map +0 -1
  265. package/views/PropsView.d.ts +0 -2
  266. package/views/PropsView.jsx +0 -21
  267. package/views/PropsView.jsx.map +0 -1
  268. package/views/Region.d.ts +0 -6
  269. package/views/Region.jsx +0 -52
  270. package/views/Region.jsx.map +0 -1
  271. package/views/RichTextView.d.ts +0 -3
  272. package/views/RichTextView.jsx +0 -39
  273. package/views/RichTextView.jsx.map +0 -1
  274. package/views/SingleComponent.d.ts +0 -4
  275. package/views/SingleComponent.jsx +0 -10
  276. package/views/SingleComponent.jsx.map +0 -1
  277. package/views/StaticContent.d.ts +0 -10
  278. package/views/StaticContent.jsx +0 -37
  279. package/views/StaticContent.jsx.map +0 -1
  280. package/views/Text.d.ts +0 -8
  281. package/views/Text.jsx +0 -4
  282. package/views/Text.jsx.map +0 -1
  283. package/views/macros/DefaultMacro.d.ts +0 -3
  284. package/views/macros/DefaultMacro.jsx +0 -4
  285. package/views/macros/DefaultMacro.jsx.map +0 -1
  286. package/views/macros/DisableMacro.d.ts +0 -3
  287. package/views/macros/DisableMacro.jsx +0 -3
  288. package/views/macros/DisableMacro.jsx.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic/nextjs-adapter",
3
- "version": "3.2.1",
3
+ "version": "3.3.0-B1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "index.js",
6
6
  "author": "Pavel Milkevich <pmi@enonic.com>",
@@ -25,6 +25,23 @@
25
25
  "utils",
26
26
  "views"
27
27
  ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.js"
33
+ },
34
+ "./views/*": {
35
+ "types": "./dist/views/*.d.ts",
36
+ "import": "./dist/views/*.jsx",
37
+ "require": "./dist/views/*.jsx"
38
+ },
39
+ "./*": {
40
+ "types": "./dist/*.d.ts",
41
+ "import": "./dist/*.js",
42
+ "require": "./dist/*.js"
43
+ }
44
+ },
28
45
  "keywords": [
29
46
  "enonic",
30
47
  "nextjs",
@@ -36,8 +53,8 @@
36
53
  "access": "public"
37
54
  },
38
55
  "scripts": {
39
- "clean": "del-cli *.d.ts *.js.map baseMappings.* client.* server.* common coverage index.* enonic-nextjs-adapter-*.tgz guillotine i18n query types utils views dist server client",
40
56
  "build": "tsc",
57
+ "clean": "del-cli dist/ *.tgz",
41
58
  "check:types": "tsc --noEmit",
42
59
  "madge": "madge -i docs/madge.png -x '(constants|env)\\.ts' src/index.ts",
43
60
  "lint": "eslint --quiet --cache src",
@@ -50,43 +67,45 @@
50
67
  "test": "jest --no-cache --coverage"
51
68
  },
52
69
  "dependencies": {
53
- "@enonic/react-components": "^5.0.1",
70
+ "@enonic/react-components": "^6.0.0-RC5",
54
71
  "@formatjs/intl-localematcher": "^0.6.1",
55
72
  "gqlmin": "^0.2.2",
56
- "html-react-parser": "^5.2.2",
57
73
  "negotiator": "^1.0.0",
58
- "next": "^15.2.4",
59
- "react": "18.3.1",
60
- "react-dom": "18.3.1",
61
74
  "unescape": "^1.0.1"
62
75
  },
63
76
  "devDependencies": {
64
- "@babel/core": "^7.26.10",
65
- "@babel/preset-env": "^7.26.9",
77
+ "@babel/core": "^7.28.0",
78
+ "@babel/preset-env": "^7.28.0",
66
79
  "@edge-runtime/jest-environment": "^4.0.0",
67
- "@enonic-types/core": "^7.15.1",
80
+ "@enonic-types/core": "^7.15.3",
68
81
  "@enonic/eslint-config": "^2.0.1",
69
- "@testing-library/jest-dom": "^6.6.3",
70
- "@testing-library/react": "^16.2.0",
71
- "@types/negotiator": "^0.6.3",
72
- "@types/node": "^22.13.14",
82
+ "@testing-library/jest-dom": "^6.6.4",
83
+ "@testing-library/react": "^16.3.0",
84
+ "@types/negotiator": "^0.6.4",
85
+ "@types/node": "^24.2.1",
73
86
  "@types/react": "^18.3.12",
74
87
  "@types/react-dom": "^18.3.1",
75
- "@typescript-eslint/eslint-plugin": "^8.29.0",
76
- "@typescript-eslint/parser": "^8.29.0",
77
- "babel-jest": "^29.7.0",
78
- "concurrently": "^9.1.2",
88
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
89
+ "@typescript-eslint/parser": "^8.39.0",
90
+ "babel-jest": "^30.0.5",
91
+ "concurrently": "^9.2.0",
79
92
  "cpy-cli": "^5.0.0",
80
93
  "del-cli": "^6.0.0",
81
- "eslint": "^9.16.0",
82
- "eslint-plugin-react": "^7.37.4",
83
- "jest": "^29.7.0",
84
- "jest-environment-jsdom": "^29.7.0",
94
+ "eslint": "^9.32.0",
95
+ "eslint-plugin-react": "^7.37.5",
96
+ "jest": "^30.0.5",
97
+ "jest-environment-jsdom": "^30.0.5",
85
98
  "madge": "^8.0.0",
86
99
  "mkdirp": "^3.0.1",
87
- "ts-jest": "^29.3.0",
100
+ "ts-jest": "^29.4.1",
88
101
  "ts-node": "^10.9.2",
89
- "typescript": "^5.8.2"
102
+ "typescript": "^5.8.3"
90
103
  },
91
- "types": "index.d.ts"
104
+ "types": "index.d.ts",
105
+ "peerDependencies": {
106
+ "html-react-parser": "^5.2.6",
107
+ "next": "^15.4.5",
108
+ "react": "^18.3.1",
109
+ "react-dom": "^18.3.1"
110
+ }
92
111
  }
@@ -13,41 +13,41 @@ import {getShortcutQuery} from './query/Shortcut';
13
13
  // Base Content Types
14
14
 
15
15
  ComponentRegistry.addContentType(FRAGMENT_CONTENTTYPE_NAME, {
16
- view: FragmentView,
16
+ view: FragmentView
17
17
  });
18
18
 
19
19
  ComponentRegistry.addContentType('base:shortcut', {
20
- query: getShortcutQuery,
20
+ query: getShortcutQuery
21
21
  });
22
22
 
23
23
  // Base Components
24
24
 
25
25
  ComponentRegistry.addComponent(XP_COMPONENT_TYPE.PAGE, {
26
- view: BasePage,
26
+ view: BasePage
27
27
  });
28
28
 
29
29
  ComponentRegistry.addComponent(XP_COMPONENT_TYPE.PART, {
30
- view: BasePart,
30
+ view: BasePart
31
31
  });
32
32
 
33
33
  ComponentRegistry.addComponent(XP_COMPONENT_TYPE.LAYOUT, {
34
- view: BaseLayout,
34
+ view: BaseLayout
35
35
  });
36
36
 
37
37
  ComponentRegistry.addComponent(XP_COMPONENT_TYPE.FRAGMENT, {
38
- view: FragmentView,
38
+ view: FragmentView
39
39
  });
40
40
 
41
41
  ComponentRegistry.addComponent(XP_COMPONENT_TYPE.TEXT, {
42
- view: TextView,
42
+ view: TextView
43
43
  });
44
44
 
45
45
  // Macro mappings
46
46
  ComponentRegistry.addMacro('system:embed', {
47
47
  view: DefaultMacro,
48
- configQuery: '{body}',
48
+ configQuery: '{body}'
49
49
  });
50
50
  ComponentRegistry.addMacro('system:disable', {
51
51
  view: DisableMacro,
52
- configQuery: '{body}',
52
+ configQuery: '{body}'
53
53
  });
@@ -4,14 +4,11 @@ import type {
4
4
  ComponentDictionary,
5
5
  PageComponent,
6
6
  SelectedQueryMaybeVariablesFunc,
7
- SelectorName,
7
+ SelectorName
8
8
  } from '../types';
9
9
 
10
10
 
11
- import {
12
- CATCH_ALL,
13
- XP_COMPONENT_TYPE,
14
- } from './constants';
11
+ import {CATCH_ALL, XP_COMPONENT_TYPE} from './constants';
15
12
 
16
13
 
17
14
  function toSelectorName(type: XP_COMPONENT_TYPE): SelectorName | undefined {
@@ -4,7 +4,7 @@ export enum ENV_VARS {
4
4
  MAPPINGS = 'ENONIC_MAPPINGS',
5
5
  API_URL = 'ENONIC_API',
6
6
  APP_NAME = 'ENONIC_APP_NAME',
7
- LOG = 'ENONIC_LOGGING',
7
+ LOG = 'ENONIC_LOGGING'
8
8
  }
9
9
 
10
10
  export const FRAGMENT_CONTENTTYPE_NAME = 'portal:fragment';
@@ -49,7 +49,7 @@ export enum GUILLOTINE_REQUEST_HEADERS {
49
49
  COOKIE = 'Cookie',
50
50
  LOCALE = 'locale',
51
51
  LOCALES = 'locales',
52
- DEFAULT_LOCALE = 'default-locale',
52
+ DEFAULT_LOCALE = 'default-locale'
53
53
  }
54
54
 
55
55
  export const JSESSIONID_HEADER = 'jsessionid';
@@ -82,11 +82,11 @@ export enum XP_COMPONENT_TYPE {
82
82
  LAYOUT = 'layout',
83
83
  TEXT = 'text',
84
84
  FRAGMENT = 'fragment',
85
- PAGE = 'page',
85
+ PAGE = 'page'
86
86
  }
87
87
 
88
88
  export enum XP_REQUEST_TYPE {
89
89
  COMPONENT = 'component',
90
90
  TYPE = 'type',
91
- PAGE = 'page',
91
+ PAGE = 'page'
92
92
  }
package/src/common/env.ts CHANGED
@@ -28,7 +28,7 @@ export const MAPPINGS = isServer ? process.env[ENV_VARS.MAPPINGS] : process.env[
28
28
  const requiredConstants = {
29
29
  [ENV_VARS.APP_NAME]: APP_NAME,
30
30
  [ENV_VARS.API_URL]: API_URL,
31
- [ENV_VARS.MAPPINGS]: MAPPINGS,
31
+ [ENV_VARS.MAPPINGS]: MAPPINGS
32
32
  };
33
33
 
34
34
  // Verify required values on server-side only
@@ -1,8 +1,4 @@
1
- import type {
2
- ComponentDescriptor,
3
- ContentResult,
4
- Context,
5
- } from '../types';
1
+ import type {ComponentDescriptor, ContentResult, Context} from '../types';
6
2
 
7
3
 
8
4
  import {getComponentConfig} from './getComponentConfig';
@@ -14,7 +10,7 @@ const NO_PROPS_PROCESSOR = async (props: any) => await props ?? {};
14
10
  export async function applyProcessors(
15
11
  componentDescriptors: ComponentDescriptor[],
16
12
  contentResults: ContentResult,
17
- context: Context,
13
+ context: Context
18
14
  ): Promise < PromiseSettledResult < any > [] > {
19
15
 
20
16
  let dataCounter = 0;
@@ -35,4 +31,4 @@ export async function applyProcessors(
35
31
  });
36
32
 
37
33
  return Promise.allSettled(processorPromises);
38
- }
34
+ }
@@ -9,7 +9,7 @@ import {getParentRegion} from './getParentRegion';
9
9
  export function buildComponentTree(
10
10
  comps: PageComponent[],
11
11
  rootComp: PageComponent,
12
- contentType?: string,
12
+ contentType?: string
13
13
  ): PageComponent {
14
14
  const rootTree: RegionTree = {};
15
15
  const isFragmentType = contentType === FRAGMENT_CONTENTTYPE_NAME;
@@ -12,7 +12,7 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
12
12
  return {
13
13
  error: {
14
14
  code,
15
- message,
15
+ message
16
16
  },
17
17
  page: null,
18
18
  common: null,
@@ -28,8 +28,8 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
28
28
  apiUrl,
29
29
  baseUrl,
30
30
  locale,
31
- defaultLocale,
32
- },
31
+ defaultLocale
32
+ }
33
33
  };
34
34
  };
35
35
  }
@@ -8,8 +8,8 @@ import {buildComponentTree} from './buildComponentTree';
8
8
  export function buildPage(contentType: string, comps: PageComponent[] = []): PageComponent {
9
9
  const page: PageComponent = {
10
10
  type: XP_COMPONENT_TYPE.PAGE,
11
- path: '/',
11
+ path: '/'
12
12
  };
13
13
 
14
14
  return buildComponentTree(comps, page, contentType);
15
- }
15
+ }
@@ -1,16 +1,9 @@
1
- import type {
2
- ComponentDescriptor,
3
- Context,
4
- PageComponent,
5
- } from '../types';
1
+ import type {ComponentDescriptor, Context, PageComponent} from '../types';
6
2
 
7
3
 
8
4
  import {ComponentRegistry} from '../common/ComponentRegistry';
9
5
  import {XP_COMPONENT_TYPE} from '../common/constants';
10
- import {
11
- APP_NAME,
12
- APP_NAME_DASHED,
13
- } from '../common/env';
6
+ import {APP_NAME, APP_NAME_DASHED} from '../common/env';
14
7
  import {processComponentConfig} from './processComponentConfig';
15
8
  import {getComponentConfig} from './getComponentConfig';
16
9
  import {getQueryAndVariables} from './getQueryAndVariables';
@@ -19,7 +12,7 @@ import {getQueryAndVariables} from './getQueryAndVariables';
19
12
  export function collectComponentDescriptors({
20
13
  components,
21
14
  xpContentPath,
22
- context,
15
+ context
23
16
  }: {
24
17
  components: PageComponent[]
25
18
  xpContentPath: string
@@ -42,7 +35,7 @@ export function collectComponentDescriptors({
42
35
  descriptors.push({
43
36
  component: cmp,
44
37
  type: cmpDef,
45
- queryAndVariables: queryAndVariables,
38
+ queryAndVariables: queryAndVariables
46
39
  });
47
40
  }
48
41
  }
@@ -51,7 +44,7 @@ export function collectComponentDescriptors({
51
44
  const fragPartDescs = collectComponentDescriptors({
52
45
  components: cmp.fragment?.fragment?.components,
53
46
  xpContentPath,
54
- context,
47
+ context
55
48
  });
56
49
  if (fragPartDescs.length) {
57
50
  descriptors.push(...fragPartDescs);
@@ -60,4 +53,4 @@ export function collectComponentDescriptors({
60
53
  }
61
54
 
62
55
  return descriptors;
63
- }
56
+ }
@@ -1,7 +1,4 @@
1
- import type {
2
- ComponentDescriptor,
3
- QueryAndVariables,
4
- } from '../types';
1
+ import type {ComponentDescriptor, QueryAndVariables} from '../types';
5
2
 
6
3
 
7
4
  const ALIAS_PREFIX = 'request';
@@ -70,6 +67,6 @@ export function combineMultipleQueries(queriesWithVars: ComponentDescriptor[]):
70
67
 
71
68
  return {
72
69
  query: superQuery,
73
- variables: superVars,
70
+ variables: superVars
74
71
  };
75
- }
72
+ }
@@ -17,7 +17,7 @@ export function createMetaData({
17
17
  pageCmp, // Optional
18
18
  renderMode,
19
19
  requestedComponentPath,
20
- requestType,
20
+ requestType
21
21
  }: {
22
22
  apiUrl: string
23
23
  baseUrl: string
@@ -46,7 +46,7 @@ export function createMetaData({
46
46
  path: contentPath,
47
47
  renderMode: renderMode,
48
48
  requestType: requestType,
49
- type: contentType,
49
+ type: contentType
50
50
  };
51
51
 
52
52
  if (requestedComponentPath) {
@@ -2,13 +2,7 @@ import type {ComponentDescriptor, Context, FetchContentResult} from '../types';
2
2
 
3
3
  import {draftMode, headers} from 'next/headers';
4
4
  import {ComponentRegistry} from '../common/ComponentRegistry';
5
- import {
6
- PAGE_TEMPLATE_CONTENTTYPE_NAME,
7
- PAGE_TEMPLATE_FOLDER,
8
- RENDER_MODE,
9
- XP_COMPONENT_TYPE,
10
- XP_REQUEST_TYPE,
11
- } from '../common/constants';
5
+ import {PAGE_TEMPLATE_CONTENTTYPE_NAME, PAGE_TEMPLATE_FOLDER, RENDER_MODE, XP_COMPONENT_TYPE, XP_REQUEST_TYPE} from '../common/constants';
12
6
  import {APP_NAME, APP_NAME_DASHED, IS_DEV_MODE} from '../common/env';
13
7
  import {getContentApiUrl} from '../utils/getContentApiUrl';
14
8
  import {getLocaleMapping} from '../utils/getLocaleMapping';
@@ -59,7 +53,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
59
53
  context,
60
54
  defaultLocale,
61
55
  locale,
62
- locales,
56
+ locales
63
57
  });
64
58
  const xpBaseUrl = getXpBaseUrl(context);
65
59
  const contentApiUrl = getContentApiUrl(context);
@@ -129,7 +123,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
129
123
  if (contentQueryAndVars) {
130
124
  allDescriptors.push({
131
125
  type: contentTypeDef,
132
- queryAndVariables: contentQueryAndVars,
126
+ queryAndVariables: contentQueryAndVars
133
127
  });
134
128
  }
135
129
 
@@ -138,7 +132,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
138
132
  if (commonQueryAndVars) {
139
133
  allDescriptors.push({
140
134
  type: contentTypeDef,
141
- queryAndVariables: commonQueryAndVars,
135
+ queryAndVariables: commonQueryAndVars
142
136
  });
143
137
  }
144
138
 
@@ -150,7 +144,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
150
144
  const componentDescriptors = collectComponentDescriptors({
151
145
  components,
152
146
  xpContentPath: contentPath,
153
- context,
147
+ context
154
148
  });
155
149
  if (componentDescriptors.length) {
156
150
  allDescriptors.push(...componentDescriptors);
@@ -219,14 +213,14 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
219
213
  pageCmp: page,
220
214
  renderMode,
221
215
  requestedComponentPath: componentPath,
222
- requestType,
216
+ requestType
223
217
  });
224
218
 
225
219
  return {
226
220
  data: contentData,
227
221
  common,
228
222
  meta,
229
- page,
223
+ page
230
224
  };
231
225
  } catch (e: any) {
232
226
  console.error(e);
@@ -237,7 +231,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
237
231
  } catch (e2) {
238
232
  error = {
239
233
  code: 'Local',
240
- message: e.message,
234
+ message: e.message
241
235
  };
242
236
  }
243
237
  const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
@@ -1,10 +1,4 @@
1
- import type {
2
- ContentApiBaseBody,
3
- ContentApiBaseBodyVariables,
4
- ContentResult,
5
- LocaleMapping,
6
- GuillotineRequestHeaders,
7
- } from '../types';
1
+ import type {ContentApiBaseBody, ContentApiBaseBodyVariables, ContentResult, LocaleMapping, GuillotineRequestHeaders} from '../types';
8
2
 
9
3
  import {fetchGuillotine} from './fetchGuillotine';
10
4
 
@@ -15,7 +9,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
15
9
  mapping: LocaleMapping,
16
10
  query: string,
17
11
  variables?: ContentApiBaseBodyVariables,
18
- headers?: GuillotineRequestHeaders,
12
+ headers?: GuillotineRequestHeaders
19
13
  ): Promise<ContentResult> => {
20
14
  const body: ContentApiBaseBody = {query};
21
15
  if (variables && Object.keys(variables).length > 0) {
@@ -23,7 +17,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
23
17
  }
24
18
  const contentResults = await fetchGuillotine<ContentResult<Content>>(contentApiUrl, mapping, {
25
19
  body,
26
- headers,
20
+ headers
27
21
  });
28
22
 
29
23
  if (contentResults.error) {
@@ -31,7 +25,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
31
25
  } else {
32
26
  return {
33
27
  // omit the aliases and return values
34
- contents: Object.values(contentResults),
28
+ contents: Object.values(contentResults)
35
29
  };
36
30
  }
37
31
  };
@@ -8,12 +8,12 @@ import {fetchContentPathsForLocale} from './fetchContentPathsForLocale';
8
8
  export async function fetchContentPathsForAllLocales(
9
9
  path: string,
10
10
  query: string = GET_STATIC_PATHS_QUERY,
11
- countPerLocale = 999,
11
+ countPerLocale = 999
12
12
  ): Promise<ContentPathItem[]> {
13
13
  const promises = Object.values(getLocaleMappings()).map(
14
14
  config => fetchContentPathsForLocale(
15
- path, config, query, countPerLocale,
16
- ),
15
+ path, config, query, countPerLocale
16
+ )
17
17
  );
18
18
  return Promise.all(promises).then(results => {
19
19
  return results.reduce((all, localePaths) => all.concat(localePaths), []);
@@ -10,32 +10,32 @@ export async function fetchContentPathsForLocale(
10
10
  path: string,
11
11
  config: LocaleMapping,
12
12
  query: string = GET_STATIC_PATHS_QUERY,
13
- count = 999,
13
+ count = 999
14
14
  ): Promise<ContentPathItem[]> {
15
15
  const contentApiUrl = getContentApiUrl({
16
16
  contentPath: path,
17
- locale: config.locale,
17
+ locale: config.locale
18
18
  });
19
19
  const body: ContentApiBaseBody = {
20
20
  query,
21
21
  variables: {
22
22
  path,
23
23
  pathRegex: `/content${config.site}/*`,
24
- count,
25
- },
24
+ count
25
+ }
26
26
  };
27
27
  return fetchGuillotine<ContentPathItem[]>(contentApiUrl, config, {body}).then((
28
- results: GuillotineResult,
28
+ results: GuillotineResult
29
29
  ) => {
30
30
  return results.guillotine.queryDsl.reduce((
31
31
  prev: ContentPathItem[],
32
- child: any,
32
+ child: any
33
33
  ) => {
34
34
  const regexp = new RegExp(`^/${child.site?._name ? `${child.site._name}/?` : ''}`);
35
35
  const contentPath = child._path.replace(regexp, '');
36
36
  prev.push({
37
37
  contentPath: contentPath.split('/'),
38
- locale: config.locale,
38
+ locale: config.locale
39
39
  });
40
40
  return prev;
41
41
  }, []);
@@ -4,7 +4,7 @@ import type {FetchOptions, GuillotineResponse, GuillotineResponseJson, LocaleMap
4
4
  export async function fetchFromApi<Data = Record<string, unknown>>(
5
5
  apiUrl: string,
6
6
  mapping: LocaleMapping,
7
- options?: FetchOptions,
7
+ options?: FetchOptions
8
8
  ): Promise<GuillotineResponseJson> {
9
9
 
10
10
  const opts = {
@@ -12,7 +12,7 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
12
12
  body: options?.body ? JSON.stringify(options?.body) : null,
13
13
  headers: mergeHeaders(mapping, options?.headers),
14
14
  next: options?.next,
15
- cache: options?.cache,
15
+ cache: options?.cache
16
16
  };
17
17
 
18
18
  let res: GuillotineResponse<Data>;
@@ -22,14 +22,14 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
22
22
  console.warn(apiUrl, e);
23
23
  throw new Error(JSON.stringify({
24
24
  code: 'API',
25
- message: e.message,
25
+ message: e.message
26
26
  }));
27
27
  }
28
28
 
29
29
  if (!res.ok) {
30
30
  throw new Error(JSON.stringify({
31
31
  code: res.status,
32
- message: `Data fetching failed (message: '${await res.text()}')`,
32
+ message: `Data fetching failed (message: '${await res.text()}')`
33
33
  }));
34
34
  }
35
35
 
@@ -39,21 +39,21 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
39
39
  } catch (e) {
40
40
  throw new Error(JSON.stringify({
41
41
  code: 500,
42
- message: `API call completed but with non-JSON data: ${JSON.stringify(await res.text())}`,
42
+ message: `API call completed but with non-JSON data: ${JSON.stringify(await res.text())}`
43
43
  }));
44
44
  }
45
45
 
46
46
  if (!json) {
47
47
  throw new Error(JSON.stringify({
48
48
  code: 500,
49
- message: `API call completed but with unexpectedly empty data: ${JSON.stringify(await res.text())}`,
49
+ message: `API call completed but with unexpectedly empty data: ${JSON.stringify(await res.text())}`
50
50
  }));
51
51
  }
52
52
 
53
53
  if (Array.isArray(json)) {
54
54
  throw new Error(JSON.stringify({
55
55
  code: 500,
56
- message: `API call completed but with unexpected array data: ${JSON.stringify(json)}`,
56
+ message: `API call completed but with unexpected array data: ${JSON.stringify(json)}`
57
57
  }));
58
58
  }
59
59
 
@@ -63,7 +63,7 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
63
63
  function mergeHeaders(mapping: LocaleMapping, headers?: HeadersInit): Headers {
64
64
  const newHeaders = new Headers({
65
65
  'Accept': 'application/json',
66
- 'Content-Type': 'application/json',
66
+ 'Content-Type': 'application/json'
67
67
  });
68
68
  if (headers) {
69
69
  Object.keys(headers).forEach((headersKey) => {