@enonic/nextjs-adapter 3.3.0-B1 → 3.3.0

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 (296) hide show
  1. package/dist/baseMappings.d.ts +1 -0
  2. package/{src/baseMappings.ts → dist/baseMappings.js} +4 -14
  3. package/dist/baseMappings.js.map +1 -0
  4. package/dist/client/getClientHydratedHtml.d.ts +1 -0
  5. package/{src/client/getClientHydratedHtml.tsx → dist/client/getClientHydratedHtml.jsx} +3 -6
  6. package/dist/client/getClientHydratedHtml.jsx.map +1 -0
  7. package/dist/client.d.ts +1 -0
  8. package/dist/client.js +3 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/common/ComponentRegistry.d.ts +34 -0
  11. package/dist/common/ComponentRegistry.js +121 -0
  12. package/dist/common/ComponentRegistry.js.map +1 -0
  13. package/dist/common/UrlProcessor.d.ts +25 -0
  14. package/{src/common/UrlProcessor.ts → dist/common/UrlProcessor.js} +49 -70
  15. package/dist/common/UrlProcessor.js.map +1 -0
  16. package/dist/common/constants.d.ts +51 -0
  17. package/{src/common/constants.ts → dist/common/constants.js} +38 -44
  18. package/dist/common/constants.js.map +1 -0
  19. package/dist/common/env.d.ts +12 -0
  20. package/{src/common/env.ts → dist/common/env.js} +3 -14
  21. package/dist/common/env.js.map +1 -0
  22. package/dist/guillotine/applyProcessors.d.ts +2 -0
  23. package/dist/guillotine/applyProcessors.js +33 -0
  24. package/dist/guillotine/applyProcessors.js.map +1 -0
  25. package/dist/guillotine/buildComponentTree.d.ts +2 -0
  26. package/{src/guillotine/buildComponentTree.ts → dist/guillotine/buildComponentTree.js} +13 -25
  27. package/dist/guillotine/buildComponentTree.js.map +1 -0
  28. package/dist/guillotine/buildErrorResponse.d.ts +3 -0
  29. package/{src/guillotine/buildErrorResponse.ts → dist/guillotine/buildErrorResponse.js} +2 -10
  30. package/dist/guillotine/buildErrorResponse.js.map +1 -0
  31. package/dist/guillotine/buildPage.d.ts +2 -0
  32. package/dist/guillotine/buildPage.js +10 -0
  33. package/dist/guillotine/buildPage.js.map +1 -0
  34. package/dist/guillotine/collectComponentDescriptors.d.ts +6 -0
  35. package/{src/guillotine/collectComponentDescriptors.ts → dist/guillotine/collectComponentDescriptors.js} +13 -26
  36. package/dist/guillotine/collectComponentDescriptors.js.map +1 -0
  37. package/dist/guillotine/combineMultipleQueries.d.ts +2 -0
  38. package/{src/guillotine/combineMultipleQueries.ts → dist/guillotine/combineMultipleQueries.js} +9 -23
  39. package/dist/guillotine/combineMultipleQueries.js.map +1 -0
  40. package/dist/guillotine/createMetaData.d.ts +18 -0
  41. package/dist/guillotine/createMetaData.js +45 -0
  42. package/dist/guillotine/createMetaData.js.map +1 -0
  43. package/dist/guillotine/fetchContent.d.ts +9 -0
  44. package/dist/guillotine/fetchContent.js +222 -0
  45. package/dist/guillotine/fetchContent.js.map +1 -0
  46. package/dist/guillotine/fetchContentData.d.ts +2 -0
  47. package/dist/guillotine/fetchContentData.js +30 -0
  48. package/dist/guillotine/fetchContentData.js.map +1 -0
  49. package/dist/guillotine/fetchContentPathsForAllLocales.d.ts +2 -0
  50. package/dist/guillotine/fetchContentPathsForAllLocales.js +21 -0
  51. package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
  52. package/dist/guillotine/fetchContentPathsForLocale.d.ts +2 -0
  53. package/dist/guillotine/fetchContentPathsForLocale.js +42 -0
  54. package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -0
  55. package/dist/guillotine/fetchFromApi.d.ts +3 -0
  56. package/dist/guillotine/fetchFromApi.js +76 -0
  57. package/dist/guillotine/fetchFromApi.js.map +1 -0
  58. package/dist/guillotine/fetchGuillotine.d.ts +3 -0
  59. package/dist/guillotine/fetchGuillotine.js +75 -0
  60. package/dist/guillotine/fetchGuillotine.js.map +1 -0
  61. package/dist/guillotine/fetchMetaData.d.ts +2 -0
  62. package/dist/guillotine/fetchMetaData.js +33 -0
  63. package/dist/guillotine/fetchMetaData.js.map +1 -0
  64. package/dist/guillotine/getCleanContentPathArrayOrThrow400.d.ts +2 -0
  65. package/{src/guillotine/getCleanContentPathArrayOrThrow400.ts → dist/guillotine/getCleanContentPathArrayOrThrow400.js} +7 -9
  66. package/dist/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
  67. package/dist/guillotine/getComponentConfig.d.ts +2 -0
  68. package/{src/guillotine/getComponentConfig.ts → dist/guillotine/getComponentConfig.js} +3 -5
  69. package/dist/guillotine/getComponentConfig.js.map +1 -0
  70. package/dist/guillotine/getContentAndComponentPaths.d.ts +1 -0
  71. package/{src/guillotine/getContentAndComponentPaths.ts → dist/guillotine/getContentAndComponentPaths.js} +6 -5
  72. package/dist/guillotine/getContentAndComponentPaths.js.map +1 -0
  73. package/dist/guillotine/getMetaData.d.ts +2 -0
  74. package/{src/guillotine/getMetaData.ts → dist/guillotine/getMetaData.js} +11 -18
  75. package/dist/guillotine/getMetaData.js.map +1 -0
  76. package/dist/guillotine/getParentRegion.d.ts +2 -0
  77. package/{src/guillotine/getParentRegion.ts → dist/guillotine/getParentRegion.js} +9 -23
  78. package/dist/guillotine/getParentRegion.js.map +1 -0
  79. package/dist/guillotine/getQueryAndVariables.d.ts +2 -0
  80. package/{src/guillotine/getQueryAndVariables.ts → dist/guillotine/getQueryAndVariables.js} +7 -23
  81. package/dist/guillotine/getQueryAndVariables.js.map +1 -0
  82. package/dist/guillotine/metadata/configQuery.d.ts +2 -0
  83. package/dist/guillotine/metadata/configQuery.js +36 -0
  84. package/dist/guillotine/metadata/configQuery.js.map +1 -0
  85. package/dist/guillotine/metadata/richTextQuery.d.ts +1 -0
  86. package/{src/guillotine/metadata/richTextQuery.ts → dist/guillotine/metadata/richTextQuery.js} +6 -8
  87. package/dist/guillotine/metadata/richTextQuery.js.map +1 -0
  88. package/dist/guillotine/parseComponentPath.d.ts +2 -0
  89. package/{src/guillotine/parseComponentPath.ts → dist/guillotine/parseComponentPath.js} +4 -8
  90. package/dist/guillotine/parseComponentPath.js.map +1 -0
  91. package/dist/guillotine/prefixFragmentCmpPath.d.ts +1 -0
  92. package/{src/guillotine/prefixFragmentCmpPath.ts → dist/guillotine/prefixFragmentCmpPath.js} +5 -5
  93. package/dist/guillotine/prefixFragmentCmpPath.js.map +1 -0
  94. package/dist/guillotine/processComponentConfig.d.ts +2 -0
  95. package/{src/guillotine/processComponentConfig.ts → dist/guillotine/processComponentConfig.js} +4 -12
  96. package/dist/guillotine/processComponentConfig.js.map +1 -0
  97. package/dist/guillotine/restrictComponentsToPath.d.ts +2 -0
  98. package/{src/guillotine/restrictComponentsToPath.ts → dist/guillotine/restrictComponentsToPath.js} +9 -19
  99. package/dist/guillotine/restrictComponentsToPath.js.map +1 -0
  100. package/dist/guillotine/validateData.d.ts +2 -0
  101. package/dist/guillotine/validateData.js +7 -0
  102. package/dist/guillotine/validateData.js.map +1 -0
  103. package/dist/guillotine/validateNotFound.d.ts +2 -0
  104. package/{src/guillotine/validateNotFound.ts → dist/guillotine/validateNotFound.js} +5 -9
  105. package/dist/guillotine/validateNotFound.js.map +1 -0
  106. package/dist/guillotine/validateShortcut.d.ts +2 -0
  107. package/{src/guillotine/validateShortcut.ts → dist/guillotine/validateShortcut.js} +12 -20
  108. package/dist/guillotine/validateShortcut.js.map +1 -0
  109. package/dist/i18n/LocaleContext.d.ts +7 -0
  110. package/dist/i18n/LocaleContext.jsx +50 -0
  111. package/dist/i18n/LocaleContext.jsx.map +1 -0
  112. package/dist/i18n/i18n.d.ts +12 -0
  113. package/dist/i18n/i18n.js +59 -0
  114. package/dist/i18n/i18n.js.map +1 -0
  115. package/dist/index.d.ts +14 -0
  116. package/dist/index.js +14 -0
  117. package/dist/index.js.map +1 -0
  118. package/dist/query/Shortcut.d.ts +1 -0
  119. package/{src/query/Shortcut.ts → dist/query/Shortcut.js} +1 -0
  120. package/dist/query/Shortcut.js.map +1 -0
  121. package/dist/server/getServerRenderedHtml.d.ts +1 -0
  122. package/dist/server/getServerRenderedHtml.js +4 -0
  123. package/dist/server/getServerRenderedHtml.js.map +1 -0
  124. package/dist/server.d.ts +5 -0
  125. package/dist/server.js +6 -0
  126. package/dist/server.js.map +1 -0
  127. package/{src/types/component.ts → dist/types/component.d.ts} +23 -62
  128. package/dist/types/component.js +2 -0
  129. package/dist/types/component.js.map +1 -0
  130. package/dist/types/componentProps.d.ts +107 -0
  131. package/dist/types/componentProps.js +2 -0
  132. package/dist/types/componentProps.js.map +1 -0
  133. package/dist/types/guillotine.d.ts +344 -0
  134. package/dist/types/guillotine.js +2 -0
  135. package/dist/types/guillotine.js.map +1 -0
  136. package/dist/types/i18n.d.ts +7 -0
  137. package/dist/types/i18n.js +2 -0
  138. package/dist/types/i18n.js.map +1 -0
  139. package/{src/types/index.ts → dist/types/index.d.ts} +19 -34
  140. package/dist/types/index.js +3 -0
  141. package/dist/types/index.js.map +1 -0
  142. package/dist/types/next.d.ts +6 -0
  143. package/dist/types/next.js +2 -0
  144. package/dist/types/next.js.map +1 -0
  145. package/dist/types/util.d.ts +3 -0
  146. package/dist/types/util.js +3 -0
  147. package/dist/types/util.js.map +1 -0
  148. package/dist/utils/addLineNumbers.d.ts +1 -0
  149. package/dist/utils/addLineNumbers.js +4 -0
  150. package/dist/utils/addLineNumbers.js.map +1 -0
  151. package/dist/utils/buildGuillotineRequestHeaders.d.ts +7 -0
  152. package/dist/utils/buildGuillotineRequestHeaders.js +16 -0
  153. package/dist/utils/buildGuillotineRequestHeaders.js.map +1 -0
  154. package/dist/utils/commonChars.d.ts +1 -0
  155. package/{src/utils/commonChars.ts → dist/utils/commonChars.js} +5 -4
  156. package/dist/utils/commonChars.js.map +1 -0
  157. package/dist/utils/enonicLog.d.ts +5 -0
  158. package/dist/utils/enonicLog.js +23 -0
  159. package/dist/utils/enonicLog.js.map +1 -0
  160. package/dist/utils/fixDoubleSlashes.d.ts +1 -0
  161. package/dist/utils/fixDoubleSlashes.js +4 -0
  162. package/dist/utils/fixDoubleSlashes.js.map +1 -0
  163. package/dist/utils/getAllLocales.d.ts +1 -0
  164. package/dist/utils/getAllLocales.js +5 -0
  165. package/dist/utils/getAllLocales.js.map +1 -0
  166. package/dist/utils/getContentApiUrl.d.ts +2 -0
  167. package/dist/utils/getContentApiUrl.js +15 -0
  168. package/dist/utils/getContentApiUrl.js.map +1 -0
  169. package/dist/utils/getLocaleMapping.d.ts +2 -0
  170. package/dist/utils/getLocaleMapping.js +19 -0
  171. package/dist/utils/getLocaleMapping.js.map +1 -0
  172. package/dist/utils/getLocaleMappingByLocale.d.ts +2 -0
  173. package/dist/utils/getLocaleMappingByLocale.js +13 -0
  174. package/dist/utils/getLocaleMappingByLocale.js.map +1 -0
  175. package/dist/utils/getLocaleMappingByProjectId.d.ts +2 -0
  176. package/dist/utils/getLocaleMappingByProjectId.js +16 -0
  177. package/dist/utils/getLocaleMappingByProjectId.js.map +1 -0
  178. package/dist/utils/getLocaleMappings.d.ts +2 -0
  179. package/{src/utils/getLocaleMappings.ts → dist/utils/getLocaleMappings.js} +8 -14
  180. package/dist/utils/getLocaleMappings.js.map +1 -0
  181. package/dist/utils/getRenderMode.d.ts +3 -0
  182. package/dist/utils/getRenderMode.js +8 -0
  183. package/dist/utils/getRenderMode.js.map +1 -0
  184. package/dist/utils/getRequestLocaleInfo.d.ts +6 -0
  185. package/{src/utils/getRequestLocaleInfo.ts → dist/utils/getRequestLocaleInfo.js} +12 -13
  186. package/dist/utils/getRequestLocaleInfo.js.map +1 -0
  187. package/dist/utils/getXpBaseUrl.d.ts +2 -0
  188. package/dist/utils/getXpBaseUrl.js +8 -0
  189. package/dist/utils/getXpBaseUrl.js.map +1 -0
  190. package/dist/utils/indent.d.ts +1 -0
  191. package/dist/utils/indent.js +5 -0
  192. package/dist/utils/indent.js.map +1 -0
  193. package/dist/utils/sanitizeGraphqlName.d.ts +1 -0
  194. package/{src/utils/sanitizeGraphqlName.ts → dist/utils/sanitizeGraphqlName.js} +3 -2
  195. package/dist/utils/sanitizeGraphqlName.js.map +1 -0
  196. package/dist/views/BaseComponent.d.ts +20 -0
  197. package/{src/views/BaseComponent.tsx → dist/views/BaseComponent.jsx} +49 -76
  198. package/dist/views/BaseComponent.jsx.map +1 -0
  199. package/dist/views/BaseContent.d.ts +3 -0
  200. package/dist/views/BaseContent.jsx +38 -0
  201. package/dist/views/BaseContent.jsx.map +1 -0
  202. package/dist/views/BaseLayout.d.ts +3 -0
  203. package/dist/views/BaseLayout.jsx +24 -0
  204. package/dist/views/BaseLayout.jsx.map +1 -0
  205. package/dist/views/BaseMacro.d.ts +6 -0
  206. package/{src/views/BaseMacro.tsx → dist/views/BaseMacro.jsx} +37 -42
  207. package/dist/views/BaseMacro.jsx.map +1 -0
  208. package/dist/views/BasePage.d.ts +3 -0
  209. package/dist/views/BasePage.jsx +34 -0
  210. package/dist/views/BasePage.jsx.map +1 -0
  211. package/dist/views/BasePart.d.ts +3 -0
  212. package/dist/views/BasePart.jsx +24 -0
  213. package/dist/views/BasePart.jsx.map +1 -0
  214. package/dist/views/Empty.d.ts +2 -0
  215. package/{src/views/Empty.tsx → dist/views/Empty.jsx} +1 -2
  216. package/dist/views/Empty.jsx.map +1 -0
  217. package/dist/views/Fragment.d.ts +3 -0
  218. package/dist/views/Fragment.jsx +30 -0
  219. package/dist/views/Fragment.jsx.map +1 -0
  220. package/dist/views/MainView.d.ts +3 -0
  221. package/dist/views/MainView.jsx +14 -0
  222. package/dist/views/MainView.jsx.map +1 -0
  223. package/dist/views/PropsView.d.ts +2 -0
  224. package/dist/views/PropsView.jsx +21 -0
  225. package/dist/views/PropsView.jsx.map +1 -0
  226. package/dist/views/Region.d.ts +6 -0
  227. package/{src/views/Region.tsx → dist/views/Region.jsx} +17 -41
  228. package/dist/views/Region.jsx.map +1 -0
  229. package/dist/views/RichTextView.d.ts +3 -0
  230. package/dist/views/RichTextView.jsx +65 -0
  231. package/dist/views/RichTextView.jsx.map +1 -0
  232. package/dist/views/SingleComponent.d.ts +4 -0
  233. package/dist/views/SingleComponent.jsx +10 -0
  234. package/dist/views/SingleComponent.jsx.map +1 -0
  235. package/dist/views/StaticContent.d.ts +10 -0
  236. package/dist/views/StaticContent.jsx +37 -0
  237. package/dist/views/StaticContent.jsx.map +1 -0
  238. package/dist/views/Text.d.ts +8 -0
  239. package/dist/views/Text.jsx +4 -0
  240. package/dist/views/Text.jsx.map +1 -0
  241. package/dist/views/macros/DefaultMacro.d.ts +3 -0
  242. package/dist/views/macros/DefaultMacro.jsx +4 -0
  243. package/dist/views/macros/DefaultMacro.jsx.map +1 -0
  244. package/dist/views/macros/DisableMacro.d.ts +3 -0
  245. package/dist/views/macros/DisableMacro.jsx +3 -0
  246. package/dist/views/macros/DisableMacro.jsx.map +1 -0
  247. package/package.json +20 -32
  248. package/src/client.ts +0 -2
  249. package/src/common/ComponentRegistry.ts +0 -159
  250. package/src/guillotine/applyProcessors.ts +0 -34
  251. package/src/guillotine/buildPage.ts +0 -15
  252. package/src/guillotine/createMetaData.ts +0 -72
  253. package/src/guillotine/fetchContent.ts +0 -240
  254. package/src/guillotine/fetchContentData.ts +0 -31
  255. package/src/guillotine/fetchContentPathsForAllLocales.ts +0 -21
  256. package/src/guillotine/fetchContentPathsForLocale.ts +0 -43
  257. package/src/guillotine/fetchFromApi.ts +0 -76
  258. package/src/guillotine/fetchGuillotine.ts +0 -76
  259. package/src/guillotine/fetchMetaData.ts +0 -31
  260. package/src/guillotine/metadata/configQuery.ts +0 -46
  261. package/src/guillotine/validateData.ts +0 -11
  262. package/src/i18n/LocaleContext.tsx +0 -59
  263. package/src/i18n/i18n.ts +0 -57
  264. package/src/index.ts +0 -42
  265. package/src/server/getServerRenderedHtml.ts +0 -3
  266. package/src/server.ts +0 -5
  267. package/src/types/componentProps.ts +0 -143
  268. package/src/types/guillotine.ts +0 -428
  269. package/src/types/i18n.ts +0 -8
  270. package/src/types/next.ts +0 -7
  271. package/src/types/util.ts +0 -5
  272. package/src/utils/addLineNumbers.ts +0 -3
  273. package/src/utils/buildGuillotineRequestHeaders.ts +0 -29
  274. package/src/utils/enonicLog.ts +0 -28
  275. package/src/utils/fixDoubleSlashes.ts +0 -3
  276. package/src/utils/getAllLocales.ts +0 -6
  277. package/src/utils/getContentApiUrl.ts +0 -20
  278. package/src/utils/getLocaleMapping.ts +0 -24
  279. package/src/utils/getLocaleMappingByLocale.ts +0 -19
  280. package/src/utils/getLocaleMappingByProjectId.ts +0 -21
  281. package/src/utils/getRenderMode.ts +0 -11
  282. package/src/utils/getXpBaseUrl.ts +0 -12
  283. package/src/utils/indent.ts +0 -4
  284. package/src/views/BaseContent.tsx +0 -47
  285. package/src/views/BaseLayout.tsx +0 -33
  286. package/src/views/BasePage.tsx +0 -42
  287. package/src/views/BasePart.tsx +0 -34
  288. package/src/views/Fragment.tsx +0 -41
  289. package/src/views/MainView.tsx +0 -22
  290. package/src/views/PropsView.tsx +0 -38
  291. package/src/views/RichTextView.tsx +0 -106
  292. package/src/views/SingleComponent.tsx +0 -19
  293. package/src/views/StaticContent.tsx +0 -39
  294. package/src/views/Text.tsx +0 -19
  295. package/src/views/macros/DefaultMacro.tsx +0 -9
  296. package/src/views/macros/DisableMacro.tsx +0 -8
@@ -1,15 +1,13 @@
1
1
  export const CATCH_ALL = '*';
2
-
3
- export enum ENV_VARS {
4
- MAPPINGS = 'ENONIC_MAPPINGS',
5
- API_URL = 'ENONIC_API',
6
- APP_NAME = 'ENONIC_APP_NAME',
7
- LOG = 'ENONIC_LOGGING'
8
- }
9
-
2
+ export var ENV_VARS;
3
+ (function (ENV_VARS) {
4
+ ENV_VARS["MAPPINGS"] = "ENONIC_MAPPINGS";
5
+ ENV_VARS["API_URL"] = "ENONIC_API";
6
+ ENV_VARS["APP_NAME"] = "ENONIC_APP_NAME";
7
+ ENV_VARS["LOG"] = "ENONIC_LOGGING";
8
+ })(ENV_VARS || (ENV_VARS = {}));
10
9
  export const FRAGMENT_CONTENTTYPE_NAME = 'portal:fragment';
11
10
  export const FRAGMENT_DEFAULT_REGION_NAME = 'fragment';
12
-
13
11
  /** excluded contents:
14
12
  * - folder
15
13
  * - shortcuts (redirect can't be used in prerender)
@@ -42,51 +40,47 @@ export const GET_STATIC_PATHS_QUERY = `query ($pathRegex: String!, $count: Int)
42
40
  }
43
41
  }
44
42
  }`;
45
-
46
43
  // Seems like NodeJS.fetch lowercases all headers, so we need to lowercase the
47
44
  // header names here.
48
- export enum GUILLOTINE_REQUEST_HEADERS {
49
- COOKIE = 'Cookie',
50
- LOCALE = 'locale',
51
- LOCALES = 'locales',
52
- DEFAULT_LOCALE = 'default-locale'
53
- }
54
-
45
+ export var GUILLOTINE_REQUEST_HEADERS;
46
+ (function (GUILLOTINE_REQUEST_HEADERS) {
47
+ GUILLOTINE_REQUEST_HEADERS["COOKIE"] = "Cookie";
48
+ GUILLOTINE_REQUEST_HEADERS["LOCALE"] = "locale";
49
+ GUILLOTINE_REQUEST_HEADERS["LOCALES"] = "locales";
50
+ GUILLOTINE_REQUEST_HEADERS["DEFAULT_LOCALE"] = "default-locale";
51
+ })(GUILLOTINE_REQUEST_HEADERS || (GUILLOTINE_REQUEST_HEADERS = {}));
55
52
  export const JSESSIONID_HEADER = 'jsessionid';
56
-
57
53
  export const PAGE_TEMPLATE_CONTENTTYPE_NAME = 'portal:page-template';
58
54
  export const PAGE_TEMPLATE_FOLDER = 'portal:template-folder';
59
55
  export const PORTAL_COMPONENT_ATTRIBUTE = 'data-portal-component-type';
60
56
  export const PORTAL_REGION_ATTRIBUTE = 'data-portal-region';
61
57
  export const PROJECT_ID_HEADER = 'content-studio-project';
62
-
63
- export enum RENDER_MODE {
64
- INLINE = 'inline',
65
- EDIT = 'edit',
66
- PREVIEW = 'preview',
67
- LIVE = 'live',
68
- ADMIN = 'admin',
69
- NEXT = 'next' // Fallback: not using XP proxy but rendering directly with next.js
70
- }
71
-
58
+ export var RENDER_MODE;
59
+ (function (RENDER_MODE) {
60
+ RENDER_MODE["INLINE"] = "inline";
61
+ RENDER_MODE["EDIT"] = "edit";
62
+ RENDER_MODE["PREVIEW"] = "preview";
63
+ RENDER_MODE["LIVE"] = "live";
64
+ RENDER_MODE["ADMIN"] = "admin";
65
+ RENDER_MODE["NEXT"] = "next"; // Fallback: not using XP proxy but rendering directly with next.js
66
+ })(RENDER_MODE || (RENDER_MODE = {}));
72
67
  export const RENDER_MODE_HEADER = 'content-studio-mode';
73
-
74
68
  export const SITE_CONTENTTYPE_NAME = 'portal:site';
75
-
76
69
  // URI parameter marking that a request is for a preview for CS. MUST MATCH THE VALUE OF 'FROM_XP_PARAM' on XP side.
77
70
  export const XP_BASE_URL_HEADER = 'xpbaseurl';
78
-
79
71
  // TODO: Use these instead of hardcoded strings everywhere
80
- export enum XP_COMPONENT_TYPE {
81
- PART = 'part',
82
- LAYOUT = 'layout',
83
- TEXT = 'text',
84
- FRAGMENT = 'fragment',
85
- PAGE = 'page'
86
- }
87
-
88
- export enum XP_REQUEST_TYPE {
89
- COMPONENT = 'component',
90
- TYPE = 'type',
91
- PAGE = 'page'
92
- }
72
+ export var XP_COMPONENT_TYPE;
73
+ (function (XP_COMPONENT_TYPE) {
74
+ XP_COMPONENT_TYPE["PART"] = "part";
75
+ XP_COMPONENT_TYPE["LAYOUT"] = "layout";
76
+ XP_COMPONENT_TYPE["TEXT"] = "text";
77
+ XP_COMPONENT_TYPE["FRAGMENT"] = "fragment";
78
+ XP_COMPONENT_TYPE["PAGE"] = "page";
79
+ })(XP_COMPONENT_TYPE || (XP_COMPONENT_TYPE = {}));
80
+ export var XP_REQUEST_TYPE;
81
+ (function (XP_REQUEST_TYPE) {
82
+ XP_REQUEST_TYPE["COMPONENT"] = "component";
83
+ XP_REQUEST_TYPE["TYPE"] = "type";
84
+ XP_REQUEST_TYPE["PAGE"] = "page";
85
+ })(XP_REQUEST_TYPE || (XP_REQUEST_TYPE = {}));
86
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG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AG,aAAa,CAAC;AAEnD,oHAAoH;AACpH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE9C,0DAA0D;AAC1D,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IACzB,kCAAa,CAAA;IACb,sCAAiB,CAAA;IACjB,kCAAa,CAAA;IACb,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACjB,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAED,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,0CAAuB,CAAA;IACvB,gCAAa,CAAA;IACb,gCAAa,CAAA;AACjB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B"}
@@ -0,0 +1,12 @@
1
+ /** URL to the guillotine API */
2
+ export declare const API_URL: string;
3
+ /** Optional utility value - defining in one place the name of the target app (the app that defines the content types, the app name is therefore part of the content type strings used both in typeselector and in query introspections) */
4
+ export declare const APP_NAME: string;
5
+ /** Optional utility value - derived from APP_NAME, only with underscores instead of dots */
6
+ export declare const APP_NAME_UNDERSCORED: string;
7
+ /** Optional utility value - derived from APP_NAME, only with dashes instead of dots */
8
+ export declare const APP_NAME_DASHED: string;
9
+ export declare const IS_DEV_MODE: boolean;
10
+ export declare const LOGGING: string;
11
+ /** Locales and Enonic XP projects correspondence list */
12
+ export declare const MAPPINGS: string;
@@ -1,41 +1,30 @@
1
- import {ENV_VARS} from './constants';
2
-
1
+ import { ENV_VARS } from './constants';
3
2
  const isServer = typeof window === 'undefined';
4
-
5
3
  // IMPORTANT:
6
4
  // NEXT_PUBLIC_ vars should be explicitly referenced to be made available on the client side (substituted with constants) !!!
7
5
  /** URL to the guillotine API */
8
6
  export const API_URL = isServer ? process.env[ENV_VARS.API_URL] : process.env['NEXT_PUBLIC_ENONIC_API'];
9
-
10
7
  /** Optional utility value - defining in one place the name of the target app (the app that defines the content types, the app name is therefore part of the content type strings used both in typeselector and in query introspections) */
11
8
  export const APP_NAME = isServer ? process.env[ENV_VARS.APP_NAME] : process.env['NEXT_PUBLIC_ENONIC_APP_NAME'];
12
-
13
9
  /** Optional utility value - derived from APP_NAME, only with underscores instead of dots */
14
10
  export const APP_NAME_UNDERSCORED = (APP_NAME || '').replace(/\./g, '_');
15
-
16
11
  /** Optional utility value - derived from APP_NAME, only with dashes instead of dots */
17
12
  export const APP_NAME_DASHED = (APP_NAME || '').replace(/\./g, '-');
18
-
19
13
  const mode = isServer ? process.env.MODE : process.env.NEXT_PUBLIC_MODE;
20
-
21
14
  export const IS_DEV_MODE = (mode === 'development');
22
-
23
15
  export const LOGGING = isServer ? process.env[ENV_VARS.LOG] : process.env['NEXT_PUBLIC_ENONIC_LOGGING'];
24
-
25
16
  /** Locales and Enonic XP projects correspondence list */
26
17
  export const MAPPINGS = isServer ? process.env[ENV_VARS.MAPPINGS] : process.env['NEXT_PUBLIC_ENONIC_MAPPINGS'];
27
-
28
18
  const requiredConstants = {
29
19
  [ENV_VARS.APP_NAME]: APP_NAME,
30
20
  [ENV_VARS.API_URL]: API_URL,
31
21
  [ENV_VARS.MAPPINGS]: MAPPINGS
32
22
  };
33
-
34
23
  // Verify required values on server-side only
35
- Object.keys(requiredConstants).forEach((key: string) => {
24
+ Object.keys(requiredConstants).forEach((key) => {
36
25
  const val = requiredConstants[key];
37
26
  if (!val) {
38
27
  throw new Error(`Environment variable '${isServer ? '' : 'NEXT_PUBLIC_'}${key}' is missing (from .env?)`);
39
28
  }
40
29
  });
41
-
30
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/common/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAErC,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAE/C,aAAa;AACb,6HAA6H;AAC7H,gCAAgC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAA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QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO;IAC3B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ;CAChC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,GAAG,2BAA2B,CAAC,CAAC;IAC9G,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ComponentDescriptor, ContentResult, Context } from '../types';
2
+ export declare function applyProcessors(componentDescriptors: ComponentDescriptor[], contentResults: ContentResult, context: Context): Promise<PromiseSettledResult<any>[]>;
@@ -0,0 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getComponentConfig } from './getComponentConfig';
11
+ const NO_PROPS_PROCESSOR = (props) => __awaiter(void 0, void 0, void 0, function* () { var _a; return (_a = yield props) !== null && _a !== void 0 ? _a : {}; });
12
+ export function applyProcessors(componentDescriptors, contentResults, context) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ let dataCounter = 0;
15
+ const processorPromises = componentDescriptors.map((desc) => __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ // we're iterating component descriptors here
18
+ // some of them might not have provided graphql requests
19
+ // but we still need to run props processor for them
20
+ // in case they want to fetch their data from elsewhere
21
+ const propsProcessor = ((_a = desc.type) === null || _a === void 0 ? void 0 : _a.processor) || NO_PROPS_PROCESSOR;
22
+ let data;
23
+ if (desc.queryAndVariables) {
24
+ // if there is a query then there must be a result for it
25
+ data = contentResults.contents[dataCounter++];
26
+ }
27
+ const config = getComponentConfig(desc.component);
28
+ return yield propsProcessor(data, context, config);
29
+ }));
30
+ return Promise.allSettled(processorPromises);
31
+ });
32
+ }
33
+ //# sourceMappingURL=applyProcessors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyProcessors.js","sourceRoot":"","sources":["../../src/guillotine/applyProcessors.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAGxD,MAAM,kBAAkB,GAAG,CAAO,KAAU,EAAE,EAAE,0DAAC,OAAA,MAAA,MAAM,KAAK,mCAAI,EAAE,CAAA,GAAA,CAAC;AAGnE,MAAM,UAAgB,eAAe,CACjC,oBAA2C,EAC3C,cAA6B,EAC7B,OAAgB;;QAGhB,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAO,IAAyB,EAAE,EAAE;;YACnF,6CAA6C;YAC7C,wDAAwD;YACxD,oDAAoD;YACpD,uDAAuD;YACvD,MAAM,cAAc,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,SAAS,KAAI,kBAAkB,CAAC;YAClE,IAAI,IAAI,CAAC;YACT,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACzB,yDAAyD;gBACzD,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAClD,OAAO,MAAM,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC,CAAA,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACjD,CAAC;CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { PageComponent } from '../types';
2
+ export declare function buildComponentTree(comps: PageComponent[], rootComp: PageComponent, contentType?: string): PageComponent;
@@ -1,57 +1,45 @@
1
- import type {PageComponent, RegionTree} from '../types';
2
-
3
-
4
- import {FRAGMENT_CONTENTTYPE_NAME, XP_COMPONENT_TYPE} from '../common/constants';
5
- import {parseComponentPath} from './parseComponentPath';
6
- import {getParentRegion} from './getParentRegion';
7
-
8
-
9
- export function buildComponentTree(
10
- comps: PageComponent[],
11
- rootComp: PageComponent,
12
- contentType?: string
13
- ): PageComponent {
14
- const rootTree: RegionTree = {};
1
+ import { FRAGMENT_CONTENTTYPE_NAME, XP_COMPONENT_TYPE } from '../common/constants';
2
+ import { parseComponentPath } from './parseComponentPath';
3
+ import { getParentRegion } from './getParentRegion';
4
+ export function buildComponentTree(comps, rootComp, contentType) {
5
+ const rootTree = {};
15
6
  const isFragmentType = contentType === FRAGMENT_CONTENTTYPE_NAME;
16
-
17
7
  if (isFragmentType) {
18
8
  rootComp.regions = rootTree;
19
9
  }
20
-
21
10
  (comps || []).forEach(cmp => {
11
+ var _a, _b, _c;
22
12
  const cmpPath = parseComponentPath(contentType, cmp.path);
23
-
24
13
  if (cmp.path === '/') {
25
14
  if (cmp.type === XP_COMPONENT_TYPE.PAGE && rootComp.type === XP_COMPONENT_TYPE.PAGE) {
26
15
  // add page values to page object
27
16
  rootComp = Object.assign(rootComp, cmp);
28
17
  rootComp.page.regions = rootTree;
29
18
  return;
30
- } else if (cmp.type === XP_COMPONENT_TYPE.LAYOUT && rootComp.type === XP_COMPONENT_TYPE.FRAGMENT) {
19
+ }
20
+ else if (cmp.type === XP_COMPONENT_TYPE.LAYOUT && rootComp.type === XP_COMPONENT_TYPE.FRAGMENT) {
31
21
  // when rendering fragment as part of the page with layout at root path
32
22
  // remove other children from list as they will be included in layout
33
23
  rootComp.fragment.fragment.components = [cmp];
34
24
  cmp.regions = rootTree;
35
25
  }
36
26
  }
37
-
38
27
  if (cmp.type === XP_COMPONENT_TYPE.FRAGMENT) {
39
28
  // build component subtree for fragment
40
- cmp = buildComponentTree(cmp.fragment?.fragment?.components, cmp, contentType);
29
+ cmp = buildComponentTree((_b = (_a = cmp.fragment) === null || _a === void 0 ? void 0 : _a.fragment) === null || _b === void 0 ? void 0 : _b.components, cmp, contentType);
41
30
  }
42
-
43
31
  const region = getParentRegion(rootTree, contentType, cmpPath, comps, true);
44
-
45
32
  if (region) {
46
33
  // getting the index of component from string like '/main/0/left/11'
47
- const cmpIndex = cmpPath[cmpPath.length - 1]?.index;
34
+ const cmpIndex = (_c = cmpPath[cmpPath.length - 1]) === null || _c === void 0 ? void 0 : _c.index;
48
35
  if (cmpIndex >= 0) {
49
36
  region.components.splice(cmpIndex, 0, cmp);
50
- } else {
37
+ }
38
+ else {
51
39
  throw Error(`Could not find [${cmp.type}] component index at ${JSON.stringify(cmpPath, null, 2)}, rendering not possible.`);
52
40
  }
53
41
  }
54
42
  });
55
-
56
43
  return rootComp;
57
44
  }
45
+ //# sourceMappingURL=buildComponentTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildComponentTree.js","sourceRoot":"","sources":["../../src/guillotine/buildComponentTree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,yBAAyB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,UAAU,kBAAkB,CAC9B,KAAsB,EACtB,QAAuB,EACvB,WAAoB;IAEpB,MAAM,QAAQ,GAAe,EAAE,CAAC;IAChC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,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAE5E,IAAI,MAAM,EAAE,CAAC;YACT,oEAAoE;YACpE,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC;YACpD,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;gBAChB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACJ,MAAM,KAAK,CAAC,mBAAmB,GAAG,CAAC,IAAI,wBAAwB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC;YAChI,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FetchContentResult } from '../types';
2
+ import { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
3
+ export declare function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE, apiUrl: string, baseUrl: string, locale: string, defaultLocale: string, contentPath?: string, contentId?: string): (code?: string, message?: string) => FetchContentResult;
@@ -1,13 +1,4 @@
1
- import type {FetchContentResult} from '../types';
2
-
3
-
4
- import {RENDER_MODE, XP_REQUEST_TYPE} from '../common/constants';
5
-
6
-
7
- export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE,
8
- apiUrl: string, baseUrl: string, locale: string, defaultLocale: string,
9
- contentPath ?: string, contentId?: string): (code ?: string, message ?: string) => FetchContentResult {
10
-
1
+ export function buildErrorResponse(requestType, renderMode, apiUrl, baseUrl, locale, defaultLocale, contentPath, contentId) {
11
2
  return function (code = '500', message = 'Unknown error') {
12
3
  return {
13
4
  error: {
@@ -33,3 +24,4 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
33
24
  };
34
25
  };
35
26
  }
27
+ //# sourceMappingURL=buildErrorResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildErrorResponse.js","sourceRoot":"","sources":["../../src/guillotine/buildErrorResponse.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,kBAAkB,CAAC,WAA4B,EAAE,UAAuB,EACpF,MAAc,EAAE,OAAe,EAAE,MAAc,EAAE,aAAqB,EACvC,WAAqB,EAAE,SAAkB;IAExE,OAAO,UAAU,IAAI,GAAG,KAAK,EAAE,OAAO,GAAG,eAAe;QACpD,OAAO;YACH,KAAK,EAAE;gBACH,IAAI;gBACJ,OAAO;aACV;YACD,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACF,EAAE,EAAE,SAAS,IAAI,EAAE;gBACnB,IAAI,EAAE,EAAE;gBACR,WAAW,EAAE,WAAW;gBACxB,UAAU,EAAE,UAAU;gBACtB,IAAI,EAAE,WAAW,IAAI,EAAE;gBACvB,SAAS,EAAE,KAAK;gBAChB,QAAQ,EAAE,KAAK;gBACf,MAAM;gBACN,OAAO;gBACP,MAAM;gBACN,aAAa;aAChB;SACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { PageComponent } from '../types';
2
+ export declare function buildPage(contentType: string, comps?: PageComponent[]): PageComponent;
@@ -0,0 +1,10 @@
1
+ import { XP_COMPONENT_TYPE } from '../common/constants';
2
+ import { buildComponentTree } from './buildComponentTree';
3
+ export function buildPage(contentType, comps = []) {
4
+ const page = {
5
+ type: XP_COMPONENT_TYPE.PAGE,
6
+ path: '/'
7
+ };
8
+ return buildComponentTree(comps, page, contentType);
9
+ }
10
+ //# sourceMappingURL=buildPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPage.js","sourceRoot":"","sources":["../../src/guillotine/buildPage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAGxD,MAAM,UAAU,SAAS,CAAC,WAAmB,EAAE,QAAyB,EAAE;IACtE,MAAM,IAAI,GAAkB;QACxB,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,IAAI,EAAE,GAAG;KACZ,CAAC;IAEF,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ComponentDescriptor, Context, PageComponent } from '../types';
2
+ export declare function collectComponentDescriptors({ components, xpContentPath, context }: {
3
+ components: PageComponent[];
4
+ xpContentPath: string;
5
+ context: Context;
6
+ }): ComponentDescriptor[];
@@ -1,26 +1,12 @@
1
- import type {ComponentDescriptor, Context, PageComponent} from '../types';
2
-
3
-
4
- import {ComponentRegistry} from '../common/ComponentRegistry';
5
- import {XP_COMPONENT_TYPE} from '../common/constants';
6
- import {APP_NAME, APP_NAME_DASHED} from '../common/env';
7
- import {processComponentConfig} from './processComponentConfig';
8
- import {getComponentConfig} from './getComponentConfig';
9
- import {getQueryAndVariables} from './getQueryAndVariables';
10
-
11
-
12
- export function collectComponentDescriptors({
13
- components,
14
- xpContentPath,
15
- context
16
- }: {
17
- components: PageComponent[]
18
- xpContentPath: string
19
- context: Context
20
- }): ComponentDescriptor[] {
21
-
22
- const descriptors: ComponentDescriptor[] = [];
23
-
1
+ import { ComponentRegistry } from '../common/ComponentRegistry';
2
+ import { XP_COMPONENT_TYPE } from '../common/constants';
3
+ import { APP_NAME, APP_NAME_DASHED } from '../common/env';
4
+ import { processComponentConfig } from './processComponentConfig';
5
+ import { getComponentConfig } from './getComponentConfig';
6
+ import { getQueryAndVariables } from './getQueryAndVariables';
7
+ export function collectComponentDescriptors({ components, xpContentPath, context }) {
8
+ var _a, _b;
9
+ const descriptors = [];
24
10
  for (const cmp of (components || [])) {
25
11
  processComponentConfig(APP_NAME, APP_NAME_DASHED, cmp);
26
12
  // only look for parts
@@ -39,10 +25,11 @@ export function collectComponentDescriptors({
39
25
  });
40
26
  }
41
27
  }
42
- } else {
28
+ }
29
+ else {
43
30
  // look for parts inside fragments
44
31
  const fragPartDescs = collectComponentDescriptors({
45
- components: cmp.fragment?.fragment?.components,
32
+ components: (_b = (_a = cmp.fragment) === null || _a === void 0 ? void 0 : _a.fragment) === null || _b === void 0 ? void 0 : _b.components,
46
33
  xpContentPath,
47
34
  context
48
35
  });
@@ -51,6 +38,6 @@ export function collectComponentDescriptors({
51
38
  }
52
39
  }
53
40
  }
54
-
55
41
  return descriptors;
56
42
  }
43
+ //# sourceMappingURL=collectComponentDescriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectComponentDescriptors.js","sourceRoot":"","sources":["../../src/guillotine/collectComponentDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAG5D,MAAM,UAAU,2BAA2B,CAAC,EACxC,UAAU,EACV,aAAa,EACb,OAAO,EAKV;;IAEG,MAAM,WAAW,GAA0B,EAAE,CAAC;IAE9C,KAAK,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QACnC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC;QACvD,sBAAsB;QACtB,2DAA2D;QAC3D,IAAI,iBAAiB,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YACrD,IAAI,MAAM,EAAE,CAAC;gBACT,6DAA6D;gBAC7D,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;gBACvC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACvG,IAAI,iBAAiB,EAAE,CAAC;oBACpB,WAAW,CAAC,IAAI,CAAC;wBACb,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,MAAM;wBACZ,iBAAiB,EAAE,iBAAiB;qBACvC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,kCAAkC;YAClC,MAAM,aAAa,GAAG,2BAA2B,CAAC;gBAC9C,UAAU,EAAE,MAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,QAAQ,0CAAE,UAAU;gBAC9C,aAAa;gBACb,OAAO;aACV,CAAC,CAAC;YACH,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;YACvC,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ComponentDescriptor, QueryAndVariables } from '../types';
2
+ export declare function combineMultipleQueries(queriesWithVars: ComponentDescriptor[]): QueryAndVariables;
@@ -1,40 +1,29 @@
1
- import type {ComponentDescriptor, QueryAndVariables} from '../types';
2
-
3
-
4
1
  const ALIAS_PREFIX = 'request';
5
-
6
2
  const GRAPHQL_FRAGMENTS_REGEXP = /fragment\s+.+\s+on\s+.+\s*{[\s\w{}().,:"'`]+}/;
7
-
8
3
  const GUILLOTINE_QUERY_REGEXP = /^\s*query\s*(?:\((.*)*\))?\s*{\s*guillotine\s*{((?:.|\s)+)}\s*}\s*$/;
9
-
10
-
11
- export function combineMultipleQueries(queriesWithVars: ComponentDescriptor[]): QueryAndVariables {
12
- const queries: string[] = [];
13
- const fragments: string[] = [];
14
- const superVars: Record<string,any> = {};
15
- const superParams: string[] = [];
16
-
17
- queriesWithVars.forEach((componentDescriptor: ComponentDescriptor, index: number) => {
4
+ export function combineMultipleQueries(queriesWithVars) {
5
+ const queries = [];
6
+ const fragments = [];
7
+ const superVars = {};
8
+ const superParams = [];
9
+ queriesWithVars.forEach((componentDescriptor, index) => {
18
10
  const queryAndVars = componentDescriptor.queryAndVariables;
19
11
  if (!queryAndVars) {
20
12
  return;
21
13
  }
22
-
23
14
  // Extract fragments first if exist
24
15
  let q = queryAndVars.query;
25
16
  let match = q.match(GRAPHQL_FRAGMENTS_REGEXP);
26
- if (match?.length === 1) {
17
+ if ((match === null || match === void 0 ? void 0 : match.length) === 1) {
27
18
  // extract a fragment to put it at root level
28
19
  fragments.push(match[0]);
29
20
  // remove it from query because queries are going to get wrapped
30
21
  q = q.replace(match[0], '');
31
22
  }
32
-
33
23
  // Extract graphql query and its params and add prefixes to exclude collisions with other queries
34
24
  match = q.match(GUILLOTINE_QUERY_REGEXP) || ['']; // Fall back to empty string if no match
35
25
  const args = match[1];
36
26
  let query = match[2];
37
-
38
27
  if (args) {
39
28
  args.split(',').forEach(originalParamString => {
40
29
  const [originalKey, originalVal] = originalParamString.trim().split(':');
@@ -47,26 +36,23 @@ export function combineMultipleQueries(queriesWithVars: ComponentDescriptor[]):
47
36
  query = query.replace(origKeyPattern, prefixedKey);
48
37
  });
49
38
  }
50
-
51
- if (query?.length) {
39
+ if (query === null || query === void 0 ? void 0 : query.length) {
52
40
  queries.push(`${ALIAS_PREFIX}${index}:guillotine {${query}}`);
53
41
  }
54
-
55
42
  // Update variables with the same prefixes
56
43
  Object.entries(queryAndVars.variables || {}).forEach(entry => {
57
44
  superVars[`${ALIAS_PREFIX}${index}_${entry[0]}`] = entry[1];
58
45
  });
59
46
  });
60
-
61
47
  // Compose the super query
62
48
  const superQuery = `query ${superParams.length ? `(${superParams.join(', ')})` : ''} {
63
49
  ${queries.join('\n')}
64
50
  }
65
51
  ${fragments.join('\n')}
66
52
  `;
67
-
68
53
  return {
69
54
  query: superQuery,
70
55
  variables: superVars
71
56
  };
72
57
  }
58
+ //# sourceMappingURL=combineMultipleQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combineMultipleQueries.js","sourceRoot":"","sources":["../../src/guillotine/combineMultipleQueries.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,MAAM,wBAAwB,GAAG,+CAA+C,CAAC;AAEjF,MAAM,uBAAuB,GAAG,qEAAqE,CAAC;AAGtG,MAAM,UAAU,sBAAsB,CAAC,eAAsC;IACzE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAuB,EAAE,CAAC;IACzC,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,eAAe,CAAC,OAAO,CAAC,CAAC,mBAAwC,EAAE,KAAa,EAAE,EAAE;QAChF,MAAM,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC;QAC3D,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QAED,mCAAmC;QACnC,IAAI,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;QAC3B,IAAI,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,MAAK,CAAC,EAAE,CAAC;YACtB,6CAA6C;YAC7C,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACzB,gEAAgE;YAChE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EA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C,KAAK,CAAC,EAAE;YACzD,SAAS,CAAC,GAAG,YAAY,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,UAAU,GAAG,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;UAC7E,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;;MAEtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;KACrB,CAAC;IAEF,OAAO;QACH,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE,SAAS;KACvB,CAAC;AACN,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { MetaData, PageComponent } from '../types';
2
+ import { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
3
+ export declare function createMetaData({ apiUrl, baseUrl, components, // Optional NOTE: Doesn't handle null
4
+ contentPath, contentType, contentId, defaultLocale, locale, pageCmp, // Optional
5
+ renderMode, requestedComponentPath, requestType }: {
6
+ apiUrl: string;
7
+ baseUrl: string;
8
+ components?: PageComponent[];
9
+ contentPath: string;
10
+ contentId: string;
11
+ contentType: string;
12
+ defaultLocale: string;
13
+ locale: string;
14
+ pageCmp?: PageComponent;
15
+ renderMode: RENDER_MODE;
16
+ requestedComponentPath: string | undefined;
17
+ requestType: XP_REQUEST_TYPE;
18
+ }): MetaData;
@@ -0,0 +1,45 @@
1
+ import { XP_REQUEST_TYPE } from '../common/constants';
2
+ import { ComponentRegistry } from '../common/ComponentRegistry';
3
+ export function createMetaData({ apiUrl, baseUrl, components = [], // Optional NOTE: Doesn't handle null
4
+ contentPath, contentType, contentId, defaultLocale, locale, pageCmp, // Optional
5
+ renderMode, requestedComponentPath, requestType }) {
6
+ var _a;
7
+ // .meta will be visible in final rendered inline props.
8
+ // Only adding some .meta attributes here on certain conditions
9
+ // (instead of always adding them and letting them be visible as false/undefined etc)
10
+ const meta = {
11
+ apiUrl,
12
+ baseUrl,
13
+ canRender: false,
14
+ catchAll: false, // catchAll only refers to content type catch-all
15
+ defaultLocale,
16
+ locale,
17
+ id: contentId,
18
+ path: contentPath,
19
+ renderMode: renderMode,
20
+ requestType: requestType,
21
+ type: contentType
22
+ };
23
+ if (requestedComponentPath) {
24
+ meta.requestedComponent = components.find(cmp => cmp.path === requestedComponentPath);
25
+ }
26
+ const pageDesc = (_a = pageCmp === null || pageCmp === void 0 ? void 0 : pageCmp.page) === null || _a === void 0 ? void 0 : _a.descriptor;
27
+ const typeDef = ComponentRegistry.getContentType(contentType);
28
+ if ((typeDef === null || typeDef === void 0 ? void 0 : typeDef.view) && !typeDef.catchAll) {
29
+ meta.canRender = true;
30
+ }
31
+ else if (requestType === XP_REQUEST_TYPE.COMPONENT) {
32
+ // always render a single component (show missing if not implemented)
33
+ meta.canRender = true;
34
+ }
35
+ else if (pageDesc) {
36
+ // always render a page if there is a descriptor (show missing if not implemented)
37
+ meta.canRender = true;
38
+ }
39
+ else if (typeDef === null || typeDef === void 0 ? void 0 : typeDef.view) {
40
+ meta.canRender = true;
41
+ meta.catchAll = true;
42
+ }
43
+ return meta;
44
+ }
45
+ //# sourceMappingURL=createMetaData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMetaData.js","sourceRoot":"","sources":["../../src/guillotine/createMetaData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAG9D,MAAM,UAAU,cAAc,CAAC,EACI,MAAM,EACN,OAAO,EACP,UAAU,GAAG,EAAE,EAAE,qCAAqC;AACtD,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,MAAM,EACN,OAAO,EAAE,WAAW;AACpB,UAAU,EACV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AI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Context, FetchContentResult } from '../types';
2
+ /**
3
+ * Default fetchContent function, built with params from imports.
4
+ * It runs custom content-type-specific guillotine calls against an XP guillotine endpoint, returns content data, error and some meta data
5
+ * Sends one query to the guillotine API and asks for content type, then uses the type to select a second query and variables, which is sent to the API and fetches content data.
6
+ * @param context object from Next, contains .query info
7
+ * @returns FetchContentResult object: {data?: T, error?: {code, message}}
8
+ */
9
+ export declare function fetchContent(context: Context): Promise<FetchContentResult>;