@enonic/nextjs-adapter 3.2.1 → 3.2.2
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.
|
@@ -9,11 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import gqlmin from 'gqlmin';
|
|
11
11
|
import { fetchFromApi } from './fetchFromApi';
|
|
12
|
+
const XP_ERROR_PATTERN = '/_/error/';
|
|
12
13
|
/** Guillotine-specialized fetch, using the generic fetch above */
|
|
13
14
|
export function fetchGuillotine(contentApiUrl, mapping, options) {
|
|
14
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
16
|
var _a;
|
|
16
17
|
const body = options === null || options === void 0 ? void 0 : options.body;
|
|
18
|
+
const path = (_a = body === null || body === void 0 ? void 0 : body.variables) === null || _a === void 0 ? void 0 : _a.path;
|
|
17
19
|
if (typeof body.query !== 'string' || !body.query.trim()) {
|
|
18
20
|
return {
|
|
19
21
|
error: {
|
|
@@ -23,10 +25,21 @@ export function fetchGuillotine(contentApiUrl, mapping, options) {
|
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
+
// special case for not sending XP generated error paths to guillotine
|
|
29
|
+
const pathArr = path === null || path === void 0 ? void 0 : path.split(XP_ERROR_PATTERN);
|
|
30
|
+
if ((pathArr === null || pathArr === void 0 ? void 0 : pathArr.length) === 2) {
|
|
31
|
+
return {
|
|
32
|
+
error: {
|
|
33
|
+
code: pathArr[1],
|
|
34
|
+
message: `XP error URL detected`,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Minify the query to avoid hitting 200k space limit
|
|
40
|
+
body.query = gqlmin(body.query);
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
|
-
const path = (_a = body === null || body === void 0 ? void 0 : body.variables) === null || _a === void 0 ? void 0 : _a.path;
|
|
30
43
|
const pathMessage = path ? JSON.stringify(path) : '';
|
|
31
44
|
return yield fetchFromApi(contentApiUrl, mapping, options)
|
|
32
45
|
.then(json => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchGuillotine.js","sourceRoot":"","sources":["../src/guillotine/fetchGuillotine.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchGuillotine.js","sourceRoot":"","sources":["../src/guillotine/fetchGuillotine.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC,kEAAkE;AAClE,MAAM,UAAgB,eAAe,CACjC,aAAqB,EACrB,OAAsB,EACtB,OAAsB;;;QAEtB,MAAM,IAAI,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,0CAAE,IAAI,CAAC;QAEnC,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;aAAM,CAAC;YACJ,sEAAsE;YACtE,MAAM,OAAO,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC9C,IAAI,CAAA,OAAO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,EAAE,EAAE,GAAG,CAAC,CAAC;YAChF,IAAI,CAAC;gBACD,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAC,CAAC;YAC5C,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACV,OAAO,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,EAAC,CAAC;YACtE,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
@@ -53,40 +53,40 @@
|
|
|
53
53
|
"@enonic/react-components": "^5.0.1",
|
|
54
54
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
55
55
|
"gqlmin": "^0.2.2",
|
|
56
|
-
"html-react-parser": "^5.2.
|
|
56
|
+
"html-react-parser": "^5.2.5",
|
|
57
57
|
"negotiator": "^1.0.0",
|
|
58
|
-
"next": "^15.2
|
|
58
|
+
"next": "^15.3.2",
|
|
59
59
|
"react": "18.3.1",
|
|
60
60
|
"react-dom": "18.3.1",
|
|
61
61
|
"unescape": "^1.0.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/preset-env": "^7.
|
|
64
|
+
"@babel/core": "^7.27.1",
|
|
65
|
+
"@babel/preset-env": "^7.27.2",
|
|
66
66
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
67
67
|
"@enonic-types/core": "^7.15.1",
|
|
68
68
|
"@enonic/eslint-config": "^2.0.1",
|
|
69
69
|
"@testing-library/jest-dom": "^6.6.3",
|
|
70
|
-
"@testing-library/react": "^16.
|
|
70
|
+
"@testing-library/react": "^16.3.0",
|
|
71
71
|
"@types/negotiator": "^0.6.3",
|
|
72
|
-
"@types/node": "^22.
|
|
72
|
+
"@types/node": "^22.15.17",
|
|
73
73
|
"@types/react": "^18.3.12",
|
|
74
74
|
"@types/react-dom": "^18.3.1",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
76
|
-
"@typescript-eslint/parser": "^8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.32.0",
|
|
77
77
|
"babel-jest": "^29.7.0",
|
|
78
78
|
"concurrently": "^9.1.2",
|
|
79
79
|
"cpy-cli": "^5.0.0",
|
|
80
80
|
"del-cli": "^6.0.0",
|
|
81
|
-
"eslint": "^9.
|
|
82
|
-
"eslint-plugin-react": "^7.37.
|
|
81
|
+
"eslint": "^9.26.0",
|
|
82
|
+
"eslint-plugin-react": "^7.37.5",
|
|
83
83
|
"jest": "^29.7.0",
|
|
84
84
|
"jest-environment-jsdom": "^29.7.0",
|
|
85
85
|
"madge": "^8.0.0",
|
|
86
86
|
"mkdirp": "^3.0.1",
|
|
87
|
-
"ts-jest": "^29.3.
|
|
87
|
+
"ts-jest": "^29.3.2",
|
|
88
88
|
"ts-node": "^10.9.2",
|
|
89
|
-
"typescript": "^5.8.
|
|
89
|
+
"typescript": "^5.8.3"
|
|
90
90
|
},
|
|
91
91
|
"types": "index.d.ts"
|
|
92
92
|
}
|
|
@@ -3,6 +3,7 @@ import gqlmin from 'gqlmin';
|
|
|
3
3
|
|
|
4
4
|
import {fetchFromApi} from './fetchFromApi';
|
|
5
5
|
|
|
6
|
+
const XP_ERROR_PATTERN = '/_/error/';
|
|
6
7
|
|
|
7
8
|
/** Guillotine-specialized fetch, using the generic fetch above */
|
|
8
9
|
export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
@@ -11,6 +12,8 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
11
12
|
options?: FetchOptions,
|
|
12
13
|
): Promise<GuillotineResult> {
|
|
13
14
|
const body = options?.body;
|
|
15
|
+
const path = body?.variables?.path;
|
|
16
|
+
|
|
14
17
|
if (typeof body.query !== 'string' || !body.query.trim()) {
|
|
15
18
|
return {
|
|
16
19
|
error: {
|
|
@@ -19,11 +22,21 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
19
22
|
},
|
|
20
23
|
};
|
|
21
24
|
} else {
|
|
22
|
-
//
|
|
23
|
-
|
|
25
|
+
// special case for not sending XP generated error paths to guillotine
|
|
26
|
+
const pathArr = path?.split(XP_ERROR_PATTERN);
|
|
27
|
+
if (pathArr?.length === 2) {
|
|
28
|
+
return {
|
|
29
|
+
error: {
|
|
30
|
+
code: pathArr[1],
|
|
31
|
+
message: `XP error URL detected`,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
// Minify the query to avoid hitting 200k space limit
|
|
36
|
+
body.query = gqlmin(body.query);
|
|
37
|
+
}
|
|
24
38
|
}
|
|
25
39
|
|
|
26
|
-
const path = body?.variables?.path;
|
|
27
40
|
const pathMessage = path ? JSON.stringify(path) : '';
|
|
28
41
|
return await fetchFromApi<Data>(
|
|
29
42
|
contentApiUrl,
|