@enonic/nextjs-adapter 3.2.2 → 3.3.0-B2
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/{baseMappings.js → dist/baseMappings.js} +9 -9
- package/dist/baseMappings.js.map +1 -0
- package/dist/client/getClientHydratedHtml.jsx.map +1 -0
- package/dist/client.js.map +1 -0
- package/{common → dist/common}/ComponentRegistry.js +1 -1
- package/dist/common/ComponentRegistry.js.map +1 -0
- package/dist/common/UrlProcessor.js.map +1 -0
- package/dist/common/constants.js.map +1 -0
- package/{common → dist/common}/env.js +1 -1
- package/dist/common/env.js.map +1 -0
- package/dist/guillotine/applyProcessors.js.map +1 -0
- package/dist/guillotine/buildComponentTree.js.map +1 -0
- package/{guillotine → dist/guillotine}/buildErrorResponse.js +3 -3
- package/dist/guillotine/buildErrorResponse.js.map +1 -0
- package/{guillotine → dist/guillotine}/buildPage.js +1 -1
- package/dist/guillotine/buildPage.js.map +1 -0
- package/{guillotine → dist/guillotine}/collectComponentDescriptors.d.ts +1 -1
- package/{guillotine → dist/guillotine}/collectComponentDescriptors.js +4 -4
- package/dist/guillotine/collectComponentDescriptors.js.map +1 -0
- package/{guillotine → dist/guillotine}/combineMultipleQueries.js +1 -1
- package/dist/guillotine/combineMultipleQueries.js.map +1 -0
- package/{guillotine → dist/guillotine}/createMetaData.d.ts +1 -1
- package/{guillotine → dist/guillotine}/createMetaData.js +2 -2
- package/dist/guillotine/createMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContent.js +10 -10
- package/dist/guillotine/fetchContent.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContentData.js +2 -2
- package/dist/guillotine/fetchContentData.js.map +1 -0
- package/dist/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchContentPathsForLocale.js +4 -4
- package/dist/guillotine/fetchContentPathsForLocale.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchFromApi.js +7 -7
- package/dist/guillotine/fetchFromApi.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchGuillotine.js +6 -6
- package/dist/guillotine/fetchGuillotine.js.map +1 -0
- package/{guillotine → dist/guillotine}/fetchMetaData.js +4 -4
- package/dist/guillotine/fetchMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/getCleanContentPathArrayOrThrow400.js +1 -1
- package/dist/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
- package/dist/guillotine/getComponentConfig.js.map +1 -0
- package/dist/guillotine/getContentAndComponentPaths.js.map +1 -0
- package/dist/guillotine/getMetaData.js.map +1 -0
- package/{guillotine → dist/guillotine}/getParentRegion.js +1 -1
- package/dist/guillotine/getParentRegion.js.map +1 -0
- package/{guillotine → dist/guillotine}/getQueryAndVariables.js +2 -2
- package/dist/guillotine/getQueryAndVariables.js.map +1 -0
- package/dist/guillotine/metadata/configQuery.js.map +1 -0
- package/dist/guillotine/metadata/richTextQuery.js.map +1 -0
- package/{guillotine → dist/guillotine}/parseComponentPath.js +3 -3
- package/dist/guillotine/parseComponentPath.js.map +1 -0
- package/dist/guillotine/prefixFragmentCmpPath.js.map +1 -0
- package/dist/guillotine/processComponentConfig.js.map +1 -0
- package/dist/guillotine/restrictComponentsToPath.js.map +1 -0
- package/dist/guillotine/validateData.js.map +1 -0
- package/dist/guillotine/validateNotFound.js.map +1 -0
- package/dist/guillotine/validateShortcut.js.map +1 -0
- package/{i18n → dist/i18n}/LocaleContext.d.ts +1 -1
- package/{i18n → dist/i18n}/LocaleContext.jsx +3 -3
- package/dist/i18n/LocaleContext.jsx.map +1 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/{index.d.ts → dist/index.d.ts} +3 -3
- package/{index.js → dist/index.js} +3 -3
- package/dist/index.js.map +1 -0
- package/dist/query/Shortcut.js.map +1 -0
- package/dist/server/getServerRenderedHtml.js.map +1 -0
- package/dist/server.js.map +1 -0
- package/{types → dist/types}/component.js.map +1 -1
- package/{types → dist/types}/componentProps.d.ts +2 -1
- package/dist/types/componentProps.js.map +1 -0
- package/{types → dist/types}/guillotine.d.ts +1 -1
- package/{types → dist/types}/guillotine.js.map +1 -1
- package/dist/types/i18n.js.map +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/next.js.map +1 -0
- package/dist/types/util.js.map +1 -0
- package/dist/utils/addLineNumbers.js.map +1 -0
- package/{utils → dist/utils}/buildGuillotineRequestHeaders.d.ts +1 -1
- package/{utils → dist/utils}/buildGuillotineRequestHeaders.js +3 -3
- package/dist/utils/buildGuillotineRequestHeaders.js.map +1 -0
- package/dist/utils/commonChars.js.map +1 -0
- package/dist/utils/enonicLog.js.map +1 -0
- package/dist/utils/fixDoubleSlashes.js.map +1 -0
- package/dist/utils/getAllLocales.js.map +1 -0
- package/dist/utils/getContentApiUrl.js.map +1 -0
- package/dist/utils/getLocaleMapping.js.map +1 -0
- package/dist/utils/getLocaleMappingByLocale.js.map +1 -0
- package/dist/utils/getLocaleMappingByProjectId.js.map +1 -0
- package/{utils → dist/utils}/getLocaleMappings.js +1 -1
- package/dist/utils/getLocaleMappings.js.map +1 -0
- package/{utils → dist/utils}/getRenderMode.js +1 -1
- package/dist/utils/getRenderMode.js.map +1 -0
- package/dist/utils/getRequestLocaleInfo.js.map +1 -0
- package/dist/utils/getXpBaseUrl.js.map +1 -0
- package/dist/utils/indent.js.map +1 -0
- package/dist/utils/sanitizeGraphqlName.js.map +1 -0
- package/{views → dist/views}/BaseComponent.d.ts +1 -1
- package/{views → dist/views}/BaseComponent.jsx +5 -5
- package/dist/views/BaseComponent.jsx.map +1 -0
- package/{views → dist/views}/BaseContent.jsx +1 -1
- package/dist/views/BaseContent.jsx.map +1 -0
- package/dist/views/BaseLayout.jsx.map +1 -0
- package/dist/views/BaseMacro.jsx.map +1 -0
- package/dist/views/BasePage.jsx.map +1 -0
- package/dist/views/BasePart.jsx.map +1 -0
- package/dist/views/Empty.jsx.map +1 -0
- package/dist/views/Fragment.jsx.map +1 -0
- package/dist/views/MainView.jsx.map +1 -0
- package/{views → dist/views}/PropsView.jsx +1 -1
- package/dist/views/PropsView.jsx.map +1 -0
- package/dist/views/Region.jsx.map +1 -0
- package/dist/views/RichTextView.jsx +65 -0
- package/dist/views/RichTextView.jsx.map +1 -0
- package/dist/views/SingleComponent.jsx.map +1 -0
- package/dist/views/StaticContent.jsx.map +1 -0
- package/dist/views/Text.jsx.map +1 -0
- package/dist/views/macros/DefaultMacro.jsx.map +1 -0
- package/dist/views/macros/DisableMacro.jsx.map +1 -0
- package/package.json +49 -42
- package/baseMappings.js.map +0 -1
- package/client/getClientHydratedHtml.jsx.map +0 -1
- package/client.js.map +0 -1
- package/common/ComponentRegistry.js.map +0 -1
- package/common/UrlProcessor.js.map +0 -1
- package/common/constants.js.map +0 -1
- package/common/env.js.map +0 -1
- package/guillotine/applyProcessors.js.map +0 -1
- package/guillotine/buildComponentTree.js.map +0 -1
- package/guillotine/buildErrorResponse.js.map +0 -1
- package/guillotine/buildPage.js.map +0 -1
- package/guillotine/collectComponentDescriptors.js.map +0 -1
- package/guillotine/combineMultipleQueries.js.map +0 -1
- package/guillotine/createMetaData.js.map +0 -1
- package/guillotine/fetchContent.js.map +0 -1
- package/guillotine/fetchContentData.js.map +0 -1
- package/guillotine/fetchContentPathsForAllLocales.js.map +0 -1
- package/guillotine/fetchContentPathsForLocale.js.map +0 -1
- package/guillotine/fetchFromApi.js.map +0 -1
- package/guillotine/fetchGuillotine.js.map +0 -1
- package/guillotine/fetchMetaData.js.map +0 -1
- package/guillotine/getCleanContentPathArrayOrThrow400.js.map +0 -1
- package/guillotine/getComponentConfig.js.map +0 -1
- package/guillotine/getContentAndComponentPaths.js.map +0 -1
- package/guillotine/getMetaData.js.map +0 -1
- package/guillotine/getParentRegion.js.map +0 -1
- package/guillotine/getQueryAndVariables.js.map +0 -1
- package/guillotine/metadata/configQuery.js.map +0 -1
- package/guillotine/metadata/richTextQuery.js.map +0 -1
- package/guillotine/parseComponentPath.js.map +0 -1
- package/guillotine/prefixFragmentCmpPath.js.map +0 -1
- package/guillotine/processComponentConfig.js.map +0 -1
- package/guillotine/restrictComponentsToPath.js.map +0 -1
- package/guillotine/validateData.js.map +0 -1
- package/guillotine/validateNotFound.js.map +0 -1
- package/guillotine/validateShortcut.js.map +0 -1
- package/i18n/LocaleContext.jsx.map +0 -1
- package/i18n/i18n.js.map +0 -1
- package/index.js.map +0 -1
- package/query/Shortcut.js.map +0 -1
- package/server/getServerRenderedHtml.js.map +0 -1
- package/server.js.map +0 -1
- package/src/baseMappings.ts +0 -53
- package/src/client/getClientHydratedHtml.tsx +0 -12
- package/src/client.ts +0 -2
- package/src/common/ComponentRegistry.ts +0 -162
- package/src/common/UrlProcessor.ts +0 -172
- package/src/common/constants.ts +0 -92
- package/src/common/env.ts +0 -41
- package/src/guillotine/applyProcessors.ts +0 -38
- package/src/guillotine/buildComponentTree.ts +0 -57
- package/src/guillotine/buildErrorResponse.ts +0 -35
- package/src/guillotine/buildPage.ts +0 -15
- package/src/guillotine/collectComponentDescriptors.ts +0 -63
- package/src/guillotine/combineMultipleQueries.ts +0 -75
- package/src/guillotine/createMetaData.ts +0 -72
- package/src/guillotine/fetchContent.ts +0 -246
- package/src/guillotine/fetchContentData.ts +0 -37
- 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/getCleanContentPathArrayOrThrow400.ts +0 -22
- package/src/guillotine/getComponentConfig.ts +0 -7
- package/src/guillotine/getContentAndComponentPaths.ts +0 -11
- package/src/guillotine/getMetaData.ts +0 -74
- package/src/guillotine/getParentRegion.ts +0 -54
- package/src/guillotine/getQueryAndVariables.ts +0 -52
- package/src/guillotine/metadata/configQuery.ts +0 -46
- package/src/guillotine/metadata/richTextQuery.ts +0 -49
- package/src/guillotine/parseComponentPath.ts +0 -29
- package/src/guillotine/prefixFragmentCmpPath.ts +0 -13
- package/src/guillotine/processComponentConfig.ts +0 -38
- package/src/guillotine/restrictComponentsToPath.ts +0 -48
- package/src/guillotine/validateData.ts +0 -11
- package/src/guillotine/validateNotFound.ts +0 -20
- package/src/guillotine/validateShortcut.ts +0 -43
- package/src/i18n/LocaleContext.tsx +0 -59
- package/src/i18n/i18n.ts +0 -57
- package/src/index.ts +0 -42
- package/src/query/Shortcut.ts +0 -18
- package/src/server/getServerRenderedHtml.ts +0 -3
- package/src/server.ts +0 -5
- package/src/types/component.ts +0 -131
- package/src/types/componentProps.ts +0 -142
- package/src/types/guillotine.ts +0 -428
- package/src/types/i18n.ts +0 -8
- package/src/types/index.ts +0 -62
- 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 -32
- package/src/utils/commonChars.ts +0 -16
- 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/getLocaleMappings.ts +0 -36
- package/src/utils/getRenderMode.ts +0 -14
- package/src/utils/getRequestLocaleInfo.ts +0 -30
- package/src/utils/getXpBaseUrl.ts +0 -12
- package/src/utils/indent.ts +0 -4
- package/src/utils/sanitizeGraphqlName.ts +0 -11
- package/src/views/BaseComponent.tsx +0 -156
- package/src/views/BaseContent.tsx +0 -47
- package/src/views/BaseLayout.tsx +0 -33
- package/src/views/BaseMacro.tsx +0 -105
- package/src/views/BasePage.tsx +0 -42
- package/src/views/BasePart.tsx +0 -34
- package/src/views/Empty.tsx +0 -5
- package/src/views/Fragment.tsx +0 -41
- package/src/views/MainView.tsx +0 -22
- package/src/views/PropsView.tsx +0 -38
- package/src/views/Region.tsx +0 -76
- package/src/views/RichTextView.tsx +0 -63
- 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
- package/types/componentProps.js.map +0 -1
- package/types/i18n.js.map +0 -1
- package/types/index.js.map +0 -1
- package/types/next.js.map +0 -1
- package/types/util.js.map +0 -1
- package/utils/addLineNumbers.js.map +0 -1
- package/utils/buildGuillotineRequestHeaders.js.map +0 -1
- package/utils/commonChars.js.map +0 -1
- package/utils/enonicLog.js.map +0 -1
- package/utils/fixDoubleSlashes.js.map +0 -1
- package/utils/getAllLocales.js.map +0 -1
- package/utils/getContentApiUrl.js.map +0 -1
- package/utils/getLocaleMapping.js.map +0 -1
- package/utils/getLocaleMappingByLocale.js.map +0 -1
- package/utils/getLocaleMappingByProjectId.js.map +0 -1
- package/utils/getLocaleMappings.js.map +0 -1
- package/utils/getRenderMode.js.map +0 -1
- package/utils/getRequestLocaleInfo.js.map +0 -1
- package/utils/getXpBaseUrl.js.map +0 -1
- package/utils/indent.js.map +0 -1
- package/utils/sanitizeGraphqlName.js.map +0 -1
- package/views/BaseComponent.jsx.map +0 -1
- package/views/BaseContent.jsx.map +0 -1
- package/views/BaseLayout.jsx.map +0 -1
- package/views/BaseMacro.jsx.map +0 -1
- package/views/BasePage.jsx.map +0 -1
- package/views/BasePart.jsx.map +0 -1
- package/views/Empty.jsx.map +0 -1
- package/views/Fragment.jsx.map +0 -1
- package/views/MainView.jsx.map +0 -1
- package/views/PropsView.jsx.map +0 -1
- package/views/Region.jsx.map +0 -1
- package/views/RichTextView.jsx +0 -39
- package/views/RichTextView.jsx.map +0 -1
- package/views/SingleComponent.jsx.map +0 -1
- package/views/StaticContent.jsx.map +0 -1
- package/views/Text.jsx.map +0 -1
- package/views/macros/DefaultMacro.jsx.map +0 -1
- package/views/macros/DisableMacro.jsx.map +0 -1
- /package/{baseMappings.d.ts → dist/baseMappings.d.ts} +0 -0
- /package/{client → dist/client}/getClientHydratedHtml.d.ts +0 -0
- /package/{client → dist/client}/getClientHydratedHtml.jsx +0 -0
- /package/{client.d.ts → dist/client.d.ts} +0 -0
- /package/{client.js → dist/client.js} +0 -0
- /package/{common → dist/common}/ComponentRegistry.d.ts +0 -0
- /package/{common → dist/common}/UrlProcessor.d.ts +0 -0
- /package/{common → dist/common}/UrlProcessor.js +0 -0
- /package/{common → dist/common}/constants.d.ts +0 -0
- /package/{common → dist/common}/constants.js +0 -0
- /package/{common → dist/common}/env.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/applyProcessors.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/applyProcessors.js +0 -0
- /package/{guillotine → dist/guillotine}/buildComponentTree.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/buildComponentTree.js +0 -0
- /package/{guillotine → dist/guillotine}/buildErrorResponse.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/buildPage.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/combineMultipleQueries.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContent.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForAllLocales.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForAllLocales.js +0 -0
- /package/{guillotine → dist/guillotine}/fetchContentPathsForLocale.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchFromApi.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchGuillotine.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/fetchMetaData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getCleanContentPathArrayOrThrow400.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getComponentConfig.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getComponentConfig.js +0 -0
- /package/{guillotine → dist/guillotine}/getContentAndComponentPaths.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getContentAndComponentPaths.js +0 -0
- /package/{guillotine → dist/guillotine}/getMetaData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getMetaData.js +0 -0
- /package/{guillotine → dist/guillotine}/getParentRegion.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/getQueryAndVariables.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/configQuery.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/configQuery.js +0 -0
- /package/{guillotine → dist/guillotine}/metadata/richTextQuery.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/metadata/richTextQuery.js +0 -0
- /package/{guillotine → dist/guillotine}/parseComponentPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/prefixFragmentCmpPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/prefixFragmentCmpPath.js +0 -0
- /package/{guillotine → dist/guillotine}/processComponentConfig.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/processComponentConfig.js +0 -0
- /package/{guillotine → dist/guillotine}/restrictComponentsToPath.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/restrictComponentsToPath.js +0 -0
- /package/{guillotine → dist/guillotine}/validateData.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateData.js +0 -0
- /package/{guillotine → dist/guillotine}/validateNotFound.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateNotFound.js +0 -0
- /package/{guillotine → dist/guillotine}/validateShortcut.d.ts +0 -0
- /package/{guillotine → dist/guillotine}/validateShortcut.js +0 -0
- /package/{i18n → dist/i18n}/i18n.d.ts +0 -0
- /package/{i18n → dist/i18n}/i18n.js +0 -0
- /package/{query → dist/query}/Shortcut.d.ts +0 -0
- /package/{query → dist/query}/Shortcut.js +0 -0
- /package/{server → dist/server}/getServerRenderedHtml.d.ts +0 -0
- /package/{server → dist/server}/getServerRenderedHtml.js +0 -0
- /package/{server.d.ts → dist/server.d.ts} +0 -0
- /package/{server.js → dist/server.js} +0 -0
- /package/{types → dist/types}/component.d.ts +0 -0
- /package/{types → dist/types}/component.js +0 -0
- /package/{types → dist/types}/componentProps.js +0 -0
- /package/{types → dist/types}/guillotine.js +0 -0
- /package/{types → dist/types}/i18n.d.ts +0 -0
- /package/{types → dist/types}/i18n.js +0 -0
- /package/{types → dist/types}/index.d.ts +0 -0
- /package/{types → dist/types}/index.js +0 -0
- /package/{types → dist/types}/next.d.ts +0 -0
- /package/{types → dist/types}/next.js +0 -0
- /package/{types → dist/types}/util.d.ts +0 -0
- /package/{types → dist/types}/util.js +0 -0
- /package/{utils → dist/utils}/addLineNumbers.d.ts +0 -0
- /package/{utils → dist/utils}/addLineNumbers.js +0 -0
- /package/{utils → dist/utils}/commonChars.d.ts +0 -0
- /package/{utils → dist/utils}/commonChars.js +0 -0
- /package/{utils → dist/utils}/enonicLog.d.ts +0 -0
- /package/{utils → dist/utils}/enonicLog.js +0 -0
- /package/{utils → dist/utils}/fixDoubleSlashes.d.ts +0 -0
- /package/{utils → dist/utils}/fixDoubleSlashes.js +0 -0
- /package/{utils → dist/utils}/getAllLocales.d.ts +0 -0
- /package/{utils → dist/utils}/getAllLocales.js +0 -0
- /package/{utils → dist/utils}/getContentApiUrl.d.ts +0 -0
- /package/{utils → dist/utils}/getContentApiUrl.js +0 -0
- /package/{utils → dist/utils}/getLocaleMapping.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMapping.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByLocale.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByLocale.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByProjectId.d.ts +0 -0
- /package/{utils → dist/utils}/getLocaleMappingByProjectId.js +0 -0
- /package/{utils → dist/utils}/getLocaleMappings.d.ts +0 -0
- /package/{utils → dist/utils}/getRenderMode.d.ts +0 -0
- /package/{utils → dist/utils}/getRequestLocaleInfo.d.ts +0 -0
- /package/{utils → dist/utils}/getRequestLocaleInfo.js +0 -0
- /package/{utils → dist/utils}/getXpBaseUrl.d.ts +0 -0
- /package/{utils → dist/utils}/getXpBaseUrl.js +0 -0
- /package/{utils → dist/utils}/indent.d.ts +0 -0
- /package/{utils → dist/utils}/indent.js +0 -0
- /package/{utils → dist/utils}/sanitizeGraphqlName.d.ts +0 -0
- /package/{utils → dist/utils}/sanitizeGraphqlName.js +0 -0
- /package/{views → dist/views}/BaseContent.d.ts +0 -0
- /package/{views → dist/views}/BaseLayout.d.ts +0 -0
- /package/{views → dist/views}/BaseLayout.jsx +0 -0
- /package/{views → dist/views}/BaseMacro.d.ts +0 -0
- /package/{views → dist/views}/BaseMacro.jsx +0 -0
- /package/{views → dist/views}/BasePage.d.ts +0 -0
- /package/{views → dist/views}/BasePage.jsx +0 -0
- /package/{views → dist/views}/BasePart.d.ts +0 -0
- /package/{views → dist/views}/BasePart.jsx +0 -0
- /package/{views → dist/views}/Empty.d.ts +0 -0
- /package/{views → dist/views}/Empty.jsx +0 -0
- /package/{views → dist/views}/Fragment.d.ts +0 -0
- /package/{views → dist/views}/Fragment.jsx +0 -0
- /package/{views → dist/views}/MainView.d.ts +0 -0
- /package/{views → dist/views}/MainView.jsx +0 -0
- /package/{views → dist/views}/PropsView.d.ts +0 -0
- /package/{views → dist/views}/Region.d.ts +0 -0
- /package/{views → dist/views}/Region.jsx +0 -0
- /package/{views → dist/views}/RichTextView.d.ts +0 -0
- /package/{views → dist/views}/SingleComponent.d.ts +0 -0
- /package/{views → dist/views}/SingleComponent.jsx +0 -0
- /package/{views → dist/views}/StaticContent.d.ts +0 -0
- /package/{views → dist/views}/StaticContent.jsx +0 -0
- /package/{views → dist/views}/Text.d.ts +0 -0
- /package/{views → dist/views}/Text.jsx +0 -0
- /package/{views → dist/views}/macros/DefaultMacro.d.ts +0 -0
- /package/{views → dist/views}/macros/DefaultMacro.jsx +0 -0
- /package/{views → dist/views}/macros/DisableMacro.d.ts +0 -0
- /package/{views → dist/views}/macros/DisableMacro.jsx +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDefinition,
|
|
3
|
-
ComponentDefinitionParams,
|
|
4
|
-
ComponentDictionary,
|
|
5
|
-
PageComponent,
|
|
6
|
-
SelectedQueryMaybeVariablesFunc,
|
|
7
|
-
SelectorName,
|
|
8
|
-
} from '../types';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
CATCH_ALL,
|
|
13
|
-
XP_COMPONENT_TYPE,
|
|
14
|
-
} from './constants';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function toSelectorName(type: XP_COMPONENT_TYPE): SelectorName | undefined {
|
|
18
|
-
switch (type) {
|
|
19
|
-
case XP_COMPONENT_TYPE.PAGE:
|
|
20
|
-
return 'page';
|
|
21
|
-
case XP_COMPONENT_TYPE.LAYOUT:
|
|
22
|
-
return 'layout';
|
|
23
|
-
case XP_COMPONENT_TYPE.PART:
|
|
24
|
-
return 'part';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export class ComponentRegistry {
|
|
30
|
-
|
|
31
|
-
private static contentTypes: ComponentDictionary = {};
|
|
32
|
-
private static pages: ComponentDictionary = {};
|
|
33
|
-
private static components: ComponentDictionary = {};
|
|
34
|
-
private static parts: ComponentDictionary = {};
|
|
35
|
-
private static layouts: ComponentDictionary = {};
|
|
36
|
-
private static macros: ComponentDictionary = {};
|
|
37
|
-
private static commonQuery: SelectedQueryMaybeVariablesFunc;
|
|
38
|
-
|
|
39
|
-
public static addComponent(name: string, obj: ComponentDefinitionParams): void {
|
|
40
|
-
return ComponentRegistry.addType('component', name, obj);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public static addContentType(name: string, obj: ComponentDefinitionParams): void {
|
|
44
|
-
return ComponentRegistry.addType('contentType', name, obj);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public static addMacro(name: string, obj: ComponentDefinitionParams): void {
|
|
48
|
-
return ComponentRegistry.addType('macro', name, obj);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public static addLayout(name: string, obj: ComponentDefinitionParams): void {
|
|
52
|
-
return ComponentRegistry.addType('layout', name, obj);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public static addPage(name: string, obj: ComponentDefinitionParams): void {
|
|
56
|
-
return ComponentRegistry.addType('page', name, obj);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public static addPart(name: string, obj: ComponentDefinitionParams): void {
|
|
60
|
-
return ComponentRegistry.addType('part', name, obj);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private static addType(selectorName: SelectorName, name: string, obj: ComponentDefinitionParams): void {
|
|
64
|
-
const selector = ComponentRegistry.getSelector(selectorName);
|
|
65
|
-
const curr = selector[name];
|
|
66
|
-
selector[name] = curr ? Object.assign(curr, obj) : obj;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private static getSelector(name: SelectorName): ComponentDictionary {
|
|
70
|
-
switch (name) {
|
|
71
|
-
case 'contentType':
|
|
72
|
-
return this.contentTypes;
|
|
73
|
-
case 'page':
|
|
74
|
-
return this.pages;
|
|
75
|
-
case 'component':
|
|
76
|
-
return this.components;
|
|
77
|
-
case 'layout':
|
|
78
|
-
return this.layouts;
|
|
79
|
-
case 'part':
|
|
80
|
-
return this.parts;
|
|
81
|
-
case 'macro':
|
|
82
|
-
return this.macros;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private static getType(selectorName: SelectorName, typeName: string, useCatchAll = true): ComponentDefinition | undefined {
|
|
87
|
-
const selector = ComponentRegistry.getSelector(selectorName);
|
|
88
|
-
let type: ComponentDefinition|undefined = selector[typeName];
|
|
89
|
-
if (type) {
|
|
90
|
-
type.catchAll = typeName === CATCH_ALL;
|
|
91
|
-
} else if (!type && useCatchAll) {
|
|
92
|
-
type = selector[CATCH_ALL];
|
|
93
|
-
if (type) {
|
|
94
|
-
type.catchAll = true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return type;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public static getByComponent(component: PageComponent): ComponentDefinition | undefined {
|
|
101
|
-
const selName = toSelectorName(component.type);
|
|
102
|
-
const cmpData = component[component.type];
|
|
103
|
-
const desc = cmpData && 'descriptor' in cmpData ? cmpData.descriptor : component.path;
|
|
104
|
-
return selName && desc ? this.getType(selName, desc) : undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public static setCommonQuery(query: SelectedQueryMaybeVariablesFunc): void {
|
|
108
|
-
this.commonQuery = query;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public static getCommonQuery(): SelectedQueryMaybeVariablesFunc {
|
|
112
|
-
return this.commonQuery;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public static getMacro(name: string): ComponentDefinition | undefined {
|
|
116
|
-
return ComponentRegistry.getType('macro', name);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public static getMacros(): [string, ComponentDefinition][] {
|
|
120
|
-
return Object.entries(this.macros);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public static getParts(): [string, ComponentDefinition][] {
|
|
124
|
-
return Object.entries(this.parts);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public static getLayouts(): [string, ComponentDefinition][] {
|
|
128
|
-
return Object.entries(this.layouts);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public static getPages(): [string, ComponentDefinition][] {
|
|
132
|
-
return Object.entries(this.pages);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public static getContentTypes(): [string, ComponentDefinition][] {
|
|
136
|
-
return Object.entries(this.contentTypes);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public static getComponents(): [string, ComponentDefinition][] {
|
|
140
|
-
return Object.entries(this.components);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public static getContentType(name: string): ComponentDefinition | undefined {
|
|
144
|
-
return ComponentRegistry.getType('contentType', name);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public static getPage(name: string): ComponentDefinition | undefined {
|
|
148
|
-
return ComponentRegistry.getType('page', name);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
public static getPart(name: string): ComponentDefinition | undefined {
|
|
152
|
-
return ComponentRegistry.getType('part', name);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public static getLayout(name: string): ComponentDefinition | undefined {
|
|
156
|
-
return ComponentRegistry.getType('layout', name);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
public static getComponent(name: string): ComponentDefinition | undefined {
|
|
160
|
-
return ComponentRegistry.getType('component', name);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import type {ImageData, LinkData, MetaData} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {RENDER_MODE} from './constants';
|
|
5
|
-
import {fixDoubleSlashes} from '../utils/fixDoubleSlashes';
|
|
6
|
-
import {addBasePath} from 'next/dist/client/add-base-path';
|
|
7
|
-
import {parseUrl} from 'next/dist/shared/lib/router/utils/parse-url';
|
|
8
|
-
import {getLocaleMappingByLocale} from '../utils/getLocaleMappingByLocale';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export class UrlProcessor {
|
|
12
|
-
|
|
13
|
-
public static IMG_TAG = 'img';
|
|
14
|
-
public static LINK_TAG = 'a';
|
|
15
|
-
public static MACRO_TAG = 'editor-macro';
|
|
16
|
-
|
|
17
|
-
public static IMG_ATTR = 'data-image-ref';
|
|
18
|
-
public static LINK_ATTR = 'data-link-ref';
|
|
19
|
-
public static MACRO_ATTR = 'data-macro-ref';
|
|
20
|
-
|
|
21
|
-
private static IMG_ATMT_REGEXP = /_\/image\/|_\/attachment\//;
|
|
22
|
-
private static endSlashPattern = /\/+$/;
|
|
23
|
-
private static startSlashPattern = /^\/+/;
|
|
24
|
-
private static localhostPattern = /localhost/;
|
|
25
|
-
|
|
26
|
-
public static process(url: string, meta: MetaData, serverSide = false, isResource = false): string {
|
|
27
|
-
if (this.startsWithHash(url) || !meta || (this.isAttachmentUrl(url)) && meta.renderMode === RENDER_MODE.NEXT) {
|
|
28
|
-
// do not process if:
|
|
29
|
-
// - url starts with #
|
|
30
|
-
// - meta is absent
|
|
31
|
-
// - attachment urls in NEXT mode
|
|
32
|
-
return url;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let normalUrl: string;
|
|
36
|
-
if (this.isRelative(url)) {
|
|
37
|
-
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
38
|
-
if (mapping.site?.length) {
|
|
39
|
-
// see if url starts with site name and remove it
|
|
40
|
-
const normalSite = mapping.site.replace(this.startSlashPattern, '').replace(this.endSlashPattern, '');
|
|
41
|
-
normalUrl = url.replace(new RegExp(`^/?${normalSite}(?=/|$)`), '');
|
|
42
|
-
} else {
|
|
43
|
-
normalUrl = url;
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
// url is absolute, try to make it relative by striping apiUrl
|
|
47
|
-
// NB: will fail to do so if content api is not on the same domain as enonic xp
|
|
48
|
-
const apiUrl = this.getApiUrl(meta);
|
|
49
|
-
normalUrl = this.stripApiUrl(url, apiUrl);
|
|
50
|
-
|
|
51
|
-
// if url is still absolute, return it as is
|
|
52
|
-
if (!this.isRelative(normalUrl)) {
|
|
53
|
-
return normalUrl;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const baseUrl = meta?.baseUrl && meta?.baseUrl !== '/' ? meta.baseUrl : '';
|
|
58
|
-
|
|
59
|
-
let result: string;
|
|
60
|
-
if (meta.renderMode === RENDER_MODE.NEXT) {
|
|
61
|
-
// only add basePath and locale in next mode
|
|
62
|
-
result = `/${normalUrl}`;
|
|
63
|
-
if (!isResource && meta.locale !== meta.defaultLocale) {
|
|
64
|
-
// append locale if it's not the default one
|
|
65
|
-
// to avoid additional middleware redirection
|
|
66
|
-
// NB: don't add locale to resource urls
|
|
67
|
-
result = `/${meta.locale}${result}`;
|
|
68
|
-
}
|
|
69
|
-
if (!serverSide) {
|
|
70
|
-
// no need for baseurl and basepath on server
|
|
71
|
-
result = addBasePath(`${baseUrl}${result}`);
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
result = `${baseUrl}/${normalUrl}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return fixDoubleSlashes(result);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/*
|
|
81
|
-
* Deprecated
|
|
82
|
-
* */
|
|
83
|
-
public static setSiteKey(key: string): void {
|
|
84
|
-
// TODO: remove in next major release
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public static isMediaLink(ref: string, linkData: LinkData[]): boolean {
|
|
88
|
-
// Assuming linkData can't contain more than one entry with the same ref
|
|
89
|
-
return Array.isArray(linkData) && !!linkData.find(data => data?.ref === ref)?.media;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public static isContentImage(ref: string, imageData: ImageData[]): boolean {
|
|
93
|
-
// Assuming imageData can't contain more than one entry with the same ref
|
|
94
|
-
return Array.isArray(imageData) && !!imageData.find(data => data.ref === ref)?.image;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public static processSrcSet(srcset: string, meta: MetaData): string {
|
|
98
|
-
return srcset.split(/, */g).map(src => {
|
|
99
|
-
const srcParts = src.trim().split(' ');
|
|
100
|
-
switch (srcParts.length) {
|
|
101
|
-
case 1: // src only
|
|
102
|
-
return this.process(src, meta);
|
|
103
|
-
case 2: // width descriptor
|
|
104
|
-
return `${this.process(srcParts[0], meta)} ${srcParts[1]}`;
|
|
105
|
-
case 3: // pixel density descriptor
|
|
106
|
-
return `${this.process(srcParts[0], meta)} ${srcParts[1]} ${srcParts[2]}`;
|
|
107
|
-
default:
|
|
108
|
-
console.warn('Can not process image srcset: ' + src);
|
|
109
|
-
return src;
|
|
110
|
-
}
|
|
111
|
-
}).join(', ');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private static stripApiUrl(url: string, apiUrl: string): string {
|
|
115
|
-
// normalise localhost-127.0.0.1 if present in urls
|
|
116
|
-
const normalUrl = parseUrl(url.replace(this.localhostPattern, '127.0.0.1'));
|
|
117
|
-
const normalApiUrl = parseUrl(apiUrl.replace(this.localhostPattern, '127.0.0.1'));
|
|
118
|
-
|
|
119
|
-
// WARNING! disregarding the protocol (http/https)
|
|
120
|
-
|
|
121
|
-
if (normalUrl.hostname !== normalApiUrl.hostname
|
|
122
|
-
|| normalUrl.port !== normalApiUrl.port) {
|
|
123
|
-
// can't strip apiUrl if hostnames or ports are different
|
|
124
|
-
return url;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const urlPathCrumbs = normalUrl.pathname.split('/');
|
|
128
|
-
const apiUrlPathCrumbs = normalApiUrl.pathname.split('/');
|
|
129
|
-
for (let i = 0; i < Math.min(apiUrlPathCrumbs.length, urlPathCrumbs.length);) {
|
|
130
|
-
const urlPathCrumb = urlPathCrumbs[i];
|
|
131
|
-
const apiUrlPathCrumb = apiUrlPathCrumbs[i];
|
|
132
|
-
if (urlPathCrumb === apiUrlPathCrumb) {
|
|
133
|
-
urlPathCrumbs.shift();
|
|
134
|
-
apiUrlPathCrumbs.shift();
|
|
135
|
-
} else {
|
|
136
|
-
i++;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return `/${urlPathCrumbs.join('/')}` + normalUrl.search + normalUrl.hash;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private static isAttachmentUrl(url: string): boolean {
|
|
144
|
-
return this.IMG_ATMT_REGEXP.test(url);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private static startsWithHash(url: string): boolean {
|
|
148
|
-
return url?.charAt(0) == '#';
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private static isRelative(url: string): boolean {
|
|
152
|
-
return !/^(?:ht|f)tps?:\/\/[^ :\r\n\t]+/.test(url);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private static getApiUrl(meta: MetaData) {
|
|
156
|
-
let combinedUrl = meta.apiUrl?.replace(this.endSlashPattern, '') || '';
|
|
157
|
-
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
158
|
-
if (mapping.site?.length) {
|
|
159
|
-
combinedUrl += '/' + mapping.site.replace(this.startSlashPattern, '');
|
|
160
|
-
}
|
|
161
|
-
return combinedUrl;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function getUrl(url: string, meta: MetaData): string {
|
|
166
|
-
return UrlProcessor.process(url, meta, false, false);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function getAsset(url: string, meta: MetaData): string {
|
|
170
|
-
return UrlProcessor.process(url, meta, false, true);
|
|
171
|
-
}
|
|
172
|
-
|
package/src/common/constants.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
export const CATCH_ALL = '*';
|
|
2
|
-
|
|
3
|
-
export enum ENV_VARS {
|
|
4
|
-
MAPPINGS = 'ENONIC_MAPPINGS',
|
|
5
|
-
API_URL = 'ENONIC_API',
|
|
6
|
-
APP_NAME = 'ENONIC_APP_NAME',
|
|
7
|
-
LOG = 'ENONIC_LOGGING',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FRAGMENT_CONTENTTYPE_NAME = 'portal:fragment';
|
|
11
|
-
export const FRAGMENT_DEFAULT_REGION_NAME = 'fragment';
|
|
12
|
-
|
|
13
|
-
/** excluded contents:
|
|
14
|
-
* - folder
|
|
15
|
-
* - shortcuts (redirect can't be used in prerender)
|
|
16
|
-
* - media
|
|
17
|
-
* - paths with '/_' in them
|
|
18
|
-
*/
|
|
19
|
-
export const GET_STATIC_PATHS_QUERY = `query ($pathRegex: String!, $count: Int) {
|
|
20
|
-
guillotine {
|
|
21
|
-
queryDsl(
|
|
22
|
-
first: $count,
|
|
23
|
-
sort: {
|
|
24
|
-
field: "modifiedTime",
|
|
25
|
-
direction: DESC
|
|
26
|
-
}
|
|
27
|
-
query: {
|
|
28
|
-
boolean: {
|
|
29
|
-
mustNot: [
|
|
30
|
-
{in: {field: "type", stringValues: ["base:shortcut", "portal:fragment", "portal:template-folder", "portal:page-template"]}}
|
|
31
|
-
{like: {field: "type", value: "media:*"}}
|
|
32
|
-
]
|
|
33
|
-
must: [
|
|
34
|
-
{like: {field:"_path", value: $pathRegex}}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
) {
|
|
39
|
-
_name
|
|
40
|
-
_path
|
|
41
|
-
site {_name}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}`;
|
|
45
|
-
|
|
46
|
-
// Seems like NodeJS.fetch lowercases all headers, so we need to lowercase the
|
|
47
|
-
// header names here.
|
|
48
|
-
export enum GUILLOTINE_REQUEST_HEADERS {
|
|
49
|
-
COOKIE = 'Cookie',
|
|
50
|
-
LOCALE = 'locale',
|
|
51
|
-
LOCALES = 'locales',
|
|
52
|
-
DEFAULT_LOCALE = 'default-locale',
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const JSESSIONID_HEADER = 'jsessionid';
|
|
56
|
-
|
|
57
|
-
export const PAGE_TEMPLATE_CONTENTTYPE_NAME = 'portal:page-template';
|
|
58
|
-
export const PAGE_TEMPLATE_FOLDER = 'portal:template-folder';
|
|
59
|
-
export const PORTAL_COMPONENT_ATTRIBUTE = 'data-portal-component-type';
|
|
60
|
-
export const PORTAL_REGION_ATTRIBUTE = 'data-portal-region';
|
|
61
|
-
export const PROJECT_ID_HEADER = 'content-studio-project';
|
|
62
|
-
|
|
63
|
-
export enum RENDER_MODE {
|
|
64
|
-
INLINE = 'inline',
|
|
65
|
-
EDIT = 'edit',
|
|
66
|
-
PREVIEW = 'preview',
|
|
67
|
-
LIVE = 'live',
|
|
68
|
-
ADMIN = 'admin',
|
|
69
|
-
NEXT = 'next' // Fallback: not using XP proxy but rendering directly with next.js
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const RENDER_MODE_HEADER = 'content-studio-mode';
|
|
73
|
-
|
|
74
|
-
export const SITE_CONTENTTYPE_NAME = 'portal:site';
|
|
75
|
-
|
|
76
|
-
// URI parameter marking that a request is for a preview for CS. MUST MATCH THE VALUE OF 'FROM_XP_PARAM' on XP side.
|
|
77
|
-
export const XP_BASE_URL_HEADER = 'xpbaseurl';
|
|
78
|
-
|
|
79
|
-
// TODO: Use these instead of hardcoded strings everywhere
|
|
80
|
-
export enum XP_COMPONENT_TYPE {
|
|
81
|
-
PART = 'part',
|
|
82
|
-
LAYOUT = 'layout',
|
|
83
|
-
TEXT = 'text',
|
|
84
|
-
FRAGMENT = 'fragment',
|
|
85
|
-
PAGE = 'page',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export enum XP_REQUEST_TYPE {
|
|
89
|
-
COMPONENT = 'component',
|
|
90
|
-
TYPE = 'type',
|
|
91
|
-
PAGE = 'page',
|
|
92
|
-
}
|
package/src/common/env.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {ENV_VARS} from './constants';
|
|
2
|
-
|
|
3
|
-
const isServer = typeof window === 'undefined';
|
|
4
|
-
|
|
5
|
-
// IMPORTANT:
|
|
6
|
-
// NEXT_PUBLIC_ vars should be explicitly referenced to be made available on the client side (substituted with constants) !!!
|
|
7
|
-
/** URL to the guillotine API */
|
|
8
|
-
export const API_URL = isServer ? process.env[ENV_VARS.API_URL] : process.env['NEXT_PUBLIC_ENONIC_API'];
|
|
9
|
-
|
|
10
|
-
/** 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) */
|
|
11
|
-
export const APP_NAME = isServer ? process.env[ENV_VARS.APP_NAME] : process.env['NEXT_PUBLIC_ENONIC_APP_NAME'];
|
|
12
|
-
|
|
13
|
-
/** Optional utility value - derived from APP_NAME, only with underscores instead of dots */
|
|
14
|
-
export const APP_NAME_UNDERSCORED = (APP_NAME || '').replace(/\./g, '_');
|
|
15
|
-
|
|
16
|
-
/** Optional utility value - derived from APP_NAME, only with dashes instead of dots */
|
|
17
|
-
export const APP_NAME_DASHED = (APP_NAME || '').replace(/\./g, '-');
|
|
18
|
-
|
|
19
|
-
const mode = isServer ? process.env.MODE : process.env.NEXT_PUBLIC_MODE;
|
|
20
|
-
|
|
21
|
-
export const IS_DEV_MODE = (mode === 'development');
|
|
22
|
-
|
|
23
|
-
export const LOGGING = isServer ? process.env[ENV_VARS.LOG] : process.env['NEXT_PUBLIC_ENONIC_LOGGING'];
|
|
24
|
-
|
|
25
|
-
/** Locales and Enonic XP projects correspondence list */
|
|
26
|
-
export const MAPPINGS = isServer ? process.env[ENV_VARS.MAPPINGS] : process.env['NEXT_PUBLIC_ENONIC_MAPPINGS'];
|
|
27
|
-
|
|
28
|
-
const requiredConstants = {
|
|
29
|
-
[ENV_VARS.APP_NAME]: APP_NAME,
|
|
30
|
-
[ENV_VARS.API_URL]: API_URL,
|
|
31
|
-
[ENV_VARS.MAPPINGS]: MAPPINGS,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Verify required values on server-side only
|
|
35
|
-
Object.keys(requiredConstants).forEach((key: string) => {
|
|
36
|
-
const val = requiredConstants[key];
|
|
37
|
-
if (!val) {
|
|
38
|
-
throw new Error(`Environment variable '${isServer ? '' : 'NEXT_PUBLIC_'}${key}' is missing (from .env?)`);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDescriptor,
|
|
3
|
-
ContentResult,
|
|
4
|
-
Context,
|
|
5
|
-
} from '../types';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {getComponentConfig} from './getComponentConfig';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const NO_PROPS_PROCESSOR = async (props: any) => await props ?? {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export async function applyProcessors(
|
|
15
|
-
componentDescriptors: ComponentDescriptor[],
|
|
16
|
-
contentResults: ContentResult,
|
|
17
|
-
context: Context,
|
|
18
|
-
): Promise < PromiseSettledResult < any > [] > {
|
|
19
|
-
|
|
20
|
-
let dataCounter = 0;
|
|
21
|
-
const processorPromises = componentDescriptors.map(async (desc: ComponentDescriptor) => {
|
|
22
|
-
// we're iterating component descriptors here
|
|
23
|
-
// some of them might not have provided graphql requests
|
|
24
|
-
// but we still need to run props processor for them
|
|
25
|
-
// in case they want to fetch their data from elsewhere
|
|
26
|
-
const propsProcessor = desc.type?.processor || NO_PROPS_PROCESSOR;
|
|
27
|
-
let data;
|
|
28
|
-
if (desc.queryAndVariables) {
|
|
29
|
-
// if there is a query then there must be a result for it
|
|
30
|
-
data = contentResults.contents[dataCounter++];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const config = getComponentConfig(desc.component);
|
|
34
|
-
return await propsProcessor(data, context, config);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return Promise.allSettled(processorPromises);
|
|
38
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type {PageComponent, RegionTree} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {FRAGMENT_CONTENTTYPE_NAME, XP_COMPONENT_TYPE} from '../common/constants';
|
|
5
|
-
import {parseComponentPath} from './parseComponentPath';
|
|
6
|
-
import {getParentRegion} from './getParentRegion';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function buildComponentTree(
|
|
10
|
-
comps: PageComponent[],
|
|
11
|
-
rootComp: PageComponent,
|
|
12
|
-
contentType?: string,
|
|
13
|
-
): PageComponent {
|
|
14
|
-
const rootTree: RegionTree = {};
|
|
15
|
-
const isFragmentType = contentType === FRAGMENT_CONTENTTYPE_NAME;
|
|
16
|
-
|
|
17
|
-
if (isFragmentType) {
|
|
18
|
-
rootComp.regions = rootTree;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
(comps || []).forEach(cmp => {
|
|
22
|
-
const cmpPath = parseComponentPath(contentType, cmp.path);
|
|
23
|
-
|
|
24
|
-
if (cmp.path === '/') {
|
|
25
|
-
if (cmp.type === XP_COMPONENT_TYPE.PAGE && rootComp.type === XP_COMPONENT_TYPE.PAGE) {
|
|
26
|
-
// add page values to page object
|
|
27
|
-
rootComp = Object.assign(rootComp, cmp);
|
|
28
|
-
rootComp.page.regions = rootTree;
|
|
29
|
-
return;
|
|
30
|
-
} else if (cmp.type === XP_COMPONENT_TYPE.LAYOUT && rootComp.type === XP_COMPONENT_TYPE.FRAGMENT) {
|
|
31
|
-
// when rendering fragment as part of the page with layout at root path
|
|
32
|
-
// remove other children from list as they will be included in layout
|
|
33
|
-
rootComp.fragment.fragment.components = [cmp];
|
|
34
|
-
cmp.regions = rootTree;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (cmp.type === XP_COMPONENT_TYPE.FRAGMENT) {
|
|
39
|
-
// build component subtree for fragment
|
|
40
|
-
cmp = buildComponentTree(cmp.fragment?.fragment?.components, cmp, contentType);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const region = getParentRegion(rootTree, contentType, cmpPath, comps, true);
|
|
44
|
-
|
|
45
|
-
if (region) {
|
|
46
|
-
// getting the index of component from string like '/main/0/left/11'
|
|
47
|
-
const cmpIndex = cmpPath[cmpPath.length - 1]?.index;
|
|
48
|
-
if (cmpIndex >= 0) {
|
|
49
|
-
region.components.splice(cmpIndex, 0, cmp);
|
|
50
|
-
} else {
|
|
51
|
-
throw Error(`Could not find [${cmp.type}] component index at ${JSON.stringify(cmpPath, null, 2)}, rendering not possible.`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return rootComp;
|
|
57
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type {FetchContentResult} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {RENDER_MODE, XP_REQUEST_TYPE} from '../common/constants';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE,
|
|
8
|
-
apiUrl: string, baseUrl: string, locale: string, defaultLocale: string,
|
|
9
|
-
contentPath ?: string, contentId?: string): (code ?: string, message ?: string) => FetchContentResult {
|
|
10
|
-
|
|
11
|
-
return function (code = '500', message = 'Unknown error') {
|
|
12
|
-
return {
|
|
13
|
-
error: {
|
|
14
|
-
code,
|
|
15
|
-
message,
|
|
16
|
-
},
|
|
17
|
-
page: null,
|
|
18
|
-
common: null,
|
|
19
|
-
data: null,
|
|
20
|
-
meta: {
|
|
21
|
-
id: contentId || '',
|
|
22
|
-
type: '',
|
|
23
|
-
requestType: requestType,
|
|
24
|
-
renderMode: renderMode,
|
|
25
|
-
path: contentPath || '',
|
|
26
|
-
canRender: false,
|
|
27
|
-
catchAll: false,
|
|
28
|
-
apiUrl,
|
|
29
|
-
baseUrl,
|
|
30
|
-
locale,
|
|
31
|
-
defaultLocale,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -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,63 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDescriptor,
|
|
3
|
-
Context,
|
|
4
|
-
PageComponent,
|
|
5
|
-
} from '../types';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
9
|
-
import {XP_COMPONENT_TYPE} from '../common/constants';
|
|
10
|
-
import {
|
|
11
|
-
APP_NAME,
|
|
12
|
-
APP_NAME_DASHED,
|
|
13
|
-
} from '../common/env';
|
|
14
|
-
import {processComponentConfig} from './processComponentConfig';
|
|
15
|
-
import {getComponentConfig} from './getComponentConfig';
|
|
16
|
-
import {getQueryAndVariables} from './getQueryAndVariables';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export function collectComponentDescriptors({
|
|
20
|
-
components,
|
|
21
|
-
xpContentPath,
|
|
22
|
-
context,
|
|
23
|
-
}: {
|
|
24
|
-
components: PageComponent[]
|
|
25
|
-
xpContentPath: string
|
|
26
|
-
context: Context
|
|
27
|
-
}): ComponentDescriptor[] {
|
|
28
|
-
|
|
29
|
-
const descriptors: ComponentDescriptor[] = [];
|
|
30
|
-
|
|
31
|
-
for (const cmp of (components || [])) {
|
|
32
|
-
processComponentConfig(APP_NAME, APP_NAME_DASHED, cmp);
|
|
33
|
-
// only look for parts
|
|
34
|
-
// look for single part if it is a single component request
|
|
35
|
-
if (XP_COMPONENT_TYPE.FRAGMENT !== cmp.type) {
|
|
36
|
-
const cmpDef = ComponentRegistry.getByComponent(cmp);
|
|
37
|
-
if (cmpDef) {
|
|
38
|
-
// const partPath = `${xpContentPath}/_component${cmp.path}`;
|
|
39
|
-
const config = getComponentConfig(cmp);
|
|
40
|
-
const queryAndVariables = getQueryAndVariables(cmp.type, xpContentPath, context, cmpDef.query, config);
|
|
41
|
-
if (queryAndVariables) {
|
|
42
|
-
descriptors.push({
|
|
43
|
-
component: cmp,
|
|
44
|
-
type: cmpDef,
|
|
45
|
-
queryAndVariables: queryAndVariables,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
// look for parts inside fragments
|
|
51
|
-
const fragPartDescs = collectComponentDescriptors({
|
|
52
|
-
components: cmp.fragment?.fragment?.components,
|
|
53
|
-
xpContentPath,
|
|
54
|
-
context,
|
|
55
|
-
});
|
|
56
|
-
if (fragPartDescs.length) {
|
|
57
|
-
descriptors.push(...fragPartDescs);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return descriptors;
|
|
63
|
-
}
|