@janbox/contentful-marketplace-sdk 4.0.0-alpha.0 → 4.0.0-alpha.1
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 +38 -1
- package/dist/entries/help-center.d.ts +50 -0
- package/dist/entries/index.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +321 -227
- 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,42 @@ const articleById = await getDocArticleDetail({
|
|
|
191
191
|
});
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
+
### Help Center
|
|
195
|
+
|
|
196
|
+
- `getHelpCategories(options?)`
|
|
197
|
+
- `getHelpArticles(options?)`
|
|
198
|
+
- `getHelpArticleDetail({ id } | { slug })`
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
// Categories are flat: build the tree from parentId (null = top level).
|
|
202
|
+
const categories = await getHelpCategories({ locale: "vi", size: 1000 });
|
|
203
|
+
|
|
204
|
+
// Article summaries (no body). Filter by category or featured flag.
|
|
205
|
+
const articles = await getHelpArticles({ locale: "vi", size: 1000 });
|
|
206
|
+
const featured = await getHelpArticles({ locale: "vi", featured: true });
|
|
207
|
+
const subcategory = categories.items.find((c) => c.parentId !== null);
|
|
208
|
+
const inCategory = await getHelpArticles({
|
|
209
|
+
locale: "vi",
|
|
210
|
+
categoryId: subcategory?.sys.id,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const article = await getHelpArticleDetail({
|
|
214
|
+
slug: "bao-lau-hang-ve-viet-nam",
|
|
215
|
+
locale: "vi",
|
|
216
|
+
});
|
|
217
|
+
// article.body: { json, links: { assets: { block } } } | null
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Notes:
|
|
221
|
+
|
|
222
|
+
- Results are ordered by `position`.
|
|
223
|
+
- 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
|
+
- `path` is the path stored on the CMS for the entry.
|
|
225
|
+
- An article slug is unique within a locale only, so pass `locale` when looking an article up by slug.
|
|
226
|
+
- 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
|
+
- `categoryId` is `null` for an article with no category.
|
|
228
|
+
- 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.
|
|
229
|
+
|
|
194
230
|
### Brand / Hyperlink / Keyword Collections
|
|
195
231
|
|
|
196
232
|
- `getBrandCollections(options?)`
|
|
@@ -239,7 +275,7 @@ Filters `marketCode` / `locale` with global fallback (entries where `markets` /
|
|
|
239
275
|
|
|
240
276
|
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
277
|
|
|
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.
|
|
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.
|
|
243
279
|
- The detail functions throw `Error("Either id or slug is required.")` if neither `id` nor `slug` is provided.
|
|
244
280
|
- Calling a function before `configure` throws `Error("Client is not configured")`.
|
|
245
281
|
|
|
@@ -275,6 +311,7 @@ The package exports:
|
|
|
275
311
|
- client and entry functions from `src/client` and `src/entries`
|
|
276
312
|
- content model field types (`TypeXxxFields`) from `src/types`
|
|
277
313
|
- response item types such as `BlogPostGraphQLItem` and `DocArticleGraphQLItem` (names kept from 2.x)
|
|
314
|
+
- help center item types `HelpCategoryItem`, `HelpArticleItem`, `HelpArticleDetailItem`, and `RichText` (the shape of rich text fields such as `body`)
|
|
278
315
|
|
|
279
316
|
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
317
|
|
|
@@ -0,0 +1,50 @@
|
|
|
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 GetHelpArticlesResponse = PaginatedResponse<HelpArticleItem>;
|
|
29
|
+
export interface HelpArticleDetailItem extends HelpArticleItem {
|
|
30
|
+
body: RichText | null;
|
|
31
|
+
}
|
|
32
|
+
export type GetHelpArticleDetailResponse = HelpArticleDetailItem;
|
|
33
|
+
export declare const getHelpCategories: ({ locale, page, size, }?: {
|
|
34
|
+
locale?: string;
|
|
35
|
+
page?: number;
|
|
36
|
+
size?: number;
|
|
37
|
+
}) => Promise<GetHelpCategoriesResponse>;
|
|
38
|
+
export declare const getHelpArticles: ({ locale, categoryId, featured, page, size, }?: {
|
|
39
|
+
locale?: string;
|
|
40
|
+
categoryId?: string;
|
|
41
|
+
featured?: boolean;
|
|
42
|
+
page?: number;
|
|
43
|
+
size?: number;
|
|
44
|
+
}) => Promise<GetHelpArticlesResponse>;
|
|
45
|
+
export declare const getHelpArticleDetail: ({ id, slug, locale, }: {
|
|
46
|
+
id?: string;
|
|
47
|
+
slug?: string;
|
|
48
|
+
locale?: string;
|
|
49
|
+
}) => Promise<GetHelpArticleDetailResponse>;
|
|
50
|
+
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"),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;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
const
|
|
1
|
+
import { createClient as Q, or as H, CmsError as V } from "@janbox/headless-cms-sdk";
|
|
2
|
+
const W = [
|
|
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 && W.every((t) => i.builtFrom[t] === s[t]))
|
|
21
21
|
return i.client;
|
|
22
|
-
const l =
|
|
22
|
+
const l = Q(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,7 +59,7 @@ 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
|
-
},
|
|
62
|
+
}, E = (e, s, i = 0) => {
|
|
63
63
|
const l = Math.max(1, Math.floor(e)), t = Math.max(1, Math.floor(s)), n = Math.max(0, Math.floor(i));
|
|
64
64
|
return {
|
|
65
65
|
page: l,
|
|
@@ -69,7 +69,7 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
69
69
|
skip: (l - 1) * t + n
|
|
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);
|
|
@@ -81,7 +81,7 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
81
81
|
asset: (t) => (t && i.get(t.sys.id)) ?? null,
|
|
82
82
|
entries: (t) => (t ?? []).map((n) => l(n)).filter((n) => n !== null)
|
|
83
83
|
};
|
|
84
|
-
}, o = (e) => e ?? null,
|
|
84
|
+
}, o = (e) => e ?? null, k = (e) => {
|
|
85
85
|
const s = e?.fields.file;
|
|
86
86
|
return s ? {
|
|
87
87
|
url: s.url,
|
|
@@ -89,7 +89,7 @@ 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
|
+
}, X = (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,
|
|
@@ -97,7 +97,7 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
97
97
|
contentType: e.fields.file?.contentType,
|
|
98
98
|
title: o(e.fields.title),
|
|
99
99
|
description: o(e.fields.description)
|
|
100
|
-
}),
|
|
100
|
+
}), B = (e, s) => {
|
|
101
101
|
if (!e || typeof e != "object")
|
|
102
102
|
return s;
|
|
103
103
|
const i = e;
|
|
@@ -106,14 +106,14 @@ 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(X);
|
|
115
115
|
return { json: e, links: { assets: { block: i } } };
|
|
116
|
-
},
|
|
116
|
+
}, L = (e) => e ? {
|
|
117
117
|
metaTitle: o(e.fields.metaTitle),
|
|
118
118
|
metaDescription: o(e.fields.metaDescription),
|
|
119
119
|
metaKeywords: o(e.fields.metaKeywords),
|
|
@@ -126,8 +126,8 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
126
126
|
marketHandling: o(e.fields.marketHandling)
|
|
127
127
|
} : null, S = (e, s) => e ? {
|
|
128
128
|
name: o(e.fields.name),
|
|
129
|
-
avatar:
|
|
130
|
-
} : null,
|
|
129
|
+
avatar: k(s.asset(e.fields.avatar))
|
|
130
|
+
} : null, ie = async ({
|
|
131
131
|
slot: e,
|
|
132
132
|
page: s = 1,
|
|
133
133
|
size: i = 20,
|
|
@@ -135,7 +135,7 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
135
135
|
marketCode: t,
|
|
136
136
|
locale: n
|
|
137
137
|
}) => {
|
|
138
|
-
const
|
|
138
|
+
const a = E(s, i), d = await r.client.getEntries(
|
|
139
139
|
{
|
|
140
140
|
content_type: "bannerCollection",
|
|
141
141
|
"fields.slot": e,
|
|
@@ -143,41 +143,41 @@ 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(n)
|
|
149
149
|
},
|
|
150
150
|
{ resolveLinks: !1 }
|
|
151
|
-
),
|
|
152
|
-
return new
|
|
153
|
-
page:
|
|
154
|
-
total:
|
|
155
|
-
size:
|
|
156
|
-
items:
|
|
157
|
-
(
|
|
158
|
-
sys: { id:
|
|
159
|
-
name: o(
|
|
160
|
-
slot: o(
|
|
161
|
-
platform: o(
|
|
151
|
+
), c = g(d);
|
|
152
|
+
return new u({
|
|
153
|
+
page: a.page,
|
|
154
|
+
total: d.total,
|
|
155
|
+
size: a.size,
|
|
156
|
+
items: d.items.map(
|
|
157
|
+
(y) => ({
|
|
158
|
+
sys: { id: y.sys.id },
|
|
159
|
+
name: o(y.fields.name),
|
|
160
|
+
slot: o(y.fields.slot),
|
|
161
|
+
platform: o(y.fields.platform),
|
|
162
162
|
bannersCollection: {
|
|
163
|
-
items:
|
|
164
|
-
sys: { id:
|
|
165
|
-
name: o(
|
|
163
|
+
items: c.entries(y.fields.banners).map((w) => ({
|
|
164
|
+
sys: { id: w.sys.id },
|
|
165
|
+
name: o(w.fields.name),
|
|
166
166
|
hyperlink: b(
|
|
167
|
-
|
|
167
|
+
c.entry(w.fields.hyperlink)
|
|
168
168
|
),
|
|
169
|
-
media:
|
|
169
|
+
media: k(c.asset(w.fields.media))
|
|
170
170
|
}))
|
|
171
171
|
}
|
|
172
172
|
})
|
|
173
173
|
)
|
|
174
174
|
});
|
|
175
|
-
}, C = () => new
|
|
175
|
+
}, C = () => new V({
|
|
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
|
+
}), v = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.shortDescription,fields.slug,fields.categories,fields.featuredImage", I = (e, s) => ({
|
|
181
181
|
sys: {
|
|
182
182
|
id: e.sys.id,
|
|
183
183
|
createdAt: e.sys.createdAt,
|
|
@@ -191,22 +191,22 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
191
191
|
sys: { id: i.sys.id },
|
|
192
192
|
title: o(i.fields.title),
|
|
193
193
|
slug: o(i.fields.slug),
|
|
194
|
-
featuredImage:
|
|
194
|
+
featuredImage: k(s.asset(i.fields.featuredImage))
|
|
195
195
|
}))
|
|
196
196
|
},
|
|
197
|
-
featuredImage:
|
|
198
|
-
}),
|
|
197
|
+
featuredImage: k(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
204
|
size: n = 20,
|
|
205
|
-
skip:
|
|
205
|
+
skip: a = 0
|
|
206
206
|
} = {}) => {
|
|
207
|
-
const
|
|
207
|
+
const d = E(t, n, 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,232 +216,232 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
216
216
|
},
|
|
217
217
|
{ resolveLinks: !1 }
|
|
218
218
|
)).items.at(0);
|
|
219
|
-
if (!
|
|
219
|
+
if (!P)
|
|
220
220
|
throw C();
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
return new
|
|
224
|
-
page:
|
|
225
|
-
total:
|
|
226
|
-
size:
|
|
221
|
+
const T = (P.fields.posts ?? []).filter((h) => h.sys.linkType === "Entry").map((h) => h.sys.id), z = T.slice(d.params.skip, d.params.skip + d.size);
|
|
222
|
+
if (!z.length)
|
|
223
|
+
return new u({
|
|
224
|
+
page: d.page,
|
|
225
|
+
total: T.length,
|
|
226
|
+
size: d.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]":
|
|
233
|
-
select:
|
|
232
|
+
"sys.id[in]": z.join(","),
|
|
233
|
+
select: v,
|
|
234
234
|
include: 2,
|
|
235
|
-
limit:
|
|
235
|
+
limit: d.size
|
|
236
236
|
},
|
|
237
237
|
{ resolveLinks: !1 }
|
|
238
|
-
),
|
|
239
|
-
return new
|
|
240
|
-
page:
|
|
241
|
-
total:
|
|
242
|
-
size:
|
|
243
|
-
items:
|
|
238
|
+
), q = g(R), J = new Map(R.items.map((h) => [h.sys.id, h]));
|
|
239
|
+
return new u({
|
|
240
|
+
page: d.page,
|
|
241
|
+
total: T.length,
|
|
242
|
+
size: d.size,
|
|
243
|
+
items: z.map((h) => J.get(h)).filter((h) => h !== void 0).map((h) => I(h, q))
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
|
-
const
|
|
246
|
+
const c = await r.client.getEntries(
|
|
247
247
|
{
|
|
248
248
|
content_type: "blogPost",
|
|
249
249
|
"fields.categories.sys.id": l || void 0,
|
|
250
|
-
select:
|
|
250
|
+
select: v,
|
|
251
251
|
include: 2,
|
|
252
252
|
order: m,
|
|
253
|
-
...
|
|
254
|
-
...
|
|
255
|
-
...
|
|
253
|
+
...d.params,
|
|
254
|
+
...p(e),
|
|
255
|
+
...f(s)
|
|
256
256
|
},
|
|
257
257
|
{ resolveLinks: !1 }
|
|
258
|
-
),
|
|
259
|
-
return new
|
|
260
|
-
page:
|
|
261
|
-
total:
|
|
262
|
-
size:
|
|
263
|
-
items:
|
|
258
|
+
), y = g(c);
|
|
259
|
+
return new u({
|
|
260
|
+
page: d.page,
|
|
261
|
+
total: c.total,
|
|
262
|
+
size: d.size,
|
|
263
|
+
items: c.items.map((w) => I(w, 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 }), n = await r.client.getEntries(
|
|
272
272
|
{
|
|
273
273
|
content_type: "blogPost",
|
|
274
274
|
...t,
|
|
275
|
-
select: `${
|
|
275
|
+
select: `${v},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 (!
|
|
282
|
+
), a = n.items.at(0);
|
|
283
|
+
if (!a)
|
|
284
284
|
throw C();
|
|
285
|
-
const
|
|
285
|
+
const d = g(n);
|
|
286
286
|
return {
|
|
287
|
-
...
|
|
288
|
-
author: S(
|
|
289
|
-
content:
|
|
290
|
-
seo:
|
|
287
|
+
...I(a, d),
|
|
288
|
+
author: S(d.entry(a.fields.author), d),
|
|
289
|
+
content: _(a.fields.content, d),
|
|
290
|
+
seo: L(d.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
294
|
title: o(e.fields.title),
|
|
295
295
|
slug: o(e.fields.slug),
|
|
296
|
-
featuredImage:
|
|
297
|
-
}),
|
|
296
|
+
featuredImage: k(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), n = 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(n);
|
|
315
|
+
return new u({
|
|
316
316
|
page: t.page,
|
|
317
317
|
total: n.total,
|
|
318
318
|
size: t.size,
|
|
319
|
-
items: n.items.map((
|
|
319
|
+
items: n.items.map((d) => M(d, 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 }), n = 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 (!
|
|
338
|
+
), a = n.items.at(0);
|
|
339
|
+
if (!a)
|
|
340
340
|
throw C();
|
|
341
|
-
const
|
|
341
|
+
const d = g(n);
|
|
342
342
|
return {
|
|
343
|
-
...
|
|
344
|
-
description: o(
|
|
345
|
-
seo:
|
|
343
|
+
...M(a, d),
|
|
344
|
+
description: o(a.fields.description),
|
|
345
|
+
seo: L(d.entry(a.fields.seo))
|
|
346
346
|
};
|
|
347
|
-
},
|
|
347
|
+
}, de = 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), n = 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(n), d = n.items.map((c) => {
|
|
365
|
+
const y = a.entry(c.fields.category);
|
|
366
366
|
return {
|
|
367
|
-
name: o(
|
|
368
|
-
type: o(
|
|
369
|
-
order: o(
|
|
370
|
-
sys: { id:
|
|
371
|
-
category:
|
|
372
|
-
sys: { id:
|
|
373
|
-
title: o(
|
|
374
|
-
slug: o(
|
|
367
|
+
name: o(c.fields.name),
|
|
368
|
+
type: o(c.fields.type),
|
|
369
|
+
order: o(c.fields.order),
|
|
370
|
+
sys: { id: c.sys.id },
|
|
371
|
+
category: y ? {
|
|
372
|
+
sys: { id: y.sys.id },
|
|
373
|
+
title: o(y.fields.title),
|
|
374
|
+
slug: o(y.fields.slug)
|
|
375
375
|
} : null,
|
|
376
|
-
featuredImage:
|
|
376
|
+
featuredImage: k(a.asset(c.fields.featuredImage))
|
|
377
377
|
};
|
|
378
378
|
});
|
|
379
|
-
return new
|
|
379
|
+
return new u({
|
|
380
380
|
page: t.page,
|
|
381
381
|
total: n.total,
|
|
382
382
|
size: t.size,
|
|
383
|
-
items:
|
|
384
|
-
...
|
|
385
|
-
category:
|
|
386
|
-
categoryId:
|
|
387
|
-
collectionId:
|
|
383
|
+
items: d.map((c) => ({
|
|
384
|
+
...c,
|
|
385
|
+
category: c.type === "category" ? c.category : null,
|
|
386
|
+
categoryId: c.type === "category" ? c.category?.sys.id ?? null : null,
|
|
387
|
+
collectionId: c.type === "manual" ? c.sys.id : null
|
|
388
388
|
}))
|
|
389
389
|
});
|
|
390
|
-
},
|
|
390
|
+
}, ce = 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), n = 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(n);
|
|
408
|
+
return new u({
|
|
409
409
|
page: t.page,
|
|
410
410
|
total: n.total,
|
|
411
411
|
size: t.size,
|
|
412
412
|
items: n.items.map(
|
|
413
|
-
(
|
|
414
|
-
sys: { id:
|
|
415
|
-
name: o(
|
|
416
|
-
slot: o(
|
|
413
|
+
(d) => ({
|
|
414
|
+
sys: { id: d.sys.id },
|
|
415
|
+
name: o(d.fields.name),
|
|
416
|
+
slot: o(d.fields.slot),
|
|
417
417
|
brandsCollection: {
|
|
418
|
-
items:
|
|
419
|
-
sys: { id:
|
|
420
|
-
name: o(
|
|
421
|
-
logo:
|
|
418
|
+
items: a.entries(d.fields.brands).map((c) => ({
|
|
419
|
+
sys: { id: c.sys.id },
|
|
420
|
+
name: o(c.fields.name),
|
|
421
|
+
logo: k(a.asset(c.fields.logo)),
|
|
422
422
|
hyperlink: b(
|
|
423
|
-
|
|
423
|
+
a.entry(c.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:
|
|
434
|
+
}), $ = (e, s) => ({
|
|
435
|
+
sys: N(e),
|
|
436
436
|
title: o(e.fields.title),
|
|
437
437
|
slug: o(e.fields.slug),
|
|
438
438
|
description: o(e.fields.description),
|
|
439
439
|
order: o(e.fields.order),
|
|
440
|
-
seo:
|
|
441
|
-
}),
|
|
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:
|
|
444
|
+
sys: N(e),
|
|
445
445
|
title: o(e.fields.title),
|
|
446
446
|
slug: o(e.fields.slug),
|
|
447
447
|
author: S(s.entry(e.fields.author), s),
|
|
@@ -452,172 +452,263 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
452
452
|
order: o(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), n = 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(n);
|
|
473
|
+
return new u({
|
|
474
474
|
page: t.page,
|
|
475
475
|
total: n.total,
|
|
476
476
|
size: t.size,
|
|
477
|
-
items: n.items.map((
|
|
477
|
+
items: n.items.map((d) => $(d, 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 }), n = 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 (!
|
|
496
|
+
), a = n.items.at(0);
|
|
497
|
+
if (!a)
|
|
498
498
|
throw C();
|
|
499
|
-
return
|
|
500
|
-
},
|
|
499
|
+
return $(a, g(n));
|
|
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 n =
|
|
507
|
+
const n = 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
517
|
...n.params,
|
|
518
|
-
...
|
|
519
|
-
...
|
|
518
|
+
...p(e),
|
|
519
|
+
...f(s)
|
|
520
520
|
},
|
|
521
521
|
{ resolveLinks: !1 }
|
|
522
|
-
),
|
|
523
|
-
return new
|
|
522
|
+
), d = g(a);
|
|
523
|
+
return new u({
|
|
524
524
|
page: n.page,
|
|
525
|
-
total:
|
|
525
|
+
total: a.total,
|
|
526
526
|
size: n.size,
|
|
527
|
-
items:
|
|
527
|
+
items: a.items.map((c) => Y(c, d))
|
|
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 }), n = 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
544
|
},
|
|
545
545
|
{ resolveLinks: !1 }
|
|
546
|
-
),
|
|
547
|
-
if (!
|
|
546
|
+
), a = n.items.at(0);
|
|
547
|
+
if (!a)
|
|
548
548
|
throw C();
|
|
549
|
-
const
|
|
549
|
+
const d = g(n);
|
|
550
550
|
return {
|
|
551
|
-
...
|
|
552
|
-
content:
|
|
553
|
-
seo:
|
|
551
|
+
...Y(a, d),
|
|
552
|
+
content: _(a.fields.content, d),
|
|
553
|
+
seo: L(d.entry(a.fields.seo))
|
|
554
554
|
};
|
|
555
|
-
},
|
|
555
|
+
}, Z = "crispHelpCategory", G = "crispHelpArticle", D = "fields.position,sys.id", ee = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.parent", K = "sys.id,sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.path,fields.locale,fields.position,fields.featured,fields.category", j = (e) => ({
|
|
556
|
+
id: e.sys.id,
|
|
557
|
+
createdAt: e.sys.createdAt,
|
|
558
|
+
updatedAt: e.sys.updatedAt
|
|
559
|
+
}), se = (e) => ({
|
|
560
|
+
sys: j(e),
|
|
561
|
+
title: o(e.fields.title),
|
|
562
|
+
slug: o(e.fields.slug),
|
|
563
|
+
path: o(e.fields.path),
|
|
564
|
+
locale: o(e.fields.locale),
|
|
565
|
+
position: o(e.fields.position),
|
|
566
|
+
parentId: e.fields.parent?.sys.id ?? null
|
|
567
|
+
}), U = (e) => ({
|
|
568
|
+
sys: j(e),
|
|
569
|
+
title: o(e.fields.title),
|
|
570
|
+
slug: o(e.fields.slug),
|
|
571
|
+
path: o(e.fields.path),
|
|
572
|
+
locale: o(e.fields.locale),
|
|
573
|
+
position: o(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: Z,
|
|
584
|
+
select: ee,
|
|
585
|
+
include: 0,
|
|
586
|
+
order: D,
|
|
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(se)
|
|
597
|
+
});
|
|
598
|
+
}, me = async ({
|
|
599
|
+
locale: e,
|
|
600
|
+
categoryId: s,
|
|
601
|
+
featured: i,
|
|
602
|
+
page: l = 1,
|
|
603
|
+
size: t = 20
|
|
604
|
+
} = {}) => {
|
|
605
|
+
const n = E(l, t), a = await r.client.getEntries(
|
|
606
|
+
{
|
|
607
|
+
content_type: G,
|
|
608
|
+
...s ? { "fields.category.sys.id": s } : {},
|
|
609
|
+
...i !== void 0 ? { "fields.featured": i } : {},
|
|
610
|
+
select: K,
|
|
611
|
+
include: 0,
|
|
612
|
+
order: D,
|
|
613
|
+
...n.params,
|
|
614
|
+
...f(e)
|
|
615
|
+
},
|
|
616
|
+
{ resolveLinks: !1 }
|
|
617
|
+
);
|
|
618
|
+
return new u({
|
|
619
|
+
page: n.page,
|
|
620
|
+
total: a.total,
|
|
621
|
+
size: n.size,
|
|
622
|
+
items: a.items.map(U)
|
|
623
|
+
});
|
|
624
|
+
}, ye = async ({
|
|
625
|
+
id: e,
|
|
626
|
+
slug: s,
|
|
627
|
+
locale: i
|
|
628
|
+
}) => {
|
|
629
|
+
const l = A({ id: e, slug: s }), t = await r.client.getEntries(
|
|
630
|
+
{
|
|
631
|
+
content_type: G,
|
|
632
|
+
...l,
|
|
633
|
+
select: `${K},fields.body`,
|
|
634
|
+
include: 1,
|
|
635
|
+
order: D,
|
|
636
|
+
...f(i)
|
|
637
|
+
},
|
|
638
|
+
{ resolveLinks: !1 }
|
|
639
|
+
), n = t.items.at(0);
|
|
640
|
+
if (!n)
|
|
641
|
+
throw C();
|
|
642
|
+
return {
|
|
643
|
+
...U(n),
|
|
644
|
+
body: _(n.fields.body, g(t))
|
|
645
|
+
};
|
|
646
|
+
}, he = async ({
|
|
556
647
|
page: e = 1,
|
|
557
648
|
size: s = 20,
|
|
558
649
|
marketCode: i,
|
|
559
650
|
locale: l
|
|
560
651
|
} = {}) => {
|
|
561
|
-
const t =
|
|
652
|
+
const t = E(e, s), n = await r.client.getEntries(
|
|
562
653
|
{
|
|
563
654
|
content_type: "hyperlinkCollection",
|
|
564
655
|
select: "sys.id,fields.name,fields.slot,fields.order,fields.links",
|
|
565
656
|
include: 1,
|
|
566
657
|
order: "fields.order",
|
|
567
658
|
...t.params,
|
|
568
|
-
...
|
|
569
|
-
...
|
|
659
|
+
...p(i),
|
|
660
|
+
...f(l)
|
|
570
661
|
},
|
|
571
662
|
{ resolveLinks: !1 }
|
|
572
|
-
),
|
|
573
|
-
return new
|
|
663
|
+
), a = g(n);
|
|
664
|
+
return new u({
|
|
574
665
|
page: t.page,
|
|
575
666
|
total: n.total,
|
|
576
667
|
size: t.size,
|
|
577
668
|
items: n.items.map(
|
|
578
|
-
(
|
|
579
|
-
sys: { id:
|
|
580
|
-
name: o(
|
|
581
|
-
slot: o(
|
|
582
|
-
order: o(
|
|
669
|
+
(d) => ({
|
|
670
|
+
sys: { id: d.sys.id },
|
|
671
|
+
name: o(d.fields.name),
|
|
672
|
+
slot: o(d.fields.slot),
|
|
673
|
+
order: o(d.fields.order),
|
|
583
674
|
linksCollection: {
|
|
584
|
-
items:
|
|
675
|
+
items: a.entries(d.fields.links).map((c) => b(c))
|
|
585
676
|
}
|
|
586
677
|
})
|
|
587
678
|
)
|
|
588
679
|
});
|
|
589
|
-
},
|
|
680
|
+
}, Ee = async ({
|
|
590
681
|
page: e = 1,
|
|
591
682
|
size: s = 20,
|
|
592
683
|
marketCode: i,
|
|
593
684
|
locale: l
|
|
594
685
|
} = {}) => {
|
|
595
|
-
const t =
|
|
686
|
+
const t = E(e, s), n = await r.client.getEntries(
|
|
596
687
|
{
|
|
597
688
|
content_type: "keywordCollection",
|
|
598
689
|
select: "sys.id,fields.name,fields.slot,fields.keywords",
|
|
599
690
|
include: 0,
|
|
600
691
|
order: m,
|
|
601
692
|
...t.params,
|
|
602
|
-
...
|
|
603
|
-
...
|
|
693
|
+
...p(i),
|
|
694
|
+
...f(l)
|
|
604
695
|
},
|
|
605
696
|
{ resolveLinks: !1 }
|
|
606
697
|
);
|
|
607
|
-
return new
|
|
698
|
+
return new u({
|
|
608
699
|
page: t.page,
|
|
609
700
|
total: n.total,
|
|
610
701
|
size: t.size,
|
|
611
702
|
items: n.items.map(
|
|
612
|
-
(
|
|
613
|
-
sys: { id:
|
|
614
|
-
name: o(
|
|
615
|
-
slot: o(
|
|
616
|
-
keywords: o(
|
|
703
|
+
(a) => ({
|
|
704
|
+
sys: { id: a.sys.id },
|
|
705
|
+
name: o(a.fields.name),
|
|
706
|
+
slot: o(a.fields.slot),
|
|
707
|
+
keywords: o(a.fields.keywords)
|
|
617
708
|
})
|
|
618
709
|
)
|
|
619
710
|
});
|
|
620
|
-
},
|
|
711
|
+
}, we = async ({
|
|
621
712
|
marketCode: e,
|
|
622
713
|
locale: s
|
|
623
714
|
} = {}) => {
|
|
@@ -628,8 +719,8 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
628
719
|
include: 1,
|
|
629
720
|
order: m,
|
|
630
721
|
limit: 1,
|
|
631
|
-
...
|
|
632
|
-
...
|
|
722
|
+
...p(e),
|
|
723
|
+
...f(s)
|
|
633
724
|
},
|
|
634
725
|
{ resolveLinks: !1 }
|
|
635
726
|
), l = i.items.at(0);
|
|
@@ -639,24 +730,27 @@ const m = "-sys.updatedAt", g = (e) => e ? P("market", [
|
|
|
639
730
|
sys: { id: l.sys.id },
|
|
640
731
|
title: o(l.fields.title),
|
|
641
732
|
locale: o(l.fields.locale),
|
|
642
|
-
content:
|
|
733
|
+
content: _(l.fields.content, g(i))
|
|
643
734
|
};
|
|
644
735
|
};
|
|
645
736
|
export {
|
|
646
737
|
r as ContentfulSDK,
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
738
|
+
u as PaginatedResponse,
|
|
739
|
+
ie as getBannerCollections,
|
|
740
|
+
ne as getBlogCategories,
|
|
741
|
+
ae as getBlogCategoryDetail,
|
|
742
|
+
de as getBlogCollections,
|
|
743
|
+
oe as getBlogPostDetail,
|
|
744
|
+
le as getBlogPosts,
|
|
745
|
+
ce as getBrandCollections,
|
|
746
|
+
pe as getDocArticleDetail,
|
|
747
|
+
ge as getDocArticles,
|
|
748
|
+
re as getDocCategories,
|
|
749
|
+
fe as getDocCategoryDetail,
|
|
750
|
+
ye as getHelpArticleDetail,
|
|
751
|
+
me as getHelpArticles,
|
|
752
|
+
ue as getHelpCategories,
|
|
753
|
+
he as getHyperlinkCollections,
|
|
754
|
+
Ee as getKeywordCollections,
|
|
755
|
+
we as getPolicyAndTerms
|
|
662
756
|
};
|
|
@@ -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