@janbox/contentful-marketplace-sdk 0.0.7 → 0.0.9
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 +8 -4
- package/dist/entries/index.d.ts +1 -0
- package/dist/index.cjs +39 -19
- package/dist/index.js +64 -27
- 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 {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Entry, EntrySys } from 'contentful';
|
|
2
2
|
import { TypeFooterMenuSkeleton } from '../types';
|
|
3
3
|
import { HyperlinkEntry } from './hyperlink';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type FooterMenuEntry = Entry<TypeFooterMenuSkeleton, "WITHOUT_UNRESOLVABLE_LINKS", string>;
|
|
5
|
+
type FooterMenuGraphQLResponse = {
|
|
6
6
|
footerMenuCollection: {
|
|
7
7
|
items: Array<{
|
|
8
8
|
sys: EntrySys;
|
|
@@ -11,10 +11,14 @@ 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
|
+
export type ListFooterMenuEntriesResponse = {
|
|
18
|
+
data: FooterMenuGraphQLResponse["footerMenuCollection"]["items"];
|
|
19
|
+
};
|
|
17
20
|
export declare const listFooterMenuEntries: ({ marketId, language, }: {
|
|
18
21
|
marketId: string;
|
|
19
22
|
language: string;
|
|
20
|
-
}) => Promise<
|
|
23
|
+
}) => Promise<ListFooterMenuEntriesResponse>;
|
|
24
|
+
export {};
|
package/dist/entries/index.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
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})=>{const s=`
|
|
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
|
|
17
|
+
order
|
|
22
18
|
childrenCollection {
|
|
23
19
|
items {
|
|
24
|
-
sys {
|
|
20
|
+
sys {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
25
23
|
label
|
|
26
24
|
url
|
|
27
25
|
target
|
|
@@ -31,4 +29,26 @@ query ($marketId: String!, $language: String!) {
|
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
`,{marketId:t,language:e});
|
|
32
|
+
`,{footerMenuCollection:n}=await i.graphqlQuery(s,{marketId:t,language:e});return{data:n.items}},E=async({marketId:t,language:e})=>{const s=`
|
|
33
|
+
query ($marketId: String!, $language: String!) {
|
|
34
|
+
footerContentCollection(
|
|
35
|
+
where: {
|
|
36
|
+
AND: [
|
|
37
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
38
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
limit: 1
|
|
42
|
+
) {
|
|
43
|
+
items {
|
|
44
|
+
brandsCollection {
|
|
45
|
+
items {
|
|
46
|
+
name
|
|
47
|
+
slug
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
keywords
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`,{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,31 @@ 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
|
+
}) => {
|
|
181
|
+
const s = `
|
|
181
182
|
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
|
|
183
|
+
footerMenuCollection(
|
|
184
|
+
where: {
|
|
185
|
+
AND: [
|
|
186
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
187
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
188
|
+
]
|
|
195
189
|
}
|
|
196
|
-
|
|
190
|
+
) {
|
|
197
191
|
items {
|
|
198
|
-
sys {
|
|
192
|
+
sys {
|
|
193
|
+
id
|
|
194
|
+
}
|
|
199
195
|
name
|
|
196
|
+
order
|
|
200
197
|
childrenCollection {
|
|
201
198
|
items {
|
|
202
|
-
sys {
|
|
199
|
+
sys {
|
|
200
|
+
id
|
|
201
|
+
}
|
|
203
202
|
label
|
|
204
203
|
url
|
|
205
204
|
target
|
|
@@ -209,18 +208,56 @@ query ($marketId: String!, $language: String!) {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
|
-
`, {
|
|
211
|
+
`, { footerMenuCollection: n } = await i.graphqlQuery(s, {
|
|
212
|
+
marketId: t,
|
|
213
|
+
language: e
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
data: n.items
|
|
217
|
+
};
|
|
218
|
+
}, T = async ({
|
|
213
219
|
marketId: t,
|
|
214
220
|
language: e
|
|
215
|
-
})
|
|
221
|
+
}) => {
|
|
222
|
+
const s = `
|
|
223
|
+
query ($marketId: String!, $language: String!) {
|
|
224
|
+
footerContentCollection(
|
|
225
|
+
where: {
|
|
226
|
+
AND: [
|
|
227
|
+
{ OR: [{ market_exists: false }, { market: { marketId: $marketId } }] }
|
|
228
|
+
{ OR: [{ language_exists: false }, { language: { code: $language } }] }
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
limit: 1
|
|
232
|
+
) {
|
|
233
|
+
items {
|
|
234
|
+
brandsCollection {
|
|
235
|
+
items {
|
|
236
|
+
name
|
|
237
|
+
slug
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
keywords
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`, { footerContentCollection: n } = await i.graphqlQuery(s, {
|
|
245
|
+
marketId: t,
|
|
246
|
+
language: e
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
data: n.items.at(0)
|
|
250
|
+
};
|
|
251
|
+
};
|
|
216
252
|
export {
|
|
217
253
|
i as ContentfulSDK,
|
|
218
254
|
m as findBlogPostEntry,
|
|
219
255
|
w as findDocArticleEntry,
|
|
220
256
|
h as findDocCategoryEntry,
|
|
221
|
-
|
|
222
|
-
|
|
257
|
+
u as listBannerEntries,
|
|
258
|
+
f as listBlogPostEntries,
|
|
223
259
|
p as listDocArticleEntries,
|
|
224
260
|
k as listDocCategoryEntries,
|
|
225
|
-
T as
|
|
261
|
+
T as listFooterContentEntry,
|
|
262
|
+
E as listFooterMenuEntries
|
|
226
263
|
};
|
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>;
|