@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/dist/index.js CHANGED
@@ -1,61 +1,29 @@
1
- const m = "-sys.updatedAt", g = (e) => e ? {
2
- "or.market.0.fields.markets[exists]": "false",
3
- "or.market.1.fields.markets.sys.contentType.sys.id": "market",
4
- "or.market.1.fields.markets.fields.code": e
5
- } : {}, p = (e) => e ? {
6
- "or.locale.0.fields.locale[exists]": "false",
7
- "or.locale.1.fields.locale": e
8
- } : {}, z = ({ id: e, slug: t }) => {
9
- if (e)
10
- return { "sys.id": e, limit: 1 };
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 configure(t) {
38
- this._config = t;
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 async getEntries(t) {
41
- const { url: i, headers: o = {} } = this.config, s = await fetch(
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: t,
36
+ page: s,
69
37
  total: i,
70
- size: o,
71
- items: s
38
+ size: l,
39
+ items: t
72
40
  }) {
73
- this.page = t, this.total = i, this.size = o, this.items = s, this.totalPages = Math.ceil(this.total / this.size);
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 f = (e) => {
77
- const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
78
- for (const s of [...e.items, ...e.includes?.Entry ?? []])
79
- t.set(s.sys.id, s);
80
- for (const s of e.includes?.Asset ?? [])
81
- i.set(s.sys.id, s);
82
- const o = (s) => (s && t.get(s.sys.id)) ?? null;
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: o,
85
- asset: (s) => (s && i.get(s.sys.id)) ?? null,
86
- entries: (s) => (s ?? []).map((l) => o(l)).filter((l) => l !== null)
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
- }, n = (e) => e ?? null, C = (e) => {
89
- const t = e?.fields.file;
90
- return t ? {
91
- url: t.url,
92
- width: t.details.image?.width ?? null,
93
- height: t.details.image?.height ?? null,
94
- contentType: t.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
- }, G = (e) => ({
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: n(e.fields.title),
103
- description: n(e.fields.description)
104
- }), B = (e, t) => {
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 t;
102
+ return s;
107
103
  const i = e;
108
104
  if (i.nodeType === "embedded-asset-block") {
109
- const o = i.data?.target?.sys?.id;
110
- o && !t.includes(o) && t.push(o);
105
+ const l = i.data?.target?.sys?.id;
106
+ l && !s.includes(l) && s.push(l);
111
107
  }
112
- for (const o of i.content ?? [])
113
- B(o, t);
114
- return t;
115
- }, D = (e, t) => {
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 = B(e, []).map((o) => t.asset({ sys: { type: "Link", linkType: "Asset", id: o } })).filter((o) => o !== null && !!o.fields.file).map(G);
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
- }, A = (e) => e ? {
121
- metaTitle: n(e.fields.metaTitle),
122
- metaDescription: n(e.fields.metaDescription),
123
- metaKeywords: n(e.fields.metaKeywords),
124
- metaRobots: n(e.fields.metaRobots)
125
- } : null, v = (e) => e ? {
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: n(e.fields.label),
128
- url: n(e.fields.url),
129
- target: n(e.fields.target),
130
- marketHandling: n(e.fields.marketHandling)
131
- } : null, x = (e, t) => e ? {
132
- name: n(e.fields.name),
133
- avatar: C(t.asset(e.fields.avatar))
134
- } : null, q = async ({
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: t = 1,
132
+ page: s = 1,
137
133
  size: i = 20,
138
- platform: o,
139
- marketCode: s,
140
- locale: l
134
+ platform: l,
135
+ marketCode: t,
136
+ locale: n
141
137
  }) => {
142
- const d = w(t, i), a = await c.getEntries({
143
- content_type: "bannerCollection",
144
- "fields.slot": e,
145
- "fields.platform": o || void 0,
146
- select: "sys.id,fields.name,fields.slot,fields.platform,fields.banners",
147
- include: 2,
148
- order: m,
149
- ...d.params,
150
- ...g(s),
151
- ...p(l)
152
- }), r = f(a);
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: d.page,
153
+ page: c.page,
155
154
  total: a.total,
156
- size: d.size,
155
+ size: c.size,
157
156
  items: a.items.map(
158
157
  (u) => ({
159
158
  sys: { id: u.sys.id },
160
- name: n(u.fields.name),
161
- slot: n(u.fields.slot),
162
- platform: n(u.fields.platform),
159
+ name: o(u.fields.name),
160
+ slot: o(u.fields.slot),
161
+ platform: o(u.fields.platform),
163
162
  bannersCollection: {
164
- items: r.entries(u.fields.banners).map((E) => ({
165
- sys: { id: E.sys.id },
166
- name: n(E.fields.name),
167
- hyperlink: v(
168
- r.entry(E.fields.hyperlink)
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: C(r.asset(E.fields.media))
169
+ media: E(d.asset(k.fields.media))
171
170
  }))
172
171
  }
173
172
  })
174
173
  )
175
174
  });
176
- };
177
- class k extends Response {
178
- constructor(...t) {
179
- super(t[0] ?? "Not Found", {
180
- status: 404,
181
- ...t[1]
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: n(e.fields.title),
192
- shortDescription: n(e.fields.shortDescription),
193
- slug: n(e.fields.slug),
186
+ title: o(e.fields.title),
187
+ shortDescription: o(e.fields.shortDescription),
188
+ slug: o(e.fields.slug),
194
189
  categoriesCollection: {
195
- items: t.entries(e.fields.categories).map((i) => ({
190
+ items: s.entries(e.fields.categories).map((i) => ({
196
191
  sys: { id: i.sys.id },
197
- title: n(i.fields.title),
198
- slug: n(i.fields.slug),
199
- featuredImage: C(t.asset(i.fields.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: C(t.asset(e.fields.featuredImage))
203
- }), U = async ({
197
+ featuredImage: E(s.asset(e.fields.featuredImage))
198
+ }), V = async ({
204
199
  marketCode: e,
205
- locale: t,
200
+ locale: s,
206
201
  collectionId: i,
207
- categoryId: o,
208
- page: s = 1,
209
- size: l = 20,
210
- skip: d = 0
202
+ categoryId: l,
203
+ page: t = 1,
204
+ size: n = 20,
205
+ skip: c = 0
211
206
  } = {}) => {
212
- const a = w(s, l, d);
207
+ const a = w(t, n, c);
213
208
  if (i) {
214
- const R = (await c.getEntries({
215
- content_type: "blogCollection",
216
- "sys.id": i,
217
- select: "sys.id,fields.posts",
218
- include: 0,
219
- limit: 1
220
- })).items.at(0);
221
- if (!R)
222
- throw new k();
223
- const _ = (R.fields.posts ?? []).filter((y) => y.sys.linkType === "Entry").map((y) => y.sys.id), T = _.slice(a.params.skip, a.params.skip + a.size);
224
- if (!T.length)
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: _.length,
225
+ total: v.length,
228
226
  size: a.size,
229
227
  items: []
230
228
  });
231
- const P = await c.getEntries({
232
- content_type: "blogPost",
233
- "sys.id[in]": T.join(","),
234
- select: I,
235
- include: 2,
236
- limit: a.size
237
- }), H = f(P), K = new Map(P.items.map((y) => [y.sys.id, y]));
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: _.length,
241
+ total: v.length,
241
242
  size: a.size,
242
- items: T.map((y) => K.get(y)).filter((y) => y !== void 0).map((y) => b(y, H))
243
+ items: A.map((y) => j.get(y)).filter((y) => y !== void 0).map((y) => L(y, N))
243
244
  });
244
245
  }
245
- const r = await c.getEntries({
246
- content_type: "blogPost",
247
- "fields.categories.sys.id": o || void 0,
248
- select: I,
249
- include: 2,
250
- order: m,
251
- ...a.params,
252
- ...g(e),
253
- ...p(t)
254
- }), u = f(r);
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: r.total,
261
+ total: d.total,
258
262
  size: a.size,
259
- items: r.items.map((E) => b(E, u))
263
+ items: d.items.map((k) => L(k, u))
260
264
  });
261
- }, Y = async ({
265
+ }, W = async ({
262
266
  id: e,
263
- slug: t,
267
+ slug: s,
264
268
  marketCode: i,
265
- locale: o
269
+ locale: l
266
270
  }) => {
267
- const s = z({ id: e, slug: t }), l = await c.getEntries({
268
- content_type: "blogPost",
269
- ...s,
270
- select: `${I},fields.author,fields.content,fields.seo`,
271
- include: 2,
272
- order: m,
273
- ...g(i),
274
- ...p(o)
275
- }), d = l.items.at(0);
276
- if (!d)
277
- throw new k();
278
- const a = f(l);
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
- ...b(d, a),
281
- author: x(a.entry(d.fields.author), a),
282
- content: D(d.fields.content, a),
283
- seo: A(a.entry(d.fields.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
- }, S = "sys.id,fields.title,fields.slug,fields.featuredImage", L = (e, t) => ({
292
+ }, M = "sys.id,fields.title,fields.slug,fields.featuredImage", x = (e, s) => ({
286
293
  sys: { id: e.sys.id },
287
- title: n(e.fields.title),
288
- slug: n(e.fields.slug),
289
- featuredImage: C(t.asset(e.fields.featuredImage))
290
- }), J = async ({
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: t,
299
+ locale: s,
293
300
  page: i = 1,
294
- size: o = 20
301
+ size: l = 20
295
302
  } = {}) => {
296
- const s = w(i, o), l = await c.getEntries({
297
- content_type: "blogCategory",
298
- select: S,
299
- include: 1,
300
- order: m,
301
- ...s.params,
302
- ...g(e),
303
- ...p(t)
304
- }), d = f(l);
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: s.page,
307
- total: l.total,
308
- size: s.size,
309
- items: l.items.map((a) => L(a, d))
316
+ page: t.page,
317
+ total: n.total,
318
+ size: t.size,
319
+ items: n.items.map((a) => x(a, c))
310
320
  });
311
- }, Q = async ({
321
+ }, Z = async ({
312
322
  id: e,
313
- slug: t,
323
+ slug: s,
314
324
  marketCode: i,
315
- locale: o
325
+ locale: l
316
326
  }) => {
317
- const s = z({ id: e, slug: t }), l = await c.getEntries({
318
- content_type: "blogCategory",
319
- ...s,
320
- select: `${S},fields.description,fields.seo`,
321
- include: 1,
322
- order: m,
323
- ...g(i),
324
- ...p(o)
325
- }), d = l.items.at(0);
326
- if (!d)
327
- throw new k();
328
- const a = f(l);
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
- ...L(d, a),
331
- description: n(d.fields.description),
332
- seo: A(a.entry(d.fields.seo))
343
+ ...x(c, a),
344
+ description: o(c.fields.description),
345
+ seo: _(a.entry(c.fields.seo))
333
346
  };
334
- }, V = async ({
347
+ }, ee = async ({
335
348
  marketCode: e,
336
- locale: t,
349
+ locale: s,
337
350
  page: i = 1,
338
- size: o = 20
351
+ size: l = 20
339
352
  } = {}) => {
340
- const s = w(i, o), l = await c.getEntries({
341
- content_type: "blogCollection",
342
- select: "sys.id,fields.name,fields.type,fields.order,fields.category,fields.featuredImage",
343
- include: 1,
344
- order: m,
345
- ...s.params,
346
- ...g(e),
347
- ...p(t)
348
- }), d = f(l), a = l.items.map((r) => {
349
- const u = d.entry(r.fields.category);
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: n(r.fields.name),
352
- type: n(r.fields.type),
353
- order: n(r.fields.order),
354
- sys: { id: r.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: n(u.fields.title),
358
- slug: n(u.fields.slug)
373
+ title: o(u.fields.title),
374
+ slug: o(u.fields.slug)
359
375
  } : null,
360
- featuredImage: C(d.asset(r.fields.featuredImage))
376
+ featuredImage: E(c.asset(d.fields.featuredImage))
361
377
  };
362
378
  });
363
379
  return new h({
364
- page: s.page,
365
- total: l.total,
366
- size: s.size,
367
- items: a.map((r) => ({
368
- ...r,
369
- category: r.type === "category" ? r.category : null,
370
- categoryId: r.type === "category" ? r.category?.sys.id ?? null : null,
371
- collectionId: r.type === "manual" ? r.sys.id : null
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
- }, W = async ({
390
+ }, se = async ({
375
391
  page: e = 1,
376
- size: t = 20,
392
+ size: s = 20,
377
393
  marketCode: i,
378
- locale: o
394
+ locale: l
379
395
  } = {}) => {
380
- const s = w(e, t), l = await c.getEntries({
381
- content_type: "brandCollection",
382
- select: "sys.id,fields.name,fields.slot,fields.brands",
383
- include: 2,
384
- order: m,
385
- ...s.params,
386
- ...g(i),
387
- ...p(o)
388
- }), d = f(l);
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: s.page,
391
- total: l.total,
392
- size: s.size,
393
- items: l.items.map(
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: n(a.fields.name),
397
- slot: n(a.fields.slot),
415
+ name: o(a.fields.name),
416
+ slot: o(a.fields.slot),
398
417
  brandsCollection: {
399
- items: d.entries(a.fields.brands).map((r) => ({
400
- sys: { id: r.sys.id },
401
- name: n(r.fields.name),
402
- logo: C(d.asset(r.fields.logo)),
403
- hyperlink: v(
404
- d.entry(r.fields.hyperlink)
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
- }, M = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.description,fields.order,fields.seo", $ = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.author,fields.category", O = (e) => ({
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
- }), j = (e, t) => ({
416
- sys: O(e),
417
- title: n(e.fields.title),
418
- slug: n(e.fields.slug),
419
- description: n(e.fields.description),
420
- order: n(e.fields.order),
421
- seo: A(t.entry(e.fields.seo))
422
- }), F = (e, t) => {
423
- const i = t.entry(e.fields.category);
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: O(e),
426
- title: n(e.fields.title),
427
- slug: n(e.fields.slug),
428
- author: x(t.entry(e.fields.author), t),
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: n(i.fields.title),
431
- slug: n(i.fields.slug),
432
- description: n(i.fields.description),
433
- order: n(i.fields.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
- }, X = async ({
455
+ }, te = async ({
437
456
  marketCode: e,
438
- locale: t,
457
+ locale: s,
439
458
  page: i = 1,
440
- size: o = 20
459
+ size: l = 20
441
460
  } = {}) => {
442
- const s = w(i, o), l = await c.getEntries({
443
- content_type: "documentationCategory",
444
- select: M,
445
- include: 1,
446
- order: m,
447
- ...s.params,
448
- ...g(e),
449
- ...p(t)
450
- }), d = f(l);
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: s.page,
453
- total: l.total,
454
- size: s.size,
455
- items: l.items.map((a) => j(a, d))
474
+ page: t.page,
475
+ total: n.total,
476
+ size: t.size,
477
+ items: n.items.map((a) => H(a, c))
456
478
  });
457
- }, Z = async ({
479
+ }, ie = async ({
458
480
  id: e,
459
- slug: t,
481
+ slug: s,
460
482
  marketCode: i,
461
- locale: o
483
+ locale: l
462
484
  }) => {
463
- const s = z({ id: e, slug: t }), l = await c.getEntries({
464
- content_type: "documentationCategory",
465
- ...s,
466
- select: M,
467
- include: 1,
468
- order: m,
469
- ...g(i),
470
- ...p(o)
471
- }), d = l.items.at(0);
472
- if (!d)
473
- throw new k();
474
- return j(d, f(l));
475
- }, ee = async ({
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: t,
502
+ locale: s,
478
503
  categorySlug: i,
479
- page: o = 1,
480
- size: s = 20
504
+ page: l = 1,
505
+ size: t = 20
481
506
  } = {}) => {
482
- const l = w(o, s), d = await c.getEntries({
483
- content_type: "documentationArticle",
484
- ...i ? {
485
- "fields.category.sys.contentType.sys.id": "documentationCategory",
486
- "fields.category.fields.slug": i
487
- } : {},
488
- select: $,
489
- include: 2,
490
- order: m,
491
- ...l.params,
492
- ...g(e),
493
- ...p(t)
494
- }), a = f(d);
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: l.page,
497
- total: d.total,
498
- size: l.size,
499
- items: d.items.map((r) => F(r, a))
524
+ page: n.page,
525
+ total: c.total,
526
+ size: n.size,
527
+ items: c.items.map((d) => K(d, a))
500
528
  });
501
- }, te = async ({
529
+ }, oe = async ({
502
530
  id: e,
503
- slug: t,
531
+ slug: s,
504
532
  marketCode: i,
505
- locale: o
533
+ locale: l
506
534
  }) => {
507
- const s = z({ id: e, slug: t }), l = await c.getEntries({
508
- content_type: "documentationArticle",
509
- ...s,
510
- select: `${$},fields.content,fields.seo`,
511
- include: 2,
512
- order: m,
513
- ...g(i),
514
- ...p(o)
515
- }), d = l.items.at(0);
516
- if (!d)
517
- throw new k();
518
- const a = f(l);
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
- ...F(d, a),
521
- content: D(d.fields.content, a),
522
- seo: A(a.entry(d.fields.seo))
551
+ ...K(c, a),
552
+ content: T(c.fields.content, a),
553
+ seo: _(a.entry(c.fields.seo))
523
554
  };
524
- }, se = async ({
555
+ }, ne = async ({
525
556
  page: e = 1,
526
- size: t = 20,
557
+ size: s = 20,
527
558
  marketCode: i,
528
- locale: o
559
+ locale: l
529
560
  } = {}) => {
530
- const s = w(e, t), l = await c.getEntries({
531
- content_type: "hyperlinkCollection",
532
- select: "sys.id,fields.name,fields.slot,fields.order,fields.links",
533
- include: 1,
534
- order: "fields.order",
535
- ...s.params,
536
- ...g(i),
537
- ...p(o)
538
- }), d = f(l);
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: s.page,
541
- total: l.total,
542
- size: s.size,
543
- items: l.items.map(
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: n(a.fields.name),
547
- slot: n(a.fields.slot),
548
- order: n(a.fields.order),
580
+ name: o(a.fields.name),
581
+ slot: o(a.fields.slot),
582
+ order: o(a.fields.order),
549
583
  linksCollection: {
550
- items: d.entries(a.fields.links).map((r) => v(r))
584
+ items: c.entries(a.fields.links).map((d) => b(d))
551
585
  }
552
586
  })
553
587
  )
554
588
  });
555
- }, ie = async ({
589
+ }, ae = async ({
556
590
  page: e = 1,
557
- size: t = 20,
591
+ size: s = 20,
558
592
  marketCode: i,
559
- locale: o
593
+ locale: l
560
594
  } = {}) => {
561
- const s = w(e, t), l = await c.getEntries({
562
- content_type: "keywordCollection",
563
- select: "sys.id,fields.name,fields.slot,fields.keywords",
564
- include: 0,
565
- order: m,
566
- ...s.params,
567
- ...g(i),
568
- ...p(o)
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: s.page,
572
- total: l.total,
573
- size: s.size,
574
- items: l.items.map(
575
- (d) => ({
576
- sys: { id: d.sys.id },
577
- name: n(d.fields.name),
578
- slot: n(d.fields.slot),
579
- keywords: n(d.fields.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
- }, oe = async ({
620
+ }, ce = async ({
584
621
  marketCode: e,
585
- locale: t
622
+ locale: s
586
623
  } = {}) => {
587
- const i = await c.getEntries({
588
- content_type: "policyAndTerms",
589
- select: "sys.id,fields.title,fields.locale,fields.content",
590
- include: 1,
591
- order: m,
592
- limit: 1,
593
- ...g(e),
594
- ...p(t)
595
- }), o = i.items.at(0);
596
- if (!o)
597
- throw new k();
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: o.sys.id },
600
- title: n(o.fields.title),
601
- locale: n(o.fields.locale),
602
- content: D(o.fields.content, f(i))
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
- c as ContentfulSDK,
646
+ r as ContentfulSDK,
607
647
  h as PaginatedResponse,
608
- q as getBannerCollections,
609
- J as getBlogCategories,
610
- Q as getBlogCategoryDetail,
611
- V as getBlogCollections,
612
- Y as getBlogPostDetail,
613
- U as getBlogPosts,
614
- W as getBrandCollections,
615
- te as getDocArticleDetail,
616
- ee as getDocArticles,
617
- X as getDocCategories,
618
- Z as getDocCategoryDetail,
619
- se as getHyperlinkCollections,
620
- ie as getKeywordCollections,
621
- oe as getPolicyAndTerms
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
  };