@enonic/nextjs-adapter 3.3.0-B1 → 3.3.0
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/dist/baseMappings.d.ts +1 -0
- package/{src/baseMappings.ts → dist/baseMappings.js} +4 -14
- package/dist/baseMappings.js.map +1 -0
- package/dist/client/getClientHydratedHtml.d.ts +1 -0
- package/{src/client/getClientHydratedHtml.tsx → dist/client/getClientHydratedHtml.jsx} +3 -6
- package/dist/client/getClientHydratedHtml.jsx.map +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/common/ComponentRegistry.d.ts +34 -0
- package/dist/common/ComponentRegistry.js +121 -0
- package/dist/common/ComponentRegistry.js.map +1 -0
- package/dist/common/UrlProcessor.d.ts +25 -0
- package/{src/common/UrlProcessor.ts → dist/common/UrlProcessor.js} +49 -70
- package/dist/common/UrlProcessor.js.map +1 -0
- package/dist/common/constants.d.ts +51 -0
- package/{src/common/constants.ts → dist/common/constants.js} +38 -44
- package/dist/common/constants.js.map +1 -0
- package/dist/common/env.d.ts +12 -0
- package/{src/common/env.ts → dist/common/env.js} +3 -14
- package/dist/common/env.js.map +1 -0
- package/dist/guillotine/applyProcessors.d.ts +2 -0
- package/dist/guillotine/applyProcessors.js +33 -0
- package/dist/guillotine/applyProcessors.js.map +1 -0
- package/dist/guillotine/buildComponentTree.d.ts +2 -0
- package/{src/guillotine/buildComponentTree.ts → dist/guillotine/buildComponentTree.js} +13 -25
- package/dist/guillotine/buildComponentTree.js.map +1 -0
- package/dist/guillotine/buildErrorResponse.d.ts +3 -0
- package/{src/guillotine/buildErrorResponse.ts → dist/guillotine/buildErrorResponse.js} +2 -10
- package/dist/guillotine/buildErrorResponse.js.map +1 -0
- package/dist/guillotine/buildPage.d.ts +2 -0
- package/dist/guillotine/buildPage.js +10 -0
- package/dist/guillotine/buildPage.js.map +1 -0
- package/dist/guillotine/collectComponentDescriptors.d.ts +6 -0
- package/{src/guillotine/collectComponentDescriptors.ts → dist/guillotine/collectComponentDescriptors.js} +13 -26
- package/dist/guillotine/collectComponentDescriptors.js.map +1 -0
- package/dist/guillotine/combineMultipleQueries.d.ts +2 -0
- package/{src/guillotine/combineMultipleQueries.ts → dist/guillotine/combineMultipleQueries.js} +9 -23
- package/dist/guillotine/combineMultipleQueries.js.map +1 -0
- package/dist/guillotine/createMetaData.d.ts +18 -0
- package/dist/guillotine/createMetaData.js +45 -0
- package/dist/guillotine/createMetaData.js.map +1 -0
- package/dist/guillotine/fetchContent.d.ts +9 -0
- package/dist/guillotine/fetchContent.js +222 -0
- package/dist/guillotine/fetchContent.js.map +1 -0
- package/dist/guillotine/fetchContentData.d.ts +2 -0
- package/dist/guillotine/fetchContentData.js +30 -0
- package/dist/guillotine/fetchContentData.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.d.ts +2 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js +21 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForLocale.d.ts +2 -0
- package/dist/guillotine/fetchContentPathsForLocale.js +42 -0
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -0
- package/dist/guillotine/fetchFromApi.d.ts +3 -0
- package/dist/guillotine/fetchFromApi.js +76 -0
- package/dist/guillotine/fetchFromApi.js.map +1 -0
- package/dist/guillotine/fetchGuillotine.d.ts +3 -0
- package/dist/guillotine/fetchGuillotine.js +75 -0
- package/dist/guillotine/fetchGuillotine.js.map +1 -0
- package/dist/guillotine/fetchMetaData.d.ts +2 -0
- package/dist/guillotine/fetchMetaData.js +33 -0
- package/dist/guillotine/fetchMetaData.js.map +1 -0
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.d.ts +2 -0
- package/{src/guillotine/getCleanContentPathArrayOrThrow400.ts → dist/guillotine/getCleanContentPathArrayOrThrow400.js} +7 -9
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
- package/dist/guillotine/getComponentConfig.d.ts +2 -0
- package/{src/guillotine/getComponentConfig.ts → dist/guillotine/getComponentConfig.js} +3 -5
- package/dist/guillotine/getComponentConfig.js.map +1 -0
- package/dist/guillotine/getContentAndComponentPaths.d.ts +1 -0
- package/{src/guillotine/getContentAndComponentPaths.ts → dist/guillotine/getContentAndComponentPaths.js} +6 -5
- package/dist/guillotine/getContentAndComponentPaths.js.map +1 -0
- package/dist/guillotine/getMetaData.d.ts +2 -0
- package/{src/guillotine/getMetaData.ts → dist/guillotine/getMetaData.js} +11 -18
- package/dist/guillotine/getMetaData.js.map +1 -0
- package/dist/guillotine/getParentRegion.d.ts +2 -0
- package/{src/guillotine/getParentRegion.ts → dist/guillotine/getParentRegion.js} +9 -23
- package/dist/guillotine/getParentRegion.js.map +1 -0
- package/dist/guillotine/getQueryAndVariables.d.ts +2 -0
- package/{src/guillotine/getQueryAndVariables.ts → dist/guillotine/getQueryAndVariables.js} +7 -23
- package/dist/guillotine/getQueryAndVariables.js.map +1 -0
- package/dist/guillotine/metadata/configQuery.d.ts +2 -0
- package/dist/guillotine/metadata/configQuery.js +36 -0
- package/dist/guillotine/metadata/configQuery.js.map +1 -0
- package/dist/guillotine/metadata/richTextQuery.d.ts +1 -0
- package/{src/guillotine/metadata/richTextQuery.ts → dist/guillotine/metadata/richTextQuery.js} +6 -8
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -0
- package/dist/guillotine/parseComponentPath.d.ts +2 -0
- package/{src/guillotine/parseComponentPath.ts → dist/guillotine/parseComponentPath.js} +4 -8
- package/dist/guillotine/parseComponentPath.js.map +1 -0
- package/dist/guillotine/prefixFragmentCmpPath.d.ts +1 -0
- package/{src/guillotine/prefixFragmentCmpPath.ts → dist/guillotine/prefixFragmentCmpPath.js} +5 -5
- package/dist/guillotine/prefixFragmentCmpPath.js.map +1 -0
- package/dist/guillotine/processComponentConfig.d.ts +2 -0
- package/{src/guillotine/processComponentConfig.ts → dist/guillotine/processComponentConfig.js} +4 -12
- package/dist/guillotine/processComponentConfig.js.map +1 -0
- package/dist/guillotine/restrictComponentsToPath.d.ts +2 -0
- package/{src/guillotine/restrictComponentsToPath.ts → dist/guillotine/restrictComponentsToPath.js} +9 -19
- package/dist/guillotine/restrictComponentsToPath.js.map +1 -0
- package/dist/guillotine/validateData.d.ts +2 -0
- package/dist/guillotine/validateData.js +7 -0
- package/dist/guillotine/validateData.js.map +1 -0
- package/dist/guillotine/validateNotFound.d.ts +2 -0
- package/{src/guillotine/validateNotFound.ts → dist/guillotine/validateNotFound.js} +5 -9
- package/dist/guillotine/validateNotFound.js.map +1 -0
- package/dist/guillotine/validateShortcut.d.ts +2 -0
- package/{src/guillotine/validateShortcut.ts → dist/guillotine/validateShortcut.js} +12 -20
- package/dist/guillotine/validateShortcut.js.map +1 -0
- package/dist/i18n/LocaleContext.d.ts +7 -0
- package/dist/i18n/LocaleContext.jsx +50 -0
- package/dist/i18n/LocaleContext.jsx.map +1 -0
- package/dist/i18n/i18n.d.ts +12 -0
- package/dist/i18n/i18n.js +59 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/query/Shortcut.d.ts +1 -0
- package/{src/query/Shortcut.ts → dist/query/Shortcut.js} +1 -0
- package/dist/query/Shortcut.js.map +1 -0
- package/dist/server/getServerRenderedHtml.d.ts +1 -0
- package/dist/server/getServerRenderedHtml.js +4 -0
- package/dist/server/getServerRenderedHtml.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -0
- package/{src/types/component.ts → dist/types/component.d.ts} +23 -62
- package/dist/types/component.js +2 -0
- package/dist/types/component.js.map +1 -0
- package/dist/types/componentProps.d.ts +107 -0
- package/dist/types/componentProps.js +2 -0
- package/dist/types/componentProps.js.map +1 -0
- package/dist/types/guillotine.d.ts +344 -0
- package/dist/types/guillotine.js +2 -0
- package/dist/types/guillotine.js.map +1 -0
- package/dist/types/i18n.d.ts +7 -0
- package/dist/types/i18n.js +2 -0
- package/dist/types/i18n.js.map +1 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +19 -34
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/next.d.ts +6 -0
- package/dist/types/next.js +2 -0
- package/dist/types/next.js.map +1 -0
- package/dist/types/util.d.ts +3 -0
- package/dist/types/util.js +3 -0
- package/dist/types/util.js.map +1 -0
- package/dist/utils/addLineNumbers.d.ts +1 -0
- package/dist/utils/addLineNumbers.js +4 -0
- package/dist/utils/addLineNumbers.js.map +1 -0
- package/dist/utils/buildGuillotineRequestHeaders.d.ts +7 -0
- package/dist/utils/buildGuillotineRequestHeaders.js +16 -0
- package/dist/utils/buildGuillotineRequestHeaders.js.map +1 -0
- package/dist/utils/commonChars.d.ts +1 -0
- package/{src/utils/commonChars.ts → dist/utils/commonChars.js} +5 -4
- package/dist/utils/commonChars.js.map +1 -0
- package/dist/utils/enonicLog.d.ts +5 -0
- package/dist/utils/enonicLog.js +23 -0
- package/dist/utils/enonicLog.js.map +1 -0
- package/dist/utils/fixDoubleSlashes.d.ts +1 -0
- package/dist/utils/fixDoubleSlashes.js +4 -0
- package/dist/utils/fixDoubleSlashes.js.map +1 -0
- package/dist/utils/getAllLocales.d.ts +1 -0
- package/dist/utils/getAllLocales.js +5 -0
- package/dist/utils/getAllLocales.js.map +1 -0
- package/dist/utils/getContentApiUrl.d.ts +2 -0
- package/dist/utils/getContentApiUrl.js +15 -0
- package/dist/utils/getContentApiUrl.js.map +1 -0
- package/dist/utils/getLocaleMapping.d.ts +2 -0
- package/dist/utils/getLocaleMapping.js +19 -0
- package/dist/utils/getLocaleMapping.js.map +1 -0
- package/dist/utils/getLocaleMappingByLocale.d.ts +2 -0
- package/dist/utils/getLocaleMappingByLocale.js +13 -0
- package/dist/utils/getLocaleMappingByLocale.js.map +1 -0
- package/dist/utils/getLocaleMappingByProjectId.d.ts +2 -0
- package/dist/utils/getLocaleMappingByProjectId.js +16 -0
- package/dist/utils/getLocaleMappingByProjectId.js.map +1 -0
- package/dist/utils/getLocaleMappings.d.ts +2 -0
- package/{src/utils/getLocaleMappings.ts → dist/utils/getLocaleMappings.js} +8 -14
- package/dist/utils/getLocaleMappings.js.map +1 -0
- package/dist/utils/getRenderMode.d.ts +3 -0
- package/dist/utils/getRenderMode.js +8 -0
- package/dist/utils/getRenderMode.js.map +1 -0
- package/dist/utils/getRequestLocaleInfo.d.ts +6 -0
- package/{src/utils/getRequestLocaleInfo.ts → dist/utils/getRequestLocaleInfo.js} +12 -13
- package/dist/utils/getRequestLocaleInfo.js.map +1 -0
- package/dist/utils/getXpBaseUrl.d.ts +2 -0
- package/dist/utils/getXpBaseUrl.js +8 -0
- package/dist/utils/getXpBaseUrl.js.map +1 -0
- package/dist/utils/indent.d.ts +1 -0
- package/dist/utils/indent.js +5 -0
- package/dist/utils/indent.js.map +1 -0
- package/dist/utils/sanitizeGraphqlName.d.ts +1 -0
- package/{src/utils/sanitizeGraphqlName.ts → dist/utils/sanitizeGraphqlName.js} +3 -2
- package/dist/utils/sanitizeGraphqlName.js.map +1 -0
- package/dist/views/BaseComponent.d.ts +20 -0
- package/{src/views/BaseComponent.tsx → dist/views/BaseComponent.jsx} +49 -76
- package/dist/views/BaseComponent.jsx.map +1 -0
- package/dist/views/BaseContent.d.ts +3 -0
- package/dist/views/BaseContent.jsx +38 -0
- package/dist/views/BaseContent.jsx.map +1 -0
- package/dist/views/BaseLayout.d.ts +3 -0
- package/dist/views/BaseLayout.jsx +24 -0
- package/dist/views/BaseLayout.jsx.map +1 -0
- package/dist/views/BaseMacro.d.ts +6 -0
- package/{src/views/BaseMacro.tsx → dist/views/BaseMacro.jsx} +37 -42
- package/dist/views/BaseMacro.jsx.map +1 -0
- package/dist/views/BasePage.d.ts +3 -0
- package/dist/views/BasePage.jsx +34 -0
- package/dist/views/BasePage.jsx.map +1 -0
- package/dist/views/BasePart.d.ts +3 -0
- package/dist/views/BasePart.jsx +24 -0
- package/dist/views/BasePart.jsx.map +1 -0
- package/dist/views/Empty.d.ts +2 -0
- package/{src/views/Empty.tsx → dist/views/Empty.jsx} +1 -2
- package/dist/views/Empty.jsx.map +1 -0
- package/dist/views/Fragment.d.ts +3 -0
- package/dist/views/Fragment.jsx +30 -0
- package/dist/views/Fragment.jsx.map +1 -0
- package/dist/views/MainView.d.ts +3 -0
- package/dist/views/MainView.jsx +14 -0
- package/dist/views/MainView.jsx.map +1 -0
- package/dist/views/PropsView.d.ts +2 -0
- package/dist/views/PropsView.jsx +21 -0
- package/dist/views/PropsView.jsx.map +1 -0
- package/dist/views/Region.d.ts +6 -0
- package/{src/views/Region.tsx → dist/views/Region.jsx} +17 -41
- package/dist/views/Region.jsx.map +1 -0
- package/dist/views/RichTextView.d.ts +3 -0
- package/dist/views/RichTextView.jsx +65 -0
- package/dist/views/RichTextView.jsx.map +1 -0
- package/dist/views/SingleComponent.d.ts +4 -0
- package/dist/views/SingleComponent.jsx +10 -0
- package/dist/views/SingleComponent.jsx.map +1 -0
- package/dist/views/StaticContent.d.ts +10 -0
- package/dist/views/StaticContent.jsx +37 -0
- package/dist/views/StaticContent.jsx.map +1 -0
- package/dist/views/Text.d.ts +8 -0
- package/dist/views/Text.jsx +4 -0
- package/dist/views/Text.jsx.map +1 -0
- package/dist/views/macros/DefaultMacro.d.ts +3 -0
- package/dist/views/macros/DefaultMacro.jsx +4 -0
- package/dist/views/macros/DefaultMacro.jsx.map +1 -0
- package/dist/views/macros/DisableMacro.d.ts +3 -0
- package/dist/views/macros/DisableMacro.jsx +3 -0
- package/dist/views/macros/DisableMacro.jsx.map +1 -0
- package/package.json +20 -32
- package/src/client.ts +0 -2
- package/src/common/ComponentRegistry.ts +0 -159
- package/src/guillotine/applyProcessors.ts +0 -34
- package/src/guillotine/buildPage.ts +0 -15
- package/src/guillotine/createMetaData.ts +0 -72
- package/src/guillotine/fetchContent.ts +0 -240
- package/src/guillotine/fetchContentData.ts +0 -31
- package/src/guillotine/fetchContentPathsForAllLocales.ts +0 -21
- package/src/guillotine/fetchContentPathsForLocale.ts +0 -43
- package/src/guillotine/fetchFromApi.ts +0 -76
- package/src/guillotine/fetchGuillotine.ts +0 -76
- package/src/guillotine/fetchMetaData.ts +0 -31
- package/src/guillotine/metadata/configQuery.ts +0 -46
- package/src/guillotine/validateData.ts +0 -11
- package/src/i18n/LocaleContext.tsx +0 -59
- package/src/i18n/i18n.ts +0 -57
- package/src/index.ts +0 -42
- package/src/server/getServerRenderedHtml.ts +0 -3
- package/src/server.ts +0 -5
- package/src/types/componentProps.ts +0 -143
- package/src/types/guillotine.ts +0 -428
- package/src/types/i18n.ts +0 -8
- package/src/types/next.ts +0 -7
- package/src/types/util.ts +0 -5
- package/src/utils/addLineNumbers.ts +0 -3
- package/src/utils/buildGuillotineRequestHeaders.ts +0 -29
- package/src/utils/enonicLog.ts +0 -28
- package/src/utils/fixDoubleSlashes.ts +0 -3
- package/src/utils/getAllLocales.ts +0 -6
- package/src/utils/getContentApiUrl.ts +0 -20
- package/src/utils/getLocaleMapping.ts +0 -24
- package/src/utils/getLocaleMappingByLocale.ts +0 -19
- package/src/utils/getLocaleMappingByProjectId.ts +0 -21
- package/src/utils/getRenderMode.ts +0 -11
- package/src/utils/getXpBaseUrl.ts +0 -12
- package/src/utils/indent.ts +0 -4
- package/src/views/BaseContent.tsx +0 -47
- package/src/views/BaseLayout.tsx +0 -33
- package/src/views/BasePage.tsx +0 -42
- package/src/views/BasePart.tsx +0 -34
- package/src/views/Fragment.tsx +0 -41
- package/src/views/MainView.tsx +0 -22
- package/src/views/PropsView.tsx +0 -38
- package/src/views/RichTextView.tsx +0 -106
- package/src/views/SingleComponent.tsx +0 -19
- package/src/views/StaticContent.tsx +0 -39
- package/src/views/Text.tsx +0 -19
- package/src/views/macros/DefaultMacro.tsx +0 -9
- package/src/views/macros/DisableMacro.tsx +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.jsx","sourceRoot":"","sources":["../../src/views/Text.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAU1C,MAAM,eAAe,GAAG,CAAC,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAQ,EAAE,EAAE,CAAC,CACxD,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,EAAE,CACnF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DefaultMacro.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,YAAY,GAAG,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAa,EAAE,EAAE,CACtD,eAAe,CAAC,MAAM,CAAC,IAAI,CAC9B,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisableMacro.jsx","sourceRoot":"","sources":["../../../src/views/macros/DisableMacro.tsx"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAG,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAa,EAAE,EAAE,CAAC,CACvD,MAAM,CAAC,IAAI,CACd,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "3.3.0
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
7
7
|
"contributors": [
|
|
8
8
|
"Christian Westgaard <cwe@enonic.com>"
|
|
9
9
|
],
|
|
10
10
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"server.js",
|
|
16
|
-
"common",
|
|
17
|
-
"client",
|
|
18
|
-
"server",
|
|
19
|
-
"guillotine",
|
|
20
|
-
"index*",
|
|
21
|
-
"i18n",
|
|
22
|
-
"query",
|
|
23
|
-
"src",
|
|
24
|
-
"types",
|
|
25
|
-
"utils",
|
|
26
|
-
"views"
|
|
11
|
+
"dist",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"package.json",
|
|
14
|
+
"README.md"
|
|
27
15
|
],
|
|
28
16
|
"exports": {
|
|
29
17
|
".": {
|
|
@@ -54,7 +42,7 @@
|
|
|
54
42
|
},
|
|
55
43
|
"scripts": {
|
|
56
44
|
"build": "tsc",
|
|
57
|
-
"clean": "del-cli dist/
|
|
45
|
+
"clean": "del-cli dist/ enonic-nextjs-adapter-*.tgz",
|
|
58
46
|
"check:types": "tsc --noEmit",
|
|
59
47
|
"madge": "madge -i docs/madge.png -x '(constants|env)\\.ts' src/index.ts",
|
|
60
48
|
"lint": "eslint --quiet --cache src",
|
|
@@ -67,31 +55,31 @@
|
|
|
67
55
|
"test": "jest --no-cache --coverage"
|
|
68
56
|
},
|
|
69
57
|
"dependencies": {
|
|
70
|
-
"@enonic/react-components": "^6.0.0
|
|
58
|
+
"@enonic/react-components": "^6.0.0",
|
|
71
59
|
"@formatjs/intl-localematcher": "^0.6.1",
|
|
72
|
-
"gqlmin": "^0.
|
|
60
|
+
"gqlmin": "^0.3.1",
|
|
73
61
|
"negotiator": "^1.0.0",
|
|
74
62
|
"unescape": "^1.0.1"
|
|
75
63
|
},
|
|
76
64
|
"devDependencies": {
|
|
77
|
-
"@babel/core": "^7.28.
|
|
78
|
-
"@babel/preset-env": "^7.28.
|
|
65
|
+
"@babel/core": "^7.28.3",
|
|
66
|
+
"@babel/preset-env": "^7.28.3",
|
|
79
67
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
80
68
|
"@enonic-types/core": "^7.15.3",
|
|
81
|
-
"@enonic/eslint-config": "^2.0
|
|
82
|
-
"@testing-library/jest-dom": "^6.
|
|
69
|
+
"@enonic/eslint-config": "^2.1.0",
|
|
70
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
83
71
|
"@testing-library/react": "^16.3.0",
|
|
84
72
|
"@types/negotiator": "^0.6.4",
|
|
85
|
-
"@types/node": "^24.
|
|
73
|
+
"@types/node": "^24.3.0",
|
|
86
74
|
"@types/react": "^18.3.12",
|
|
87
75
|
"@types/react-dom": "^18.3.1",
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
89
|
-
"@typescript-eslint/parser": "^8.
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
77
|
+
"@typescript-eslint/parser": "^8.40.0",
|
|
90
78
|
"babel-jest": "^30.0.5",
|
|
91
79
|
"concurrently": "^9.2.0",
|
|
92
|
-
"cpy-cli": "^
|
|
80
|
+
"cpy-cli": "^6.0.0",
|
|
93
81
|
"del-cli": "^6.0.0",
|
|
94
|
-
"eslint": "^9.
|
|
82
|
+
"eslint": "^9.34.0",
|
|
95
83
|
"eslint-plugin-react": "^7.37.5",
|
|
96
84
|
"jest": "^30.0.5",
|
|
97
85
|
"jest-environment-jsdom": "^30.0.5",
|
|
@@ -99,12 +87,12 @@
|
|
|
99
87
|
"mkdirp": "^3.0.1",
|
|
100
88
|
"ts-jest": "^29.4.1",
|
|
101
89
|
"ts-node": "^10.9.2",
|
|
102
|
-
"typescript": "^5.
|
|
90
|
+
"typescript": "^5.9.2"
|
|
103
91
|
},
|
|
104
92
|
"types": "index.d.ts",
|
|
105
93
|
"peerDependencies": {
|
|
106
94
|
"html-react-parser": "^5.2.6",
|
|
107
|
-
"next": "^
|
|
95
|
+
"next": "^14.2.32",
|
|
108
96
|
"react": "^18.3.1",
|
|
109
97
|
"react-dom": "^18.3.1"
|
|
110
98
|
}
|
package/src/client.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDefinition,
|
|
3
|
-
ComponentDefinitionParams,
|
|
4
|
-
ComponentDictionary,
|
|
5
|
-
PageComponent,
|
|
6
|
-
SelectedQueryMaybeVariablesFunc,
|
|
7
|
-
SelectorName
|
|
8
|
-
} from '../types';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {CATCH_ALL, XP_COMPONENT_TYPE} from './constants';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function toSelectorName(type: XP_COMPONENT_TYPE): SelectorName | undefined {
|
|
15
|
-
switch (type) {
|
|
16
|
-
case XP_COMPONENT_TYPE.PAGE:
|
|
17
|
-
return 'page';
|
|
18
|
-
case XP_COMPONENT_TYPE.LAYOUT:
|
|
19
|
-
return 'layout';
|
|
20
|
-
case XP_COMPONENT_TYPE.PART:
|
|
21
|
-
return 'part';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export class ComponentRegistry {
|
|
27
|
-
|
|
28
|
-
private static contentTypes: ComponentDictionary = {};
|
|
29
|
-
private static pages: ComponentDictionary = {};
|
|
30
|
-
private static components: ComponentDictionary = {};
|
|
31
|
-
private static parts: ComponentDictionary = {};
|
|
32
|
-
private static layouts: ComponentDictionary = {};
|
|
33
|
-
private static macros: ComponentDictionary = {};
|
|
34
|
-
private static commonQuery: SelectedQueryMaybeVariablesFunc;
|
|
35
|
-
|
|
36
|
-
public static addComponent(name: string, obj: ComponentDefinitionParams): void {
|
|
37
|
-
return ComponentRegistry.addType('component', name, obj);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public static addContentType(name: string, obj: ComponentDefinitionParams): void {
|
|
41
|
-
return ComponentRegistry.addType('contentType', name, obj);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public static addMacro(name: string, obj: ComponentDefinitionParams): void {
|
|
45
|
-
return ComponentRegistry.addType('macro', name, obj);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public static addLayout(name: string, obj: ComponentDefinitionParams): void {
|
|
49
|
-
return ComponentRegistry.addType('layout', name, obj);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public static addPage(name: string, obj: ComponentDefinitionParams): void {
|
|
53
|
-
return ComponentRegistry.addType('page', name, obj);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public static addPart(name: string, obj: ComponentDefinitionParams): void {
|
|
57
|
-
return ComponentRegistry.addType('part', name, obj);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private static addType(selectorName: SelectorName, name: string, obj: ComponentDefinitionParams): void {
|
|
61
|
-
const selector = ComponentRegistry.getSelector(selectorName);
|
|
62
|
-
const curr = selector[name];
|
|
63
|
-
selector[name] = curr ? Object.assign(curr, obj) : obj;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private static getSelector(name: SelectorName): ComponentDictionary {
|
|
67
|
-
switch (name) {
|
|
68
|
-
case 'contentType':
|
|
69
|
-
return this.contentTypes;
|
|
70
|
-
case 'page':
|
|
71
|
-
return this.pages;
|
|
72
|
-
case 'component':
|
|
73
|
-
return this.components;
|
|
74
|
-
case 'layout':
|
|
75
|
-
return this.layouts;
|
|
76
|
-
case 'part':
|
|
77
|
-
return this.parts;
|
|
78
|
-
case 'macro':
|
|
79
|
-
return this.macros;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private static getType(selectorName: SelectorName, typeName: string, useCatchAll = true): ComponentDefinition | undefined {
|
|
84
|
-
const selector = ComponentRegistry.getSelector(selectorName);
|
|
85
|
-
let type: ComponentDefinition|undefined = selector[typeName];
|
|
86
|
-
if (type) {
|
|
87
|
-
type.catchAll = typeName === CATCH_ALL;
|
|
88
|
-
} else if (!type && useCatchAll) {
|
|
89
|
-
type = selector[CATCH_ALL];
|
|
90
|
-
if (type) {
|
|
91
|
-
type.catchAll = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return type;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public static getByComponent(component: PageComponent): ComponentDefinition | undefined {
|
|
98
|
-
const selName = toSelectorName(component.type);
|
|
99
|
-
const cmpData = component[component.type];
|
|
100
|
-
const desc = cmpData && 'descriptor' in cmpData ? cmpData.descriptor : component.path;
|
|
101
|
-
return selName && desc ? this.getType(selName, desc) : undefined;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public static setCommonQuery(query: SelectedQueryMaybeVariablesFunc): void {
|
|
105
|
-
this.commonQuery = query;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public static getCommonQuery(): SelectedQueryMaybeVariablesFunc {
|
|
109
|
-
return this.commonQuery;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public static getMacro(name: string): ComponentDefinition | undefined {
|
|
113
|
-
return ComponentRegistry.getType('macro', name);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public static getMacros(): [string, ComponentDefinition][] {
|
|
117
|
-
return Object.entries(this.macros);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public static getParts(): [string, ComponentDefinition][] {
|
|
121
|
-
return Object.entries(this.parts);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public static getLayouts(): [string, ComponentDefinition][] {
|
|
125
|
-
return Object.entries(this.layouts);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public static getPages(): [string, ComponentDefinition][] {
|
|
129
|
-
return Object.entries(this.pages);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public static getContentTypes(): [string, ComponentDefinition][] {
|
|
133
|
-
return Object.entries(this.contentTypes);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public static getComponents(): [string, ComponentDefinition][] {
|
|
137
|
-
return Object.entries(this.components);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public static getContentType(name: string): ComponentDefinition | undefined {
|
|
141
|
-
return ComponentRegistry.getType('contentType', name);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public static getPage(name: string): ComponentDefinition | undefined {
|
|
145
|
-
return ComponentRegistry.getType('page', name);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public static getPart(name: string): ComponentDefinition | undefined {
|
|
149
|
-
return ComponentRegistry.getType('part', name);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public static getLayout(name: string): ComponentDefinition | undefined {
|
|
153
|
-
return ComponentRegistry.getType('layout', name);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public static getComponent(name: string): ComponentDefinition | undefined {
|
|
157
|
-
return ComponentRegistry.getType('component', name);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {ComponentDescriptor, ContentResult, Context} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {getComponentConfig} from './getComponentConfig';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const NO_PROPS_PROCESSOR = async (props: any) => await props ?? {};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export async function applyProcessors(
|
|
11
|
-
componentDescriptors: ComponentDescriptor[],
|
|
12
|
-
contentResults: ContentResult,
|
|
13
|
-
context: Context
|
|
14
|
-
): Promise < PromiseSettledResult < any > [] > {
|
|
15
|
-
|
|
16
|
-
let dataCounter = 0;
|
|
17
|
-
const processorPromises = componentDescriptors.map(async (desc: ComponentDescriptor) => {
|
|
18
|
-
// we're iterating component descriptors here
|
|
19
|
-
// some of them might not have provided graphql requests
|
|
20
|
-
// but we still need to run props processor for them
|
|
21
|
-
// in case they want to fetch their data from elsewhere
|
|
22
|
-
const propsProcessor = desc.type?.processor || NO_PROPS_PROCESSOR;
|
|
23
|
-
let data;
|
|
24
|
-
if (desc.queryAndVariables) {
|
|
25
|
-
// if there is a query then there must be a result for it
|
|
26
|
-
data = contentResults.contents[dataCounter++];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const config = getComponentConfig(desc.component);
|
|
30
|
-
return await propsProcessor(data, context, config);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return Promise.allSettled(processorPromises);
|
|
34
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type {PageComponent} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
5
|
-
import {buildComponentTree} from './buildComponentTree';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function buildPage(contentType: string, comps: PageComponent[] = []): PageComponent {
|
|
9
|
-
const page: PageComponent = {
|
|
10
|
-
type: XP_COMPONENT_TYPE.PAGE,
|
|
11
|
-
path: '/'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return buildComponentTree(comps, page, contentType);
|
|
15
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type {MetaData, PageComponent} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {RENDER_MODE, XP_REQUEST_TYPE} from '../common/constants';
|
|
5
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function createMetaData({
|
|
9
|
-
apiUrl,
|
|
10
|
-
baseUrl,
|
|
11
|
-
components = [], // Optional NOTE: Doesn't handle null
|
|
12
|
-
contentPath,
|
|
13
|
-
contentType,
|
|
14
|
-
contentId,
|
|
15
|
-
defaultLocale,
|
|
16
|
-
locale,
|
|
17
|
-
pageCmp, // Optional
|
|
18
|
-
renderMode,
|
|
19
|
-
requestedComponentPath,
|
|
20
|
-
requestType
|
|
21
|
-
}: {
|
|
22
|
-
apiUrl: string
|
|
23
|
-
baseUrl: string
|
|
24
|
-
components?: PageComponent[]
|
|
25
|
-
contentPath: string
|
|
26
|
-
contentId: string
|
|
27
|
-
contentType: string
|
|
28
|
-
defaultLocale: string
|
|
29
|
-
locale: string
|
|
30
|
-
pageCmp?: PageComponent
|
|
31
|
-
renderMode: RENDER_MODE
|
|
32
|
-
requestedComponentPath: string | undefined
|
|
33
|
-
requestType: XP_REQUEST_TYPE
|
|
34
|
-
}): MetaData {
|
|
35
|
-
// .meta will be visible in final rendered inline props.
|
|
36
|
-
// Only adding some .meta attributes here on certain conditions
|
|
37
|
-
// (instead of always adding them and letting them be visible as false/undefined etc)
|
|
38
|
-
const meta: MetaData = {
|
|
39
|
-
apiUrl,
|
|
40
|
-
baseUrl,
|
|
41
|
-
canRender: false,
|
|
42
|
-
catchAll: false, // catchAll only refers to content type catch-all
|
|
43
|
-
defaultLocale,
|
|
44
|
-
locale,
|
|
45
|
-
id: contentId,
|
|
46
|
-
path: contentPath,
|
|
47
|
-
renderMode: renderMode,
|
|
48
|
-
requestType: requestType,
|
|
49
|
-
type: contentType
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
if (requestedComponentPath) {
|
|
53
|
-
meta.requestedComponent = components.find(cmp => cmp.path === requestedComponentPath);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const pageDesc = pageCmp?.page?.descriptor;
|
|
57
|
-
const typeDef = ComponentRegistry.getContentType(contentType);
|
|
58
|
-
if (typeDef?.view && !typeDef.catchAll) {
|
|
59
|
-
meta.canRender = true;
|
|
60
|
-
} else if (requestType === XP_REQUEST_TYPE.COMPONENT) {
|
|
61
|
-
// always render a single component (show missing if not implemented)
|
|
62
|
-
meta.canRender = true;
|
|
63
|
-
} else if (pageDesc) {
|
|
64
|
-
// always render a page if there is a descriptor (show missing if not implemented)
|
|
65
|
-
meta.canRender = true;
|
|
66
|
-
} else if (typeDef?.view) {
|
|
67
|
-
meta.canRender = true;
|
|
68
|
-
meta.catchAll = true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return meta;
|
|
72
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import type {ComponentDescriptor, Context, FetchContentResult} from '../types';
|
|
2
|
-
|
|
3
|
-
import {draftMode, headers} from 'next/headers';
|
|
4
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
5
|
-
import {PAGE_TEMPLATE_CONTENTTYPE_NAME, PAGE_TEMPLATE_FOLDER, RENDER_MODE, XP_COMPONENT_TYPE, XP_REQUEST_TYPE} from '../common/constants';
|
|
6
|
-
import {APP_NAME, APP_NAME_DASHED, IS_DEV_MODE} from '../common/env';
|
|
7
|
-
import {getContentApiUrl} from '../utils/getContentApiUrl';
|
|
8
|
-
import {getLocaleMapping} from '../utils/getLocaleMapping';
|
|
9
|
-
import {getRenderMode} from '../utils/getRenderMode';
|
|
10
|
-
import {getXpBaseUrl} from '../utils/getXpBaseUrl';
|
|
11
|
-
import {getRequestLocaleInfo} from '../utils/getRequestLocaleInfo';
|
|
12
|
-
import {buildGuillotineRequestHeaders} from '../utils/buildGuillotineRequestHeaders';
|
|
13
|
-
|
|
14
|
-
import {buildPage} from './buildPage';
|
|
15
|
-
import {fetchMetaData} from './fetchMetaData';
|
|
16
|
-
import {getCleanContentPathArrayOrThrow400} from './getCleanContentPathArrayOrThrow400';
|
|
17
|
-
import {buildErrorResponse} from './buildErrorResponse';
|
|
18
|
-
import {getContentAndComponentPaths} from './getContentAndComponentPaths';
|
|
19
|
-
import {restrictComponentsToPath} from './restrictComponentsToPath';
|
|
20
|
-
import {processComponentConfig} from './processComponentConfig';
|
|
21
|
-
import {getQueryAndVariables} from './getQueryAndVariables';
|
|
22
|
-
import {collectComponentDescriptors} from './collectComponentDescriptors';
|
|
23
|
-
import {combineMultipleQueries} from './combineMultipleQueries';
|
|
24
|
-
import {fetchContentData} from './fetchContentData';
|
|
25
|
-
import {applyProcessors} from './applyProcessors';
|
|
26
|
-
import {createMetaData} from './createMetaData';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Default fetchContent function, built with params from imports.
|
|
31
|
-
* It runs custom content-type-specific guillotine calls against an XP guillotine endpoint, returns content data, error and some meta data
|
|
32
|
-
* Sends one query to the guillotine API and asks for content type, then uses the type to select a second query and variables, which is sent to the API and fetches content data.
|
|
33
|
-
* @param context object from Next, contains .query info
|
|
34
|
-
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
35
|
-
*/
|
|
36
|
-
export async function fetchContent(context: Context): Promise<FetchContentResult> {
|
|
37
|
-
const {locale, locales, defaultLocale} = getRequestLocaleInfo(context);
|
|
38
|
-
const {isEnabled} = await draftMode();
|
|
39
|
-
|
|
40
|
-
// we only want to read headers in draft mode, because they bail out static generation
|
|
41
|
-
if (isEnabled) {
|
|
42
|
-
const allHeaders = await headers();
|
|
43
|
-
|
|
44
|
-
if (!context.headers) {
|
|
45
|
-
context.headers = new Headers();
|
|
46
|
-
}
|
|
47
|
-
allHeaders.forEach((value, key) => {
|
|
48
|
-
context.headers.set(key, value);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const outHeaders = buildGuillotineRequestHeaders({
|
|
53
|
-
context,
|
|
54
|
-
defaultLocale,
|
|
55
|
-
locale,
|
|
56
|
-
locales
|
|
57
|
-
});
|
|
58
|
-
const xpBaseUrl = getXpBaseUrl(context);
|
|
59
|
-
const contentApiUrl = getContentApiUrl(context);
|
|
60
|
-
const mapping = getLocaleMapping(context);
|
|
61
|
-
const renderMode = getRenderMode(context);
|
|
62
|
-
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
63
|
-
const requestContentPath = getCleanContentPathArrayOrThrow400(context.contentPath);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const [siteRelativeContentPath, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
67
|
-
if (componentPath) {
|
|
68
|
-
// set component request type because url contains component path
|
|
69
|
-
requestType = XP_REQUEST_TYPE.COMPONENT;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ///////////// FIRST GUILLOTINE CALL FOR METADATA /////////////////
|
|
73
|
-
const metaResult = await fetchMetaData(contentApiUrl, '${site}/' + siteRelativeContentPath, mapping, outHeaders);
|
|
74
|
-
// ///////////////////////////////////////////////////////////////////////
|
|
75
|
-
|
|
76
|
-
const {_id, _path, type} = metaResult.meta || {};
|
|
77
|
-
const contentPath = _path || siteRelativeContentPath;
|
|
78
|
-
|
|
79
|
-
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath, _id);
|
|
80
|
-
|
|
81
|
-
if (metaResult.error) {
|
|
82
|
-
console.error(metaResult.error);
|
|
83
|
-
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!metaResult.meta) {
|
|
87
|
-
return errorResponse('404', 'No meta data found for content, most likely content does not exist');
|
|
88
|
-
} else if (!type) {
|
|
89
|
-
return errorResponse('500', "Server responded with incomplete meta data: missing content 'type' attribute.");
|
|
90
|
-
|
|
91
|
-
} else if (
|
|
92
|
-
renderMode === RENDER_MODE.NEXT
|
|
93
|
-
&& !IS_DEV_MODE
|
|
94
|
-
&& (
|
|
95
|
-
type === PAGE_TEMPLATE_CONTENTTYPE_NAME ||
|
|
96
|
-
type === PAGE_TEMPLATE_FOLDER
|
|
97
|
-
)) {
|
|
98
|
-
return errorResponse('404', `Content type [${type}] is not accessible in ${renderMode} mode`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const components = restrictComponentsToPath(type, metaResult.meta.components, componentPath);
|
|
102
|
-
if (componentPath && !components.length) {
|
|
103
|
-
// component was not found
|
|
104
|
-
return errorResponse('404', `Component ${componentPath} was not found`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (requestType !== XP_REQUEST_TYPE.COMPONENT && components.length > 0) {
|
|
108
|
-
requestType = XP_REQUEST_TYPE.PAGE;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// ////////////////////////////////////////////////// Content type established. Proceed to data call:
|
|
112
|
-
|
|
113
|
-
const allDescriptors: ComponentDescriptor[] = [];
|
|
114
|
-
|
|
115
|
-
// Add the content type query at all cases
|
|
116
|
-
const contentTypeDef = ComponentRegistry.getContentType(type);
|
|
117
|
-
const pageCmp = (components || []).find(cmp => cmp.type === XP_COMPONENT_TYPE.PAGE);
|
|
118
|
-
if (pageCmp) {
|
|
119
|
-
processComponentConfig(APP_NAME, APP_NAME_DASHED, pageCmp);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const contentQueryAndVars = getQueryAndVariables(type, contentPath, context, contentTypeDef?.query, pageCmp?.page?.config);
|
|
123
|
-
if (contentQueryAndVars) {
|
|
124
|
-
allDescriptors.push({
|
|
125
|
-
type: contentTypeDef,
|
|
126
|
-
queryAndVariables: contentQueryAndVars
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const commonQueryAndVars = getQueryAndVariables(type, contentPath, context, ComponentRegistry.getCommonQuery(),
|
|
131
|
-
pageCmp?.page?.config);
|
|
132
|
-
if (commonQueryAndVars) {
|
|
133
|
-
allDescriptors.push({
|
|
134
|
-
type: contentTypeDef,
|
|
135
|
-
queryAndVariables: commonQueryAndVars
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (components?.length && ComponentRegistry) {
|
|
140
|
-
for (const cmp of (components || [])) {
|
|
141
|
-
processComponentConfig(APP_NAME, APP_NAME_DASHED, cmp);
|
|
142
|
-
}
|
|
143
|
-
// Collect component queries if defined
|
|
144
|
-
const componentDescriptors = collectComponentDescriptors({
|
|
145
|
-
components,
|
|
146
|
-
xpContentPath: contentPath,
|
|
147
|
-
context
|
|
148
|
-
});
|
|
149
|
-
if (componentDescriptors.length) {
|
|
150
|
-
allDescriptors.push(...componentDescriptors);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const {query, variables} = combineMultipleQueries(allDescriptors);
|
|
155
|
-
if (!query.trim()) {
|
|
156
|
-
return errorResponse('400', `Missing or empty query override for content type ${type}`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// /////////////// SECOND GUILLOTINE CALL FOR DATA //////////////////////
|
|
160
|
-
const contentResults = await fetchContentData(contentApiUrl, contentPath, mapping, query, variables, outHeaders);
|
|
161
|
-
// ///////////////////////////////////////////////////////////////////////////
|
|
162
|
-
|
|
163
|
-
if (contentResults.error) {
|
|
164
|
-
console.error(contentResults.error);
|
|
165
|
-
return errorResponse(contentResults.error.code, contentResults.error.message);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Apply processors to every component
|
|
169
|
-
const datas = await applyProcessors(allDescriptors, contentResults, context);
|
|
170
|
-
|
|
171
|
-
// Unwind the data back to components
|
|
172
|
-
|
|
173
|
-
let contentData = null, common = null;
|
|
174
|
-
let startFrom = 0;
|
|
175
|
-
if (contentQueryAndVars) {
|
|
176
|
-
const item = datas[startFrom];
|
|
177
|
-
contentData = item.status === 'fulfilled' ? item.value : item.reason;
|
|
178
|
-
startFrom++;
|
|
179
|
-
}
|
|
180
|
-
if (commonQueryAndVars) {
|
|
181
|
-
const item = datas[startFrom];
|
|
182
|
-
common = item.status === 'fulfilled' ? item.value : item.reason;
|
|
183
|
-
startFrom++;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
for (let i = startFrom; i < datas.length; i++) {
|
|
187
|
-
// component descriptors hold references to components
|
|
188
|
-
// that will later be used for creating page regions
|
|
189
|
-
const datum = datas[i];
|
|
190
|
-
if (datum.status === 'rejected') {
|
|
191
|
-
let reason = datum.reason;
|
|
192
|
-
if (reason instanceof Error) {
|
|
193
|
-
reason = reason.message;
|
|
194
|
-
} else if (typeof reason !== 'string') {
|
|
195
|
-
reason = String(reason);
|
|
196
|
-
}
|
|
197
|
-
allDescriptors[i].component.error = reason;
|
|
198
|
-
} else {
|
|
199
|
-
allDescriptors[i].component.data = datum.value;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const page = buildPage(type, components);
|
|
204
|
-
const meta = createMetaData({
|
|
205
|
-
apiUrl: contentApiUrl,
|
|
206
|
-
baseUrl: xpBaseUrl,
|
|
207
|
-
components,
|
|
208
|
-
contentPath: siteRelativeContentPath,
|
|
209
|
-
contentType: type,
|
|
210
|
-
contentId: _id,
|
|
211
|
-
defaultLocale,
|
|
212
|
-
locale,
|
|
213
|
-
pageCmp: page,
|
|
214
|
-
renderMode,
|
|
215
|
-
requestedComponentPath: componentPath,
|
|
216
|
-
requestType
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
return {
|
|
220
|
-
data: contentData,
|
|
221
|
-
common,
|
|
222
|
-
meta,
|
|
223
|
-
page
|
|
224
|
-
};
|
|
225
|
-
} catch (e: any) {
|
|
226
|
-
console.error(e);
|
|
227
|
-
|
|
228
|
-
let error;
|
|
229
|
-
try {
|
|
230
|
-
error = JSON.parse(e.message);
|
|
231
|
-
} catch (e2) {
|
|
232
|
-
error = {
|
|
233
|
-
code: 'Local',
|
|
234
|
-
message: e.message
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
238
|
-
return errorResponse(error.code, error.message);
|
|
239
|
-
}
|
|
240
|
-
}
|