@bright.global/arboretum-sdk 0.0.7 → 0.0.9
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/clients/contentful-client/impl/constants.js +8 -0
- package/dist/clients/contentful-client/impl/contentful-client-impl.js +21 -11
- package/dist/clients/contentful-client/impl/methods/contentful-fetch.js +116 -0
- package/dist/clients/contentful-client/impl/methods/get-content-types.js +27 -0
- package/dist/clients/contentful-client/impl/methods/get-entries.js +34 -0
- package/dist/clients/contentful-client/impl/methods/get-locales.js +20 -0
- package/dist/clients/contentful-client/impl/methods/get-tags.js +20 -0
- package/dist/es6/clients/contentful-client/impl/constants.js +5 -0
- package/dist/es6/clients/contentful-client/impl/contentful-client-impl.js +19 -10
- package/dist/es6/clients/contentful-client/impl/methods/contentful-fetch.js +112 -0
- package/dist/es6/clients/contentful-client/impl/methods/get-content-types.js +23 -0
- package/dist/es6/clients/contentful-client/impl/methods/get-entries.js +30 -0
- package/dist/es6/clients/contentful-client/impl/methods/get-locales.js +16 -0
- package/dist/es6/clients/contentful-client/impl/methods/get-tags.js +16 -0
- package/dist/es6/impl/arboretum-client.impl.js +3 -1
- package/dist/es6/impl/data/helpers/get-all-entries-recursively.js +5 -3
- package/dist/es6/impl/data/helpers/get-all-entries-recursively.test.js +3 -3
- package/dist/es6/impl/data/page-entries.js +1 -1
- package/dist/es6/impl/data/redirect-entries.js +1 -1
- package/dist/es6/impl/sitemap/adapters/page-entry-adapter.js +1 -0
- package/dist/es6/impl/sitemap/adapters/to-arboretum-page-adapter.test.js +6 -0
- package/dist/es6/impl/sitemap/adapters/to-arboretum-page-with-missing-data-adapter.js +2 -1
- package/dist/es6/impl/sitemap/helpers/__mocks__/mocked-localized-sitemap.js +59 -58
- package/dist/es6/impl/sitemap/helpers/build-localized-sitemap.test.js +34 -34
- package/dist/es6/utils/get-rendom-number.js +3 -0
- package/dist/impl/arboretum-client.impl.js +3 -1
- package/dist/impl/data/helpers/get-all-entries-recursively.js +5 -3
- package/dist/impl/data/helpers/get-all-entries-recursively.test.js +3 -3
- package/dist/impl/data/page-entries.js +1 -1
- package/dist/impl/data/redirect-entries.js +1 -1
- package/dist/impl/sitemap/adapters/page-entry-adapter.js +1 -0
- package/dist/impl/sitemap/adapters/to-arboretum-page-adapter.test.js +6 -0
- package/dist/impl/sitemap/adapters/to-arboretum-page-with-missing-data-adapter.js +2 -1
- package/dist/impl/sitemap/helpers/__mocks__/mocked-localized-sitemap.js +59 -58
- package/dist/impl/sitemap/helpers/build-localized-sitemap.test.js +30 -30
- package/dist/types/arboretum-client.d.ts +32 -4
- package/dist/types/clients/contentful-client/contentful-client.d.ts +37 -27
- package/dist/types/clients/contentful-client/impl/constants.d.ts +5 -0
- package/dist/types/clients/contentful-client/impl/contentful-client-impl.d.ts +2 -1
- package/dist/types/clients/contentful-client/impl/methods/contentful-fetch.d.ts +2 -0
- package/dist/types/clients/contentful-client/impl/methods/get-content-types.d.ts +3 -0
- package/dist/types/clients/contentful-client/impl/methods/get-entries.d.ts +3 -0
- package/dist/types/clients/contentful-client/impl/methods/get-locales.d.ts +3 -0
- package/dist/types/clients/contentful-client/impl/methods/get-tags.d.ts +3 -0
- package/dist/types/impl/arboretum-client.impl.d.ts +2 -1
- package/dist/types/impl/data/helpers/get-all-entries-recursively.d.ts +1 -1
- package/dist/types/impl/sitemap/adapters/to-arboretum-page-with-missing-data-adapter.d.ts +3 -3
- package/dist/types/impl/sitemap/helpers/__mocks__/mocked-localized-sitemap.d.ts +1 -1
- package/dist/types/utils/get-rendom-number.d.ts +1 -0
- package/dist/utils/get-rendom-number.js +7 -0
- package/package.json +2 -5
|
@@ -37,11 +37,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
37
37
|
import { mockedPage1, mockedPage1_1, mockedPage1_1_1, mockedPage1_1_2, mockedRoot, mockedLocalizedSitemap, } from '../helpers/__mocks__/mocked-localized-sitemap';
|
|
38
38
|
import { toArboretumPage } from './to-arboretum-page-adapter';
|
|
39
39
|
var localeCode = 'en';
|
|
40
|
+
var contentTypeId = "page";
|
|
40
41
|
var toArboretumPageF = function (options) {
|
|
41
42
|
return toArboretumPage(mockedLocalizedSitemap, localeCode, options);
|
|
42
43
|
};
|
|
43
44
|
var arboretumPageRoot = {
|
|
44
45
|
type: 'page',
|
|
46
|
+
contentTypeId: contentTypeId,
|
|
45
47
|
id: mockedRoot.sys.id,
|
|
46
48
|
localeCode: localeCode,
|
|
47
49
|
path: mockedRoot.path,
|
|
@@ -50,6 +52,7 @@ var arboretumPageRoot = {
|
|
|
50
52
|
};
|
|
51
53
|
var arboretumPagePage1 = {
|
|
52
54
|
id: mockedPage1.sys.id,
|
|
55
|
+
contentTypeId: contentTypeId,
|
|
53
56
|
localeCode: localeCode,
|
|
54
57
|
path: mockedPage1.path,
|
|
55
58
|
slug: mockedPage1.slug,
|
|
@@ -58,6 +61,7 @@ var arboretumPagePage1 = {
|
|
|
58
61
|
};
|
|
59
62
|
var arboretumPagePage1_1 = {
|
|
60
63
|
id: mockedPage1_1.sys.id,
|
|
64
|
+
contentTypeId: contentTypeId,
|
|
61
65
|
localeCode: localeCode,
|
|
62
66
|
path: mockedPage1_1.path,
|
|
63
67
|
slug: mockedPage1_1.slug,
|
|
@@ -66,6 +70,7 @@ var arboretumPagePage1_1 = {
|
|
|
66
70
|
};
|
|
67
71
|
var arboretumPage1_1_1 = {
|
|
68
72
|
id: mockedPage1_1_1.sys.id,
|
|
73
|
+
contentTypeId: contentTypeId,
|
|
69
74
|
localeCode: localeCode,
|
|
70
75
|
path: mockedPage1_1_1.path,
|
|
71
76
|
slug: mockedPage1_1_1.slug,
|
|
@@ -74,6 +79,7 @@ var arboretumPage1_1_1 = {
|
|
|
74
79
|
};
|
|
75
80
|
var arboretumPage1_1_2 = {
|
|
76
81
|
id: mockedPage1_1_2.sys.id,
|
|
82
|
+
contentTypeId: contentTypeId,
|
|
77
83
|
localeCode: localeCode,
|
|
78
84
|
path: mockedPage1_1_2.path,
|
|
79
85
|
slug: mockedPage1_1_2.slug,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var toArboretumPageWithMissingData = function (localeCode) {
|
|
2
2
|
return function (page, ancestors, children) { return ({
|
|
3
|
-
type:
|
|
3
|
+
type: "page",
|
|
4
|
+
contentTypeId: page.sys.contentTypeId,
|
|
4
5
|
id: page.sys.id,
|
|
5
6
|
title: page.title,
|
|
6
7
|
cmaOnlyStatus: page.sys.cmaOnlyStatus,
|
|
@@ -23,24 +23,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
23
23
|
}
|
|
24
24
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
25
|
};
|
|
26
|
-
var mockedRootSysId =
|
|
27
|
-
var mockedPage1SysId =
|
|
28
|
-
var mockedPage1_1SysId =
|
|
29
|
-
var mockedPage1_1_1SysId =
|
|
30
|
-
var mockedPage1_1_2SysId =
|
|
31
|
-
var mockedPage1_2SysId =
|
|
32
|
-
var mockedPage2SysId =
|
|
33
|
-
var mockedPage2_1SysId =
|
|
34
|
-
var mockedPage3SysId =
|
|
35
|
-
var mockedRedirect1SysId =
|
|
36
|
-
var mockedRedirect2SysId =
|
|
37
|
-
var mockedRedirect3SysId =
|
|
26
|
+
var mockedRootSysId = "root";
|
|
27
|
+
var mockedPage1SysId = "page1";
|
|
28
|
+
var mockedPage1_1SysId = "page1-1";
|
|
29
|
+
var mockedPage1_1_1SysId = "page1-1-1";
|
|
30
|
+
var mockedPage1_1_2SysId = "page1-1-2";
|
|
31
|
+
var mockedPage1_2SysId = "page1-2";
|
|
32
|
+
var mockedPage2SysId = "page2";
|
|
33
|
+
var mockedPage2_1SysId = "page2_1";
|
|
34
|
+
var mockedPage3SysId = "page3";
|
|
35
|
+
var mockedRedirect1SysId = "redirect1";
|
|
36
|
+
var mockedRedirect2SysId = "redirect2";
|
|
37
|
+
var mockedRedirect3SysId = "redirect3";
|
|
38
|
+
var contentTypeId = "page";
|
|
38
39
|
export var mockedRoot = {
|
|
39
|
-
type:
|
|
40
|
-
sys: { id: mockedRootSysId },
|
|
40
|
+
type: "page",
|
|
41
|
+
sys: { id: mockedRootSysId, contentTypeId: contentTypeId },
|
|
41
42
|
parent: undefined,
|
|
42
43
|
slug: mockedRootSysId,
|
|
43
|
-
path:
|
|
44
|
+
path: "/en",
|
|
44
45
|
childPages: [
|
|
45
46
|
{ sys: { id: mockedPage1SysId } },
|
|
46
47
|
{ sys: { id: mockedPage2SysId } },
|
|
@@ -51,21 +52,21 @@ export var mockedRoot = {
|
|
|
51
52
|
],
|
|
52
53
|
};
|
|
53
54
|
export var mockedPage1 = {
|
|
54
|
-
type:
|
|
55
|
-
sys: { id: mockedPage1SysId },
|
|
56
|
-
parent: { sys: mockedRoot.sys },
|
|
55
|
+
type: "page",
|
|
56
|
+
sys: { id: mockedPage1SysId, contentTypeId: contentTypeId },
|
|
57
|
+
parent: { sys: { id: mockedRoot.sys.id } },
|
|
57
58
|
slug: mockedPage1SysId,
|
|
58
|
-
path: mockedRoot.path +
|
|
59
|
+
path: mockedRoot.path + "/" + mockedPage1SysId,
|
|
59
60
|
childPages: [
|
|
60
61
|
{ sys: { id: mockedPage1_1SysId } },
|
|
61
62
|
{ sys: { id: mockedPage1_2SysId } },
|
|
62
63
|
],
|
|
63
64
|
};
|
|
64
65
|
export var mockedPage1_1 = {
|
|
65
|
-
type:
|
|
66
|
-
sys: { id: mockedPage1_1SysId },
|
|
67
|
-
parent: { sys: mockedPage1.sys },
|
|
68
|
-
path: mockedPage1.path +
|
|
66
|
+
type: "page",
|
|
67
|
+
sys: { id: mockedPage1_1SysId, contentTypeId: contentTypeId },
|
|
68
|
+
parent: { sys: { id: mockedPage1.sys.id } },
|
|
69
|
+
path: mockedPage1.path + "/" + mockedPage1_1SysId,
|
|
69
70
|
slug: mockedPage1_1SysId,
|
|
70
71
|
childPages: [
|
|
71
72
|
{ sys: { id: mockedPage1_1_1SysId } },
|
|
@@ -73,72 +74,72 @@ export var mockedPage1_1 = {
|
|
|
73
74
|
],
|
|
74
75
|
};
|
|
75
76
|
export var mockedPage1_2 = {
|
|
76
|
-
type:
|
|
77
|
-
sys: { id: mockedPage1_2SysId },
|
|
78
|
-
parent: { sys: mockedPage1.sys },
|
|
79
|
-
path: mockedPage1.path +
|
|
77
|
+
type: "page",
|
|
78
|
+
sys: { id: mockedPage1_2SysId, contentTypeId: contentTypeId },
|
|
79
|
+
parent: { sys: { id: mockedPage1.sys.id } },
|
|
80
|
+
path: mockedPage1.path + "/" + mockedPage1_2SysId,
|
|
80
81
|
slug: mockedPage1_2SysId,
|
|
81
82
|
childPages: [],
|
|
82
83
|
};
|
|
83
84
|
export var mockedPage1_1_1 = {
|
|
84
|
-
type:
|
|
85
|
-
sys: { id: mockedPage1_1_1SysId },
|
|
86
|
-
parent: { sys: mockedPage1_1.sys },
|
|
87
|
-
path: mockedPage1_1.path +
|
|
85
|
+
type: "page",
|
|
86
|
+
sys: { id: mockedPage1_1_1SysId, contentTypeId: contentTypeId },
|
|
87
|
+
parent: { sys: { id: mockedPage1_1.sys.id } },
|
|
88
|
+
path: mockedPage1_1.path + "/" + mockedPage1_1_1SysId,
|
|
88
89
|
slug: mockedPage1_1_1SysId,
|
|
89
90
|
childPages: [],
|
|
90
91
|
};
|
|
91
92
|
export var mockedPage1_1_2 = {
|
|
92
|
-
type:
|
|
93
|
-
sys: { id: mockedPage1_1_2SysId },
|
|
94
|
-
parent: { sys: mockedPage1_1.sys },
|
|
95
|
-
path: mockedPage1_1.path +
|
|
93
|
+
type: "page",
|
|
94
|
+
sys: { id: mockedPage1_1_2SysId, contentTypeId: contentTypeId },
|
|
95
|
+
parent: { sys: { id: mockedPage1_1.sys.id } },
|
|
96
|
+
path: mockedPage1_1.path + "/" + mockedPage1_1_2SysId,
|
|
96
97
|
slug: mockedPage1_1_2SysId,
|
|
97
98
|
childPages: [],
|
|
98
99
|
};
|
|
99
100
|
export var mockedPage2 = {
|
|
100
|
-
type:
|
|
101
|
-
sys: { id: mockedPage2SysId },
|
|
102
|
-
parent: { sys: mockedRoot.sys },
|
|
103
|
-
path: mockedRoot.path +
|
|
101
|
+
type: "page",
|
|
102
|
+
sys: { id: mockedPage2SysId, contentTypeId: contentTypeId },
|
|
103
|
+
parent: { sys: { id: mockedRoot.sys.id } },
|
|
104
|
+
path: mockedRoot.path + "/" + mockedPage2SysId,
|
|
104
105
|
slug: mockedPage2SysId,
|
|
105
106
|
childPages: [{ sys: { id: mockedPage2_1SysId } }],
|
|
106
107
|
};
|
|
107
108
|
export var mockedPage2_1 = {
|
|
108
|
-
type:
|
|
109
|
-
sys: { id: mockedPage2_1SysId },
|
|
110
|
-
parent: { sys: mockedPage2.sys },
|
|
111
|
-
path: mockedPage2.path +
|
|
109
|
+
type: "page",
|
|
110
|
+
sys: { id: mockedPage2_1SysId, contentTypeId: contentTypeId },
|
|
111
|
+
parent: { sys: { id: mockedPage2.sys.id } },
|
|
112
|
+
path: mockedPage2.path + "/" + mockedPage2_1SysId,
|
|
112
113
|
slug: mockedPage2_1SysId,
|
|
113
114
|
childPages: [],
|
|
114
115
|
};
|
|
115
116
|
export var mockedPage3 = {
|
|
116
|
-
type:
|
|
117
|
-
sys: { id: mockedPage3SysId },
|
|
118
|
-
parent: { sys: mockedRoot.sys },
|
|
119
|
-
path: mockedRoot.path +
|
|
117
|
+
type: "page",
|
|
118
|
+
sys: { id: mockedPage3SysId, contentTypeId: contentTypeId },
|
|
119
|
+
parent: { sys: { id: mockedRoot.sys.id } },
|
|
120
|
+
path: mockedRoot.path + "/" + mockedPage3SysId,
|
|
120
121
|
slug: mockedPage3SysId,
|
|
121
122
|
childPages: [],
|
|
122
123
|
};
|
|
123
124
|
var mockedRedirect1 = {
|
|
124
|
-
type:
|
|
125
|
+
type: "alias",
|
|
125
126
|
sys: { id: mockedRedirect1SysId },
|
|
126
127
|
page: { sys: { id: mockedRedirect1SysId } },
|
|
127
|
-
path: mockedRoot.path +
|
|
128
|
+
path: mockedRoot.path + "/" + mockedRedirect1SysId,
|
|
128
129
|
parent: { sys: { id: mockedRoot.sys.id } },
|
|
129
130
|
};
|
|
130
131
|
var mockedRedirect2 = {
|
|
131
|
-
type:
|
|
132
|
+
type: "redirect",
|
|
132
133
|
sys: { id: mockedRedirect2SysId },
|
|
133
134
|
page: { sys: { id: mockedRedirect2SysId } },
|
|
134
|
-
path: mockedRoot.path +
|
|
135
|
+
path: mockedRoot.path + "/" + mockedRedirect2SysId,
|
|
135
136
|
parent: { sys: { id: mockedRoot.sys.id } },
|
|
136
137
|
};
|
|
137
138
|
var mockedRedirect3 = {
|
|
138
|
-
type:
|
|
139
|
+
type: "alias",
|
|
139
140
|
sys: { id: mockedRedirect3SysId },
|
|
140
141
|
page: { sys: { id: mockedRedirect3SysId } },
|
|
141
|
-
path: mockedRoot.path +
|
|
142
|
+
path: mockedRoot.path + "/" + mockedRedirect3SysId,
|
|
142
143
|
parent: { sys: { id: mockedRoot.sys.id } },
|
|
143
144
|
};
|
|
144
145
|
export var mockedRedirects = [
|
|
@@ -158,9 +159,9 @@ export var mockedPages = __spreadArray([
|
|
|
158
159
|
mockedPage3
|
|
159
160
|
], __read(mockedRedirects), false);
|
|
160
161
|
export var mockedLocalizedSitemap = {
|
|
161
|
-
root: { sys: mockedRoot.sys },
|
|
162
|
+
root: { sys: { id: mockedRoot.sys.id } },
|
|
162
163
|
sitemap: new Map(mockedPages.map(function (page) {
|
|
163
|
-
if (!page.parent && page.type ===
|
|
164
|
+
if (!page.parent && page.type === "page") {
|
|
164
165
|
return [page.sys.id, page];
|
|
165
166
|
}
|
|
166
167
|
return [page.sys.id, page];
|
|
@@ -168,10 +169,10 @@ export var mockedLocalizedSitemap = {
|
|
|
168
169
|
pageIdByPath: new Map(mockedPages.map(function (page) { return [page.path, page.sys.id]; })),
|
|
169
170
|
};
|
|
170
171
|
export var mockedPage1WithCircularReference = {
|
|
171
|
-
type:
|
|
172
|
-
sys: { id: mockedPage1SysId },
|
|
172
|
+
type: "page",
|
|
173
|
+
sys: { id: mockedPage1SysId, contentTypeId: contentTypeId },
|
|
173
174
|
parent: { sys: { id: mockedRoot.sys.id } },
|
|
174
|
-
path: mockedRoot.path +
|
|
175
|
+
path: mockedRoot.path + "/" + mockedPage1SysId,
|
|
175
176
|
slug: mockedPage1SysId,
|
|
176
177
|
childPages: [{ sys: { id: mockedRootSysId } }],
|
|
177
178
|
};
|
|
@@ -10,23 +10,23 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
var _a;
|
|
13
|
-
import { right } from
|
|
14
|
-
import { jsonStrigifyMapReplacer } from
|
|
15
|
-
import { buildLocalizedSitemap } from
|
|
16
|
-
import { mockedPages, mockedCircularReferencesPages, mockedPage1WithCircularReference, mockedRoot, mockedLocalizedSitemap, } from
|
|
13
|
+
import { right } from "../../../utils/fp-utils";
|
|
14
|
+
import { jsonStrigifyMapReplacer } from "../../../utils/json-stringify-map-replacer";
|
|
15
|
+
import { buildLocalizedSitemap } from "./build-localized-sitemap";
|
|
16
|
+
import { mockedPages, mockedCircularReferencesPages, mockedPage1WithCircularReference, mockedRoot, mockedLocalizedSitemap, } from "./__mocks__/mocked-localized-sitemap";
|
|
17
17
|
var defaultLocale = {
|
|
18
|
-
code:
|
|
18
|
+
code: "en",
|
|
19
19
|
default: true,
|
|
20
20
|
fallbackCode: null,
|
|
21
|
-
name:
|
|
21
|
+
name: "English",
|
|
22
22
|
};
|
|
23
|
-
var pageContentTypeId =
|
|
24
|
-
var pageContentTypeSlugFieldId =
|
|
25
|
-
var pageContentTypeChildPagesFieldId =
|
|
26
|
-
var redirectContentTypeId =
|
|
27
|
-
var redirectContentTypePage =
|
|
28
|
-
var redirectContentTypePath =
|
|
29
|
-
var redirectContentTypeType =
|
|
23
|
+
var pageContentTypeId = "page";
|
|
24
|
+
var pageContentTypeSlugFieldId = "slug";
|
|
25
|
+
var pageContentTypeChildPagesFieldId = "childPages";
|
|
26
|
+
var redirectContentTypeId = "redirect";
|
|
27
|
+
var redirectContentTypePage = "page";
|
|
28
|
+
var redirectContentTypePath = "path";
|
|
29
|
+
var redirectContentTypeType = "type";
|
|
30
30
|
var contentTypes = new Map([
|
|
31
31
|
[
|
|
32
32
|
pageContentTypeId,
|
|
@@ -38,8 +38,8 @@ var contentTypes = new Map([
|
|
|
38
38
|
{
|
|
39
39
|
id: pageContentTypeSlugFieldId,
|
|
40
40
|
localized: true,
|
|
41
|
-
name:
|
|
42
|
-
type: "Symbol"
|
|
41
|
+
name: "Slug",
|
|
42
|
+
type: "Symbol",
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
[
|
|
@@ -47,8 +47,8 @@ var contentTypes = new Map([
|
|
|
47
47
|
{
|
|
48
48
|
id: pageContentTypeChildPagesFieldId,
|
|
49
49
|
localized: true,
|
|
50
|
-
name:
|
|
51
|
-
type: "Array"
|
|
50
|
+
name: "Child Pages",
|
|
51
|
+
type: "Array",
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
54
|
]),
|
|
@@ -64,8 +64,8 @@ var contentTypes = new Map([
|
|
|
64
64
|
{
|
|
65
65
|
id: redirectContentTypePage,
|
|
66
66
|
localized: true,
|
|
67
|
-
name:
|
|
68
|
-
type: "Link"
|
|
67
|
+
name: "Page",
|
|
68
|
+
type: "Link",
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
[
|
|
@@ -73,8 +73,8 @@ var contentTypes = new Map([
|
|
|
73
73
|
{
|
|
74
74
|
id: redirectContentTypePath,
|
|
75
75
|
localized: true,
|
|
76
|
-
name:
|
|
77
|
-
type: "Symbol"
|
|
76
|
+
name: "Path",
|
|
77
|
+
type: "Symbol",
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
[
|
|
@@ -82,8 +82,8 @@ var contentTypes = new Map([
|
|
|
82
82
|
{
|
|
83
83
|
id: redirectContentTypeType,
|
|
84
84
|
localized: true,
|
|
85
|
-
name:
|
|
86
|
-
type: "Symbol"
|
|
85
|
+
name: "Type",
|
|
86
|
+
type: "Symbol",
|
|
87
87
|
},
|
|
88
88
|
],
|
|
89
89
|
]),
|
|
@@ -140,7 +140,7 @@ var redirectToEntry = function (page, tagsIds) {
|
|
|
140
140
|
});
|
|
141
141
|
};
|
|
142
142
|
describe(buildLocalizedSitemap, function () {
|
|
143
|
-
test(
|
|
143
|
+
test("Not enough data to build sitemap", function () {
|
|
144
144
|
var emptyData = {
|
|
145
145
|
contentTypes: contentTypes,
|
|
146
146
|
defaultLocaleCode: defaultLocale.code,
|
|
@@ -149,17 +149,17 @@ describe(buildLocalizedSitemap, function () {
|
|
|
149
149
|
pages: new Map(),
|
|
150
150
|
redirects: [],
|
|
151
151
|
};
|
|
152
|
-
expect(buildLocalizedSitemap(emptyData, { pageContentTypes: {} },
|
|
152
|
+
expect(buildLocalizedSitemap(emptyData, { pageContentTypes: {} }, "pageHome", defaultLocale)._tag).toBe("Left");
|
|
153
153
|
});
|
|
154
|
-
test(
|
|
155
|
-
var pageHomeTagId =
|
|
154
|
+
test("Build localized sitemap", function () {
|
|
155
|
+
var pageHomeTagId = "pagHome";
|
|
156
156
|
var pagesEntries = mockedPages.flatMap(function (page) {
|
|
157
|
-
return page.type ===
|
|
158
|
-
? [pageToEntry(page, page.sys.id ===
|
|
157
|
+
return page.type === "page"
|
|
158
|
+
? [pageToEntry(page, page.sys.id === "root" ? [pageHomeTagId] : [])]
|
|
159
159
|
: [];
|
|
160
160
|
});
|
|
161
161
|
var redirectsEntries = mockedPages.flatMap(function (page) {
|
|
162
|
-
return page.type !==
|
|
162
|
+
return page.type !== "page" ? [redirectToEntry(page)] : [];
|
|
163
163
|
});
|
|
164
164
|
var data = {
|
|
165
165
|
contentTypes: contentTypes,
|
|
@@ -176,10 +176,10 @@ describe(buildLocalizedSitemap, function () {
|
|
|
176
176
|
};
|
|
177
177
|
expect(JSON.parse(JSON.stringify(buildLocalizedSitemap(data, options, pageHomeTagId, defaultLocale), jsonStrigifyMapReplacer))).toMatchObject(JSON.parse(JSON.stringify(right(mockedLocalizedSitemap), jsonStrigifyMapReplacer)));
|
|
178
178
|
});
|
|
179
|
-
test(
|
|
180
|
-
var pageHomeTagId =
|
|
179
|
+
test("Handle reference cycles", function () {
|
|
180
|
+
var pageHomeTagId = "pagHome";
|
|
181
181
|
var entries = mockedCircularReferencesPages.map(function (page) {
|
|
182
|
-
return pageToEntry(page, page.sys.id ===
|
|
182
|
+
return pageToEntry(page, page.sys.id === "root" ? [pageHomeTagId] : []);
|
|
183
183
|
});
|
|
184
184
|
var data = {
|
|
185
185
|
contentTypes: contentTypes,
|
|
@@ -195,7 +195,7 @@ describe(buildLocalizedSitemap, function () {
|
|
|
195
195
|
redirects: [],
|
|
196
196
|
};
|
|
197
197
|
var expectedLocalizedSitemap = right({
|
|
198
|
-
root: { sys: mockedRoot.sys },
|
|
198
|
+
root: { sys: { id: mockedRoot.sys.id } },
|
|
199
199
|
sitemap: new Map([
|
|
200
200
|
__assign(__assign({}, mockedRoot), { childPages: [
|
|
201
201
|
{ sys: { id: mockedPage1WithCircularReference.sys.id } },
|
|
@@ -129,7 +129,9 @@ var createArboretumClient = function (config) { return __awaiter(void 0, void 0,
|
|
|
129
129
|
options: __assign(__assign({}, options), { includeEntryStatus: includeEntryStatus }),
|
|
130
130
|
localeTagIdPrefix: localeTagIdPrefix,
|
|
131
131
|
pageHomeTagId: options.homePageTagId || pageHomeTagId,
|
|
132
|
-
contentfulClientType: config.type
|
|
132
|
+
contentfulClientType: config.type === "cda-client" && config.contentful.client.withAllLocales
|
|
133
|
+
? "cda-client-with-all-locales"
|
|
134
|
+
: config.type,
|
|
133
135
|
pageTagIdPrefix: pageTagIdPrefix,
|
|
134
136
|
cmaPreviewClientApi: cmaPreviewClientApi,
|
|
135
137
|
};
|
|
@@ -83,7 +83,7 @@ var filterOutNestedEntriesFieldsOtherThanSysEff = function (entry) {
|
|
|
83
83
|
return entry;
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
var getAllEntriesRecursively = function (_a, contentType, skip, acc, select, refFieldsToFilterOut, limit) {
|
|
86
|
+
var getAllEntriesRecursively = function (_a, contentfulClientType, contentType, skip, acc, select, refFieldsToFilterOut, limit) {
|
|
87
87
|
var getEntries = _a.getEntries;
|
|
88
88
|
if (refFieldsToFilterOut === void 0) { refFieldsToFilterOut = []; }
|
|
89
89
|
if (limit === void 0) { limit = 1000; }
|
|
@@ -97,7 +97,9 @@ var getAllEntriesRecursively = function (_a, contentType, skip, acc, select, ref
|
|
|
97
97
|
content_type: contentType,
|
|
98
98
|
include: 0,
|
|
99
99
|
select: select,
|
|
100
|
-
locale: "
|
|
100
|
+
locale: contentfulClientType === "cda-client-with-all-locales"
|
|
101
|
+
? undefined
|
|
102
|
+
: "*",
|
|
101
103
|
})];
|
|
102
104
|
case 1:
|
|
103
105
|
items = (_b.sent()).items;
|
|
@@ -108,7 +110,7 @@ var getAllEntriesRecursively = function (_a, contentType, skip, acc, select, ref
|
|
|
108
110
|
});
|
|
109
111
|
acc.push.apply(acc, __spreadArray([], __read(items), false));
|
|
110
112
|
return [2 /*return*/, items.length >= limit
|
|
111
|
-
? (0, exports.getAllEntriesRecursively)({ getEntries: getEntries }, contentType, skip + limit, acc, select)
|
|
113
|
+
? (0, exports.getAllEntriesRecursively)({ getEntries: getEntries }, contentfulClientType, contentType, skip + limit, acc, select)
|
|
112
114
|
: acc];
|
|
113
115
|
}
|
|
114
116
|
});
|
|
@@ -69,7 +69,7 @@ describe(get_all_entries_recursively_1.getAllEntriesRecursively, function () {
|
|
|
69
69
|
var entries;
|
|
70
70
|
return __generator(this, function (_a) {
|
|
71
71
|
switch (_a.label) {
|
|
72
|
-
case 0: return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, 0), testContentTypeId, 0, [], undefined, [], 10)];
|
|
72
|
+
case 0: return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, 0), "cda-client", testContentTypeId, 0, [], undefined, [], 10)];
|
|
73
73
|
case 1:
|
|
74
74
|
entries = _a.sent();
|
|
75
75
|
expect(entries.length).toBe(0);
|
|
@@ -83,7 +83,7 @@ describe(get_all_entries_recursively_1.getAllEntriesRecursively, function () {
|
|
|
83
83
|
switch (_a.label) {
|
|
84
84
|
case 0:
|
|
85
85
|
total = 10;
|
|
86
|
-
return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, total), testContentTypeId, 0, [], undefined, [], 10)];
|
|
86
|
+
return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, total), "cda-client", testContentTypeId, 0, [], undefined, [], 10)];
|
|
87
87
|
case 1:
|
|
88
88
|
entries = _a.sent();
|
|
89
89
|
entriesIds = entries.map(function (e) { return e.sys.id; });
|
|
@@ -101,7 +101,7 @@ describe(get_all_entries_recursively_1.getAllEntriesRecursively, function () {
|
|
|
101
101
|
switch (_a.label) {
|
|
102
102
|
case 0:
|
|
103
103
|
total = 101;
|
|
104
|
-
return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, total), testContentTypeId, 0, [], undefined, [], 10)];
|
|
104
|
+
return [4 /*yield*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)((0, mocked_contentful_entries_client_api_1.mockedContentfulEntriesClientApi)(testContentTypeId, total), "cda-client", testContentTypeId, 0, [], undefined, [], 10)];
|
|
105
105
|
case 1:
|
|
106
106
|
entries = _a.sent();
|
|
107
107
|
entriesIds = entries.map(function (e) { return e.sys.id; });
|
|
@@ -86,7 +86,7 @@ var getAllPageEntriesRecursively = function (_a, contentfulClientType, pageConte
|
|
|
86
86
|
pageContentTypeOpt.childPagesFieldId,
|
|
87
87
|
pageContentTypeOpt.titleFieldId,
|
|
88
88
|
].flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
89
|
-
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)({ getEntries: getEntries }, pageContentTypeOpt.id, skip, acc,
|
|
89
|
+
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)({ getEntries: getEntries }, contentfulClientType, pageContentTypeOpt.id, skip, acc,
|
|
90
90
|
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
91
91
|
{
|
|
92
92
|
"status": 400,
|
|
@@ -85,7 +85,7 @@ var getAllRedirectEntriesRecursively = function (ctx, redirectContentType, skip,
|
|
|
85
85
|
redirectContentType.typeFieldId,
|
|
86
86
|
redirectContentType.pathFieldId,
|
|
87
87
|
].flatMap(function (id) { return (id ? ["fields.".concat(id)] : []); });
|
|
88
|
-
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)(ctx.clientApi, redirectContentType.id, skip, acc,
|
|
88
|
+
return [2 /*return*/, (0, get_all_entries_recursively_1.getAllEntriesRecursively)(ctx.clientApi, ctx.contentfulClientType, redirectContentType.id, skip, acc,
|
|
89
89
|
/* For some reason select param causes errors in CMA. I'm getting the following response:
|
|
90
90
|
{
|
|
91
91
|
"status": 400,
|
|
@@ -22,6 +22,7 @@ var pageEntryAdapter = function (data, slugField, titleField, childPagesField, l
|
|
|
22
22
|
sys: {
|
|
23
23
|
id: entry.sys.id,
|
|
24
24
|
cmaOnlyStatus: entry.sys.cmaOnlyStatus,
|
|
25
|
+
contentTypeId: entry.sys.contentType.sys.id
|
|
25
26
|
},
|
|
26
27
|
metadata: entry.metadata,
|
|
27
28
|
childPages: (childPages === null || childPages === void 0 ? void 0 : childPages.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 } }] : []; })) || [],
|
|
@@ -39,11 +39,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
var mocked_localized_sitemap_1 = require("../helpers/__mocks__/mocked-localized-sitemap");
|
|
40
40
|
var to_arboretum_page_adapter_1 = require("./to-arboretum-page-adapter");
|
|
41
41
|
var localeCode = 'en';
|
|
42
|
+
var contentTypeId = "page";
|
|
42
43
|
var toArboretumPageF = function (options) {
|
|
43
44
|
return (0, to_arboretum_page_adapter_1.toArboretumPage)(mocked_localized_sitemap_1.mockedLocalizedSitemap, localeCode, options);
|
|
44
45
|
};
|
|
45
46
|
var arboretumPageRoot = {
|
|
46
47
|
type: 'page',
|
|
48
|
+
contentTypeId: contentTypeId,
|
|
47
49
|
id: mocked_localized_sitemap_1.mockedRoot.sys.id,
|
|
48
50
|
localeCode: localeCode,
|
|
49
51
|
path: mocked_localized_sitemap_1.mockedRoot.path,
|
|
@@ -52,6 +54,7 @@ var arboretumPageRoot = {
|
|
|
52
54
|
};
|
|
53
55
|
var arboretumPagePage1 = {
|
|
54
56
|
id: mocked_localized_sitemap_1.mockedPage1.sys.id,
|
|
57
|
+
contentTypeId: contentTypeId,
|
|
55
58
|
localeCode: localeCode,
|
|
56
59
|
path: mocked_localized_sitemap_1.mockedPage1.path,
|
|
57
60
|
slug: mocked_localized_sitemap_1.mockedPage1.slug,
|
|
@@ -60,6 +63,7 @@ var arboretumPagePage1 = {
|
|
|
60
63
|
};
|
|
61
64
|
var arboretumPagePage1_1 = {
|
|
62
65
|
id: mocked_localized_sitemap_1.mockedPage1_1.sys.id,
|
|
66
|
+
contentTypeId: contentTypeId,
|
|
63
67
|
localeCode: localeCode,
|
|
64
68
|
path: mocked_localized_sitemap_1.mockedPage1_1.path,
|
|
65
69
|
slug: mocked_localized_sitemap_1.mockedPage1_1.slug,
|
|
@@ -68,6 +72,7 @@ var arboretumPagePage1_1 = {
|
|
|
68
72
|
};
|
|
69
73
|
var arboretumPage1_1_1 = {
|
|
70
74
|
id: mocked_localized_sitemap_1.mockedPage1_1_1.sys.id,
|
|
75
|
+
contentTypeId: contentTypeId,
|
|
71
76
|
localeCode: localeCode,
|
|
72
77
|
path: mocked_localized_sitemap_1.mockedPage1_1_1.path,
|
|
73
78
|
slug: mocked_localized_sitemap_1.mockedPage1_1_1.slug,
|
|
@@ -76,6 +81,7 @@ var arboretumPage1_1_1 = {
|
|
|
76
81
|
};
|
|
77
82
|
var arboretumPage1_1_2 = {
|
|
78
83
|
id: mocked_localized_sitemap_1.mockedPage1_1_2.sys.id,
|
|
84
|
+
contentTypeId: contentTypeId,
|
|
79
85
|
localeCode: localeCode,
|
|
80
86
|
path: mocked_localized_sitemap_1.mockedPage1_1_2.path,
|
|
81
87
|
slug: mocked_localized_sitemap_1.mockedPage1_1_2.slug,
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toArboretumPageWithMissingData = void 0;
|
|
4
4
|
var toArboretumPageWithMissingData = function (localeCode) {
|
|
5
5
|
return function (page, ancestors, children) { return ({
|
|
6
|
-
type:
|
|
6
|
+
type: "page",
|
|
7
|
+
contentTypeId: page.sys.contentTypeId,
|
|
7
8
|
id: page.sys.id,
|
|
8
9
|
title: page.title,
|
|
9
10
|
cmaOnlyStatus: page.sys.cmaOnlyStatus,
|