@janbox/contentful-marketplace-sdk 4.0.0-alpha.0 → 4.0.0-alpha.2
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 +46 -1
- package/dist/entries/help-center.d.ts +56 -0
- package/dist/entries/index.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +382 -268
- package/dist/types/content-model.d.ts +18 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,6 +191,50 @@ const articleById = await getDocArticleDetail({
|
|
|
191
191
|
});
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
+
### Help Center
|
|
195
|
+
|
|
196
|
+
- `getHelpCategories(options?)`
|
|
197
|
+
- `getHelpCategoryDetail({ id } | { slug })`
|
|
198
|
+
- `getHelpArticles(options?)`
|
|
199
|
+
- `getHelpArticleDetail({ id } | { slug })`
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
// Categories are flat: build the tree from parentId (null = top level).
|
|
203
|
+
const categories = await getHelpCategories({ locale: "vi", size: 1000 });
|
|
204
|
+
|
|
205
|
+
// One category, same shape as a list item.
|
|
206
|
+
const category = await getHelpCategoryDetail({
|
|
207
|
+
slug: "thanh-toan",
|
|
208
|
+
locale: "vi",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Article summaries (no body). Filter by category or featured flag.
|
|
212
|
+
const articles = await getHelpArticles({ locale: "vi", size: 1000 });
|
|
213
|
+
const featured = await getHelpArticles({ locale: "vi", featured: true });
|
|
214
|
+
const subcategory = categories.items.find((c) => c.parentId !== null);
|
|
215
|
+
const inCategory = await getHelpArticles({
|
|
216
|
+
locale: "vi",
|
|
217
|
+
categoryId: subcategory?.sys.id,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const article = await getHelpArticleDetail({
|
|
221
|
+
slug: "bao-lau-hang-ve-viet-nam",
|
|
222
|
+
locale: "vi",
|
|
223
|
+
});
|
|
224
|
+
// article.body: { json, links: { assets: { block } } } | null
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Notes:
|
|
228
|
+
|
|
229
|
+
- Results are ordered by `position`.
|
|
230
|
+
- To load a whole locale, pass `size: 1000` (the maximum the CMS accepts) and check `totalPages`. A larger `size` is rejected with `CmsError` `InvalidQuery`.
|
|
231
|
+
- `path` is the path stored on the CMS for the entry.
|
|
232
|
+
- An article slug is unique within a locale only, so pass `locale` when looking an article up by slug.
|
|
233
|
+
- A category slug is not always unique, even within a locale: a subcategory can share its parent's slug. `getHelpCategoryDetail({ slug })` then returns the category that comes first by `position`; use `id` to get a specific one.
|
|
234
|
+
- Every item has `locale` (`null` when the entry has none), so an article fetched by `id`, or a list fetched without `locale`, still tells which language it belongs to.
|
|
235
|
+
- `categoryId` is `null` for an article with no category.
|
|
236
|
+
- The `categoryId` filter matches an article's own category only, not its subcategories. To list a whole branch, load all articles once and group them by `categoryId` along the tree.
|
|
237
|
+
|
|
194
238
|
### Brand / Hyperlink / Keyword Collections
|
|
195
239
|
|
|
196
240
|
- `getBrandCollections(options?)`
|
|
@@ -239,7 +283,7 @@ Filters `marketCode` / `locale` with global fallback (entries where `markets` /
|
|
|
239
283
|
|
|
240
284
|
Every error from the CMS is a `CmsError` of `@janbox/headless-cms-sdk` (`id`, `status`, `requestId`, `details`, `url`). The SDK README lists the `id` values.
|
|
241
285
|
|
|
242
|
-
- The detail functions (`getBlogPostDetail`, `getBlogCategoryDetail`, `getDocCategoryDetail`, `getDocArticleDetail`), `getPolicyAndTerms` and `getBlogPosts({ collectionId })` throw a `CmsError` with `id: "NotFound"`, `status: 404` and `message: "Entry not found"` when no entry matches.
|
|
286
|
+
- The detail functions (`getBlogPostDetail`, `getBlogCategoryDetail`, `getDocCategoryDetail`, `getDocArticleDetail`, `getHelpCategoryDetail`, `getHelpArticleDetail`), `getPolicyAndTerms` and `getBlogPosts({ collectionId })` throw a `CmsError` with `id: "NotFound"`, `status: 404` and `message: "Entry not found"` when no entry matches.
|
|
243
287
|
- The detail functions throw `Error("Either id or slug is required.")` if neither `id` nor `slug` is provided.
|
|
244
288
|
- Calling a function before `configure` throws `Error("Client is not configured")`.
|
|
245
289
|
|
|
@@ -275,6 +319,7 @@ The package exports:
|
|
|
275
319
|
- client and entry functions from `src/client` and `src/entries`
|
|
276
320
|
- content model field types (`TypeXxxFields`) from `src/types`
|
|
277
321
|
- response item types such as `BlogPostGraphQLItem` and `DocArticleGraphQLItem` (names kept from 2.x)
|
|
322
|
+
- help center item types `HelpCategoryItem`, `HelpArticleItem`, `HelpArticleDetailItem`, and `RichText` (the shape of rich text fields such as `body`)
|
|
278
323
|
|
|
279
324
|
CMS data, query, config and error types (`Entry`, `Asset`, `Link`, `RawEntryCollection`, `EntriesQuery`, `ClientConfig`, `CmsClient`, `CmsError`) come from `@janbox/headless-cms-sdk`; this package does not re-export them.
|
|
280
325
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PaginatedResponse } from '../utils';
|
|
2
|
+
import { RichText } from '../utils/resolve';
|
|
3
|
+
type HelpEntrySys = {
|
|
4
|
+
id: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
};
|
|
8
|
+
export type HelpCategoryItem = {
|
|
9
|
+
sys: HelpEntrySys;
|
|
10
|
+
title: string | null;
|
|
11
|
+
slug: string | null;
|
|
12
|
+
path: string | null;
|
|
13
|
+
locale: string | null;
|
|
14
|
+
position: number | null;
|
|
15
|
+
parentId: string | null;
|
|
16
|
+
};
|
|
17
|
+
export type HelpArticleItem = {
|
|
18
|
+
sys: HelpEntrySys;
|
|
19
|
+
title: string | null;
|
|
20
|
+
slug: string | null;
|
|
21
|
+
path: string | null;
|
|
22
|
+
locale: string | null;
|
|
23
|
+
position: number | null;
|
|
24
|
+
featured: boolean;
|
|
25
|
+
categoryId: string | null;
|
|
26
|
+
};
|
|
27
|
+
export type GetHelpCategoriesResponse = PaginatedResponse<HelpCategoryItem>;
|
|
28
|
+
export type GetHelpCategoryDetailResponse = HelpCategoryItem;
|
|
29
|
+
export type GetHelpArticlesResponse = PaginatedResponse<HelpArticleItem>;
|
|
30
|
+
export interface HelpArticleDetailItem extends HelpArticleItem {
|
|
31
|
+
body: RichText | null;
|
|
32
|
+
}
|
|
33
|
+
export type GetHelpArticleDetailResponse = HelpArticleDetailItem;
|
|
34
|
+
export declare const getHelpCategories: ({ locale, page, size, }?: {
|
|
35
|
+
locale?: string;
|
|
36
|
+
page?: number;
|
|
37
|
+
size?: number;
|
|
38
|
+
}) => Promise<GetHelpCategoriesResponse>;
|
|
39
|
+
export declare const getHelpCategoryDetail: ({ id, slug, locale, }: {
|
|
40
|
+
id?: string;
|
|
41
|
+
slug?: string;
|
|
42
|
+
locale?: string;
|
|
43
|
+
}) => Promise<GetHelpCategoryDetailResponse>;
|
|
44
|
+
export declare const getHelpArticles: ({ locale, categoryId, featured, page, size, }?: {
|
|
45
|
+
locale?: string;
|
|
46
|
+
categoryId?: string;
|
|
47
|
+
featured?: boolean;
|
|
48
|
+
page?: number;
|
|
49
|
+
size?: number;
|
|
50
|
+
}) => Promise<GetHelpArticlesResponse>;
|
|
51
|
+
export declare const getHelpArticleDetail: ({ id, slug, locale, }: {
|
|
52
|
+
id?: string;
|
|
53
|
+
slug?: string;
|
|
54
|
+
locale?: string;
|
|
55
|
+
}) => Promise<GetHelpArticleDetailResponse>;
|
|
56
|
+
export {};
|
package/dist/entries/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './blog-category';
|
|
|
4
4
|
export * from './blog-collection';
|
|
5
5
|
export * from './brand-collection';
|
|
6
6
|
export * from './documentation';
|
|
7
|
+
export * from './help-center';
|
|
7
8
|
export * from './hyperlink-collection';
|
|
8
9
|
export * from './hyperlink';
|
|
9
10
|
export * from './keyword-collection';
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@janbox/headless-cms-sdk"),U=["baseUrl","accessToken","headers","fetch","timeout","retry"];class d{static _config;static _client;static get config(){if(!this._config)throw new Error("Client is not configured");return this._config}static get client(){const t=this.config,i=this._client;if(i&&U.every(s=>i.builtFrom[s]===t[s]))return i.client;const l=A.createClient(t);return this._client={client:l,builtFrom:{...t}},l}static configure(t){this._config=t}}class h{page;total;size;items;totalPages;constructor({page:t,total:i,size:l,items:s}){this.page=t,this.total=i,this.size=l,this.items=s,this.totalPages=Math.ceil(this.total/this.size)}}const m="-sys.updatedAt",g=e=>e?A.or("market",[{"fields.markets[exists]":"false"},{"fields.markets.sys.contentType.sys.id":"market","fields.markets.fields.code":e}]):{},p=e=>e?A.or("locale",[{"fields.locale[exists]":"false"},{"fields.locale":e}]):{},v=({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 l=Math.max(1,Math.floor(e)),s=Math.max(1,Math.floor(t)),n=Math.max(0,Math.floor(i));return{page:l,size:s,params:{limit:s,skip:(l-1)*s+n}}},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 l=s=>(s&&t.get(s.sys.id))??null;return{entry:l,asset:s=>(s&&i.get(s.sys.id))??null,entries:s=>(s??[]).map(n=>l(n)).filter(n=>n!==null)}},o=e=>e??null,k=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},q=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:o(e.fields.title),description:o(e.fields.description)}),S=(e,t)=>{if(!e||typeof e!="object")return t;const i=e;if(i.nodeType==="embedded-asset-block"){const l=i.data?.target?.sys?.id;l&&!t.includes(l)&&t.push(l)}for(const l of i.content??[])S(l,t);return t},T=(e,t)=>{if(!e)return null;const i=S(e,[]).map(l=>t.asset({sys:{type:"Link",linkType:"Asset",id:l}})).filter(l=>l!==null&&!!l.fields.file).map(q);return{json:e,links:{assets:{block:i}}}},z=e=>e?{metaTitle:o(e.fields.metaTitle),metaDescription:o(e.fields.metaDescription),metaKeywords:o(e.fields.metaKeywords),metaRobots:o(e.fields.metaRobots)}:null,b=e=>e?{sys:{id:e.sys.id},label:o(e.fields.label),url:o(e.fields.url),target:o(e.fields.target),marketHandling:o(e.fields.marketHandling)}:null,R=(e,t)=>e?{name:o(e.fields.name),avatar:k(t.asset(e.fields.avatar))}:null,G=async({slot:e,page:t=1,size:i=20,platform:l,marketCode:s,locale:n})=>{const c=w(t,i),a=await d.client.getEntries({content_type:"bannerCollection","fields.slot":e,"fields.platform":l||void 0,select:"sys.id,fields.name,fields.slot,fields.platform,fields.banners",include:2,order:m,...c.params,...g(s),...p(n)},{resolveLinks:!1}),r=f(a);return new h({page:c.page,total:a.total,size:c.size,items:a.items.map(u=>({sys:{id:u.sys.id},name:o(u.fields.name),slot:o(u.fields.slot),platform:o(u.fields.platform),bannersCollection:{items:r.entries(u.fields.banners).map(C=>({sys:{id:C.sys.id},name:o(C.fields.name),hyperlink:b(r.entry(C.fields.hyperlink)),media:k(r.asset(C.fields.media))}))}}))})},E=()=>new A.CmsError({id:"NotFound",message:"Entry not found",url:`${d.config.baseUrl.trim().replace(/\/+$/,"")}/entries`,status:404}),I="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage",L=(e,t)=>({sys:{id:e.sys.id,createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt},title:o(e.fields.title),shortDescription:o(e.fields.shortDescription),slug:o(e.fields.slug),categoriesCollection:{items:t.entries(e.fields.categories).map(i=>({sys:{id:i.sys.id},title:o(i.fields.title),slug:o(i.fields.slug),featuredImage:k(t.asset(i.fields.featuredImage))}))},featuredImage:k(t.asset(e.fields.featuredImage))}),Y=async({marketCode:e,locale:t,collectionId:i,categoryId:l,page:s=1,size:n=20,skip:c=0}={})=>{const a=w(s,n,c);if(i){const B=(await d.client.getEntries({content_type:"blogCollection","sys.id":i,select:"sys.id,fields.posts",include:0,limit:1},{resolveLinks:!1})).items.at(0);if(!B)throw E();const _=(B.fields.posts??[]).filter(y=>y.sys.linkType==="Entry").map(y=>y.sys.id),D=_.slice(a.params.skip,a.params.skip+a.size);if(!D.length)return new h({page:a.page,total:_.length,size:a.size,items:[]});const P=await d.client.getEntries({content_type:"blogPost","sys.id[in]":D.join(","),select:I,include:2,limit:a.size},{resolveLinks:!1}),j=f(P),N=new Map(P.items.map(y=>[y.sys.id,y]));return new h({page:a.page,total:_.length,size:a.size,items:D.map(y=>N.get(y)).filter(y=>y!==void 0).map(y=>L(y,j))})}const r=await d.client.getEntries({content_type:"blogPost","fields.categories.sys.id":l||void 0,select:I,include:2,order:m,...a.params,...g(e),...p(t)},{resolveLinks:!1}),u=f(r);return new h({page:a.page,total:r.total,size:a.size,items:r.items.map(C=>L(C,u))})},J=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=v({id:e,slug:t}),n=await d.client.getEntries({content_type:"blogPost",...s,select:`${I},fields.author,fields.content,fields.seo`,include:2,order:m,...g(i),...p(l)},{resolveLinks:!1}),c=n.items.at(0);if(!c)throw E();const a=f(n);return{...L(c,a),author:R(a.entry(c.fields.author),a),content:T(c.fields.content,a),seo:z(a.entry(c.fields.seo))}},M="sys.id,fields.title,fields.slug,fields.featuredImage",F=(e,t)=>({sys:{id:e.sys.id},title:o(e.fields.title),slug:o(e.fields.slug),featuredImage:k(t.asset(e.fields.featuredImage))}),Q=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=w(i,l),n=await d.client.getEntries({content_type:"blogCategory",select:M,include:1,order:m,...s.params,...g(e),...p(t)},{resolveLinks:!1}),c=f(n);return new h({page:s.page,total:n.total,size:s.size,items:n.items.map(a=>F(a,c))})},V=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=v({id:e,slug:t}),n=await d.client.getEntries({content_type:"blogCategory",...s,select:`${M},fields.description,fields.seo`,include:1,order:m,...g(i),...p(l)},{resolveLinks:!1}),c=n.items.at(0);if(!c)throw E();const a=f(n);return{...F(c,a),description:o(c.fields.description),seo:z(a.entry(c.fields.seo))}},W=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=w(i,l),n=await d.client.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)},{resolveLinks:!1}),c=f(n),a=n.items.map(r=>{const u=c.entry(r.fields.category);return{name:o(r.fields.name),type:o(r.fields.type),order:o(r.fields.order),sys:{id:r.sys.id},category:u?{sys:{id:u.sys.id},title:o(u.fields.title),slug:o(u.fields.slug)}:null,featuredImage:k(c.asset(r.fields.featuredImage))}});return new h({page:s.page,total:n.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}))})},X=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=w(e,t),n=await d.client.getEntries({content_type:"brandCollection",select:"sys.id,fields.name,fields.slot,fields.brands",include:2,order:m,...s.params,...g(i),...p(l)},{resolveLinks:!1}),c=f(n);return new h({page:s.page,total:n.total,size:s.size,items:n.items.map(a=>({sys:{id:a.sys.id},name:o(a.fields.name),slot:o(a.fields.slot),brandsCollection:{items:c.entries(a.fields.brands).map(r=>({sys:{id:r.sys.id},name:o(r.fields.name),logo:k(c.asset(r.fields.logo)),hyperlink:b(c.entry(r.fields.hyperlink))}))}}))})},x="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",K=e=>({id:e.sys.id,createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt}),H=(e,t)=>({sys:K(e),title:o(e.fields.title),slug:o(e.fields.slug),description:o(e.fields.description),order:o(e.fields.order),seo:z(t.entry(e.fields.seo))}),$=(e,t)=>{const i=t.entry(e.fields.category);return{sys:K(e),title:o(e.fields.title),slug:o(e.fields.slug),author:R(t.entry(e.fields.author),t),category:i?{title:o(i.fields.title),slug:o(i.fields.slug),description:o(i.fields.description),order:o(i.fields.order)}:null}},Z=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=w(i,l),n=await d.client.getEntries({content_type:"documentationCategory",select:x,include:1,order:m,...s.params,...g(e),...p(t)},{resolveLinks:!1}),c=f(n);return new h({page:s.page,total:n.total,size:s.size,items:n.items.map(a=>H(a,c))})},ee=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=v({id:e,slug:t}),n=await d.client.getEntries({content_type:"documentationCategory",...s,select:x,include:1,order:m,...g(i),...p(l)},{resolveLinks:!1}),c=n.items.at(0);if(!c)throw E();return H(c,f(n))},te=async({marketCode:e,locale:t,categorySlug:i,page:l=1,size:s=20}={})=>{const n=w(l,s),c=await d.client.getEntries({content_type:"documentationArticle",...i?{"fields.category.sys.contentType.sys.id":"documentationCategory","fields.category.fields.slug":i}:{},select:O,include:2,order:m,...n.params,...g(e),...p(t)},{resolveLinks:!1}),a=f(c);return new h({page:n.page,total:c.total,size:n.size,items:c.items.map(r=>$(r,a))})},se=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=v({id:e,slug:t}),n=await d.client.getEntries({content_type:"documentationArticle",...s,select:`${O},fields.content,fields.seo`,include:2,order:m,...g(i),...p(l)},{resolveLinks:!1}),c=n.items.at(0);if(!c)throw E();const a=f(n);return{...$(c,a),content:T(c.fields.content,a),seo:z(a.entry(c.fields.seo))}},ie=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=w(e,t),n=await d.client.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(l)},{resolveLinks:!1}),c=f(n);return new h({page:s.page,total:n.total,size:s.size,items:n.items.map(a=>({sys:{id:a.sys.id},name:o(a.fields.name),slot:o(a.fields.slot),order:o(a.fields.order),linksCollection:{items:c.entries(a.fields.links).map(r=>b(r))}}))})},le=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=w(e,t),n=await d.client.getEntries({content_type:"keywordCollection",select:"sys.id,fields.name,fields.slot,fields.keywords",include:0,order:m,...s.params,...g(i),...p(l)},{resolveLinks:!1});return new h({page:s.page,total:n.total,size:s.size,items:n.items.map(c=>({sys:{id:c.sys.id},name:o(c.fields.name),slot:o(c.fields.slot),keywords:o(c.fields.keywords)}))})},oe=async({marketCode:e,locale:t}={})=>{const i=await d.client.getEntries({content_type:"policyAndTerms",select:"sys.id,fields.title,fields.locale,fields.content",include:1,order:m,limit:1,...g(e),...p(t)},{resolveLinks:!1}),l=i.items.at(0);if(!l)throw E();return{sys:{id:l.sys.id},title:o(l.fields.title),locale:o(l.fields.locale),content:T(l.fields.content,f(i))}};exports.ContentfulSDK=d;exports.PaginatedResponse=h;exports.getBannerCollections=G;exports.getBlogCategories=Q;exports.getBlogCategoryDetail=V;exports.getBlogCollections=W;exports.getBlogPostDetail=J;exports.getBlogPosts=Y;exports.getBrandCollections=X;exports.getDocArticleDetail=se;exports.getDocArticles=te;exports.getDocCategories=Z;exports.getDocCategoryDetail=ee;exports.getHyperlinkCollections=ie;exports.getKeywordCollections=le;exports.getPolicyAndTerms=oe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@janbox/headless-cms-sdk"),X=["baseUrl","accessToken","headers","fetch","timeout","retry"];class r{static _config;static _client;static get config(){if(!this._config)throw new Error("Client is not configured");return this._config}static get client(){const t=this.config,i=this._client;if(i&&X.every(s=>i.builtFrom[s]===t[s]))return i.client;const l=_.createClient(t);return this._client={client:l,builtFrom:{...t}},l}static configure(t){this._config=t}}class p{page;total;size;items;totalPages;constructor({page:t,total:i,size:l,items:s}){this.page=t,this.total=i,this.size=l,this.items=s,this.totalPages=Math.ceil(this.total/this.size)}}const m="-sys.updatedAt",u=e=>e?_.or("market",[{"fields.markets[exists]":"false"},{"fields.markets.sys.contentType.sys.id":"market","fields.markets.fields.code":e}]):{},f=e=>e?_.or("locale",[{"fields.locale[exists]":"false"},{"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.")},C=(e,t,i=0)=>{const l=Math.max(1,Math.floor(e)),s=Math.max(1,Math.floor(t)),o=Math.max(0,Math.floor(i));return{page:l,size:s,params:{limit:s,skip:(l-1)*s+o}}},g=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 l=s=>(s&&t.get(s.sys.id))??null;return{entry:l,asset:s=>(s&&i.get(s.sys.id))??null,entries:s=>(s??[]).map(o=>l(o)).filter(o=>o!==null)}},n=e=>e??null,k=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},Z=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 l=i.data?.target?.sys?.id;l&&!t.includes(l)&&t.push(l)}for(const l of i.content??[])R(l,t);return t},L=(e,t)=>{if(!e)return null;const i=R(e,[]).map(l=>t.asset({sys:{type:"Link",linkType:"Asset",id:l}})).filter(l=>l!==null&&!!l.fields.file).map(Z);return{json:e,links:{assets:{block:i}}}},T=e=>e?{metaTitle:n(e.fields.metaTitle),metaDescription:n(e.fields.metaDescription),metaKeywords:n(e.fields.metaKeywords),metaRobots:n(e.fields.metaRobots)}:null,P=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:k(t.asset(e.fields.avatar))}:null,ee=async({slot:e,page:t=1,size:i=20,platform:l,marketCode:s,locale:o})=>{const a=C(t,i),c=await r.client.getEntries({content_type:"bannerCollection","fields.slot":e,"fields.platform":l||void 0,select:"sys.id,fields.name,fields.slot,fields.platform,fields.banners",include:2,order:m,...a.params,...u(s),...f(o)},{resolveLinks:!1}),d=g(c);return new p({page:a.page,total:c.total,size:a.size,items:c.items.map(y=>({sys:{id:y.sys.id},name:n(y.fields.name),slot:n(y.fields.slot),platform:n(y.fields.platform),bannersCollection:{items:d.entries(y.fields.banners).map(w=>({sys:{id:w.sys.id},name:n(w.fields.name),hyperlink:P(d.entry(w.fields.hyperlink)),media:k(d.asset(w.fields.media))}))}}))})},E=()=>new _.CmsError({id:"NotFound",message:"Entry not found",url:`${r.config.baseUrl.trim().replace(/\/+$/,"")}/entries`,status:404}),I="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage",b=(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:k(t.asset(i.fields.featuredImage))}))},featuredImage:k(t.asset(e.fields.featuredImage))}),te=async({marketCode:e,locale:t,collectionId:i,categoryId:l,page:s=1,size:o=20,skip:a=0}={})=>{const c=C(s,o,a);if(i){const H=(await r.client.getEntries({content_type:"blogCollection","sys.id":i,select:"sys.id,fields.posts",include:0,limit:1},{resolveLinks:!1})).items.at(0);if(!H)throw E();const z=(H.fields.posts??[]).filter(h=>h.sys.linkType==="Entry").map(h=>h.sys.id),D=z.slice(c.params.skip,c.params.skip+c.size);if(!D.length)return new p({page:c.page,total:z.length,size:c.size,items:[]});const B=await r.client.getEntries({content_type:"blogPost","sys.id[in]":D.join(","),select:I,include:2,limit:c.size},{resolveLinks:!1}),V=g(B),W=new Map(B.items.map(h=>[h.sys.id,h]));return new p({page:c.page,total:z.length,size:c.size,items:D.map(h=>W.get(h)).filter(h=>h!==void 0).map(h=>b(h,V))})}const d=await r.client.getEntries({content_type:"blogPost","fields.categories.sys.id":l||void 0,select:I,include:2,order:m,...c.params,...u(e),...f(t)},{resolveLinks:!1}),y=g(d);return new p({page:c.page,total:d.total,size:c.size,items:d.items.map(w=>b(w,y))})},se=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),o=await r.client.getEntries({content_type:"blogPost",...s,select:`${I},fields.author,fields.content,fields.seo`,include:2,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=o.items.at(0);if(!a)throw E();const c=g(o);return{...b(a,c),author:S(c.entry(a.fields.author),c),content:L(a.fields.content,c),seo:T(c.entry(a.fields.seo))}},O="sys.id,fields.title,fields.slug,fields.featuredImage",M=(e,t)=>({sys:{id:e.sys.id},title:n(e.fields.title),slug:n(e.fields.slug),featuredImage:k(t.asset(e.fields.featuredImage))}),ie=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),o=await r.client.getEntries({content_type:"blogCategory",select:O,include:1,order:m,...s.params,...u(e),...f(t)},{resolveLinks:!1}),a=g(o);return new p({page:s.page,total:o.total,size:s.size,items:o.items.map(c=>M(c,a))})},le=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),o=await r.client.getEntries({content_type:"blogCategory",...s,select:`${O},fields.description,fields.seo`,include:1,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=o.items.at(0);if(!a)throw E();const c=g(o);return{...M(a,c),description:n(a.fields.description),seo:T(c.entry(a.fields.seo))}},oe=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),o=await r.client.getEntries({content_type:"blogCollection",select:"sys.id,fields.name,fields.type,fields.order,fields.category,fields.featuredImage",include:1,order:m,...s.params,...u(e),...f(t)},{resolveLinks:!1}),a=g(o),c=o.items.map(d=>{const y=a.entry(d.fields.category);return{name:n(d.fields.name),type:n(d.fields.type),order:n(d.fields.order),sys:{id:d.sys.id},category:y?{sys:{id:y.sys.id},title:n(y.fields.title),slug:n(y.fields.slug)}:null,featuredImage:k(a.asset(d.fields.featuredImage))}});return new p({page:s.page,total:o.total,size:s.size,items:c.map(d=>({...d,category:d.type==="category"?d.category:null,categoryId:d.type==="category"?d.category?.sys.id??null:null,collectionId:d.type==="manual"?d.sys.id:null}))})},ne=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),o=await r.client.getEntries({content_type:"brandCollection",select:"sys.id,fields.name,fields.slot,fields.brands",include:2,order:m,...s.params,...u(i),...f(l)},{resolveLinks:!1}),a=g(o);return new p({page:s.page,total:o.total,size:s.size,items:o.items.map(c=>({sys:{id:c.sys.id},name:n(c.fields.name),slot:n(c.fields.slot),brandsCollection:{items:a.entries(c.fields.brands).map(d=>({sys:{id:d.sys.id},name:n(d.fields.name),logo:k(a.asset(d.fields.logo)),hyperlink:P(a.entry(d.fields.hyperlink))}))}}))})},F="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.description,fields.order,fields.seo",x="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.author,fields.category",N=e=>({id:e.sys.id,createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt}),$=(e,t)=>({sys:N(e),title:n(e.fields.title),slug:n(e.fields.slug),description:n(e.fields.description),order:n(e.fields.order),seo:T(t.entry(e.fields.seo))}),K=(e,t)=>{const i=t.entry(e.fields.category);return{sys:N(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}},ae=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),o=await r.client.getEntries({content_type:"documentationCategory",select:F,include:1,order:m,...s.params,...u(e),...f(t)},{resolveLinks:!1}),a=g(o);return new p({page:s.page,total:o.total,size:s.size,items:o.items.map(c=>$(c,a))})},ce=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),o=await r.client.getEntries({content_type:"documentationCategory",...s,select:F,include:1,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=o.items.at(0);if(!a)throw E();return $(a,g(o))},de=async({marketCode:e,locale:t,categorySlug:i,page:l=1,size:s=20}={})=>{const o=C(l,s),a=await r.client.getEntries({content_type:"documentationArticle",...i?{"fields.category.sys.contentType.sys.id":"documentationCategory","fields.category.fields.slug":i}:{},select:x,include:2,order:m,...o.params,...u(e),...f(t)},{resolveLinks:!1}),c=g(a);return new p({page:o.page,total:a.total,size:o.size,items:a.items.map(d=>K(d,c))})},re=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),o=await r.client.getEntries({content_type:"documentationArticle",...s,select:`${x},fields.content,fields.seo`,include:2,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=o.items.at(0);if(!a)throw E();const c=g(o);return{...K(a,c),content:L(a.fields.content,c),seo:T(c.entry(a.fields.seo))}},Y="crispHelpCategory",j="crispHelpArticle",v="fields.position,sys.id",G="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.parent",U="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.featured,fields.category",q=e=>({id:e.sys.id,createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt}),J=e=>({sys:q(e),title:n(e.fields.title),slug:n(e.fields.slug),path:n(e.fields.path),locale:n(e.fields.locale),position:n(e.fields.position),parentId:e.fields.parent?.sys.id??null}),Q=e=>({sys:q(e),title:n(e.fields.title),slug:n(e.fields.slug),path:n(e.fields.path),locale:n(e.fields.locale),position:n(e.fields.position),featured:e.fields.featured===!0,categoryId:e.fields.category?.sys.id??null}),fe=async({locale:e,page:t=1,size:i=20}={})=>{const l=C(t,i),s=await r.client.getEntries({content_type:Y,select:G,include:0,order:v,...l.params,...f(e)},{resolveLinks:!1});return new p({page:l.page,total:s.total,size:l.size,items:s.items.map(J)})},ge=async({id:e,slug:t,locale:i})=>{const l=A({id:e,slug:t}),o=(await r.client.getEntries({content_type:Y,...l,select:G,include:0,order:v,...f(i)},{resolveLinks:!1})).items.at(0);if(!o)throw E();return J(o)},pe=async({locale:e,categoryId:t,featured:i,page:l=1,size:s=20}={})=>{const o=C(l,s),a=await r.client.getEntries({content_type:j,...t?{"fields.category.sys.id":t}:{},...i!==void 0?{"fields.featured":i}:{},select:U,include:0,order:v,...o.params,...f(e)},{resolveLinks:!1});return new p({page:o.page,total:a.total,size:o.size,items:a.items.map(Q)})},ue=async({id:e,slug:t,locale:i})=>{const l=A({id:e,slug:t}),s=await r.client.getEntries({content_type:j,...l,select:`${U},fields.body`,include:1,order:v,...f(i)},{resolveLinks:!1}),o=s.items.at(0);if(!o)throw E();return{...Q(o),body:L(o.fields.body,g(s))}},me=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),o=await r.client.getEntries({content_type:"hyperlinkCollection",select:"sys.id,fields.name,fields.slot,fields.order,fields.links",include:1,order:"fields.order",...s.params,...u(i),...f(l)},{resolveLinks:!1}),a=g(o);return new p({page:s.page,total:o.total,size:s.size,items:o.items.map(c=>({sys:{id:c.sys.id},name:n(c.fields.name),slot:n(c.fields.slot),order:n(c.fields.order),linksCollection:{items:a.entries(c.fields.links).map(d=>P(d))}}))})},ye=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),o=await r.client.getEntries({content_type:"keywordCollection",select:"sys.id,fields.name,fields.slot,fields.keywords",include:0,order:m,...s.params,...u(i),...f(l)},{resolveLinks:!1});return new p({page:s.page,total:o.total,size:s.size,items:o.items.map(a=>({sys:{id:a.sys.id},name:n(a.fields.name),slot:n(a.fields.slot),keywords:n(a.fields.keywords)}))})},he=async({marketCode:e,locale:t}={})=>{const i=await r.client.getEntries({content_type:"policyAndTerms",select:"sys.id,fields.title,fields.locale,fields.content",include:1,order:m,limit:1,...u(e),...f(t)},{resolveLinks:!1}),l=i.items.at(0);if(!l)throw E();return{sys:{id:l.sys.id},title:n(l.fields.title),locale:n(l.fields.locale),content:L(l.fields.content,g(i))}};exports.ContentfulSDK=r;exports.PaginatedResponse=p;exports.getBannerCollections=ee;exports.getBlogCategories=ie;exports.getBlogCategoryDetail=le;exports.getBlogCollections=oe;exports.getBlogPostDetail=se;exports.getBlogPosts=te;exports.getBrandCollections=ne;exports.getDocArticleDetail=re;exports.getDocArticles=de;exports.getDocCategories=ae;exports.getDocCategoryDetail=ce;exports.getHelpArticleDetail=ue;exports.getHelpArticles=pe;exports.getHelpCategories=fe;exports.getHelpCategoryDetail=ge;exports.getHyperlinkCollections=me;exports.getKeywordCollections=ye;exports.getPolicyAndTerms=he;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
const
|
|
1
|
+
import { createClient as X, or as H, CmsError as Z } from "@janbox/headless-cms-sdk";
|
|
2
|
+
const ee = [
|
|
3
3
|
"baseUrl",
|
|
4
4
|
"accessToken",
|
|
5
5
|
"headers",
|
|
@@ -17,16 +17,16 @@ class r {
|
|
|
17
17
|
}
|
|
18
18
|
static get client() {
|
|
19
19
|
const s = this.config, i = this._client;
|
|
20
|
-
if (i &&
|
|
20
|
+
if (i && ee.every((t) => i.builtFrom[t] === s[t]))
|
|
21
21
|
return i.client;
|
|
22
|
-
const l =
|
|
22
|
+
const l = X(s);
|
|
23
23
|
return this._client = { client: l, builtFrom: { ...s } }, l;
|
|
24
24
|
}
|
|
25
25
|
static configure(s) {
|
|
26
26
|
this._config = s;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class u {
|
|
30
30
|
page;
|
|
31
31
|
total;
|
|
32
32
|
size;
|
|
@@ -41,16 +41,16 @@ class h {
|
|
|
41
41
|
this.page = s, this.total = i, this.size = l, this.items = t, this.totalPages = Math.ceil(this.total / this.size);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const m = "-sys.updatedAt",
|
|
44
|
+
const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
45
45
|
{ "fields.markets[exists]": "false" },
|
|
46
46
|
{
|
|
47
47
|
"fields.markets.sys.contentType.sys.id": "market",
|
|
48
48
|
"fields.markets.fields.code": e
|
|
49
49
|
}
|
|
50
|
-
]) : {},
|
|
50
|
+
]) : {}, f = (e) => e ? H("locale", [
|
|
51
51
|
{ "fields.locale[exists]": "false" },
|
|
52
52
|
{ "fields.locale": e }
|
|
53
|
-
]) : {},
|
|
53
|
+
]) : {}, A = ({
|
|
54
54
|
id: e,
|
|
55
55
|
slug: s
|
|
56
56
|
}) => {
|
|
@@ -59,17 +59,17 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
59
59
|
if (s)
|
|
60
60
|
return { "fields.slug": s, limit: 1 };
|
|
61
61
|
throw new Error("Either id or slug is required.");
|
|
62
|
-
},
|
|
63
|
-
const l = Math.max(1, Math.floor(e)), t = Math.max(1, Math.floor(s)),
|
|
62
|
+
}, E = (e, s, i = 0) => {
|
|
63
|
+
const l = Math.max(1, Math.floor(e)), t = Math.max(1, Math.floor(s)), o = Math.max(0, Math.floor(i));
|
|
64
64
|
return {
|
|
65
65
|
page: l,
|
|
66
66
|
size: t,
|
|
67
67
|
params: {
|
|
68
68
|
limit: t,
|
|
69
|
-
skip: (l - 1) * t +
|
|
69
|
+
skip: (l - 1) * t + o
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
},
|
|
72
|
+
}, g = (e) => {
|
|
73
73
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
74
74
|
for (const t of [...e.items, ...e.includes?.Entry ?? []])
|
|
75
75
|
s.set(t.sys.id, t);
|
|
@@ -79,9 +79,9 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
79
79
|
return {
|
|
80
80
|
entry: l,
|
|
81
81
|
asset: (t) => (t && i.get(t.sys.id)) ?? null,
|
|
82
|
-
entries: (t) => (t ?? []).map((
|
|
82
|
+
entries: (t) => (t ?? []).map((o) => l(o)).filter((o) => o !== null)
|
|
83
83
|
};
|
|
84
|
-
},
|
|
84
|
+
}, n = (e) => e ?? null, C = (e) => {
|
|
85
85
|
const s = e?.fields.file;
|
|
86
86
|
return s ? {
|
|
87
87
|
url: s.url,
|
|
@@ -89,15 +89,15 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
89
89
|
height: s.details.image?.height ?? null,
|
|
90
90
|
contentType: s.contentType
|
|
91
91
|
} : null;
|
|
92
|
-
},
|
|
92
|
+
}, se = (e) => ({
|
|
93
93
|
sys: { id: e.sys.id },
|
|
94
94
|
url: e.fields.file?.url,
|
|
95
95
|
width: e.fields.file?.details.image?.width ?? null,
|
|
96
96
|
height: e.fields.file?.details.image?.height ?? null,
|
|
97
97
|
contentType: e.fields.file?.contentType,
|
|
98
|
-
title:
|
|
99
|
-
description:
|
|
100
|
-
}),
|
|
98
|
+
title: n(e.fields.title),
|
|
99
|
+
description: n(e.fields.description)
|
|
100
|
+
}), B = (e, s) => {
|
|
101
101
|
if (!e || typeof e != "object")
|
|
102
102
|
return s;
|
|
103
103
|
const i = e;
|
|
@@ -106,36 +106,36 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
106
106
|
l && !s.includes(l) && s.push(l);
|
|
107
107
|
}
|
|
108
108
|
for (const l of i.content ?? [])
|
|
109
|
-
|
|
109
|
+
B(l, s);
|
|
110
110
|
return s;
|
|
111
|
-
},
|
|
111
|
+
}, _ = (e, s) => {
|
|
112
112
|
if (!e)
|
|
113
113
|
return null;
|
|
114
|
-
const i =
|
|
114
|
+
const i = B(e, []).map((l) => s.asset({ sys: { type: "Link", linkType: "Asset", id: l } })).filter((l) => l !== null && !!l.fields.file).map(se);
|
|
115
115
|
return { json: e, links: { assets: { block: i } } };
|
|
116
|
-
},
|
|
117
|
-
metaTitle:
|
|
118
|
-
metaDescription:
|
|
119
|
-
metaKeywords:
|
|
120
|
-
metaRobots:
|
|
121
|
-
} : null,
|
|
116
|
+
}, L = (e) => e ? {
|
|
117
|
+
metaTitle: n(e.fields.metaTitle),
|
|
118
|
+
metaDescription: n(e.fields.metaDescription),
|
|
119
|
+
metaKeywords: n(e.fields.metaKeywords),
|
|
120
|
+
metaRobots: n(e.fields.metaRobots)
|
|
121
|
+
} : null, D = (e) => e ? {
|
|
122
122
|
sys: { id: e.sys.id },
|
|
123
|
-
label:
|
|
124
|
-
url:
|
|
125
|
-
target:
|
|
126
|
-
marketHandling:
|
|
123
|
+
label: n(e.fields.label),
|
|
124
|
+
url: n(e.fields.url),
|
|
125
|
+
target: n(e.fields.target),
|
|
126
|
+
marketHandling: n(e.fields.marketHandling)
|
|
127
127
|
} : null, S = (e, s) => e ? {
|
|
128
|
-
name:
|
|
129
|
-
avatar:
|
|
130
|
-
} : null,
|
|
128
|
+
name: n(e.fields.name),
|
|
129
|
+
avatar: C(s.asset(e.fields.avatar))
|
|
130
|
+
} : null, ie = async ({
|
|
131
131
|
slot: e,
|
|
132
132
|
page: s = 1,
|
|
133
133
|
size: i = 20,
|
|
134
134
|
platform: l,
|
|
135
135
|
marketCode: t,
|
|
136
|
-
locale:
|
|
136
|
+
locale: o
|
|
137
137
|
}) => {
|
|
138
|
-
const
|
|
138
|
+
const a = E(s, i), c = await r.client.getEntries(
|
|
139
139
|
{
|
|
140
140
|
content_type: "bannerCollection",
|
|
141
141
|
"fields.slot": e,
|
|
@@ -143,70 +143,70 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
143
143
|
select: "sys.id,fields.name,fields.slot,fields.platform,fields.banners",
|
|
144
144
|
include: 2,
|
|
145
145
|
order: m,
|
|
146
|
-
...
|
|
147
|
-
...
|
|
148
|
-
...
|
|
146
|
+
...a.params,
|
|
147
|
+
...p(t),
|
|
148
|
+
...f(o)
|
|
149
149
|
},
|
|
150
150
|
{ resolveLinks: !1 }
|
|
151
|
-
), d =
|
|
152
|
-
return new
|
|
153
|
-
page:
|
|
154
|
-
total:
|
|
155
|
-
size:
|
|
156
|
-
items:
|
|
157
|
-
(
|
|
158
|
-
sys: { id:
|
|
159
|
-
name:
|
|
160
|
-
slot:
|
|
161
|
-
platform:
|
|
151
|
+
), d = g(c);
|
|
152
|
+
return new u({
|
|
153
|
+
page: a.page,
|
|
154
|
+
total: c.total,
|
|
155
|
+
size: a.size,
|
|
156
|
+
items: c.items.map(
|
|
157
|
+
(y) => ({
|
|
158
|
+
sys: { id: y.sys.id },
|
|
159
|
+
name: n(y.fields.name),
|
|
160
|
+
slot: n(y.fields.slot),
|
|
161
|
+
platform: n(y.fields.platform),
|
|
162
162
|
bannersCollection: {
|
|
163
|
-
items: d.entries(
|
|
163
|
+
items: d.entries(y.fields.banners).map((k) => ({
|
|
164
164
|
sys: { id: k.sys.id },
|
|
165
|
-
name:
|
|
166
|
-
hyperlink:
|
|
165
|
+
name: n(k.fields.name),
|
|
166
|
+
hyperlink: D(
|
|
167
167
|
d.entry(k.fields.hyperlink)
|
|
168
168
|
),
|
|
169
|
-
media:
|
|
169
|
+
media: C(d.asset(k.fields.media))
|
|
170
170
|
}))
|
|
171
171
|
}
|
|
172
172
|
})
|
|
173
173
|
)
|
|
174
174
|
});
|
|
175
|
-
},
|
|
175
|
+
}, w = () => new Z({
|
|
176
176
|
id: "NotFound",
|
|
177
177
|
message: "Entry not found",
|
|
178
178
|
url: `${r.config.baseUrl.trim().replace(/\/+$/, "")}/entries`,
|
|
179
179
|
status: 404
|
|
180
|
-
}), I = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage",
|
|
180
|
+
}), I = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage", b = (e, s) => ({
|
|
181
181
|
sys: {
|
|
182
182
|
id: e.sys.id,
|
|
183
183
|
createdAt: e.sys.createdAt,
|
|
184
184
|
updatedAt: e.sys.updatedAt
|
|
185
185
|
},
|
|
186
|
-
title:
|
|
187
|
-
shortDescription:
|
|
188
|
-
slug:
|
|
186
|
+
title: n(e.fields.title),
|
|
187
|
+
shortDescription: n(e.fields.shortDescription),
|
|
188
|
+
slug: n(e.fields.slug),
|
|
189
189
|
categoriesCollection: {
|
|
190
190
|
items: s.entries(e.fields.categories).map((i) => ({
|
|
191
191
|
sys: { id: i.sys.id },
|
|
192
|
-
title:
|
|
193
|
-
slug:
|
|
194
|
-
featuredImage:
|
|
192
|
+
title: n(i.fields.title),
|
|
193
|
+
slug: n(i.fields.slug),
|
|
194
|
+
featuredImage: C(s.asset(i.fields.featuredImage))
|
|
195
195
|
}))
|
|
196
196
|
},
|
|
197
|
-
featuredImage:
|
|
198
|
-
}),
|
|
197
|
+
featuredImage: C(s.asset(e.fields.featuredImage))
|
|
198
|
+
}), le = async ({
|
|
199
199
|
marketCode: e,
|
|
200
200
|
locale: s,
|
|
201
201
|
collectionId: i,
|
|
202
202
|
categoryId: l,
|
|
203
203
|
page: t = 1,
|
|
204
|
-
size:
|
|
205
|
-
skip:
|
|
204
|
+
size: o = 20,
|
|
205
|
+
skip: a = 0
|
|
206
206
|
} = {}) => {
|
|
207
|
-
const
|
|
207
|
+
const c = E(t, o, a);
|
|
208
208
|
if (i) {
|
|
209
|
-
const
|
|
209
|
+
const P = (await r.client.getEntries(
|
|
210
210
|
{
|
|
211
211
|
content_type: "blogCollection",
|
|
212
212
|
"sys.id": i,
|
|
@@ -216,31 +216,31 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
216
216
|
},
|
|
217
217
|
{ resolveLinks: !1 }
|
|
218
218
|
)).items.at(0);
|
|
219
|
-
if (!
|
|
220
|
-
throw
|
|
221
|
-
const v = (
|
|
222
|
-
if (!
|
|
223
|
-
return new
|
|
224
|
-
page:
|
|
219
|
+
if (!P)
|
|
220
|
+
throw w();
|
|
221
|
+
const v = (P.fields.posts ?? []).filter((h) => h.sys.linkType === "Entry").map((h) => h.sys.id), z = v.slice(c.params.skip, c.params.skip + c.size);
|
|
222
|
+
if (!z.length)
|
|
223
|
+
return new u({
|
|
224
|
+
page: c.page,
|
|
225
225
|
total: v.length,
|
|
226
|
-
size:
|
|
226
|
+
size: c.size,
|
|
227
227
|
items: []
|
|
228
228
|
});
|
|
229
|
-
const
|
|
229
|
+
const R = await r.client.getEntries(
|
|
230
230
|
{
|
|
231
231
|
content_type: "blogPost",
|
|
232
|
-
"sys.id[in]":
|
|
232
|
+
"sys.id[in]": z.join(","),
|
|
233
233
|
select: I,
|
|
234
234
|
include: 2,
|
|
235
|
-
limit:
|
|
235
|
+
limit: c.size
|
|
236
236
|
},
|
|
237
237
|
{ resolveLinks: !1 }
|
|
238
|
-
),
|
|
239
|
-
return new
|
|
240
|
-
page:
|
|
238
|
+
), V = g(R), W = new Map(R.items.map((h) => [h.sys.id, h]));
|
|
239
|
+
return new u({
|
|
240
|
+
page: c.page,
|
|
241
241
|
total: v.length,
|
|
242
|
-
size:
|
|
243
|
-
items:
|
|
242
|
+
size: c.size,
|
|
243
|
+
items: z.map((h) => W.get(h)).filter((h) => h !== void 0).map((h) => b(h, V))
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
const d = await r.client.getEntries(
|
|
@@ -250,374 +250,484 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
250
250
|
select: I,
|
|
251
251
|
include: 2,
|
|
252
252
|
order: m,
|
|
253
|
-
...
|
|
254
|
-
...
|
|
255
|
-
...
|
|
253
|
+
...c.params,
|
|
254
|
+
...p(e),
|
|
255
|
+
...f(s)
|
|
256
256
|
},
|
|
257
257
|
{ resolveLinks: !1 }
|
|
258
|
-
),
|
|
259
|
-
return new
|
|
260
|
-
page:
|
|
258
|
+
), y = g(d);
|
|
259
|
+
return new u({
|
|
260
|
+
page: c.page,
|
|
261
261
|
total: d.total,
|
|
262
|
-
size:
|
|
263
|
-
items: d.items.map((k) =>
|
|
262
|
+
size: c.size,
|
|
263
|
+
items: d.items.map((k) => b(k, y))
|
|
264
264
|
});
|
|
265
|
-
},
|
|
265
|
+
}, oe = async ({
|
|
266
266
|
id: e,
|
|
267
267
|
slug: s,
|
|
268
268
|
marketCode: i,
|
|
269
269
|
locale: l
|
|
270
270
|
}) => {
|
|
271
|
-
const t =
|
|
271
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
272
272
|
{
|
|
273
273
|
content_type: "blogPost",
|
|
274
274
|
...t,
|
|
275
275
|
select: `${I},fields.author,fields.content,fields.seo`,
|
|
276
276
|
include: 2,
|
|
277
277
|
order: m,
|
|
278
|
-
...
|
|
279
|
-
...
|
|
278
|
+
...p(i),
|
|
279
|
+
...f(l)
|
|
280
280
|
},
|
|
281
281
|
{ resolveLinks: !1 }
|
|
282
|
-
),
|
|
283
|
-
if (!
|
|
284
|
-
throw
|
|
285
|
-
const
|
|
282
|
+
), a = o.items.at(0);
|
|
283
|
+
if (!a)
|
|
284
|
+
throw w();
|
|
285
|
+
const c = g(o);
|
|
286
286
|
return {
|
|
287
|
-
...
|
|
288
|
-
author: S(
|
|
289
|
-
content:
|
|
290
|
-
seo:
|
|
287
|
+
...b(a, c),
|
|
288
|
+
author: S(c.entry(a.fields.author), c),
|
|
289
|
+
content: _(a.fields.content, c),
|
|
290
|
+
seo: L(c.entry(a.fields.seo))
|
|
291
291
|
};
|
|
292
|
-
},
|
|
292
|
+
}, O = "sys.id,fields.title,fields.slug,fields.featuredImage", M = (e, s) => ({
|
|
293
293
|
sys: { id: e.sys.id },
|
|
294
|
-
title:
|
|
295
|
-
slug:
|
|
296
|
-
featuredImage:
|
|
297
|
-
}),
|
|
294
|
+
title: n(e.fields.title),
|
|
295
|
+
slug: n(e.fields.slug),
|
|
296
|
+
featuredImage: C(s.asset(e.fields.featuredImage))
|
|
297
|
+
}), ne = async ({
|
|
298
298
|
marketCode: e,
|
|
299
299
|
locale: s,
|
|
300
300
|
page: i = 1,
|
|
301
301
|
size: l = 20
|
|
302
302
|
} = {}) => {
|
|
303
|
-
const t =
|
|
303
|
+
const t = E(i, l), o = await r.client.getEntries(
|
|
304
304
|
{
|
|
305
305
|
content_type: "blogCategory",
|
|
306
|
-
select:
|
|
306
|
+
select: O,
|
|
307
307
|
include: 1,
|
|
308
308
|
order: m,
|
|
309
309
|
...t.params,
|
|
310
|
-
...
|
|
311
|
-
...
|
|
310
|
+
...p(e),
|
|
311
|
+
...f(s)
|
|
312
312
|
},
|
|
313
313
|
{ resolveLinks: !1 }
|
|
314
|
-
),
|
|
315
|
-
return new
|
|
314
|
+
), a = g(o);
|
|
315
|
+
return new u({
|
|
316
316
|
page: t.page,
|
|
317
|
-
total:
|
|
317
|
+
total: o.total,
|
|
318
318
|
size: t.size,
|
|
319
|
-
items:
|
|
319
|
+
items: o.items.map((c) => M(c, a))
|
|
320
320
|
});
|
|
321
|
-
},
|
|
321
|
+
}, ae = async ({
|
|
322
322
|
id: e,
|
|
323
323
|
slug: s,
|
|
324
324
|
marketCode: i,
|
|
325
325
|
locale: l
|
|
326
326
|
}) => {
|
|
327
|
-
const t =
|
|
327
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
328
328
|
{
|
|
329
329
|
content_type: "blogCategory",
|
|
330
330
|
...t,
|
|
331
|
-
select: `${
|
|
331
|
+
select: `${O},fields.description,fields.seo`,
|
|
332
332
|
include: 1,
|
|
333
333
|
order: m,
|
|
334
|
-
...
|
|
335
|
-
...
|
|
334
|
+
...p(i),
|
|
335
|
+
...f(l)
|
|
336
336
|
},
|
|
337
337
|
{ resolveLinks: !1 }
|
|
338
|
-
),
|
|
339
|
-
if (!
|
|
340
|
-
throw
|
|
341
|
-
const
|
|
338
|
+
), a = o.items.at(0);
|
|
339
|
+
if (!a)
|
|
340
|
+
throw w();
|
|
341
|
+
const c = g(o);
|
|
342
342
|
return {
|
|
343
|
-
...
|
|
344
|
-
description:
|
|
345
|
-
seo:
|
|
343
|
+
...M(a, c),
|
|
344
|
+
description: n(a.fields.description),
|
|
345
|
+
seo: L(c.entry(a.fields.seo))
|
|
346
346
|
};
|
|
347
|
-
},
|
|
347
|
+
}, ce = async ({
|
|
348
348
|
marketCode: e,
|
|
349
349
|
locale: s,
|
|
350
350
|
page: i = 1,
|
|
351
351
|
size: l = 20
|
|
352
352
|
} = {}) => {
|
|
353
|
-
const t =
|
|
353
|
+
const t = E(i, l), o = await r.client.getEntries(
|
|
354
354
|
{
|
|
355
355
|
content_type: "blogCollection",
|
|
356
356
|
select: "sys.id,fields.name,fields.type,fields.order,fields.category,fields.featuredImage",
|
|
357
357
|
include: 1,
|
|
358
358
|
order: m,
|
|
359
359
|
...t.params,
|
|
360
|
-
...
|
|
361
|
-
...
|
|
360
|
+
...p(e),
|
|
361
|
+
...f(s)
|
|
362
362
|
},
|
|
363
363
|
{ resolveLinks: !1 }
|
|
364
|
-
),
|
|
365
|
-
const
|
|
364
|
+
), a = g(o), c = o.items.map((d) => {
|
|
365
|
+
const y = a.entry(d.fields.category);
|
|
366
366
|
return {
|
|
367
|
-
name:
|
|
368
|
-
type:
|
|
369
|
-
order:
|
|
367
|
+
name: n(d.fields.name),
|
|
368
|
+
type: n(d.fields.type),
|
|
369
|
+
order: n(d.fields.order),
|
|
370
370
|
sys: { id: d.sys.id },
|
|
371
|
-
category:
|
|
372
|
-
sys: { id:
|
|
373
|
-
title:
|
|
374
|
-
slug:
|
|
371
|
+
category: y ? {
|
|
372
|
+
sys: { id: y.sys.id },
|
|
373
|
+
title: n(y.fields.title),
|
|
374
|
+
slug: n(y.fields.slug)
|
|
375
375
|
} : null,
|
|
376
|
-
featuredImage:
|
|
376
|
+
featuredImage: C(a.asset(d.fields.featuredImage))
|
|
377
377
|
};
|
|
378
378
|
});
|
|
379
|
-
return new
|
|
379
|
+
return new u({
|
|
380
380
|
page: t.page,
|
|
381
|
-
total:
|
|
381
|
+
total: o.total,
|
|
382
382
|
size: t.size,
|
|
383
|
-
items:
|
|
383
|
+
items: c.map((d) => ({
|
|
384
384
|
...d,
|
|
385
385
|
category: d.type === "category" ? d.category : null,
|
|
386
386
|
categoryId: d.type === "category" ? d.category?.sys.id ?? null : null,
|
|
387
387
|
collectionId: d.type === "manual" ? d.sys.id : null
|
|
388
388
|
}))
|
|
389
389
|
});
|
|
390
|
-
},
|
|
390
|
+
}, de = async ({
|
|
391
391
|
page: e = 1,
|
|
392
392
|
size: s = 20,
|
|
393
393
|
marketCode: i,
|
|
394
394
|
locale: l
|
|
395
395
|
} = {}) => {
|
|
396
|
-
const t =
|
|
396
|
+
const t = E(e, s), o = await r.client.getEntries(
|
|
397
397
|
{
|
|
398
398
|
content_type: "brandCollection",
|
|
399
399
|
select: "sys.id,fields.name,fields.slot,fields.brands",
|
|
400
400
|
include: 2,
|
|
401
401
|
order: m,
|
|
402
402
|
...t.params,
|
|
403
|
-
...
|
|
404
|
-
...
|
|
403
|
+
...p(i),
|
|
404
|
+
...f(l)
|
|
405
405
|
},
|
|
406
406
|
{ resolveLinks: !1 }
|
|
407
|
-
),
|
|
408
|
-
return new
|
|
407
|
+
), a = g(o);
|
|
408
|
+
return new u({
|
|
409
409
|
page: t.page,
|
|
410
|
-
total:
|
|
410
|
+
total: o.total,
|
|
411
411
|
size: t.size,
|
|
412
|
-
items:
|
|
413
|
-
(
|
|
414
|
-
sys: { id:
|
|
415
|
-
name:
|
|
416
|
-
slot:
|
|
412
|
+
items: o.items.map(
|
|
413
|
+
(c) => ({
|
|
414
|
+
sys: { id: c.sys.id },
|
|
415
|
+
name: n(c.fields.name),
|
|
416
|
+
slot: n(c.fields.slot),
|
|
417
417
|
brandsCollection: {
|
|
418
|
-
items:
|
|
418
|
+
items: a.entries(c.fields.brands).map((d) => ({
|
|
419
419
|
sys: { id: d.sys.id },
|
|
420
|
-
name:
|
|
421
|
-
logo:
|
|
422
|
-
hyperlink:
|
|
423
|
-
|
|
420
|
+
name: n(d.fields.name),
|
|
421
|
+
logo: C(a.asset(d.fields.logo)),
|
|
422
|
+
hyperlink: D(
|
|
423
|
+
a.entry(d.fields.hyperlink)
|
|
424
424
|
)
|
|
425
425
|
}))
|
|
426
426
|
}
|
|
427
427
|
})
|
|
428
428
|
)
|
|
429
429
|
});
|
|
430
|
-
},
|
|
430
|
+
}, x = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.description,fields.order,fields.seo", F = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.author,fields.category", N = (e) => ({
|
|
431
431
|
id: e.sys.id,
|
|
432
432
|
createdAt: e.sys.createdAt,
|
|
433
433
|
updatedAt: e.sys.updatedAt
|
|
434
|
-
}),
|
|
435
|
-
sys:
|
|
436
|
-
title:
|
|
437
|
-
slug:
|
|
438
|
-
description:
|
|
439
|
-
order:
|
|
440
|
-
seo:
|
|
441
|
-
}),
|
|
434
|
+
}), $ = (e, s) => ({
|
|
435
|
+
sys: N(e),
|
|
436
|
+
title: n(e.fields.title),
|
|
437
|
+
slug: n(e.fields.slug),
|
|
438
|
+
description: n(e.fields.description),
|
|
439
|
+
order: n(e.fields.order),
|
|
440
|
+
seo: L(s.entry(e.fields.seo))
|
|
441
|
+
}), Y = (e, s) => {
|
|
442
442
|
const i = s.entry(e.fields.category);
|
|
443
443
|
return {
|
|
444
|
-
sys:
|
|
445
|
-
title:
|
|
446
|
-
slug:
|
|
444
|
+
sys: N(e),
|
|
445
|
+
title: n(e.fields.title),
|
|
446
|
+
slug: n(e.fields.slug),
|
|
447
447
|
author: S(s.entry(e.fields.author), s),
|
|
448
448
|
category: i ? {
|
|
449
|
-
title:
|
|
450
|
-
slug:
|
|
451
|
-
description:
|
|
452
|
-
order:
|
|
449
|
+
title: n(i.fields.title),
|
|
450
|
+
slug: n(i.fields.slug),
|
|
451
|
+
description: n(i.fields.description),
|
|
452
|
+
order: n(i.fields.order)
|
|
453
453
|
} : null
|
|
454
454
|
};
|
|
455
|
-
},
|
|
455
|
+
}, re = async ({
|
|
456
456
|
marketCode: e,
|
|
457
457
|
locale: s,
|
|
458
458
|
page: i = 1,
|
|
459
459
|
size: l = 20
|
|
460
460
|
} = {}) => {
|
|
461
|
-
const t =
|
|
461
|
+
const t = E(i, l), o = await r.client.getEntries(
|
|
462
462
|
{
|
|
463
463
|
content_type: "documentationCategory",
|
|
464
|
-
select:
|
|
464
|
+
select: x,
|
|
465
465
|
include: 1,
|
|
466
466
|
order: m,
|
|
467
467
|
...t.params,
|
|
468
|
-
...
|
|
469
|
-
...
|
|
468
|
+
...p(e),
|
|
469
|
+
...f(s)
|
|
470
470
|
},
|
|
471
471
|
{ resolveLinks: !1 }
|
|
472
|
-
),
|
|
473
|
-
return new
|
|
472
|
+
), a = g(o);
|
|
473
|
+
return new u({
|
|
474
474
|
page: t.page,
|
|
475
|
-
total:
|
|
475
|
+
total: o.total,
|
|
476
476
|
size: t.size,
|
|
477
|
-
items:
|
|
477
|
+
items: o.items.map((c) => $(c, a))
|
|
478
478
|
});
|
|
479
|
-
},
|
|
479
|
+
}, fe = async ({
|
|
480
480
|
id: e,
|
|
481
481
|
slug: s,
|
|
482
482
|
marketCode: i,
|
|
483
483
|
locale: l
|
|
484
484
|
}) => {
|
|
485
|
-
const t =
|
|
485
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
486
486
|
{
|
|
487
487
|
content_type: "documentationCategory",
|
|
488
488
|
...t,
|
|
489
|
-
select:
|
|
489
|
+
select: x,
|
|
490
490
|
include: 1,
|
|
491
491
|
order: m,
|
|
492
|
-
...
|
|
493
|
-
...
|
|
492
|
+
...p(i),
|
|
493
|
+
...f(l)
|
|
494
494
|
},
|
|
495
495
|
{ resolveLinks: !1 }
|
|
496
|
-
),
|
|
497
|
-
if (!
|
|
498
|
-
throw
|
|
499
|
-
return
|
|
500
|
-
},
|
|
496
|
+
), a = o.items.at(0);
|
|
497
|
+
if (!a)
|
|
498
|
+
throw w();
|
|
499
|
+
return $(a, g(o));
|
|
500
|
+
}, ge = async ({
|
|
501
501
|
marketCode: e,
|
|
502
502
|
locale: s,
|
|
503
503
|
categorySlug: i,
|
|
504
504
|
page: l = 1,
|
|
505
505
|
size: t = 20
|
|
506
506
|
} = {}) => {
|
|
507
|
-
const
|
|
507
|
+
const o = E(l, t), a = await r.client.getEntries(
|
|
508
508
|
{
|
|
509
509
|
content_type: "documentationArticle",
|
|
510
510
|
...i ? {
|
|
511
511
|
"fields.category.sys.contentType.sys.id": "documentationCategory",
|
|
512
512
|
"fields.category.fields.slug": i
|
|
513
513
|
} : {},
|
|
514
|
-
select:
|
|
514
|
+
select: F,
|
|
515
515
|
include: 2,
|
|
516
516
|
order: m,
|
|
517
|
-
...
|
|
518
|
-
...
|
|
519
|
-
...
|
|
517
|
+
...o.params,
|
|
518
|
+
...p(e),
|
|
519
|
+
...f(s)
|
|
520
520
|
},
|
|
521
521
|
{ resolveLinks: !1 }
|
|
522
|
-
),
|
|
523
|
-
return new
|
|
524
|
-
page:
|
|
525
|
-
total:
|
|
526
|
-
size:
|
|
527
|
-
items:
|
|
522
|
+
), c = g(a);
|
|
523
|
+
return new u({
|
|
524
|
+
page: o.page,
|
|
525
|
+
total: a.total,
|
|
526
|
+
size: o.size,
|
|
527
|
+
items: a.items.map((d) => Y(d, c))
|
|
528
528
|
});
|
|
529
|
-
},
|
|
529
|
+
}, pe = async ({
|
|
530
530
|
id: e,
|
|
531
531
|
slug: s,
|
|
532
532
|
marketCode: i,
|
|
533
533
|
locale: l
|
|
534
534
|
}) => {
|
|
535
|
-
const t =
|
|
535
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
536
536
|
{
|
|
537
537
|
content_type: "documentationArticle",
|
|
538
538
|
...t,
|
|
539
|
-
select: `${
|
|
539
|
+
select: `${F},fields.content,fields.seo`,
|
|
540
540
|
include: 2,
|
|
541
541
|
order: m,
|
|
542
|
-
...
|
|
543
|
-
...
|
|
542
|
+
...p(i),
|
|
543
|
+
...f(l)
|
|
544
|
+
},
|
|
545
|
+
{ resolveLinks: !1 }
|
|
546
|
+
), a = o.items.at(0);
|
|
547
|
+
if (!a)
|
|
548
|
+
throw w();
|
|
549
|
+
const c = g(o);
|
|
550
|
+
return {
|
|
551
|
+
...Y(a, c),
|
|
552
|
+
content: _(a.fields.content, c),
|
|
553
|
+
seo: L(c.entry(a.fields.seo))
|
|
554
|
+
};
|
|
555
|
+
}, G = "crispHelpCategory", K = "crispHelpArticle", T = "fields.position,sys.id", j = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.parent", U = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.featured,fields.category", q = (e) => ({
|
|
556
|
+
id: e.sys.id,
|
|
557
|
+
createdAt: e.sys.createdAt,
|
|
558
|
+
updatedAt: e.sys.updatedAt
|
|
559
|
+
}), J = (e) => ({
|
|
560
|
+
sys: q(e),
|
|
561
|
+
title: n(e.fields.title),
|
|
562
|
+
slug: n(e.fields.slug),
|
|
563
|
+
path: n(e.fields.path),
|
|
564
|
+
locale: n(e.fields.locale),
|
|
565
|
+
position: n(e.fields.position),
|
|
566
|
+
parentId: e.fields.parent?.sys.id ?? null
|
|
567
|
+
}), Q = (e) => ({
|
|
568
|
+
sys: q(e),
|
|
569
|
+
title: n(e.fields.title),
|
|
570
|
+
slug: n(e.fields.slug),
|
|
571
|
+
path: n(e.fields.path),
|
|
572
|
+
locale: n(e.fields.locale),
|
|
573
|
+
position: n(e.fields.position),
|
|
574
|
+
featured: e.fields.featured === !0,
|
|
575
|
+
categoryId: e.fields.category?.sys.id ?? null
|
|
576
|
+
}), ue = async ({
|
|
577
|
+
locale: e,
|
|
578
|
+
page: s = 1,
|
|
579
|
+
size: i = 20
|
|
580
|
+
} = {}) => {
|
|
581
|
+
const l = E(s, i), t = await r.client.getEntries(
|
|
582
|
+
{
|
|
583
|
+
content_type: G,
|
|
584
|
+
select: j,
|
|
585
|
+
include: 0,
|
|
586
|
+
order: T,
|
|
587
|
+
...l.params,
|
|
588
|
+
...f(e)
|
|
589
|
+
},
|
|
590
|
+
{ resolveLinks: !1 }
|
|
591
|
+
);
|
|
592
|
+
return new u({
|
|
593
|
+
page: l.page,
|
|
594
|
+
total: t.total,
|
|
595
|
+
size: l.size,
|
|
596
|
+
items: t.items.map(J)
|
|
597
|
+
});
|
|
598
|
+
}, me = async ({
|
|
599
|
+
id: e,
|
|
600
|
+
slug: s,
|
|
601
|
+
locale: i
|
|
602
|
+
}) => {
|
|
603
|
+
const l = A({ id: e, slug: s }), o = (await r.client.getEntries(
|
|
604
|
+
{
|
|
605
|
+
content_type: G,
|
|
606
|
+
...l,
|
|
607
|
+
select: j,
|
|
608
|
+
include: 0,
|
|
609
|
+
order: T,
|
|
610
|
+
...f(i)
|
|
611
|
+
},
|
|
612
|
+
{ resolveLinks: !1 }
|
|
613
|
+
)).items.at(0);
|
|
614
|
+
if (!o)
|
|
615
|
+
throw w();
|
|
616
|
+
return J(o);
|
|
617
|
+
}, ye = async ({
|
|
618
|
+
locale: e,
|
|
619
|
+
categoryId: s,
|
|
620
|
+
featured: i,
|
|
621
|
+
page: l = 1,
|
|
622
|
+
size: t = 20
|
|
623
|
+
} = {}) => {
|
|
624
|
+
const o = E(l, t), a = await r.client.getEntries(
|
|
625
|
+
{
|
|
626
|
+
content_type: K,
|
|
627
|
+
...s ? { "fields.category.sys.id": s } : {},
|
|
628
|
+
...i !== void 0 ? { "fields.featured": i } : {},
|
|
629
|
+
select: U,
|
|
630
|
+
include: 0,
|
|
631
|
+
order: T,
|
|
632
|
+
...o.params,
|
|
633
|
+
...f(e)
|
|
634
|
+
},
|
|
635
|
+
{ resolveLinks: !1 }
|
|
636
|
+
);
|
|
637
|
+
return new u({
|
|
638
|
+
page: o.page,
|
|
639
|
+
total: a.total,
|
|
640
|
+
size: o.size,
|
|
641
|
+
items: a.items.map(Q)
|
|
642
|
+
});
|
|
643
|
+
}, he = async ({
|
|
644
|
+
id: e,
|
|
645
|
+
slug: s,
|
|
646
|
+
locale: i
|
|
647
|
+
}) => {
|
|
648
|
+
const l = A({ id: e, slug: s }), t = await r.client.getEntries(
|
|
649
|
+
{
|
|
650
|
+
content_type: K,
|
|
651
|
+
...l,
|
|
652
|
+
select: `${U},fields.body`,
|
|
653
|
+
include: 1,
|
|
654
|
+
order: T,
|
|
655
|
+
...f(i)
|
|
544
656
|
},
|
|
545
657
|
{ resolveLinks: !1 }
|
|
546
|
-
),
|
|
547
|
-
if (!
|
|
548
|
-
throw
|
|
549
|
-
const a = f(n);
|
|
658
|
+
), o = t.items.at(0);
|
|
659
|
+
if (!o)
|
|
660
|
+
throw w();
|
|
550
661
|
return {
|
|
551
|
-
...
|
|
552
|
-
|
|
553
|
-
seo: _(a.entry(c.fields.seo))
|
|
662
|
+
...Q(o),
|
|
663
|
+
body: _(o.fields.body, g(t))
|
|
554
664
|
};
|
|
555
|
-
},
|
|
665
|
+
}, Ee = async ({
|
|
556
666
|
page: e = 1,
|
|
557
667
|
size: s = 20,
|
|
558
668
|
marketCode: i,
|
|
559
669
|
locale: l
|
|
560
670
|
} = {}) => {
|
|
561
|
-
const t =
|
|
671
|
+
const t = E(e, s), o = await r.client.getEntries(
|
|
562
672
|
{
|
|
563
673
|
content_type: "hyperlinkCollection",
|
|
564
674
|
select: "sys.id,fields.name,fields.slot,fields.order,fields.links",
|
|
565
675
|
include: 1,
|
|
566
676
|
order: "fields.order",
|
|
567
677
|
...t.params,
|
|
568
|
-
...
|
|
569
|
-
...
|
|
678
|
+
...p(i),
|
|
679
|
+
...f(l)
|
|
570
680
|
},
|
|
571
681
|
{ resolveLinks: !1 }
|
|
572
|
-
),
|
|
573
|
-
return new
|
|
682
|
+
), a = g(o);
|
|
683
|
+
return new u({
|
|
574
684
|
page: t.page,
|
|
575
|
-
total:
|
|
685
|
+
total: o.total,
|
|
576
686
|
size: t.size,
|
|
577
|
-
items:
|
|
578
|
-
(
|
|
579
|
-
sys: { id:
|
|
580
|
-
name:
|
|
581
|
-
slot:
|
|
582
|
-
order:
|
|
687
|
+
items: o.items.map(
|
|
688
|
+
(c) => ({
|
|
689
|
+
sys: { id: c.sys.id },
|
|
690
|
+
name: n(c.fields.name),
|
|
691
|
+
slot: n(c.fields.slot),
|
|
692
|
+
order: n(c.fields.order),
|
|
583
693
|
linksCollection: {
|
|
584
|
-
items:
|
|
694
|
+
items: a.entries(c.fields.links).map((d) => D(d))
|
|
585
695
|
}
|
|
586
696
|
})
|
|
587
697
|
)
|
|
588
698
|
});
|
|
589
|
-
},
|
|
699
|
+
}, we = async ({
|
|
590
700
|
page: e = 1,
|
|
591
701
|
size: s = 20,
|
|
592
702
|
marketCode: i,
|
|
593
703
|
locale: l
|
|
594
704
|
} = {}) => {
|
|
595
|
-
const t =
|
|
705
|
+
const t = E(e, s), o = await r.client.getEntries(
|
|
596
706
|
{
|
|
597
707
|
content_type: "keywordCollection",
|
|
598
708
|
select: "sys.id,fields.name,fields.slot,fields.keywords",
|
|
599
709
|
include: 0,
|
|
600
710
|
order: m,
|
|
601
711
|
...t.params,
|
|
602
|
-
...
|
|
603
|
-
...
|
|
712
|
+
...p(i),
|
|
713
|
+
...f(l)
|
|
604
714
|
},
|
|
605
715
|
{ resolveLinks: !1 }
|
|
606
716
|
);
|
|
607
|
-
return new
|
|
717
|
+
return new u({
|
|
608
718
|
page: t.page,
|
|
609
|
-
total:
|
|
719
|
+
total: o.total,
|
|
610
720
|
size: t.size,
|
|
611
|
-
items:
|
|
612
|
-
(
|
|
613
|
-
sys: { id:
|
|
614
|
-
name:
|
|
615
|
-
slot:
|
|
616
|
-
keywords:
|
|
721
|
+
items: o.items.map(
|
|
722
|
+
(a) => ({
|
|
723
|
+
sys: { id: a.sys.id },
|
|
724
|
+
name: n(a.fields.name),
|
|
725
|
+
slot: n(a.fields.slot),
|
|
726
|
+
keywords: n(a.fields.keywords)
|
|
617
727
|
})
|
|
618
728
|
)
|
|
619
729
|
});
|
|
620
|
-
},
|
|
730
|
+
}, ke = async ({
|
|
621
731
|
marketCode: e,
|
|
622
732
|
locale: s
|
|
623
733
|
} = {}) => {
|
|
@@ -628,35 +738,39 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
628
738
|
include: 1,
|
|
629
739
|
order: m,
|
|
630
740
|
limit: 1,
|
|
631
|
-
...
|
|
632
|
-
...
|
|
741
|
+
...p(e),
|
|
742
|
+
...f(s)
|
|
633
743
|
},
|
|
634
744
|
{ resolveLinks: !1 }
|
|
635
745
|
), l = i.items.at(0);
|
|
636
746
|
if (!l)
|
|
637
|
-
throw
|
|
747
|
+
throw w();
|
|
638
748
|
return {
|
|
639
749
|
sys: { id: l.sys.id },
|
|
640
|
-
title:
|
|
641
|
-
locale:
|
|
642
|
-
content:
|
|
750
|
+
title: n(l.fields.title),
|
|
751
|
+
locale: n(l.fields.locale),
|
|
752
|
+
content: _(l.fields.content, g(i))
|
|
643
753
|
};
|
|
644
754
|
};
|
|
645
755
|
export {
|
|
646
756
|
r as ContentfulSDK,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
757
|
+
u as PaginatedResponse,
|
|
758
|
+
ie as getBannerCollections,
|
|
759
|
+
ne as getBlogCategories,
|
|
760
|
+
ae as getBlogCategoryDetail,
|
|
761
|
+
ce as getBlogCollections,
|
|
762
|
+
oe as getBlogPostDetail,
|
|
763
|
+
le as getBlogPosts,
|
|
764
|
+
de as getBrandCollections,
|
|
765
|
+
pe as getDocArticleDetail,
|
|
766
|
+
ge as getDocArticles,
|
|
767
|
+
re as getDocCategories,
|
|
768
|
+
fe as getDocCategoryDetail,
|
|
769
|
+
he as getHelpArticleDetail,
|
|
770
|
+
ye as getHelpArticles,
|
|
771
|
+
ue as getHelpCategories,
|
|
772
|
+
me as getHelpCategoryDetail,
|
|
773
|
+
Ee as getHyperlinkCollections,
|
|
774
|
+
we as getKeywordCollections,
|
|
775
|
+
ke as getPolicyAndTerms
|
|
662
776
|
};
|
|
@@ -82,6 +82,24 @@ export interface TypeDocumentationCategoryFields {
|
|
|
82
82
|
seo?: Link<"Entry">;
|
|
83
83
|
markets?: Link<"Entry">[];
|
|
84
84
|
}
|
|
85
|
+
export interface TypeHelpArticleFields {
|
|
86
|
+
title: string;
|
|
87
|
+
slug: string;
|
|
88
|
+
path: string;
|
|
89
|
+
locale?: string;
|
|
90
|
+
position?: number;
|
|
91
|
+
featured?: boolean;
|
|
92
|
+
category?: Link<"Entry">;
|
|
93
|
+
body?: Document;
|
|
94
|
+
}
|
|
95
|
+
export interface TypeHelpCategoryFields {
|
|
96
|
+
title: string;
|
|
97
|
+
slug: string;
|
|
98
|
+
path: string;
|
|
99
|
+
locale?: string;
|
|
100
|
+
position?: number;
|
|
101
|
+
parent?: Link<"Entry">;
|
|
102
|
+
}
|
|
85
103
|
export interface TypeHyperlinkFields {
|
|
86
104
|
label: string;
|
|
87
105
|
url: string;
|
package/dist/utils/index.d.ts
CHANGED