@enonic/nextjs-adapter 2.0.0 → 3.0.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 (245) hide show
  1. package/baseMappings.js +3 -2
  2. package/baseMappings.js.map +1 -0
  3. package/client.d.ts +1 -0
  4. package/client.js +3 -0
  5. package/client.js.map +1 -0
  6. package/common/ComponentRegistry.d.ts +34 -0
  7. package/{ComponentRegistry.js → common/ComponentRegistry.js} +26 -26
  8. package/common/ComponentRegistry.js.map +1 -0
  9. package/{UrlProcessor.d.ts → common/UrlProcessor.d.ts} +5 -4
  10. package/{UrlProcessor.js → common/UrlProcessor.js} +40 -17
  11. package/common/UrlProcessor.js.map +1 -0
  12. package/common/constants.d.ts +50 -0
  13. package/common/constants.js +79 -0
  14. package/common/constants.js.map +1 -0
  15. package/common/env.d.ts +11 -0
  16. package/common/env.js +28 -0
  17. package/common/env.js.map +1 -0
  18. package/guillotine/applyProcessors.d.ts +2 -0
  19. package/guillotine/applyProcessors.js +33 -0
  20. package/guillotine/applyProcessors.js.map +1 -0
  21. package/guillotine/buildComponentTree.d.ts +2 -0
  22. package/guillotine/buildComponentTree.js +45 -0
  23. package/guillotine/buildComponentTree.js.map +1 -0
  24. package/guillotine/buildErrorResponse.d.ts +3 -0
  25. package/guillotine/buildErrorResponse.js +26 -0
  26. package/guillotine/buildErrorResponse.js.map +1 -0
  27. package/guillotine/buildPage.d.ts +2 -0
  28. package/guillotine/buildPage.js +10 -0
  29. package/guillotine/buildPage.js.map +1 -0
  30. package/guillotine/collectComponentDescriptors.d.ts +6 -0
  31. package/guillotine/collectComponentDescriptors.js +43 -0
  32. package/guillotine/collectComponentDescriptors.js.map +1 -0
  33. package/guillotine/combineMultipleQueries.d.ts +2 -0
  34. package/guillotine/combineMultipleQueries.js +58 -0
  35. package/guillotine/combineMultipleQueries.js.map +1 -0
  36. package/guillotine/createMetaData.d.ts +17 -0
  37. package/guillotine/createMetaData.js +44 -0
  38. package/guillotine/createMetaData.js.map +1 -0
  39. package/guillotine/fetchContent.d.ts +1 -41
  40. package/guillotine/fetchContent.js +193 -800
  41. package/guillotine/fetchContent.js.map +1 -0
  42. package/guillotine/fetchContentData.d.ts +2 -0
  43. package/guillotine/fetchContentData.js +27 -0
  44. package/guillotine/fetchContentData.js.map +1 -0
  45. package/guillotine/fetchContentPathsForAllLocales.d.ts +2 -0
  46. package/guillotine/fetchContentPathsForAllLocales.js +21 -0
  47. package/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
  48. package/guillotine/fetchContentPathsForLocale.d.ts +2 -0
  49. package/guillotine/fetchContentPathsForLocale.js +40 -0
  50. package/guillotine/fetchContentPathsForLocale.js.map +1 -0
  51. package/guillotine/fetchFromApi.d.ts +3 -0
  52. package/guillotine/fetchFromApi.js +65 -0
  53. package/guillotine/fetchFromApi.js.map +1 -0
  54. package/guillotine/fetchGuillotine.d.ts +3 -0
  55. package/guillotine/fetchGuillotine.js +55 -0
  56. package/guillotine/fetchGuillotine.js.map +1 -0
  57. package/guillotine/fetchMetaData.d.ts +2 -0
  58. package/guillotine/fetchMetaData.js +30 -0
  59. package/guillotine/fetchMetaData.js.map +1 -0
  60. package/guillotine/getCleanContentPathArrayOrThrow400.d.ts +2 -0
  61. package/guillotine/getCleanContentPathArrayOrThrow400.js +20 -0
  62. package/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
  63. package/guillotine/getComponentConfig.d.ts +2 -0
  64. package/guillotine/getComponentConfig.js +5 -0
  65. package/guillotine/getComponentConfig.js.map +1 -0
  66. package/guillotine/getContentAndComponentPaths.d.ts +1 -0
  67. package/guillotine/getContentAndComponentPaths.js +12 -0
  68. package/guillotine/getContentAndComponentPaths.js.map +1 -0
  69. package/guillotine/getMetaData.d.ts +0 -92
  70. package/guillotine/getMetaData.js +47 -109
  71. package/guillotine/getMetaData.js.map +1 -0
  72. package/guillotine/getParentRegion.d.ts +2 -0
  73. package/guillotine/getParentRegion.js +40 -0
  74. package/guillotine/getParentRegion.js.map +1 -0
  75. package/guillotine/getQueryAndVariables.d.ts +2 -0
  76. package/guillotine/getQueryAndVariables.js +32 -0
  77. package/guillotine/getQueryAndVariables.js.map +1 -0
  78. package/guillotine/metadata/configQuery.d.ts +2 -0
  79. package/guillotine/metadata/configQuery.js +36 -0
  80. package/guillotine/metadata/configQuery.js.map +1 -0
  81. package/guillotine/metadata/richTextQuery.d.ts +1 -0
  82. package/guillotine/metadata/richTextQuery.js +32 -0
  83. package/guillotine/metadata/richTextQuery.js.map +1 -0
  84. package/guillotine/parseComponentPath.d.ts +2 -0
  85. package/guillotine/parseComponentPath.js +22 -0
  86. package/guillotine/parseComponentPath.js.map +1 -0
  87. package/guillotine/prefixLayoutPath.d.ts +1 -0
  88. package/guillotine/prefixLayoutPath.js +13 -0
  89. package/guillotine/prefixLayoutPath.js.map +1 -0
  90. package/guillotine/processComponentConfig.d.ts +2 -0
  91. package/guillotine/processComponentConfig.js +30 -0
  92. package/guillotine/processComponentConfig.js.map +1 -0
  93. package/guillotine/restrictComponentsToPath.d.ts +2 -0
  94. package/guillotine/restrictComponentsToPath.js +35 -0
  95. package/guillotine/restrictComponentsToPath.js.map +1 -0
  96. package/guillotine/validateData.d.ts +2 -0
  97. package/guillotine/validateData.js +7 -0
  98. package/guillotine/validateData.js.map +1 -0
  99. package/guillotine/validateNotFound.d.ts +2 -0
  100. package/guillotine/validateNotFound.js +16 -0
  101. package/guillotine/validateNotFound.js.map +1 -0
  102. package/guillotine/validateShortcut.d.ts +2 -0
  103. package/guillotine/validateShortcut.js +29 -0
  104. package/guillotine/validateShortcut.js.map +1 -0
  105. package/i18n/LocaleContext.d.ts +7 -0
  106. package/i18n/LocaleContext.jsx +46 -0
  107. package/i18n/LocaleContext.jsx.map +1 -0
  108. package/i18n/i18n.d.ts +11 -0
  109. package/i18n/i18n.js +57 -0
  110. package/i18n/i18n.js.map +1 -0
  111. package/index.d.ts +18 -5
  112. package/index.js +18 -5
  113. package/index.js.map +1 -0
  114. package/package.json +67 -16
  115. package/query/Shortcut.js +1 -0
  116. package/query/Shortcut.js.map +1 -0
  117. package/types/component.d.ts +114 -0
  118. package/types/component.js +2 -0
  119. package/types/component.js.map +1 -0
  120. package/types/componentProps.d.ts +104 -0
  121. package/types/componentProps.js +2 -0
  122. package/types/componentProps.js.map +1 -0
  123. package/types/guillotine.d.ts +342 -0
  124. package/types/guillotine.js +2 -0
  125. package/types/guillotine.js.map +1 -0
  126. package/types/i18n.d.ts +7 -0
  127. package/types/i18n.js +2 -0
  128. package/types/i18n.js.map +1 -0
  129. package/types/index.d.ts +45 -0
  130. package/types/index.js +3 -0
  131. package/types/index.js.map +1 -0
  132. package/types/next.d.ts +6 -0
  133. package/types/next.js +2 -0
  134. package/types/next.js.map +1 -0
  135. package/types/util.d.ts +3 -0
  136. package/types/util.js +3 -0
  137. package/types/util.js.map +1 -0
  138. package/utils/addLineNumbers.d.ts +1 -0
  139. package/utils/addLineNumbers.js +4 -0
  140. package/utils/addLineNumbers.js.map +1 -0
  141. package/utils/buildGuillotineRequestHeaders.d.ts +7 -0
  142. package/utils/buildGuillotineRequestHeaders.js +16 -0
  143. package/utils/buildGuillotineRequestHeaders.js.map +1 -0
  144. package/utils/commonChars.d.ts +1 -0
  145. package/utils/commonChars.js +17 -0
  146. package/utils/commonChars.js.map +1 -0
  147. package/utils/fixDoubleSlashes.d.ts +1 -0
  148. package/utils/fixDoubleSlashes.js +4 -0
  149. package/utils/fixDoubleSlashes.js.map +1 -0
  150. package/utils/getContentApiUrl.d.ts +2 -0
  151. package/utils/getContentApiUrl.js +15 -0
  152. package/utils/getContentApiUrl.js.map +1 -0
  153. package/utils/getProjectLocaleConfig.d.ts +2 -0
  154. package/utils/getProjectLocaleConfig.js +19 -0
  155. package/utils/getProjectLocaleConfig.js.map +1 -0
  156. package/utils/getProjectLocaleConfigById.d.ts +2 -0
  157. package/utils/getProjectLocaleConfigById.js +16 -0
  158. package/utils/getProjectLocaleConfigById.js.map +1 -0
  159. package/utils/getProjectLocaleConfigByLocale.d.ts +2 -0
  160. package/utils/getProjectLocaleConfigByLocale.js +13 -0
  161. package/utils/getProjectLocaleConfigByLocale.js.map +1 -0
  162. package/utils/getProjectLocaleConfigs.d.ts +2 -0
  163. package/utils/getProjectLocaleConfigs.js +30 -0
  164. package/utils/getProjectLocaleConfigs.js.map +1 -0
  165. package/utils/getProjectLocales.d.ts +1 -0
  166. package/utils/getProjectLocales.js +5 -0
  167. package/utils/getProjectLocales.js.map +1 -0
  168. package/utils/getRenderMode.d.ts +3 -0
  169. package/utils/getRenderMode.js +8 -0
  170. package/utils/getRenderMode.js.map +1 -0
  171. package/utils/getRequestLocaleInfo.d.ts +6 -0
  172. package/utils/getRequestLocaleInfo.js +26 -0
  173. package/utils/getRequestLocaleInfo.js.map +1 -0
  174. package/utils/getXpBaseUrl.d.ts +2 -0
  175. package/utils/getXpBaseUrl.js +8 -0
  176. package/utils/getXpBaseUrl.js.map +1 -0
  177. package/utils/indent.d.ts +1 -0
  178. package/utils/indent.js +5 -0
  179. package/utils/indent.js.map +1 -0
  180. package/utils/sanitizeGraphqlName.d.ts +1 -0
  181. package/utils/sanitizeGraphqlName.js +12 -0
  182. package/utils/sanitizeGraphqlName.js.map +1 -0
  183. package/views/BaseComponent.d.ts +5 -10
  184. package/views/BaseComponent.jsx +17 -6
  185. package/views/BaseComponent.jsx.map +1 -0
  186. package/views/BaseContent.d.ts +3 -3
  187. package/views/BaseContent.jsx +2 -5
  188. package/views/BaseContent.jsx.map +1 -0
  189. package/views/BaseLayout.d.ts +3 -16
  190. package/views/BaseLayout.jsx +3 -3
  191. package/views/BaseLayout.jsx.map +1 -0
  192. package/views/BaseMacro.d.ts +3 -13
  193. package/views/BaseMacro.jsx +4 -3
  194. package/views/BaseMacro.jsx.map +1 -0
  195. package/views/BasePage.d.ts +3 -18
  196. package/views/BasePage.jsx +3 -3
  197. package/views/BasePage.jsx.map +1 -0
  198. package/views/BasePart.d.ts +3 -18
  199. package/views/BasePart.jsx +3 -3
  200. package/views/BasePart.jsx.map +1 -0
  201. package/views/Empty.d.ts +2 -2
  202. package/views/Empty.jsx +2 -1
  203. package/views/Empty.jsx.map +1 -0
  204. package/views/Fragment.d.ts +3 -9
  205. package/views/Fragment.jsx +2 -2
  206. package/views/Fragment.jsx.map +1 -0
  207. package/views/MainView.d.ts +3 -3
  208. package/views/MainView.jsx +2 -2
  209. package/views/MainView.jsx.map +1 -0
  210. package/views/PropsView.d.ts +3 -0
  211. package/views/PropsView.jsx +21 -0
  212. package/views/PropsView.jsx.map +1 -0
  213. package/views/Region.d.ts +4 -17
  214. package/views/Region.jsx +2 -2
  215. package/views/Region.jsx.map +1 -0
  216. package/views/RichTextView.d.ts +3 -13
  217. package/views/RichTextView.jsx +6 -3
  218. package/views/RichTextView.jsx.map +1 -0
  219. package/views/SingleComponent.d.ts +3 -3
  220. package/views/SingleComponent.jsx +1 -2
  221. package/views/SingleComponent.jsx.map +1 -0
  222. package/views/StaticContent.d.ts +2 -6
  223. package/views/StaticContent.jsx +1 -0
  224. package/views/StaticContent.jsx.map +1 -0
  225. package/views/Text.d.ts +5 -5
  226. package/views/Text.jsx +1 -1
  227. package/views/Text.jsx.map +1 -0
  228. package/views/getClientHydratedHtml.d.ts +2 -0
  229. package/views/getClientHydratedHtml.jsx +9 -0
  230. package/views/getClientHydratedHtml.jsx.map +1 -0
  231. package/views/macros/DefaultMacro.d.ts +1 -1
  232. package/views/macros/DefaultMacro.jsx +1 -0
  233. package/views/macros/DefaultMacro.jsx.map +1 -0
  234. package/views/macros/DisableMacro.d.ts +1 -1
  235. package/views/macros/DisableMacro.jsx +1 -0
  236. package/views/macros/DisableMacro.jsx.map +1 -0
  237. package/ComponentRegistry.d.ts +0 -64
  238. package/server/ClearableFileCache.d.ts +0 -31
  239. package/server/ClearableFileCache.js +0 -472
  240. package/server/cache.d.ts +0 -2
  241. package/server/cache.js +0 -129
  242. package/server/index.d.ts +0 -5
  243. package/server/index.js +0 -132
  244. package/utils.d.ts +0 -114
  245. package/utils.js +0 -241
@@ -0,0 +1,342 @@
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
+ Cookie?: string;
42
+ locale: string;
43
+ locales: string;
44
+ 'default-locale': string;
45
+ }
46
+ export type GuillotineResult = Result & Record<string, any>;
47
+ export interface MetaResult extends Result {
48
+ meta?: {
49
+ _path: string;
50
+ type: string;
51
+ pageAsJson?: PageData;
52
+ components?: PageComponent[];
53
+ };
54
+ }
55
+ export interface Result {
56
+ error?: {
57
+ code: string;
58
+ message: string;
59
+ } | null;
60
+ }
61
+ interface AccessControlEntry {
62
+ principal: PrincipalKey;
63
+ allow: [Permission];
64
+ deny: [Permission];
65
+ }
66
+ interface Attachment {
67
+ name: string;
68
+ label: string;
69
+ size: number;
70
+ mimeType: string;
71
+ attachmentUrl: string;
72
+ }
73
+ type DateTime = string;
74
+ export interface Component {
75
+ type: ComponentType;
76
+ path: string;
77
+ page?: PageComponentData | null;
78
+ layout?: LayoutComponentData | null;
79
+ image?: ImageComponentData | null;
80
+ part?: PartComponentData | null;
81
+ text?: TextComponentData | null;
82
+ fragment?: FragmentComponentData | null;
83
+ }
84
+ type ComponentType = 'page' | 'layout' | 'image' | 'part' | 'text' | 'fragment';
85
+ interface Content {
86
+ _id: string;
87
+ _name: string;
88
+ _path: string;
89
+ _references?: Content[];
90
+ _score?: number;
91
+ creator?: PrincipalKey;
92
+ modifier?: PrincipalKey;
93
+ createdTime?: DateTime;
94
+ modifiedTime?: DateTime;
95
+ owner?: PrincipalKey;
96
+ type?: string;
97
+ contentType?: ContentType;
98
+ displayName?: string;
99
+ hasChildren?: boolean;
100
+ language?: string;
101
+ valid?: boolean;
102
+ dataAsJson?: JSON;
103
+ x?: ExtraData;
104
+ xAsJson?: JSON;
105
+ pageAsJson?: JSON;
106
+ pageTemplate?: Content;
107
+ components?: Component[];
108
+ attachments?: Attachment[];
109
+ publish?: PublishInfo;
110
+ pageUrl?: string;
111
+ site?: portal_Site;
112
+ parent?: Content;
113
+ children?: Content[];
114
+ childrenConnection?: ContentConnection;
115
+ permissions?: Permissions;
116
+ }
117
+ interface ContentConnection {
118
+ totalCount: Int;
119
+ edges: ContentEdge[];
120
+ pageInfo: PageInfo;
121
+ }
122
+ interface ContentEdge {
123
+ node: Content;
124
+ cursor: string;
125
+ }
126
+ interface ContentType {
127
+ name: string;
128
+ displayName: string;
129
+ description: string;
130
+ superType: string;
131
+ abstract: boolean;
132
+ final: boolean;
133
+ allowChildContent: boolean;
134
+ contentDisplayNameScript: string;
135
+ icon: Icon;
136
+ form: FormItem[];
137
+ formAsJson: JSON;
138
+ getInstances: Content[];
139
+ getInstanceConnection: ContentConnection;
140
+ }
141
+ type ExtraData<App = Record<string, unknown>> = App & {
142
+ media: XData_media_ApplicationConfig;
143
+ base: XData_base_ApplicationConfig;
144
+ };
145
+ type Float = number;
146
+ interface FormItem {
147
+ formItemType: FormItemType;
148
+ name: string;
149
+ label: string;
150
+ }
151
+ type FormItemType = 'ItemSet' | 'Layout' | 'Input' | 'OptionSet';
152
+ interface FragmentComponentData {
153
+ id: string;
154
+ fragment: Content;
155
+ }
156
+ interface GeoPoint {
157
+ value: string;
158
+ latitude: Float;
159
+ longitude: Float;
160
+ }
161
+ export interface HeadlessCms {
162
+ get?: Content;
163
+ getChildren?: Content[];
164
+ getChildrenConnection?: ContentConnection;
165
+ getPermissions?: Permissions;
166
+ getSite?: portal_Site;
167
+ getType?: ContentType;
168
+ getTypes?: ContentType[];
169
+ query?: Content[];
170
+ queryConnection?: QueryContentConnection;
171
+ queryDsl?: Content[];
172
+ queryDslConnection?: QueryDSLContentConnection;
173
+ }
174
+ interface Icon {
175
+ mimeType: string;
176
+ modifiedTime: string;
177
+ }
178
+ interface Image {
179
+ image: Content;
180
+ ref: string;
181
+ style: ImageStyle;
182
+ }
183
+ interface ImageComponentData {
184
+ id: string;
185
+ caption?: string;
186
+ image: media_Image;
187
+ }
188
+ interface ImageStyle {
189
+ name: string;
190
+ aspectRatio: string;
191
+ filter: string;
192
+ }
193
+ type Int = number;
194
+ type JSON = Record<string, unknown>;
195
+ interface LayoutComponentData {
196
+ descriptor: string;
197
+ configAsJson: JSON | null;
198
+ }
199
+ interface Link {
200
+ ref: string;
201
+ uri: string;
202
+ media: Media;
203
+ content: Content;
204
+ }
205
+ type LocalDateTime = string;
206
+ interface Macro_system_disable_DataConfig {
207
+ body: string;
208
+ }
209
+ interface Macro_system_embed_DataConfig {
210
+ body: string;
211
+ }
212
+ interface Macro {
213
+ ref: string;
214
+ name: string;
215
+ descriptor: string;
216
+ config: MacroConfig;
217
+ }
218
+ interface MacroConfig {
219
+ disable: Macro_system_disable_DataConfig;
220
+ embed: Macro_system_embed_DataConfig;
221
+ }
222
+ interface Media {
223
+ content: Content;
224
+ intent: MediaIntentType;
225
+ }
226
+ type MediaIntentType = 'download' | 'inline';
227
+ interface media_Image extends Content {
228
+ mediaUrl: string;
229
+ imageUrl: string;
230
+ data: media_Image_Data;
231
+ }
232
+ interface media_Image_Data {
233
+ media: MediaUploader;
234
+ caption: string;
235
+ altText: string;
236
+ artist: string[];
237
+ copyright: string;
238
+ tags: string[];
239
+ }
240
+ interface MediaFocalPoint {
241
+ x: number;
242
+ y: number;
243
+ }
244
+ interface MediaUploader {
245
+ attachment: string;
246
+ focalPoint: MediaFocalPoint;
247
+ }
248
+ interface PageComponentData {
249
+ descriptor?: string;
250
+ customized?: boolean;
251
+ configAsJson?: JSON;
252
+ template?: Content | null;
253
+ }
254
+ interface PageInfo {
255
+ startCursor: string;
256
+ endCursor: string;
257
+ hasNext: boolean;
258
+ }
259
+ interface PartComponentData<Config = Record<string, unknown>> {
260
+ descriptor: string;
261
+ config: Config;
262
+ configAsJson: JSON;
263
+ }
264
+ type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
265
+ interface Permissions {
266
+ inheritsPermissions: boolean;
267
+ permissions: AccessControlEntry[];
268
+ }
269
+ interface portal_Site extends Content {
270
+ data: portal_Site_Data;
271
+ }
272
+ interface portal_Site_Data {
273
+ description: string;
274
+ }
275
+ type PrincipalType = 'user' | 'group' | 'role';
276
+ interface PrincipalKey {
277
+ value: string;
278
+ type: PrincipalType;
279
+ idProvider: string;
280
+ principalId: string;
281
+ }
282
+ interface QueryContentConnection extends ContentConnection {
283
+ aggregationsAsJson: JSON;
284
+ }
285
+ interface QueryDSLContentConnection extends QueryContentConnection {
286
+ highlightAsJson: JSON;
287
+ }
288
+ interface RichText {
289
+ raw: string;
290
+ processedHtml: string;
291
+ macrosAsJson: JSON;
292
+ macros: Macro[];
293
+ images: Image[];
294
+ links: Link[];
295
+ }
296
+ interface TextComponentData {
297
+ value: RichText;
298
+ }
299
+ interface XData_base_ApplicationConfig {
300
+ gpsInfo: XData_base_gpsInfo_DataConfig;
301
+ }
302
+ interface XData_base_gpsInfo_DataConfig {
303
+ geoPoint: GeoPoint;
304
+ altitude: String;
305
+ direction: String;
306
+ }
307
+ interface XData_media_ApplicationConfig {
308
+ imageInfo: XData_media_imageInfo_DataConfig;
309
+ cameraInfo: XData_media_cameraInfo_DataConfig;
310
+ }
311
+ interface XData_media_imageInfo_DataConfig {
312
+ pixelSize: number;
313
+ imageHeight: number;
314
+ imageWidth: number;
315
+ contentType: string;
316
+ description: string;
317
+ byteSize: number;
318
+ colorSpace: string[];
319
+ fileSource: string;
320
+ }
321
+ interface XData_media_cameraInfo_DataConfig {
322
+ date: LocalDateTime;
323
+ make: string;
324
+ model: string;
325
+ lens: string;
326
+ iso: string;
327
+ focalLength: string;
328
+ focalLength35: string;
329
+ exposureBias: string;
330
+ aperture: string[];
331
+ shutterTime: string;
332
+ flash: string;
333
+ autoFlashCompensation: string;
334
+ whiteBalance: string;
335
+ exposureProgram: string;
336
+ shootingMode: string;
337
+ meteringMode: string;
338
+ exposureMode: string;
339
+ focusDistance: string;
340
+ orientation: string;
341
+ }
342
+ 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
+ }
package/types/i18n.js ADDED
@@ -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":""}
@@ -0,0 +1,45 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="react" />
3
+ export type * from './component';
4
+ export type * from './componentProps';
5
+ export type * from './guillotine';
6
+ export type * from './i18n';
7
+ export type * from './next';
8
+ export type * from './util';
9
+ export interface ContentApiBaseBody {
10
+ query?: string;
11
+ variables?: {
12
+ path?: string;
13
+ [key: string]: string | number | undefined;
14
+ };
15
+ }
16
+ export interface ContentPathItem {
17
+ contentPath: string[];
18
+ locale: string;
19
+ }
20
+ export interface PathFragment {
21
+ index: number;
22
+ region: string;
23
+ }
24
+ export interface PreviewParams {
25
+ contentPath: string[];
26
+ headers: Record<string, string>;
27
+ params: Record<string, string>;
28
+ }
29
+ export interface ProjectLocaleConfig {
30
+ default: boolean;
31
+ project: string;
32
+ site: string;
33
+ locale: string;
34
+ }
35
+ export type ProjectLocalesConfig = Record<string, ProjectLocaleConfig>;
36
+ export type SelectorName = 'contentType' | 'page' | 'component' | 'part' | 'layout' | 'macro';
37
+ export interface ServerSideParams extends NodeJS.Dict<string | string[]> {
38
+ contentPath?: string[];
39
+ mode?: string;
40
+ }
41
+ export interface StaticContentProps extends Record<string, any> {
42
+ children?: React.ReactNode;
43
+ element?: string;
44
+ condition: boolean;
45
+ }
package/types/index.js ADDED
@@ -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
+ }
package/types/next.js ADDED
@@ -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
+ };
package/types/util.js ADDED
@@ -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,EACH,0BAA0B,EAC1B,iBAAiB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,6BAA6B,CAAC,EAC1C,OAAO,EACP,aAAa,EACb,MAAM,EACN,OAAO,GAMV;;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;
@@ -0,0 +1,17 @@
1
+ export const commonChars = (s1, s2) => {
2
+ let result = '';
3
+ if (!s1 || s1.length === 0 || !s2 || s2.length === 0) {
4
+ return result;
5
+ }
6
+ for (let i = 0; i < s1.length; i++) {
7
+ const s1Element = s1[i];
8
+ if (s2[i] === s1Element) {
9
+ result += s1Element;
10
+ }
11
+ else {
12
+ break;
13
+ }
14
+ }
15
+ return result;
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 @@
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,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 { getProjectLocaleConfig } from './getProjectLocaleConfig';
4
+ import { fixDoubleSlashes } from './fixDoubleSlashes';
5
+ import { getRenderMode } from './getRenderMode';
6
+ export function getContentApiUrl(context) {
7
+ const project = getProjectLocaleConfig(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,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,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,sBAAsB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IACxD,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, ProjectLocaleConfig } from '../types';
2
+ export declare function getProjectLocaleConfig(context: Context): ProjectLocaleConfig;
@@ -0,0 +1,19 @@
1
+ import { PROJECT_ID_HEADER } from '../common/constants';
2
+ import { getProjectLocaleConfigById } from './getProjectLocaleConfigById';
3
+ import { getProjectLocaleConfigByLocale } from './getProjectLocaleConfigByLocale';
4
+ export function getProjectLocaleConfig(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 = getProjectLocaleConfigById(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 = getProjectLocaleConfigByLocale(context.locale);
16
+ }
17
+ return config;
18
+ }
19
+ //# sourceMappingURL=getProjectLocaleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getProjectLocaleConfig.js","sourceRoot":"","sources":["../../src/utils/getProjectLocaleConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAGhF,MAAM,UAAU,sBAAsB,CAAC,OAAgB;;IACnD,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAE1D,IAAI,MAA2B,CAAC;IAChC,IAAI,SAAS,EAAE,CAAC;QACZ,8BAA8B;QAC9B,MAAM,GAAG,0BAA0B,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,kCAAkC;QAClC,mDAAmD;QACnD,MAAM,GAAG,8BAA8B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProjectLocaleConfig } from '../types';
2
+ export declare function getProjectLocaleConfigById(projectId?: string, useDefault?: boolean): ProjectLocaleConfig;
@@ -0,0 +1,16 @@
1
+ import { getProjectLocaleConfigs } from './getProjectLocaleConfigs';
2
+ export function getProjectLocaleConfigById(projectId, useDefault = true) {
3
+ const configs = getProjectLocaleConfigs();
4
+ let config;
5
+ if (projectId) {
6
+ config = Object.values(configs).find(p => {
7
+ var _a;
8
+ return ((_a = p === null || p === void 0 ? void 0 : p.project) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === projectId.toLowerCase();
9
+ });
10
+ }
11
+ if (!config && useDefault) {
12
+ config = Object.values(configs).find(c => c.default);
13
+ }
14
+ return config;
15
+ }
16
+ //# sourceMappingURL=getProjectLocaleConfigById.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getProjectLocaleConfigById.js","sourceRoot":"","sources":["../../src/utils/getProjectLocaleConfigById.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAGlE,MAAM,UAAU,0BAA0B,CAAC,SAAkB,EAAE,UAAU,GAAG,IAAI;IAC5E,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,MAA2B,CAAC;IAChC,IAAI,SAAS,EAAE,CAAC;QACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;;YACrC,OAAO,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,0CAAE,WAAW,EAAE,MAAK,SAAS,CAAC,WAAW,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProjectLocaleConfig } from '../types';
2
+ export declare function getProjectLocaleConfigByLocale(locale?: string, useDefault?: boolean): ProjectLocaleConfig;
@@ -0,0 +1,13 @@
1
+ import { getProjectLocaleConfigs } from './getProjectLocaleConfigs';
2
+ export function getProjectLocaleConfigByLocale(locale, useDefault = true) {
3
+ const configs = getProjectLocaleConfigs();
4
+ let config;
5
+ if (locale) {
6
+ config = configs[locale];
7
+ }
8
+ if (!config && useDefault) {
9
+ config = Object.values(configs).find(c => c.default);
10
+ }
11
+ return config;
12
+ }
13
+ //# sourceMappingURL=getProjectLocaleConfigByLocale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getProjectLocaleConfigByLocale.js","sourceRoot":"","sources":["../../src/utils/getProjectLocaleConfigByLocale.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAGlE,MAAM,UAAU,8BAA8B,CAAC,MAAe,EAAE,UAAU,GAAG,IAAI;IAC7E,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,MAA2B,CAAC;IAChC,IAAI,MAAM,EAAE,CAAC;QACT,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProjectLocalesConfig } from '../types';
2
+ export declare function getProjectLocaleConfigs(): ProjectLocalesConfig;