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