@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
|
@@ -26,24 +26,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.mockedLocalizedSitemapWithCircularReference = exports.mockedCircularReferencesPages = exports.mockedPage1WithCircularReference = exports.mockedLocalizedSitemap = exports.mockedPages = exports.mockedRedirects = exports.mockedPage3 = exports.mockedPage2_1 = exports.mockedPage2 = exports.mockedPage1_1_2 = exports.mockedPage1_1_1 = exports.mockedPage1_2 = exports.mockedPage1_1 = exports.mockedPage1 = exports.mockedRoot = void 0;
|
|
29
|
-
var mockedRootSysId =
|
|
30
|
-
var mockedPage1SysId =
|
|
31
|
-
var mockedPage1_1SysId =
|
|
32
|
-
var mockedPage1_1_1SysId =
|
|
33
|
-
var mockedPage1_1_2SysId =
|
|
34
|
-
var mockedPage1_2SysId =
|
|
35
|
-
var mockedPage2SysId =
|
|
36
|
-
var mockedPage2_1SysId =
|
|
37
|
-
var mockedPage3SysId =
|
|
38
|
-
var mockedRedirect1SysId =
|
|
39
|
-
var mockedRedirect2SysId =
|
|
40
|
-
var mockedRedirect3SysId =
|
|
29
|
+
var mockedRootSysId = "root";
|
|
30
|
+
var mockedPage1SysId = "page1";
|
|
31
|
+
var mockedPage1_1SysId = "page1-1";
|
|
32
|
+
var mockedPage1_1_1SysId = "page1-1-1";
|
|
33
|
+
var mockedPage1_1_2SysId = "page1-1-2";
|
|
34
|
+
var mockedPage1_2SysId = "page1-2";
|
|
35
|
+
var mockedPage2SysId = "page2";
|
|
36
|
+
var mockedPage2_1SysId = "page2_1";
|
|
37
|
+
var mockedPage3SysId = "page3";
|
|
38
|
+
var mockedRedirect1SysId = "redirect1";
|
|
39
|
+
var mockedRedirect2SysId = "redirect2";
|
|
40
|
+
var mockedRedirect3SysId = "redirect3";
|
|
41
|
+
var contentTypeId = "page";
|
|
41
42
|
exports.mockedRoot = {
|
|
42
|
-
type:
|
|
43
|
-
sys: { id: mockedRootSysId },
|
|
43
|
+
type: "page",
|
|
44
|
+
sys: { id: mockedRootSysId, contentTypeId: contentTypeId },
|
|
44
45
|
parent: undefined,
|
|
45
46
|
slug: mockedRootSysId,
|
|
46
|
-
path:
|
|
47
|
+
path: "/en",
|
|
47
48
|
childPages: [
|
|
48
49
|
{ sys: { id: mockedPage1SysId } },
|
|
49
50
|
{ sys: { id: mockedPage2SysId } },
|
|
@@ -54,21 +55,21 @@ exports.mockedRoot = {
|
|
|
54
55
|
],
|
|
55
56
|
};
|
|
56
57
|
exports.mockedPage1 = {
|
|
57
|
-
type:
|
|
58
|
-
sys: { id: mockedPage1SysId },
|
|
59
|
-
parent: { sys: exports.mockedRoot.sys },
|
|
58
|
+
type: "page",
|
|
59
|
+
sys: { id: mockedPage1SysId, contentTypeId: contentTypeId },
|
|
60
|
+
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
60
61
|
slug: mockedPage1SysId,
|
|
61
|
-
path: exports.mockedRoot.path +
|
|
62
|
+
path: exports.mockedRoot.path + "/" + mockedPage1SysId,
|
|
62
63
|
childPages: [
|
|
63
64
|
{ sys: { id: mockedPage1_1SysId } },
|
|
64
65
|
{ sys: { id: mockedPage1_2SysId } },
|
|
65
66
|
],
|
|
66
67
|
};
|
|
67
68
|
exports.mockedPage1_1 = {
|
|
68
|
-
type:
|
|
69
|
-
sys: { id: mockedPage1_1SysId },
|
|
70
|
-
parent: { sys: exports.mockedPage1.sys },
|
|
71
|
-
path: exports.mockedPage1.path +
|
|
69
|
+
type: "page",
|
|
70
|
+
sys: { id: mockedPage1_1SysId, contentTypeId: contentTypeId },
|
|
71
|
+
parent: { sys: { id: exports.mockedPage1.sys.id } },
|
|
72
|
+
path: exports.mockedPage1.path + "/" + mockedPage1_1SysId,
|
|
72
73
|
slug: mockedPage1_1SysId,
|
|
73
74
|
childPages: [
|
|
74
75
|
{ sys: { id: mockedPage1_1_1SysId } },
|
|
@@ -76,72 +77,72 @@ exports.mockedPage1_1 = {
|
|
|
76
77
|
],
|
|
77
78
|
};
|
|
78
79
|
exports.mockedPage1_2 = {
|
|
79
|
-
type:
|
|
80
|
-
sys: { id: mockedPage1_2SysId },
|
|
81
|
-
parent: { sys: exports.mockedPage1.sys },
|
|
82
|
-
path: exports.mockedPage1.path +
|
|
80
|
+
type: "page",
|
|
81
|
+
sys: { id: mockedPage1_2SysId, contentTypeId: contentTypeId },
|
|
82
|
+
parent: { sys: { id: exports.mockedPage1.sys.id } },
|
|
83
|
+
path: exports.mockedPage1.path + "/" + mockedPage1_2SysId,
|
|
83
84
|
slug: mockedPage1_2SysId,
|
|
84
85
|
childPages: [],
|
|
85
86
|
};
|
|
86
87
|
exports.mockedPage1_1_1 = {
|
|
87
|
-
type:
|
|
88
|
-
sys: { id: mockedPage1_1_1SysId },
|
|
89
|
-
parent: { sys: exports.mockedPage1_1.sys },
|
|
90
|
-
path: exports.mockedPage1_1.path +
|
|
88
|
+
type: "page",
|
|
89
|
+
sys: { id: mockedPage1_1_1SysId, contentTypeId: contentTypeId },
|
|
90
|
+
parent: { sys: { id: exports.mockedPage1_1.sys.id } },
|
|
91
|
+
path: exports.mockedPage1_1.path + "/" + mockedPage1_1_1SysId,
|
|
91
92
|
slug: mockedPage1_1_1SysId,
|
|
92
93
|
childPages: [],
|
|
93
94
|
};
|
|
94
95
|
exports.mockedPage1_1_2 = {
|
|
95
|
-
type:
|
|
96
|
-
sys: { id: mockedPage1_1_2SysId },
|
|
97
|
-
parent: { sys: exports.mockedPage1_1.sys },
|
|
98
|
-
path: exports.mockedPage1_1.path +
|
|
96
|
+
type: "page",
|
|
97
|
+
sys: { id: mockedPage1_1_2SysId, contentTypeId: contentTypeId },
|
|
98
|
+
parent: { sys: { id: exports.mockedPage1_1.sys.id } },
|
|
99
|
+
path: exports.mockedPage1_1.path + "/" + mockedPage1_1_2SysId,
|
|
99
100
|
slug: mockedPage1_1_2SysId,
|
|
100
101
|
childPages: [],
|
|
101
102
|
};
|
|
102
103
|
exports.mockedPage2 = {
|
|
103
|
-
type:
|
|
104
|
-
sys: { id: mockedPage2SysId },
|
|
105
|
-
parent: { sys: exports.mockedRoot.sys },
|
|
106
|
-
path: exports.mockedRoot.path +
|
|
104
|
+
type: "page",
|
|
105
|
+
sys: { id: mockedPage2SysId, contentTypeId: contentTypeId },
|
|
106
|
+
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
107
|
+
path: exports.mockedRoot.path + "/" + mockedPage2SysId,
|
|
107
108
|
slug: mockedPage2SysId,
|
|
108
109
|
childPages: [{ sys: { id: mockedPage2_1SysId } }],
|
|
109
110
|
};
|
|
110
111
|
exports.mockedPage2_1 = {
|
|
111
|
-
type:
|
|
112
|
-
sys: { id: mockedPage2_1SysId },
|
|
113
|
-
parent: { sys: exports.mockedPage2.sys },
|
|
114
|
-
path: exports.mockedPage2.path +
|
|
112
|
+
type: "page",
|
|
113
|
+
sys: { id: mockedPage2_1SysId, contentTypeId: contentTypeId },
|
|
114
|
+
parent: { sys: { id: exports.mockedPage2.sys.id } },
|
|
115
|
+
path: exports.mockedPage2.path + "/" + mockedPage2_1SysId,
|
|
115
116
|
slug: mockedPage2_1SysId,
|
|
116
117
|
childPages: [],
|
|
117
118
|
};
|
|
118
119
|
exports.mockedPage3 = {
|
|
119
|
-
type:
|
|
120
|
-
sys: { id: mockedPage3SysId },
|
|
121
|
-
parent: { sys: exports.mockedRoot.sys },
|
|
122
|
-
path: exports.mockedRoot.path +
|
|
120
|
+
type: "page",
|
|
121
|
+
sys: { id: mockedPage3SysId, contentTypeId: contentTypeId },
|
|
122
|
+
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
123
|
+
path: exports.mockedRoot.path + "/" + mockedPage3SysId,
|
|
123
124
|
slug: mockedPage3SysId,
|
|
124
125
|
childPages: [],
|
|
125
126
|
};
|
|
126
127
|
var mockedRedirect1 = {
|
|
127
|
-
type:
|
|
128
|
+
type: "alias",
|
|
128
129
|
sys: { id: mockedRedirect1SysId },
|
|
129
130
|
page: { sys: { id: mockedRedirect1SysId } },
|
|
130
|
-
path: exports.mockedRoot.path +
|
|
131
|
+
path: exports.mockedRoot.path + "/" + mockedRedirect1SysId,
|
|
131
132
|
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
132
133
|
};
|
|
133
134
|
var mockedRedirect2 = {
|
|
134
|
-
type:
|
|
135
|
+
type: "redirect",
|
|
135
136
|
sys: { id: mockedRedirect2SysId },
|
|
136
137
|
page: { sys: { id: mockedRedirect2SysId } },
|
|
137
|
-
path: exports.mockedRoot.path +
|
|
138
|
+
path: exports.mockedRoot.path + "/" + mockedRedirect2SysId,
|
|
138
139
|
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
139
140
|
};
|
|
140
141
|
var mockedRedirect3 = {
|
|
141
|
-
type:
|
|
142
|
+
type: "alias",
|
|
142
143
|
sys: { id: mockedRedirect3SysId },
|
|
143
144
|
page: { sys: { id: mockedRedirect3SysId } },
|
|
144
|
-
path: exports.mockedRoot.path +
|
|
145
|
+
path: exports.mockedRoot.path + "/" + mockedRedirect3SysId,
|
|
145
146
|
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
146
147
|
};
|
|
147
148
|
exports.mockedRedirects = [
|
|
@@ -161,9 +162,9 @@ exports.mockedPages = __spreadArray([
|
|
|
161
162
|
exports.mockedPage3
|
|
162
163
|
], __read(exports.mockedRedirects), false);
|
|
163
164
|
exports.mockedLocalizedSitemap = {
|
|
164
|
-
root: { sys: exports.mockedRoot.sys },
|
|
165
|
+
root: { sys: { id: exports.mockedRoot.sys.id } },
|
|
165
166
|
sitemap: new Map(exports.mockedPages.map(function (page) {
|
|
166
|
-
if (!page.parent && page.type ===
|
|
167
|
+
if (!page.parent && page.type === "page") {
|
|
167
168
|
return [page.sys.id, page];
|
|
168
169
|
}
|
|
169
170
|
return [page.sys.id, page];
|
|
@@ -171,10 +172,10 @@ exports.mockedLocalizedSitemap = {
|
|
|
171
172
|
pageIdByPath: new Map(exports.mockedPages.map(function (page) { return [page.path, page.sys.id]; })),
|
|
172
173
|
};
|
|
173
174
|
exports.mockedPage1WithCircularReference = {
|
|
174
|
-
type:
|
|
175
|
-
sys: { id: mockedPage1SysId },
|
|
175
|
+
type: "page",
|
|
176
|
+
sys: { id: mockedPage1SysId, contentTypeId: contentTypeId },
|
|
176
177
|
parent: { sys: { id: exports.mockedRoot.sys.id } },
|
|
177
|
-
path: exports.mockedRoot.path +
|
|
178
|
+
path: exports.mockedRoot.path + "/" + mockedPage1SysId,
|
|
178
179
|
slug: mockedPage1SysId,
|
|
179
180
|
childPages: [{ sys: { id: mockedRootSysId } }],
|
|
180
181
|
};
|
|
@@ -17,18 +17,18 @@ var json_stringify_map_replacer_1 = require("../../../utils/json-stringify-map-r
|
|
|
17
17
|
var build_localized_sitemap_1 = require("./build-localized-sitemap");
|
|
18
18
|
var mocked_localized_sitemap_1 = require("./__mocks__/mocked-localized-sitemap");
|
|
19
19
|
var defaultLocale = {
|
|
20
|
-
code:
|
|
20
|
+
code: "en",
|
|
21
21
|
default: true,
|
|
22
22
|
fallbackCode: null,
|
|
23
|
-
name:
|
|
23
|
+
name: "English",
|
|
24
24
|
};
|
|
25
|
-
var pageContentTypeId =
|
|
26
|
-
var pageContentTypeSlugFieldId =
|
|
27
|
-
var pageContentTypeChildPagesFieldId =
|
|
28
|
-
var redirectContentTypeId =
|
|
29
|
-
var redirectContentTypePage =
|
|
30
|
-
var redirectContentTypePath =
|
|
31
|
-
var redirectContentTypeType =
|
|
25
|
+
var pageContentTypeId = "page";
|
|
26
|
+
var pageContentTypeSlugFieldId = "slug";
|
|
27
|
+
var pageContentTypeChildPagesFieldId = "childPages";
|
|
28
|
+
var redirectContentTypeId = "redirect";
|
|
29
|
+
var redirectContentTypePage = "page";
|
|
30
|
+
var redirectContentTypePath = "path";
|
|
31
|
+
var redirectContentTypeType = "type";
|
|
32
32
|
var contentTypes = new Map([
|
|
33
33
|
[
|
|
34
34
|
pageContentTypeId,
|
|
@@ -40,8 +40,8 @@ var contentTypes = new Map([
|
|
|
40
40
|
{
|
|
41
41
|
id: pageContentTypeSlugFieldId,
|
|
42
42
|
localized: true,
|
|
43
|
-
name:
|
|
44
|
-
type: "Symbol"
|
|
43
|
+
name: "Slug",
|
|
44
|
+
type: "Symbol",
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
[
|
|
@@ -49,8 +49,8 @@ var contentTypes = new Map([
|
|
|
49
49
|
{
|
|
50
50
|
id: pageContentTypeChildPagesFieldId,
|
|
51
51
|
localized: true,
|
|
52
|
-
name:
|
|
53
|
-
type: "Array"
|
|
52
|
+
name: "Child Pages",
|
|
53
|
+
type: "Array",
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
56
|
]),
|
|
@@ -66,8 +66,8 @@ var contentTypes = new Map([
|
|
|
66
66
|
{
|
|
67
67
|
id: redirectContentTypePage,
|
|
68
68
|
localized: true,
|
|
69
|
-
name:
|
|
70
|
-
type: "Link"
|
|
69
|
+
name: "Page",
|
|
70
|
+
type: "Link",
|
|
71
71
|
},
|
|
72
72
|
],
|
|
73
73
|
[
|
|
@@ -75,8 +75,8 @@ var contentTypes = new Map([
|
|
|
75
75
|
{
|
|
76
76
|
id: redirectContentTypePath,
|
|
77
77
|
localized: true,
|
|
78
|
-
name:
|
|
79
|
-
type: "Symbol"
|
|
78
|
+
name: "Path",
|
|
79
|
+
type: "Symbol",
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
[
|
|
@@ -84,8 +84,8 @@ var contentTypes = new Map([
|
|
|
84
84
|
{
|
|
85
85
|
id: redirectContentTypeType,
|
|
86
86
|
localized: true,
|
|
87
|
-
name:
|
|
88
|
-
type: "Symbol"
|
|
87
|
+
name: "Type",
|
|
88
|
+
type: "Symbol",
|
|
89
89
|
},
|
|
90
90
|
],
|
|
91
91
|
]),
|
|
@@ -142,7 +142,7 @@ var redirectToEntry = function (page, tagsIds) {
|
|
|
142
142
|
});
|
|
143
143
|
};
|
|
144
144
|
describe(build_localized_sitemap_1.buildLocalizedSitemap, function () {
|
|
145
|
-
test(
|
|
145
|
+
test("Not enough data to build sitemap", function () {
|
|
146
146
|
var emptyData = {
|
|
147
147
|
contentTypes: contentTypes,
|
|
148
148
|
defaultLocaleCode: defaultLocale.code,
|
|
@@ -151,17 +151,17 @@ describe(build_localized_sitemap_1.buildLocalizedSitemap, function () {
|
|
|
151
151
|
pages: new Map(),
|
|
152
152
|
redirects: [],
|
|
153
153
|
};
|
|
154
|
-
expect((0, build_localized_sitemap_1.buildLocalizedSitemap)(emptyData, { pageContentTypes: {} },
|
|
154
|
+
expect((0, build_localized_sitemap_1.buildLocalizedSitemap)(emptyData, { pageContentTypes: {} }, "pageHome", defaultLocale)._tag).toBe("Left");
|
|
155
155
|
});
|
|
156
|
-
test(
|
|
157
|
-
var pageHomeTagId =
|
|
156
|
+
test("Build localized sitemap", function () {
|
|
157
|
+
var pageHomeTagId = "pagHome";
|
|
158
158
|
var pagesEntries = mocked_localized_sitemap_1.mockedPages.flatMap(function (page) {
|
|
159
|
-
return page.type ===
|
|
160
|
-
? [pageToEntry(page, page.sys.id ===
|
|
159
|
+
return page.type === "page"
|
|
160
|
+
? [pageToEntry(page, page.sys.id === "root" ? [pageHomeTagId] : [])]
|
|
161
161
|
: [];
|
|
162
162
|
});
|
|
163
163
|
var redirectsEntries = mocked_localized_sitemap_1.mockedPages.flatMap(function (page) {
|
|
164
|
-
return page.type !==
|
|
164
|
+
return page.type !== "page" ? [redirectToEntry(page)] : [];
|
|
165
165
|
});
|
|
166
166
|
var data = {
|
|
167
167
|
contentTypes: contentTypes,
|
|
@@ -178,10 +178,10 @@ describe(build_localized_sitemap_1.buildLocalizedSitemap, function () {
|
|
|
178
178
|
};
|
|
179
179
|
expect(JSON.parse(JSON.stringify((0, build_localized_sitemap_1.buildLocalizedSitemap)(data, options, pageHomeTagId, defaultLocale), json_stringify_map_replacer_1.jsonStrigifyMapReplacer))).toMatchObject(JSON.parse(JSON.stringify((0, fp_utils_1.right)(mocked_localized_sitemap_1.mockedLocalizedSitemap), json_stringify_map_replacer_1.jsonStrigifyMapReplacer)));
|
|
180
180
|
});
|
|
181
|
-
test(
|
|
182
|
-
var pageHomeTagId =
|
|
181
|
+
test("Handle reference cycles", function () {
|
|
182
|
+
var pageHomeTagId = "pagHome";
|
|
183
183
|
var entries = mocked_localized_sitemap_1.mockedCircularReferencesPages.map(function (page) {
|
|
184
|
-
return pageToEntry(page, page.sys.id ===
|
|
184
|
+
return pageToEntry(page, page.sys.id === "root" ? [pageHomeTagId] : []);
|
|
185
185
|
});
|
|
186
186
|
var data = {
|
|
187
187
|
contentTypes: contentTypes,
|
|
@@ -197,7 +197,7 @@ describe(build_localized_sitemap_1.buildLocalizedSitemap, function () {
|
|
|
197
197
|
redirects: [],
|
|
198
198
|
};
|
|
199
199
|
var expectedLocalizedSitemap = (0, fp_utils_1.right)({
|
|
200
|
-
root: { sys: mocked_localized_sitemap_1.mockedRoot.sys },
|
|
200
|
+
root: { sys: { id: mocked_localized_sitemap_1.mockedRoot.sys.id } },
|
|
201
201
|
sitemap: new Map([
|
|
202
202
|
__assign(__assign({}, mocked_localized_sitemap_1.mockedRoot), { childPages: [
|
|
203
203
|
{ sys: { id: mocked_localized_sitemap_1.mockedPage1WithCircularReference.sys.id } },
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ContentfulClientApi, CreateClientParams } from "contentful";
|
|
2
1
|
import { CachedDataT, SysIdT } from "./impl/arboretum-client.impl";
|
|
3
2
|
import { Either } from "./utils/fp-utils";
|
|
4
|
-
import {
|
|
5
|
-
import { LocaleT, StatusT } from "./clients/contentful-client/contentful-client";
|
|
3
|
+
import { ContentTypeT, EntryT, LocaleT, StatusT, TagT } from "./clients/contentful-client/contentful-client";
|
|
6
4
|
export type ArboretumClientOptions = {
|
|
7
5
|
data?: CachedDataT;
|
|
8
6
|
eagerly?: boolean;
|
|
@@ -25,6 +23,13 @@ export type ArboretumClientContentfulConfigOptionsT = {
|
|
|
25
23
|
};
|
|
26
24
|
homePageTagId?: string;
|
|
27
25
|
};
|
|
26
|
+
export type ContentfulEnvironmentAPI = {
|
|
27
|
+
getEntries: (query?: any) => Promise<ContentfulCollection<EntryT>>;
|
|
28
|
+
getPublishedEntries: (query?: any) => Promise<ContentfulCollection<EntryT>>;
|
|
29
|
+
getLocales: () => Promise<ContentfulCollection<LocaleT>>;
|
|
30
|
+
getContentTypes: (query?: any) => Promise<ContentfulCollection<ContentTypeT>>;
|
|
31
|
+
getTags: (query?: any) => Promise<ContentfulCollection<TagT>>;
|
|
32
|
+
};
|
|
28
33
|
export type ArboretumClientConfigFromCmaT = {
|
|
29
34
|
type: "cma-client";
|
|
30
35
|
preview: boolean;
|
|
@@ -34,6 +39,19 @@ export type ArboretumClientConfigFromCmaT = {
|
|
|
34
39
|
};
|
|
35
40
|
options?: ArboretumClientOptions;
|
|
36
41
|
};
|
|
42
|
+
type ContentfulCollection<T> = {
|
|
43
|
+
total: number;
|
|
44
|
+
skip: number;
|
|
45
|
+
limit: number;
|
|
46
|
+
items: Array<T>;
|
|
47
|
+
};
|
|
48
|
+
export type ContentfulClientApi = {
|
|
49
|
+
withAllLocales?: ContentfulClientApi;
|
|
50
|
+
getEntries: (query?: any) => Promise<ContentfulCollection<EntryT>>;
|
|
51
|
+
getLocales: () => Promise<ContentfulCollection<LocaleT>>;
|
|
52
|
+
getContentTypes: (query?: any) => Promise<ContentfulCollection<ContentTypeT>>;
|
|
53
|
+
getTags: (query?: any) => Promise<ContentfulCollection<TagT>>;
|
|
54
|
+
};
|
|
37
55
|
export type ArboretumClientConfigFromCdaT = {
|
|
38
56
|
type: "cda-client";
|
|
39
57
|
preview: boolean;
|
|
@@ -43,10 +61,19 @@ export type ArboretumClientConfigFromCdaT = {
|
|
|
43
61
|
};
|
|
44
62
|
options?: Pick<ArboretumClientOptions, "data" | "eagerly">;
|
|
45
63
|
};
|
|
64
|
+
export type CreateClientParams = {
|
|
65
|
+
space: string;
|
|
66
|
+
accessToken: string;
|
|
67
|
+
environment?: string;
|
|
68
|
+
host?: string;
|
|
69
|
+
retryOnError?: boolean;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
retryLimit?: number;
|
|
72
|
+
};
|
|
46
73
|
export type ArboretumClientConfigFromCdaParamsT = {
|
|
47
74
|
type: "cda-client-params";
|
|
48
75
|
preview: boolean;
|
|
49
|
-
contentful: CreateClientParams & {
|
|
76
|
+
contentful: Omit<CreateClientParams, "host"> & {
|
|
50
77
|
options: ArboretumClientContentfulConfigOptionsT;
|
|
51
78
|
};
|
|
52
79
|
options?: Pick<ArboretumClientOptions, "data" | "eagerly">;
|
|
@@ -69,6 +96,7 @@ export type ArboretumAliasT = ArboretumPageBaseT & {
|
|
|
69
96
|
};
|
|
70
97
|
export type ArboretumPageT = ArboretumPageBaseT & {
|
|
71
98
|
type: "page";
|
|
99
|
+
contentTypeId: string;
|
|
72
100
|
slug: string;
|
|
73
101
|
totalDirectChildrenCount: number;
|
|
74
102
|
children?: Array<ArboretumPageNodeT>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Entry, Locale } from "contentful";
|
|
2
1
|
type EntriesQueryT = {
|
|
3
2
|
limit?: number;
|
|
4
3
|
skip?: number;
|
|
@@ -23,7 +22,9 @@ export type EntryT = {
|
|
|
23
22
|
};
|
|
24
23
|
}>;
|
|
25
24
|
};
|
|
26
|
-
fields:
|
|
25
|
+
fields: {
|
|
26
|
+
[localeCode: string]: any;
|
|
27
|
+
};
|
|
27
28
|
sys: {
|
|
28
29
|
id: string;
|
|
29
30
|
archivedVersion?: number;
|
|
@@ -49,7 +50,12 @@ export type TagT = {
|
|
|
49
50
|
id: string;
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
|
-
export type LocaleT =
|
|
53
|
+
export type LocaleT = {
|
|
54
|
+
code: string;
|
|
55
|
+
name: string;
|
|
56
|
+
default: boolean;
|
|
57
|
+
fallbackCode: string | null;
|
|
58
|
+
};
|
|
53
59
|
export type ContentTypeT = {
|
|
54
60
|
sys: {
|
|
55
61
|
id: string;
|
|
@@ -66,30 +72,34 @@ export type ContentTypeT = {
|
|
|
66
72
|
};
|
|
67
73
|
}>;
|
|
68
74
|
};
|
|
75
|
+
export type GetLocalesResponseT = {
|
|
76
|
+
skip: number;
|
|
77
|
+
limit: number;
|
|
78
|
+
total: number;
|
|
79
|
+
items: Array<LocaleT>;
|
|
80
|
+
};
|
|
81
|
+
export type GetContentTypesResponseT = {
|
|
82
|
+
skip: number;
|
|
83
|
+
limit: number;
|
|
84
|
+
total: number;
|
|
85
|
+
items: Array<ContentTypeT>;
|
|
86
|
+
};
|
|
87
|
+
export type GetTagsResponseT = {
|
|
88
|
+
skip: number;
|
|
89
|
+
limit: number;
|
|
90
|
+
total: number;
|
|
91
|
+
items: Array<TagT>;
|
|
92
|
+
};
|
|
93
|
+
export type GetEntriesResponseT = {
|
|
94
|
+
skip: number;
|
|
95
|
+
limit: number;
|
|
96
|
+
total: number;
|
|
97
|
+
items: Array<EntryT>;
|
|
98
|
+
};
|
|
69
99
|
export type ContentfulClientT = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
items: Array<EntryT>;
|
|
75
|
-
}>;
|
|
76
|
-
getLocales: () => Promise<{
|
|
77
|
-
skip: number;
|
|
78
|
-
limit: number;
|
|
79
|
-
total: number;
|
|
80
|
-
items: Array<LocaleT>;
|
|
81
|
-
}>;
|
|
82
|
-
getContentTypes: (query?: ContentTypesQueryT) => Promise<{
|
|
83
|
-
skip: number;
|
|
84
|
-
limit: number;
|
|
85
|
-
total: number;
|
|
86
|
-
items: Array<ContentTypeT>;
|
|
87
|
-
}>;
|
|
88
|
-
getTags: (query?: TagsQueryT) => Promise<{
|
|
89
|
-
skip: number;
|
|
90
|
-
limit: number;
|
|
91
|
-
total: number;
|
|
92
|
-
items: Array<TagT>;
|
|
93
|
-
}>;
|
|
100
|
+
getLocales: () => Promise<GetLocalesResponseT>;
|
|
101
|
+
getContentTypes: (query?: ContentTypesQueryT) => Promise<GetContentTypesResponseT>;
|
|
102
|
+
getTags: (query?: TagsQueryT) => Promise<GetTagsResponseT>;
|
|
103
|
+
getEntries: (query?: EntriesQueryT) => Promise<GetEntriesResponseT>;
|
|
94
104
|
};
|
|
95
105
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { ArboretumClientConfigT } from "../../../arboretum-client";
|
|
1
|
+
import { ArboretumClientConfigT, CreateClientParams } from "../../../arboretum-client";
|
|
2
2
|
import { ContentfulClientT } from "../contentful-client";
|
|
3
3
|
export declare const createContentfulClient: (config: ArboretumClientConfigT) => ContentfulClientT;
|
|
4
|
+
export declare const createCdaRestApiContentfulClient: (config: CreateClientParams) => ContentfulClientT;
|
|
@@ -16,6 +16,7 @@ export type PageT = {
|
|
|
16
16
|
sys: {
|
|
17
17
|
id: string;
|
|
18
18
|
cmaOnlyStatus?: StatusT;
|
|
19
|
+
contentTypeId: string;
|
|
19
20
|
};
|
|
20
21
|
metadata?: MetadataT;
|
|
21
22
|
parent: {
|
|
@@ -76,7 +77,7 @@ export type PagesByTagIdT = Map<LocaleCodeT, PagesByTagIdV>;
|
|
|
76
77
|
export type CachedDataT = Pick<ArboretumClientCtx, "data" | "pagesByTagId" | "sitemap">;
|
|
77
78
|
export type ArboretumClientCtx = {
|
|
78
79
|
preview: boolean;
|
|
79
|
-
contentfulClientType: ArboretumClientConfigT["type"];
|
|
80
|
+
contentfulClientType: ArboretumClientConfigT["type"] | "cda-client-with-all-locales";
|
|
80
81
|
lastUpdatedAt: string;
|
|
81
82
|
clientApi: ContentfulClientT;
|
|
82
83
|
cmaPreviewClientApi?: ContentfulClientT;
|
|
@@ -3,4 +3,4 @@ import { ArboretumClientCtx, SysIdT } from "../../arboretum-client.impl";
|
|
|
3
3
|
export type PagesT = {
|
|
4
4
|
[sys: SysIdT]: EntryT;
|
|
5
5
|
};
|
|
6
|
-
export declare const getAllEntriesRecursively: ({ getEntries }: Pick<ArboretumClientCtx["clientApi"], "getEntries">, contentType: string, skip: number, acc: Array<EntryT>, select?: string, refFieldsToFilterOut?: Array<string>, limit?: number) => Promise<Array<EntryT>>;
|
|
6
|
+
export declare const getAllEntriesRecursively: ({ getEntries }: Pick<ArboretumClientCtx["clientApi"], "getEntries">, contentfulClientType: ArboretumClientCtx["contentfulClientType"], contentType: string, skip: number, acc: Array<EntryT>, select?: string, refFieldsToFilterOut?: Array<string>, limit?: number) => Promise<Array<EntryT>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ArboretumPageT } from
|
|
2
|
-
import { PageT } from
|
|
3
|
-
export declare const toArboretumPageWithMissingData: (localeCode: string) => (page: PageT, ancestors: ArboretumPageT[
|
|
1
|
+
import { ArboretumPageT } from "../../../arboretum-client";
|
|
2
|
+
import { PageT } from "../../arboretum-client.impl";
|
|
3
|
+
export declare const toArboretumPageWithMissingData: (localeCode: string) => (page: PageT, ancestors: ArboretumPageT["ancestors"], children: ArboretumPageT["children"]) => ArboretumPageT;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LocalizedSitemapT, PageT, RedirectT } from
|
|
1
|
+
import { LocalizedSitemapT, PageT, RedirectT } from "../../../arboretum-client.impl";
|
|
2
2
|
export declare const mockedRoot: PageT;
|
|
3
3
|
export declare const mockedPage1: PageT;
|
|
4
4
|
export declare const mockedPage1_1: PageT;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRandomNumber(min: number, max: number): number;
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bright.global/arboretum-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The sitemap for contentful",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"contentful": "^9.2.5",
|
|
8
|
-
"contentful-management": "10.29.1"
|
|
9
|
-
},
|
|
6
|
+
"dependencies": {},
|
|
10
7
|
"sideEffects": false,
|
|
11
8
|
"devDependencies": {
|
|
12
9
|
"@babel/preset-env": "^7.22.6",
|