@enonic/nextjs-adapter 6.0.0-beta.3 → 6.0.0-beta.5
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.
- package/README.md +76 -106
- package/dist/client/DraftModeButton.d.ts +2 -0
- package/dist/client/DraftModeButton.jsx +28 -0
- package/dist/client/DraftModeButton.jsx.map +1 -0
- package/dist/client/DraftModeButton.module.css +43 -0
- package/dist/client/replaceLocation.d.ts +1 -0
- package/dist/client/replaceLocation.js +5 -0
- package/dist/client/replaceLocation.js.map +1 -0
- package/dist/common/constants.d.ts +4 -0
- package/dist/common/constants.js +4 -0
- package/dist/common/constants.js.map +1 -1
- package/dist/common/env.d.ts +7 -3
- package/dist/common/env.js +13 -7
- package/dist/common/env.js.map +1 -1
- package/dist/guillotine/applyProcessors.js +18 -29
- package/dist/guillotine/applyProcessors.js.map +1 -1
- package/dist/guillotine/fetchContent.js +180 -191
- package/dist/guillotine/fetchContent.js.map +1 -1
- package/dist/guillotine/fetchContentData.js +3 -12
- package/dist/guillotine/fetchContentData.js.map +1 -1
- package/dist/guillotine/fetchContentPathsForAllLocales.js +4 -15
- package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -1
- package/dist/guillotine/fetchContentPathsForLocale.js +25 -36
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -1
- package/dist/guillotine/fetchFromApi.js +48 -59
- package/dist/guillotine/fetchFromApi.js.map +1 -1
- package/dist/guillotine/fetchGuillotine.js +50 -60
- package/dist/guillotine/fetchGuillotine.js.map +1 -1
- package/dist/guillotine/fetchMetaData.js +3 -12
- package/dist/guillotine/fetchMetaData.js.map +1 -1
- package/dist/guillotine/metadata/richTextQuery.d.ts +7 -0
- package/dist/guillotine/metadata/richTextQuery.js +55 -34
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -1
- package/dist/guillotine/urlQueries.d.ts +5 -0
- package/dist/guillotine/urlQueries.js +23 -0
- package/dist/guillotine/urlQueries.js.map +1 -0
- package/dist/guillotine/urls.d.ts +9 -0
- package/dist/guillotine/urls.js +18 -0
- package/dist/guillotine/urls.js.map +1 -0
- package/dist/guillotine/validateShortcut.js +5 -6
- package/dist/guillotine/validateShortcut.js.map +1 -1
- package/dist/i18n/LocaleContext.jsx +2 -11
- package/dist/i18n/LocaleContext.jsx.map +1 -1
- package/dist/i18n/i18n.js +9 -20
- package/dist/i18n/i18n.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/query/Shortcut.js +2 -3
- package/dist/query/Shortcut.js.map +1 -1
- package/dist/server/disableDraftMode.d.ts +1 -0
- package/dist/server/disableDraftMode.js +7 -0
- package/dist/server/disableDraftMode.js.map +1 -0
- package/dist/types/guillotine.d.ts +2 -2
- package/dist/types/index.d.ts +6 -0
- package/dist/types/urls.d.ts +34 -0
- package/dist/types/urls.js +2 -0
- package/dist/types/urls.js.map +1 -0
- package/dist/utils/getMediaUrl.d.ts +3 -0
- package/dist/utils/getMediaUrl.js +17 -0
- package/dist/utils/getMediaUrl.js.map +1 -0
- package/dist/utils/getPageUrl.d.ts +3 -0
- package/dist/utils/getPageUrl.js +8 -0
- package/dist/utils/getPageUrl.js.map +1 -0
- package/dist/utils/localizeMappings.d.ts +3 -0
- package/dist/utils/localizeMappings.js +6 -0
- package/dist/utils/localizeMappings.js.map +1 -0
- package/dist/views/DraftModeIndicator.d.ts +2 -0
- package/dist/views/DraftModeIndicator.jsx +12 -0
- package/dist/views/DraftModeIndicator.jsx.map +1 -0
- package/dist/views/RichTextView.jsx +10 -3
- package/dist/views/RichTextView.jsx.map +1 -1
- package/package.json +7 -7
- package/dist/common/UrlProcessor.d.ts +0 -17
- package/dist/common/UrlProcessor.js +0 -33
- package/dist/common/UrlProcessor.js.map +0 -1
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { draftMode, headers } from 'next/headers';
|
|
11
2
|
import { ComponentRegistry } from '../common/ComponentRegistry';
|
|
12
3
|
import { PAGE_TEMPLATE_CONTENTTYPE_NAME, PAGE_TEMPLATE_FOLDER, RENDER_MODE, XP_COMPONENT_TYPE, XP_REQUEST_TYPE, RENDER_MODE_HEADER } from '../common/constants';
|
|
13
|
-
import { APP_NAME, APP_NAME_DASHED, IS_DEV_MODE,
|
|
4
|
+
import { APP_NAME, APP_NAME_DASHED, IS_DEV_MODE, GUILLOTINE_URL } from '../common/env';
|
|
14
5
|
import { getContentBranch } from '../utils/getContentBranch';
|
|
15
6
|
import { getLocaleMapping } from '../utils/getLocaleMapping';
|
|
16
7
|
import { getRenderMode } from '../utils/getRenderMode';
|
|
@@ -38,196 +29,194 @@ import { createMetaData } from './createMetaData';
|
|
|
38
29
|
* @param context object from Next, contains .query info
|
|
39
30
|
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
40
31
|
*/
|
|
41
|
-
export function fetchContent(context) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
context.headers = new Headers();
|
|
51
|
-
}
|
|
52
|
-
allHeaders.forEach((value, key) => {
|
|
53
|
-
context.headers.set(key, value);
|
|
54
|
-
});
|
|
55
|
-
// set render mode based on preview cookie.
|
|
56
|
-
context.headers.set(RENDER_MODE_HEADER, RENDER_MODE.EDIT);
|
|
32
|
+
export async function fetchContent(context) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const { locale, locales, defaultLocale } = getRequestLocaleInfo(context);
|
|
35
|
+
const { isEnabled } = await draftMode();
|
|
36
|
+
// we only want to read headers in draft mode, because they bail out static generation
|
|
37
|
+
if (isEnabled) {
|
|
38
|
+
const allHeaders = await headers();
|
|
39
|
+
if (!context.headers) {
|
|
40
|
+
context.headers = new Headers();
|
|
57
41
|
}
|
|
58
|
-
|
|
59
|
-
context,
|
|
60
|
-
defaultLocale,
|
|
61
|
-
locale,
|
|
62
|
-
locales
|
|
42
|
+
allHeaders.forEach((value, key) => {
|
|
43
|
+
context.headers.set(key, value);
|
|
63
44
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
45
|
+
// set render mode based on preview cookie.
|
|
46
|
+
context.headers.set(RENDER_MODE_HEADER, RENDER_MODE.EDIT);
|
|
47
|
+
}
|
|
48
|
+
const outHeaders = buildGuillotineRequestHeaders({
|
|
49
|
+
context,
|
|
50
|
+
defaultLocale,
|
|
51
|
+
locale,
|
|
52
|
+
locales
|
|
53
|
+
});
|
|
54
|
+
const xpBaseUrl = getXpBaseUrl(context);
|
|
55
|
+
const contentApiUrl = GUILLOTINE_URL;
|
|
56
|
+
const mapping = getLocaleMapping(context);
|
|
57
|
+
const renderMode = getRenderMode(context);
|
|
58
|
+
const branch = getContentBranch(context);
|
|
59
|
+
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
60
|
+
const requestContentPath = getSiteRelativePathOrThrow(context.contentPath);
|
|
61
|
+
try {
|
|
62
|
+
const [contentPathWithoutComponent, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
63
|
+
if (componentPath) {
|
|
64
|
+
// set component request type because url contains component path
|
|
65
|
+
requestType = XP_REQUEST_TYPE.COMPONENT;
|
|
66
|
+
}
|
|
67
|
+
// ///////////// FIRST GUILLOTINE CALL FOR METADATA /////////////////
|
|
68
|
+
// Guillotine resolves content by its full path (incl. site name), but incoming paths are
|
|
69
|
+
// site-relative (the site name is stripped from urls upstream), so add it back for the query.
|
|
70
|
+
const metaPath = prependSitePath(contentPathWithoutComponent, mapping.site);
|
|
71
|
+
const metaResult = await fetchMetaData(contentApiUrl, metaPath, mapping, branch, outHeaders);
|
|
72
|
+
// ///////////////////////////////////////////////////////////////////////
|
|
73
|
+
const { _id, _path, type } = metaResult.meta || {};
|
|
74
|
+
const contentPath = _path || contentPathWithoutComponent;
|
|
75
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, mapping.project, mapping.site, branch, xpBaseUrl, locale, defaultLocale, requestContentPath, _id);
|
|
76
|
+
if (metaResult.error) {
|
|
77
|
+
console.error(metaResult.error);
|
|
78
|
+
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
79
|
+
}
|
|
80
|
+
if (!metaResult.meta) {
|
|
81
|
+
return errorResponse('404', 'No meta data found for content, most likely content does not exist');
|
|
82
|
+
}
|
|
83
|
+
else if (!type) {
|
|
84
|
+
return errorResponse('500', "Server responded with incomplete meta data: missing content 'type' attribute.");
|
|
85
|
+
}
|
|
86
|
+
else if (renderMode === RENDER_MODE.NEXT
|
|
87
|
+
&& !IS_DEV_MODE
|
|
88
|
+
&& (type === PAGE_TEMPLATE_CONTENTTYPE_NAME ||
|
|
89
|
+
type === PAGE_TEMPLATE_FOLDER)) {
|
|
90
|
+
return errorResponse('404', `Content type [${type}] is not accessible in ${renderMode} mode`);
|
|
91
|
+
}
|
|
92
|
+
const components = restrictComponentsToPath(type, metaResult.meta.components, componentPath);
|
|
93
|
+
if (componentPath && !components.length) {
|
|
94
|
+
// component was not found
|
|
95
|
+
return errorResponse('404', `Component ${componentPath} was not found`);
|
|
96
|
+
}
|
|
97
|
+
if (requestType !== XP_REQUEST_TYPE.COMPONENT && components.length > 0) {
|
|
98
|
+
requestType = XP_REQUEST_TYPE.PAGE;
|
|
99
|
+
}
|
|
100
|
+
// ////////////////////////////////////////////////// Content type established. Proceed to data call:
|
|
101
|
+
const allDescriptors = [];
|
|
102
|
+
// Add the content type query at all cases
|
|
103
|
+
const contentTypeDef = ComponentRegistry.getContentType(type);
|
|
104
|
+
const pageCmp = (components || []).find(cmp => cmp.type === XP_COMPONENT_TYPE.PAGE);
|
|
105
|
+
if (pageCmp) {
|
|
106
|
+
processComponentConfig(APP_NAME, APP_NAME_DASHED, pageCmp);
|
|
107
|
+
}
|
|
108
|
+
const contentQueryAndVars = getQueryAndVariables(type, contentPath, branch, mapping, context, contentTypeDef === null || contentTypeDef === void 0 ? void 0 : contentTypeDef.query, (_a = pageCmp === null || pageCmp === void 0 ? void 0 : pageCmp.page) === null || _a === void 0 ? void 0 : _a.config);
|
|
109
|
+
if (contentQueryAndVars) {
|
|
110
|
+
allDescriptors.push({
|
|
111
|
+
type: contentTypeDef,
|
|
112
|
+
queryAndVariables: contentQueryAndVars
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const commonQueryAndVars = getQueryAndVariables(type, contentPath, branch, mapping, context, ComponentRegistry.getCommonQuery(), (_b = pageCmp === null || pageCmp === void 0 ? void 0 : pageCmp.page) === null || _b === void 0 ? void 0 : _b.config);
|
|
116
|
+
if (commonQueryAndVars) {
|
|
117
|
+
allDescriptors.push({
|
|
118
|
+
type: contentTypeDef,
|
|
119
|
+
queryAndVariables: commonQueryAndVars
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if ((components === null || components === void 0 ? void 0 : components.length) && ComponentRegistry) {
|
|
123
|
+
for (const cmp of (components || [])) {
|
|
124
|
+
processComponentConfig(APP_NAME, APP_NAME_DASHED, cmp);
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
// Collect component queries if defined
|
|
127
|
+
const componentDescriptors = collectComponentDescriptors({
|
|
128
|
+
components,
|
|
129
|
+
contentPath,
|
|
130
|
+
branch,
|
|
131
|
+
mapping,
|
|
132
|
+
context
|
|
133
|
+
});
|
|
134
|
+
if (componentDescriptors.length) {
|
|
135
|
+
allDescriptors.push(...componentDescriptors);
|
|
131
136
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
}
|
|
138
|
+
const { query, variables } = combineMultipleQueries(allDescriptors);
|
|
139
|
+
if (!query.trim()) {
|
|
140
|
+
return errorResponse('400', `Missing or empty query override for content type ${type}`);
|
|
141
|
+
}
|
|
142
|
+
// /////////////// SECOND GUILLOTINE CALL FOR DATA //////////////////////
|
|
143
|
+
const contentResults = await fetchContentData(contentApiUrl, contentPath, mapping, branch, query, variables, outHeaders);
|
|
144
|
+
// ///////////////////////////////////////////////////////////////////////////
|
|
145
|
+
if (contentResults.error) {
|
|
146
|
+
console.error(contentResults.error);
|
|
147
|
+
return errorResponse(contentResults.error.code, contentResults.error.message);
|
|
148
|
+
}
|
|
149
|
+
// Apply processors to every component
|
|
150
|
+
const datas = await applyProcessors(allDescriptors, contentResults, context);
|
|
151
|
+
// Unwind the data back to components
|
|
152
|
+
let contentData = null, common = null;
|
|
153
|
+
let startFrom = 0;
|
|
154
|
+
if (contentQueryAndVars) {
|
|
155
|
+
const item = datas[startFrom];
|
|
156
|
+
contentData = item.status === 'fulfilled' ? item.value : item.reason;
|
|
157
|
+
startFrom++;
|
|
158
|
+
}
|
|
159
|
+
if (commonQueryAndVars) {
|
|
160
|
+
const item = datas[startFrom];
|
|
161
|
+
common = item.status === 'fulfilled' ? item.value : item.reason;
|
|
162
|
+
startFrom++;
|
|
163
|
+
}
|
|
164
|
+
for (let i = startFrom; i < datas.length; i++) {
|
|
165
|
+
// component descriptors hold references to components
|
|
166
|
+
// that will later be used for creating page regions
|
|
167
|
+
const datum = datas[i];
|
|
168
|
+
if (datum.status === 'rejected') {
|
|
169
|
+
let reason = datum.reason;
|
|
170
|
+
if (reason instanceof Error) {
|
|
171
|
+
reason = reason.message;
|
|
135
172
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
components,
|
|
139
|
-
contentPath,
|
|
140
|
-
branch,
|
|
141
|
-
mapping,
|
|
142
|
-
context
|
|
143
|
-
});
|
|
144
|
-
if (componentDescriptors.length) {
|
|
145
|
-
allDescriptors.push(...componentDescriptors);
|
|
173
|
+
else if (typeof reason !== 'string') {
|
|
174
|
+
reason = String(reason);
|
|
146
175
|
}
|
|
176
|
+
allDescriptors[i].component.error = reason;
|
|
147
177
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return errorResponse('400', `Missing or empty query override for content type ${type}`);
|
|
151
|
-
}
|
|
152
|
-
// /////////////// SECOND GUILLOTINE CALL FOR DATA //////////////////////
|
|
153
|
-
const contentResults = yield fetchContentData(contentApiUrl, contentPath, mapping, branch, query, variables, outHeaders);
|
|
154
|
-
// ///////////////////////////////////////////////////////////////////////////
|
|
155
|
-
if (contentResults.error) {
|
|
156
|
-
console.error(contentResults.error);
|
|
157
|
-
return errorResponse(contentResults.error.code, contentResults.error.message);
|
|
158
|
-
}
|
|
159
|
-
// Apply processors to every component
|
|
160
|
-
const datas = yield applyProcessors(allDescriptors, contentResults, context);
|
|
161
|
-
// Unwind the data back to components
|
|
162
|
-
let contentData = null, common = null;
|
|
163
|
-
let startFrom = 0;
|
|
164
|
-
if (contentQueryAndVars) {
|
|
165
|
-
const item = datas[startFrom];
|
|
166
|
-
contentData = item.status === 'fulfilled' ? item.value : item.reason;
|
|
167
|
-
startFrom++;
|
|
168
|
-
}
|
|
169
|
-
if (commonQueryAndVars) {
|
|
170
|
-
const item = datas[startFrom];
|
|
171
|
-
common = item.status === 'fulfilled' ? item.value : item.reason;
|
|
172
|
-
startFrom++;
|
|
173
|
-
}
|
|
174
|
-
for (let i = startFrom; i < datas.length; i++) {
|
|
175
|
-
// component descriptors hold references to components
|
|
176
|
-
// that will later be used for creating page regions
|
|
177
|
-
const datum = datas[i];
|
|
178
|
-
if (datum.status === 'rejected') {
|
|
179
|
-
let reason = datum.reason;
|
|
180
|
-
if (reason instanceof Error) {
|
|
181
|
-
reason = reason.message;
|
|
182
|
-
}
|
|
183
|
-
else if (typeof reason !== 'string') {
|
|
184
|
-
reason = String(reason);
|
|
185
|
-
}
|
|
186
|
-
allDescriptors[i].component.error = reason;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
allDescriptors[i].component.data = datum.value;
|
|
190
|
-
}
|
|
178
|
+
else {
|
|
179
|
+
allDescriptors[i].component.data = datum.value;
|
|
191
180
|
}
|
|
192
|
-
const page = buildPage(type, components);
|
|
193
|
-
const meta = createMetaData({
|
|
194
|
-
project: mapping.project,
|
|
195
|
-
site: mapping.site,
|
|
196
|
-
branch,
|
|
197
|
-
baseUrl: xpBaseUrl,
|
|
198
|
-
components,
|
|
199
|
-
contentPath: contentPathWithoutComponent,
|
|
200
|
-
contentType: type,
|
|
201
|
-
contentId: _id,
|
|
202
|
-
defaultLocale,
|
|
203
|
-
locale,
|
|
204
|
-
pageCmp: page,
|
|
205
|
-
renderMode,
|
|
206
|
-
requestedComponentPath: componentPath,
|
|
207
|
-
requestType
|
|
208
|
-
});
|
|
209
|
-
return {
|
|
210
|
-
data: contentData,
|
|
211
|
-
common,
|
|
212
|
-
meta,
|
|
213
|
-
page
|
|
214
|
-
};
|
|
215
181
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
182
|
+
const page = buildPage(type, components);
|
|
183
|
+
const meta = createMetaData({
|
|
184
|
+
project: mapping.project,
|
|
185
|
+
site: mapping.site,
|
|
186
|
+
branch,
|
|
187
|
+
baseUrl: xpBaseUrl,
|
|
188
|
+
components,
|
|
189
|
+
contentPath: contentPathWithoutComponent,
|
|
190
|
+
contentType: type,
|
|
191
|
+
contentId: _id,
|
|
192
|
+
defaultLocale,
|
|
193
|
+
locale,
|
|
194
|
+
pageCmp: page,
|
|
195
|
+
renderMode,
|
|
196
|
+
requestedComponentPath: componentPath,
|
|
197
|
+
requestType
|
|
198
|
+
});
|
|
199
|
+
return {
|
|
200
|
+
data: contentData,
|
|
201
|
+
common,
|
|
202
|
+
meta,
|
|
203
|
+
page
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
console.error(e);
|
|
208
|
+
let error;
|
|
209
|
+
try {
|
|
210
|
+
error = JSON.parse(e.message);
|
|
230
211
|
}
|
|
231
|
-
|
|
212
|
+
catch (e2) {
|
|
213
|
+
error = {
|
|
214
|
+
code: 'Local',
|
|
215
|
+
message: e.message
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, mapping.project, mapping.site, branch, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
219
|
+
return errorResponse(error.code, error.message);
|
|
220
|
+
}
|
|
232
221
|
}
|
|
233
222
|
//# sourceMappingURL=fetchContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContent.js","sourceRoot":"","sources":["../../src/guillotine/fetchContent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchContent.js","sourceRoot":"","sources":["../../src/guillotine/fetchContent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACH,8BAA8B,EAC9B,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACrF,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAC,6BAA6B,EAAC,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAC1E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B,SAAS,EAAE,GAAG;YACd,aAAa;YACb,MAAM;YACN,OAAO,EAAE,IAAI;YACb,UAAU;YACV,sBAAsB,EAAE,aAAa;YACrC,WAAW;SACd,CAAC,CAAC;QAEH,OAAO;YACH,IAAI,EAAE,WAAW;YACjB,MAAM;YACN,IAAI;YACJ,IAAI;SACP,CAAC;IACN,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEjB,IAAI,KAAK,CAAC;QACV,IAAI,CAAC;YACD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACV,KAAK,GAAG;gBACJ,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,CAAC,CAAC,OAAO;aACrB,CAAC;QACN,CAAC;QACD,MAAM,aAAa,GAAG,kBAAkB,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EACtH,aAAa,EAAE,kBAAkB,CAAC,CAAC;QACvC,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;AACL,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { fetchGuillotine } from './fetchGuillotine';
|
|
11
|
-
export const fetchContentData = (contentApiUrl, contentPath, mapping, branch, query, variables, headers) =>
|
|
2
|
+
export const fetchContentData = async (contentApiUrl, contentPath, mapping, branch, query, variables, headers) => {
|
|
12
3
|
const body = {
|
|
13
4
|
query,
|
|
14
5
|
variables: {
|
|
@@ -21,7 +12,7 @@ export const fetchContentData = (contentApiUrl, contentPath, mapping, branch, qu
|
|
|
21
12
|
if (variables && Object.keys(variables).length > 0) {
|
|
22
13
|
body.variables = Object.assign(body.variables, variables);
|
|
23
14
|
}
|
|
24
|
-
const contentResults =
|
|
15
|
+
const contentResults = await fetchGuillotine(contentApiUrl, {
|
|
25
16
|
body,
|
|
26
17
|
headers
|
|
27
18
|
});
|
|
@@ -34,5 +25,5 @@ export const fetchContentData = (contentApiUrl, contentPath, mapping, branch, qu
|
|
|
34
25
|
contents: Object.values(contentResults)
|
|
35
26
|
};
|
|
36
27
|
}
|
|
37
|
-
}
|
|
28
|
+
};
|
|
38
29
|
//# sourceMappingURL=fetchContentData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContentData.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchContentData.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACjC,aAAqB,EACrB,WAAmB,EACnB,OAAsB,EACtB,MAAc,EACd,KAAa,EACb,SAAuC,EACvC,OAAkC,EACZ,EAAE;IACxB,MAAM,IAAI,GAAuB;QAC7B,KAAK;QACL,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM;SACT;KACJ,CAAC;IACF,IAAI,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,eAAe,CAAyB,aAAa,EAAE;QAChF,IAAI;QACJ,OAAO;KACV,CAAC,CAAC;IAEH,IAAI,cAAc,CAAC,KAAK,EAAE,CAAC;QACvB,OAAO,cAAc,CAAC;IAC1B,CAAC;SAAM,CAAC;QACJ,OAAO;YACH,qCAAqC;YACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;SAC1C,CAAC;IACN,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { GET_STATIC_PATHS_QUERY } from '../common/constants';
|
|
11
2
|
import { getLocaleMappings } from '../utils/getLocaleMappings';
|
|
12
3
|
import { fetchContentPathsForLocale } from './fetchContentPathsForLocale';
|
|
13
|
-
export function fetchContentPathsForAllLocales() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
return results.reduce((all, localePaths) => all.concat(localePaths), []);
|
|
18
|
-
});
|
|
4
|
+
export async function fetchContentPathsForAllLocales(query = GET_STATIC_PATHS_QUERY, countPerLocale = 999) {
|
|
5
|
+
const promises = Object.values(getLocaleMappings()).map(config => fetchContentPathsForLocale(config, query, countPerLocale));
|
|
6
|
+
return Promise.all(promises).then(results => {
|
|
7
|
+
return results.reduce((all, localePaths) => all.concat(localePaths), []);
|
|
19
8
|
});
|
|
20
9
|
}
|
|
21
10
|
//# sourceMappingURL=fetchContentPathsForAllLocales.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContentPathsForAllLocales.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentPathsForAllLocales.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchContentPathsForAllLocales.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentPathsForAllLocales.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AAGxE,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAChD,QAAgB,sBAAsB,EACtC,cAAc,GAAG,GAAG;IAEpB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,GAAG,CACnD,MAAM,CAAC,EAAE,CAAC,0BAA0B,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CACtE,CAAC;IACF,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QACxC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,42 +1,31 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { GET_STATIC_PATHS_QUERY } from '../common/constants';
|
|
11
|
-
import {
|
|
2
|
+
import { GUILLOTINE_URL } from '../common/env';
|
|
12
3
|
import { getContentBranch } from '../utils/getContentBranch';
|
|
13
4
|
import { fetchGuillotine } from './fetchGuillotine';
|
|
14
|
-
export function fetchContentPathsForLocale(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, []);
|
|
39
|
-
});
|
|
5
|
+
export async function fetchContentPathsForLocale(mapping, query = GET_STATIC_PATHS_QUERY, count = 999) {
|
|
6
|
+
const contentApiUrl = GUILLOTINE_URL;
|
|
7
|
+
const body = {
|
|
8
|
+
query,
|
|
9
|
+
variables: {
|
|
10
|
+
path: mapping.site,
|
|
11
|
+
pathRegex: `/content${mapping.site}/*`,
|
|
12
|
+
count,
|
|
13
|
+
project: mapping.project,
|
|
14
|
+
siteKey: mapping.site,
|
|
15
|
+
branch: getContentBranch()
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return fetchGuillotine(contentApiUrl, { body }).then((results) => {
|
|
19
|
+
return results.guillotine.queryDsl.reduce((prev, child) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const regexp = new RegExp(`^/${((_a = child.site) === null || _a === void 0 ? void 0 : _a._name) ? `${child.site._name}/?` : ''}`);
|
|
22
|
+
const contentPath = child._path.replace(regexp, '');
|
|
23
|
+
prev.push({
|
|
24
|
+
contentPath: contentPath.split('/'),
|
|
25
|
+
locale: mapping.locale
|
|
26
|
+
});
|
|
27
|
+
return prev;
|
|
28
|
+
}, []);
|
|
40
29
|
});
|
|
41
30
|
}
|
|
42
31
|
//# sourceMappingURL=fetchContentPathsForLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContentPathsForLocale.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentPathsForLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchContentPathsForLocale.js","sourceRoot":"","sources":["../../src/guillotine/fetchContentPathsForLocale.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC5C,OAAsB,EACtB,QAAgB,sBAAsB,EACtC,KAAK,GAAG,GAAG;IAEX,MAAM,aAAa,GAAG,cAAc,CAAC;IACrC,MAAM,IAAI,GAAuB;QAC7B,KAAK;QACL,SAAS,EAAE;YACP,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,WAAW,OAAO,CAAC,IAAI,IAAI;Y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