@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,428 +0,0 @@
1
- import type {PublishInfo} from '@enonic-types/core';
2
- import type {PageComponent, PageData} from './component';
3
- import type {MetaData} from './componentProps';
4
- import type {Context} from './next';
5
- import type {RecursivePartial} from './util';
6
-
7
-
8
- export interface GuillotineError {
9
- errorType: string
10
- locations: {
11
- line: number
12
- column: number
13
- }[]
14
- message: string
15
- validationErrorType?: string
16
- }
17
-
18
- // A specific observed error
19
- // export interface GuillotineValidationError extends GuillotineError {
20
- // errorType: 'ValidationError'
21
- // validationErrorType: string // 'FieldUndefined'
22
- // }
23
-
24
- // export interface GuillotineErrorResponseJson {
25
- // errors: GuillotineError[]
26
- // }
27
-
28
- // export interface GuillotineOkResponseJson<Data = Record<string,unknown>> {
29
- // data: Data
30
- // }
31
-
32
- // export type GuillotineResponseJson<Data> = GuillotineOkResponseJson<Data> | GuillotineErrorResponseJson;
33
-
34
- export interface GuillotineResponseJson<Guillotine = RecursivePartial<HeadlessCms>> {
35
- // NOTE: guillotine is the actual field on the top Query, but can be used multiple times via aliases
36
- data?: Record<string, Guillotine>
37
- errors?: GuillotineError[]
38
- }
39
-
40
- export interface GuillotineResponse<Data = Record<string,unknown>> {
41
- json: () => Promise<GuillotineResponseJson<Data>>
42
- text: () => Promise<string>
43
- ok: boolean
44
- status: number
45
- }
46
-
47
- /**
48
- * 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.
49
- * @param contentPath string or string array: pre-split or slash-delimited _path to a content available on the API
50
- * @returns FetchContentResult object: {data?: T, error?: {code, message}}
51
- */
52
- export type ContentFetcher = (context: Context) => Promise<FetchContentResult>;
53
-
54
- export interface ContentResult<Content = Record<string, unknown>> extends Result {
55
- contents?: Content[]
56
- }
57
-
58
- export interface FetchContentResult extends Result {
59
- data: Record<string, any> | null
60
- common: Record<string, any> | null
61
- meta: MetaData
62
- page: PageComponent | null
63
- }
64
-
65
- // Seems like NodeJS.fetch lowercases all headers, so we need to lowercase the
66
- // header names here.
67
- export interface GuillotineRequestHeaders {
68
- [key: string]: string | undefined;
69
- Cookie?: string
70
- locale: string
71
- locales: string
72
- 'default-locale': string
73
- }
74
-
75
- export type GuillotineResult = Result & Record<string, any>;
76
-
77
- export interface MetaResult extends Result {
78
- meta?: {
79
- _id: string
80
- _path: string
81
- type: string
82
- pageAsJson?: PageData
83
- components?: PageComponent[]
84
- }
85
- }
86
-
87
- export interface Result {
88
- error?: {
89
- code: string
90
- message: string
91
- } | null
92
- }
93
-
94
- // Types from Query Playground Docs:
95
-
96
- interface AccessControlEntry {
97
- principal: PrincipalKey
98
- allow: [Permission]
99
- deny: [Permission]
100
- }
101
-
102
- interface Attachment {
103
- name: string
104
- label: string
105
- size: number
106
- mimeType: string
107
- attachmentUrl: string
108
- }
109
-
110
- type DateTime = string;
111
-
112
- export interface Component {
113
- type: ComponentType
114
- path: string
115
- page?: PageComponentData | null
116
- layout?: LayoutComponentData | null
117
- image?: ImageComponentData | null
118
- part?: PartComponentData | null
119
- text?: TextComponentData | null
120
- fragment?: FragmentComponentData | null
121
- }
122
-
123
- type ComponentType = 'page' | 'layout' | 'image' | 'part' | 'text' | 'fragment';
124
-
125
- interface Content {
126
- _id: string // !
127
- _name: string // !
128
- _path: string // !
129
- _references?: Content[]
130
- _score?: number
131
- creator?: PrincipalKey
132
- modifier?: PrincipalKey
133
- createdTime?: DateTime
134
- modifiedTime?: DateTime
135
- owner?: PrincipalKey
136
- type?: string
137
- contentType?: ContentType
138
- displayName?: string
139
- hasChildren?: boolean
140
- language?: string
141
- valid?: boolean
142
- dataAsJson?: JSON
143
- x?: ExtraData
144
- xAsJson?: JSON
145
- pageAsJson?: JSON
146
- pageTemplate?: Content
147
- components?: Component[]
148
- attachments?: Attachment[]
149
- publish?: PublishInfo
150
- pageUrl?: string
151
- site?: portal_Site
152
- parent?: Content
153
- children?: Content[]
154
- childrenConnection?: ContentConnection
155
- permissions?: Permissions
156
- }
157
-
158
- interface ContentConnection {
159
- totalCount: Int
160
- edges: ContentEdge[]
161
- pageInfo: PageInfo
162
- }
163
-
164
- interface ContentEdge {
165
- node: Content
166
- cursor: string
167
- }
168
-
169
- interface ContentType {
170
- name: string
171
- displayName: string
172
- description: string
173
- superType: string
174
- abstract: boolean
175
- final: boolean
176
- allowChildContent: boolean
177
- contentDisplayNameScript: string
178
- icon: Icon
179
- form: FormItem[]
180
- formAsJson: JSON
181
- getInstances: Content[]
182
- getInstanceConnection: ContentConnection
183
- }
184
-
185
- type ExtraData<App = Record<string,unknown>> = App & {
186
- media: XData_media_ApplicationConfig
187
- base: XData_base_ApplicationConfig
188
- };
189
-
190
- type Float = number;
191
-
192
- interface FormItem {
193
- formItemType: FormItemType
194
- name: string
195
- label: string
196
- }
197
-
198
- type FormItemType = 'ItemSet' | 'Layout' | 'Input' | 'OptionSet';
199
-
200
- interface FragmentComponentData {
201
- id: string
202
- fragment: Content
203
- }
204
-
205
- interface GeoPoint {
206
- value: string
207
- latitude: Float
208
- longitude: Float
209
- }
210
-
211
- export interface HeadlessCms {
212
- get?: Content
213
- getChildren?: Content[]
214
- getChildrenConnection?: ContentConnection
215
- getPermissions?: Permissions
216
- getSite?: portal_Site
217
- getType?: ContentType
218
- getTypes?: ContentType[]
219
- query?: Content[]
220
- queryConnection?: QueryContentConnection
221
- queryDsl?: Content[]
222
- queryDslConnection?: QueryDSLContentConnection
223
- }
224
-
225
- interface Icon {
226
- mimeType: string
227
- modifiedTime: string
228
- }
229
-
230
- interface Image {
231
- image: Content
232
- ref: string
233
- style: ImageStyle
234
- }
235
-
236
- interface ImageComponentData {
237
- id: string
238
- caption?: string
239
- image: media_Image
240
- }
241
-
242
- interface ImageStyle {
243
- name: string
244
- aspectRatio: string
245
- filter: string
246
- }
247
-
248
- type Int = number;
249
-
250
- type JSON = Record<string, unknown>;
251
-
252
- interface LayoutComponentData {
253
- descriptor: string
254
- configAsJson: JSON | null
255
- }
256
-
257
- interface Link {
258
- ref: string
259
- uri: string
260
- media: Media
261
- content: Content
262
- }
263
-
264
- type LocalDateTime = string;
265
-
266
- interface Macro_system_disable_DataConfig {
267
- body: string
268
- }
269
-
270
- interface Macro_system_embed_DataConfig {
271
- body: string
272
- }
273
-
274
- interface Macro {
275
- ref: string
276
- name: string
277
- descriptor: string
278
- config: MacroConfig
279
- }
280
-
281
- interface MacroConfig {
282
- disable: Macro_system_disable_DataConfig
283
- embed: Macro_system_embed_DataConfig
284
- }
285
-
286
- interface Media {
287
- content: Content
288
- intent: MediaIntentType
289
- }
290
-
291
- type MediaIntentType = 'download' | 'inline';
292
-
293
- interface media_Image extends Content {
294
- mediaUrl: string
295
- imageUrl: string
296
- data: media_Image_Data
297
- }
298
-
299
- interface media_Image_Data {
300
- media: MediaUploader
301
- caption: string
302
- altText: string
303
- artist: string[]
304
- copyright: string
305
- tags: string[]
306
- }
307
-
308
- interface MediaFocalPoint {
309
- x: number
310
- y: number
311
- }
312
-
313
- interface MediaUploader {
314
- attachment: string
315
- focalPoint: MediaFocalPoint
316
- }
317
-
318
- interface PageComponentData {
319
- descriptor?: string
320
- customized?: boolean
321
- configAsJson?: JSON
322
- template?: Content | null
323
- }
324
-
325
- interface PageInfo {
326
- startCursor: string // !
327
- endCursor: string // !
328
- hasNext: boolean // !
329
- }
330
-
331
- interface PartComponentData<Config = Record<string, unknown>> {
332
- descriptor: string
333
- config: Config
334
- configAsJson: JSON
335
- }
336
-
337
- type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
338
-
339
- interface Permissions {
340
- inheritsPermissions: boolean
341
- permissions: AccessControlEntry[]
342
- }
343
-
344
- interface portal_Site extends Content {
345
- data: portal_Site_Data
346
- }
347
-
348
- interface portal_Site_Data {
349
- description: string
350
- }
351
-
352
- type PrincipalType = 'user' | 'group' | 'role';
353
-
354
- interface PrincipalKey {
355
- value: string
356
- type: PrincipalType
357
- idProvider: string
358
- principalId: string
359
- }
360
-
361
- interface QueryContentConnection extends ContentConnection {
362
- aggregationsAsJson: JSON
363
- }
364
-
365
- interface QueryDSLContentConnection extends QueryContentConnection {
366
- highlightAsJson: JSON
367
- }
368
-
369
- interface RichText {
370
- raw: string
371
- processedHtml: string
372
- macrosAsJson: JSON
373
- macros: Macro[]
374
- images: Image[]
375
- links: Link[]
376
- }
377
-
378
- interface TextComponentData {
379
- value: RichText
380
- }
381
-
382
- interface XData_base_ApplicationConfig {
383
- gpsInfo: XData_base_gpsInfo_DataConfig
384
- }
385
-
386
- interface XData_base_gpsInfo_DataConfig {
387
- geoPoint: GeoPoint
388
- altitude: string
389
- direction: string
390
- }
391
-
392
- interface XData_media_ApplicationConfig {
393
- imageInfo: XData_media_imageInfo_DataConfig
394
- cameraInfo: XData_media_cameraInfo_DataConfig
395
- }
396
-
397
- interface XData_media_imageInfo_DataConfig {
398
- pixelSize: number
399
- imageHeight: number
400
- imageWidth: number
401
- contentType: string
402
- description: string
403
- byteSize: number
404
- colorSpace: string[]
405
- fileSource: string
406
- }
407
-
408
- interface XData_media_cameraInfo_DataConfig {
409
- date: LocalDateTime
410
- make: string
411
- model: string
412
- lens: string
413
- iso: string
414
- focalLength: string
415
- focalLength35: string
416
- exposureBias: string
417
- aperture: string[]
418
- shutterTime: string
419
- flash: string
420
- autoFlashCompensation: string
421
- whiteBalance: string
422
- exposureProgram: string
423
- shootingMode: string
424
- meteringMode: string
425
- exposureMode: string
426
- focusDistance: string
427
- orientation: string
428
- }
package/src/types/i18n.ts DELETED
@@ -1,8 +0,0 @@
1
- export type Dict = Record<string, string>;
2
-
3
- export interface LocaleContextType {
4
- dictionary: Dict
5
- locale: string
6
- localize: (key: string, ...args: any[]) => string
7
- setLocale: (locale: string) => Promise<Dict>
8
- }
package/src/types/next.ts DELETED
@@ -1,7 +0,0 @@
1
- import type {ReadonlyHeaders} from 'next/dist/server/web/spec-extension/adapters/headers';
2
-
3
- export interface Context {
4
- headers?: ReadonlyHeaders | Headers
5
- locale?: string
6
- contentPath: string | string[]
7
- }
package/src/types/util.ts DELETED
@@ -1,5 +0,0 @@
1
- export type RecursivePartial<T> = {
2
- [P in keyof T]?: RecursivePartial<T[P]>;
3
- };
4
-
5
- // export type PartialExcept<T, K extends keyof T> = RecursivePartial<T> & Pick<T, K>;
@@ -1,3 +0,0 @@
1
- export function addLineNumbers(s: string) {
2
- return s.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
3
- }
@@ -1,29 +0,0 @@
1
- import type {Context, GuillotineRequestHeaders} from '../types';
2
-
3
-
4
- import {GUILLOTINE_REQUEST_HEADERS, JSESSIONID_HEADER} from '../common/constants';
5
-
6
-
7
- export function buildGuillotineRequestHeaders({
8
- context,
9
- defaultLocale,
10
- locale,
11
- locales
12
- }: {
13
- context: Context
14
- defaultLocale: string
15
- locale: string
16
- locales: string[]
17
- }): GuillotineRequestHeaders {
18
- const guillotineRequestHeaders: GuillotineRequestHeaders = {
19
- [GUILLOTINE_REQUEST_HEADERS.DEFAULT_LOCALE]: defaultLocale,
20
- [GUILLOTINE_REQUEST_HEADERS.LOCALE]: locale,
21
- [GUILLOTINE_REQUEST_HEADERS.LOCALES]: JSON.stringify(locales)
22
- };
23
- const jsessionid = context.headers?.get(JSESSIONID_HEADER);
24
- if (jsessionid) {
25
- guillotineRequestHeaders[GUILLOTINE_REQUEST_HEADERS.COOKIE] =
26
- `${JSESSIONID_HEADER}=${jsessionid}`;
27
- }
28
- return guillotineRequestHeaders;
29
- }
@@ -1,28 +0,0 @@
1
- import {LOGGING} from '../common/env';
2
-
3
- export const enonicDebug = (s?: string, ...params: any[]) => {
4
- enonicPrint('debug', s, ...params);
5
- };
6
-
7
- export const enonicLog = (s?: string, ...params: any[]) => {
8
- enonicPrint('log', s, ...params);
9
- };
10
-
11
- export const enonicInfo = (s?: string, ...params: any[]) => {
12
- enonicPrint('info', s, ...params);
13
- };
14
-
15
- export const enonicWarn = (s?: string, ...params: any[]) => {
16
- enonicPrint('warn', s, ...params);
17
- };
18
-
19
- export const enonicError = (s?: string, ...params: any[]) => {
20
- enonicPrint('error', s, ...params);
21
- };
22
-
23
- const enonicPrint = (type: 'log' | 'debug' | 'info' | 'warn' | 'error', s?: string, ...params: any[]) => {
24
- if (LOGGING) {
25
- const m = `\n[${new Date().toLocaleTimeString()}] ${s}:\n`;
26
- console[type](m, ...params, '\n');
27
- }
28
- };
@@ -1,3 +0,0 @@
1
- export function fixDoubleSlashes(str: string) {
2
- return str.replace(/(^|[^:/])\/{2,}/g, '$1/');
3
- }
@@ -1,6 +0,0 @@
1
- import {getLocaleMappings} from './getLocaleMappings';
2
-
3
-
4
- export function getAllLocales(): string[] {
5
- return Object.keys(getLocaleMappings());
6
- }
@@ -1,20 +0,0 @@
1
- import type {Context} from '../types';
2
-
3
-
4
- import {RENDER_MODE} from '../common/constants';
5
- import {API_URL} from '../common/env';
6
- import {getLocaleMapping} from './getLocaleMapping';
7
- import {fixDoubleSlashes} from './fixDoubleSlashes';
8
- import {getRenderMode} from './getRenderMode';
9
-
10
-
11
- export function getContentApiUrl(context: Context): string {
12
- const project = getLocaleMapping(context).project;
13
- const branch = getRenderMode(context) === RENDER_MODE.NEXT
14
- ? 'master'
15
- : getRenderMode(context) === RENDER_MODE.LIVE
16
- ? 'master'
17
- : 'draft';
18
-
19
- return fixDoubleSlashes(`${API_URL}/${project}/${branch}`);
20
- }
@@ -1,24 +0,0 @@
1
- import type {Context, LocaleMapping} from '../types';
2
-
3
-
4
- import {PROJECT_ID_HEADER} from '../common/constants';
5
- import {getLocaleMappingByProjectId} from './getLocaleMappingByProjectId';
6
- import {getLocaleMappingByLocale} from './getLocaleMappingByLocale';
7
-
8
-
9
- export function getLocaleMapping(context: Context): LocaleMapping {
10
- const projectId = context.headers?.get(PROJECT_ID_HEADER);
11
-
12
- let config: LocaleMapping;
13
- if (projectId) {
14
- // first use project id header
15
- config = getLocaleMappingByProjectId(projectId, false);
16
- }
17
- if (!config) {
18
- // next try to use locale from url
19
- // it will fall back to default locale if not found
20
- config = getLocaleMappingByLocale(context.locale);
21
- }
22
-
23
- return config;
24
- }
@@ -1,19 +0,0 @@
1
- import type {LocaleMapping} from '../types';
2
-
3
-
4
- import {getLocaleMappings} from './getLocaleMappings';
5
-
6
-
7
- export function getLocaleMappingByLocale(locale?: string, useDefault = true): LocaleMapping {
8
- const mappings = getLocaleMappings();
9
-
10
- let config: LocaleMapping;
11
- if (locale) {
12
- config = mappings[locale];
13
- }
14
- if (!config && useDefault) {
15
- config = Object.values(mappings).find(c => c.default);
16
- }
17
-
18
- return config;
19
- }
@@ -1,21 +0,0 @@
1
- import type {LocaleMapping} from '../types';
2
-
3
-
4
- import {getLocaleMappings} from './getLocaleMappings';
5
-
6
-
7
- export function getLocaleMappingByProjectId(projectId?: string, useDefault = true): LocaleMapping {
8
- const mappings = getLocaleMappings();
9
-
10
- let config: LocaleMapping;
11
- if (projectId) {
12
- config = Object.values(mappings).find(p => {
13
- return p?.project?.toLowerCase() === projectId.toLowerCase();
14
- });
15
- }
16
- if (!config && useDefault) {
17
- config = Object.values(mappings).find(c => c.default);
18
- }
19
-
20
- return config;
21
- }
@@ -1,11 +0,0 @@
1
- import type {Context} from '../types';
2
-
3
-
4
- import {RENDER_MODE, RENDER_MODE_HEADER} from '../common/constants';
5
-
6
-
7
- export const getRenderMode = (context: Context): RENDER_MODE => {
8
- const value = context.headers?.get(RENDER_MODE_HEADER);
9
- const enumValue = RENDER_MODE[(value as keyof typeof RENDER_MODE)?.toUpperCase()];
10
- return enumValue || RENDER_MODE[process.env.RENDER_MODE] || RENDER_MODE.NEXT;
11
- };
@@ -1,12 +0,0 @@
1
- import type {Context} from '../types';
2
-
3
-
4
- import {XP_BASE_URL_HEADER} from '../common/constants';
5
-
6
-
7
- export const getXpBaseUrl = (context: Context): string => {
8
- const header = context.headers?.get(XP_BASE_URL_HEADER) || '/';
9
-
10
- // TODO: workaround for XP pattern controller mapping not picked up in edit mode
11
- return header.replace(/\/edit\//, '/inline/');
12
- };
@@ -1,4 +0,0 @@
1
- export const indent = (s: string, count = 2, indentChar = ' ') => s
2
- .split('\n')
3
- .map((line) => `${indentChar.repeat(count)}${line}`)
4
- .join('\n');
@@ -1,47 +0,0 @@
1
- /// <reference types="react" />
2
- import type {BasePageProps, FetchContentResult} from '../types';
3
-
4
-
5
- import {ComponentRegistry} from '../common/ComponentRegistry';
6
- import BasePage from './BasePage';
7
-
8
-
9
- const BaseContent = (props: FetchContentResult) => {
10
- const {common, meta, page} = props;
11
-
12
- if (!meta?.type) {
13
- console.warn("BaseContent props are missing 'meta.type'");
14
- return null;
15
- }
16
-
17
- const pageData = page?.page;
18
- const pageDesc = pageData?.descriptor;
19
- const typeDef = ComponentRegistry.getContentType(meta.type);
20
- const ContentTypeView = typeDef?.view;
21
-
22
- if (ContentTypeView && !typeDef?.catchAll) {
23
- return <ContentTypeView {...props}/>;
24
- } else if (pageDesc) {
25
- const pageAttrs: BasePageProps = {
26
- component: pageData,
27
- path: page?.path,
28
- meta,
29
- common
30
- };
31
- if (page?.data) {
32
- pageAttrs.data = page.data;
33
- }
34
- if (page?.error) {
35
- pageAttrs.error = page.error;
36
- }
37
-
38
- return <BasePage {...pageAttrs}/>;
39
- } else if (ContentTypeView) {
40
- return <ContentTypeView {...props}/>;
41
- }
42
-
43
- console.log(`BaseContent: can not render ${meta.type}: no content type or page view defined`);
44
- return null;
45
- };
46
-
47
- export default BaseContent;