@janbox/contentful-marketplace-sdk 3.0.0 → 4.0.0-alpha.0
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/README.md +42 -22
- package/dist/client/index.d.ts +5 -11
- package/dist/index.cjs +1 -2
- package/dist/index.js +492 -452
- package/dist/types/content-model.d.ts +38 -38
- package/dist/types/index.d.ts +0 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/query.d.ts +5 -6
- package/dist/utils/resolve.d.ts +11 -10
- package/package.json +3 -2
- package/dist/http-responses/index.d.ts +0 -3
- package/dist/types/cms.d.ts +0 -61
package/dist/index.js
CHANGED
|
@@ -1,61 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (t)
|
|
12
|
-
return { "fields.slug": t, limit: 1 };
|
|
13
|
-
throw new Error("Either id or slug is required.");
|
|
14
|
-
}, w = (e, t, i = 0) => {
|
|
15
|
-
const o = Math.max(1, Math.floor(e)), s = Math.max(1, Math.floor(t)), l = Math.max(0, Math.floor(i));
|
|
16
|
-
return {
|
|
17
|
-
page: o,
|
|
18
|
-
size: s,
|
|
19
|
-
params: {
|
|
20
|
-
limit: s,
|
|
21
|
-
skip: (o - 1) * s + l
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}, N = (e) => {
|
|
25
|
-
const t = new URLSearchParams();
|
|
26
|
-
for (const [i, o] of Object.entries(e))
|
|
27
|
-
o !== void 0 && t.append(i, String(o));
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
class c {
|
|
1
|
+
import { createClient as U, or as P, CmsError as G } from "@janbox/headless-cms-sdk";
|
|
2
|
+
const q = [
|
|
3
|
+
"baseUrl",
|
|
4
|
+
"accessToken",
|
|
5
|
+
"headers",
|
|
6
|
+
"fetch",
|
|
7
|
+
"timeout",
|
|
8
|
+
"retry"
|
|
9
|
+
];
|
|
10
|
+
class r {
|
|
31
11
|
static _config;
|
|
12
|
+
static _client;
|
|
32
13
|
static get config() {
|
|
33
14
|
if (!this._config)
|
|
34
15
|
throw new Error("Client is not configured");
|
|
35
16
|
return this._config;
|
|
36
17
|
}
|
|
37
|
-
static
|
|
38
|
-
this.
|
|
18
|
+
static get client() {
|
|
19
|
+
const s = this.config, i = this._client;
|
|
20
|
+
if (i && q.every((t) => i.builtFrom[t] === s[t]))
|
|
21
|
+
return i.client;
|
|
22
|
+
const l = U(s);
|
|
23
|
+
return this._client = { client: l, builtFrom: { ...s } }, l;
|
|
39
24
|
}
|
|
40
|
-
static
|
|
41
|
-
|
|
42
|
-
`${i.replace(/\/+$/, "")}/entries?${N(t)}`,
|
|
43
|
-
{
|
|
44
|
-
method: "GET",
|
|
45
|
-
headers: {
|
|
46
|
-
Accept: "application/json",
|
|
47
|
-
...o
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
if (!s.ok) {
|
|
52
|
-
const l = await s.text();
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Request failed: ${s.status} ${s.statusText}
|
|
55
|
-
${l}`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
return s.json();
|
|
25
|
+
static configure(s) {
|
|
26
|
+
this._config = s;
|
|
59
27
|
}
|
|
60
28
|
}
|
|
61
29
|
class h {
|
|
@@ -65,558 +33,630 @@ class h {
|
|
|
65
33
|
items;
|
|
66
34
|
totalPages;
|
|
67
35
|
constructor({
|
|
68
|
-
page:
|
|
36
|
+
page: s,
|
|
69
37
|
total: i,
|
|
70
|
-
size:
|
|
71
|
-
items:
|
|
38
|
+
size: l,
|
|
39
|
+
items: t
|
|
72
40
|
}) {
|
|
73
|
-
this.page =
|
|
41
|
+
this.page = s, this.total = i, this.size = l, this.items = t, this.totalPages = Math.ceil(this.total / this.size);
|
|
74
42
|
}
|
|
75
43
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
44
|
+
const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
45
|
+
{ "fields.markets[exists]": "false" },
|
|
46
|
+
{
|
|
47
|
+
"fields.markets.sys.contentType.sys.id": "market",
|
|
48
|
+
"fields.markets.fields.code": e
|
|
49
|
+
}
|
|
50
|
+
]) : {}, p = (e) => e ? P("locale", [
|
|
51
|
+
{ "fields.locale[exists]": "false" },
|
|
52
|
+
{ "fields.locale": e }
|
|
53
|
+
]) : {}, z = ({
|
|
54
|
+
id: e,
|
|
55
|
+
slug: s
|
|
56
|
+
}) => {
|
|
57
|
+
if (e)
|
|
58
|
+
return { "sys.id": e, limit: 1 };
|
|
59
|
+
if (s)
|
|
60
|
+
return { "fields.slug": s, limit: 1 };
|
|
61
|
+
throw new Error("Either id or slug is required.");
|
|
62
|
+
}, w = (e, s, i = 0) => {
|
|
63
|
+
const l = Math.max(1, Math.floor(e)), t = Math.max(1, Math.floor(s)), n = Math.max(0, Math.floor(i));
|
|
64
|
+
return {
|
|
65
|
+
page: l,
|
|
66
|
+
size: t,
|
|
67
|
+
params: {
|
|
68
|
+
limit: t,
|
|
69
|
+
skip: (l - 1) * t + n
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}, f = (e) => {
|
|
73
|
+
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const t of [...e.items, ...e.includes?.Entry ?? []])
|
|
75
|
+
s.set(t.sys.id, t);
|
|
76
|
+
for (const t of e.includes?.Asset ?? [])
|
|
77
|
+
i.set(t.sys.id, t);
|
|
78
|
+
const l = (t) => (t && s.get(t.sys.id)) ?? null;
|
|
83
79
|
return {
|
|
84
|
-
entry:
|
|
85
|
-
asset: (
|
|
86
|
-
entries: (
|
|
80
|
+
entry: l,
|
|
81
|
+
asset: (t) => (t && i.get(t.sys.id)) ?? null,
|
|
82
|
+
entries: (t) => (t ?? []).map((n) => l(n)).filter((n) => n !== null)
|
|
87
83
|
};
|
|
88
|
-
},
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
url:
|
|
92
|
-
width:
|
|
93
|
-
height:
|
|
94
|
-
contentType:
|
|
84
|
+
}, o = (e) => e ?? null, E = (e) => {
|
|
85
|
+
const s = e?.fields.file;
|
|
86
|
+
return s ? {
|
|
87
|
+
url: s.url,
|
|
88
|
+
width: s.details.image?.width ?? null,
|
|
89
|
+
height: s.details.image?.height ?? null,
|
|
90
|
+
contentType: s.contentType
|
|
95
91
|
} : null;
|
|
96
|
-
},
|
|
92
|
+
}, Y = (e) => ({
|
|
97
93
|
sys: { id: e.sys.id },
|
|
98
94
|
url: e.fields.file?.url,
|
|
99
95
|
width: e.fields.file?.details.image?.width ?? null,
|
|
100
96
|
height: e.fields.file?.details.image?.height ?? null,
|
|
101
97
|
contentType: e.fields.file?.contentType,
|
|
102
|
-
title:
|
|
103
|
-
description:
|
|
104
|
-
}),
|
|
98
|
+
title: o(e.fields.title),
|
|
99
|
+
description: o(e.fields.description)
|
|
100
|
+
}), R = (e, s) => {
|
|
105
101
|
if (!e || typeof e != "object")
|
|
106
|
-
return
|
|
102
|
+
return s;
|
|
107
103
|
const i = e;
|
|
108
104
|
if (i.nodeType === "embedded-asset-block") {
|
|
109
|
-
const
|
|
110
|
-
|
|
105
|
+
const l = i.data?.target?.sys?.id;
|
|
106
|
+
l && !s.includes(l) && s.push(l);
|
|
111
107
|
}
|
|
112
|
-
for (const
|
|
113
|
-
|
|
114
|
-
return
|
|
115
|
-
},
|
|
108
|
+
for (const l of i.content ?? [])
|
|
109
|
+
R(l, s);
|
|
110
|
+
return s;
|
|
111
|
+
}, T = (e, s) => {
|
|
116
112
|
if (!e)
|
|
117
113
|
return null;
|
|
118
|
-
const i =
|
|
114
|
+
const i = R(e, []).map((l) => s.asset({ sys: { type: "Link", linkType: "Asset", id: l } })).filter((l) => l !== null && !!l.fields.file).map(Y);
|
|
119
115
|
return { json: e, links: { assets: { block: i } } };
|
|
120
|
-
},
|
|
121
|
-
metaTitle:
|
|
122
|
-
metaDescription:
|
|
123
|
-
metaKeywords:
|
|
124
|
-
metaRobots:
|
|
125
|
-
} : null,
|
|
116
|
+
}, _ = (e) => e ? {
|
|
117
|
+
metaTitle: o(e.fields.metaTitle),
|
|
118
|
+
metaDescription: o(e.fields.metaDescription),
|
|
119
|
+
metaKeywords: o(e.fields.metaKeywords),
|
|
120
|
+
metaRobots: o(e.fields.metaRobots)
|
|
121
|
+
} : null, b = (e) => e ? {
|
|
126
122
|
sys: { id: e.sys.id },
|
|
127
|
-
label:
|
|
128
|
-
url:
|
|
129
|
-
target:
|
|
130
|
-
marketHandling:
|
|
131
|
-
} : null,
|
|
132
|
-
name:
|
|
133
|
-
avatar:
|
|
134
|
-
} : null,
|
|
123
|
+
label: o(e.fields.label),
|
|
124
|
+
url: o(e.fields.url),
|
|
125
|
+
target: o(e.fields.target),
|
|
126
|
+
marketHandling: o(e.fields.marketHandling)
|
|
127
|
+
} : null, S = (e, s) => e ? {
|
|
128
|
+
name: o(e.fields.name),
|
|
129
|
+
avatar: E(s.asset(e.fields.avatar))
|
|
130
|
+
} : null, Q = async ({
|
|
135
131
|
slot: e,
|
|
136
|
-
page:
|
|
132
|
+
page: s = 1,
|
|
137
133
|
size: i = 20,
|
|
138
|
-
platform:
|
|
139
|
-
marketCode:
|
|
140
|
-
locale:
|
|
134
|
+
platform: l,
|
|
135
|
+
marketCode: t,
|
|
136
|
+
locale: n
|
|
141
137
|
}) => {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
138
|
+
const c = w(s, i), a = await r.client.getEntries(
|
|
139
|
+
{
|
|
140
|
+
content_type: "bannerCollection",
|
|
141
|
+
"fields.slot": e,
|
|
142
|
+
"fields.platform": l || void 0,
|
|
143
|
+
select: "sys.id,fields.name,fields.slot,fields.platform,fields.banners",
|
|
144
|
+
include: 2,
|
|
145
|
+
order: m,
|
|
146
|
+
...c.params,
|
|
147
|
+
...g(t),
|
|
148
|
+
...p(n)
|
|
149
|
+
},
|
|
150
|
+
{ resolveLinks: !1 }
|
|
151
|
+
), d = f(a);
|
|
153
152
|
return new h({
|
|
154
|
-
page:
|
|
153
|
+
page: c.page,
|
|
155
154
|
total: a.total,
|
|
156
|
-
size:
|
|
155
|
+
size: c.size,
|
|
157
156
|
items: a.items.map(
|
|
158
157
|
(u) => ({
|
|
159
158
|
sys: { id: u.sys.id },
|
|
160
|
-
name:
|
|
161
|
-
slot:
|
|
162
|
-
platform:
|
|
159
|
+
name: o(u.fields.name),
|
|
160
|
+
slot: o(u.fields.slot),
|
|
161
|
+
platform: o(u.fields.platform),
|
|
163
162
|
bannersCollection: {
|
|
164
|
-
items:
|
|
165
|
-
sys: { id:
|
|
166
|
-
name:
|
|
167
|
-
hyperlink:
|
|
168
|
-
|
|
163
|
+
items: d.entries(u.fields.banners).map((k) => ({
|
|
164
|
+
sys: { id: k.sys.id },
|
|
165
|
+
name: o(k.fields.name),
|
|
166
|
+
hyperlink: b(
|
|
167
|
+
d.entry(k.fields.hyperlink)
|
|
169
168
|
),
|
|
170
|
-
media:
|
|
169
|
+
media: E(d.asset(k.fields.media))
|
|
171
170
|
}))
|
|
172
171
|
}
|
|
173
172
|
})
|
|
174
173
|
)
|
|
175
174
|
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const I = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage", b = (e, t) => ({
|
|
175
|
+
}, C = () => new G({
|
|
176
|
+
id: "NotFound",
|
|
177
|
+
message: "Entry not found",
|
|
178
|
+
url: `${r.config.baseUrl.trim().replace(/\/+$/, "")}/entries`,
|
|
179
|
+
status: 404
|
|
180
|
+
}), I = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage", L = (e, s) => ({
|
|
186
181
|
sys: {
|
|
187
182
|
id: e.sys.id,
|
|
188
183
|
createdAt: e.sys.createdAt,
|
|
189
184
|
updatedAt: e.sys.updatedAt
|
|
190
185
|
},
|
|
191
|
-
title:
|
|
192
|
-
shortDescription:
|
|
193
|
-
slug:
|
|
186
|
+
title: o(e.fields.title),
|
|
187
|
+
shortDescription: o(e.fields.shortDescription),
|
|
188
|
+
slug: o(e.fields.slug),
|
|
194
189
|
categoriesCollection: {
|
|
195
|
-
items:
|
|
190
|
+
items: s.entries(e.fields.categories).map((i) => ({
|
|
196
191
|
sys: { id: i.sys.id },
|
|
197
|
-
title:
|
|
198
|
-
slug:
|
|
199
|
-
featuredImage:
|
|
192
|
+
title: o(i.fields.title),
|
|
193
|
+
slug: o(i.fields.slug),
|
|
194
|
+
featuredImage: E(s.asset(i.fields.featuredImage))
|
|
200
195
|
}))
|
|
201
196
|
},
|
|
202
|
-
featuredImage:
|
|
203
|
-
}),
|
|
197
|
+
featuredImage: E(s.asset(e.fields.featuredImage))
|
|
198
|
+
}), V = async ({
|
|
204
199
|
marketCode: e,
|
|
205
|
-
locale:
|
|
200
|
+
locale: s,
|
|
206
201
|
collectionId: i,
|
|
207
|
-
categoryId:
|
|
208
|
-
page:
|
|
209
|
-
size:
|
|
210
|
-
skip:
|
|
202
|
+
categoryId: l,
|
|
203
|
+
page: t = 1,
|
|
204
|
+
size: n = 20,
|
|
205
|
+
skip: c = 0
|
|
211
206
|
} = {}) => {
|
|
212
|
-
const a = w(
|
|
207
|
+
const a = w(t, n, c);
|
|
213
208
|
if (i) {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (!
|
|
209
|
+
const D = (await r.client.getEntries(
|
|
210
|
+
{
|
|
211
|
+
content_type: "blogCollection",
|
|
212
|
+
"sys.id": i,
|
|
213
|
+
select: "sys.id,fields.posts",
|
|
214
|
+
include: 0,
|
|
215
|
+
limit: 1
|
|
216
|
+
},
|
|
217
|
+
{ resolveLinks: !1 }
|
|
218
|
+
)).items.at(0);
|
|
219
|
+
if (!D)
|
|
220
|
+
throw C();
|
|
221
|
+
const v = (D.fields.posts ?? []).filter((y) => y.sys.linkType === "Entry").map((y) => y.sys.id), A = v.slice(a.params.skip, a.params.skip + a.size);
|
|
222
|
+
if (!A.length)
|
|
225
223
|
return new h({
|
|
226
224
|
page: a.page,
|
|
227
|
-
total:
|
|
225
|
+
total: v.length,
|
|
228
226
|
size: a.size,
|
|
229
227
|
items: []
|
|
230
228
|
});
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
229
|
+
const B = await r.client.getEntries(
|
|
230
|
+
{
|
|
231
|
+
content_type: "blogPost",
|
|
232
|
+
"sys.id[in]": A.join(","),
|
|
233
|
+
select: I,
|
|
234
|
+
include: 2,
|
|
235
|
+
limit: a.size
|
|
236
|
+
},
|
|
237
|
+
{ resolveLinks: !1 }
|
|
238
|
+
), N = f(B), j = new Map(B.items.map((y) => [y.sys.id, y]));
|
|
238
239
|
return new h({
|
|
239
240
|
page: a.page,
|
|
240
|
-
total:
|
|
241
|
+
total: v.length,
|
|
241
242
|
size: a.size,
|
|
242
|
-
items:
|
|
243
|
+
items: A.map((y) => j.get(y)).filter((y) => y !== void 0).map((y) => L(y, N))
|
|
243
244
|
});
|
|
244
245
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
const d = await r.client.getEntries(
|
|
247
|
+
{
|
|
248
|
+
content_type: "blogPost",
|
|
249
|
+
"fields.categories.sys.id": l || void 0,
|
|
250
|
+
select: I,
|
|
251
|
+
include: 2,
|
|
252
|
+
order: m,
|
|
253
|
+
...a.params,
|
|
254
|
+
...g(e),
|
|
255
|
+
...p(s)
|
|
256
|
+
},
|
|
257
|
+
{ resolveLinks: !1 }
|
|
258
|
+
), u = f(d);
|
|
255
259
|
return new h({
|
|
256
260
|
page: a.page,
|
|
257
|
-
total:
|
|
261
|
+
total: d.total,
|
|
258
262
|
size: a.size,
|
|
259
|
-
items:
|
|
263
|
+
items: d.items.map((k) => L(k, u))
|
|
260
264
|
});
|
|
261
|
-
},
|
|
265
|
+
}, W = async ({
|
|
262
266
|
id: e,
|
|
263
|
-
slug:
|
|
267
|
+
slug: s,
|
|
264
268
|
marketCode: i,
|
|
265
|
-
locale:
|
|
269
|
+
locale: l
|
|
266
270
|
}) => {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
const t = z({ id: e, slug: s }), n = await r.client.getEntries(
|
|
272
|
+
{
|
|
273
|
+
content_type: "blogPost",
|
|
274
|
+
...t,
|
|
275
|
+
select: `${I},fields.author,fields.content,fields.seo`,
|
|
276
|
+
include: 2,
|
|
277
|
+
order: m,
|
|
278
|
+
...g(i),
|
|
279
|
+
...p(l)
|
|
280
|
+
},
|
|
281
|
+
{ resolveLinks: !1 }
|
|
282
|
+
), c = n.items.at(0);
|
|
283
|
+
if (!c)
|
|
284
|
+
throw C();
|
|
285
|
+
const a = f(n);
|
|
279
286
|
return {
|
|
280
|
-
...
|
|
281
|
-
author:
|
|
282
|
-
content:
|
|
283
|
-
seo:
|
|
287
|
+
...L(c, a),
|
|
288
|
+
author: S(a.entry(c.fields.author), a),
|
|
289
|
+
content: T(c.fields.content, a),
|
|
290
|
+
seo: _(a.entry(c.fields.seo))
|
|
284
291
|
};
|
|
285
|
-
},
|
|
292
|
+
}, M = "sys.id,fields.title,fields.slug,fields.featuredImage", x = (e, s) => ({
|
|
286
293
|
sys: { id: e.sys.id },
|
|
287
|
-
title:
|
|
288
|
-
slug:
|
|
289
|
-
featuredImage:
|
|
290
|
-
}),
|
|
294
|
+
title: o(e.fields.title),
|
|
295
|
+
slug: o(e.fields.slug),
|
|
296
|
+
featuredImage: E(s.asset(e.fields.featuredImage))
|
|
297
|
+
}), X = async ({
|
|
291
298
|
marketCode: e,
|
|
292
|
-
locale:
|
|
299
|
+
locale: s,
|
|
293
300
|
page: i = 1,
|
|
294
|
-
size:
|
|
301
|
+
size: l = 20
|
|
295
302
|
} = {}) => {
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
const t = w(i, l), n = await r.client.getEntries(
|
|
304
|
+
{
|
|
305
|
+
content_type: "blogCategory",
|
|
306
|
+
select: M,
|
|
307
|
+
include: 1,
|
|
308
|
+
order: m,
|
|
309
|
+
...t.params,
|
|
310
|
+
...g(e),
|
|
311
|
+
...p(s)
|
|
312
|
+
},
|
|
313
|
+
{ resolveLinks: !1 }
|
|
314
|
+
), c = f(n);
|
|
305
315
|
return new h({
|
|
306
|
-
page:
|
|
307
|
-
total:
|
|
308
|
-
size:
|
|
309
|
-
items:
|
|
316
|
+
page: t.page,
|
|
317
|
+
total: n.total,
|
|
318
|
+
size: t.size,
|
|
319
|
+
items: n.items.map((a) => x(a, c))
|
|
310
320
|
});
|
|
311
|
-
},
|
|
321
|
+
}, Z = async ({
|
|
312
322
|
id: e,
|
|
313
|
-
slug:
|
|
323
|
+
slug: s,
|
|
314
324
|
marketCode: i,
|
|
315
|
-
locale:
|
|
325
|
+
locale: l
|
|
316
326
|
}) => {
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
const t = z({ id: e, slug: s }), n = await r.client.getEntries(
|
|
328
|
+
{
|
|
329
|
+
content_type: "blogCategory",
|
|
330
|
+
...t,
|
|
331
|
+
select: `${M},fields.description,fields.seo`,
|
|
332
|
+
include: 1,
|
|
333
|
+
order: m,
|
|
334
|
+
...g(i),
|
|
335
|
+
...p(l)
|
|
336
|
+
},
|
|
337
|
+
{ resolveLinks: !1 }
|
|
338
|
+
), c = n.items.at(0);
|
|
339
|
+
if (!c)
|
|
340
|
+
throw C();
|
|
341
|
+
const a = f(n);
|
|
329
342
|
return {
|
|
330
|
-
...
|
|
331
|
-
description:
|
|
332
|
-
seo:
|
|
343
|
+
...x(c, a),
|
|
344
|
+
description: o(c.fields.description),
|
|
345
|
+
seo: _(a.entry(c.fields.seo))
|
|
333
346
|
};
|
|
334
|
-
},
|
|
347
|
+
}, ee = async ({
|
|
335
348
|
marketCode: e,
|
|
336
|
-
locale:
|
|
349
|
+
locale: s,
|
|
337
350
|
page: i = 1,
|
|
338
|
-
size:
|
|
351
|
+
size: l = 20
|
|
339
352
|
} = {}) => {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
353
|
+
const t = w(i, l), n = await r.client.getEntries(
|
|
354
|
+
{
|
|
355
|
+
content_type: "blogCollection",
|
|
356
|
+
select: "sys.id,fields.name,fields.type,fields.order,fields.category,fields.featuredImage",
|
|
357
|
+
include: 1,
|
|
358
|
+
order: m,
|
|
359
|
+
...t.params,
|
|
360
|
+
...g(e),
|
|
361
|
+
...p(s)
|
|
362
|
+
},
|
|
363
|
+
{ resolveLinks: !1 }
|
|
364
|
+
), c = f(n), a = n.items.map((d) => {
|
|
365
|
+
const u = c.entry(d.fields.category);
|
|
350
366
|
return {
|
|
351
|
-
name:
|
|
352
|
-
type:
|
|
353
|
-
order:
|
|
354
|
-
sys: { id:
|
|
367
|
+
name: o(d.fields.name),
|
|
368
|
+
type: o(d.fields.type),
|
|
369
|
+
order: o(d.fields.order),
|
|
370
|
+
sys: { id: d.sys.id },
|
|
355
371
|
category: u ? {
|
|
356
372
|
sys: { id: u.sys.id },
|
|
357
|
-
title:
|
|
358
|
-
slug:
|
|
373
|
+
title: o(u.fields.title),
|
|
374
|
+
slug: o(u.fields.slug)
|
|
359
375
|
} : null,
|
|
360
|
-
featuredImage:
|
|
376
|
+
featuredImage: E(c.asset(d.fields.featuredImage))
|
|
361
377
|
};
|
|
362
378
|
});
|
|
363
379
|
return new h({
|
|
364
|
-
page:
|
|
365
|
-
total:
|
|
366
|
-
size:
|
|
367
|
-
items: a.map((
|
|
368
|
-
...
|
|
369
|
-
category:
|
|
370
|
-
categoryId:
|
|
371
|
-
collectionId:
|
|
380
|
+
page: t.page,
|
|
381
|
+
total: n.total,
|
|
382
|
+
size: t.size,
|
|
383
|
+
items: a.map((d) => ({
|
|
384
|
+
...d,
|
|
385
|
+
category: d.type === "category" ? d.category : null,
|
|
386
|
+
categoryId: d.type === "category" ? d.category?.sys.id ?? null : null,
|
|
387
|
+
collectionId: d.type === "manual" ? d.sys.id : null
|
|
372
388
|
}))
|
|
373
389
|
});
|
|
374
|
-
},
|
|
390
|
+
}, se = async ({
|
|
375
391
|
page: e = 1,
|
|
376
|
-
size:
|
|
392
|
+
size: s = 20,
|
|
377
393
|
marketCode: i,
|
|
378
|
-
locale:
|
|
394
|
+
locale: l
|
|
379
395
|
} = {}) => {
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
396
|
+
const t = w(e, s), n = await r.client.getEntries(
|
|
397
|
+
{
|
|
398
|
+
content_type: "brandCollection",
|
|
399
|
+
select: "sys.id,fields.name,fields.slot,fields.brands",
|
|
400
|
+
include: 2,
|
|
401
|
+
order: m,
|
|
402
|
+
...t.params,
|
|
403
|
+
...g(i),
|
|
404
|
+
...p(l)
|
|
405
|
+
},
|
|
406
|
+
{ resolveLinks: !1 }
|
|
407
|
+
), c = f(n);
|
|
389
408
|
return new h({
|
|
390
|
-
page:
|
|
391
|
-
total:
|
|
392
|
-
size:
|
|
393
|
-
items:
|
|
409
|
+
page: t.page,
|
|
410
|
+
total: n.total,
|
|
411
|
+
size: t.size,
|
|
412
|
+
items: n.items.map(
|
|
394
413
|
(a) => ({
|
|
395
414
|
sys: { id: a.sys.id },
|
|
396
|
-
name:
|
|
397
|
-
slot:
|
|
415
|
+
name: o(a.fields.name),
|
|
416
|
+
slot: o(a.fields.slot),
|
|
398
417
|
brandsCollection: {
|
|
399
|
-
items:
|
|
400
|
-
sys: { id:
|
|
401
|
-
name:
|
|
402
|
-
logo:
|
|
403
|
-
hyperlink:
|
|
404
|
-
|
|
418
|
+
items: c.entries(a.fields.brands).map((d) => ({
|
|
419
|
+
sys: { id: d.sys.id },
|
|
420
|
+
name: o(d.fields.name),
|
|
421
|
+
logo: E(c.asset(d.fields.logo)),
|
|
422
|
+
hyperlink: b(
|
|
423
|
+
c.entry(d.fields.hyperlink)
|
|
405
424
|
)
|
|
406
425
|
}))
|
|
407
426
|
}
|
|
408
427
|
})
|
|
409
428
|
)
|
|
410
429
|
});
|
|
411
|
-
},
|
|
430
|
+
}, F = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.description,fields.order,fields.seo", O = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.author,fields.category", $ = (e) => ({
|
|
412
431
|
id: e.sys.id,
|
|
413
432
|
createdAt: e.sys.createdAt,
|
|
414
433
|
updatedAt: e.sys.updatedAt
|
|
415
|
-
}),
|
|
416
|
-
sys:
|
|
417
|
-
title:
|
|
418
|
-
slug:
|
|
419
|
-
description:
|
|
420
|
-
order:
|
|
421
|
-
seo:
|
|
422
|
-
}),
|
|
423
|
-
const i =
|
|
434
|
+
}), H = (e, s) => ({
|
|
435
|
+
sys: $(e),
|
|
436
|
+
title: o(e.fields.title),
|
|
437
|
+
slug: o(e.fields.slug),
|
|
438
|
+
description: o(e.fields.description),
|
|
439
|
+
order: o(e.fields.order),
|
|
440
|
+
seo: _(s.entry(e.fields.seo))
|
|
441
|
+
}), K = (e, s) => {
|
|
442
|
+
const i = s.entry(e.fields.category);
|
|
424
443
|
return {
|
|
425
|
-
sys:
|
|
426
|
-
title:
|
|
427
|
-
slug:
|
|
428
|
-
author:
|
|
444
|
+
sys: $(e),
|
|
445
|
+
title: o(e.fields.title),
|
|
446
|
+
slug: o(e.fields.slug),
|
|
447
|
+
author: S(s.entry(e.fields.author), s),
|
|
429
448
|
category: i ? {
|
|
430
|
-
title:
|
|
431
|
-
slug:
|
|
432
|
-
description:
|
|
433
|
-
order:
|
|
449
|
+
title: o(i.fields.title),
|
|
450
|
+
slug: o(i.fields.slug),
|
|
451
|
+
description: o(i.fields.description),
|
|
452
|
+
order: o(i.fields.order)
|
|
434
453
|
} : null
|
|
435
454
|
};
|
|
436
|
-
},
|
|
455
|
+
}, te = async ({
|
|
437
456
|
marketCode: e,
|
|
438
|
-
locale:
|
|
457
|
+
locale: s,
|
|
439
458
|
page: i = 1,
|
|
440
|
-
size:
|
|
459
|
+
size: l = 20
|
|
441
460
|
} = {}) => {
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
461
|
+
const t = w(i, l), n = await r.client.getEntries(
|
|
462
|
+
{
|
|
463
|
+
content_type: "documentationCategory",
|
|
464
|
+
select: F,
|
|
465
|
+
include: 1,
|
|
466
|
+
order: m,
|
|
467
|
+
...t.params,
|
|
468
|
+
...g(e),
|
|
469
|
+
...p(s)
|
|
470
|
+
},
|
|
471
|
+
{ resolveLinks: !1 }
|
|
472
|
+
), c = f(n);
|
|
451
473
|
return new h({
|
|
452
|
-
page:
|
|
453
|
-
total:
|
|
454
|
-
size:
|
|
455
|
-
items:
|
|
474
|
+
page: t.page,
|
|
475
|
+
total: n.total,
|
|
476
|
+
size: t.size,
|
|
477
|
+
items: n.items.map((a) => H(a, c))
|
|
456
478
|
});
|
|
457
|
-
},
|
|
479
|
+
}, ie = async ({
|
|
458
480
|
id: e,
|
|
459
|
-
slug:
|
|
481
|
+
slug: s,
|
|
460
482
|
marketCode: i,
|
|
461
|
-
locale:
|
|
483
|
+
locale: l
|
|
462
484
|
}) => {
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
485
|
+
const t = z({ id: e, slug: s }), n = await r.client.getEntries(
|
|
486
|
+
{
|
|
487
|
+
content_type: "documentationCategory",
|
|
488
|
+
...t,
|
|
489
|
+
select: F,
|
|
490
|
+
include: 1,
|
|
491
|
+
order: m,
|
|
492
|
+
...g(i),
|
|
493
|
+
...p(l)
|
|
494
|
+
},
|
|
495
|
+
{ resolveLinks: !1 }
|
|
496
|
+
), c = n.items.at(0);
|
|
497
|
+
if (!c)
|
|
498
|
+
throw C();
|
|
499
|
+
return H(c, f(n));
|
|
500
|
+
}, le = async ({
|
|
476
501
|
marketCode: e,
|
|
477
|
-
locale:
|
|
502
|
+
locale: s,
|
|
478
503
|
categorySlug: i,
|
|
479
|
-
page:
|
|
480
|
-
size:
|
|
504
|
+
page: l = 1,
|
|
505
|
+
size: t = 20
|
|
481
506
|
} = {}) => {
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
507
|
+
const n = w(l, t), c = await r.client.getEntries(
|
|
508
|
+
{
|
|
509
|
+
content_type: "documentationArticle",
|
|
510
|
+
...i ? {
|
|
511
|
+
"fields.category.sys.contentType.sys.id": "documentationCategory",
|
|
512
|
+
"fields.category.fields.slug": i
|
|
513
|
+
} : {},
|
|
514
|
+
select: O,
|
|
515
|
+
include: 2,
|
|
516
|
+
order: m,
|
|
517
|
+
...n.params,
|
|
518
|
+
...g(e),
|
|
519
|
+
...p(s)
|
|
520
|
+
},
|
|
521
|
+
{ resolveLinks: !1 }
|
|
522
|
+
), a = f(c);
|
|
495
523
|
return new h({
|
|
496
|
-
page:
|
|
497
|
-
total:
|
|
498
|
-
size:
|
|
499
|
-
items:
|
|
524
|
+
page: n.page,
|
|
525
|
+
total: c.total,
|
|
526
|
+
size: n.size,
|
|
527
|
+
items: c.items.map((d) => K(d, a))
|
|
500
528
|
});
|
|
501
|
-
},
|
|
529
|
+
}, oe = async ({
|
|
502
530
|
id: e,
|
|
503
|
-
slug:
|
|
531
|
+
slug: s,
|
|
504
532
|
marketCode: i,
|
|
505
|
-
locale:
|
|
533
|
+
locale: l
|
|
506
534
|
}) => {
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
535
|
+
const t = z({ id: e, slug: s }), n = await r.client.getEntries(
|
|
536
|
+
{
|
|
537
|
+
content_type: "documentationArticle",
|
|
538
|
+
...t,
|
|
539
|
+
select: `${O},fields.content,fields.seo`,
|
|
540
|
+
include: 2,
|
|
541
|
+
order: m,
|
|
542
|
+
...g(i),
|
|
543
|
+
...p(l)
|
|
544
|
+
},
|
|
545
|
+
{ resolveLinks: !1 }
|
|
546
|
+
), c = n.items.at(0);
|
|
547
|
+
if (!c)
|
|
548
|
+
throw C();
|
|
549
|
+
const a = f(n);
|
|
519
550
|
return {
|
|
520
|
-
...
|
|
521
|
-
content:
|
|
522
|
-
seo:
|
|
551
|
+
...K(c, a),
|
|
552
|
+
content: T(c.fields.content, a),
|
|
553
|
+
seo: _(a.entry(c.fields.seo))
|
|
523
554
|
};
|
|
524
|
-
},
|
|
555
|
+
}, ne = async ({
|
|
525
556
|
page: e = 1,
|
|
526
|
-
size:
|
|
557
|
+
size: s = 20,
|
|
527
558
|
marketCode: i,
|
|
528
|
-
locale:
|
|
559
|
+
locale: l
|
|
529
560
|
} = {}) => {
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
561
|
+
const t = w(e, s), n = await r.client.getEntries(
|
|
562
|
+
{
|
|
563
|
+
content_type: "hyperlinkCollection",
|
|
564
|
+
select: "sys.id,fields.name,fields.slot,fields.order,fields.links",
|
|
565
|
+
include: 1,
|
|
566
|
+
order: "fields.order",
|
|
567
|
+
...t.params,
|
|
568
|
+
...g(i),
|
|
569
|
+
...p(l)
|
|
570
|
+
},
|
|
571
|
+
{ resolveLinks: !1 }
|
|
572
|
+
), c = f(n);
|
|
539
573
|
return new h({
|
|
540
|
-
page:
|
|
541
|
-
total:
|
|
542
|
-
size:
|
|
543
|
-
items:
|
|
574
|
+
page: t.page,
|
|
575
|
+
total: n.total,
|
|
576
|
+
size: t.size,
|
|
577
|
+
items: n.items.map(
|
|
544
578
|
(a) => ({
|
|
545
579
|
sys: { id: a.sys.id },
|
|
546
|
-
name:
|
|
547
|
-
slot:
|
|
548
|
-
order:
|
|
580
|
+
name: o(a.fields.name),
|
|
581
|
+
slot: o(a.fields.slot),
|
|
582
|
+
order: o(a.fields.order),
|
|
549
583
|
linksCollection: {
|
|
550
|
-
items:
|
|
584
|
+
items: c.entries(a.fields.links).map((d) => b(d))
|
|
551
585
|
}
|
|
552
586
|
})
|
|
553
587
|
)
|
|
554
588
|
});
|
|
555
|
-
},
|
|
589
|
+
}, ae = async ({
|
|
556
590
|
page: e = 1,
|
|
557
|
-
size:
|
|
591
|
+
size: s = 20,
|
|
558
592
|
marketCode: i,
|
|
559
|
-
locale:
|
|
593
|
+
locale: l
|
|
560
594
|
} = {}) => {
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
595
|
+
const t = w(e, s), n = await r.client.getEntries(
|
|
596
|
+
{
|
|
597
|
+
content_type: "keywordCollection",
|
|
598
|
+
select: "sys.id,fields.name,fields.slot,fields.keywords",
|
|
599
|
+
include: 0,
|
|
600
|
+
order: m,
|
|
601
|
+
...t.params,
|
|
602
|
+
...g(i),
|
|
603
|
+
...p(l)
|
|
604
|
+
},
|
|
605
|
+
{ resolveLinks: !1 }
|
|
606
|
+
);
|
|
570
607
|
return new h({
|
|
571
|
-
page:
|
|
572
|
-
total:
|
|
573
|
-
size:
|
|
574
|
-
items:
|
|
575
|
-
(
|
|
576
|
-
sys: { id:
|
|
577
|
-
name:
|
|
578
|
-
slot:
|
|
579
|
-
keywords:
|
|
608
|
+
page: t.page,
|
|
609
|
+
total: n.total,
|
|
610
|
+
size: t.size,
|
|
611
|
+
items: n.items.map(
|
|
612
|
+
(c) => ({
|
|
613
|
+
sys: { id: c.sys.id },
|
|
614
|
+
name: o(c.fields.name),
|
|
615
|
+
slot: o(c.fields.slot),
|
|
616
|
+
keywords: o(c.fields.keywords)
|
|
580
617
|
})
|
|
581
618
|
)
|
|
582
619
|
});
|
|
583
|
-
},
|
|
620
|
+
}, ce = async ({
|
|
584
621
|
marketCode: e,
|
|
585
|
-
locale:
|
|
622
|
+
locale: s
|
|
586
623
|
} = {}) => {
|
|
587
|
-
const i = await
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
624
|
+
const i = await r.client.getEntries(
|
|
625
|
+
{
|
|
626
|
+
content_type: "policyAndTerms",
|
|
627
|
+
select: "sys.id,fields.title,fields.locale,fields.content",
|
|
628
|
+
include: 1,
|
|
629
|
+
order: m,
|
|
630
|
+
limit: 1,
|
|
631
|
+
...g(e),
|
|
632
|
+
...p(s)
|
|
633
|
+
},
|
|
634
|
+
{ resolveLinks: !1 }
|
|
635
|
+
), l = i.items.at(0);
|
|
636
|
+
if (!l)
|
|
637
|
+
throw C();
|
|
598
638
|
return {
|
|
599
|
-
sys: { id:
|
|
600
|
-
title:
|
|
601
|
-
locale:
|
|
602
|
-
content:
|
|
639
|
+
sys: { id: l.sys.id },
|
|
640
|
+
title: o(l.fields.title),
|
|
641
|
+
locale: o(l.fields.locale),
|
|
642
|
+
content: T(l.fields.content, f(i))
|
|
603
643
|
};
|
|
604
644
|
};
|
|
605
645
|
export {
|
|
606
|
-
|
|
646
|
+
r as ContentfulSDK,
|
|
607
647
|
h as PaginatedResponse,
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
648
|
+
Q as getBannerCollections,
|
|
649
|
+
X as getBlogCategories,
|
|
650
|
+
Z as getBlogCategoryDetail,
|
|
651
|
+
ee as getBlogCollections,
|
|
652
|
+
W as getBlogPostDetail,
|
|
653
|
+
V as getBlogPosts,
|
|
654
|
+
se as getBrandCollections,
|
|
655
|
+
oe as getDocArticleDetail,
|
|
656
|
+
le as getDocArticles,
|
|
657
|
+
te as getDocCategories,
|
|
658
|
+
ie as getDocCategoryDetail,
|
|
659
|
+
ne as getHyperlinkCollections,
|
|
660
|
+
ae as getKeywordCollections,
|
|
661
|
+
ce as getPolicyAndTerms
|
|
622
662
|
};
|