@enonic/nextjs-adapter 3.3.0-B1 → 3.3.0-B2

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 +41 -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} +5 -7
  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 +19 -31
  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
@@ -0,0 +1,344 @@
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
+ export interface GuillotineError {
7
+ errorType: string;
8
+ locations: {
9
+ line: number;
10
+ column: number;
11
+ }[];
12
+ message: string;
13
+ validationErrorType?: string;
14
+ }
15
+ export interface GuillotineResponseJson<Guillotine = RecursivePartial<HeadlessCms>> {
16
+ data?: Record<string, Guillotine>;
17
+ errors?: GuillotineError[];
18
+ }
19
+ export interface GuillotineResponse<Data = Record<string, unknown>> {
20
+ json: () => Promise<GuillotineResponseJson<Data>>;
21
+ text: () => Promise<string>;
22
+ ok: boolean;
23
+ status: number;
24
+ }
25
+ /**
26
+ * 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.
27
+ * @param contentPath string or string array: pre-split or slash-delimited _path to a content available on the API
28
+ * @returns FetchContentResult object: {data?: T, error?: {code, message}}
29
+ */
30
+ export type ContentFetcher = (context: Context) => Promise<FetchContentResult>;
31
+ export interface ContentResult<Content = Record<string, unknown>> extends Result {
32
+ contents?: Content[];
33
+ }
34
+ export interface FetchContentResult extends Result {
35
+ data: Record<string, any> | null;
36
+ common: Record<string, any> | null;
37
+ meta: MetaData;
38
+ page: PageComponent | null;
39
+ }
40
+ export interface GuillotineRequestHeaders {
41
+ [key: string]: string | undefined;
42
+ Cookie?: string;
43
+ locale: string;
44
+ locales: string;
45
+ 'default-locale': string;
46
+ }
47
+ export type GuillotineResult = Result & Record<string, any>;
48
+ export interface MetaResult extends Result {
49
+ meta?: {
50
+ _id: string;
51
+ _path: string;
52
+ type: string;
53
+ pageAsJson?: PageData;
54
+ components?: PageComponent[];
55
+ };
56
+ }
57
+ export interface Result {
58
+ error?: {
59
+ code: string;
60
+ message: string;
61
+ } | null;
62
+ }
63
+ interface AccessControlEntry {
64
+ principal: PrincipalKey;
65
+ allow: [Permission];
66
+ deny: [Permission];
67
+ }
68
+ interface Attachment {
69
+ name: string;
70
+ label: string;
71
+ size: number;
72
+ mimeType: string;
73
+ attachmentUrl: string;
74
+ }
75
+ type DateTime = string;
76
+ export interface Component {
77
+ type: ComponentType;
78
+ path: string;
79
+ page?: PageComponentData | null;
80
+ layout?: LayoutComponentData | null;
81
+ image?: ImageComponentData | null;
82
+ part?: PartComponentData | null;
83
+ text?: TextComponentData | null;
84
+ fragment?: FragmentComponentData | null;
85
+ }
86
+ type ComponentType = 'page' | 'layout' | 'image' | 'part' | 'text' | 'fragment';
87
+ interface Content {
88
+ _id: string;
89
+ _name: string;
90
+ _path: string;
91
+ _references?: Content[];
92
+ _score?: number;
93
+ creator?: PrincipalKey;
94
+ modifier?: PrincipalKey;
95
+ createdTime?: DateTime;
96
+ modifiedTime?: DateTime;
97
+ owner?: PrincipalKey;
98
+ type?: string;
99
+ contentType?: ContentType;
100
+ displayName?: string;
101
+ hasChildren?: boolean;
102
+ language?: string;
103
+ valid?: boolean;
104
+ dataAsJson?: JSON;
105
+ x?: ExtraData;
106
+ xAsJson?: JSON;
107
+ pageAsJson?: JSON;
108
+ pageTemplate?: Content;
109
+ components?: Component[];
110
+ attachments?: Attachment[];
111
+ publish?: PublishInfo;
112
+ pageUrl?: string;
113
+ site?: portal_Site;
114
+ parent?: Content;
115
+ children?: Content[];
116
+ childrenConnection?: ContentConnection;
117
+ permissions?: Permissions;
118
+ }
119
+ interface ContentConnection {
120
+ totalCount: Int;
121
+ edges: ContentEdge[];
122
+ pageInfo: PageInfo;
123
+ }
124
+ interface ContentEdge {
125
+ node: Content;
126
+ cursor: string;
127
+ }
128
+ interface ContentType {
129
+ name: string;
130
+ displayName: string;
131
+ description: string;
132
+ superType: string;
133
+ abstract: boolean;
134
+ final: boolean;
135
+ allowChildContent: boolean;
136
+ contentDisplayNameScript: string;
137
+ icon: Icon;
138
+ form: FormItem[];
139
+ formAsJson: JSON;
140
+ getInstances: Content[];
141
+ getInstanceConnection: ContentConnection;
142
+ }
143
+ type ExtraData<App = Record<string, unknown>> = App & {
144
+ media: XData_media_ApplicationConfig;
145
+ base: XData_base_ApplicationConfig;
146
+ };
147
+ type Float = number;
148
+ interface FormItem {
149
+ formItemType: FormItemType;
150
+ name: string;
151
+ label: string;
152
+ }
153
+ type FormItemType = 'ItemSet' | 'Layout' | 'Input' | 'OptionSet';
154
+ interface FragmentComponentData {
155
+ id: string;
156
+ fragment: Content;
157
+ }
158
+ interface GeoPoint {
159
+ value: string;
160
+ latitude: Float;
161
+ longitude: Float;
162
+ }
163
+ export interface HeadlessCms {
164
+ get?: Content;
165
+ getChildren?: Content[];
166
+ getChildrenConnection?: ContentConnection;
167
+ getPermissions?: Permissions;
168
+ getSite?: portal_Site;
169
+ getType?: ContentType;
170
+ getTypes?: ContentType[];
171
+ query?: Content[];
172
+ queryConnection?: QueryContentConnection;
173
+ queryDsl?: Content[];
174
+ queryDslConnection?: QueryDSLContentConnection;
175
+ }
176
+ interface Icon {
177
+ mimeType: string;
178
+ modifiedTime: string;
179
+ }
180
+ interface Image {
181
+ image: Content;
182
+ ref: string;
183
+ style: ImageStyle;
184
+ }
185
+ interface ImageComponentData {
186
+ id: string;
187
+ caption?: string;
188
+ image: media_Image;
189
+ }
190
+ interface ImageStyle {
191
+ name: string;
192
+ aspectRatio: string;
193
+ filter: string;
194
+ }
195
+ type Int = number;
196
+ type JSON = Record<string, unknown>;
197
+ interface LayoutComponentData {
198
+ descriptor: string;
199
+ configAsJson: JSON | null;
200
+ }
201
+ interface Link {
202
+ ref: string;
203
+ uri: string;
204
+ media: Media;
205
+ content: Content;
206
+ }
207
+ type LocalDateTime = string;
208
+ interface Macro_system_disable_DataConfig {
209
+ body: string;
210
+ }
211
+ interface Macro_system_embed_DataConfig {
212
+ body: string;
213
+ }
214
+ interface Macro {
215
+ ref: string;
216
+ name: string;
217
+ descriptor: string;
218
+ config: MacroConfig;
219
+ }
220
+ interface MacroConfig {
221
+ disable: Macro_system_disable_DataConfig;
222
+ embed: Macro_system_embed_DataConfig;
223
+ }
224
+ interface Media {
225
+ content: Content;
226
+ intent: MediaIntentType;
227
+ }
228
+ type MediaIntentType = 'download' | 'inline';
229
+ interface media_Image extends Content {
230
+ mediaUrl: string;
231
+ imageUrl: string;
232
+ data: media_Image_Data;
233
+ }
234
+ interface media_Image_Data {
235
+ media: MediaUploader;
236
+ caption: string;
237
+ altText: string;
238
+ artist: string[];
239
+ copyright: string;
240
+ tags: string[];
241
+ }
242
+ interface MediaFocalPoint {
243
+ x: number;
244
+ y: number;
245
+ }
246
+ interface MediaUploader {
247
+ attachment: string;
248
+ focalPoint: MediaFocalPoint;
249
+ }
250
+ interface PageComponentData {
251
+ descriptor?: string;
252
+ customized?: boolean;
253
+ configAsJson?: JSON;
254
+ template?: Content | null;
255
+ }
256
+ interface PageInfo {
257
+ startCursor: string;
258
+ endCursor: string;
259
+ hasNext: boolean;
260
+ }
261
+ interface PartComponentData<Config = Record<string, unknown>> {
262
+ descriptor: string;
263
+ config: Config;
264
+ configAsJson: JSON;
265
+ }
266
+ type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
267
+ interface Permissions {
268
+ inheritsPermissions: boolean;
269
+ permissions: AccessControlEntry[];
270
+ }
271
+ interface portal_Site extends Content {
272
+ data: portal_Site_Data;
273
+ }
274
+ interface portal_Site_Data {
275
+ description: string;
276
+ }
277
+ type PrincipalType = 'user' | 'group' | 'role';
278
+ interface PrincipalKey {
279
+ value: string;
280
+ type: PrincipalType;
281
+ idProvider: string;
282
+ principalId: string;
283
+ }
284
+ interface QueryContentConnection extends ContentConnection {
285
+ aggregationsAsJson: JSON;
286
+ }
287
+ interface QueryDSLContentConnection extends QueryContentConnection {
288
+ highlightAsJson: JSON;
289
+ }
290
+ interface RichText {
291
+ raw: string;
292
+ processedHtml: string;
293
+ macrosAsJson: JSON;
294
+ macros: Macro[];
295
+ images: Image[];
296
+ links: Link[];
297
+ }
298
+ interface TextComponentData {
299
+ value: RichText;
300
+ }
301
+ interface XData_base_ApplicationConfig {
302
+ gpsInfo: XData_base_gpsInfo_DataConfig;
303
+ }
304
+ interface XData_base_gpsInfo_DataConfig {
305
+ geoPoint: GeoPoint;
306
+ altitude: string;
307
+ direction: string;
308
+ }
309
+ interface XData_media_ApplicationConfig {
310
+ imageInfo: XData_media_imageInfo_DataConfig;
311
+ cameraInfo: XData_media_cameraInfo_DataConfig;
312
+ }
313
+ interface XData_media_imageInfo_DataConfig {
314
+ pixelSize: number;
315
+ imageHeight: number;
316
+ imageWidth: number;
317
+ contentType: string;
318
+ description: string;
319
+ byteSize: number;
320
+ colorSpace: string[];
321
+ fileSource: string;
322
+ }
323
+ interface XData_media_cameraInfo_DataConfig {
324
+ date: LocalDateTime;
325
+ make: string;
326
+ model: string;
327
+ lens: string;
328
+ iso: string;
329
+ focalLength: string;
330
+ focalLength35: string;
331
+ exposureBias: string;
332
+ aperture: string[];
333
+ shutterTime: string;
334
+ flash: string;
335
+ autoFlashCompensation: string;
336
+ whiteBalance: string;
337
+ exposureProgram: string;
338
+ shootingMode: string;
339
+ meteringMode: string;
340
+ exposureMode: string;
341
+ focusDistance: string;
342
+ orientation: string;
343
+ }
344
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=guillotine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guillotine.js","sourceRoot":"","sources":["../../src/types/guillotine.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export type Dict = Record<string, string>;
2
+ export interface LocaleContextType {
3
+ dictionary: Dict;
4
+ locale: string;
5
+ localize: (key: string, ...args: any[]) => string;
6
+ setLocale: (locale: string) => Promise<Dict>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/types/i18n.ts"],"names":[],"mappings":""}
@@ -1,60 +1,45 @@
1
- /// <reference types="react" />
2
-
3
1
  export type * from './component';
4
2
  export type * from './componentProps';
5
3
  export type * from './guillotine';
6
4
  export type * from './i18n';
7
5
  export type * from './next';
8
6
  export type * from './util';
9
-
10
-
11
- // Shape of content base-data API body
12
7
  export interface ContentApiBaseBody {
13
- query?: string, // Override the default base-data query
14
- variables?: ContentApiBaseBodyVariables // GraphQL variables inserted into the query
8
+ query?: string;
9
+ variables?: ContentApiBaseBodyVariables;
15
10
  }
16
-
17
11
  export interface ContentApiBaseBodyVariables {
18
- path?: string, // Full content item _path
19
- [key: string]: string | number | undefined
12
+ path?: string;
13
+ [key: string]: string | number | undefined;
20
14
  }
21
-
22
15
  export interface ContentPathItem {
23
- contentPath: string[]
24
- locale: string
16
+ contentPath: string[];
17
+ locale: string;
25
18
  }
26
-
27
19
  export interface PathFragment {
28
- index: number
29
- region: string
20
+ index: number;
21
+ region: string;
30
22
  }
31
-
32
23
  export interface PreviewParams {
33
- contentPath: string[]
34
- headers: Record<string, string>
35
- params: Record<string, string>
24
+ contentPath: string[];
25
+ headers: Record<string, string>;
26
+ params: Record<string, string>;
36
27
  }
37
-
38
28
  export interface LocaleMapping {
39
- default: boolean
40
- project: string
41
- site: string
42
- locale: string
29
+ default: boolean;
30
+ project: string;
31
+ site: string;
32
+ locale: string;
43
33
  }
44
-
45
34
  export type LocaleMappings = Record<string, LocaleMapping>;
46
-
47
35
  export type SelectorName = 'contentType' | 'page' | 'component' | 'part' | 'layout' | 'macro';
48
-
49
- // https://nextjs.org/docs/app/api-reference/functions/fetch
50
36
  export type FetchOptions = Omit<RequestInit, 'body'> & {
51
- body?: ContentApiBaseBody,
37
+ body?: ContentApiBaseBody;
52
38
  next?: {
53
- revalidate?: boolean | number,
54
- tags?: string[]
55
- }
39
+ revalidate?: boolean | number;
40
+ tags?: string[];
41
+ };
56
42
  };
57
-
58
43
  export interface StaticContentProps extends Record<string, any> {
59
44
  children?: React.ReactNode;
60
45
  element?: string;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export {};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,+BAA+B"}
@@ -0,0 +1,6 @@
1
+ import type { ReadonlyHeaders } from 'next/dist/server/web/spec-extension/adapters/headers';
2
+ export interface Context {
3
+ headers?: ReadonlyHeaders | Headers;
4
+ locale?: string;
5
+ contentPath: string | string[];
6
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/types/next.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type RecursivePartial<T> = {
2
+ [P in keyof T]?: RecursivePartial<T[P]>;
3
+ };
@@ -0,0 +1,3 @@
1
+ export {};
2
+ // export type PartialExcept<T, K extends keyof T> = RecursivePartial<T> & Pick<T, K>;
3
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":";AAIA,sFAAsF"}
@@ -0,0 +1 @@
1
+ export declare function addLineNumbers(s: string): string;
@@ -0,0 +1,4 @@
1
+ export function addLineNumbers(s) {
2
+ return s.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
3
+ }
4
+ //# sourceMappingURL=addLineNumbers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addLineNumbers.js","sourceRoot":"","sources":["../../src/utils/addLineNumbers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Context, GuillotineRequestHeaders } from '../types';
2
+ export declare function buildGuillotineRequestHeaders({ context, defaultLocale, locale, locales }: {
3
+ context: Context;
4
+ defaultLocale: string;
5
+ locale: string;
6
+ locales: string[];
7
+ }): GuillotineRequestHeaders;
@@ -0,0 +1,16 @@
1
+ import { GUILLOTINE_REQUEST_HEADERS, JSESSIONID_HEADER } from '../common/constants';
2
+ export function buildGuillotineRequestHeaders({ context, defaultLocale, locale, locales }) {
3
+ var _a;
4
+ const guillotineRequestHeaders = {
5
+ [GUILLOTINE_REQUEST_HEADERS.DEFAULT_LOCALE]: defaultLocale,
6
+ [GUILLOTINE_REQUEST_HEADERS.LOCALE]: locale,
7
+ [GUILLOTINE_REQUEST_HEADERS.LOCALES]: JSON.stringify(locales)
8
+ };
9
+ const jsessionid = (_a = context.headers) === null || _a === void 0 ? void 0 : _a.get(JSESSIONID_HEADER);
10
+ if (jsessionid) {
11
+ guillotineRequestHeaders[GUILLOTINE_REQUEST_HEADERS.COOKIE] =
12
+ `${JSESSIONID_HEADER}=${jsessionid}`;
13
+ }
14
+ return guillotineRequestHeaders;
15
+ }
16
+ //# sourceMappingURL=buildGuillotineRequestHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildGuillotineRequestHeaders.js","sourceRoot":"","sources":["../../src/utils/buildGuillotineRequestHeaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,0BAA0B,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGlF,MAAM,UAAU,6BAA6B,CAAC,EAC1C,OAAO,EACP,aAAa,EACb,MAAM,EACN,OAAO,EAMV;;IACG,MAAM,wBAAwB,GAA6B;QACvD,CAAC,0BAA0B,CAAC,cAAc,CAAC,EAAE,aAAa;QAC1D,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,MAAM;QAC3C,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAChE,CAAC;IACF,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC3D,IAAI,UAAU,EAAE,CAAC;QACb,wBAAwB,CAAC,0BAA0B,CAAC,MAAM,CAAC;YACvD,GAAG,iBAAiB,IAAI,UAAU,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,wBAAwB,CAAC;AACpC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const commonChars: (s1?: string, s2?: string) => string;
@@ -1,4 +1,4 @@
1
- export const commonChars = (s1?: string, s2?: string) => {
1
+ export const commonChars = (s1, s2) => {
2
2
  let result = '';
3
3
  if (!s1 || s1.length === 0 || !s2 || s2.length === 0) {
4
4
  return result;
@@ -7,10 +7,11 @@ export const commonChars = (s1?: string, s2?: string) => {
7
7
  const s1Element = s1[i];
8
8
  if (s2[i] === s1Element) {
9
9
  result += s1Element;
10
- } else {
10
+ }
11
+ else {
11
12
  break;
12
13
  }
13
14
  }
14
-
15
15
  return result;
16
- };
16
+ };
17
+ //# sourceMappingURL=commonChars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonChars.js","sourceRoot":"","sources":["../../src/utils/commonChars.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAW,EAAE,EAAW,EAAE,EAAE;IACpD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,SAAS,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,MAAM;QACV,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const enonicDebug: (s?: string, ...params: any[]) => void;
2
+ export declare const enonicLog: (s?: string, ...params: any[]) => void;
3
+ export declare const enonicInfo: (s?: string, ...params: any[]) => void;
4
+ export declare const enonicWarn: (s?: string, ...params: any[]) => void;
5
+ export declare const enonicError: (s?: string, ...params: any[]) => void;
@@ -0,0 +1,23 @@
1
+ import { LOGGING } from '../common/env';
2
+ export const enonicDebug = (s, ...params) => {
3
+ enonicPrint('debug', s, ...params);
4
+ };
5
+ export const enonicLog = (s, ...params) => {
6
+ enonicPrint('log', s, ...params);
7
+ };
8
+ export const enonicInfo = (s, ...params) => {
9
+ enonicPrint('info', s, ...params);
10
+ };
11
+ export const enonicWarn = (s, ...params) => {
12
+ enonicPrint('warn', s, ...params);
13
+ };
14
+ export const enonicError = (s, ...params) => {
15
+ enonicPrint('error', s, ...params);
16
+ };
17
+ const enonicPrint = (type, s, ...params) => {
18
+ if (LOGGING) {
19
+ const m = `\n[${new Date().toLocaleTimeString()}] ${s}:\n`;
20
+ console[type](m, ...params, '\n');
21
+ }
22
+ };
23
+ //# sourceMappingURL=enonicLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enonicLog.js","sourceRoot":"","sources":["../../src/utils/enonicLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACxD,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACtD,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACvD,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACvD,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACxD,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAiD,EAAE,CAAU,EAAE,GAAG,MAAa,EAAE,EAAE;IACpG,IAAI,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function fixDoubleSlashes(str: string): string;
@@ -0,0 +1,4 @@
1
+ export function fixDoubleSlashes(str) {
2
+ return str.replace(/(^|[^:/])\/{2,}/g, '$1/');
3
+ }
4
+ //# sourceMappingURL=fixDoubleSlashes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixDoubleSlashes.js","sourceRoot":"","sources":["../../src/utils/fixDoubleSlashes.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function getAllLocales(): string[];
@@ -0,0 +1,5 @@
1
+ import { getLocaleMappings } from './getLocaleMappings';
2
+ export function getAllLocales() {
3
+ return Object.keys(getLocaleMappings());
4
+ }
5
+ //# sourceMappingURL=getAllLocales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllLocales.js","sourceRoot":"","sources":["../../src/utils/getAllLocales.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,UAAU,aAAa;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Context } from '../types';
2
+ export declare function getContentApiUrl(context: Context): string;
@@ -0,0 +1,15 @@
1
+ import { RENDER_MODE } from '../common/constants';
2
+ import { API_URL } from '../common/env';
3
+ import { getLocaleMapping } from './getLocaleMapping';
4
+ import { fixDoubleSlashes } from './fixDoubleSlashes';
5
+ import { getRenderMode } from './getRenderMode';
6
+ export function getContentApiUrl(context) {
7
+ const project = getLocaleMapping(context).project;
8
+ const branch = getRenderMode(context) === RENDER_MODE.NEXT
9
+ ? 'master'
10
+ : getRenderMode(context) === RENDER_MODE.LIVE
11
+ ? 'master'
12
+ : 'draft';
13
+ return fixDoubleSlashes(`${API_URL}/${project}/${branch}`);
14
+ }
15
+ //# sourceMappingURL=getContentApiUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContentApiUrl.js","sourceRoot":"","sources":["../../src/utils/getContentApiUrl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC7C,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IAClD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,IAAI;QACtD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,IAAI;YACzC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,OAAO,CAAC;IAElB,OAAO,gBAAgB,CAAC,GAAG,OAAO,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Context, LocaleMapping } from '../types';
2
+ export declare function getLocaleMapping(context: Context): LocaleMapping;
@@ -0,0 +1,19 @@
1
+ import { PROJECT_ID_HEADER } from '../common/constants';
2
+ import { getLocaleMappingByProjectId } from './getLocaleMappingByProjectId';
3
+ import { getLocaleMappingByLocale } from './getLocaleMappingByLocale';
4
+ export function getLocaleMapping(context) {
5
+ var _a;
6
+ const projectId = (_a = context.headers) === null || _a === void 0 ? void 0 : _a.get(PROJECT_ID_HEADER);
7
+ let config;
8
+ if (projectId) {
9
+ // first use project id header
10
+ config = getLocaleMappingByProjectId(projectId, false);
11
+ }
12
+ if (!config) {
13
+ // next try to use locale from url
14
+ // it will fall back to default locale if not found
15
+ config = getLocaleMappingByLocale(context.locale);
16
+ }
17
+ return config;
18
+ }
19
+ //# sourceMappingURL=getLocaleMapping.js.map