@enonic/nextjs-adapter 3.0.0-B2 → 3.0.0-B3
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/common/env.js +14 -13
- package/common/env.js.map +1 -1
- package/guillotine/fetchContent.d.ts +2 -2
- package/guillotine/fetchContent.js +172 -170
- package/guillotine/fetchContent.js.map +1 -1
- package/guillotine/fetchFromApi.d.ts +1 -1
- package/guillotine/fetchFromApi.js +56 -54
- package/guillotine/fetchFromApi.js.map +1 -1
- package/guillotine/fetchGuillotine.d.ts +1 -1
- package/guillotine/fetchGuillotine.js +38 -36
- package/guillotine/fetchGuillotine.js.map +1 -1
- package/index.d.ts +1 -5
- package/index.js +1 -5
- package/index.js.map +1 -1
- package/package.json +13 -13
- package/server.d.ts +5 -0
- package/server.js.map +1 -0
package/common/env.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { ENV_VARS } from './constants';
|
|
2
|
+
const isServer = typeof window === 'undefined';
|
|
3
|
+
// IMPORTANT:
|
|
4
|
+
// NEXT_PUBLIC_ vars should be explicitly referenced to be made available on the client side (substituted with constants) !!!
|
|
2
5
|
/** URL to the guillotine API */
|
|
3
|
-
export const API_URL =
|
|
6
|
+
export const API_URL = isServer ? process.env[ENV_VARS.API_URL] : process.env['NEXT_PUBLIC_ENONIC_API'];
|
|
4
7
|
/** Optional utility value - defining in one place the name of the target app (the app that defines the content types, the app name is therefore part of the content type strings used both in typeselector and in query introspections) */
|
|
5
|
-
export const APP_NAME =
|
|
8
|
+
export const APP_NAME = isServer ? process.env[ENV_VARS.APP_NAME] : process.env['NEXT_PUBLIC_ENONIC_APP_NAME'];
|
|
6
9
|
/** Optional utility value - derived from APP_NAME, only with underscores instead of dots */
|
|
7
10
|
export const APP_NAME_UNDERSCORED = (APP_NAME || '').replace(/\./g, '_');
|
|
8
11
|
/** Optional utility value - derived from APP_NAME, only with dashes instead of dots */
|
|
9
12
|
export const APP_NAME_DASHED = (APP_NAME || '').replace(/\./g, '-');
|
|
10
|
-
const mode = process.env.MODE
|
|
13
|
+
const mode = isServer ? process.env.MODE : process.env.NEXT_PUBLIC_MODE;
|
|
11
14
|
export const IS_DEV_MODE = (mode === 'development');
|
|
12
15
|
/** Locales and Enonic XP projects correspondence list */
|
|
13
|
-
export const PROJECTS =
|
|
16
|
+
export const PROJECTS = isServer ? process.env[ENV_VARS.PROJECTS] : process.env['NEXT_PUBLIC_ENONIC_PROJECTS'];
|
|
14
17
|
const requiredConstants = {
|
|
15
18
|
[ENV_VARS.APP_NAME]: APP_NAME,
|
|
16
19
|
[ENV_VARS.API_URL]: API_URL,
|
|
17
20
|
[ENV_VARS.PROJECTS]: PROJECTS,
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
}
|
|
22
|
+
// Verify required values on server-side only
|
|
23
|
+
Object.keys(requiredConstants).forEach((key) => {
|
|
24
|
+
const val = requiredConstants[key];
|
|
25
|
+
if (!val) {
|
|
26
|
+
throw new Error(`Environment variable '${isServer ? '' : 'NEXT_PUBLIC_'}${key}' is missing (from .env?)`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
28
29
|
//# sourceMappingURL=env.js.map
|
package/common/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/common/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAErC,gCAAgC;AAChC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/common/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAErC,MAAM,QAA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AAE,OAAO;IAC3B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ;CAChC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,GAAG,2BAA2B,CAAC,CAAC;IAC9G,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context, FetchContentResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Default fetchContent function, built with params from imports.
|
|
4
4
|
* It runs custom content-type-specific guillotine calls against an XP guillotine endpoint, returns content data, error and some meta data
|
|
@@ -6,4 +6,4 @@ import type { ContentFetcher } from '../types';
|
|
|
6
6
|
* @param context object from Next, contains .query info
|
|
7
7
|
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare function fetchContent(context: Context): Promise<FetchContentResult>;
|
|
@@ -38,185 +38,187 @@ import { createMetaData } from './createMetaData';
|
|
|
38
38
|
* @param context object from Next, contains .query info
|
|
39
39
|
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export function fetchContent(context) {
|
|
42
42
|
var _a, _b;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
const outHeaders = buildGuillotineRequestHeaders({
|
|
57
|
-
context,
|
|
58
|
-
defaultLocale,
|
|
59
|
-
locale,
|
|
60
|
-
locales,
|
|
61
|
-
});
|
|
62
|
-
const xpBaseUrl = getXpBaseUrl(context);
|
|
63
|
-
const contentApiUrl = getContentApiUrl(context);
|
|
64
|
-
const projectConfig = getProjectLocaleConfig(context);
|
|
65
|
-
const renderMode = getRenderMode(context);
|
|
66
|
-
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
67
|
-
const requestContentPath = getCleanContentPathArrayOrThrow400(context.contentPath);
|
|
68
|
-
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
69
|
-
UrlProcessor.setSiteKey(projectConfig.site);
|
|
70
|
-
try {
|
|
71
|
-
const [siteRelativeContentPath, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
72
|
-
if (componentPath) {
|
|
73
|
-
// set component request type because url contains component path
|
|
74
|
-
requestType = XP_REQUEST_TYPE.COMPONENT;
|
|
75
|
-
}
|
|
76
|
-
// ///////////// FIRST GUILLOTINE CALL FOR METADATA /////////////////
|
|
77
|
-
const metaResult = yield fetchMetaData(contentApiUrl, '${site}/' + siteRelativeContentPath, projectConfig, outHeaders);
|
|
78
|
-
// ///////////////////////////////////////////////////////////////////////
|
|
79
|
-
const { _path, type } = metaResult.meta || {};
|
|
80
|
-
const contentPath = _path || siteRelativeContentPath;
|
|
81
|
-
if (metaResult.error) {
|
|
82
|
-
console.error(metaResult.error);
|
|
83
|
-
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
84
|
-
}
|
|
85
|
-
if (!metaResult.meta) {
|
|
86
|
-
return errorResponse('404', 'No meta data found for content, most likely content does not exist');
|
|
87
|
-
}
|
|
88
|
-
else if (!type) {
|
|
89
|
-
return errorResponse('500', "Server responded with incomplete meta data: missing content 'type' attribute.");
|
|
90
|
-
}
|
|
91
|
-
else if (renderMode === RENDER_MODE.NEXT
|
|
92
|
-
&& !IS_DEV_MODE
|
|
93
|
-
&& (type === FRAGMENT_CONTENTTYPE_NAME ||
|
|
94
|
-
type === PAGE_TEMPLATE_CONTENTTYPE_NAME ||
|
|
95
|
-
type === PAGE_TEMPLATE_FOLDER)) {
|
|
96
|
-
return errorResponse('404', `Content type [${type}] is not accessible in ${renderMode} mode`);
|
|
97
|
-
}
|
|
98
|
-
const components = restrictComponentsToPath(type, metaResult.meta.components, componentPath);
|
|
99
|
-
if (componentPath && !components.length) {
|
|
100
|
-
// component was not found
|
|
101
|
-
return errorResponse('404', `Component ${componentPath} was not found`);
|
|
102
|
-
}
|
|
103
|
-
if (requestType !== XP_REQUEST_TYPE.COMPONENT && components.length > 0) {
|
|
104
|
-
requestType = XP_REQUEST_TYPE.PAGE;
|
|
105
|
-
}
|
|
106
|
-
// ////////////////////////////////////////////////// Content type established. Proceed to data call:
|
|
107
|
-
const allDescriptors = [];
|
|
108
|
-
// Add the content type query at all cases
|
|
109
|
-
const contentTypeDef = ComponentRegistry.getContentType(type);
|
|
110
|
-
const pageCmp = (components || []).find(cmp => cmp.type === XP_COMPONENT_TYPE.PAGE);
|
|
111
|
-
if (pageCmp) {
|
|
112
|
-
processComponentConfig(APP_NAME, APP_NAME_DASHED, pageCmp);
|
|
113
|
-
}
|
|
114
|
-
const contentQueryAndVars = getQueryAndVariables(type, contentPath, 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);
|
|
115
|
-
if (contentQueryAndVars) {
|
|
116
|
-
allDescriptors.push({
|
|
117
|
-
type: contentTypeDef,
|
|
118
|
-
queryAndVariables: contentQueryAndVars,
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const { locale, locales, defaultLocale } = getRequestLocaleInfo(context);
|
|
45
|
+
// ideally we only want to set headers in draft mode,
|
|
46
|
+
// but draft mode token is not passed in non-static mode
|
|
47
|
+
// so try to add them whenever they are absent
|
|
48
|
+
if (!context.headers) {
|
|
49
|
+
// TODO does this break routing or dynamic server-side rendering?
|
|
50
|
+
// I guess hydration will fix it anyway?
|
|
51
|
+
const allHeaders = headers();
|
|
52
|
+
context.headers = new Headers();
|
|
53
|
+
allHeaders.forEach((value, key) => {
|
|
54
|
+
context.headers.set(key, value);
|
|
119
55
|
});
|
|
120
56
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
57
|
+
const outHeaders = buildGuillotineRequestHeaders({
|
|
58
|
+
context,
|
|
59
|
+
defaultLocale,
|
|
60
|
+
locale,
|
|
61
|
+
locales,
|
|
62
|
+
});
|
|
63
|
+
const xpBaseUrl = getXpBaseUrl(context);
|
|
64
|
+
const contentApiUrl = getContentApiUrl(context);
|
|
65
|
+
const projectConfig = getProjectLocaleConfig(context);
|
|
66
|
+
const renderMode = getRenderMode(context);
|
|
67
|
+
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
68
|
+
const requestContentPath = getCleanContentPathArrayOrThrow400(context.contentPath);
|
|
69
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
70
|
+
UrlProcessor.setSiteKey(projectConfig.site);
|
|
71
|
+
try {
|
|
72
|
+
const [siteRelativeContentPath, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
73
|
+
if (componentPath) {
|
|
74
|
+
// set component request type because url contains component path
|
|
75
|
+
requestType = XP_REQUEST_TYPE.COMPONENT;
|
|
131
76
|
}
|
|
132
|
-
//
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
77
|
+
// ///////////// FIRST GUILLOTINE CALL FOR METADATA /////////////////
|
|
78
|
+
const metaResult = yield fetchMetaData(contentApiUrl, '${site}/' + siteRelativeContentPath, projectConfig, outHeaders);
|
|
79
|
+
// ///////////////////////////////////////////////////////////////////////
|
|
80
|
+
const { _path, type } = metaResult.meta || {};
|
|
81
|
+
const contentPath = _path || siteRelativeContentPath;
|
|
82
|
+
if (metaResult.error) {
|
|
83
|
+
console.error(metaResult.error);
|
|
84
|
+
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
140
85
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
86
|
+
if (!metaResult.meta) {
|
|
87
|
+
return errorResponse('404', 'No meta data found for content, most likely content does not exist');
|
|
88
|
+
}
|
|
89
|
+
else if (!type) {
|
|
90
|
+
return errorResponse('500', "Server responded with incomplete meta data: missing content 'type' attribute.");
|
|
91
|
+
}
|
|
92
|
+
else if (renderMode === RENDER_MODE.NEXT
|
|
93
|
+
&& !IS_DEV_MODE
|
|
94
|
+
&& (type === FRAGMENT_CONTENTTYPE_NAME ||
|
|
95
|
+
type === PAGE_TEMPLATE_CONTENTTYPE_NAME ||
|
|
96
|
+
type === PAGE_TEMPLATE_FOLDER)) {
|
|
97
|
+
return errorResponse('404', `Content type [${type}] is not accessible in ${renderMode} mode`);
|
|
98
|
+
}
|
|
99
|
+
const components = restrictComponentsToPath(type, metaResult.meta.components, componentPath);
|
|
100
|
+
if (componentPath && !components.length) {
|
|
101
|
+
// component was not found
|
|
102
|
+
return errorResponse('404', `Component ${componentPath} was not found`);
|
|
103
|
+
}
|
|
104
|
+
if (requestType !== XP_REQUEST_TYPE.COMPONENT && components.length > 0) {
|
|
105
|
+
requestType = XP_REQUEST_TYPE.PAGE;
|
|
106
|
+
}
|
|
107
|
+
// ////////////////////////////////////////////////// Content type established. Proceed to data call:
|
|
108
|
+
const allDescriptors = [];
|
|
109
|
+
// Add the content type query at all cases
|
|
110
|
+
const contentTypeDef = ComponentRegistry.getContentType(type);
|
|
111
|
+
const pageCmp = (components || []).find(cmp => cmp.type === XP_COMPONENT_TYPE.PAGE);
|
|
112
|
+
if (pageCmp) {
|
|
113
|
+
processComponentConfig(APP_NAME, APP_NAME_DASHED, pageCmp);
|
|
114
|
+
}
|
|
115
|
+
const contentQueryAndVars = getQueryAndVariables(type, contentPath, 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);
|
|
116
|
+
if (contentQueryAndVars) {
|
|
117
|
+
allDescriptors.push({
|
|
118
|
+
type: contentTypeDef,
|
|
119
|
+
queryAndVariables: contentQueryAndVars,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const commonQueryAndVars = getQueryAndVariables(type, contentPath, context, ComponentRegistry.getCommonQuery(), (_b = pageCmp === null || pageCmp === void 0 ? void 0 : pageCmp.page) === null || _b === void 0 ? void 0 : _b.config);
|
|
123
|
+
if (commonQueryAndVars) {
|
|
124
|
+
allDescriptors.push({
|
|
125
|
+
type: contentTypeDef,
|
|
126
|
+
queryAndVariables: commonQueryAndVars,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if ((components === null || components === void 0 ? void 0 : components.length) && ComponentRegistry) {
|
|
130
|
+
for (const cmp of (components || [])) {
|
|
131
|
+
processComponentConfig(APP_NAME, APP_NAME_DASHED, cmp);
|
|
176
132
|
}
|
|
177
|
-
|
|
178
|
-
|
|
133
|
+
// Collect component queries if defined
|
|
134
|
+
const componentDescriptors = collectComponentDescriptors({
|
|
135
|
+
components,
|
|
136
|
+
xpContentPath: contentPath,
|
|
137
|
+
context,
|
|
138
|
+
});
|
|
139
|
+
if (componentDescriptors.length) {
|
|
140
|
+
allDescriptors.push(...componentDescriptors);
|
|
179
141
|
}
|
|
180
|
-
allDescriptors[i].component.error = reason;
|
|
181
142
|
}
|
|
182
|
-
|
|
183
|
-
|
|
143
|
+
const { query, variables } = combineMultipleQueries(allDescriptors);
|
|
144
|
+
if (!query.trim()) {
|
|
145
|
+
return errorResponse('400', `Missing or empty query override for content type ${type}`);
|
|
184
146
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
147
|
+
// /////////////// SECOND GUILLOTINE CALL FOR DATA //////////////////////
|
|
148
|
+
const contentResults = yield fetchContentData(contentApiUrl, contentPath, projectConfig, query, variables, outHeaders);
|
|
149
|
+
// ///////////////////////////////////////////////////////////////////////////
|
|
150
|
+
if (contentResults.error) {
|
|
151
|
+
console.error(contentResults.error);
|
|
152
|
+
return errorResponse(contentResults.error.code, contentResults.error.message);
|
|
153
|
+
}
|
|
154
|
+
// Apply processors to every component
|
|
155
|
+
const datas = yield applyProcessors(allDescriptors, contentResults, context);
|
|
156
|
+
// Unwind the data back to components
|
|
157
|
+
let contentData = null, common = null;
|
|
158
|
+
let startFrom = 0;
|
|
159
|
+
if (contentQueryAndVars) {
|
|
160
|
+
const item = datas[startFrom];
|
|
161
|
+
contentData = item.status === 'fulfilled' ? item.value : item.reason;
|
|
162
|
+
startFrom++;
|
|
163
|
+
}
|
|
164
|
+
if (commonQueryAndVars) {
|
|
165
|
+
const item = datas[startFrom];
|
|
166
|
+
common = item.status === 'fulfilled' ? item.value : item.reason;
|
|
167
|
+
startFrom++;
|
|
168
|
+
}
|
|
169
|
+
for (let i = startFrom; i < datas.length; i++) {
|
|
170
|
+
// component descriptors hold references to components
|
|
171
|
+
// that will later be used for creating page regions
|
|
172
|
+
const datum = datas[i];
|
|
173
|
+
if (datum.status === 'rejected') {
|
|
174
|
+
let reason = datum.reason;
|
|
175
|
+
if (reason instanceof Error) {
|
|
176
|
+
reason = reason.message;
|
|
177
|
+
}
|
|
178
|
+
else if (typeof reason !== 'string') {
|
|
179
|
+
reason = String(reason);
|
|
180
|
+
}
|
|
181
|
+
allDescriptors[i].component.error = reason;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
allDescriptors[i].component.data = datum.value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const page = buildPage(type, components);
|
|
188
|
+
const meta = createMetaData({
|
|
189
|
+
apiUrl: contentApiUrl,
|
|
190
|
+
baseUrl: xpBaseUrl,
|
|
191
|
+
components,
|
|
192
|
+
contentPath: siteRelativeContentPath,
|
|
193
|
+
contentType: type,
|
|
194
|
+
defaultLocale,
|
|
195
|
+
locale,
|
|
196
|
+
pageCmp: page,
|
|
197
|
+
renderMode,
|
|
198
|
+
requestedComponentPath: componentPath,
|
|
199
|
+
requestType,
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
data: contentData,
|
|
203
|
+
common,
|
|
204
|
+
meta,
|
|
205
|
+
page,
|
|
217
206
|
};
|
|
218
207
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
catch (e) {
|
|
209
|
+
console.error(e);
|
|
210
|
+
let error;
|
|
211
|
+
try {
|
|
212
|
+
error = JSON.parse(e.message);
|
|
213
|
+
}
|
|
214
|
+
catch (e2) {
|
|
215
|
+
error = {
|
|
216
|
+
code: 'Local',
|
|
217
|
+
message: e.message,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return errorResponse(error.code, error.message);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
222
224
|
//# sourceMappingURL=fetchContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContent.js","sourceRoot":"","sources":["../../src/guillotine/fetchContent.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACH,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,eAAe,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AACvE,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;AAErF,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,kCAAkC,EAAC,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAC,kBAAkB,EAAC,MAAM,s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,sBAAsB,EAAE,aAAa;gBACrC,WAAW;aACd,CAAC,CAAC;YAEH,OAAO;gBACH,IAAI,EAAE,WAAW;gBACjB,MAAM;gBACN,IAAI;gBACJ,IAAI;aACP,CAAC;QACN,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAEjB,IAAI,KAAK,CAAC;YACV,IAAI,CAAC;gBACD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACV,KAAK,GAAG;oBACJ,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,CAAC,CAAC,OAAO;iBACrB,CAAC;YACN,CAAC;YACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC;;CACJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ContentApiBaseBody, GuillotineResponseJson, ProjectLocaleConfig } from '../types';
|
|
2
2
|
/** Generic fetch */
|
|
3
|
-
export declare
|
|
3
|
+
export declare function fetchFromApi<Data = Record<string, unknown>>(apiUrl: string, body: ContentApiBaseBody, projectConfig: ProjectLocaleConfig, headers?: {}, method?: string): Promise<GuillotineResponseJson<Data>>;
|
|
@@ -8,58 +8,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
/** Generic fetch */
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
11
|
+
export function fetchFromApi(apiUrl, body, projectConfig, headers, method = 'POST') {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const options = {
|
|
14
|
+
method,
|
|
15
|
+
headers: {
|
|
16
|
+
'Accept': 'application/json',
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
'X-Guillotine-SiteKey': projectConfig.site,
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify(body),
|
|
21
|
+
};
|
|
22
|
+
if (headers) {
|
|
23
|
+
Object.assign(options.headers, headers);
|
|
24
|
+
}
|
|
25
|
+
let res;
|
|
26
|
+
try {
|
|
27
|
+
res = yield fetch(apiUrl, options);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
console.warn(apiUrl, e);
|
|
31
|
+
throw new Error(JSON.stringify({
|
|
32
|
+
code: 'API',
|
|
33
|
+
message: e.message,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
throw new Error(JSON.stringify({
|
|
38
|
+
code: res.status,
|
|
39
|
+
message: `Data fetching failed (message: '${yield res.text()}')`,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
let json;
|
|
43
|
+
try {
|
|
44
|
+
json = yield res.json();
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
throw new Error(JSON.stringify({
|
|
48
|
+
code: 500,
|
|
49
|
+
message: `API call completed but with non-JSON data: ${JSON.stringify(yield res.text())}`,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
if (!json) {
|
|
53
|
+
throw new Error(JSON.stringify({
|
|
54
|
+
code: 500,
|
|
55
|
+
message: `API call completed but with unexpectedly empty data: ${JSON.stringify(yield res.text())}`,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(json)) {
|
|
59
|
+
throw new Error(JSON.stringify({
|
|
60
|
+
code: 500,
|
|
61
|
+
message: `API call completed but with unexpected array data: ${JSON.stringify(json)}`,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
return json;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
65
67
|
//# sourceMappingURL=fetchFromApi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchFromApi.js","sourceRoot":"","sources":["../../src/guillotine/fetchFromApi.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetchFromApi.js","sourceRoot":"","sources":["../../src/guillotine/fetchFromApi.ts"],"names":[],"mappings":";;;;;;;;;AAGA,oBAAoB;AACpB,MAAM,UAAgB,YAAY,CAC9B,MAAc,EACd,IAAwB,EACxB,aAAkC,EAClC,OAAY,EACZ,MAAM,GAAG,MAAM;;QAEf,MAAM,OAAO,GAAG;YACZ,MAAM;YACN,OAAO,EAAE;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,cAAc,EAAE,kBAAkB;gBAClC,sBAAsB,EAAE,aAAa,CAAC,IAAI;aAC7C;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC7B,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,GAA6B,CAAC;QAClC,IA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AK,CAAC,IAAI,CAAC,SAAS,CAAC;gBAC3B,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,sDAAsD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;aACxF,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ContentApiBaseBody, GuillotineResult, ProjectLocaleConfig } from '../types';
|
|
2
2
|
/** Guillotine-specialized fetch, using the generic fetch above */
|
|
3
|
-
export declare
|
|
3
|
+
export declare function fetchGuillotine<Data = Record<string, unknown>>(contentApiUrl: string, body: ContentApiBaseBody, projectConfig: ProjectLocaleConfig, headers?: {}): Promise<GuillotineResult>;
|
|
@@ -9,47 +9,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { fetchFromApi } from './fetchFromApi';
|
|
11
11
|
/** Guillotine-specialized fetch, using the generic fetch above */
|
|
12
|
-
export
|
|
12
|
+
export function fetchGuillotine(contentApiUrl, body, projectConfig, headers) {
|
|
13
13
|
var _a;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error: {
|
|
17
|
-
code: '400',
|
|
18
|
-
message: `Invalid or missing query. JSON.stringify(query) = ${JSON.stringify(body.query)}`,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const path = (_a = body.variables) === null || _a === void 0 ? void 0 : _a.path;
|
|
23
|
-
const pathMessage = path ? JSON.stringify(path) : '';
|
|
24
|
-
return yield fetchFromApi(contentApiUrl, body, projectConfig, headers)
|
|
25
|
-
.then(json => {
|
|
26
|
-
let errors = json.errors; // fetchFromApi ensures json is an object
|
|
27
|
-
if (errors) {
|
|
28
|
-
if (!Array.isArray(errors)) {
|
|
29
|
-
errors = [errors];
|
|
30
|
-
}
|
|
31
|
-
console.error(`${errors.length} error(s) when fetching data from: ${contentApiUrl}`);
|
|
32
|
-
console.error(`headers: ${JSON.stringify(headers, null, 2)} \nvariables: ${JSON.stringify(body.variables, null, 2)}`);
|
|
33
|
-
errors.forEach(error => {
|
|
34
|
-
console.error(error);
|
|
35
|
-
});
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (typeof body.query !== 'string' || !body.query.trim()) {
|
|
36
16
|
return {
|
|
37
17
|
error: {
|
|
38
|
-
code: '
|
|
39
|
-
message: `
|
|
18
|
+
code: '400',
|
|
19
|
+
message: `Invalid or missing query. JSON.stringify(query) = ${JSON.stringify(body.query)}`,
|
|
40
20
|
},
|
|
41
21
|
};
|
|
42
22
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
const path = (_a = body.variables) === null || _a === void 0 ? void 0 : _a.path;
|
|
24
|
+
const pathMessage = path ? JSON.stringify(path) : '';
|
|
25
|
+
return yield fetchFromApi(contentApiUrl, body, projectConfig, headers)
|
|
26
|
+
.then(json => {
|
|
27
|
+
let errors = json.errors; // fetchFromApi ensures json is an object
|
|
28
|
+
if (errors) {
|
|
29
|
+
if (!Array.isArray(errors)) {
|
|
30
|
+
errors = [errors];
|
|
31
|
+
}
|
|
32
|
+
console.error(`${errors.length} error(s) when fetching data from: ${contentApiUrl}`);
|
|
33
|
+
console.error(`headers: ${JSON.stringify(headers, null, 2)} \nvariables: ${JSON.stringify(body.variables, null, 2)}`);
|
|
34
|
+
errors.forEach(error => {
|
|
35
|
+
console.error(error);
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
error: {
|
|
39
|
+
code: '500',
|
|
40
|
+
message: `Server responded with ${errors.length} error(s), probably from guillotine - see log.`,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return json.data;
|
|
45
|
+
})
|
|
46
|
+
.catch((err) => {
|
|
47
|
+
console.warn(`Client-side error when trying to fetch data ${pathMessage}`, err);
|
|
48
|
+
try {
|
|
49
|
+
return { error: JSON.parse(err.message) };
|
|
50
|
+
}
|
|
51
|
+
catch (e2) {
|
|
52
|
+
return { error: { code: 'Client-side error', message: err.message } };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
53
55
|
});
|
|
54
|
-
}
|
|
56
|
+
}
|
|
55
57
|
//# sourceMappingURL=fetchGuillotine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchGuillotine.js","sourceRoot":"","sources":["../../src/guillotine/fetchGuillotine.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetchGuillotine.js","sourceRoot":"","sources":["../../src/guillotine/fetchGuillotine.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C,kEAAkE;AAClE,MAAM,UAAgB,eAAe,CACjC,aAAqB,EACrB,IAAwB,EACxB,aAAkC,EAClC,OAAY;;;QAEZ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACvD,OAAO;gBACH,KAAK,EAAE;oBACH,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,qDAAqD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;iBAC7F;aACJ,CAAC;QACN,CAAC;QACD,MAAM,IAAI,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,YAAY,CACrB,aAAa,EACb,IAAI,EACJ,aAAa,EACb,OAAO,CACV;aACI,IAAI,CAAC,IAAI,CAAC,EAAE;YACT,IAAI,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.ts
CHANGED
|
@@ -2,17 +2,13 @@ export { APP_NAME, APP_NAME_DASHED, APP_NAME_UNDERSCORED, IS_DEV_MODE, } from '.
|
|
|
2
2
|
export type * from './types';
|
|
3
3
|
export { ComponentRegistry } from './common/ComponentRegistry';
|
|
4
4
|
export { CATCH_ALL, JSESSIONID_HEADER, PORTAL_COMPONENT_ATTRIBUTE, PORTAL_REGION_ATTRIBUTE, PROJECT_ID_HEADER, RENDER_MODE, RENDER_MODE_HEADER, XP_BASE_URL_HEADER, XP_COMPONENT_TYPE, XP_REQUEST_TYPE, } from './common/constants';
|
|
5
|
-
export { fetchContent } from './guillotine/fetchContent';
|
|
6
|
-
export { fetchContentPathsForAllLocales } from './guillotine/fetchContentPathsForAllLocales';
|
|
7
|
-
export { fetchContentPathsForLocale } from './guillotine/fetchContentPathsForLocale';
|
|
8
|
-
export { fetchFromApi } from './guillotine/fetchFromApi';
|
|
9
|
-
export { fetchGuillotine } from './guillotine/fetchGuillotine';
|
|
10
5
|
export { richTextQuery } from './guillotine/metadata/richTextQuery';
|
|
11
6
|
export { validateData } from './guillotine/validateData';
|
|
12
7
|
export { I18n } from './i18n/i18n';
|
|
13
8
|
export { getContentApiUrl } from './utils/getContentApiUrl';
|
|
14
9
|
export { getProjectLocaleConfig } from './utils/getProjectLocaleConfig';
|
|
15
10
|
export { getProjectLocaleConfigById } from './utils/getProjectLocaleConfigById';
|
|
11
|
+
export { getProjectLocaleConfigByLocale } from './utils/getProjectLocaleConfigByLocale';
|
|
16
12
|
export { getRequestLocaleInfo } from './utils/getRequestLocaleInfo';
|
|
17
13
|
export { sanitizeGraphqlName } from './utils/sanitizeGraphqlName';
|
|
18
14
|
export { UrlProcessor, getAsset, getUrl, } from './common/UrlProcessor';
|
package/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
export { APP_NAME, APP_NAME_DASHED, APP_NAME_UNDERSCORED, IS_DEV_MODE, } from './common/env';
|
|
2
2
|
export { ComponentRegistry } from './common/ComponentRegistry';
|
|
3
3
|
export { CATCH_ALL, JSESSIONID_HEADER, PORTAL_COMPONENT_ATTRIBUTE, PORTAL_REGION_ATTRIBUTE, PROJECT_ID_HEADER, RENDER_MODE, RENDER_MODE_HEADER, XP_BASE_URL_HEADER, XP_COMPONENT_TYPE, XP_REQUEST_TYPE, } from './common/constants';
|
|
4
|
-
export { fetchContent } from './guillotine/fetchContent';
|
|
5
|
-
export { fetchContentPathsForAllLocales } from './guillotine/fetchContentPathsForAllLocales';
|
|
6
|
-
export { fetchContentPathsForLocale } from './guillotine/fetchContentPathsForLocale';
|
|
7
|
-
export { fetchFromApi } from './guillotine/fetchFromApi';
|
|
8
|
-
export { fetchGuillotine } from './guillotine/fetchGuillotine';
|
|
9
4
|
export { richTextQuery } from './guillotine/metadata/richTextQuery';
|
|
10
5
|
export { validateData } from './guillotine/validateData';
|
|
11
6
|
export { I18n } from './i18n/i18n';
|
|
12
7
|
export { getContentApiUrl } from './utils/getContentApiUrl';
|
|
13
8
|
export { getProjectLocaleConfig } from './utils/getProjectLocaleConfig';
|
|
14
9
|
export { getProjectLocaleConfigById } from './utils/getProjectLocaleConfigById';
|
|
10
|
+
export { getProjectLocaleConfigByLocale } from './utils/getProjectLocaleConfigByLocale';
|
|
15
11
|
export { getRequestLocaleInfo } from './utils/getRequestLocaleInfo';
|
|
16
12
|
export { sanitizeGraphqlName } from './utils/sanitizeGraphqlName';
|
|
17
13
|
export { UrlProcessor, getAsset, getUrl, } from './common/UrlProcessor';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,WAAW,GACd,MAAM,cAAc,CAAC;AAItB,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EACH,SAAS,EACT,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAClB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,WAAW,GACd,MAAM,cAAc,CAAC;AAItB,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EACH,SAAS,EACT,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAC,aAAa,EAAC,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAC,8BAA8B,EAAC,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,MAAM,GACT,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-B3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"clean": "del-cli *.d.ts *.js.map baseMappings.* client.* common coverage index.* enonic-nextjs-adapter-*.tgz guillotine i18n query types utils views dist",
|
|
36
|
+
"clean": "del-cli *.d.ts *.js.map baseMappings.* client.* server.* common coverage index.* enonic-nextjs-adapter-*.tgz guillotine i18n query types utils views dist",
|
|
37
37
|
"build": "tsc",
|
|
38
38
|
"build:prod": "tsc --outDir ./dist && npx --yes cpy-cli package.json README.md ./dist",
|
|
39
39
|
"release": "concurrently -c auto -g --timings npm:test npm:lint npm:build:prod",
|
|
@@ -49,25 +49,25 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
52
|
-
"html-react-parser": "^5.1.
|
|
52
|
+
"html-react-parser": "^5.1.2",
|
|
53
53
|
"negotiator": "^0.6.3",
|
|
54
|
-
"next": "^14.0
|
|
54
|
+
"next": "^14.1.0",
|
|
55
55
|
"react": "18.2.0",
|
|
56
56
|
"react-dom": "18.2.0",
|
|
57
57
|
"unescape": "^1.0.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@edge-runtime/jest-environment": "^2.3.
|
|
60
|
+
"@edge-runtime/jest-environment": "^2.3.9",
|
|
61
61
|
"@enonic-types/core": "^7.14.0-B2",
|
|
62
62
|
"@enonic/eslint-config": "^1.1.0",
|
|
63
|
-
"@testing-library/jest-dom": "^6.2
|
|
64
|
-
"@testing-library/react": "^14.1
|
|
63
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
64
|
+
"@testing-library/react": "^14.2.1",
|
|
65
65
|
"@types/negotiator": "^0.6.3",
|
|
66
|
-
"@types/node": "^20.11.
|
|
67
|
-
"@types/react": "^18.2.
|
|
68
|
-
"@types/react-dom": "^18.2.
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
70
|
-
"@typescript-eslint/parser": "^6.
|
|
66
|
+
"@types/node": "^20.11.17",
|
|
67
|
+
"@types/react": "^18.2.55",
|
|
68
|
+
"@types/react-dom": "^18.2.19",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
70
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
71
71
|
"concurrently": "^8.2.2",
|
|
72
72
|
"cpy-cli": "^5.0.0",
|
|
73
73
|
"del-cli": "^5.1.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"jest-environment-jsdom": "^29.7.0",
|
|
78
78
|
"madge": "^6.1.0",
|
|
79
79
|
"mkdirp": "^3.0.1",
|
|
80
|
-
"ts-jest": "^29.1.
|
|
80
|
+
"ts-jest": "^29.1.2",
|
|
81
81
|
"ts-node": "^10.9.2",
|
|
82
82
|
"typescript": "^5.3.3"
|
|
83
83
|
},
|
package/server.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { fetchContent } from './guillotine/fetchContent';
|
|
2
|
+
export { fetchContentPathsForAllLocales } from './guillotine/fetchContentPathsForAllLocales';
|
|
3
|
+
export { fetchContentPathsForLocale } from './guillotine/fetchContentPathsForLocale';
|
|
4
|
+
export { fetchFromApi } from './guillotine/fetchFromApi';
|
|
5
|
+
export { fetchGuillotine } from './guillotine/fetchGuillotine';
|
package/server.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,8BAA8B,EAAC,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAC,0BAA0B,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC"}
|