@enonic/nextjs-adapter 3.0.0-B2 → 3.0.0-B4

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 (173) hide show
  1. package/LICENSE +201 -0
  2. package/baseMappings.js.map +1 -1
  3. package/client.js.map +1 -1
  4. package/common/ComponentRegistry.js.map +1 -1
  5. package/common/UrlProcessor.js.map +1 -1
  6. package/common/constants.js.map +1 -1
  7. package/common/env.js +14 -13
  8. package/common/env.js.map +1 -1
  9. package/guillotine/applyProcessors.js.map +1 -1
  10. package/guillotine/buildComponentTree.js.map +1 -1
  11. package/guillotine/buildErrorResponse.js.map +1 -1
  12. package/guillotine/buildPage.js.map +1 -1
  13. package/guillotine/collectComponentDescriptors.js.map +1 -1
  14. package/guillotine/combineMultipleQueries.js.map +1 -1
  15. package/guillotine/createMetaData.js.map +1 -1
  16. package/guillotine/fetchContent.d.ts +2 -2
  17. package/guillotine/fetchContent.js +172 -170
  18. package/guillotine/fetchContent.js.map +1 -1
  19. package/guillotine/fetchContentData.js.map +1 -1
  20. package/guillotine/fetchContentPathsForAllLocales.js.map +1 -1
  21. package/guillotine/fetchContentPathsForLocale.js.map +1 -1
  22. package/guillotine/fetchFromApi.d.ts +1 -1
  23. package/guillotine/fetchFromApi.js +56 -54
  24. package/guillotine/fetchFromApi.js.map +1 -1
  25. package/guillotine/fetchGuillotine.d.ts +1 -1
  26. package/guillotine/fetchGuillotine.js +38 -36
  27. package/guillotine/fetchGuillotine.js.map +1 -1
  28. package/guillotine/fetchMetaData.js.map +1 -1
  29. package/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -1
  30. package/guillotine/getComponentConfig.js.map +1 -1
  31. package/guillotine/getContentAndComponentPaths.js.map +1 -1
  32. package/guillotine/getMetaData.js.map +1 -1
  33. package/guillotine/getParentRegion.js.map +1 -1
  34. package/guillotine/getQueryAndVariables.js.map +1 -1
  35. package/guillotine/metadata/configQuery.js.map +1 -1
  36. package/guillotine/metadata/richTextQuery.js.map +1 -1
  37. package/guillotine/parseComponentPath.js.map +1 -1
  38. package/guillotine/prefixLayoutPath.js.map +1 -1
  39. package/guillotine/processComponentConfig.js.map +1 -1
  40. package/guillotine/restrictComponentsToPath.js.map +1 -1
  41. package/guillotine/validateData.js.map +1 -1
  42. package/guillotine/validateNotFound.js.map +1 -1
  43. package/guillotine/validateShortcut.js.map +1 -1
  44. package/i18n/LocaleContext.jsx.map +1 -1
  45. package/i18n/i18n.js.map +1 -1
  46. package/index.d.ts +1 -5
  47. package/index.js +1 -5
  48. package/index.js.map +1 -1
  49. package/package.json +15 -16
  50. package/query/Shortcut.js.map +1 -1
  51. package/server.d.ts +5 -0
  52. package/server.js +6 -0
  53. package/server.js.map +1 -0
  54. package/src/baseMappings.ts +53 -0
  55. package/src/client.ts +2 -0
  56. package/src/common/ComponentRegistry.ts +162 -0
  57. package/src/common/UrlProcessor.ts +142 -0
  58. package/src/common/constants.ts +85 -0
  59. package/src/common/env.ts +39 -0
  60. package/src/guillotine/applyProcessors.ts +38 -0
  61. package/src/guillotine/buildComponentTree.ts +63 -0
  62. package/src/guillotine/buildErrorResponse.ts +39 -0
  63. package/src/guillotine/buildPage.ts +15 -0
  64. package/src/guillotine/collectComponentDescriptors.ts +63 -0
  65. package/src/guillotine/combineMultipleQueries.ts +75 -0
  66. package/src/guillotine/createMetaData.ts +73 -0
  67. package/src/guillotine/fetchContent.ts +250 -0
  68. package/src/guillotine/fetchContentData.ts +33 -0
  69. package/src/guillotine/fetchContentPathsForAllLocales.ts +21 -0
  70. package/src/guillotine/fetchContentPathsForLocale.ts +42 -0
  71. package/src/guillotine/fetchFromApi.ts +69 -0
  72. package/src/guillotine/fetchGuillotine.ts +61 -0
  73. package/src/guillotine/fetchMetaData.ts +32 -0
  74. package/src/guillotine/getCleanContentPathArrayOrThrow400.ts +22 -0
  75. package/src/guillotine/getComponentConfig.ts +7 -0
  76. package/src/guillotine/getContentAndComponentPaths.ts +11 -0
  77. package/src/guillotine/getMetaData.ts +73 -0
  78. package/src/guillotine/getParentRegion.ts +59 -0
  79. package/src/guillotine/getQueryAndVariables.ts +52 -0
  80. package/src/guillotine/metadata/configQuery.ts +46 -0
  81. package/src/guillotine/metadata/richTextQuery.ts +34 -0
  82. package/src/guillotine/parseComponentPath.ts +29 -0
  83. package/src/guillotine/prefixLayoutPath.ts +16 -0
  84. package/src/guillotine/processComponentConfig.ts +38 -0
  85. package/src/guillotine/restrictComponentsToPath.ts +45 -0
  86. package/src/guillotine/validateData.ts +11 -0
  87. package/src/guillotine/validateNotFound.ts +20 -0
  88. package/src/guillotine/validateShortcut.ts +37 -0
  89. package/src/i18n/LocaleContext.tsx +54 -0
  90. package/src/i18n/i18n.ts +54 -0
  91. package/src/index.ts +42 -0
  92. package/src/query/Shortcut.ts +14 -0
  93. package/src/server.ts +5 -0
  94. package/src/types/component.ts +147 -0
  95. package/src/types/componentProps.ts +142 -0
  96. package/src/types/guillotine.ts +426 -0
  97. package/src/types/i18n.ts +8 -0
  98. package/src/types/index.ts +58 -0
  99. package/src/types/next.ts +7 -0
  100. package/src/types/util.ts +5 -0
  101. package/src/utils/addLineNumbers.ts +3 -0
  102. package/src/utils/buildGuillotineRequestHeaders.ts +32 -0
  103. package/src/utils/commonChars.ts +16 -0
  104. package/src/utils/fixDoubleSlashes.ts +3 -0
  105. package/src/utils/getContentApiUrl.ts +20 -0
  106. package/src/utils/getProjectLocaleConfig.ts +24 -0
  107. package/src/utils/getProjectLocaleConfigById.ts +21 -0
  108. package/src/utils/getProjectLocaleConfigByLocale.ts +19 -0
  109. package/src/utils/getProjectLocaleConfigs.ts +36 -0
  110. package/src/utils/getProjectLocales.ts +6 -0
  111. package/src/utils/getRenderMode.ts +14 -0
  112. package/src/utils/getRequestLocaleInfo.ts +29 -0
  113. package/src/utils/getXpBaseUrl.ts +12 -0
  114. package/src/utils/indent.ts +4 -0
  115. package/src/utils/sanitizeGraphqlName.ts +11 -0
  116. package/src/views/BaseComponent.tsx +153 -0
  117. package/src/views/BaseContent.tsx +47 -0
  118. package/src/views/BaseLayout.tsx +33 -0
  119. package/src/views/BaseMacro.tsx +94 -0
  120. package/src/views/BasePage.tsx +42 -0
  121. package/src/views/BasePart.tsx +34 -0
  122. package/src/views/Empty.tsx +5 -0
  123. package/src/views/Fragment.tsx +41 -0
  124. package/src/views/MainView.tsx +22 -0
  125. package/src/views/PropsView.tsx +38 -0
  126. package/src/views/Region.tsx +76 -0
  127. package/src/views/RichTextView.tsx +75 -0
  128. package/src/views/SingleComponent.tsx +19 -0
  129. package/src/views/StaticContent.tsx +39 -0
  130. package/src/views/Text.tsx +19 -0
  131. package/src/views/getClientHydratedHtml.tsx +12 -0
  132. package/src/views/macros/DefaultMacro.tsx +9 -0
  133. package/src/views/macros/DisableMacro.tsx +8 -0
  134. package/types/component.js.map +1 -1
  135. package/types/componentProps.js.map +1 -1
  136. package/types/guillotine.js.map +1 -1
  137. package/types/i18n.js.map +1 -1
  138. package/types/index.js.map +1 -1
  139. package/types/next.js.map +1 -1
  140. package/types/util.js.map +1 -1
  141. package/utils/addLineNumbers.js.map +1 -1
  142. package/utils/buildGuillotineRequestHeaders.js.map +1 -1
  143. package/utils/commonChars.js.map +1 -1
  144. package/utils/fixDoubleSlashes.js.map +1 -1
  145. package/utils/getContentApiUrl.js.map +1 -1
  146. package/utils/getProjectLocaleConfig.js.map +1 -1
  147. package/utils/getProjectLocaleConfigById.js.map +1 -1
  148. package/utils/getProjectLocaleConfigByLocale.js.map +1 -1
  149. package/utils/getProjectLocaleConfigs.js.map +1 -1
  150. package/utils/getProjectLocales.js.map +1 -1
  151. package/utils/getRenderMode.js.map +1 -1
  152. package/utils/getRequestLocaleInfo.js.map +1 -1
  153. package/utils/getXpBaseUrl.js.map +1 -1
  154. package/utils/indent.js.map +1 -1
  155. package/utils/sanitizeGraphqlName.js.map +1 -1
  156. package/views/BaseComponent.jsx.map +1 -1
  157. package/views/BaseContent.jsx.map +1 -1
  158. package/views/BaseLayout.jsx.map +1 -1
  159. package/views/BaseMacro.jsx.map +1 -1
  160. package/views/BasePage.jsx.map +1 -1
  161. package/views/BasePart.jsx.map +1 -1
  162. package/views/Empty.jsx.map +1 -1
  163. package/views/Fragment.jsx.map +1 -1
  164. package/views/MainView.jsx.map +1 -1
  165. package/views/PropsView.jsx.map +1 -1
  166. package/views/Region.jsx.map +1 -1
  167. package/views/RichTextView.jsx.map +1 -1
  168. package/views/SingleComponent.jsx.map +1 -1
  169. package/views/StaticContent.jsx.map +1 -1
  170. package/views/Text.jsx.map +1 -1
  171. package/views/getClientHydratedHtml.jsx.map +1 -1
  172. package/views/macros/DefaultMacro.jsx.map +1 -1
  173. package/views/macros/DisableMacro.jsx.map +1 -1
@@ -0,0 +1,142 @@
1
+ import {DOMNode} from 'html-react-parser';
2
+ import type {
3
+ RENDER_MODE,
4
+ XP_REQUEST_TYPE,
5
+ } from '../common/constants';
6
+ import type {
7
+ FragmentData,
8
+ LayoutData,
9
+ MacroConfig,
10
+ MacroData,
11
+ PageComponent,
12
+ PageData,
13
+ PartData,
14
+ RichTextData,
15
+ RegionTree,
16
+ } from './component';
17
+
18
+
19
+ export interface BaseComponentProps {
20
+ component: PageComponent;
21
+ meta: MetaData;
22
+ common?: any; // Content is passed down for optional consumption in componentviews.
23
+ // TODO: Use a react contextprovider instead of "manually" passing everything down
24
+ }
25
+
26
+ export interface BaseLayoutProps {
27
+ component?: LayoutData;
28
+ path: string;
29
+ regions?: RegionTree;
30
+ common?: any;
31
+ meta: MetaData;
32
+ }
33
+
34
+ export interface BaseMacroProps {
35
+ data: MacroData;
36
+ meta: MetaData;
37
+ renderInEditMode?: boolean;
38
+ }
39
+
40
+ export interface BasePageProps {
41
+ component?: PageData;
42
+ path?: string;
43
+ common?: any;
44
+ data?: any;
45
+ error?: string;
46
+ meta: MetaData;
47
+ }
48
+
49
+ export interface BasePartProps {
50
+ component?: PartData;
51
+ path: string;
52
+ common?: any;
53
+ data?: any;
54
+ error?: string;
55
+ meta: MetaData;
56
+ }
57
+
58
+ export interface FragmentProps {
59
+ page?: PageData;
60
+ component?: FragmentData;
61
+ common?: any;
62
+ meta: MetaData;
63
+ }
64
+
65
+ export interface LayoutProps {
66
+ layout: LayoutData;
67
+ path: string;
68
+ common: any;
69
+ meta: MetaData;
70
+ }
71
+
72
+ export interface MacroProps {
73
+ name: string;
74
+ config: MacroConfig;
75
+ meta: MetaData;
76
+ }
77
+
78
+ export interface MetaData {
79
+ type: string,
80
+ path: string,
81
+ requestType: XP_REQUEST_TYPE,
82
+ renderMode: RENDER_MODE,
83
+ requestedComponent?: PageComponent,
84
+ canRender: boolean,
85
+ catchAll: boolean,
86
+ apiUrl: string,
87
+ baseUrl: string,
88
+ locale: string,
89
+ defaultLocale: string,
90
+ }
91
+
92
+ export interface PageProps {
93
+ page: PageData;
94
+ path: string;
95
+ data?: any;
96
+ common?: any; // Content is passed down to componentviews. TODO: Use a react contextprovider instead?
97
+ meta: MetaData;
98
+ }
99
+
100
+ export interface PartProps {
101
+ part: PartData
102
+ path: string
103
+ data?: any
104
+ // Content is passed down to componentviews. TODO: Use a react contextprovider instead?
105
+ common?: any
106
+ meta: MetaData
107
+ }
108
+
109
+ export interface RegionProps {
110
+ name: string
111
+ components?: PageComponent[]
112
+ className?: string
113
+ // Content is passed down for optional consumption in componentviews. TODO: Use a react contextprovider instead?
114
+ common?: any
115
+ meta: MetaData
116
+ }
117
+
118
+ export interface RegionsProps {
119
+ page: PageData | null;
120
+ name?: string;
121
+ // Content is passed down for optional consumption in componentviews. TODO: Use a react contextprovider instead?
122
+ common?: any;
123
+ meta: MetaData;
124
+ }
125
+
126
+ export type Replacer = (
127
+ domNode: DOMNode,
128
+ data: RichTextData,
129
+ meta: MetaData,
130
+ renderMacroInEditMode: boolean
131
+ ) => ReplacerResult;
132
+
133
+ export type ReplacerResult = JSX.Element | object | void | undefined | null | false;
134
+
135
+ export interface RichTextViewProps {
136
+ data: RichTextData
137
+ meta: MetaData
138
+ className?: string
139
+ tag?: string
140
+ renderMacroInEditMode?: boolean
141
+ customReplacer?: Replacer
142
+ }
@@ -0,0 +1,426 @@
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
+ Cookie?: string
69
+ locale: string
70
+ locales: string
71
+ 'default-locale': string
72
+ }
73
+
74
+ export type GuillotineResult = Result & Record<string, any>;
75
+
76
+ export interface MetaResult extends Result {
77
+ meta?: {
78
+ _path: string
79
+ type: string
80
+ pageAsJson?: PageData
81
+ components?: PageComponent[]
82
+ }
83
+ }
84
+
85
+ export interface Result {
86
+ error?: {
87
+ code: string
88
+ message: string
89
+ } | null
90
+ }
91
+
92
+ // Types from Query Playground Docs:
93
+
94
+ interface AccessControlEntry {
95
+ principal: PrincipalKey
96
+ allow: [Permission]
97
+ deny: [Permission]
98
+ }
99
+
100
+ interface Attachment {
101
+ name: string
102
+ label: string
103
+ size: number
104
+ mimeType: string
105
+ attachmentUrl: string
106
+ }
107
+
108
+ type DateTime = string;
109
+
110
+ export interface Component {
111
+ type: ComponentType
112
+ path: string
113
+ page?: PageComponentData | null
114
+ layout?: LayoutComponentData | null
115
+ image?: ImageComponentData | null
116
+ part?: PartComponentData | null
117
+ text?: TextComponentData | null
118
+ fragment?: FragmentComponentData | null
119
+ }
120
+
121
+ type ComponentType = 'page' | 'layout' | 'image' | 'part' | 'text' | 'fragment';
122
+
123
+ interface Content {
124
+ _id: string // !
125
+ _name: string // !
126
+ _path: string // !
127
+ _references?: Content[]
128
+ _score?: number
129
+ creator?: PrincipalKey
130
+ modifier?: PrincipalKey
131
+ createdTime?: DateTime
132
+ modifiedTime?: DateTime
133
+ owner?: PrincipalKey
134
+ type?: string
135
+ contentType?: ContentType
136
+ displayName?: string
137
+ hasChildren?: boolean
138
+ language?: string
139
+ valid?: boolean
140
+ dataAsJson?: JSON
141
+ x?: ExtraData
142
+ xAsJson?: JSON
143
+ pageAsJson?: JSON
144
+ pageTemplate?: Content
145
+ components?: Component[]
146
+ attachments?: Attachment[]
147
+ publish?: PublishInfo
148
+ pageUrl?: string
149
+ site?: portal_Site
150
+ parent?: Content
151
+ children?: Content[]
152
+ childrenConnection?: ContentConnection
153
+ permissions?: Permissions
154
+ }
155
+
156
+ interface ContentConnection {
157
+ totalCount: Int
158
+ edges: ContentEdge[]
159
+ pageInfo: PageInfo
160
+ }
161
+
162
+ interface ContentEdge {
163
+ node: Content
164
+ cursor: string
165
+ }
166
+
167
+ interface ContentType {
168
+ name: string
169
+ displayName: string
170
+ description: string
171
+ superType: string
172
+ abstract: boolean
173
+ final: boolean
174
+ allowChildContent: boolean
175
+ contentDisplayNameScript: string
176
+ icon: Icon
177
+ form: FormItem[]
178
+ formAsJson: JSON
179
+ getInstances: Content[]
180
+ getInstanceConnection: ContentConnection
181
+ }
182
+
183
+ type ExtraData<App = Record<string,unknown>> = App & {
184
+ media: XData_media_ApplicationConfig
185
+ base: XData_base_ApplicationConfig
186
+ };
187
+
188
+ type Float = number;
189
+
190
+ interface FormItem {
191
+ formItemType: FormItemType
192
+ name: string
193
+ label: string
194
+ }
195
+
196
+ type FormItemType = 'ItemSet' | 'Layout' | 'Input' | 'OptionSet';
197
+
198
+ interface FragmentComponentData {
199
+ id: string
200
+ fragment: Content
201
+ }
202
+
203
+ interface GeoPoint {
204
+ value: string
205
+ latitude: Float
206
+ longitude: Float
207
+ }
208
+
209
+ export interface HeadlessCms {
210
+ get?: Content
211
+ getChildren?: Content[]
212
+ getChildrenConnection?: ContentConnection
213
+ getPermissions?: Permissions
214
+ getSite?: portal_Site
215
+ getType?: ContentType
216
+ getTypes?: ContentType[]
217
+ query?: Content[]
218
+ queryConnection?: QueryContentConnection
219
+ queryDsl?: Content[]
220
+ queryDslConnection?: QueryDSLContentConnection
221
+ }
222
+
223
+ interface Icon {
224
+ mimeType: string
225
+ modifiedTime: string
226
+ }
227
+
228
+ interface Image {
229
+ image: Content
230
+ ref: string
231
+ style: ImageStyle
232
+ }
233
+
234
+ interface ImageComponentData {
235
+ id: string
236
+ caption?: string
237
+ image: media_Image
238
+ }
239
+
240
+ interface ImageStyle {
241
+ name: string
242
+ aspectRatio: string
243
+ filter: string
244
+ }
245
+
246
+ type Int = number;
247
+
248
+ type JSON = Record<string, unknown>;
249
+
250
+ interface LayoutComponentData {
251
+ descriptor: string
252
+ configAsJson: JSON | null
253
+ }
254
+
255
+ interface Link {
256
+ ref: string
257
+ uri: string
258
+ media: Media
259
+ content: Content
260
+ }
261
+
262
+ type LocalDateTime = string;
263
+
264
+ interface Macro_system_disable_DataConfig {
265
+ body: string
266
+ }
267
+
268
+ interface Macro_system_embed_DataConfig {
269
+ body: string
270
+ }
271
+
272
+ interface Macro {
273
+ ref: string
274
+ name: string
275
+ descriptor: string
276
+ config: MacroConfig
277
+ }
278
+
279
+ interface MacroConfig {
280
+ disable: Macro_system_disable_DataConfig
281
+ embed: Macro_system_embed_DataConfig
282
+ }
283
+
284
+ interface Media {
285
+ content: Content
286
+ intent: MediaIntentType
287
+ }
288
+
289
+ type MediaIntentType = 'download' | 'inline';
290
+
291
+ interface media_Image extends Content {
292
+ mediaUrl: string
293
+ imageUrl: string
294
+ data: media_Image_Data
295
+ }
296
+
297
+ interface media_Image_Data {
298
+ media: MediaUploader
299
+ caption: string
300
+ altText: string
301
+ artist: string[]
302
+ copyright: string
303
+ tags: string[]
304
+ }
305
+
306
+ interface MediaFocalPoint {
307
+ x: number
308
+ y: number
309
+ }
310
+
311
+ interface MediaUploader {
312
+ attachment: string
313
+ focalPoint: MediaFocalPoint
314
+ }
315
+
316
+ interface PageComponentData {
317
+ descriptor?: string
318
+ customized?: boolean
319
+ configAsJson?: JSON
320
+ template?: Content | null
321
+ }
322
+
323
+ interface PageInfo {
324
+ startCursor: string // !
325
+ endCursor: string // !
326
+ hasNext: boolean // !
327
+ }
328
+
329
+ interface PartComponentData<Config = Record<string, unknown>> {
330
+ descriptor: string
331
+ config: Config
332
+ configAsJson: JSON
333
+ }
334
+
335
+ type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
336
+
337
+ interface Permissions {
338
+ inheritsPermissions: boolean
339
+ permissions: AccessControlEntry[]
340
+ }
341
+
342
+ interface portal_Site extends Content {
343
+ data: portal_Site_Data
344
+ }
345
+
346
+ interface portal_Site_Data {
347
+ description: string
348
+ }
349
+
350
+ type PrincipalType = 'user' | 'group' | 'role';
351
+
352
+ interface PrincipalKey {
353
+ value: string
354
+ type: PrincipalType
355
+ idProvider: string
356
+ principalId: string
357
+ }
358
+
359
+ interface QueryContentConnection extends ContentConnection {
360
+ aggregationsAsJson: JSON
361
+ }
362
+
363
+ interface QueryDSLContentConnection extends QueryContentConnection {
364
+ highlightAsJson: JSON
365
+ }
366
+
367
+ interface RichText {
368
+ raw: string
369
+ processedHtml: string
370
+ macrosAsJson: JSON
371
+ macros: Macro[]
372
+ images: Image[]
373
+ links: Link[]
374
+ }
375
+
376
+ interface TextComponentData {
377
+ value: RichText
378
+ }
379
+
380
+ interface XData_base_ApplicationConfig {
381
+ gpsInfo: XData_base_gpsInfo_DataConfig
382
+ }
383
+
384
+ interface XData_base_gpsInfo_DataConfig {
385
+ geoPoint: GeoPoint
386
+ altitude: String
387
+ direction: String
388
+ }
389
+
390
+ interface XData_media_ApplicationConfig {
391
+ imageInfo: XData_media_imageInfo_DataConfig
392
+ cameraInfo: XData_media_cameraInfo_DataConfig
393
+ }
394
+
395
+ interface XData_media_imageInfo_DataConfig {
396
+ pixelSize: number
397
+ imageHeight: number
398
+ imageWidth: number
399
+ contentType: string
400
+ description: string
401
+ byteSize: number
402
+ colorSpace: string[]
403
+ fileSource: string
404
+ }
405
+
406
+ interface XData_media_cameraInfo_DataConfig {
407
+ date: LocalDateTime
408
+ make: string
409
+ model: string
410
+ lens: string
411
+ iso: string
412
+ focalLength: string
413
+ focalLength35: string
414
+ exposureBias: string
415
+ aperture: string[]
416
+ shutterTime: string
417
+ flash: string
418
+ autoFlashCompensation: string
419
+ whiteBalance: string
420
+ exposureProgram: string
421
+ shootingMode: string
422
+ meteringMode: string
423
+ exposureMode: string
424
+ focusDistance: string
425
+ orientation: string
426
+ }
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,58 @@
1
+ /// <reference types="react" />
2
+
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
+
10
+
11
+ // Shape of content base-data API body
12
+ export interface ContentApiBaseBody {
13
+ query?: string, // Override the default base-data query
14
+ variables?: { // GraphQL variables inserted into the query
15
+ path?: string, // Full content item _path
16
+ [key: string]: string | number | undefined,
17
+ }
18
+ }
19
+
20
+ export interface ContentPathItem {
21
+ contentPath: string[]
22
+ locale: string,
23
+ }
24
+
25
+ export interface PathFragment {
26
+ index: number
27
+ region: string
28
+ }
29
+
30
+ export interface PreviewParams {
31
+ contentPath: string[]
32
+ headers: Record<string, string>
33
+ params: Record<string, string>
34
+ }
35
+
36
+ export interface ProjectLocaleConfig {
37
+ default: boolean
38
+ project: string
39
+ site: string
40
+ locale: string
41
+ }
42
+
43
+ export type ProjectLocalesConfig = Record<string, ProjectLocaleConfig>;
44
+
45
+ export type SelectorName = 'contentType' | 'page' | 'component' | 'part' | 'layout' | 'macro';
46
+
47
+ export interface ServerSideParams
48
+ extends NodeJS.Dict<string | string[]> {
49
+ // String array catching a sub-path assumed to match the site-relative path of an XP content.
50
+ contentPath?: string[];
51
+ mode?: string;
52
+ }
53
+
54
+ export interface StaticContentProps extends Record<string, any> {
55
+ children?: React.ReactNode;
56
+ element?: string;
57
+ condition: boolean;
58
+ }
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1,3 @@
1
+ export function addLineNumbers(s: string) {
2
+ return s.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
3
+ }
@@ -0,0 +1,32 @@
1
+ import type {Context, GuillotineRequestHeaders} from '../types';
2
+
3
+
4
+ import {
5
+ GUILLOTINE_REQUEST_HEADERS,
6
+ JSESSIONID_HEADER,
7
+ } from '../common/constants';
8
+
9
+
10
+ export function buildGuillotineRequestHeaders({
11
+ context,
12
+ defaultLocale,
13
+ locale,
14
+ locales,
15
+ }: {
16
+ context: Context
17
+ defaultLocale: string
18
+ locale: string
19
+ locales: string[]
20
+ }): GuillotineRequestHeaders {
21
+ const guillotineRequestHeaders: GuillotineRequestHeaders = {
22
+ [GUILLOTINE_REQUEST_HEADERS.DEFAULT_LOCALE]: defaultLocale,
23
+ [GUILLOTINE_REQUEST_HEADERS.LOCALE]: locale,
24
+ [GUILLOTINE_REQUEST_HEADERS.LOCALES]: JSON.stringify(locales),
25
+ };
26
+ const jsessionid = context.headers?.get(JSESSIONID_HEADER);
27
+ if (jsessionid) {
28
+ guillotineRequestHeaders[GUILLOTINE_REQUEST_HEADERS.COOKIE] =
29
+ `${JSESSIONID_HEADER}=${jsessionid}`;
30
+ }
31
+ return guillotineRequestHeaders;
32
+ }
@@ -0,0 +1,16 @@
1
+ export const commonChars = (s1?: string, s2?: string) => {
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
+ } else {
11
+ break;
12
+ }
13
+ }
14
+
15
+ return result;
16
+ };
@@ -0,0 +1,3 @@
1
+ export function fixDoubleSlashes(str: string) {
2
+ return str.replace(/(^|[^:/])\/{2,}/g, '$1/');
3
+ }