@enonic/nextjs-adapter 3.2.2 → 3.3.0-B1
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/package.json +41 -22
- package/src/baseMappings.ts +9 -9
- package/src/common/ComponentRegistry.ts +2 -5
- package/src/common/constants.ts +4 -4
- package/src/common/env.ts +1 -1
- package/src/guillotine/applyProcessors.ts +3 -7
- package/src/guillotine/buildComponentTree.ts +1 -1
- package/src/guillotine/buildErrorResponse.ts +3 -3
- package/src/guillotine/buildPage.ts +2 -2
- package/src/guillotine/collectComponentDescriptors.ts +6 -13
- package/src/guillotine/combineMultipleQueries.ts +3 -6
- package/src/guillotine/createMetaData.ts +2 -2
- package/src/guillotine/fetchContent.ts +8 -14
- package/src/guillotine/fetchContentData.ts +4 -10
- package/src/guillotine/fetchContentPathsForAllLocales.ts +3 -3
- package/src/guillotine/fetchContentPathsForLocale.ts +7 -7
- package/src/guillotine/fetchFromApi.ts +8 -8
- package/src/guillotine/fetchGuillotine.ts +8 -8
- package/src/guillotine/fetchMetaData.ts +5 -5
- package/src/guillotine/getCleanContentPathArrayOrThrow400.ts +2 -2
- package/src/guillotine/getParentRegion.ts +2 -2
- package/src/guillotine/getQueryAndVariables.ts +5 -9
- package/src/guillotine/metadata/configQuery.ts +2 -2
- package/src/guillotine/parseComponentPath.ts +4 -7
- package/src/guillotine/processComponentConfig.ts +1 -1
- package/src/guillotine/restrictComponentsToPath.ts +1 -1
- package/src/i18n/LocaleContext.tsx +3 -3
- package/src/index.ts +3 -3
- package/src/types/component.ts +1 -1
- package/src/types/componentProps.ts +4 -3
- package/src/types/guillotine.ts +1 -1
- package/src/types/index.ts +3 -3
- package/src/utils/buildGuillotineRequestHeaders.ts +4 -7
- package/src/utils/fixDoubleSlashes.ts +1 -1
- package/src/utils/getLocaleMappings.ts +1 -1
- package/src/utils/getRenderMode.ts +2 -5
- package/src/views/BaseComponent.tsx +5 -5
- package/src/views/BaseContent.tsx +1 -1
- package/src/views/BaseMacro.tsx +1 -1
- package/src/views/PropsView.tsx +1 -1
- package/src/views/RichTextView.tsx +68 -25
- package/src/views/StaticContent.tsx +1 -1
- package/baseMappings.d.ts +0 -1
- package/baseMappings.js +0 -43
- package/baseMappings.js.map +0 -1
- package/client/getClientHydratedHtml.d.ts +0 -1
- package/client/getClientHydratedHtml.jsx +0 -9
- package/client/getClientHydratedHtml.jsx.map +0 -1
- package/client.d.ts +0 -1
- package/client.js +0 -3
- package/client.js.map +0 -1
- package/common/ComponentRegistry.d.ts +0 -34
- package/common/ComponentRegistry.js +0 -121
- package/common/ComponentRegistry.js.map +0 -1
- package/common/UrlProcessor.d.ts +0 -25
- package/common/UrlProcessor.js +0 -151
- package/common/UrlProcessor.js.map +0 -1
- package/common/constants.d.ts +0 -51
- package/common/constants.js +0 -86
- package/common/constants.js.map +0 -1
- package/common/env.d.ts +0 -12
- package/common/env.js +0 -30
- package/common/env.js.map +0 -1
- package/guillotine/applyProcessors.d.ts +0 -2
- package/guillotine/applyProcessors.js +0 -33
- package/guillotine/applyProcessors.js.map +0 -1
- package/guillotine/buildComponentTree.d.ts +0 -2
- package/guillotine/buildComponentTree.js +0 -45
- package/guillotine/buildComponentTree.js.map +0 -1
- package/guillotine/buildErrorResponse.d.ts +0 -3
- package/guillotine/buildErrorResponse.js +0 -27
- package/guillotine/buildErrorResponse.js.map +0 -1
- package/guillotine/buildPage.d.ts +0 -2
- package/guillotine/buildPage.js +0 -10
- package/guillotine/buildPage.js.map +0 -1
- package/guillotine/collectComponentDescriptors.d.ts +0 -6
- package/guillotine/collectComponentDescriptors.js +0 -43
- package/guillotine/collectComponentDescriptors.js.map +0 -1
- package/guillotine/combineMultipleQueries.d.ts +0 -2
- package/guillotine/combineMultipleQueries.js +0 -58
- package/guillotine/combineMultipleQueries.js.map +0 -1
- package/guillotine/createMetaData.d.ts +0 -18
- package/guillotine/createMetaData.js +0 -45
- package/guillotine/createMetaData.js.map +0 -1
- package/guillotine/fetchContent.d.ts +0 -9
- package/guillotine/fetchContent.js +0 -222
- package/guillotine/fetchContent.js.map +0 -1
- package/guillotine/fetchContentData.d.ts +0 -2
- package/guillotine/fetchContentData.js +0 -30
- package/guillotine/fetchContentData.js.map +0 -1
- package/guillotine/fetchContentPathsForAllLocales.d.ts +0 -2
- package/guillotine/fetchContentPathsForAllLocales.js +0 -21
- package/guillotine/fetchContentPathsForAllLocales.js.map +0 -1
- package/guillotine/fetchContentPathsForLocale.d.ts +0 -2
- package/guillotine/fetchContentPathsForLocale.js +0 -41
- package/guillotine/fetchContentPathsForLocale.js.map +0 -1
- package/guillotine/fetchFromApi.d.ts +0 -3
- package/guillotine/fetchFromApi.js +0 -76
- package/guillotine/fetchFromApi.js.map +0 -1
- package/guillotine/fetchGuillotine.d.ts +0 -3
- package/guillotine/fetchGuillotine.js +0 -75
- package/guillotine/fetchGuillotine.js.map +0 -1
- package/guillotine/fetchMetaData.d.ts +0 -2
- package/guillotine/fetchMetaData.js +0 -33
- package/guillotine/fetchMetaData.js.map +0 -1
- package/guillotine/getCleanContentPathArrayOrThrow400.d.ts +0 -2
- package/guillotine/getCleanContentPathArrayOrThrow400.js +0 -20
- package/guillotine/getCleanContentPathArrayOrThrow400.js.map +0 -1
- package/guillotine/getComponentConfig.d.ts +0 -2
- package/guillotine/getComponentConfig.js +0 -5
- package/guillotine/getComponentConfig.js.map +0 -1
- package/guillotine/getContentAndComponentPaths.d.ts +0 -1
- package/guillotine/getContentAndComponentPaths.js +0 -12
- package/guillotine/getContentAndComponentPaths.js.map +0 -1
- package/guillotine/getMetaData.d.ts +0 -2
- package/guillotine/getMetaData.js +0 -67
- package/guillotine/getMetaData.js.map +0 -1
- package/guillotine/getParentRegion.d.ts +0 -2
- package/guillotine/getParentRegion.js +0 -40
- package/guillotine/getParentRegion.js.map +0 -1
- package/guillotine/getQueryAndVariables.d.ts +0 -2
- package/guillotine/getQueryAndVariables.js +0 -32
- package/guillotine/getQueryAndVariables.js.map +0 -1
- package/guillotine/metadata/configQuery.d.ts +0 -2
- package/guillotine/metadata/configQuery.js +0 -36
- package/guillotine/metadata/configQuery.js.map +0 -1
- package/guillotine/metadata/richTextQuery.d.ts +0 -1
- package/guillotine/metadata/richTextQuery.js +0 -47
- package/guillotine/metadata/richTextQuery.js.map +0 -1
- package/guillotine/parseComponentPath.d.ts +0 -2
- package/guillotine/parseComponentPath.js +0 -22
- package/guillotine/parseComponentPath.js.map +0 -1
- package/guillotine/prefixFragmentCmpPath.d.ts +0 -1
- package/guillotine/prefixFragmentCmpPath.js +0 -13
- package/guillotine/prefixFragmentCmpPath.js.map +0 -1
- package/guillotine/processComponentConfig.d.ts +0 -2
- package/guillotine/processComponentConfig.js +0 -30
- package/guillotine/processComponentConfig.js.map +0 -1
- package/guillotine/restrictComponentsToPath.d.ts +0 -2
- package/guillotine/restrictComponentsToPath.js +0 -38
- package/guillotine/restrictComponentsToPath.js.map +0 -1
- package/guillotine/validateData.d.ts +0 -2
- package/guillotine/validateData.js +0 -7
- package/guillotine/validateData.js.map +0 -1
- package/guillotine/validateNotFound.d.ts +0 -2
- package/guillotine/validateNotFound.js +0 -16
- package/guillotine/validateNotFound.js.map +0 -1
- package/guillotine/validateShortcut.d.ts +0 -2
- package/guillotine/validateShortcut.js +0 -35
- package/guillotine/validateShortcut.js.map +0 -1
- package/i18n/LocaleContext.d.ts +0 -7
- package/i18n/LocaleContext.jsx +0 -50
- package/i18n/LocaleContext.jsx.map +0 -1
- package/i18n/i18n.d.ts +0 -12
- package/i18n/i18n.js +0 -59
- package/i18n/i18n.js.map +0 -1
- package/index.d.ts +0 -14
- package/index.js +0 -14
- package/index.js.map +0 -1
- package/query/Shortcut.d.ts +0 -1
- package/query/Shortcut.js +0 -19
- package/query/Shortcut.js.map +0 -1
- package/server/getServerRenderedHtml.d.ts +0 -1
- package/server/getServerRenderedHtml.js +0 -4
- package/server/getServerRenderedHtml.js.map +0 -1
- package/server.d.ts +0 -5
- package/server.js +0 -6
- package/server.js.map +0 -1
- package/types/component.d.ts +0 -92
- package/types/component.js +0 -2
- package/types/component.js.map +0 -1
- package/types/componentProps.d.ts +0 -106
- package/types/componentProps.js +0 -2
- package/types/componentProps.js.map +0 -1
- package/types/guillotine.d.ts +0 -344
- package/types/guillotine.js +0 -2
- package/types/guillotine.js.map +0 -1
- package/types/i18n.d.ts +0 -7
- package/types/i18n.js +0 -2
- package/types/i18n.js.map +0 -1
- package/types/index.d.ts +0 -47
- package/types/index.js +0 -3
- package/types/index.js.map +0 -1
- package/types/next.d.ts +0 -6
- package/types/next.js +0 -2
- package/types/next.js.map +0 -1
- package/types/util.d.ts +0 -3
- package/types/util.js +0 -3
- package/types/util.js.map +0 -1
- package/utils/addLineNumbers.d.ts +0 -1
- package/utils/addLineNumbers.js +0 -4
- package/utils/addLineNumbers.js.map +0 -1
- package/utils/buildGuillotineRequestHeaders.d.ts +0 -7
- package/utils/buildGuillotineRequestHeaders.js +0 -16
- package/utils/buildGuillotineRequestHeaders.js.map +0 -1
- package/utils/commonChars.d.ts +0 -1
- package/utils/commonChars.js +0 -17
- package/utils/commonChars.js.map +0 -1
- package/utils/enonicLog.d.ts +0 -5
- package/utils/enonicLog.js +0 -23
- package/utils/enonicLog.js.map +0 -1
- package/utils/fixDoubleSlashes.d.ts +0 -1
- package/utils/fixDoubleSlashes.js +0 -4
- package/utils/fixDoubleSlashes.js.map +0 -1
- package/utils/getAllLocales.d.ts +0 -1
- package/utils/getAllLocales.js +0 -5
- package/utils/getAllLocales.js.map +0 -1
- package/utils/getContentApiUrl.d.ts +0 -2
- package/utils/getContentApiUrl.js +0 -15
- package/utils/getContentApiUrl.js.map +0 -1
- package/utils/getLocaleMapping.d.ts +0 -2
- package/utils/getLocaleMapping.js +0 -19
- package/utils/getLocaleMapping.js.map +0 -1
- package/utils/getLocaleMappingByLocale.d.ts +0 -2
- package/utils/getLocaleMappingByLocale.js +0 -13
- package/utils/getLocaleMappingByLocale.js.map +0 -1
- package/utils/getLocaleMappingByProjectId.d.ts +0 -2
- package/utils/getLocaleMappingByProjectId.js +0 -16
- package/utils/getLocaleMappingByProjectId.js.map +0 -1
- package/utils/getLocaleMappings.d.ts +0 -2
- package/utils/getLocaleMappings.js +0 -30
- package/utils/getLocaleMappings.js.map +0 -1
- package/utils/getRenderMode.d.ts +0 -3
- package/utils/getRenderMode.js +0 -8
- package/utils/getRenderMode.js.map +0 -1
- package/utils/getRequestLocaleInfo.d.ts +0 -6
- package/utils/getRequestLocaleInfo.js +0 -29
- package/utils/getRequestLocaleInfo.js.map +0 -1
- package/utils/getXpBaseUrl.d.ts +0 -2
- package/utils/getXpBaseUrl.js +0 -8
- package/utils/getXpBaseUrl.js.map +0 -1
- package/utils/indent.d.ts +0 -1
- package/utils/indent.js +0 -5
- package/utils/indent.js.map +0 -1
- package/utils/sanitizeGraphqlName.d.ts +0 -1
- package/utils/sanitizeGraphqlName.js +0 -12
- package/utils/sanitizeGraphqlName.js.map +0 -1
- package/views/BaseComponent.d.ts +0 -20
- package/views/BaseComponent.jsx +0 -129
- package/views/BaseComponent.jsx.map +0 -1
- package/views/BaseContent.d.ts +0 -3
- package/views/BaseContent.jsx +0 -38
- package/views/BaseContent.jsx.map +0 -1
- package/views/BaseLayout.d.ts +0 -3
- package/views/BaseLayout.jsx +0 -24
- package/views/BaseLayout.jsx.map +0 -1
- package/views/BaseMacro.d.ts +0 -6
- package/views/BaseMacro.jsx +0 -100
- package/views/BaseMacro.jsx.map +0 -1
- package/views/BasePage.d.ts +0 -3
- package/views/BasePage.jsx +0 -34
- package/views/BasePage.jsx.map +0 -1
- package/views/BasePart.d.ts +0 -3
- package/views/BasePart.jsx +0 -24
- package/views/BasePart.jsx.map +0 -1
- package/views/Empty.d.ts +0 -2
- package/views/Empty.jsx +0 -4
- package/views/Empty.jsx.map +0 -1
- package/views/Fragment.d.ts +0 -3
- package/views/Fragment.jsx +0 -30
- package/views/Fragment.jsx.map +0 -1
- package/views/MainView.d.ts +0 -3
- package/views/MainView.jsx +0 -14
- package/views/MainView.jsx.map +0 -1
- package/views/PropsView.d.ts +0 -2
- package/views/PropsView.jsx +0 -21
- package/views/PropsView.jsx.map +0 -1
- package/views/Region.d.ts +0 -6
- package/views/Region.jsx +0 -52
- package/views/Region.jsx.map +0 -1
- package/views/RichTextView.d.ts +0 -3
- package/views/RichTextView.jsx +0 -39
- package/views/RichTextView.jsx.map +0 -1
- package/views/SingleComponent.d.ts +0 -4
- package/views/SingleComponent.jsx +0 -10
- package/views/SingleComponent.jsx.map +0 -1
- package/views/StaticContent.d.ts +0 -10
- package/views/StaticContent.jsx +0 -37
- package/views/StaticContent.jsx.map +0 -1
- package/views/Text.d.ts +0 -8
- package/views/Text.jsx +0 -4
- package/views/Text.jsx.map +0 -1
- package/views/macros/DefaultMacro.d.ts +0 -3
- package/views/macros/DefaultMacro.jsx +0 -4
- package/views/macros/DefaultMacro.jsx.map +0 -1
- package/views/macros/DisableMacro.d.ts +0 -3
- package/views/macros/DisableMacro.jsx +0 -3
- package/views/macros/DisableMacro.jsx.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-B1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
@@ -25,6 +25,23 @@
|
|
|
25
25
|
"utils",
|
|
26
26
|
"views"
|
|
27
27
|
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./views/*": {
|
|
35
|
+
"types": "./dist/views/*.d.ts",
|
|
36
|
+
"import": "./dist/views/*.jsx",
|
|
37
|
+
"require": "./dist/views/*.jsx"
|
|
38
|
+
},
|
|
39
|
+
"./*": {
|
|
40
|
+
"types": "./dist/*.d.ts",
|
|
41
|
+
"import": "./dist/*.js",
|
|
42
|
+
"require": "./dist/*.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
28
45
|
"keywords": [
|
|
29
46
|
"enonic",
|
|
30
47
|
"nextjs",
|
|
@@ -36,8 +53,8 @@
|
|
|
36
53
|
"access": "public"
|
|
37
54
|
},
|
|
38
55
|
"scripts": {
|
|
39
|
-
"clean": "del-cli *.d.ts *.js.map baseMappings.* client.* server.* common coverage index.* enonic-nextjs-adapter-*.tgz guillotine i18n query types utils views dist server client",
|
|
40
56
|
"build": "tsc",
|
|
57
|
+
"clean": "del-cli dist/ *.tgz",
|
|
41
58
|
"check:types": "tsc --noEmit",
|
|
42
59
|
"madge": "madge -i docs/madge.png -x '(constants|env)\\.ts' src/index.ts",
|
|
43
60
|
"lint": "eslint --quiet --cache src",
|
|
@@ -50,43 +67,45 @@
|
|
|
50
67
|
"test": "jest --no-cache --coverage"
|
|
51
68
|
},
|
|
52
69
|
"dependencies": {
|
|
53
|
-
"@enonic/react-components": "^
|
|
70
|
+
"@enonic/react-components": "^6.0.0-RC5",
|
|
54
71
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
55
72
|
"gqlmin": "^0.2.2",
|
|
56
|
-
"html-react-parser": "^5.2.5",
|
|
57
73
|
"negotiator": "^1.0.0",
|
|
58
|
-
"next": "^15.3.2",
|
|
59
|
-
"react": "18.3.1",
|
|
60
|
-
"react-dom": "18.3.1",
|
|
61
74
|
"unescape": "^1.0.1"
|
|
62
75
|
},
|
|
63
76
|
"devDependencies": {
|
|
64
|
-
"@babel/core": "^7.
|
|
65
|
-
"@babel/preset-env": "^7.
|
|
77
|
+
"@babel/core": "^7.28.0",
|
|
78
|
+
"@babel/preset-env": "^7.28.0",
|
|
66
79
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
67
|
-
"@enonic-types/core": "^7.15.
|
|
80
|
+
"@enonic-types/core": "^7.15.3",
|
|
68
81
|
"@enonic/eslint-config": "^2.0.1",
|
|
69
|
-
"@testing-library/jest-dom": "^6.6.
|
|
82
|
+
"@testing-library/jest-dom": "^6.6.4",
|
|
70
83
|
"@testing-library/react": "^16.3.0",
|
|
71
|
-
"@types/negotiator": "^0.6.
|
|
72
|
-
"@types/node": "^
|
|
84
|
+
"@types/negotiator": "^0.6.4",
|
|
85
|
+
"@types/node": "^24.2.1",
|
|
73
86
|
"@types/react": "^18.3.12",
|
|
74
87
|
"@types/react-dom": "^18.3.1",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
76
|
-
"@typescript-eslint/parser": "^8.
|
|
77
|
-
"babel-jest": "^
|
|
78
|
-
"concurrently": "^9.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
89
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
90
|
+
"babel-jest": "^30.0.5",
|
|
91
|
+
"concurrently": "^9.2.0",
|
|
79
92
|
"cpy-cli": "^5.0.0",
|
|
80
93
|
"del-cli": "^6.0.0",
|
|
81
|
-
"eslint": "^9.
|
|
94
|
+
"eslint": "^9.32.0",
|
|
82
95
|
"eslint-plugin-react": "^7.37.5",
|
|
83
|
-
"jest": "^
|
|
84
|
-
"jest-environment-jsdom": "^
|
|
96
|
+
"jest": "^30.0.5",
|
|
97
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
85
98
|
"madge": "^8.0.0",
|
|
86
99
|
"mkdirp": "^3.0.1",
|
|
87
|
-
"ts-jest": "^29.
|
|
100
|
+
"ts-jest": "^29.4.1",
|
|
88
101
|
"ts-node": "^10.9.2",
|
|
89
102
|
"typescript": "^5.8.3"
|
|
90
103
|
},
|
|
91
|
-
"types": "index.d.ts"
|
|
104
|
+
"types": "index.d.ts",
|
|
105
|
+
"peerDependencies": {
|
|
106
|
+
"html-react-parser": "^5.2.6",
|
|
107
|
+
"next": "^15.4.5",
|
|
108
|
+
"react": "^18.3.1",
|
|
109
|
+
"react-dom": "^18.3.1"
|
|
110
|
+
}
|
|
92
111
|
}
|
package/src/baseMappings.ts
CHANGED
|
@@ -13,41 +13,41 @@ import {getShortcutQuery} from './query/Shortcut';
|
|
|
13
13
|
// Base Content Types
|
|
14
14
|
|
|
15
15
|
ComponentRegistry.addContentType(FRAGMENT_CONTENTTYPE_NAME, {
|
|
16
|
-
view: FragmentView
|
|
16
|
+
view: FragmentView
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
ComponentRegistry.addContentType('base:shortcut', {
|
|
20
|
-
query: getShortcutQuery
|
|
20
|
+
query: getShortcutQuery
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Base Components
|
|
24
24
|
|
|
25
25
|
ComponentRegistry.addComponent(XP_COMPONENT_TYPE.PAGE, {
|
|
26
|
-
view: BasePage
|
|
26
|
+
view: BasePage
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
ComponentRegistry.addComponent(XP_COMPONENT_TYPE.PART, {
|
|
30
|
-
view: BasePart
|
|
30
|
+
view: BasePart
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
ComponentRegistry.addComponent(XP_COMPONENT_TYPE.LAYOUT, {
|
|
34
|
-
view: BaseLayout
|
|
34
|
+
view: BaseLayout
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
ComponentRegistry.addComponent(XP_COMPONENT_TYPE.FRAGMENT, {
|
|
38
|
-
view: FragmentView
|
|
38
|
+
view: FragmentView
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
ComponentRegistry.addComponent(XP_COMPONENT_TYPE.TEXT, {
|
|
42
|
-
view: TextView
|
|
42
|
+
view: TextView
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
// Macro mappings
|
|
46
46
|
ComponentRegistry.addMacro('system:embed', {
|
|
47
47
|
view: DefaultMacro,
|
|
48
|
-
configQuery: '{body}'
|
|
48
|
+
configQuery: '{body}'
|
|
49
49
|
});
|
|
50
50
|
ComponentRegistry.addMacro('system:disable', {
|
|
51
51
|
view: DisableMacro,
|
|
52
|
-
configQuery: '{body}'
|
|
52
|
+
configQuery: '{body}'
|
|
53
53
|
});
|
|
@@ -4,14 +4,11 @@ import type {
|
|
|
4
4
|
ComponentDictionary,
|
|
5
5
|
PageComponent,
|
|
6
6
|
SelectedQueryMaybeVariablesFunc,
|
|
7
|
-
SelectorName
|
|
7
|
+
SelectorName
|
|
8
8
|
} from '../types';
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
CATCH_ALL,
|
|
13
|
-
XP_COMPONENT_TYPE,
|
|
14
|
-
} from './constants';
|
|
11
|
+
import {CATCH_ALL, XP_COMPONENT_TYPE} from './constants';
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
function toSelectorName(type: XP_COMPONENT_TYPE): SelectorName | undefined {
|
package/src/common/constants.ts
CHANGED
|
@@ -4,7 +4,7 @@ export enum ENV_VARS {
|
|
|
4
4
|
MAPPINGS = 'ENONIC_MAPPINGS',
|
|
5
5
|
API_URL = 'ENONIC_API',
|
|
6
6
|
APP_NAME = 'ENONIC_APP_NAME',
|
|
7
|
-
LOG = 'ENONIC_LOGGING'
|
|
7
|
+
LOG = 'ENONIC_LOGGING'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const FRAGMENT_CONTENTTYPE_NAME = 'portal:fragment';
|
|
@@ -49,7 +49,7 @@ export enum GUILLOTINE_REQUEST_HEADERS {
|
|
|
49
49
|
COOKIE = 'Cookie',
|
|
50
50
|
LOCALE = 'locale',
|
|
51
51
|
LOCALES = 'locales',
|
|
52
|
-
DEFAULT_LOCALE = 'default-locale'
|
|
52
|
+
DEFAULT_LOCALE = 'default-locale'
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export const JSESSIONID_HEADER = 'jsessionid';
|
|
@@ -82,11 +82,11 @@ export enum XP_COMPONENT_TYPE {
|
|
|
82
82
|
LAYOUT = 'layout',
|
|
83
83
|
TEXT = 'text',
|
|
84
84
|
FRAGMENT = 'fragment',
|
|
85
|
-
PAGE = 'page'
|
|
85
|
+
PAGE = 'page'
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export enum XP_REQUEST_TYPE {
|
|
89
89
|
COMPONENT = 'component',
|
|
90
90
|
TYPE = 'type',
|
|
91
|
-
PAGE = 'page'
|
|
91
|
+
PAGE = 'page'
|
|
92
92
|
}
|
package/src/common/env.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const MAPPINGS = isServer ? process.env[ENV_VARS.MAPPINGS] : process.env[
|
|
|
28
28
|
const requiredConstants = {
|
|
29
29
|
[ENV_VARS.APP_NAME]: APP_NAME,
|
|
30
30
|
[ENV_VARS.API_URL]: API_URL,
|
|
31
|
-
[ENV_VARS.MAPPINGS]: MAPPINGS
|
|
31
|
+
[ENV_VARS.MAPPINGS]: MAPPINGS
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
// Verify required values on server-side only
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDescriptor,
|
|
3
|
-
ContentResult,
|
|
4
|
-
Context,
|
|
5
|
-
} from '../types';
|
|
1
|
+
import type {ComponentDescriptor, ContentResult, Context} from '../types';
|
|
6
2
|
|
|
7
3
|
|
|
8
4
|
import {getComponentConfig} from './getComponentConfig';
|
|
@@ -14,7 +10,7 @@ const NO_PROPS_PROCESSOR = async (props: any) => await props ?? {};
|
|
|
14
10
|
export async function applyProcessors(
|
|
15
11
|
componentDescriptors: ComponentDescriptor[],
|
|
16
12
|
contentResults: ContentResult,
|
|
17
|
-
context: Context
|
|
13
|
+
context: Context
|
|
18
14
|
): Promise < PromiseSettledResult < any > [] > {
|
|
19
15
|
|
|
20
16
|
let dataCounter = 0;
|
|
@@ -35,4 +31,4 @@ export async function applyProcessors(
|
|
|
35
31
|
});
|
|
36
32
|
|
|
37
33
|
return Promise.allSettled(processorPromises);
|
|
38
|
-
}
|
|
34
|
+
}
|
|
@@ -9,7 +9,7 @@ import {getParentRegion} from './getParentRegion';
|
|
|
9
9
|
export function buildComponentTree(
|
|
10
10
|
comps: PageComponent[],
|
|
11
11
|
rootComp: PageComponent,
|
|
12
|
-
contentType?: string
|
|
12
|
+
contentType?: string
|
|
13
13
|
): PageComponent {
|
|
14
14
|
const rootTree: RegionTree = {};
|
|
15
15
|
const isFragmentType = contentType === FRAGMENT_CONTENTTYPE_NAME;
|
|
@@ -12,7 +12,7 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
|
|
|
12
12
|
return {
|
|
13
13
|
error: {
|
|
14
14
|
code,
|
|
15
|
-
message
|
|
15
|
+
message
|
|
16
16
|
},
|
|
17
17
|
page: null,
|
|
18
18
|
common: null,
|
|
@@ -28,8 +28,8 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
|
|
|
28
28
|
apiUrl,
|
|
29
29
|
baseUrl,
|
|
30
30
|
locale,
|
|
31
|
-
defaultLocale
|
|
32
|
-
}
|
|
31
|
+
defaultLocale
|
|
32
|
+
}
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
}
|
|
@@ -8,8 +8,8 @@ import {buildComponentTree} from './buildComponentTree';
|
|
|
8
8
|
export function buildPage(contentType: string, comps: PageComponent[] = []): PageComponent {
|
|
9
9
|
const page: PageComponent = {
|
|
10
10
|
type: XP_COMPONENT_TYPE.PAGE,
|
|
11
|
-
path: '/'
|
|
11
|
+
path: '/'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
return buildComponentTree(comps, page, contentType);
|
|
15
|
-
}
|
|
15
|
+
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDescriptor,
|
|
3
|
-
Context,
|
|
4
|
-
PageComponent,
|
|
5
|
-
} from '../types';
|
|
1
|
+
import type {ComponentDescriptor, Context, PageComponent} from '../types';
|
|
6
2
|
|
|
7
3
|
|
|
8
4
|
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
9
5
|
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
10
|
-
import {
|
|
11
|
-
APP_NAME,
|
|
12
|
-
APP_NAME_DASHED,
|
|
13
|
-
} from '../common/env';
|
|
6
|
+
import {APP_NAME, APP_NAME_DASHED} from '../common/env';
|
|
14
7
|
import {processComponentConfig} from './processComponentConfig';
|
|
15
8
|
import {getComponentConfig} from './getComponentConfig';
|
|
16
9
|
import {getQueryAndVariables} from './getQueryAndVariables';
|
|
@@ -19,7 +12,7 @@ import {getQueryAndVariables} from './getQueryAndVariables';
|
|
|
19
12
|
export function collectComponentDescriptors({
|
|
20
13
|
components,
|
|
21
14
|
xpContentPath,
|
|
22
|
-
context
|
|
15
|
+
context
|
|
23
16
|
}: {
|
|
24
17
|
components: PageComponent[]
|
|
25
18
|
xpContentPath: string
|
|
@@ -42,7 +35,7 @@ export function collectComponentDescriptors({
|
|
|
42
35
|
descriptors.push({
|
|
43
36
|
component: cmp,
|
|
44
37
|
type: cmpDef,
|
|
45
|
-
queryAndVariables: queryAndVariables
|
|
38
|
+
queryAndVariables: queryAndVariables
|
|
46
39
|
});
|
|
47
40
|
}
|
|
48
41
|
}
|
|
@@ -51,7 +44,7 @@ export function collectComponentDescriptors({
|
|
|
51
44
|
const fragPartDescs = collectComponentDescriptors({
|
|
52
45
|
components: cmp.fragment?.fragment?.components,
|
|
53
46
|
xpContentPath,
|
|
54
|
-
context
|
|
47
|
+
context
|
|
55
48
|
});
|
|
56
49
|
if (fragPartDescs.length) {
|
|
57
50
|
descriptors.push(...fragPartDescs);
|
|
@@ -60,4 +53,4 @@ export function collectComponentDescriptors({
|
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
return descriptors;
|
|
63
|
-
}
|
|
56
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDescriptor,
|
|
3
|
-
QueryAndVariables,
|
|
4
|
-
} from '../types';
|
|
1
|
+
import type {ComponentDescriptor, QueryAndVariables} from '../types';
|
|
5
2
|
|
|
6
3
|
|
|
7
4
|
const ALIAS_PREFIX = 'request';
|
|
@@ -70,6 +67,6 @@ export function combineMultipleQueries(queriesWithVars: ComponentDescriptor[]):
|
|
|
70
67
|
|
|
71
68
|
return {
|
|
72
69
|
query: superQuery,
|
|
73
|
-
variables: superVars
|
|
70
|
+
variables: superVars
|
|
74
71
|
};
|
|
75
|
-
}
|
|
72
|
+
}
|
|
@@ -17,7 +17,7 @@ export function createMetaData({
|
|
|
17
17
|
pageCmp, // Optional
|
|
18
18
|
renderMode,
|
|
19
19
|
requestedComponentPath,
|
|
20
|
-
|
|
20
|
+
requestType
|
|
21
21
|
}: {
|
|
22
22
|
apiUrl: string
|
|
23
23
|
baseUrl: string
|
|
@@ -46,7 +46,7 @@ export function createMetaData({
|
|
|
46
46
|
path: contentPath,
|
|
47
47
|
renderMode: renderMode,
|
|
48
48
|
requestType: requestType,
|
|
49
|
-
type: contentType
|
|
49
|
+
type: contentType
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
if (requestedComponentPath) {
|
|
@@ -2,13 +2,7 @@ import type {ComponentDescriptor, Context, FetchContentResult} from '../types';
|
|
|
2
2
|
|
|
3
3
|
import {draftMode, headers} from 'next/headers';
|
|
4
4
|
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
5
|
-
import {
|
|
6
|
-
PAGE_TEMPLATE_CONTENTTYPE_NAME,
|
|
7
|
-
PAGE_TEMPLATE_FOLDER,
|
|
8
|
-
RENDER_MODE,
|
|
9
|
-
XP_COMPONENT_TYPE,
|
|
10
|
-
XP_REQUEST_TYPE,
|
|
11
|
-
} from '../common/constants';
|
|
5
|
+
import {PAGE_TEMPLATE_CONTENTTYPE_NAME, PAGE_TEMPLATE_FOLDER, RENDER_MODE, XP_COMPONENT_TYPE, XP_REQUEST_TYPE} from '../common/constants';
|
|
12
6
|
import {APP_NAME, APP_NAME_DASHED, IS_DEV_MODE} from '../common/env';
|
|
13
7
|
import {getContentApiUrl} from '../utils/getContentApiUrl';
|
|
14
8
|
import {getLocaleMapping} from '../utils/getLocaleMapping';
|
|
@@ -59,7 +53,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
59
53
|
context,
|
|
60
54
|
defaultLocale,
|
|
61
55
|
locale,
|
|
62
|
-
locales
|
|
56
|
+
locales
|
|
63
57
|
});
|
|
64
58
|
const xpBaseUrl = getXpBaseUrl(context);
|
|
65
59
|
const contentApiUrl = getContentApiUrl(context);
|
|
@@ -129,7 +123,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
129
123
|
if (contentQueryAndVars) {
|
|
130
124
|
allDescriptors.push({
|
|
131
125
|
type: contentTypeDef,
|
|
132
|
-
queryAndVariables: contentQueryAndVars
|
|
126
|
+
queryAndVariables: contentQueryAndVars
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
129
|
|
|
@@ -138,7 +132,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
138
132
|
if (commonQueryAndVars) {
|
|
139
133
|
allDescriptors.push({
|
|
140
134
|
type: contentTypeDef,
|
|
141
|
-
queryAndVariables: commonQueryAndVars
|
|
135
|
+
queryAndVariables: commonQueryAndVars
|
|
142
136
|
});
|
|
143
137
|
}
|
|
144
138
|
|
|
@@ -150,7 +144,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
150
144
|
const componentDescriptors = collectComponentDescriptors({
|
|
151
145
|
components,
|
|
152
146
|
xpContentPath: contentPath,
|
|
153
|
-
context
|
|
147
|
+
context
|
|
154
148
|
});
|
|
155
149
|
if (componentDescriptors.length) {
|
|
156
150
|
allDescriptors.push(...componentDescriptors);
|
|
@@ -219,14 +213,14 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
219
213
|
pageCmp: page,
|
|
220
214
|
renderMode,
|
|
221
215
|
requestedComponentPath: componentPath,
|
|
222
|
-
requestType
|
|
216
|
+
requestType
|
|
223
217
|
});
|
|
224
218
|
|
|
225
219
|
return {
|
|
226
220
|
data: contentData,
|
|
227
221
|
common,
|
|
228
222
|
meta,
|
|
229
|
-
page
|
|
223
|
+
page
|
|
230
224
|
};
|
|
231
225
|
} catch (e: any) {
|
|
232
226
|
console.error(e);
|
|
@@ -237,7 +231,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
237
231
|
} catch (e2) {
|
|
238
232
|
error = {
|
|
239
233
|
code: 'Local',
|
|
240
|
-
message: e.message
|
|
234
|
+
message: e.message
|
|
241
235
|
};
|
|
242
236
|
}
|
|
243
237
|
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ContentApiBaseBody,
|
|
3
|
-
ContentApiBaseBodyVariables,
|
|
4
|
-
ContentResult,
|
|
5
|
-
LocaleMapping,
|
|
6
|
-
GuillotineRequestHeaders,
|
|
7
|
-
} from '../types';
|
|
1
|
+
import type {ContentApiBaseBody, ContentApiBaseBodyVariables, ContentResult, LocaleMapping, GuillotineRequestHeaders} from '../types';
|
|
8
2
|
|
|
9
3
|
import {fetchGuillotine} from './fetchGuillotine';
|
|
10
4
|
|
|
@@ -15,7 +9,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
|
|
|
15
9
|
mapping: LocaleMapping,
|
|
16
10
|
query: string,
|
|
17
11
|
variables?: ContentApiBaseBodyVariables,
|
|
18
|
-
headers?: GuillotineRequestHeaders
|
|
12
|
+
headers?: GuillotineRequestHeaders
|
|
19
13
|
): Promise<ContentResult> => {
|
|
20
14
|
const body: ContentApiBaseBody = {query};
|
|
21
15
|
if (variables && Object.keys(variables).length > 0) {
|
|
@@ -23,7 +17,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
|
|
|
23
17
|
}
|
|
24
18
|
const contentResults = await fetchGuillotine<ContentResult<Content>>(contentApiUrl, mapping, {
|
|
25
19
|
body,
|
|
26
|
-
headers
|
|
20
|
+
headers
|
|
27
21
|
});
|
|
28
22
|
|
|
29
23
|
if (contentResults.error) {
|
|
@@ -31,7 +25,7 @@ export const fetchContentData = async <Content = Record<string, unknown>>(
|
|
|
31
25
|
} else {
|
|
32
26
|
return {
|
|
33
27
|
// omit the aliases and return values
|
|
34
|
-
contents: Object.values(contentResults)
|
|
28
|
+
contents: Object.values(contentResults)
|
|
35
29
|
};
|
|
36
30
|
}
|
|
37
31
|
};
|
|
@@ -8,12 +8,12 @@ import {fetchContentPathsForLocale} from './fetchContentPathsForLocale';
|
|
|
8
8
|
export async function fetchContentPathsForAllLocales(
|
|
9
9
|
path: string,
|
|
10
10
|
query: string = GET_STATIC_PATHS_QUERY,
|
|
11
|
-
countPerLocale = 999
|
|
11
|
+
countPerLocale = 999
|
|
12
12
|
): Promise<ContentPathItem[]> {
|
|
13
13
|
const promises = Object.values(getLocaleMappings()).map(
|
|
14
14
|
config => fetchContentPathsForLocale(
|
|
15
|
-
path, config, query, countPerLocale
|
|
16
|
-
)
|
|
15
|
+
path, config, query, countPerLocale
|
|
16
|
+
)
|
|
17
17
|
);
|
|
18
18
|
return Promise.all(promises).then(results => {
|
|
19
19
|
return results.reduce((all, localePaths) => all.concat(localePaths), []);
|
|
@@ -10,32 +10,32 @@ export async function fetchContentPathsForLocale(
|
|
|
10
10
|
path: string,
|
|
11
11
|
config: LocaleMapping,
|
|
12
12
|
query: string = GET_STATIC_PATHS_QUERY,
|
|
13
|
-
count = 999
|
|
13
|
+
count = 999
|
|
14
14
|
): Promise<ContentPathItem[]> {
|
|
15
15
|
const contentApiUrl = getContentApiUrl({
|
|
16
16
|
contentPath: path,
|
|
17
|
-
locale: config.locale
|
|
17
|
+
locale: config.locale
|
|
18
18
|
});
|
|
19
19
|
const body: ContentApiBaseBody = {
|
|
20
20
|
query,
|
|
21
21
|
variables: {
|
|
22
22
|
path,
|
|
23
23
|
pathRegex: `/content${config.site}/*`,
|
|
24
|
-
count
|
|
25
|
-
}
|
|
24
|
+
count
|
|
25
|
+
}
|
|
26
26
|
};
|
|
27
27
|
return fetchGuillotine<ContentPathItem[]>(contentApiUrl, config, {body}).then((
|
|
28
|
-
results: GuillotineResult
|
|
28
|
+
results: GuillotineResult
|
|
29
29
|
) => {
|
|
30
30
|
return results.guillotine.queryDsl.reduce((
|
|
31
31
|
prev: ContentPathItem[],
|
|
32
|
-
child: any
|
|
32
|
+
child: any
|
|
33
33
|
) => {
|
|
34
34
|
const regexp = new RegExp(`^/${child.site?._name ? `${child.site._name}/?` : ''}`);
|
|
35
35
|
const contentPath = child._path.replace(regexp, '');
|
|
36
36
|
prev.push({
|
|
37
37
|
contentPath: contentPath.split('/'),
|
|
38
|
-
locale: config.locale
|
|
38
|
+
locale: config.locale
|
|
39
39
|
});
|
|
40
40
|
return prev;
|
|
41
41
|
}, []);
|
|
@@ -4,7 +4,7 @@ import type {FetchOptions, GuillotineResponse, GuillotineResponseJson, LocaleMap
|
|
|
4
4
|
export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
5
5
|
apiUrl: string,
|
|
6
6
|
mapping: LocaleMapping,
|
|
7
|
-
options?: FetchOptions
|
|
7
|
+
options?: FetchOptions
|
|
8
8
|
): Promise<GuillotineResponseJson> {
|
|
9
9
|
|
|
10
10
|
const opts = {
|
|
@@ -12,7 +12,7 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
|
12
12
|
body: options?.body ? JSON.stringify(options?.body) : null,
|
|
13
13
|
headers: mergeHeaders(mapping, options?.headers),
|
|
14
14
|
next: options?.next,
|
|
15
|
-
cache: options?.cache
|
|
15
|
+
cache: options?.cache
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
let res: GuillotineResponse<Data>;
|
|
@@ -22,14 +22,14 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
|
22
22
|
console.warn(apiUrl, e);
|
|
23
23
|
throw new Error(JSON.stringify({
|
|
24
24
|
code: 'API',
|
|
25
|
-
message: e.message
|
|
25
|
+
message: e.message
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (!res.ok) {
|
|
30
30
|
throw new Error(JSON.stringify({
|
|
31
31
|
code: res.status,
|
|
32
|
-
message: `Data fetching failed (message: '${await res.text()}')
|
|
32
|
+
message: `Data fetching failed (message: '${await res.text()}')`
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -39,21 +39,21 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
|
39
39
|
} catch (e) {
|
|
40
40
|
throw new Error(JSON.stringify({
|
|
41
41
|
code: 500,
|
|
42
|
-
message: `API call completed but with non-JSON data: ${JSON.stringify(await res.text())}
|
|
42
|
+
message: `API call completed but with non-JSON data: ${JSON.stringify(await res.text())}`
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (!json) {
|
|
47
47
|
throw new Error(JSON.stringify({
|
|
48
48
|
code: 500,
|
|
49
|
-
message: `API call completed but with unexpectedly empty data: ${JSON.stringify(await res.text())}
|
|
49
|
+
message: `API call completed but with unexpectedly empty data: ${JSON.stringify(await res.text())}`
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (Array.isArray(json)) {
|
|
54
54
|
throw new Error(JSON.stringify({
|
|
55
55
|
code: 500,
|
|
56
|
-
message: `API call completed but with unexpected array data: ${JSON.stringify(json)}
|
|
56
|
+
message: `API call completed but with unexpected array data: ${JSON.stringify(json)}`
|
|
57
57
|
}));
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
|
63
63
|
function mergeHeaders(mapping: LocaleMapping, headers?: HeadersInit): Headers {
|
|
64
64
|
const newHeaders = new Headers({
|
|
65
65
|
'Accept': 'application/json',
|
|
66
|
-
'Content-Type': 'application/json'
|
|
66
|
+
'Content-Type': 'application/json'
|
|
67
67
|
});
|
|
68
68
|
if (headers) {
|
|
69
69
|
Object.keys(headers).forEach((headersKey) => {
|
|
@@ -9,7 +9,7 @@ const XP_ERROR_PATTERN = '/_/error/';
|
|
|
9
9
|
export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
10
10
|
contentApiUrl: string,
|
|
11
11
|
mapping: LocaleMapping,
|
|
12
|
-
options?: FetchOptions
|
|
12
|
+
options?: FetchOptions
|
|
13
13
|
): Promise<GuillotineResult> {
|
|
14
14
|
const body = options?.body;
|
|
15
15
|
const path = body?.variables?.path;
|
|
@@ -18,8 +18,8 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
18
18
|
return {
|
|
19
19
|
error: {
|
|
20
20
|
code: '400',
|
|
21
|
-
message: `Invalid or missing query. JSON.stringify(query) = ${JSON.stringify(body.query)}
|
|
22
|
-
}
|
|
21
|
+
message: `Invalid or missing query. JSON.stringify(query) = ${JSON.stringify(body.query)}`
|
|
22
|
+
}
|
|
23
23
|
};
|
|
24
24
|
} else {
|
|
25
25
|
// special case for not sending XP generated error paths to guillotine
|
|
@@ -28,8 +28,8 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
28
28
|
return {
|
|
29
29
|
error: {
|
|
30
30
|
code: pathArr[1],
|
|
31
|
-
message: `XP error URL detected
|
|
32
|
-
}
|
|
31
|
+
message: `XP error URL detected`
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
35
|
// Minify the query to avoid hitting 200k space limit
|
|
@@ -41,7 +41,7 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
41
41
|
return await fetchFromApi<Data>(
|
|
42
42
|
contentApiUrl,
|
|
43
43
|
mapping,
|
|
44
|
-
options
|
|
44
|
+
options
|
|
45
45
|
)
|
|
46
46
|
.then(json => {
|
|
47
47
|
let errors: any[] = json.errors; // fetchFromApi ensures json is an object
|
|
@@ -58,8 +58,8 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
58
58
|
return {
|
|
59
59
|
error: {
|
|
60
60
|
code: '500',
|
|
61
|
-
message: `Server responded with ${errors.length} error(s), probably from guillotine - see log
|
|
62
|
-
}
|
|
61
|
+
message: `Server responded with ${errors.length} error(s), probably from guillotine - see log.`
|
|
62
|
+
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|