@enonic/nextjs-adapter 2.0.0 → 3.0.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 +3 -2
- package/baseMappings.js.map +1 -0
- package/client.d.ts +1 -0
- package/client.js +3 -0
- package/client.js.map +1 -0
- package/common/ComponentRegistry.d.ts +34 -0
- package/{ComponentRegistry.js → common/ComponentRegistry.js} +26 -26
- package/common/ComponentRegistry.js.map +1 -0
- package/{UrlProcessor.d.ts → common/UrlProcessor.d.ts} +5 -4
- package/{UrlProcessor.js → common/UrlProcessor.js} +40 -17
- package/common/UrlProcessor.js.map +1 -0
- package/common/constants.d.ts +50 -0
- package/common/constants.js +79 -0
- package/common/constants.js.map +1 -0
- package/common/env.d.ts +11 -0
- package/common/env.js +28 -0
- package/common/env.js.map +1 -0
- package/guillotine/applyProcessors.d.ts +2 -0
- package/guillotine/applyProcessors.js +33 -0
- package/guillotine/applyProcessors.js.map +1 -0
- package/guillotine/buildComponentTree.d.ts +2 -0
- package/guillotine/buildComponentTree.js +45 -0
- package/guillotine/buildComponentTree.js.map +1 -0
- package/guillotine/buildErrorResponse.d.ts +3 -0
- package/guillotine/buildErrorResponse.js +26 -0
- package/guillotine/buildErrorResponse.js.map +1 -0
- package/guillotine/buildPage.d.ts +2 -0
- package/guillotine/buildPage.js +10 -0
- package/guillotine/buildPage.js.map +1 -0
- package/guillotine/collectComponentDescriptors.d.ts +6 -0
- package/guillotine/collectComponentDescriptors.js +43 -0
- package/guillotine/collectComponentDescriptors.js.map +1 -0
- package/guillotine/combineMultipleQueries.d.ts +2 -0
- package/guillotine/combineMultipleQueries.js +58 -0
- package/guillotine/combineMultipleQueries.js.map +1 -0
- package/guillotine/createMetaData.d.ts +17 -0
- package/guillotine/createMetaData.js +44 -0
- package/guillotine/createMetaData.js.map +1 -0
- package/guillotine/fetchContent.d.ts +1 -41
- package/guillotine/fetchContent.js +193 -800
- package/guillotine/fetchContent.js.map +1 -0
- package/guillotine/fetchContentData.d.ts +2 -0
- package/guillotine/fetchContentData.js +27 -0
- package/guillotine/fetchContentData.js.map +1 -0
- package/guillotine/fetchContentPathsForAllLocales.d.ts +2 -0
- package/guillotine/fetchContentPathsForAllLocales.js +21 -0
- package/guillotine/fetchContentPathsForAllLocales.js.map +1 -0
- package/guillotine/fetchContentPathsForLocale.d.ts +2 -0
- package/guillotine/fetchContentPathsForLocale.js +40 -0
- package/guillotine/fetchContentPathsForLocale.js.map +1 -0
- package/guillotine/fetchFromApi.d.ts +3 -0
- package/guillotine/fetchFromApi.js +65 -0
- package/guillotine/fetchFromApi.js.map +1 -0
- package/guillotine/fetchGuillotine.d.ts +3 -0
- package/guillotine/fetchGuillotine.js +55 -0
- package/guillotine/fetchGuillotine.js.map +1 -0
- package/guillotine/fetchMetaData.d.ts +2 -0
- package/guillotine/fetchMetaData.js +30 -0
- package/guillotine/fetchMetaData.js.map +1 -0
- package/guillotine/getCleanContentPathArrayOrThrow400.d.ts +2 -0
- package/guillotine/getCleanContentPathArrayOrThrow400.js +20 -0
- package/guillotine/getCleanContentPathArrayOrThrow400.js.map +1 -0
- package/guillotine/getComponentConfig.d.ts +2 -0
- package/guillotine/getComponentConfig.js +5 -0
- package/guillotine/getComponentConfig.js.map +1 -0
- package/guillotine/getContentAndComponentPaths.d.ts +1 -0
- package/guillotine/getContentAndComponentPaths.js +12 -0
- package/guillotine/getContentAndComponentPaths.js.map +1 -0
- package/guillotine/getMetaData.d.ts +0 -92
- package/guillotine/getMetaData.js +47 -109
- package/guillotine/getMetaData.js.map +1 -0
- package/guillotine/getParentRegion.d.ts +2 -0
- package/guillotine/getParentRegion.js +40 -0
- package/guillotine/getParentRegion.js.map +1 -0
- package/guillotine/getQueryAndVariables.d.ts +2 -0
- package/guillotine/getQueryAndVariables.js +32 -0
- package/guillotine/getQueryAndVariables.js.map +1 -0
- package/guillotine/metadata/configQuery.d.ts +2 -0
- package/guillotine/metadata/configQuery.js +36 -0
- package/guillotine/metadata/configQuery.js.map +1 -0
- package/guillotine/metadata/richTextQuery.d.ts +1 -0
- package/guillotine/metadata/richTextQuery.js +32 -0
- package/guillotine/metadata/richTextQuery.js.map +1 -0
- package/guillotine/parseComponentPath.d.ts +2 -0
- package/guillotine/parseComponentPath.js +22 -0
- package/guillotine/parseComponentPath.js.map +1 -0
- package/guillotine/prefixLayoutPath.d.ts +1 -0
- package/guillotine/prefixLayoutPath.js +13 -0
- package/guillotine/prefixLayoutPath.js.map +1 -0
- package/guillotine/processComponentConfig.d.ts +2 -0
- package/guillotine/processComponentConfig.js +30 -0
- package/guillotine/processComponentConfig.js.map +1 -0
- package/guillotine/restrictComponentsToPath.d.ts +2 -0
- package/guillotine/restrictComponentsToPath.js +35 -0
- package/guillotine/restrictComponentsToPath.js.map +1 -0
- package/guillotine/validateData.d.ts +2 -0
- package/guillotine/validateData.js +7 -0
- package/guillotine/validateData.js.map +1 -0
- package/guillotine/validateNotFound.d.ts +2 -0
- package/guillotine/validateNotFound.js +16 -0
- package/guillotine/validateNotFound.js.map +1 -0
- package/guillotine/validateShortcut.d.ts +2 -0
- package/guillotine/validateShortcut.js +29 -0
- package/guillotine/validateShortcut.js.map +1 -0
- package/i18n/LocaleContext.d.ts +7 -0
- package/i18n/LocaleContext.jsx +46 -0
- package/i18n/LocaleContext.jsx.map +1 -0
- package/i18n/i18n.d.ts +11 -0
- package/i18n/i18n.js +57 -0
- package/i18n/i18n.js.map +1 -0
- package/index.d.ts +18 -5
- package/index.js +18 -5
- package/index.js.map +1 -0
- package/package.json +67 -16
- package/query/Shortcut.js +1 -0
- package/query/Shortcut.js.map +1 -0
- package/types/component.d.ts +114 -0
- package/types/component.js +2 -0
- package/types/component.js.map +1 -0
- package/types/componentProps.d.ts +104 -0
- package/types/componentProps.js +2 -0
- package/types/componentProps.js.map +1 -0
- package/types/guillotine.d.ts +342 -0
- package/types/guillotine.js +2 -0
- package/types/guillotine.js.map +1 -0
- package/types/i18n.d.ts +7 -0
- package/types/i18n.js +2 -0
- package/types/i18n.js.map +1 -0
- package/types/index.d.ts +45 -0
- package/types/index.js +3 -0
- package/types/index.js.map +1 -0
- package/types/next.d.ts +6 -0
- package/types/next.js +2 -0
- package/types/next.js.map +1 -0
- package/types/util.d.ts +3 -0
- package/types/util.js +3 -0
- package/types/util.js.map +1 -0
- package/utils/addLineNumbers.d.ts +1 -0
- package/utils/addLineNumbers.js +4 -0
- package/utils/addLineNumbers.js.map +1 -0
- package/utils/buildGuillotineRequestHeaders.d.ts +7 -0
- package/utils/buildGuillotineRequestHeaders.js +16 -0
- package/utils/buildGuillotineRequestHeaders.js.map +1 -0
- package/utils/commonChars.d.ts +1 -0
- package/utils/commonChars.js +17 -0
- package/utils/commonChars.js.map +1 -0
- package/utils/fixDoubleSlashes.d.ts +1 -0
- package/utils/fixDoubleSlashes.js +4 -0
- package/utils/fixDoubleSlashes.js.map +1 -0
- package/utils/getContentApiUrl.d.ts +2 -0
- package/utils/getContentApiUrl.js +15 -0
- package/utils/getContentApiUrl.js.map +1 -0
- package/utils/getProjectLocaleConfig.d.ts +2 -0
- package/utils/getProjectLocaleConfig.js +19 -0
- package/utils/getProjectLocaleConfig.js.map +1 -0
- package/utils/getProjectLocaleConfigById.d.ts +2 -0
- package/utils/getProjectLocaleConfigById.js +16 -0
- package/utils/getProjectLocaleConfigById.js.map +1 -0
- package/utils/getProjectLocaleConfigByLocale.d.ts +2 -0
- package/utils/getProjectLocaleConfigByLocale.js +13 -0
- package/utils/getProjectLocaleConfigByLocale.js.map +1 -0
- package/utils/getProjectLocaleConfigs.d.ts +2 -0
- package/utils/getProjectLocaleConfigs.js +30 -0
- package/utils/getProjectLocaleConfigs.js.map +1 -0
- package/utils/getProjectLocales.d.ts +1 -0
- package/utils/getProjectLocales.js +5 -0
- package/utils/getProjectLocales.js.map +1 -0
- package/utils/getRenderMode.d.ts +3 -0
- package/utils/getRenderMode.js +8 -0
- package/utils/getRenderMode.js.map +1 -0
- package/utils/getRequestLocaleInfo.d.ts +6 -0
- package/utils/getRequestLocaleInfo.js +26 -0
- package/utils/getRequestLocaleInfo.js.map +1 -0
- package/utils/getXpBaseUrl.d.ts +2 -0
- package/utils/getXpBaseUrl.js +8 -0
- package/utils/getXpBaseUrl.js.map +1 -0
- package/utils/indent.d.ts +1 -0
- package/utils/indent.js +5 -0
- package/utils/indent.js.map +1 -0
- package/utils/sanitizeGraphqlName.d.ts +1 -0
- package/utils/sanitizeGraphqlName.js +12 -0
- package/utils/sanitizeGraphqlName.js.map +1 -0
- package/views/BaseComponent.d.ts +5 -10
- package/views/BaseComponent.jsx +17 -6
- package/views/BaseComponent.jsx.map +1 -0
- package/views/BaseContent.d.ts +3 -3
- package/views/BaseContent.jsx +2 -5
- package/views/BaseContent.jsx.map +1 -0
- package/views/BaseLayout.d.ts +3 -16
- package/views/BaseLayout.jsx +3 -3
- package/views/BaseLayout.jsx.map +1 -0
- package/views/BaseMacro.d.ts +3 -13
- package/views/BaseMacro.jsx +4 -3
- package/views/BaseMacro.jsx.map +1 -0
- package/views/BasePage.d.ts +3 -18
- package/views/BasePage.jsx +3 -3
- package/views/BasePage.jsx.map +1 -0
- package/views/BasePart.d.ts +3 -18
- package/views/BasePart.jsx +3 -3
- package/views/BasePart.jsx.map +1 -0
- package/views/Empty.d.ts +2 -2
- package/views/Empty.jsx +2 -1
- package/views/Empty.jsx.map +1 -0
- package/views/Fragment.d.ts +3 -9
- package/views/Fragment.jsx +2 -2
- package/views/Fragment.jsx.map +1 -0
- package/views/MainView.d.ts +3 -3
- package/views/MainView.jsx +2 -2
- package/views/MainView.jsx.map +1 -0
- package/views/PropsView.d.ts +3 -0
- package/views/PropsView.jsx +21 -0
- package/views/PropsView.jsx.map +1 -0
- package/views/Region.d.ts +4 -17
- package/views/Region.jsx +2 -2
- package/views/Region.jsx.map +1 -0
- package/views/RichTextView.d.ts +3 -13
- package/views/RichTextView.jsx +6 -3
- package/views/RichTextView.jsx.map +1 -0
- package/views/SingleComponent.d.ts +3 -3
- package/views/SingleComponent.jsx +1 -2
- package/views/SingleComponent.jsx.map +1 -0
- package/views/StaticContent.d.ts +2 -6
- package/views/StaticContent.jsx +1 -0
- package/views/StaticContent.jsx.map +1 -0
- package/views/Text.d.ts +5 -5
- package/views/Text.jsx +1 -1
- package/views/Text.jsx.map +1 -0
- package/views/getClientHydratedHtml.d.ts +2 -0
- package/views/getClientHydratedHtml.jsx +9 -0
- package/views/getClientHydratedHtml.jsx.map +1 -0
- package/views/macros/DefaultMacro.d.ts +1 -1
- package/views/macros/DefaultMacro.jsx +1 -0
- package/views/macros/DefaultMacro.jsx.map +1 -0
- package/views/macros/DisableMacro.d.ts +1 -1
- package/views/macros/DisableMacro.jsx +1 -0
- package/views/macros/DisableMacro.jsx.map +1 -0
- package/ComponentRegistry.d.ts +0 -64
- package/server/ClearableFileCache.d.ts +0 -31
- package/server/ClearableFileCache.js +0 -472
- package/server/cache.d.ts +0 -2
- package/server/cache.js +0 -129
- package/server/index.d.ts +0 -5
- package/server/index.js +0 -132
- package/utils.d.ts +0 -114
- package/utils.js +0 -241
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import { ComponentRegistry } from '../common/ComponentRegistry';
|
|
2
|
+
import { configQuery } from './metadata/configQuery';
|
|
3
|
+
import { richTextQuery } from './metadata/richTextQuery';
|
|
4
|
+
import { indent } from '../utils/indent';
|
|
6
5
|
const partConfigQuery = () => {
|
|
7
6
|
return configQuery(ComponentRegistry.getParts());
|
|
8
7
|
};
|
|
@@ -12,117 +11,56 @@ const layoutConfigQuery = () => {
|
|
|
12
11
|
const pageConfigQuery = () => {
|
|
13
12
|
return configQuery(ComponentRegistry.getPages());
|
|
14
13
|
};
|
|
15
|
-
const configQuery = (list, includeAppName = true, canUseConfigAsJson = true) => {
|
|
16
|
-
const hasQueryList = (list === null || list === void 0 ? void 0 : list.filter(([key, def]) => def.configQuery)) || [];
|
|
17
|
-
if (hasQueryList.length === 0) {
|
|
18
|
-
return canUseConfigAsJson ? 'configAsJson' : '';
|
|
19
|
-
}
|
|
20
|
-
const configsByApp = {};
|
|
21
|
-
hasQueryList
|
|
22
|
-
.forEach((entry) => {
|
|
23
|
-
const nameParts = entry[0].split(':');
|
|
24
|
-
if (nameParts.length === 2) {
|
|
25
|
-
const sanitizedAppName = sanitizeGraphqlName(nameParts[0]);
|
|
26
|
-
let existingConfigs = configsByApp[sanitizedAppName];
|
|
27
|
-
if (!existingConfigs) {
|
|
28
|
-
existingConfigs = [];
|
|
29
|
-
configsByApp[sanitizedAppName] = existingConfigs;
|
|
30
|
-
}
|
|
31
|
-
existingConfigs.push(`${sanitizeGraphqlName(nameParts[1])}${entry[1].configQuery}`);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
// Still query for configAsJson if at least one item has no configQuery defined
|
|
35
|
-
const configAsJsonQuery = canUseConfigAsJson && hasQueryList.length < list.length ? 'configAsJson' : '';
|
|
36
|
-
if (!includeAppName) {
|
|
37
|
-
return `${configAsJsonQuery}
|
|
38
|
-
config {
|
|
39
|
-
${Object.values(configsByApp).reduce((arr, curr) => arr.concat(curr), []).join('\n')}
|
|
40
|
-
}`;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return `${configAsJsonQuery}
|
|
44
|
-
config {
|
|
45
|
-
${Object.entries(configsByApp).map(entry => entry[0] + '{\n' + entry[1].join('\n') + '\n}')}
|
|
46
|
-
}`;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
14
|
/*
|
|
50
15
|
IMPORTANT: make sure to transform your queries into functions too when using this function inside them !!!
|
|
51
16
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type
|
|
79
|
-
path
|
|
80
|
-
page {
|
|
81
|
-
descriptor
|
|
82
|
-
${pageConfigQuery()}
|
|
83
|
-
template {
|
|
84
|
-
_path
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
layout {
|
|
88
|
-
descriptor
|
|
89
|
-
${layoutConfigQuery()}
|
|
90
|
-
}
|
|
91
|
-
text {
|
|
92
|
-
${richTextQuery('value')}
|
|
93
|
-
}
|
|
94
|
-
part {
|
|
95
|
-
descriptor
|
|
96
|
-
${partConfigQuery()}
|
|
97
|
-
}
|
|
98
|
-
image {
|
|
99
|
-
caption
|
|
100
|
-
image {
|
|
101
|
-
imageUrl (type:absolute, scale: "width-768")
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
17
|
+
const componentsQuery = () => `type
|
|
18
|
+
path
|
|
19
|
+
page {
|
|
20
|
+
descriptor
|
|
21
|
+
${indent(pageConfigQuery(), 4)}
|
|
22
|
+
template {
|
|
23
|
+
_path
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
layout {
|
|
27
|
+
descriptor
|
|
28
|
+
${indent(layoutConfigQuery(), 4)}
|
|
29
|
+
}
|
|
30
|
+
text {
|
|
31
|
+
${indent(richTextQuery('value'), 4)}
|
|
32
|
+
}
|
|
33
|
+
part {
|
|
34
|
+
descriptor
|
|
35
|
+
${indent(partConfigQuery(), 4)}
|
|
36
|
+
}
|
|
37
|
+
image {
|
|
38
|
+
caption
|
|
39
|
+
image {
|
|
40
|
+
imageUrl (type:absolute, scale: "width-768")
|
|
41
|
+
}
|
|
42
|
+
}`;
|
|
105
43
|
// THIS QUERY DOES NOT SUPPORT NESTED FRAGMENTS
|
|
106
|
-
export const pageFragmentQuery = () => `
|
|
107
|
-
|
|
44
|
+
export const pageFragmentQuery = () => `components(resolveFragment: false, resolveTemplate: true) {
|
|
45
|
+
fragment {
|
|
46
|
+
id
|
|
108
47
|
fragment {
|
|
109
|
-
id
|
|
110
|
-
fragment {
|
|
111
48
|
components {
|
|
112
|
-
|
|
49
|
+
${indent(componentsQuery(), 16)}
|
|
113
50
|
}
|
|
114
|
-
}
|
|
115
51
|
}
|
|
116
|
-
|
|
117
|
-
|
|
52
|
+
}
|
|
53
|
+
${indent(componentsQuery(), 4)}
|
|
54
|
+
}`;
|
|
118
55
|
export function getMetaQuery(pageFragment) {
|
|
119
|
-
return `query($path:ID!){
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
56
|
+
return `query($path:ID!) {
|
|
57
|
+
guillotine {
|
|
58
|
+
get(key:$path) {
|
|
59
|
+
_path
|
|
60
|
+
type
|
|
61
|
+
${indent(pageFragment || '', 12)}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}`;
|
|
128
65
|
}
|
|
66
|
+
//# sourceMappingURL=getMetaData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMetaData.js","sourceRoot":"","sources":["../../src/guillotine/getMetaData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAGvC,MAAM,eAAe,GAAG,GAAW,EAAE;IACjC,OAAO,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAW,EAAE;IACnC,OAAO,WAAW,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,GAAW,EAAE;IACjC,OAAO,WAAW,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAGF;;GAEG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC;;;;EAI5B,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;;;;;;;EAO5B,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;;;EAG9B,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;;;;EAIjC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;;;;;;;EAO5B,CAAC;AAEH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC;;;;;EAKrC,MAAM,CAAC,eAAe,EAAE,EAAC,EAAE,CAAC;;;;EAI5B,MAAM,CAAC,eAAe,EAAE,EAAC,CAAC,CAAC;EAC3B,CAAC;AAEH,MAAM,UAAU,YAAY,CAAC,YAAqB;IAC9C,OAAO;;;;;EAKT,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,EAAE,CAAC;;;EAG9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { XP_COMPONENT_TYPE } from '../common/constants';
|
|
2
|
+
import { prefixLayoutPath } from './prefixLayoutPath';
|
|
3
|
+
export function getParentRegion(source, contentType, cmpPath, components = [], createMissing) {
|
|
4
|
+
let currentTree = source;
|
|
5
|
+
let currentRegion;
|
|
6
|
+
let parentPath = '';
|
|
7
|
+
for (let i = 0; i < cmpPath.length; i++) {
|
|
8
|
+
const pathFragment = cmpPath[i];
|
|
9
|
+
const regionName = pathFragment.region;
|
|
10
|
+
parentPath += `/${pathFragment.region}/${pathFragment.index}`;
|
|
11
|
+
currentRegion = currentTree[regionName];
|
|
12
|
+
if (!currentRegion) {
|
|
13
|
+
if (createMissing) {
|
|
14
|
+
currentRegion = {
|
|
15
|
+
name: regionName,
|
|
16
|
+
components: [],
|
|
17
|
+
};
|
|
18
|
+
currentTree[regionName] = currentRegion;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw `Region [${regionName}] was not found`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (i < cmpPath.length - 1) {
|
|
25
|
+
// look for layouts inside if this is not the last path fragment
|
|
26
|
+
const layout = components.find((cmp) => {
|
|
27
|
+
return cmp.type === XP_COMPONENT_TYPE.LAYOUT && prefixLayoutPath(contentType, cmp.path) === parentPath;
|
|
28
|
+
});
|
|
29
|
+
if (!layout) {
|
|
30
|
+
throw `Layout [${parentPath}] not found among components, but needed for component [${JSON.stringify(cmpPath, null, 2)}]`;
|
|
31
|
+
}
|
|
32
|
+
if (!layout.regions) {
|
|
33
|
+
layout.regions = {};
|
|
34
|
+
}
|
|
35
|
+
currentTree = layout.regions;
|
|
36
|
+
}
|
|
37
|
+
} // for
|
|
38
|
+
return currentRegion;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=getParentRegion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getParentRegion.js","sourceRoot":"","sources":["../../src/guillotine/getParentRegion.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGpD,MAAM,UAAU,eAAe,CAC3B,MAAkB,EAClB,WAAmB,EACnB,OAAuB,EACvB,aAA8B,EAAE,EAChC,aAAyB;IAEzB,IAAI,WAAW,GAAe,MAAM,CAAC;IACrC,IAAI,aAAqC,CAAC;IAC1C,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,YAA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Variables, SelectedQueryMaybeVariablesFunc } from '../types';
|
|
2
|
+
export declare function getQueryAndVariables(type: string, path: string, context: Context, selectedQuery?: SelectedQueryMaybeVariablesFunc, config?: any): QueryAndVariables | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function getQueryAndVariables(type, path, context, selectedQuery, config) {
|
|
2
|
+
let query, getVariables;
|
|
3
|
+
if (typeof selectedQuery === 'string' || typeof selectedQuery === 'function') {
|
|
4
|
+
query = selectedQuery;
|
|
5
|
+
}
|
|
6
|
+
else if (Array.isArray(selectedQuery)) {
|
|
7
|
+
query = selectedQuery[0];
|
|
8
|
+
getVariables = selectedQuery[1];
|
|
9
|
+
}
|
|
10
|
+
else if (typeof selectedQuery === 'object') {
|
|
11
|
+
query = selectedQuery.query;
|
|
12
|
+
getVariables = selectedQuery.variables;
|
|
13
|
+
}
|
|
14
|
+
if (getVariables && typeof getVariables !== 'function') {
|
|
15
|
+
throw Error(`getVariables for content type ${type} should be a function, not: ${typeof getVariables}`);
|
|
16
|
+
}
|
|
17
|
+
if (query && typeof query !== 'string' && typeof query !== 'function') {
|
|
18
|
+
throw Error(`Query for content type ${type} should be a string or function, not: ${typeof query}`);
|
|
19
|
+
}
|
|
20
|
+
if (typeof query === 'function') {
|
|
21
|
+
query = query(path, context, config);
|
|
22
|
+
}
|
|
23
|
+
if (query) {
|
|
24
|
+
return {
|
|
25
|
+
query,
|
|
26
|
+
variables: getVariables ? getVariables(path, context, config) : {
|
|
27
|
+
path,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getQueryAndVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getQueryAndVariables.js","sourceRoot":"","sources":["../../src/guillotine/getQueryAndVariables.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,oBAAoB,CAChC,IAAY,EACZ,IAAY,EACZ,OAAgB,EAChB,aAA+C,EAC/C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qlName';
|
|
2
|
+
export const configQuery = (list, includeAppName = true, canUseConfigAsJson = true) => {
|
|
3
|
+
const hasQueryList = (list === null || list === void 0 ? void 0 : list.filter(([key, def]) => def.configQuery)) || [];
|
|
4
|
+
if (hasQueryList.length === 0) {
|
|
5
|
+
return canUseConfigAsJson ? 'configAsJson' : '';
|
|
6
|
+
}
|
|
7
|
+
const configsByApp = {};
|
|
8
|
+
hasQueryList
|
|
9
|
+
.forEach((entry) => {
|
|
10
|
+
const nameParts = entry[0].split(':');
|
|
11
|
+
if (nameParts.length === 2) {
|
|
12
|
+
const sanitizedAppName = sanitizeGraphqlName(nameParts[0]);
|
|
13
|
+
let existingConfigs = configsByApp[sanitizedAppName];
|
|
14
|
+
if (!existingConfigs) {
|
|
15
|
+
existingConfigs = [];
|
|
16
|
+
configsByApp[sanitizedAppName] = existingConfigs;
|
|
17
|
+
}
|
|
18
|
+
existingConfigs.push(`${sanitizeGraphqlName(nameParts[1])}${entry[1].configQuery}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
// Still query for configAsJson if at least one item has no configQuery defined
|
|
22
|
+
const configAsJsonQuery = canUseConfigAsJson && hasQueryList.length < list.length ? 'configAsJson' : '';
|
|
23
|
+
if (!includeAppName) {
|
|
24
|
+
return `${configAsJsonQuery}
|
|
25
|
+
config {
|
|
26
|
+
${Object.values(configsByApp).reduce((arr, curr) => arr.concat(curr), []).join('\n')}
|
|
27
|
+
}`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return `${configAsJsonQuery}
|
|
31
|
+
config {
|
|
32
|
+
${Object.entries(configsByApp).map(entry => entry[0] + '{\n' + entry[1].join('\n') + '\n}')}
|
|
33
|
+
}`;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=configQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configQuery.js","sourceRoot":"","sources":["../../../src/guillotine/metadata/configQuery.ts"],"names":[],"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GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAExG,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,OAAO,GAAG,iBAAiB;;sBAEb,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;kBACtF,CAAC;IACf,CAAC;SAAM,CAAC;QACJ,OAAO,GAAG,iBAAiB;;sBAEb,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;kBAC7F,CAAC;IACf,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const richTextQuery: (fieldName: string) => string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentRegistry } from '../../common/ComponentRegistry';
|
|
2
|
+
import { configQuery } from './configQuery';
|
|
3
|
+
import { indent } from '../../utils/indent';
|
|
4
|
+
const macroConfigQuery = () => {
|
|
5
|
+
return configQuery(ComponentRegistry.getMacros(), false, false);
|
|
6
|
+
};
|
|
7
|
+
export const richTextQuery = (fieldName) => {
|
|
8
|
+
return `${fieldName}(processHtml:{type:absolute, imageWidths:[400, 800, 1200], imageSizes:"(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"}) {
|
|
9
|
+
processedHtml
|
|
10
|
+
macros {
|
|
11
|
+
ref
|
|
12
|
+
name
|
|
13
|
+
descriptor
|
|
14
|
+
${indent(macroConfigQuery(), 8)}
|
|
15
|
+
}
|
|
16
|
+
links {
|
|
17
|
+
ref
|
|
18
|
+
media {
|
|
19
|
+
content {
|
|
20
|
+
_id
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
images {
|
|
25
|
+
ref
|
|
26
|
+
image {
|
|
27
|
+
_id
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}`;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=richTextQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"richTextQuery.js","sourceRoot":"","sources":["../../../src/guillotine/metadata/richTextQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAG1C,MAAM,gBAAgB,GAAG,GAAW,EAAE;IAClC,OAAO,WAAW,CAAC,iBAAiB,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,OAAO,GAAG,SAAS;;;;;;UAMb,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;EAgBrC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FRAGMENT_CONTENTTYPE_NAME, FRAGMENT_DEFAULT_REGION_NAME, } from '../common/constants';
|
|
2
|
+
export function parseComponentPath(contentType, path) {
|
|
3
|
+
const matches = [];
|
|
4
|
+
let match;
|
|
5
|
+
const myRegexp = /(?:(\w+)\/(\d+))+/g;
|
|
6
|
+
while ((match = myRegexp.exec(path)) !== null) {
|
|
7
|
+
matches.push({
|
|
8
|
+
region: match[1],
|
|
9
|
+
index: +match[2],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (contentType === FRAGMENT_CONTENTTYPE_NAME) {
|
|
13
|
+
// there is no main region in fragment content and the root component has '/' path
|
|
14
|
+
// prepend FRAGMENT_DEFAULT_REGION_NAME to path to conform to page structure
|
|
15
|
+
matches.unshift({
|
|
16
|
+
region: FRAGMENT_DEFAULT_REGION_NAME,
|
|
17
|
+
index: 0,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return matches;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=parseComponentPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseComponentPath.js","sourceRoot":"","sources":["../../src/guillotine/parseComponentPath.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,yBAAyB,EACzB,4BAA4B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,kBAAkB,CAAC,WAAmB,EAAE,IAAY;IAChE,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,IAAI,KAAK,CAAC;IACV,MAAM,QAAQ,GAAG,oBAAoB,CAAC;IACtC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAChB,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SACnB,CAAC,CAAC;IACP,CAAC;IACD,IAAI,WAAW,KAAK,yBAAyB,EAAE,CAAC;QAC5C,kFAAkF;QAClF,4EAA4E;QAC5E,OAAO,CAAC,OAAO,CAAC;YACZ,MAAM,EAAE,4BAA4B;YACpC,KAAK,EAAE,CAAC;SACX,CAAC,CAAC;IACP,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prefixLayoutPath(contentType: string, path: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FRAGMENT_CONTENTTYPE_NAME, FRAGMENT_DEFAULT_REGION_NAME, } from '../common/constants';
|
|
2
|
+
export function prefixLayoutPath(contentType, path) {
|
|
3
|
+
if (contentType !== FRAGMENT_CONTENTTYPE_NAME) {
|
|
4
|
+
return path;
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
// prepend FRAGMENT_DEFAULT_REGION_NAME to path to conform to page structure
|
|
8
|
+
// so that component with path '/' becomes /FRAGMENT_DEFAULT_REGION_NAME/0
|
|
9
|
+
// path /left/1 becomes /FRAGMENT_DEFAULT_REGION_NAME/0/left/1
|
|
10
|
+
return `/${FRAGMENT_DEFAULT_REGION_NAME}/0${path === '/' ? '' : path}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=prefixLayoutPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixLayoutPath.js","sourceRoot":"","sources":["../../src/guillotine/prefixLayoutPath.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,yBAAyB,EACzB,4BAA4B,GAC/B,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,IAAY;IAC9D,IAAI,WAAW,KAAK,yBAAyB,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IAChB,CAAC;SAAM,CAAC;QACJ,4EAA4E;QAC5E,0EAA0E;QAC1E,8DAA8D;QAC9D,OAAO,IAAI,4BAA4B,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sanitizeGraphqlName } from '../utils/sanitizeGraphqlName';
|
|
2
|
+
export function processComponentConfig(myAppName, myAppNameDashed, cmp) {
|
|
3
|
+
const cmpData = cmp[cmp.type];
|
|
4
|
+
if (cmpData && 'descriptor' in cmpData && cmpData.descriptor) {
|
|
5
|
+
const [appName, cmpName] = cmpData.descriptor.split(':');
|
|
6
|
+
if (appName !== myAppName) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let config;
|
|
10
|
+
const configArray = [];
|
|
11
|
+
if ('configAsJson' in cmpData && cmpData.configAsJson && cmpData.configAsJson[myAppNameDashed]) {
|
|
12
|
+
config = cmpData.configAsJson[myAppNameDashed][cmpName];
|
|
13
|
+
if (config) {
|
|
14
|
+
configArray.push(config);
|
|
15
|
+
delete cmpData.configAsJson;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const sanitizedAppName = sanitizeGraphqlName(appName);
|
|
19
|
+
if ('config' in cmpData && cmpData.config && cmpData.config[sanitizedAppName]) {
|
|
20
|
+
config = cmpData.config[sanitizedAppName][sanitizeGraphqlName(cmpName)];
|
|
21
|
+
if (config) {
|
|
22
|
+
configArray.push(config);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (configArray.length) {
|
|
26
|
+
cmpData.config = Object.assign({}, ...configArray);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=processComponentConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processComponentConfig.js","sourceRoot":"","sources":["../../src/guillotine/processComponentConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAGjE,MAAM,UAAU,sBAAsB,CAClC,SAAiB,EACjB,eAAuB,EACvB,GAAkB;IAElB,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3D,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,IAAI,MAAM,CAAC;QACX,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,IAAI,cAAc,IAAI,OAAO,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC;YAC7F,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC;YACxD,IAAI,MAAM,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACzB,OAAO,OAAO,CAAC,YAAY,CAAC;YAChC,CAAC;QACL,CAAC;QACD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC5E,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;YACxE,IAAI,MAAM,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;QACL,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACrB,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,WAAW,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { XP_COMPONENT_TYPE } from '../common/constants';
|
|
2
|
+
import { parseComponentPath } from './parseComponentPath';
|
|
3
|
+
export function restrictComponentsToPath(contentType, components, componentPath) {
|
|
4
|
+
if (!componentPath || !(components === null || components === void 0 ? void 0 : components.length)) {
|
|
5
|
+
return components || [];
|
|
6
|
+
}
|
|
7
|
+
// filter components to the requested one only
|
|
8
|
+
const component = components.find(cmp => {
|
|
9
|
+
return cmp.path === componentPath;
|
|
10
|
+
});
|
|
11
|
+
if (!component) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
let result = [component];
|
|
15
|
+
if (component.type !== XP_COMPONENT_TYPE.LAYOUT) {
|
|
16
|
+
// remember to include all parent layouts too !
|
|
17
|
+
const cmpPath = parseComponentPath(contentType, component.path);
|
|
18
|
+
for (let i = cmpPath.length - 2; i >= 0; i--) {
|
|
19
|
+
const parentPath = cmpPath[i];
|
|
20
|
+
const parentCmp = components.find(cmp => cmp.path === `/${parentPath.region}/${parentPath.index}`);
|
|
21
|
+
if (parentCmp) {
|
|
22
|
+
result.unshift(parentCmp);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// It's a layout, include child components
|
|
28
|
+
const childCmps = components.filter(cmp => cmp.path !== component.path && cmp.path.startsWith(component.path));
|
|
29
|
+
if (childCmps.length) {
|
|
30
|
+
result = result.concat(childCmps);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=restrictComponentsToPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restrictComponentsToPath.js","sourceRoot":"","sources":["../../src/guillotine/restrictComponentsToPath.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAGxD,MAAM,UAAU,wBAAwB,CACpC,WAAmB,EACnB,UAA4B,EAC5B,aAAsB;IAEtB,IAAI,CAAC,aAAa,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAA,EAAE,CAAC;QACxC,OAAO,UAAU,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,8CAA8C;IAC9C,MAAM,SAAS,GAAG,U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|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateData.js","sourceRoot":"","sources":["../../src/guillotine/validateData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAGpD,MAAM,UAAU,YAAY,CAAC,KAAyB;IAClD,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACxB,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { notFound } from 'next/navigation';
|
|
2
|
+
export function validateNotFound(props) {
|
|
3
|
+
const { error } = props;
|
|
4
|
+
if (error) {
|
|
5
|
+
switch (error.code) {
|
|
6
|
+
case '404':
|
|
7
|
+
console.warn(error.code, error.message);
|
|
8
|
+
notFound();
|
|
9
|
+
break;
|
|
10
|
+
default:
|
|
11
|
+
console.error(error.code, error.message);
|
|
12
|
+
throw new Error(error.message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=validateNotFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateNotFound.js","sourceRoot":"","sources":["../../src/guillotine/validateNotFound.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAGzC,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACtD,MAAM,EAAC,KAAK,EAAC,GAAG,KAAK,CAAC;IACtB,IAAI,KAAK,EAAE,CAAC;QACR,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,KAAK;gBACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxC,QAAQ,EAAE,CAAC;gBACX,MAAM;YACV;gBACI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { notFound, redirect, RedirectType } from 'next/navigation';
|
|
2
|
+
import { RENDER_MODE } from '../common/constants';
|
|
3
|
+
import { IS_DEV_MODE } from '../common/env';
|
|
4
|
+
import { UrlProcessor } from '../common/UrlProcessor';
|
|
5
|
+
export function validateShortcut(props) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const { data, meta, error } = props;
|
|
8
|
+
const pageUrl = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.get) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.pageUrl;
|
|
9
|
+
if (meta.type === 'base:shortcut' && pageUrl) {
|
|
10
|
+
if (meta.renderMode !== RENDER_MODE.NEXT) {
|
|
11
|
+
// do not show shortcut targets in preview/edit mode
|
|
12
|
+
console.warn(404, `Shortcuts are not available in ${RENDER_MODE.NEXT} render mode`);
|
|
13
|
+
notFound();
|
|
14
|
+
}
|
|
15
|
+
const destination = UrlProcessor.process(pageUrl, meta, true);
|
|
16
|
+
console.debug(`Redirecting shortcut content [${meta.path}] to`, destination);
|
|
17
|
+
redirect(destination, RedirectType.replace);
|
|
18
|
+
}
|
|
19
|
+
// we can not set 418 for static paths,
|
|
20
|
+
// but we can show 404 instead to be handled in CS
|
|
21
|
+
const canNotRender = meta && !meta.canRender && meta.renderMode !== RENDER_MODE.EDIT;
|
|
22
|
+
const catchAllInNextProdMode = meta.renderMode === RENDER_MODE.NEXT && !IS_DEV_MODE && meta.catchAll;
|
|
23
|
+
const isNotFound = (error && error.code === '404') || canNotRender || catchAllInNextProdMode;
|
|
24
|
+
if (isNotFound) {
|
|
25
|
+
console.warn(404, `Can not render content at [${meta.path}]`);
|
|
26
|
+
notFound();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=validateShortcut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateShortcut.js","sourceRoot":"","sources":["../../src/guillotine/validateShortcut.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAGpD,MAAM,UAAU,gBAAgB,CAAC,KAAyB;;IACtD,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;IAClC,MAAM,OAAO,GAAG,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,0CAAE,IAAI,0CAAE,MAAM,0CAAE,OAAO,CAAC;IACjD,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,OAAO,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;YACvC,oDAAoD;YACpD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,kCAAkC,WAAW,CAAC,IAAI,cAAc,CAAC,CAAC;YACpF,QAAQ,EAAE,CAAC;QACf,CAAC;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,IAAI,MAAM,EAAE,WAAW,CAAC,CAAC;QAC7E,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,uCAAuC;IACvC,kDAAkD;IAClD,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,WAAW,CAAC,IAAI,CAAC;IAErF,MAAM,sBAAsB,GAAG,IAAI,CAAC,UAAU,KAAK,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC;IAErG,MAAM,UAAU,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,YAAY,IAAI,sBAAsB,CAAC;IAE7F,IAAI,UAAU,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,8BAA8B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9D,QAAQ,EAAE,CAAC;IACf,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LocaleContextType } from '../types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const useLocaleContext: () => LocaleContextType;
|
|
4
|
+
export declare const LocaleContextProvider: ({ children, locale: localeProps, }: {
|
|
5
|
+
children: any;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
12
|
+
import { getPhrase, loadPhrases } from './i18n';
|
|
13
|
+
const LocaleContext = createContext({
|
|
14
|
+
dictionary: {},
|
|
15
|
+
locale: '',
|
|
16
|
+
localize: (key, ...args) => key,
|
|
17
|
+
setLocale: (locale) => Promise.resolve({}),
|
|
18
|
+
});
|
|
19
|
+
export const useLocaleContext = () => useContext(LocaleContext);
|
|
20
|
+
export const LocaleContextProvider = ({ children, locale: localeProps = '', }) => {
|
|
21
|
+
const [currentLocale, setLocaleState] = useState(localeProps);
|
|
22
|
+
const [dictionary, setPhrasesState] = useState({});
|
|
23
|
+
const setLocale = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
setLocaleState(locale);
|
|
25
|
+
return loadPhrases(locale).then((phrases) => {
|
|
26
|
+
setPhrasesState(phrases);
|
|
27
|
+
console.info(`Loaded client-side phrases for locale "${locale}"`);
|
|
28
|
+
return phrases;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (localeProps) {
|
|
33
|
+
void setLocale(localeProps); // void to avoid @typescript-eslint/no-floating-promises
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
36
|
+
const localize = (key, ...args) => getPhrase(currentLocale, dictionary, key, ...args);
|
|
37
|
+
return (<LocaleContext.Provider value={{
|
|
38
|
+
setLocale,
|
|
39
|
+
locale: currentLocale,
|
|
40
|
+
dictionary,
|
|
41
|
+
localize,
|
|
42
|
+
}}>
|
|
43
|
+
{children}
|
|
44
|
+
</LocaleContext.Provider>);
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=LocaleContext.jsx.map
|