@janbox/contentful-marketplace-sdk 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entries/brand.d.ts +3 -0
- package/dist/entries/footer-content.d.ts +21 -0
- package/dist/entries/footer-menu.d.ts +1 -1
- package/dist/entries/index.d.ts +1 -0
- package/dist/index.cjs +38 -19
- package/dist/index.js +56 -25
- package/dist/types/index.d.ts +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Entry } from 'contentful';
|
|
2
|
+
import { TypeFooterContentSkeleton } from '../types';
|
|
3
|
+
import { BrandEntry } from './brand';
|
|
4
|
+
type FooterContentEntry = Entry<TypeFooterContentSkeleton, "WITHOUT_UNRESOLVABLE_LINKS", string>;
|
|
5
|
+
type FooterContentGraphQLResponse = {
|
|
6
|
+
footerContentCollection: {
|
|
7
|
+
items: Array<{
|
|
8
|
+
brandsCollection: {
|
|
9
|
+
items: Array<Pick<BrandEntry["fields"], "name" | "slug">>;
|
|
10
|
+
};
|
|
11
|
+
} & Pick<FooterContentEntry["fields"], "keywords">>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type ListFooterContentEntryResponse = {
|
|
15
|
+
data?: FooterContentGraphQLResponse["footerContentCollection"]["items"][0];
|
|
16
|
+
};
|
|
17
|
+
export declare const listFooterContentEntry: ({ marketId, language, }: {
|
|
18
|
+
marketId: string;
|
|
19
|
+
language: string;
|
|
20
|
+
}) => Promise<ListFooterContentEntryResponse>;
|
|
21
|
+
export {};
|
|
@@ -11,7 +11,7 @@ export type FooterMenuGraphQLResponse = {
|
|
|
11
11
|
sys: EntrySys;
|
|
12
12
|
} & Pick<HyperlinkEntry["fields"], "label" | "url" | "target" | "basePath">>;
|
|
13
13
|
};
|
|
14
|
-
} & Pick<FooterMenuEntry["fields"], "name">>;
|
|
14
|
+
} & Pick<FooterMenuEntry["fields"], "name" | "order">>;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export declare const listFooterMenuEntries: ({ marketId, language, }: {
|
package/dist/entries/index.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
${d}`)}const l=await a.json();if(l.errors)throw new Error(`GraphQL errors: ${JSON.stringify(l.errors,null,2)}`);return l.data}}const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("contentful");class i{static _client;static _clientParams;static get clientParams(){if(!this._clientParams)throw new Error("Client is not configured");return this._clientParams}static get client(){return this._client||(this._client=g.createClient(this.clientParams)),this._client}static configure(e){this._clientParams={...e,environment:e.environment??"master"}}static async graphqlQuery(e,s={}){const{space:n,accessToken:r,environment:c="master"}=this.clientParams,a=await fetch(`https://graphql.contentful.com/content/v1/spaces/${n}/environments/${c}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({query:e,variables:s})});if(!a.ok){const d=await a.text();throw new Error(`GraphQL request failed: ${a.status} ${a.statusText}
|
|
2
|
+
${d}`)}const l=await a.json();if(l.errors)throw new Error(`GraphQL errors: ${JSON.stringify(l.errors,null,2)}`);return l.data}}const y=async({query:t,marketId:e,language:s})=>i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,...t,content_type:"banner"});class o extends Response{constructor(...e){super(e[0]??"Not Found",{status:404,...e[1]})}}const u=async({query:t,marketId:e,language:s})=>i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,select:["fields.title","fields.category","fields.slug","fields.featuredImage","fields.shortDescription"],content_type:"blogPost",...t}),f=async({query:t,marketId:e,language:s})=>{const n=await i.client.withoutUnresolvableLinks.getEntries({select:["fields.title","fields.category","fields.slug","fields.featuredImage","fields.shortDescription","fields.author","fields.content","fields.seo","sys.updatedAt"],"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,content_type:"blogPost",limit:1,...t}).then(r=>r.items.at(0));if(!n)throw new o;return n},m=async({query:t,marketId:e,language:s})=>i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,...t,content_type:"documentationCategory"}),k=async({query:t,marketId:e,language:s})=>{const n=await i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,...t,content_type:"documentationCategory",limit:1}).then(r=>r.items.at(0));if(!n)throw new o;return n},h=({query:t,marketId:e,language:s})=>i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,...t,content_type:"documentationArticle"}),p=async({query:t,marketId:e,language:s})=>{const n=await i.client.withoutUnresolvableLinks.getEntries({"fields.market.sys.contentType.sys.id":"market","fields.market.fields.marketId":e,"fields.language.sys.contentType.sys.id":"language","fields.language.fields.code":s,...t,content_type:"documentationArticle",limit:1}).then(r=>r.items.at(0));if(!n)throw new o;return n},w=async({marketId:t,language:e})=>i.graphqlQuery(`
|
|
3
3
|
query ($marketId: String!, $language: String!) {
|
|
4
|
-
footerMenuCollection(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
market: {
|
|
11
|
-
marketId: $marketId
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
language: {
|
|
16
|
-
code: $language
|
|
4
|
+
footerMenuCollection(
|
|
5
|
+
where: {
|
|
6
|
+
AND: [
|
|
7
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
8
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
9
|
+
]
|
|
17
10
|
}
|
|
18
|
-
|
|
11
|
+
) {
|
|
19
12
|
items {
|
|
20
|
-
sys {
|
|
13
|
+
sys {
|
|
14
|
+
id
|
|
15
|
+
}
|
|
21
16
|
name
|
|
22
17
|
childrenCollection {
|
|
23
18
|
items {
|
|
24
|
-
sys {
|
|
19
|
+
sys {
|
|
20
|
+
id
|
|
21
|
+
}
|
|
25
22
|
label
|
|
26
23
|
url
|
|
27
24
|
target
|
|
@@ -31,4 +28,26 @@ query ($marketId: String!, $language: String!) {
|
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
|
-
`,{marketId:t,language:e})
|
|
31
|
+
`,{marketId:t,language:e}),E=async({marketId:t,language:e})=>{const s=`
|
|
32
|
+
query ($marketId: String!, $language: String!) {
|
|
33
|
+
footerContentCollection(
|
|
34
|
+
where: {
|
|
35
|
+
AND: [
|
|
36
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
37
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
limit: 1
|
|
41
|
+
) {
|
|
42
|
+
items {
|
|
43
|
+
brandsCollection {
|
|
44
|
+
items {
|
|
45
|
+
name
|
|
46
|
+
slug
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
keywords
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`,{footerContentCollection:n}=await i.graphqlQuery(s,{marketId:t,language:e});return{data:n.items.at(0)}};exports.ContentfulSDK=i;exports.findBlogPostEntry=f;exports.findDocArticleEntry=p;exports.findDocCategoryEntry=k;exports.listBannerEntries=y;exports.listBlogPostEntries=u;exports.listDocArticleEntries=h;exports.listDocCategoryEntries=m;exports.listFooterContentEntry=E;exports.listFooterMenuEntries=w;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClient as
|
|
1
|
+
import { createClient as g } from "contentful";
|
|
2
2
|
class i {
|
|
3
3
|
static _client;
|
|
4
4
|
static _clientParams;
|
|
@@ -9,7 +9,7 @@ class i {
|
|
|
9
9
|
return this._clientParams;
|
|
10
10
|
}
|
|
11
11
|
static get client() {
|
|
12
|
-
return this._client || (this._client =
|
|
12
|
+
return this._client || (this._client = g(this.clientParams)), this._client;
|
|
13
13
|
}
|
|
14
14
|
static configure(e) {
|
|
15
15
|
this._clientParams = {
|
|
@@ -44,7 +44,7 @@ ${d}`
|
|
|
44
44
|
return l.data;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const u = async ({
|
|
48
48
|
query: t,
|
|
49
49
|
marketId: e,
|
|
50
50
|
language: s
|
|
@@ -66,7 +66,7 @@ class o extends Response {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
const
|
|
69
|
+
const f = async ({
|
|
70
70
|
query: t,
|
|
71
71
|
marketId: e,
|
|
72
72
|
language: s
|
|
@@ -174,32 +174,29 @@ const u = async ({
|
|
|
174
174
|
if (!n)
|
|
175
175
|
throw new o();
|
|
176
176
|
return n;
|
|
177
|
-
},
|
|
177
|
+
}, E = async ({
|
|
178
178
|
marketId: t,
|
|
179
179
|
language: e
|
|
180
180
|
}) => i.graphqlQuery(`
|
|
181
181
|
query ($marketId: String!, $language: String!) {
|
|
182
|
-
footerMenuCollection(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
market: {
|
|
189
|
-
marketId: $marketId
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
],
|
|
193
|
-
language: {
|
|
194
|
-
code: $language
|
|
182
|
+
footerMenuCollection(
|
|
183
|
+
where: {
|
|
184
|
+
AND: [
|
|
185
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
186
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
187
|
+
]
|
|
195
188
|
}
|
|
196
|
-
|
|
189
|
+
) {
|
|
197
190
|
items {
|
|
198
|
-
sys {
|
|
191
|
+
sys {
|
|
192
|
+
id
|
|
193
|
+
}
|
|
199
194
|
name
|
|
200
195
|
childrenCollection {
|
|
201
196
|
items {
|
|
202
|
-
sys {
|
|
197
|
+
sys {
|
|
198
|
+
id
|
|
199
|
+
}
|
|
203
200
|
label
|
|
204
201
|
url
|
|
205
202
|
target
|
|
@@ -212,15 +209,49 @@ query ($marketId: String!, $language: String!) {
|
|
|
212
209
|
`, {
|
|
213
210
|
marketId: t,
|
|
214
211
|
language: e
|
|
215
|
-
})
|
|
212
|
+
}), T = async ({
|
|
213
|
+
marketId: t,
|
|
214
|
+
language: e
|
|
215
|
+
}) => {
|
|
216
|
+
const s = `
|
|
217
|
+
query ($marketId: String!, $language: String!) {
|
|
218
|
+
footerContentCollection(
|
|
219
|
+
where: {
|
|
220
|
+
AND: [
|
|
221
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
222
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
limit: 1
|
|
226
|
+
) {
|
|
227
|
+
items {
|
|
228
|
+
brandsCollection {
|
|
229
|
+
items {
|
|
230
|
+
name
|
|
231
|
+
slug
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
keywords
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
`, { footerContentCollection: n } = await i.graphqlQuery(s, {
|
|
239
|
+
marketId: t,
|
|
240
|
+
language: e
|
|
241
|
+
});
|
|
242
|
+
return {
|
|
243
|
+
data: n.items.at(0)
|
|
244
|
+
};
|
|
245
|
+
};
|
|
216
246
|
export {
|
|
217
247
|
i as ContentfulSDK,
|
|
218
248
|
m as findBlogPostEntry,
|
|
219
249
|
w as findDocArticleEntry,
|
|
220
250
|
h as findDocCategoryEntry,
|
|
221
|
-
|
|
222
|
-
|
|
251
|
+
u as listBannerEntries,
|
|
252
|
+
f as listBlogPostEntries,
|
|
223
253
|
p as listDocArticleEntries,
|
|
224
254
|
k as listDocCategoryEntries,
|
|
225
|
-
T as
|
|
255
|
+
T as listFooterContentEntry,
|
|
256
|
+
E as listFooterMenuEntries
|
|
226
257
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -41,6 +41,13 @@ export interface TypeBlogPostFields {
|
|
|
41
41
|
}
|
|
42
42
|
export type TypeBlogPostSkeleton = EntrySkeletonType<TypeBlogPostFields, "blogPost">;
|
|
43
43
|
export type TypeBlogPost<Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Entry<TypeBlogPostSkeleton, Modifiers, Locales>;
|
|
44
|
+
export interface TypeBrandFields {
|
|
45
|
+
name: EntryFieldTypes.Symbol;
|
|
46
|
+
slug: EntryFieldTypes.Symbol;
|
|
47
|
+
logo?: EntryFieldTypes.AssetLink;
|
|
48
|
+
}
|
|
49
|
+
export type TypeBrandSkeleton = EntrySkeletonType<TypeBrandFields, "brand">;
|
|
50
|
+
export type TypeBrand<Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Entry<TypeBrandSkeleton, Modifiers, Locales>;
|
|
44
51
|
export interface TypeComponentSvgFields {
|
|
45
52
|
name: EntryFieldTypes.Symbol;
|
|
46
53
|
source: EntryFieldTypes.Text;
|
|
@@ -71,11 +78,21 @@ export interface TypeDocumentationCategoryFields {
|
|
|
71
78
|
}
|
|
72
79
|
export type TypeDocumentationCategorySkeleton = EntrySkeletonType<TypeDocumentationCategoryFields, "documentationCategory">;
|
|
73
80
|
export type TypeDocumentationCategory<Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Entry<TypeDocumentationCategorySkeleton, Modifiers, Locales>;
|
|
81
|
+
export interface TypeFooterContentFields {
|
|
82
|
+
title: EntryFieldTypes.Symbol;
|
|
83
|
+
market?: EntryFieldTypes.EntryLink<TypeMarketSkeleton>;
|
|
84
|
+
language?: EntryFieldTypes.EntryLink<TypeLanguageSkeleton>;
|
|
85
|
+
brands?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<TypeBrandSkeleton>>;
|
|
86
|
+
keywords?: EntryFieldTypes.Array<EntryFieldTypes.Symbol>;
|
|
87
|
+
}
|
|
88
|
+
export type TypeFooterContentSkeleton = EntrySkeletonType<TypeFooterContentFields, "footerContent">;
|
|
89
|
+
export type TypeFooterContent<Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Entry<TypeFooterContentSkeleton, Modifiers, Locales>;
|
|
74
90
|
export interface TypeFooterMenuFields {
|
|
75
91
|
name: EntryFieldTypes.Symbol;
|
|
76
92
|
children: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<TypeHyperlinkSkeleton>>;
|
|
77
93
|
language: EntryFieldTypes.EntryLink<TypeLanguageSkeleton>;
|
|
78
94
|
market?: EntryFieldTypes.EntryLink<TypeMarketSkeleton>;
|
|
95
|
+
order: EntryFieldTypes.Integer;
|
|
79
96
|
}
|
|
80
97
|
export type TypeFooterMenuSkeleton = EntrySkeletonType<TypeFooterMenuFields, "footerMenu">;
|
|
81
98
|
export type TypeFooterMenu<Modifiers extends ChainModifiers, Locales extends LocaleCode = LocaleCode> = Entry<TypeFooterMenuSkeleton, Modifiers, Locales>;
|