@janbox/contentful-marketplace-sdk 4.0.0-alpha.1 → 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 +9 -1
- package/dist/entries/help-center.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +240 -220
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,7 @@ const articleById = await getDocArticleDetail({
|
|
|
194
194
|
### Help Center
|
|
195
195
|
|
|
196
196
|
- `getHelpCategories(options?)`
|
|
197
|
+
- `getHelpCategoryDetail({ id } | { slug })`
|
|
197
198
|
- `getHelpArticles(options?)`
|
|
198
199
|
- `getHelpArticleDetail({ id } | { slug })`
|
|
199
200
|
|
|
@@ -201,6 +202,12 @@ const articleById = await getDocArticleDetail({
|
|
|
201
202
|
// Categories are flat: build the tree from parentId (null = top level).
|
|
202
203
|
const categories = await getHelpCategories({ locale: "vi", size: 1000 });
|
|
203
204
|
|
|
205
|
+
// One category, same shape as a list item.
|
|
206
|
+
const category = await getHelpCategoryDetail({
|
|
207
|
+
slug: "thanh-toan",
|
|
208
|
+
locale: "vi",
|
|
209
|
+
});
|
|
210
|
+
|
|
204
211
|
// Article summaries (no body). Filter by category or featured flag.
|
|
205
212
|
const articles = await getHelpArticles({ locale: "vi", size: 1000 });
|
|
206
213
|
const featured = await getHelpArticles({ locale: "vi", featured: true });
|
|
@@ -223,6 +230,7 @@ Notes:
|
|
|
223
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`.
|
|
224
231
|
- `path` is the path stored on the CMS for the entry.
|
|
225
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.
|
|
226
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.
|
|
227
235
|
- `categoryId` is `null` for an article with no category.
|
|
228
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.
|
|
@@ -275,7 +283,7 @@ Filters `marketCode` / `locale` with global fallback (entries where `markets` /
|
|
|
275
283
|
|
|
276
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.
|
|
277
285
|
|
|
278
|
-
- The detail functions (`getBlogPostDetail`, `getBlogCategoryDetail`, `getDocCategoryDetail`, `getDocArticleDetail`, `getHelpArticleDetail`), `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.
|
|
279
287
|
- The detail functions throw `Error("Either id or slug is required.")` if neither `id` nor `slug` is provided.
|
|
280
288
|
- Calling a function before `configure` throws `Error("Client is not configured")`.
|
|
281
289
|
|
|
@@ -25,6 +25,7 @@ export type HelpArticleItem = {
|
|
|
25
25
|
categoryId: string | null;
|
|
26
26
|
};
|
|
27
27
|
export type GetHelpCategoriesResponse = PaginatedResponse<HelpCategoryItem>;
|
|
28
|
+
export type GetHelpCategoryDetailResponse = HelpCategoryItem;
|
|
28
29
|
export type GetHelpArticlesResponse = PaginatedResponse<HelpArticleItem>;
|
|
29
30
|
export interface HelpArticleDetailItem extends HelpArticleItem {
|
|
30
31
|
body: RichText | null;
|
|
@@ -35,6 +36,11 @@ export declare const getHelpCategories: ({ locale, page, size, }?: {
|
|
|
35
36
|
page?: number;
|
|
36
37
|
size?: number;
|
|
37
38
|
}) => Promise<GetHelpCategoriesResponse>;
|
|
39
|
+
export declare const getHelpCategoryDetail: ({ id, slug, locale, }: {
|
|
40
|
+
id?: string;
|
|
41
|
+
slug?: string;
|
|
42
|
+
locale?: string;
|
|
43
|
+
}) => Promise<GetHelpCategoryDetailResponse>;
|
|
38
44
|
export declare const getHelpArticles: ({ locale, categoryId, featured, page, size, }?: {
|
|
39
45
|
locale?: string;
|
|
40
46
|
categoryId?: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@janbox/headless-cms-sdk"),Q=["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&&Q.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)),n=Math.max(0,Math.floor(i));return{page:l,size:s,params:{limit:s,skip:(l-1)*s+n}}},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(n=>l(n)).filter(n=>n!==null)}},o=e=>e??null,w=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},V=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)}),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(V);return{json:e,links:{assets:{block:i}}}},T=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,S=(e,t)=>e?{name:o(e.fields.name),avatar:w(t.asset(e.fields.avatar))}:null,W=async({slot:e,page:t=1,size:i=20,platform:l,marketCode:s,locale:n})=>{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(n)},{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:o(y.fields.name),slot:o(y.fields.slot),platform:o(y.fields.platform),bannersCollection:{items:d.entries(y.fields.banners).map(E=>({sys:{id:E.sys.id},name:o(E.fields.name),hyperlink:b(d.entry(E.fields.hyperlink)),media:w(d.asset(E.fields.media))}))}}))})},k=()=>new _.CmsError({id:"NotFound",message:"Entry not found",url:`${r.config.baseUrl.trim().replace(/\/+$/,"")}/entries`,status:404}),D="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: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:w(t.asset(i.fields.featuredImage))}))},featuredImage:w(t.asset(e.fields.featuredImage))}),X=async({marketCode:e,locale:t,collectionId:i,categoryId:l,page:s=1,size:n=20,skip:a=0}={})=>{const c=C(s,n,a);if(i){const B=(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(!B)throw k();const v=(B.fields.posts??[]).filter(h=>h.sys.linkType==="Entry").map(h=>h.sys.id),z=v.slice(c.params.skip,c.params.skip+c.size);if(!z.length)return new p({page:c.page,total:v.length,size:c.size,items:[]});const H=await r.client.getEntries({content_type:"blogPost","sys.id[in]":z.join(","),select:D,include:2,limit:c.size},{resolveLinks:!1}),q=g(H),J=new Map(H.items.map(h=>[h.sys.id,h]));return new p({page:c.page,total:v.length,size:c.size,items:z.map(h=>J.get(h)).filter(h=>h!==void 0).map(h=>I(h,q))})}const d=await r.client.getEntries({content_type:"blogPost","fields.categories.sys.id":l||void 0,select:D,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(E=>I(E,y))})},Z=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),n=await r.client.getEntries({content_type:"blogPost",...s,select:`${D},fields.author,fields.content,fields.seo`,include:2,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=n.items.at(0);if(!a)throw k();const c=g(n);return{...I(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:o(e.fields.title),slug:o(e.fields.slug),featuredImage:w(t.asset(e.fields.featuredImage))}),ee=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),n=await r.client.getEntries({content_type:"blogCategory",select:O,include:1,order:m,...s.params,...u(e),...f(t)},{resolveLinks:!1}),a=g(n);return new p({page:s.page,total:n.total,size:s.size,items:n.items.map(c=>M(c,a))})},te=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),n=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=n.items.at(0);if(!a)throw k();const c=g(n);return{...M(a,c),description:o(a.fields.description),seo:T(c.entry(a.fields.seo))}},se=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),n=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(n),c=n.items.map(d=>{const y=a.entry(d.fields.category);return{name:o(d.fields.name),type:o(d.fields.type),order:o(d.fields.order),sys:{id:d.sys.id},category:y?{sys:{id:y.sys.id},title:o(y.fields.title),slug:o(y.fields.slug)}:null,featuredImage:w(a.asset(d.fields.featuredImage))}});return new p({page:s.page,total:n.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}))})},ie=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),n=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(n);return new p({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),brandsCollection:{items:a.entries(c.fields.brands).map(d=>({sys:{id:d.sys.id},name:o(d.fields.name),logo:w(a.asset(d.fields.logo)),hyperlink:b(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:o(e.fields.title),slug:o(e.fields.slug),description:o(e.fields.description),order:o(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:o(e.fields.title),slug:o(e.fields.slug),author:S(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}},le=async({marketCode:e,locale:t,page:i=1,size:l=20}={})=>{const s=C(i,l),n=await r.client.getEntries({content_type:"documentationCategory",select:F,include:1,order:m,...s.params,...u(e),...f(t)},{resolveLinks:!1}),a=g(n);return new p({page:s.page,total:n.total,size:s.size,items:n.items.map(c=>$(c,a))})},oe=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),n=await r.client.getEntries({content_type:"documentationCategory",...s,select:F,include:1,order:m,...u(i),...f(l)},{resolveLinks:!1}),a=n.items.at(0);if(!a)throw k();return $(a,g(n))},ne=async({marketCode:e,locale:t,categorySlug:i,page:l=1,size:s=20}={})=>{const n=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,...n.params,...u(e),...f(t)},{resolveLinks:!1}),c=g(a);return new p({page:n.page,total:a.total,size:n.size,items:a.items.map(d=>K(d,c))})},ae=async({id:e,slug:t,marketCode:i,locale:l})=>{const s=A({id:e,slug:t}),n=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=n.items.at(0);if(!a)throw k();const c=g(n);return{...K(a,c),content:L(a.fields.content,c),seo:T(c.entry(a.fields.seo))}},ce="crispHelpCategory",Y="crispHelpArticle",P="fields.position,sys.id",de="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.parent",j="sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.featured,fields.category",G=e=>({id:e.sys.id,createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt}),re=e=>({sys:G(e),title:o(e.fields.title),slug:o(e.fields.slug),path:o(e.fields.path),locale:o(e.fields.locale),position:o(e.fields.position),parentId:e.fields.parent?.sys.id??null}),U=e=>({sys:G(e),title:o(e.fields.title),slug:o(e.fields.slug),path:o(e.fields.path),locale:o(e.fields.locale),position:o(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:ce,select:de,include:0,order:P,...l.params,...f(e)},{resolveLinks:!1});return new p({page:l.page,total:s.total,size:l.size,items:s.items.map(re)})},ge=async({locale:e,categoryId:t,featured:i,page:l=1,size:s=20}={})=>{const n=C(l,s),a=await r.client.getEntries({content_type:Y,...t?{"fields.category.sys.id":t}:{},...i!==void 0?{"fields.featured":i}:{},select:j,include:0,order:P,...n.params,...f(e)},{resolveLinks:!1});return new p({page:n.page,total:a.total,size:n.size,items:a.items.map(U)})},pe=async({id:e,slug:t,locale:i})=>{const l=A({id:e,slug:t}),s=await r.client.getEntries({content_type:Y,...l,select:`${j},fields.body`,include:1,order:P,...f(i)},{resolveLinks:!1}),n=s.items.at(0);if(!n)throw k();return{...U(n),body:L(n.fields.body,g(s))}},ue=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),n=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(n);return new p({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),order:o(c.fields.order),linksCollection:{items:a.entries(c.fields.links).map(d=>b(d))}}))})},me=async({page:e=1,size:t=20,marketCode:i,locale:l}={})=>{const s=C(e,t),n=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: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),keywords:o(a.fields.keywords)}))})},ye=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 k();return{sys:{id:l.sys.id},title:o(l.fields.title),locale:o(l.fields.locale),content:L(l.fields.content,g(i))}};exports.ContentfulSDK=r;exports.PaginatedResponse=p;exports.getBannerCollections=W;exports.getBlogCategories=ee;exports.getBlogCategoryDetail=te;exports.getBlogCollections=se;exports.getBlogPostDetail=Z;exports.getBlogPosts=X;exports.getBrandCollections=ie;exports.getDocArticleDetail=ae;exports.getDocArticles=ne;exports.getDocCategories=le;exports.getDocCategoryDetail=oe;exports.getHelpArticleDetail=pe;exports.getHelpArticles=ge;exports.getHelpCategories=fe;exports.getHyperlinkCollections=ue;exports.getKeywordCollections=me;exports.getPolicyAndTerms=ye;
|
|
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,9 +17,9 @@ 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) {
|
|
@@ -60,13 +60,13 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
60
60
|
return { "fields.slug": s, limit: 1 };
|
|
61
61
|
throw new Error("Either id or slug is required.");
|
|
62
62
|
}, E = (e, s, i = 0) => {
|
|
63
|
-
const l = Math.max(1, Math.floor(e)), t = Math.max(1, Math.floor(s)),
|
|
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) => {
|
|
@@ -79,9 +79,9 @@ const m = "-sys.updatedAt", p = (e) => e ? H("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,14 +89,14 @@ const m = "-sys.updatedAt", p = (e) => e ? H("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:
|
|
98
|
+
title: n(e.fields.title),
|
|
99
|
+
description: n(e.fields.description)
|
|
100
100
|
}), B = (e, s) => {
|
|
101
101
|
if (!e || typeof e != "object")
|
|
102
102
|
return s;
|
|
@@ -111,31 +111,31 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
111
111
|
}, _ = (e, s) => {
|
|
112
112
|
if (!e)
|
|
113
113
|
return null;
|
|
114
|
-
const i = B(e, []).map((l) => s.asset({ sys: { type: "Link", linkType: "Asset", id: l } })).filter((l) => l !== null && !!l.fields.file).map(
|
|
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
116
|
}, L = (e) => e ? {
|
|
117
|
-
metaTitle:
|
|
118
|
-
metaDescription:
|
|
119
|
-
metaKeywords:
|
|
120
|
-
metaRobots:
|
|
121
|
-
} : null,
|
|
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:
|
|
128
|
+
name: n(e.fields.name),
|
|
129
|
+
avatar: C(s.asset(e.fields.avatar))
|
|
130
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 a = E(s, i),
|
|
138
|
+
const a = E(s, i), c = await r.client.getEntries(
|
|
139
139
|
{
|
|
140
140
|
content_type: "bannerCollection",
|
|
141
141
|
"fields.slot": e,
|
|
@@ -145,66 +145,66 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
145
145
|
order: m,
|
|
146
146
|
...a.params,
|
|
147
147
|
...p(t),
|
|
148
|
-
...f(
|
|
148
|
+
...f(o)
|
|
149
149
|
},
|
|
150
150
|
{ resolveLinks: !1 }
|
|
151
|
-
),
|
|
151
|
+
), d = g(c);
|
|
152
152
|
return new u({
|
|
153
153
|
page: a.page,
|
|
154
|
-
total:
|
|
154
|
+
total: c.total,
|
|
155
155
|
size: a.size,
|
|
156
|
-
items:
|
|
156
|
+
items: c.items.map(
|
|
157
157
|
(y) => ({
|
|
158
158
|
sys: { id: y.sys.id },
|
|
159
|
-
name:
|
|
160
|
-
slot:
|
|
161
|
-
platform:
|
|
159
|
+
name: n(y.fields.name),
|
|
160
|
+
slot: n(y.fields.slot),
|
|
161
|
+
platform: n(y.fields.platform),
|
|
162
162
|
bannersCollection: {
|
|
163
|
-
items:
|
|
164
|
-
sys: { id:
|
|
165
|
-
name:
|
|
166
|
-
hyperlink:
|
|
167
|
-
|
|
163
|
+
items: d.entries(y.fields.banners).map((k) => ({
|
|
164
|
+
sys: { id: k.sys.id },
|
|
165
|
+
name: n(k.fields.name),
|
|
166
|
+
hyperlink: D(
|
|
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
|
-
}),
|
|
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:
|
|
197
|
+
featuredImage: C(s.asset(e.fields.featuredImage))
|
|
198
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:
|
|
204
|
+
size: o = 20,
|
|
205
205
|
skip: a = 0
|
|
206
206
|
} = {}) => {
|
|
207
|
-
const
|
|
207
|
+
const c = E(t, o, a);
|
|
208
208
|
if (i) {
|
|
209
209
|
const P = (await r.client.getEntries(
|
|
210
210
|
{
|
|
@@ -217,50 +217,50 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
217
217
|
{ resolveLinks: !1 }
|
|
218
218
|
)).items.at(0);
|
|
219
219
|
if (!P)
|
|
220
|
-
throw
|
|
221
|
-
const
|
|
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
222
|
if (!z.length)
|
|
223
223
|
return new u({
|
|
224
|
-
page:
|
|
225
|
-
total:
|
|
226
|
-
size:
|
|
224
|
+
page: c.page,
|
|
225
|
+
total: v.length,
|
|
226
|
+
size: c.size,
|
|
227
227
|
items: []
|
|
228
228
|
});
|
|
229
229
|
const R = await r.client.getEntries(
|
|
230
230
|
{
|
|
231
231
|
content_type: "blogPost",
|
|
232
232
|
"sys.id[in]": z.join(","),
|
|
233
|
-
select:
|
|
233
|
+
select: I,
|
|
234
234
|
include: 2,
|
|
235
|
-
limit:
|
|
235
|
+
limit: c.size
|
|
236
236
|
},
|
|
237
237
|
{ resolveLinks: !1 }
|
|
238
|
-
),
|
|
238
|
+
), V = g(R), W = new Map(R.items.map((h) => [h.sys.id, h]));
|
|
239
239
|
return new u({
|
|
240
|
-
page:
|
|
241
|
-
total:
|
|
242
|
-
size:
|
|
243
|
-
items: z.map((h) =>
|
|
240
|
+
page: c.page,
|
|
241
|
+
total: v.length,
|
|
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
|
-
const
|
|
246
|
+
const d = await r.client.getEntries(
|
|
247
247
|
{
|
|
248
248
|
content_type: "blogPost",
|
|
249
249
|
"fields.categories.sys.id": l || void 0,
|
|
250
|
-
select:
|
|
250
|
+
select: I,
|
|
251
251
|
include: 2,
|
|
252
252
|
order: m,
|
|
253
|
-
...
|
|
253
|
+
...c.params,
|
|
254
254
|
...p(e),
|
|
255
255
|
...f(s)
|
|
256
256
|
},
|
|
257
257
|
{ resolveLinks: !1 }
|
|
258
|
-
), y = g(
|
|
258
|
+
), y = g(d);
|
|
259
259
|
return new u({
|
|
260
|
-
page:
|
|
261
|
-
total:
|
|
262
|
-
size:
|
|
263
|
-
items:
|
|
260
|
+
page: c.page,
|
|
261
|
+
total: d.total,
|
|
262
|
+
size: c.size,
|
|
263
|
+
items: d.items.map((k) => b(k, y))
|
|
264
264
|
});
|
|
265
265
|
}, oe = async ({
|
|
266
266
|
id: e,
|
|
@@ -268,39 +268,39 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
268
268
|
marketCode: i,
|
|
269
269
|
locale: l
|
|
270
270
|
}) => {
|
|
271
|
-
const t = A({ id: e, slug: s }),
|
|
271
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
272
272
|
{
|
|
273
273
|
content_type: "blogPost",
|
|
274
274
|
...t,
|
|
275
|
-
select: `${
|
|
275
|
+
select: `${I},fields.author,fields.content,fields.seo`,
|
|
276
276
|
include: 2,
|
|
277
277
|
order: m,
|
|
278
278
|
...p(i),
|
|
279
279
|
...f(l)
|
|
280
280
|
},
|
|
281
281
|
{ resolveLinks: !1 }
|
|
282
|
-
), a =
|
|
282
|
+
), a = o.items.at(0);
|
|
283
283
|
if (!a)
|
|
284
|
-
throw
|
|
285
|
-
const
|
|
284
|
+
throw w();
|
|
285
|
+
const c = g(o);
|
|
286
286
|
return {
|
|
287
|
-
...
|
|
288
|
-
author: S(
|
|
289
|
-
content: _(a.fields.content,
|
|
290
|
-
seo: L(
|
|
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:
|
|
294
|
+
title: n(e.fields.title),
|
|
295
|
+
slug: n(e.fields.slug),
|
|
296
|
+
featuredImage: C(s.asset(e.fields.featuredImage))
|
|
297
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 = E(i, l),
|
|
303
|
+
const t = E(i, l), o = await r.client.getEntries(
|
|
304
304
|
{
|
|
305
305
|
content_type: "blogCategory",
|
|
306
306
|
select: O,
|
|
@@ -311,12 +311,12 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
311
311
|
...f(s)
|
|
312
312
|
},
|
|
313
313
|
{ resolveLinks: !1 }
|
|
314
|
-
), a = g(
|
|
314
|
+
), a = g(o);
|
|
315
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,
|
|
@@ -324,7 +324,7 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
324
324
|
marketCode: i,
|
|
325
325
|
locale: l
|
|
326
326
|
}) => {
|
|
327
|
-
const t = A({ id: e, slug: s }),
|
|
327
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
328
328
|
{
|
|
329
329
|
content_type: "blogCategory",
|
|
330
330
|
...t,
|
|
@@ -335,22 +335,22 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
335
335
|
...f(l)
|
|
336
336
|
},
|
|
337
337
|
{ resolveLinks: !1 }
|
|
338
|
-
), a =
|
|
338
|
+
), a = o.items.at(0);
|
|
339
339
|
if (!a)
|
|
340
|
-
throw
|
|
341
|
-
const
|
|
340
|
+
throw w();
|
|
341
|
+
const c = g(o);
|
|
342
342
|
return {
|
|
343
|
-
...M(a,
|
|
344
|
-
description:
|
|
345
|
-
seo: L(
|
|
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 = E(i, l),
|
|
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",
|
|
@@ -361,39 +361,39 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
361
361
|
...f(s)
|
|
362
362
|
},
|
|
363
363
|
{ resolveLinks: !1 }
|
|
364
|
-
), a = g(
|
|
365
|
-
const y = a.entry(
|
|
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:
|
|
370
|
-
sys: { id:
|
|
367
|
+
name: n(d.fields.name),
|
|
368
|
+
type: n(d.fields.type),
|
|
369
|
+
order: n(d.fields.order),
|
|
370
|
+
sys: { id: d.sys.id },
|
|
371
371
|
category: y ? {
|
|
372
372
|
sys: { id: y.sys.id },
|
|
373
|
-
title:
|
|
374
|
-
slug:
|
|
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
379
|
return new u({
|
|
380
380
|
page: t.page,
|
|
381
|
-
total:
|
|
381
|
+
total: o.total,
|
|
382
382
|
size: t.size,
|
|
383
|
-
items:
|
|
384
|
-
...
|
|
385
|
-
category:
|
|
386
|
-
categoryId:
|
|
387
|
-
collectionId:
|
|
383
|
+
items: c.map((d) => ({
|
|
384
|
+
...d,
|
|
385
|
+
category: d.type === "category" ? d.category : null,
|
|
386
|
+
categoryId: d.type === "category" ? d.category?.sys.id ?? null : null,
|
|
387
|
+
collectionId: d.type === "manual" ? d.sys.id : null
|
|
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 = E(e, s),
|
|
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",
|
|
@@ -404,23 +404,23 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
404
404
|
...f(l)
|
|
405
405
|
},
|
|
406
406
|
{ resolveLinks: !1 }
|
|
407
|
-
), a = g(
|
|
407
|
+
), a = g(o);
|
|
408
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: a.entries(
|
|
419
|
-
sys: { id:
|
|
420
|
-
name:
|
|
421
|
-
logo:
|
|
422
|
-
hyperlink:
|
|
423
|
-
a.entry(
|
|
418
|
+
items: a.entries(c.fields.brands).map((d) => ({
|
|
419
|
+
sys: { id: d.sys.id },
|
|
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
|
}
|
|
@@ -433,23 +433,23 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
433
433
|
updatedAt: e.sys.updatedAt
|
|
434
434
|
}), $ = (e, s) => ({
|
|
435
435
|
sys: N(e),
|
|
436
|
-
title:
|
|
437
|
-
slug:
|
|
438
|
-
description:
|
|
439
|
-
order:
|
|
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
440
|
seo: L(s.entry(e.fields.seo))
|
|
441
441
|
}), Y = (e, s) => {
|
|
442
442
|
const i = s.entry(e.fields.category);
|
|
443
443
|
return {
|
|
444
444
|
sys: N(e),
|
|
445
|
-
title:
|
|
446
|
-
slug:
|
|
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 ({
|
|
@@ -458,7 +458,7 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
458
458
|
page: i = 1,
|
|
459
459
|
size: l = 20
|
|
460
460
|
} = {}) => {
|
|
461
|
-
const t = E(i, l),
|
|
461
|
+
const t = E(i, l), o = await r.client.getEntries(
|
|
462
462
|
{
|
|
463
463
|
content_type: "documentationCategory",
|
|
464
464
|
select: x,
|
|
@@ -469,12 +469,12 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
469
469
|
...f(s)
|
|
470
470
|
},
|
|
471
471
|
{ resolveLinks: !1 }
|
|
472
|
-
), a = g(
|
|
472
|
+
), a = g(o);
|
|
473
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,
|
|
@@ -482,7 +482,7 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
482
482
|
marketCode: i,
|
|
483
483
|
locale: l
|
|
484
484
|
}) => {
|
|
485
|
-
const t = A({ id: e, slug: s }),
|
|
485
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
486
486
|
{
|
|
487
487
|
content_type: "documentationCategory",
|
|
488
488
|
...t,
|
|
@@ -493,10 +493,10 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
493
493
|
...f(l)
|
|
494
494
|
},
|
|
495
495
|
{ resolveLinks: !1 }
|
|
496
|
-
), a =
|
|
496
|
+
), a = o.items.at(0);
|
|
497
497
|
if (!a)
|
|
498
|
-
throw
|
|
499
|
-
return $(a, g(
|
|
498
|
+
throw w();
|
|
499
|
+
return $(a, g(o));
|
|
500
500
|
}, ge = async ({
|
|
501
501
|
marketCode: e,
|
|
502
502
|
locale: s,
|
|
@@ -504,7 +504,7 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
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 ? {
|
|
@@ -514,17 +514,17 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
514
514
|
select: F,
|
|
515
515
|
include: 2,
|
|
516
516
|
order: m,
|
|
517
|
-
...
|
|
517
|
+
...o.params,
|
|
518
518
|
...p(e),
|
|
519
519
|
...f(s)
|
|
520
520
|
},
|
|
521
521
|
{ resolveLinks: !1 }
|
|
522
|
-
),
|
|
522
|
+
), c = g(a);
|
|
523
523
|
return new u({
|
|
524
|
-
page:
|
|
524
|
+
page: o.page,
|
|
525
525
|
total: a.total,
|
|
526
|
-
size:
|
|
527
|
-
items: a.items.map((
|
|
526
|
+
size: o.size,
|
|
527
|
+
items: a.items.map((d) => Y(d, c))
|
|
528
528
|
});
|
|
529
529
|
}, pe = async ({
|
|
530
530
|
id: e,
|
|
@@ -532,7 +532,7 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
532
532
|
marketCode: i,
|
|
533
533
|
locale: l
|
|
534
534
|
}) => {
|
|
535
|
-
const t = A({ id: e, slug: s }),
|
|
535
|
+
const t = A({ id: e, slug: s }), o = await r.client.getEntries(
|
|
536
536
|
{
|
|
537
537
|
content_type: "documentationArticle",
|
|
538
538
|
...t,
|
|
@@ -543,34 +543,34 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
543
543
|
...f(l)
|
|
544
544
|
},
|
|
545
545
|
{ resolveLinks: !1 }
|
|
546
|
-
), a =
|
|
546
|
+
), a = o.items.at(0);
|
|
547
547
|
if (!a)
|
|
548
|
-
throw
|
|
549
|
-
const
|
|
548
|
+
throw w();
|
|
549
|
+
const c = g(o);
|
|
550
550
|
return {
|
|
551
|
-
...Y(a,
|
|
552
|
-
content: _(a.fields.content,
|
|
553
|
-
seo: L(
|
|
551
|
+
...Y(a, c),
|
|
552
|
+
content: _(a.fields.content, c),
|
|
553
|
+
seo: L(c.entry(a.fields.seo))
|
|
554
554
|
};
|
|
555
|
-
},
|
|
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
556
|
id: e.sys.id,
|
|
557
557
|
createdAt: e.sys.createdAt,
|
|
558
558
|
updatedAt: e.sys.updatedAt
|
|
559
|
-
}),
|
|
560
|
-
sys:
|
|
561
|
-
title:
|
|
562
|
-
slug:
|
|
563
|
-
path:
|
|
564
|
-
locale:
|
|
565
|
-
position:
|
|
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
566
|
parentId: e.fields.parent?.sys.id ?? null
|
|
567
|
-
}),
|
|
568
|
-
sys:
|
|
569
|
-
title:
|
|
570
|
-
slug:
|
|
571
|
-
path:
|
|
572
|
-
locale:
|
|
573
|
-
position:
|
|
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
574
|
featured: e.fields.featured === !0,
|
|
575
575
|
categoryId: e.fields.category?.sys.id ?? null
|
|
576
576
|
}), ue = async ({
|
|
@@ -580,10 +580,10 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
580
580
|
} = {}) => {
|
|
581
581
|
const l = E(s, i), t = await r.client.getEntries(
|
|
582
582
|
{
|
|
583
|
-
content_type:
|
|
584
|
-
select:
|
|
583
|
+
content_type: G,
|
|
584
|
+
select: j,
|
|
585
585
|
include: 0,
|
|
586
|
-
order:
|
|
586
|
+
order: T,
|
|
587
587
|
...l.params,
|
|
588
588
|
...f(e)
|
|
589
589
|
},
|
|
@@ -593,63 +593,82 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
593
593
|
page: l.page,
|
|
594
594
|
total: t.total,
|
|
595
595
|
size: l.size,
|
|
596
|
-
items: t.items.map(
|
|
596
|
+
items: t.items.map(J)
|
|
597
597
|
});
|
|
598
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 ({
|
|
599
618
|
locale: e,
|
|
600
619
|
categoryId: s,
|
|
601
620
|
featured: i,
|
|
602
621
|
page: l = 1,
|
|
603
622
|
size: t = 20
|
|
604
623
|
} = {}) => {
|
|
605
|
-
const
|
|
624
|
+
const o = E(l, t), a = await r.client.getEntries(
|
|
606
625
|
{
|
|
607
|
-
content_type:
|
|
626
|
+
content_type: K,
|
|
608
627
|
...s ? { "fields.category.sys.id": s } : {},
|
|
609
628
|
...i !== void 0 ? { "fields.featured": i } : {},
|
|
610
|
-
select:
|
|
629
|
+
select: U,
|
|
611
630
|
include: 0,
|
|
612
|
-
order:
|
|
613
|
-
...
|
|
631
|
+
order: T,
|
|
632
|
+
...o.params,
|
|
614
633
|
...f(e)
|
|
615
634
|
},
|
|
616
635
|
{ resolveLinks: !1 }
|
|
617
636
|
);
|
|
618
637
|
return new u({
|
|
619
|
-
page:
|
|
638
|
+
page: o.page,
|
|
620
639
|
total: a.total,
|
|
621
|
-
size:
|
|
622
|
-
items: a.items.map(
|
|
640
|
+
size: o.size,
|
|
641
|
+
items: a.items.map(Q)
|
|
623
642
|
});
|
|
624
|
-
},
|
|
643
|
+
}, he = async ({
|
|
625
644
|
id: e,
|
|
626
645
|
slug: s,
|
|
627
646
|
locale: i
|
|
628
647
|
}) => {
|
|
629
648
|
const l = A({ id: e, slug: s }), t = await r.client.getEntries(
|
|
630
649
|
{
|
|
631
|
-
content_type:
|
|
650
|
+
content_type: K,
|
|
632
651
|
...l,
|
|
633
|
-
select: `${
|
|
652
|
+
select: `${U},fields.body`,
|
|
634
653
|
include: 1,
|
|
635
|
-
order:
|
|
654
|
+
order: T,
|
|
636
655
|
...f(i)
|
|
637
656
|
},
|
|
638
657
|
{ resolveLinks: !1 }
|
|
639
|
-
),
|
|
640
|
-
if (!
|
|
641
|
-
throw
|
|
658
|
+
), o = t.items.at(0);
|
|
659
|
+
if (!o)
|
|
660
|
+
throw w();
|
|
642
661
|
return {
|
|
643
|
-
...
|
|
644
|
-
body: _(
|
|
662
|
+
...Q(o),
|
|
663
|
+
body: _(o.fields.body, g(t))
|
|
645
664
|
};
|
|
646
|
-
},
|
|
665
|
+
}, Ee = async ({
|
|
647
666
|
page: e = 1,
|
|
648
667
|
size: s = 20,
|
|
649
668
|
marketCode: i,
|
|
650
669
|
locale: l
|
|
651
670
|
} = {}) => {
|
|
652
|
-
const t = E(e, s),
|
|
671
|
+
const t = E(e, s), o = await r.client.getEntries(
|
|
653
672
|
{
|
|
654
673
|
content_type: "hyperlinkCollection",
|
|
655
674
|
select: "sys.id,fields.name,fields.slot,fields.order,fields.links",
|
|
@@ -660,30 +679,30 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
660
679
|
...f(l)
|
|
661
680
|
},
|
|
662
681
|
{ resolveLinks: !1 }
|
|
663
|
-
), a = g(
|
|
682
|
+
), a = g(o);
|
|
664
683
|
return new u({
|
|
665
684
|
page: t.page,
|
|
666
|
-
total:
|
|
685
|
+
total: o.total,
|
|
667
686
|
size: t.size,
|
|
668
|
-
items:
|
|
669
|
-
(
|
|
670
|
-
sys: { id:
|
|
671
|
-
name:
|
|
672
|
-
slot:
|
|
673
|
-
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),
|
|
674
693
|
linksCollection: {
|
|
675
|
-
items: a.entries(
|
|
694
|
+
items: a.entries(c.fields.links).map((d) => D(d))
|
|
676
695
|
}
|
|
677
696
|
})
|
|
678
697
|
)
|
|
679
698
|
});
|
|
680
|
-
},
|
|
699
|
+
}, we = async ({
|
|
681
700
|
page: e = 1,
|
|
682
701
|
size: s = 20,
|
|
683
702
|
marketCode: i,
|
|
684
703
|
locale: l
|
|
685
704
|
} = {}) => {
|
|
686
|
-
const t = E(e, s),
|
|
705
|
+
const t = E(e, s), o = await r.client.getEntries(
|
|
687
706
|
{
|
|
688
707
|
content_type: "keywordCollection",
|
|
689
708
|
select: "sys.id,fields.name,fields.slot,fields.keywords",
|
|
@@ -697,18 +716,18 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
697
716
|
);
|
|
698
717
|
return new u({
|
|
699
718
|
page: t.page,
|
|
700
|
-
total:
|
|
719
|
+
total: o.total,
|
|
701
720
|
size: t.size,
|
|
702
|
-
items:
|
|
721
|
+
items: o.items.map(
|
|
703
722
|
(a) => ({
|
|
704
723
|
sys: { id: a.sys.id },
|
|
705
|
-
name:
|
|
706
|
-
slot:
|
|
707
|
-
keywords:
|
|
724
|
+
name: n(a.fields.name),
|
|
725
|
+
slot: n(a.fields.slot),
|
|
726
|
+
keywords: n(a.fields.keywords)
|
|
708
727
|
})
|
|
709
728
|
)
|
|
710
729
|
});
|
|
711
|
-
},
|
|
730
|
+
}, ke = async ({
|
|
712
731
|
marketCode: e,
|
|
713
732
|
locale: s
|
|
714
733
|
} = {}) => {
|
|
@@ -725,11 +744,11 @@ const m = "-sys.updatedAt", p = (e) => e ? H("market", [
|
|
|
725
744
|
{ resolveLinks: !1 }
|
|
726
745
|
), l = i.items.at(0);
|
|
727
746
|
if (!l)
|
|
728
|
-
throw
|
|
747
|
+
throw w();
|
|
729
748
|
return {
|
|
730
749
|
sys: { id: l.sys.id },
|
|
731
|
-
title:
|
|
732
|
-
locale:
|
|
750
|
+
title: n(l.fields.title),
|
|
751
|
+
locale: n(l.fields.locale),
|
|
733
752
|
content: _(l.fields.content, g(i))
|
|
734
753
|
};
|
|
735
754
|
};
|
|
@@ -739,18 +758,19 @@ export {
|
|
|
739
758
|
ie as getBannerCollections,
|
|
740
759
|
ne as getBlogCategories,
|
|
741
760
|
ae as getBlogCategoryDetail,
|
|
742
|
-
|
|
761
|
+
ce as getBlogCollections,
|
|
743
762
|
oe as getBlogPostDetail,
|
|
744
763
|
le as getBlogPosts,
|
|
745
|
-
|
|
764
|
+
de as getBrandCollections,
|
|
746
765
|
pe as getDocArticleDetail,
|
|
747
766
|
ge as getDocArticles,
|
|
748
767
|
re as getDocCategories,
|
|
749
768
|
fe as getDocCategoryDetail,
|
|
750
|
-
|
|
751
|
-
|
|
769
|
+
he as getHelpArticleDetail,
|
|
770
|
+
ye as getHelpArticles,
|
|
752
771
|
ue as getHelpCategories,
|
|
753
|
-
|
|
754
|
-
Ee as
|
|
755
|
-
we as
|
|
772
|
+
me as getHelpCategoryDetail,
|
|
773
|
+
Ee as getHyperlinkCollections,
|
|
774
|
+
we as getKeywordCollections,
|
|
775
|
+
ke as getPolicyAndTerms
|
|
756
776
|
};
|