@bright.global/arboretum-sdk 0.0.9 → 0.1.0-rc.1
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/es6/impl/arboretum-client.impl.js +13 -13
- package/dist/es6/impl/data/helpers/get-all-entries-recursively.js +21 -4
- package/dist/es6/impl/data/page-entries.js +9 -30
- package/dist/es6/impl/sitemap/adapters/page-entry-adapter.js +19 -9
- package/dist/es6/impl/sitemap/adapters/to-arboretum-page-with-missing-data-adapter.js +1 -0
- package/dist/es6/impl/sitemap/helpers/build-localized-sitemap.js +56 -12
- package/dist/impl/arboretum-client.impl.js +13 -13
- package/dist/impl/data/helpers/get-all-entries-recursively.js +21 -4
- package/dist/impl/data/page-entries.js +9 -30
- package/dist/impl/sitemap/adapters/page-entry-adapter.js +18 -8
- package/dist/impl/sitemap/adapters/to-arboretum-page-with-missing-data-adapter.js +1 -0
- package/dist/impl/sitemap/helpers/build-localized-sitemap.js +52 -8
- package/dist/types/arboretum-client.d.ts +9 -3
- package/dist/types/impl/arboretum-client.impl.d.ts +3 -0
- package/dist/types/impl/sitemap/adapters/page-entry-adapter.d.ts +4 -4
- package/dist/types/impl/sitemap/helpers/build-localized-sitemap.d.ts +5 -5
- package/package.json +1 -1
|
@@ -108,9 +108,9 @@ var arboretumConfigOptions = function (config) {
|
|
|
108
108
|
};
|
|
109
109
|
export var createArboretumClient = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
110
|
var clientApi, cmaPreviewClientApi, includeEntryStatus, options, sitemapDataCtx, dataE, _a, c, sitemap, pagesByTagIdRecord, ctx_1;
|
|
111
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
112
|
-
return __generator(this, function (
|
|
113
|
-
switch (
|
|
111
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
112
|
+
return __generator(this, function (_k) {
|
|
113
|
+
switch (_k.label) {
|
|
114
114
|
case 0:
|
|
115
115
|
clientApi = createContentfulClient(config);
|
|
116
116
|
cmaPreviewClientApi = config.type === "cma-client"
|
|
@@ -119,11 +119,11 @@ export var createArboretumClient = function (config) { return __awaiter(void 0,
|
|
|
119
119
|
includeEntryStatus = config.type === "cma-client" ? !!((_b = config.options) === null || _b === void 0 ? void 0 : _b.includeEntryStatus) : false;
|
|
120
120
|
return [4 /*yield*/, arboretumConfigOptions(config)];
|
|
121
121
|
case 1:
|
|
122
|
-
options =
|
|
122
|
+
options = _k.sent();
|
|
123
123
|
sitemapDataCtx = {
|
|
124
124
|
preview: config.preview,
|
|
125
125
|
clientApi: clientApi,
|
|
126
|
-
options: __assign(__assign({}, options), { includeEntryStatus: includeEntryStatus }),
|
|
126
|
+
options: __assign(__assign({}, options), { includeEntryStatus: includeEntryStatus, sitemapRepresentation: (_c = config.options) === null || _c === void 0 ? void 0 : _c.sitemapRepresentation }),
|
|
127
127
|
localeTagIdPrefix: localeTagIdPrefix,
|
|
128
128
|
pageHomeTagId: options.homePageTagId || pageHomeTagId,
|
|
129
129
|
contentfulClientType: config.type === "cda-client" && config.contentful.client.withAllLocales
|
|
@@ -132,25 +132,25 @@ export var createArboretumClient = function (config) { return __awaiter(void 0,
|
|
|
132
132
|
pageTagIdPrefix: pageTagIdPrefix,
|
|
133
133
|
cmaPreviewClientApi: cmaPreviewClientApi,
|
|
134
134
|
};
|
|
135
|
-
if (!((
|
|
136
|
-
_a = right({ data: (
|
|
135
|
+
if (!((_d = config.options) === null || _d === void 0 ? void 0 : _d.data)) return [3 /*break*/, 2];
|
|
136
|
+
_a = right({ data: (_e = config.options) === null || _e === void 0 ? void 0 : _e.data.data, warnings: undefined });
|
|
137
137
|
return [3 /*break*/, 4];
|
|
138
138
|
case 2: return [4 /*yield*/, sitemapData(sitemapDataCtx)];
|
|
139
139
|
case 3:
|
|
140
|
-
_a =
|
|
141
|
-
|
|
140
|
+
_a = _k.sent();
|
|
141
|
+
_k.label = 4;
|
|
142
142
|
case 4:
|
|
143
143
|
dataE = _a;
|
|
144
144
|
if (dataE._tag === "Right") {
|
|
145
145
|
c = __assign(__assign({}, sitemapDataCtx), { data: dataE.right.data });
|
|
146
|
-
sitemap = ((
|
|
146
|
+
sitemap = ((_f = config.options) === null || _f === void 0 ? void 0 : _f.data)
|
|
147
147
|
? config.options.data.sitemap
|
|
148
|
-
: ((
|
|
148
|
+
: ((_g = config.options) === null || _g === void 0 ? void 0 : _g.eagerly)
|
|
149
149
|
? buildSitemapEagerly(c, dataE.right.data.locales)
|
|
150
150
|
: new Map();
|
|
151
|
-
pagesByTagIdRecord = ((
|
|
151
|
+
pagesByTagIdRecord = ((_h = config.options) === null || _h === void 0 ? void 0 : _h.data)
|
|
152
152
|
? config.options.data.pagesByTagId
|
|
153
|
-
: ((
|
|
153
|
+
: ((_j = config.options) === null || _j === void 0 ? void 0 : _j.eagerly)
|
|
154
154
|
? buildPagesByTagEagerly(__assign(__assign({}, c), { sitemap: sitemap }), dataE.right.data.locales)
|
|
155
155
|
: new Map();
|
|
156
156
|
ctx_1 = __assign(__assign({}, c), { data: dataE.right.data, sitemap: sitemap, pagesByTagId: pagesByTagIdRecord, lastUpdatedAt: new Date().toISOString(), regenerationInProgress: false });
|
|
@@ -93,10 +93,27 @@ export var getAllEntriesRecursively = function (_a, contentfulClientType, conten
|
|
|
93
93
|
skip: skip,
|
|
94
94
|
content_type: contentType,
|
|
95
95
|
include: 0,
|
|
96
|
-
select:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
97
|
+
{
|
|
98
|
+
"status": 400,
|
|
99
|
+
"statusText": "Bad Request",
|
|
100
|
+
"message": "The query you sent was invalid. Probably a filter or ordering specification is not applicable to the type of a field.",
|
|
101
|
+
"details": {
|
|
102
|
+
"errors": [
|
|
103
|
+
{
|
|
104
|
+
"name": "select",
|
|
105
|
+
"details": "Select is only applicable when querying a collection of entities."
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"request": {
|
|
110
|
+
"url": "/spaces/8h4rcnu50txt/environments/dacjan-test/public/entries",
|
|
111
|
+
"method": "get",
|
|
112
|
+
...
|
|
113
|
+
},
|
|
114
|
+
}*/
|
|
115
|
+
select: contentfulClientType !== "cma-client" ? select : undefined,
|
|
116
|
+
locale: contentfulClientType === "cda-client-with-all-locales" ? undefined : "*",
|
|
100
117
|
})];
|
|
101
118
|
case 1:
|
|
102
119
|
items = (_b.sent()).items;
|
|
@@ -76,36 +76,8 @@ import { arrayToMap } from "../../utils/array-to-map";
|
|
|
76
76
|
var getAllPageEntriesRecursively = function (_a, contentfulClientType, pageContentTypeOpt, skip, acc, select) {
|
|
77
77
|
var getEntries = _a.getEntries;
|
|
78
78
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var fieldsSelect;
|
|
80
79
|
return __generator(this, function (_b) {
|
|
81
|
-
|
|
82
|
-
pageContentTypeOpt.slugFieldId,
|
|
83
|
-
pageContentTypeOpt.childPagesFieldId,
|
|
84
|
-
pageContentTypeOpt.titleFieldId,
|
|
85
|
-
].flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
86
|
-
return [2 /*return*/, getAllEntriesRecursively({ getEntries: getEntries }, contentfulClientType, pageContentTypeOpt.id, skip, acc,
|
|
87
|
-
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
88
|
-
{
|
|
89
|
-
"status": 400,
|
|
90
|
-
"statusText": "Bad Request",
|
|
91
|
-
"message": "The query you sent was invalid. Probably a filter or ordering specification is not applicable to the type of a field.",
|
|
92
|
-
"details": {
|
|
93
|
-
"errors": [
|
|
94
|
-
{
|
|
95
|
-
"name": "select",
|
|
96
|
-
"details": "Select is only applicable when querying a collection of entities."
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
},
|
|
100
|
-
"request": {
|
|
101
|
-
"url": "/spaces/8h4rcnu50txt/environments/dacjan-test/public/entries",
|
|
102
|
-
"method": "get",
|
|
103
|
-
...
|
|
104
|
-
},
|
|
105
|
-
}*/
|
|
106
|
-
select || contentfulClientType === "cma-client"
|
|
107
|
-
? undefined
|
|
108
|
-
: __spreadArray(["sys", "metadata"], __read(fieldsSelect), false).join(","), pageContentTypeOpt.childPagesFieldId
|
|
80
|
+
return [2 /*return*/, getAllEntriesRecursively({ getEntries: getEntries }, contentfulClientType, pageContentTypeOpt.id, skip, acc, select, pageContentTypeOpt.childPagesFieldId
|
|
109
81
|
? [pageContentTypeOpt.childPagesFieldId]
|
|
110
82
|
: [])];
|
|
111
83
|
});
|
|
@@ -141,7 +113,14 @@ export var pageEntries = function (ctx, apiClient, cmaPreviewClientApi) { return
|
|
|
141
113
|
pageContentTypes = Object.entries(options.pageContentTypes);
|
|
142
114
|
pageEntriesPromise = Promise.all(pageContentTypes.map(function (_a) {
|
|
143
115
|
var _b = __read(_a, 2), id = _b[0], fieldIds = _b[1];
|
|
144
|
-
|
|
116
|
+
var fieldsSelect = __spreadArray([
|
|
117
|
+
fieldIds.slugFieldId,
|
|
118
|
+
fieldIds.childPagesFieldId,
|
|
119
|
+
fieldIds.titleFieldId,
|
|
120
|
+
fieldIds.parentPageFieldId
|
|
121
|
+
], __read((fieldIds.select || [])), false).flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
122
|
+
var select = __spreadArray(["sys", "metadata"], __read(fieldsSelect), false).join(",");
|
|
123
|
+
return getAllPageEntriesRecursively(apiClient, ctx.contentfulClientType, __assign({ id: id }, fieldIds), 0, [], select);
|
|
145
124
|
}));
|
|
146
125
|
statusRecordPromise = ctx.options.includeEntryStatus &&
|
|
147
126
|
ctx.contentfulClientType === "cma-client" &&
|
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
import { localizeField } from
|
|
2
|
-
export var pageEntryAdapter = function (data, slugField, titleField,
|
|
1
|
+
import { localizeField } from "../helpers/localize-contentful-field";
|
|
2
|
+
export var pageEntryAdapter = function (data, options, slugField, titleField, childrenRefs, locale, parent, entry) {
|
|
3
3
|
var _a;
|
|
4
4
|
var fieldValue = localizeField(data, locale);
|
|
5
5
|
var slug = (_a = fieldValue(slugField.localized, entry.fields[slugField.id])) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
6
6
|
var title = titleField
|
|
7
7
|
? fieldValue(titleField.localized, entry.fields[titleField.id])
|
|
8
8
|
: undefined;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
var contentTypeId = entry.sys.contentType.sys.id;
|
|
10
|
+
var additionalFields = (options.pageContentTypes[contentTypeId].select || []).reduce(function (acc, fieldId) {
|
|
11
|
+
var contentType = data.contentTypes.get(contentTypeId);
|
|
12
|
+
if (contentType) {
|
|
13
|
+
var field = contentType.fields.get(fieldId);
|
|
14
|
+
var value = field
|
|
15
|
+
? fieldValue(field.localized, entry.fields[field.id])
|
|
16
|
+
: undefined;
|
|
17
|
+
acc[fieldId] = value;
|
|
18
|
+
}
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
12
21
|
return slug
|
|
13
22
|
? {
|
|
14
|
-
type:
|
|
23
|
+
type: "page",
|
|
15
24
|
parent: parent ? { sys: parent.sys } : undefined,
|
|
16
|
-
path: parent ? parent.path +
|
|
25
|
+
path: parent ? parent.path + "/" + slug : "/" + locale.code,
|
|
17
26
|
slug: slug,
|
|
18
27
|
title: title || undefined,
|
|
19
28
|
sys: {
|
|
20
29
|
id: entry.sys.id,
|
|
21
30
|
cmaOnlyStatus: entry.sys.cmaOnlyStatus,
|
|
22
|
-
contentTypeId:
|
|
31
|
+
contentTypeId: contentTypeId,
|
|
23
32
|
},
|
|
24
33
|
metadata: entry.metadata,
|
|
25
|
-
childPages: (
|
|
34
|
+
childPages: (childrenRefs === null || childrenRefs === void 0 ? void 0 : childrenRefs.flatMap(function (childPage) { var _a; return ((_a = childPage === null || childPage === void 0 ? void 0 : childPage.sys) === null || _a === void 0 ? void 0 : _a.id) ? [{ sys: { id: childPage === null || childPage === void 0 ? void 0 : childPage.sys.id } }] : []; })) || [],
|
|
35
|
+
additionalFields: additionalFields,
|
|
26
36
|
}
|
|
27
37
|
: undefined;
|
|
28
38
|
};
|
|
@@ -34,10 +34,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
34
34
|
}
|
|
35
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
36
|
};
|
|
37
|
-
import { left, right } from
|
|
38
|
-
import { pageEntryAdapter } from
|
|
39
|
-
import { redirectEntryAdapter } from
|
|
40
|
-
import { isRoot } from
|
|
37
|
+
import { left, right } from "../../../utils/fp-utils";
|
|
38
|
+
import { pageEntryAdapter } from "../adapters/page-entry-adapter";
|
|
39
|
+
import { redirectEntryAdapter } from "../adapters/redirect-entry-adapter";
|
|
40
|
+
import { isRoot } from "./is-root";
|
|
41
|
+
import { localizeField } from "./localize-contentful-field";
|
|
41
42
|
var getAllRedirects = function (data, options, locale, parent) {
|
|
42
43
|
var redirectContentType = options.id
|
|
43
44
|
? data.contentTypes.get(options.id)
|
|
@@ -58,15 +59,49 @@ var getAllRedirects = function (data, options, locale, parent) {
|
|
|
58
59
|
return redirect ? [redirect] : [];
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
var findPageFieldF = function (data, options, pageContentTypeId) {
|
|
63
|
+
return function (fieldId) {
|
|
64
|
+
var contentTypes = data.contentTypes;
|
|
65
|
+
var pageContentType = contentTypes.get(pageContentTypeId);
|
|
66
|
+
var pageContentTypeConfig = options.pageContentTypes[pageContentTypeId];
|
|
66
67
|
return pageContentType && pageContentTypeConfig
|
|
67
68
|
? pageContentType.fields.get(fieldId)
|
|
68
69
|
: undefined;
|
|
69
70
|
};
|
|
71
|
+
};
|
|
72
|
+
var getChildrenRefsByParentId = function (data, locale, options) {
|
|
73
|
+
var pages = data.pages;
|
|
74
|
+
var acc = new Map();
|
|
75
|
+
pages.forEach(function (page) {
|
|
76
|
+
var _a;
|
|
77
|
+
var pageContentTypeConfig = options.pageContentTypes[page.sys.contentType.sys.id];
|
|
78
|
+
var findPageField = findPageFieldF(data, options, page.sys.contentType.sys.id);
|
|
79
|
+
var parentPageField = pageContentTypeConfig.parentPageFieldId
|
|
80
|
+
? findPageField(pageContentTypeConfig.parentPageFieldId)
|
|
81
|
+
: undefined;
|
|
82
|
+
var fieldValue = localizeField(data, locale);
|
|
83
|
+
var parentPage = parentPageField
|
|
84
|
+
? fieldValue(parentPageField.localized, page.fields[parentPageField.id])
|
|
85
|
+
: undefined;
|
|
86
|
+
var parentPageId = (_a = parentPage === null || parentPage === void 0 ? void 0 : parentPage.sys) === null || _a === void 0 ? void 0 : _a.id;
|
|
87
|
+
if (parentPageId) {
|
|
88
|
+
var pageRef = { sys: { id: page.sys.id } };
|
|
89
|
+
var maybePages = acc.get(parentPageId);
|
|
90
|
+
if (maybePages) {
|
|
91
|
+
maybePages.push(pageRef);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
acc.set(parentPageId, [pageRef]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return acc;
|
|
99
|
+
};
|
|
100
|
+
var buildLocalizedSitemapArrRecursively = function (data, options, locale, parent, childrenRefsByPageId, pageEntry, acc) {
|
|
101
|
+
var _a;
|
|
102
|
+
var pages = data.pages;
|
|
103
|
+
var pageContentTypeConfig = options.pageContentTypes[pageEntry.sys.contentType.sys.id];
|
|
104
|
+
var findPageField = findPageFieldF(data, options, pageEntry.sys.contentType.sys.id);
|
|
70
105
|
var slugField = findPageField(pageContentTypeConfig.slugFieldId);
|
|
71
106
|
var titleField = pageContentTypeConfig.titleFieldId
|
|
72
107
|
? findPageField(pageContentTypeConfig.titleFieldId)
|
|
@@ -74,8 +109,14 @@ var buildLocalizedSitemapArrRecursively = function (data, options, locale, paren
|
|
|
74
109
|
var childPagesField = pageContentTypeConfig.childPagesFieldId
|
|
75
110
|
? findPageField(pageContentTypeConfig.childPagesFieldId)
|
|
76
111
|
: undefined;
|
|
112
|
+
var fieldValue = localizeField(data, locale);
|
|
113
|
+
var childrenRefs = childrenRefsByPageId
|
|
114
|
+
? childrenRefsByPageId.get(pageEntry.sys.id) || []
|
|
115
|
+
: childPagesField
|
|
116
|
+
? ((_a = fieldValue(childPagesField.localized, pageEntry.fields[childPagesField.id])) === null || _a === void 0 ? void 0 : _a.flatMap(function (childPage) { var _a; return ((_a = childPage === null || childPage === void 0 ? void 0 : childPage.sys) === null || _a === void 0 ? void 0 : _a.id) ? [{ sys: { id: childPage === null || childPage === void 0 ? void 0 : childPage.sys.id } }] : []; })) || []
|
|
117
|
+
: [];
|
|
77
118
|
var page = slugField
|
|
78
|
-
? pageEntryAdapter(data, slugField, titleField,
|
|
119
|
+
? pageEntryAdapter(data, options, slugField, titleField, childrenRefs, locale, parent, pageEntry)
|
|
79
120
|
: undefined;
|
|
80
121
|
if (page) {
|
|
81
122
|
var validChildPages_1 = page.childPages.filter(function (c) { return pages.get(c.sys.id) && !acc.get(c.sys.id); });
|
|
@@ -93,7 +134,7 @@ var buildLocalizedSitemapArrRecursively = function (data, options, locale, paren
|
|
|
93
134
|
var id = _a.sys.id;
|
|
94
135
|
var childPageEntry = pages.get(id);
|
|
95
136
|
childPageEntry &&
|
|
96
|
-
buildLocalizedSitemapArrRecursively(data, options, locale, { sys: pageEntry.sys, path: page.path }, childPageEntry, acc);
|
|
137
|
+
buildLocalizedSitemapArrRecursively(data, options, locale, { sys: pageEntry.sys, path: page.path }, childrenRefsByPageId, childPageEntry, acc);
|
|
97
138
|
});
|
|
98
139
|
return acc;
|
|
99
140
|
}
|
|
@@ -107,7 +148,10 @@ export var buildLocalizedSitemap = function (data, options, pageHomeTagId, local
|
|
|
107
148
|
var homePageRef = (_d = (_c = (_b = (_a = homePagesByTagId === null || homePagesByTagId === void 0 ? void 0 : homePagesByTagId.get(locale.code)) === null || _a === void 0 ? void 0 : _a.get(pageHomeTagId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.sys) === null || _d === void 0 ? void 0 : _d.id;
|
|
108
149
|
var homePageEntry = homePageRef ? pages.get(homePageRef) : undefined;
|
|
109
150
|
if (homePageEntry) {
|
|
110
|
-
var
|
|
151
|
+
var childrenRefsByPageId = options.sitemapRepresentation === "child-to-parent"
|
|
152
|
+
? getChildrenRefsByParentId(data, locale, options)
|
|
153
|
+
: undefined;
|
|
154
|
+
var sitemap = buildLocalizedSitemapArrRecursively(data, options, locale, undefined, childrenRefsByPageId, homePageEntry, new Map());
|
|
111
155
|
return right({
|
|
112
156
|
root: { sys: homePageEntry.sys },
|
|
113
157
|
sitemap: sitemap,
|
|
@@ -111,9 +111,9 @@ var arboretumConfigOptions = function (config) {
|
|
|
111
111
|
};
|
|
112
112
|
var createArboretumClient = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
113
|
var clientApi, cmaPreviewClientApi, includeEntryStatus, options, sitemapDataCtx, dataE, _a, c, sitemap, pagesByTagIdRecord, ctx_1;
|
|
114
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
115
|
-
return __generator(this, function (
|
|
116
|
-
switch (
|
|
114
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
115
|
+
return __generator(this, function (_k) {
|
|
116
|
+
switch (_k.label) {
|
|
117
117
|
case 0:
|
|
118
118
|
clientApi = (0, contentful_client_impl_1.createContentfulClient)(config);
|
|
119
119
|
cmaPreviewClientApi = config.type === "cma-client"
|
|
@@ -122,11 +122,11 @@ var createArboretumClient = function (config) { return __awaiter(void 0, void 0,
|
|
|
122
122
|
includeEntryStatus = config.type === "cma-client" ? !!((_b = config.options) === null || _b === void 0 ? void 0 : _b.includeEntryStatus) : false;
|
|
123
123
|
return [4 /*yield*/, arboretumConfigOptions(config)];
|
|
124
124
|
case 1:
|
|
125
|
-
options =
|
|
125
|
+
options = _k.sent();
|
|
126
126
|
sitemapDataCtx = {
|
|
127
127
|
preview: config.preview,
|
|
128
128
|
clientApi: clientApi,
|
|
129
|
-
options: __assign(__assign({}, options), { includeEntryStatus: includeEntryStatus }),
|
|
129
|
+
options: __assign(__assign({}, options), { includeEntryStatus: includeEntryStatus, sitemapRepresentation: (_c = config.options) === null || _c === void 0 ? void 0 : _c.sitemapRepresentation }),
|
|
130
130
|
localeTagIdPrefix: localeTagIdPrefix,
|
|
131
131
|
pageHomeTagId: options.homePageTagId || pageHomeTagId,
|
|
132
132
|
contentfulClientType: config.type === "cda-client" && config.contentful.client.withAllLocales
|
|
@@ -135,25 +135,25 @@ var createArboretumClient = function (config) { return __awaiter(void 0, void 0,
|
|
|
135
135
|
pageTagIdPrefix: pageTagIdPrefix,
|
|
136
136
|
cmaPreviewClientApi: cmaPreviewClientApi,
|
|
137
137
|
};
|
|
138
|
-
if (!((
|
|
139
|
-
_a = (0, fp_utils_1.right)({ data: (
|
|
138
|
+
if (!((_d = config.options) === null || _d === void 0 ? void 0 : _d.data)) return [3 /*break*/, 2];
|
|
139
|
+
_a = (0, fp_utils_1.right)({ data: (_e = config.options) === null || _e === void 0 ? void 0 : _e.data.data, warnings: undefined });
|
|
140
140
|
return [3 /*break*/, 4];
|
|
141
141
|
case 2: return [4 /*yield*/, (0, sitemap_data_1.sitemapData)(sitemapDataCtx)];
|
|
142
142
|
case 3:
|
|
143
|
-
_a =
|
|
144
|
-
|
|
143
|
+
_a = _k.sent();
|
|
144
|
+
_k.label = 4;
|
|
145
145
|
case 4:
|
|
146
146
|
dataE = _a;
|
|
147
147
|
if (dataE._tag === "Right") {
|
|
148
148
|
c = __assign(__assign({}, sitemapDataCtx), { data: dataE.right.data });
|
|
149
|
-
sitemap = ((
|
|
149
|
+
sitemap = ((_f = config.options) === null || _f === void 0 ? void 0 : _f.data)
|
|
150
150
|
? config.options.data.sitemap
|
|
151
|
-
: ((
|
|
151
|
+
: ((_g = config.options) === null || _g === void 0 ? void 0 : _g.eagerly)
|
|
152
152
|
? (0, build_sitemap_eagerly_1.buildSitemapEagerly)(c, dataE.right.data.locales)
|
|
153
153
|
: new Map();
|
|
154
|
-
pagesByTagIdRecord = ((
|
|
154
|
+
pagesByTagIdRecord = ((_h = config.options) === null || _h === void 0 ? void 0 : _h.data)
|
|
155
155
|
? config.options.data.pagesByTagId
|
|
156
|
-
: ((
|
|
156
|
+
: ((_j = config.options) === null || _j === void 0 ? void 0 : _j.eagerly)
|
|
157
157
|
? (0, build_pages_by_tag_eagerly_1.buildPagesByTagEagerly)(__assign(__assign({}, c), { sitemap: sitemap }), dataE.right.data.locales)
|
|
158
158
|
: new Map();
|
|
159
159
|
ctx_1 = __assign(__assign({}, c), { data: dataE.right.data, sitemap: sitemap, pagesByTagId: pagesByTagIdRecord, lastUpdatedAt: new Date().toISOString(), regenerationInProgress: false });
|
|
@@ -96,10 +96,27 @@ var getAllEntriesRecursively = function (_a, contentfulClientType, contentType,
|
|
|
96
96
|
skip: skip,
|
|
97
97
|
content_type: contentType,
|
|
98
98
|
include: 0,
|
|
99
|
-
select:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
100
|
+
{
|
|
101
|
+
"status": 400,
|
|
102
|
+
"statusText": "Bad Request",
|
|
103
|
+
"message": "The query you sent was invalid. Probably a filter or ordering specification is not applicable to the type of a field.",
|
|
104
|
+
"details": {
|
|
105
|
+
"errors": [
|
|
106
|
+
{
|
|
107
|
+
"name": "select",
|
|
108
|
+
"details": "Select is only applicable when querying a collection of entities."
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"request": {
|
|
113
|
+
"url": "/spaces/8h4rcnu50txt/environments/dacjan-test/public/entries",
|
|
114
|
+
"method": "get",
|
|
115
|
+
...
|
|
116
|
+
},
|
|
117
|
+
}*/
|
|
118
|
+
select: contentfulClientType !== "cma-client" ? select : undefined,
|
|
119
|
+
locale: contentfulClientType === "cda-client-with-all-locales" ? undefined : "*",
|
|
103
120
|
})];
|
|
104
121
|
case 1:
|
|
105
122
|
items = (_b.sent()).items;
|
|
@@ -79,36 +79,8 @@ var array_to_map_1 = require("../../utils/array-to-map");
|
|
|
79
79
|
var getAllPageEntriesRecursively = function (_a, contentfulClientType, pageContentTypeOpt, skip, acc, select) {
|
|
80
80
|
var getEntries = _a.getEntries;
|
|
81
81
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
-
var fieldsSelect;
|
|
83
82
|
return __generator(this, function (_b) {
|
|
84
|
-
|
|
85
|
-
pageContentTypeOpt.slugFieldId,
|
|
86
|
-
pageContentTypeOpt.childPagesFieldId,
|
|
87
|
-
pageContentTypeOpt.titleFieldId,
|
|
88
|
-
].flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
89
|
-
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)({ getEntries: getEntries }, contentfulClientType, pageContentTypeOpt.id, skip, acc,
|
|
90
|
-
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
91
|
-
{
|
|
92
|
-
"status": 400,
|
|
93
|
-
"statusText": "Bad Request",
|
|
94
|
-
"message": "The query you sent was invalid. Probably a filter or ordering specification is not applicable to the type of a field.",
|
|
95
|
-
"details": {
|
|
96
|
-
"errors": [
|
|
97
|
-
{
|
|
98
|
-
"name": "select",
|
|
99
|
-
"details": "Select is only applicable when querying a collection of entities."
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
},
|
|
103
|
-
"request": {
|
|
104
|
-
"url": "/spaces/8h4rcnu50txt/environments/dacjan-test/public/entries",
|
|
105
|
-
"method": "get",
|
|
106
|
-
...
|
|
107
|
-
},
|
|
108
|
-
}*/
|
|
109
|
-
select || contentfulClientType === "cma-client"
|
|
110
|
-
? undefined
|
|
111
|
-
: __spreadArray(["sys", "metadata"], __read(fieldsSelect), false).join(","), pageContentTypeOpt.childPagesFieldId
|
|
83
|
+
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)({ getEntries: getEntries }, contentfulClientType, pageContentTypeOpt.id, skip, acc, select, pageContentTypeOpt.childPagesFieldId
|
|
112
84
|
? [pageContentTypeOpt.childPagesFieldId]
|
|
113
85
|
: [])];
|
|
114
86
|
});
|
|
@@ -144,7 +116,14 @@ var pageEntries = function (ctx, apiClient, cmaPreviewClientApi) { return __awai
|
|
|
144
116
|
pageContentTypes = Object.entries(options.pageContentTypes);
|
|
145
117
|
pageEntriesPromise = Promise.all(pageContentTypes.map(function (_a) {
|
|
146
118
|
var _b = __read(_a, 2), id = _b[0], fieldIds = _b[1];
|
|
147
|
-
|
|
119
|
+
var fieldsSelect = __spreadArray([
|
|
120
|
+
fieldIds.slugFieldId,
|
|
121
|
+
fieldIds.childPagesFieldId,
|
|
122
|
+
fieldIds.titleFieldId,
|
|
123
|
+
fieldIds.parentPageFieldId
|
|
124
|
+
], __read((fieldIds.select || [])), false).flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
125
|
+
var select = __spreadArray(["sys", "metadata"], __read(fieldsSelect), false).join(",");
|
|
126
|
+
return getAllPageEntriesRecursively(apiClient, ctx.contentfulClientType, __assign({ id: id }, fieldIds), 0, [], select);
|
|
148
127
|
}));
|
|
149
128
|
statusRecordPromise = ctx.options.includeEntryStatus &&
|
|
150
129
|
ctx.contentfulClientType === "cma-client" &&
|
|
@@ -2,30 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pageEntryAdapter = void 0;
|
|
4
4
|
var localize_contentful_field_1 = require("../helpers/localize-contentful-field");
|
|
5
|
-
var pageEntryAdapter = function (data, slugField, titleField,
|
|
5
|
+
var pageEntryAdapter = function (data, options, slugField, titleField, childrenRefs, locale, parent, entry) {
|
|
6
6
|
var _a;
|
|
7
7
|
var fieldValue = (0, localize_contentful_field_1.localizeField)(data, locale);
|
|
8
8
|
var slug = (_a = fieldValue(slugField.localized, entry.fields[slugField.id])) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
9
9
|
var title = titleField
|
|
10
10
|
? fieldValue(titleField.localized, entry.fields[titleField.id])
|
|
11
11
|
: undefined;
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var contentTypeId = entry.sys.contentType.sys.id;
|
|
13
|
+
var additionalFields = (options.pageContentTypes[contentTypeId].select || []).reduce(function (acc, fieldId) {
|
|
14
|
+
var contentType = data.contentTypes.get(contentTypeId);
|
|
15
|
+
if (contentType) {
|
|
16
|
+
var field = contentType.fields.get(fieldId);
|
|
17
|
+
var value = field
|
|
18
|
+
? fieldValue(field.localized, entry.fields[field.id])
|
|
19
|
+
: undefined;
|
|
20
|
+
acc[fieldId] = value;
|
|
21
|
+
}
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
15
24
|
return slug
|
|
16
25
|
? {
|
|
17
|
-
type:
|
|
26
|
+
type: "page",
|
|
18
27
|
parent: parent ? { sys: parent.sys } : undefined,
|
|
19
|
-
path: parent ? parent.path +
|
|
28
|
+
path: parent ? parent.path + "/" + slug : "/" + locale.code,
|
|
20
29
|
slug: slug,
|
|
21
30
|
title: title || undefined,
|
|
22
31
|
sys: {
|
|
23
32
|
id: entry.sys.id,
|
|
24
33
|
cmaOnlyStatus: entry.sys.cmaOnlyStatus,
|
|
25
|
-
contentTypeId:
|
|
34
|
+
contentTypeId: contentTypeId,
|
|
26
35
|
},
|
|
27
36
|
metadata: entry.metadata,
|
|
28
|
-
childPages: (
|
|
37
|
+
childPages: (childrenRefs === null || childrenRefs === void 0 ? void 0 : childrenRefs.flatMap(function (childPage) { var _a; return ((_a = childPage === null || childPage === void 0 ? void 0 : childPage.sys) === null || _a === void 0 ? void 0 : _a.id) ? [{ sys: { id: childPage === null || childPage === void 0 ? void 0 : childPage.sys.id } }] : []; })) || [],
|
|
38
|
+
additionalFields: additionalFields,
|
|
29
39
|
}
|
|
30
40
|
: undefined;
|
|
31
41
|
};
|
|
@@ -16,6 +16,7 @@ var toArboretumPageWithMissingData = function (localeCode) {
|
|
|
16
16
|
: page.childPages.length,
|
|
17
17
|
children: children,
|
|
18
18
|
ancestors: ancestors,
|
|
19
|
+
additionalFields: page.additionalFields,
|
|
19
20
|
}); };
|
|
20
21
|
};
|
|
21
22
|
exports.toArboretumPageWithMissingData = toArboretumPageWithMissingData;
|
|
@@ -41,6 +41,7 @@ var fp_utils_1 = require("../../../utils/fp-utils");
|
|
|
41
41
|
var page_entry_adapter_1 = require("../adapters/page-entry-adapter");
|
|
42
42
|
var redirect_entry_adapter_1 = require("../adapters/redirect-entry-adapter");
|
|
43
43
|
var is_root_1 = require("./is-root");
|
|
44
|
+
var localize_contentful_field_1 = require("./localize-contentful-field");
|
|
44
45
|
var getAllRedirects = function (data, options, locale, parent) {
|
|
45
46
|
var redirectContentType = options.id
|
|
46
47
|
? data.contentTypes.get(options.id)
|
|
@@ -61,15 +62,49 @@ var getAllRedirects = function (data, options, locale, parent) {
|
|
|
61
62
|
return redirect ? [redirect] : [];
|
|
62
63
|
});
|
|
63
64
|
};
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
var findPageFieldF = function (data, options, pageContentTypeId) {
|
|
66
|
+
return function (fieldId) {
|
|
67
|
+
var contentTypes = data.contentTypes;
|
|
68
|
+
var pageContentType = contentTypes.get(pageContentTypeId);
|
|
69
|
+
var pageContentTypeConfig = options.pageContentTypes[pageContentTypeId];
|
|
69
70
|
return pageContentType && pageContentTypeConfig
|
|
70
71
|
? pageContentType.fields.get(fieldId)
|
|
71
72
|
: undefined;
|
|
72
73
|
};
|
|
74
|
+
};
|
|
75
|
+
var getChildrenRefsByParentId = function (data, locale, options) {
|
|
76
|
+
var pages = data.pages;
|
|
77
|
+
var acc = new Map();
|
|
78
|
+
pages.forEach(function (page) {
|
|
79
|
+
var _a;
|
|
80
|
+
var pageContentTypeConfig = options.pageContentTypes[page.sys.contentType.sys.id];
|
|
81
|
+
var findPageField = findPageFieldF(data, options, page.sys.contentType.sys.id);
|
|
82
|
+
var parentPageField = pageContentTypeConfig.parentPageFieldId
|
|
83
|
+
? findPageField(pageContentTypeConfig.parentPageFieldId)
|
|
84
|
+
: undefined;
|
|
85
|
+
var fieldValue = (0, localize_contentful_field_1.localizeField)(data, locale);
|
|
86
|
+
var parentPage = parentPageField
|
|
87
|
+
? fieldValue(parentPageField.localized, page.fields[parentPageField.id])
|
|
88
|
+
: undefined;
|
|
89
|
+
var parentPageId = (_a = parentPage === null || parentPage === void 0 ? void 0 : parentPage.sys) === null || _a === void 0 ? void 0 : _a.id;
|
|
90
|
+
if (parentPageId) {
|
|
91
|
+
var pageRef = { sys: { id: page.sys.id } };
|
|
92
|
+
var maybePages = acc.get(parentPageId);
|
|
93
|
+
if (maybePages) {
|
|
94
|
+
maybePages.push(pageRef);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
acc.set(parentPageId, [pageRef]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return acc;
|
|
102
|
+
};
|
|
103
|
+
var buildLocalizedSitemapArrRecursively = function (data, options, locale, parent, childrenRefsByPageId, pageEntry, acc) {
|
|
104
|
+
var _a;
|
|
105
|
+
var pages = data.pages;
|
|
106
|
+
var pageContentTypeConfig = options.pageContentTypes[pageEntry.sys.contentType.sys.id];
|
|
107
|
+
var findPageField = findPageFieldF(data, options, pageEntry.sys.contentType.sys.id);
|
|
73
108
|
var slugField = findPageField(pageContentTypeConfig.slugFieldId);
|
|
74
109
|
var titleField = pageContentTypeConfig.titleFieldId
|
|
75
110
|
? findPageField(pageContentTypeConfig.titleFieldId)
|
|
@@ -77,8 +112,14 @@ var buildLocalizedSitemapArrRecursively = function (data, options, locale, paren
|
|
|
77
112
|
var childPagesField = pageContentTypeConfig.childPagesFieldId
|
|
78
113
|
? findPageField(pageContentTypeConfig.childPagesFieldId)
|
|
79
114
|
: undefined;
|
|
115
|
+
var fieldValue = (0, localize_contentful_field_1.localizeField)(data, locale);
|
|
116
|
+
var childrenRefs = childrenRefsByPageId
|
|
117
|
+
? childrenRefsByPageId.get(pageEntry.sys.id) || []
|
|
118
|
+
: childPagesField
|
|
119
|
+
? ((_a = fieldValue(childPagesField.localized, pageEntry.fields[childPagesField.id])) === null || _a === void 0 ? void 0 : _a.flatMap(function (childPage) { var _a; return ((_a = childPage === null || childPage === void 0 ? void 0 : childPage.sys) === null || _a === void 0 ? void 0 : _a.id) ? [{ sys: { id: childPage === null || childPage === void 0 ? void 0 : childPage.sys.id } }] : []; })) || []
|
|
120
|
+
: [];
|
|
80
121
|
var page = slugField
|
|
81
|
-
? (0, page_entry_adapter_1.pageEntryAdapter)(data, slugField, titleField,
|
|
122
|
+
? (0, page_entry_adapter_1.pageEntryAdapter)(data, options, slugField, titleField, childrenRefs, locale, parent, pageEntry)
|
|
82
123
|
: undefined;
|
|
83
124
|
if (page) {
|
|
84
125
|
var validChildPages_1 = page.childPages.filter(function (c) { return pages.get(c.sys.id) && !acc.get(c.sys.id); });
|
|
@@ -96,7 +137,7 @@ var buildLocalizedSitemapArrRecursively = function (data, options, locale, paren
|
|
|
96
137
|
var id = _a.sys.id;
|
|
97
138
|
var childPageEntry = pages.get(id);
|
|
98
139
|
childPageEntry &&
|
|
99
|
-
buildLocalizedSitemapArrRecursively(data, options, locale, { sys: pageEntry.sys, path: page.path }, childPageEntry, acc);
|
|
140
|
+
buildLocalizedSitemapArrRecursively(data, options, locale, { sys: pageEntry.sys, path: page.path }, childrenRefsByPageId, childPageEntry, acc);
|
|
100
141
|
});
|
|
101
142
|
return acc;
|
|
102
143
|
}
|
|
@@ -110,7 +151,10 @@ var buildLocalizedSitemap = function (data, options, pageHomeTagId, locale) {
|
|
|
110
151
|
var homePageRef = (_d = (_c = (_b = (_a = homePagesByTagId === null || homePagesByTagId === void 0 ? void 0 : homePagesByTagId.get(locale.code)) === null || _a === void 0 ? void 0 : _a.get(pageHomeTagId)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.sys) === null || _d === void 0 ? void 0 : _d.id;
|
|
111
152
|
var homePageEntry = homePageRef ? pages.get(homePageRef) : undefined;
|
|
112
153
|
if (homePageEntry) {
|
|
113
|
-
var
|
|
154
|
+
var childrenRefsByPageId = options.sitemapRepresentation === "child-to-parent"
|
|
155
|
+
? getChildrenRefsByParentId(data, locale, options)
|
|
156
|
+
: undefined;
|
|
157
|
+
var sitemap = buildLocalizedSitemapArrRecursively(data, options, locale, undefined, childrenRefsByPageId, homePageEntry, new Map());
|
|
114
158
|
return (0, fp_utils_1.right)({
|
|
115
159
|
root: { sys: homePageEntry.sys },
|
|
116
160
|
sitemap: sitemap,
|
|
@@ -4,6 +4,7 @@ import { ContentTypeT, EntryT, LocaleT, StatusT, TagT } from "./clients/contentf
|
|
|
4
4
|
export type ArboretumClientOptions = {
|
|
5
5
|
data?: CachedDataT;
|
|
6
6
|
eagerly?: boolean;
|
|
7
|
+
sitemapRepresentation?: "parent-to-children" | "child-to-parent";
|
|
7
8
|
includeEntryStatus?: boolean;
|
|
8
9
|
};
|
|
9
10
|
export type ArboretumClientContentfulConfigOptionsT = {
|
|
@@ -12,6 +13,8 @@ export type ArboretumClientContentfulConfigOptionsT = {
|
|
|
12
13
|
slugFieldId: string;
|
|
13
14
|
titleFieldId?: string;
|
|
14
15
|
childPagesFieldId?: string;
|
|
16
|
+
parentPageFieldId?: string;
|
|
17
|
+
select?: Array<string>;
|
|
15
18
|
};
|
|
16
19
|
};
|
|
17
20
|
redirectContentType?: {
|
|
@@ -59,7 +62,7 @@ export type ArboretumClientConfigFromCdaT = {
|
|
|
59
62
|
client: ContentfulClientApi;
|
|
60
63
|
options: ArboretumClientContentfulConfigOptionsT;
|
|
61
64
|
};
|
|
62
|
-
options?: Pick<ArboretumClientOptions, "data" | "eagerly">;
|
|
65
|
+
options?: Pick<ArboretumClientOptions, "data" | "eagerly" | "sitemapRepresentation">;
|
|
63
66
|
};
|
|
64
67
|
export type CreateClientParams = {
|
|
65
68
|
space: string;
|
|
@@ -76,7 +79,7 @@ export type ArboretumClientConfigFromCdaParamsT = {
|
|
|
76
79
|
contentful: Omit<CreateClientParams, "host"> & {
|
|
77
80
|
options: ArboretumClientContentfulConfigOptionsT;
|
|
78
81
|
};
|
|
79
|
-
options?: Pick<ArboretumClientOptions, "data" | "eagerly">;
|
|
82
|
+
options?: Pick<ArboretumClientOptions, "data" | "eagerly" | "sitemapRepresentation">;
|
|
80
83
|
};
|
|
81
84
|
export type ArboretumClientConfigT = ArboretumClientConfigFromCmaT | ArboretumClientConfigFromCdaT | ArboretumClientConfigFromCdaParamsT;
|
|
82
85
|
type ArboretumPageBaseT = {
|
|
@@ -101,13 +104,16 @@ export type ArboretumPageT = ArboretumPageBaseT & {
|
|
|
101
104
|
totalDirectChildrenCount: number;
|
|
102
105
|
children?: Array<ArboretumPageNodeT>;
|
|
103
106
|
ancestors?: Array<Omit<ArboretumPageT, "children" | "ancestors">>;
|
|
107
|
+
additionalFields?: {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
104
110
|
};
|
|
105
111
|
export type ArboretumPageNodeT = ArboretumPageT | ArboretumRedirectT | ArboretumAliasT;
|
|
106
112
|
export type OptionsT = {
|
|
107
113
|
withChildren?: boolean;
|
|
108
114
|
withAncestors?: boolean;
|
|
109
115
|
};
|
|
110
|
-
export type ArboretumClientOptionsT = Pick<ArboretumClientContentfulConfigOptionsT, "pageContentTypes" | "redirectContentType"> & Pick<ArboretumClientOptions, "includeEntryStatus">;
|
|
116
|
+
export type ArboretumClientOptionsT = Pick<ArboretumClientContentfulConfigOptionsT, "pageContentTypes" | "redirectContentType"> & Pick<ArboretumClientOptions, "includeEntryStatus" | "sitemapRepresentation">;
|
|
111
117
|
export type ArboretumClientT = {
|
|
112
118
|
homePage: (localeCode: string, options?: OptionsT) => Either<string, ArboretumPageT>;
|
|
113
119
|
pageByPath: (path: string, options?: OptionsT) => Either<string, ArboretumPageNodeT>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PageT } from
|
|
2
|
-
import { ContentTypeT, EntryT, LocaleT } from
|
|
3
|
-
import { SitemapDataT } from
|
|
4
|
-
export declare const pageEntryAdapter: (data: Pick<SitemapDataT,
|
|
1
|
+
import { ArboretumClientCtx, PageT } from "../../arboretum-client.impl";
|
|
2
|
+
import { ContentTypeT, EntryT, LocaleT } from "../../../clients/contentful-client/contentful-client";
|
|
3
|
+
import { SitemapDataT } from "../../data/sitemap-data";
|
|
4
|
+
export declare const pageEntryAdapter: (data: Pick<SitemapDataT, "locales" | "defaultLocaleCode" | "pages" | "contentTypes">, options: Pick<ArboretumClientCtx["options"], "pageContentTypes">, slugField: ContentTypeT["fields"][number], titleField: ContentTypeT["fields"][number] | undefined, childrenRefs: PageT["childPages"], locale: LocaleT, parent: (NonNullable<PageT["parent"]> & {
|
|
5
5
|
path: string;
|
|
6
6
|
}) | undefined, entry: EntryT) => PageT | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Either } from
|
|
2
|
-
import { ArboretumClientCtx, LocalizedSitemapT } from
|
|
3
|
-
import { LocaleT } from
|
|
4
|
-
export declare const buildLocalizedSitemap: (data: Pick<ArboretumClientCtx[
|
|
5
|
-
export declare const localizedSitemapFromCacheOrBuildEff: (ctx: Pick<ArboretumClientCtx,
|
|
1
|
+
import { Either } from "../../../utils/fp-utils";
|
|
2
|
+
import { ArboretumClientCtx, LocalizedSitemapT } from "../../arboretum-client.impl";
|
|
3
|
+
import { LocaleT } from "../../../clients/contentful-client/contentful-client";
|
|
4
|
+
export declare const buildLocalizedSitemap: (data: Pick<ArboretumClientCtx["data"], "homePagesByTagId" | "pages" | "contentTypes" | "defaultLocaleCode" | "locales" | "redirects">, options: ArboretumClientCtx["options"], pageHomeTagId: ArboretumClientCtx["pageHomeTagId"], locale: LocaleT) => Either<string, LocalizedSitemapT>;
|
|
5
|
+
export declare const localizedSitemapFromCacheOrBuildEff: (ctx: Pick<ArboretumClientCtx, "options" | "data" | "pageHomeTagId" | "sitemap">, locale: LocaleT) => Either<string, LocalizedSitemapT>;
|