@se-studio/contentful-rest-api 1.0.152 → 1.0.155
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/CHANGELOG.md +24 -0
- package/README.md +20 -0
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +2 -0
- package/dist/api/context.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/tag-type.d.ts +32 -0
- package/dist/api/tag-type.d.ts.map +1 -0
- package/dist/api/tag-type.js +123 -0
- package/dist/api/tag-type.js.map +1 -0
- package/dist/baseTypes/baseTagType.d.ts +45 -0
- package/dist/baseTypes/baseTagType.d.ts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -6
- package/dist/client.js.map +1 -1
- package/dist/converters/article.d.ts.map +1 -1
- package/dist/converters/article.js +18 -5
- package/dist/converters/article.js.map +1 -1
- package/dist/converters/helpers.d.ts +7 -0
- package/dist/converters/helpers.d.ts.map +1 -1
- package/dist/converters/helpers.js.map +1 -1
- package/dist/converters/iconCollector.js +3 -3
- package/dist/converters/iconCollector.js.map +1 -1
- package/dist/converters/index.d.ts +1 -0
- package/dist/converters/index.d.ts.map +1 -1
- package/dist/converters/index.js +1 -0
- package/dist/converters/index.js.map +1 -1
- package/dist/converters/person.d.ts.map +1 -1
- package/dist/converters/person.js +10 -2
- package/dist/converters/person.js.map +1 -1
- package/dist/converters/resolver.d.ts.map +1 -1
- package/dist/converters/resolver.js +6 -5
- package/dist/converters/resolver.js.map +1 -1
- package/dist/converters/svgProcessor.js +2 -2
- package/dist/converters/svgProcessor.js.map +1 -1
- package/dist/converters/tag.d.ts +2 -2
- package/dist/converters/tag.d.ts.map +1 -1
- package/dist/converters/tag.js +51 -18
- package/dist/converters/tag.js.map +1 -1
- package/dist/converters/tagType.d.ts +8 -0
- package/dist/converters/tagType.d.ts.map +1 -0
- package/dist/converters/tagType.js +26 -0
- package/dist/converters/tagType.js.map +1 -0
- package/dist/converters/videoEnricher.d.ts.map +1 -1
- package/dist/converters/videoEnricher.js +6 -3
- package/dist/converters/videoEnricher.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/revalidation/route.js +8 -4
- package/dist/revalidation/route.js.map +1 -1
- package/dist/revalidation/server-utils.js +4 -2
- package/dist/revalidation/server-utils.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/tags.d.ts +9 -0
- package/dist/utils/tags.d.ts.map +1 -0
- package/dist/utils/tags.js +14 -0
- package/dist/utils/tags.js.map +1 -0
- package/docs/llms.md +209 -0
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
* );
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export { type AnyEntryRestResult, type ArticleTypeFetchOptions, type BreadcrumbLookup, type BreadcrumbLookupEntry, buildFetchOptions, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulAnyEntryRest, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries, contentfulAssetRest, contentfulBannerRest, contentfulComponentRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonRest, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTemplateRest, coreGetContentfulConfig, createBaseConverterContext, createSitemapProvider, type DefaultChainModifier, filterRelatedArticles, getAllSitemapEntries, getBreadcrumbLookup, getPreviewEntryInfo, type IContentfulRichText, type IFetchedTemplate, type ISitemapEntry, isBrowserViewable, type PersonFetchOptions, type PreviewContentType, type PreviewEntryInfo, type RelatedArticlesOptions, type SitemapChangeFrequency, type SitemapConfig, type SitemapContentTypeConfig, type SitemapEntryProvider, type TagFetchOptions, } from './api';
|
|
20
|
+
export { type AnyEntryRestResult, type ArticleTypeFetchOptions, type BreadcrumbLookup, type BreadcrumbLookupEntry, buildFetchOptions, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulAnyEntryRest, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries, contentfulAssetRest, contentfulBannerRest, contentfulComponentRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonRest, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTagTypeRest, contentfulTemplateRest, coreGetContentfulConfig, createBaseConverterContext, createSitemapProvider, type DefaultChainModifier, filterRelatedArticles, getAllSitemapEntries, getBreadcrumbLookup, getPreviewEntryInfo, type IContentfulRichText, type IFetchedTemplate, type ISitemapEntry, isBrowserViewable, type PersonFetchOptions, type PreviewContentType, type PreviewEntryInfo, type RelatedArticlesOptions, type SitemapChangeFrequency, type SitemapConfig, type SitemapContentTypeConfig, type SitemapEntryProvider, type TagFetchOptions, type TagTypeFetchOptions, } from './api';
|
|
21
21
|
export type { ContentfulFetchClient as ContentfulClient } from './client';
|
|
22
22
|
export { type ContentfulFetchClient, createContentfulClient, createContentfulPreviewClient, getContentfulClient, } from './client';
|
|
23
23
|
export type { ContentResolverFunction } from './converters';
|
|
24
24
|
export { type BaseConverterContext, baseCollectionConverter, baseComponentConverter, baseExternalComponentConverter, basePageConverter, type ConverterContext, calculatePageHref, calculatePageVariantHref, createResponsiveVisual, type IContentfulArticle, type IContentfulArticleLink, type IContentfulCollection, type IContentfulComponent, type IContentfulExternalComponent, type IContentfulPerson, lookupAsset, mergeAlternatePageContentsInTree, resolveLink, resolveLinks, resolveRichTextDocument, type UrlCalculators, } from './converters';
|
|
25
25
|
export { AllTags, ArticleTag, ArticleTypeTag, AssetTag, articleTag, articleTypeIndexTag, articleTypeTag, assetTag, BannerTag, CustomTypeTag, customTypeTag, GlobalTag, getCacheTags, getCacheTagsForPreview, getCacheTagsForProduction, LocationTag, locationTag, NavigationTag, PageTag, PageVariantTag, PersonTag, pageTag, pageVariantTag, personTag, TagTag, TemplateTag, tagTag, templateTag, } from './revalidation';
|
|
26
26
|
export type { CmsError, CmsResponse, ContentfulConfig, FetchOptions, RetryConfig, } from './types';
|
|
27
|
-
export { AuthenticationError, arrayOrUndefined, ContentfulError, calculateBackoffDelay, EntryNotFoundError, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, isValidDate, notEmpty, RateLimitError, RateLimiter, safeDate, ValidationError, withRetry, } from './utils';
|
|
27
|
+
export { AuthenticationError, arrayOrUndefined, ContentfulError, calculateBackoffDelay, EntryNotFoundError, getPrimaryTag, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, isValidDate, notEmpty, RateLimitError, RateLimiter, safeDate, ValidationError, withRetry, } from './utils';
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,+BAA+B,EAC/B,yBAAyB,EACzB,mCAAmC,EAEnC,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EA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AAM,SAAS,CAAC;AAEjB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,QAAQ,EACR,eAAe,EACf,SAAS,GACV,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// API functions
|
|
21
21
|
export { buildFetchOptions, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulAnyEntryRest, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries,
|
|
22
22
|
// Asset/download functions
|
|
23
|
-
contentfulAssetRest, contentfulBannerRest, contentfulComponentRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonRest, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTemplateRest, coreGetContentfulConfig, createBaseConverterContext, createSitemapProvider, filterRelatedArticles, getAllSitemapEntries, getBreadcrumbLookup,
|
|
23
|
+
contentfulAssetRest, contentfulBannerRest, contentfulComponentRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonRest, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTagTypeRest, contentfulTemplateRest, coreGetContentfulConfig, createBaseConverterContext, createSitemapProvider, filterRelatedArticles, getAllSitemapEntries, getBreadcrumbLookup,
|
|
24
24
|
// Preview
|
|
25
25
|
getPreviewEntryInfo, isBrowserViewable, } from './api';
|
|
26
26
|
// Client exports
|
|
@@ -34,5 +34,5 @@ getCacheTagsForPreview, getCacheTagsForProduction, LocationTag, locationTag, Nav
|
|
|
34
34
|
// Tag constants and functions
|
|
35
35
|
PageTag, PageVariantTag, PersonTag, pageTag, pageVariantTag, personTag, TagTag, TemplateTag, tagTag, templateTag, } from './revalidation';
|
|
36
36
|
// Error handling and retry utilities
|
|
37
|
-
export { AuthenticationError, arrayOrUndefined, ContentfulError, calculateBackoffDelay, EntryNotFoundError, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, isValidDate, notEmpty, RateLimitError, RateLimiter, safeDate, ValidationError, withRetry, } from './utils';
|
|
37
|
+
export { AuthenticationError, arrayOrUndefined, ContentfulError, calculateBackoffDelay, EntryNotFoundError, getPrimaryTag, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, isValidDate, notEmpty, RateLimitError, RateLimiter, safeDate, ValidationError, withRetry, } from './utils';
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gBAAgB;AAChB,OAAO,EAKL,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,+BAA+B,EAC/B,yBAAyB,EACzB,mCAAmC;AACnC,2BAA2B;AAC3B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EAC5B,oBAAoB,EACpB,8BAA8B,EAC9B,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EAErB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB;AACnB,UAAU;AACV,mBAAmB,EAKnB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,gBAAgB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C;AASxB,qCAAqC;AACrC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,QAAQ,EACR,eAAe,EACf,SAAS,GACV,MAAM,SAAS,CAAC"}
|
|
@@ -17,14 +17,16 @@ async function publishEntry(content, preview) {
|
|
|
17
17
|
const contentType = content.sys.contentType.sys.id;
|
|
18
18
|
const handler = contentTypeHandlers[contentType];
|
|
19
19
|
if (!handler) {
|
|
20
|
-
|
|
20
|
+
if (process.env.LOG_CMS)
|
|
21
|
+
console.warn(`Unknown content type: ${contentType}`);
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
23
24
|
return await revalidateEntry(handler, content, contentType, preview);
|
|
24
25
|
}
|
|
25
26
|
// Handle entry deletion
|
|
26
27
|
async function deleteEntry(content, preview) {
|
|
27
|
-
|
|
28
|
+
if (process.env.LOG_CMS)
|
|
29
|
+
console.log(`Delete entry: ${content.sys.id}`);
|
|
28
30
|
const contentType = content.sys.contentType.sys.id;
|
|
29
31
|
const success = await revalidateDeletedEntry(contentType, preview);
|
|
30
32
|
// Note: Search rebuild logic would go here if needed
|
|
@@ -32,7 +34,8 @@ async function deleteEntry(content, preview) {
|
|
|
32
34
|
}
|
|
33
35
|
// Revalidate all tags (for global revalidation)
|
|
34
36
|
async function revalidateAll(preview) {
|
|
35
|
-
|
|
37
|
+
if (process.env.LOG_CMS)
|
|
38
|
+
console.log('Revalidating all tags');
|
|
36
39
|
await delay(500);
|
|
37
40
|
if (preview) {
|
|
38
41
|
await revalidateSingleTag(GlobalTag, 'global revalidation');
|
|
@@ -80,7 +83,8 @@ export async function handleRevalidation(request, preview = false) {
|
|
|
80
83
|
success = await publishEntry(content, preview);
|
|
81
84
|
break;
|
|
82
85
|
default:
|
|
83
|
-
|
|
86
|
+
if (process.env.LOG_CMS)
|
|
87
|
+
console.warn(`Unknown message type: ${content.sys.type}`);
|
|
84
88
|
return NextResponse.json({ message: 'Unknown message type' }, { status: 400 });
|
|
85
89
|
}
|
|
86
90
|
if (!success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/revalidation/route.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uDAAuD;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAGL,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE5C,0BAA0B;AAC1B,KAAK,UAAU,YAAY,CAAC,OAAkB,EAAE,OAAgB;IAC9D,OAAO,MAAM,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AAED,wBAAwB;AACxB,KAAK,UAAU,WAAW,CAAC,OAAiB,EAAE,OAAgB;IAC5D,OAAO,MAAM,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,0BAA0B;AAC1B,KAAK,UAAU,YAAY,CAAC,OAAiB,EAAE,OAAgB;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/revalidation/route.ts"],"names":[],"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CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACvF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,qDAAqD;QACrD,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC"}
|
|
@@ -13,7 +13,8 @@ export async function revalidateTags(tags, reason) {
|
|
|
13
13
|
// Add a delay to prevent overwhelming the cache system
|
|
14
14
|
await delay(500);
|
|
15
15
|
for (const tag of tags) {
|
|
16
|
-
|
|
16
|
+
if (process.env.LOG_CMS)
|
|
17
|
+
console.log(`Revalidating tag: ${tag} - ${reason}`);
|
|
17
18
|
revalidateTag(tag);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -28,7 +29,8 @@ export async function revalidateTags(tags, reason) {
|
|
|
28
29
|
*/
|
|
29
30
|
export async function revalidateSingleTag(tag, reason) {
|
|
30
31
|
await delay(500);
|
|
31
|
-
|
|
32
|
+
if (process.env.LOG_CMS)
|
|
33
|
+
console.log(`Revalidating single tag: ${tag} - ${reason}`);
|
|
32
34
|
revalidateTag(tag);
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-utils.js","sourceRoot":"","sources":["../../src/revalidation/server-utils.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc,EAAE,MAAc;IACjE,uDAAuD;IACvD,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAM,MAAM,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"server-utils.js","sourceRoot":"","sources":["../../src/revalidation/server-utils.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc,EAAE,MAAc;IACjE,uDAAuD;IACvD,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAM,MAAM,EAAE,CAAC,CAAC;QAC7E,aAAa,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW,EAAE,MAAc;IACnE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,MAAM,MAAM,EAAE,CAAC,CAAC;IACpF,aAAa,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { arrayOrUndefined, notEmpty } from './arrayUtils';
|
|
|
5
5
|
export { isValidDate, safeDate } from './dateUtils';
|
|
6
6
|
export { AuthenticationError, ContentfulError, EntryNotFoundError, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, RateLimitError, ValidationError, } from './errors';
|
|
7
7
|
export { calculateBackoffDelay, RateLimiter, withRetry, } from './retry';
|
|
8
|
+
export { getPrimaryTag } from './tags';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -5,4 +5,5 @@ export { arrayOrUndefined, notEmpty } from './arrayUtils';
|
|
|
5
5
|
export { isValidDate, safeDate } from './dateUtils';
|
|
6
6
|
export { AuthenticationError, ContentfulError, EntryNotFoundError, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, RateLimitError, ValidationError, } from './errors';
|
|
7
7
|
export { calculateBackoffDelay, RateLimiter, withRetry, } from './retry';
|
|
8
|
+
export { getPrimaryTag } from './tags';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ITagLink } from '@se-studio/core-data-types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the primary tag for an article.
|
|
4
|
+
*
|
|
5
|
+
* When tagTypeSlug is provided, finds the first tag whose tagType.slug matches.
|
|
6
|
+
* Falls back to tags[0] if no match or no slug given — preserving existing behaviour.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPrimaryTag(tags: ReadonlyArray<ITagLink> | undefined, tagTypeSlug?: string): ITagLink | undefined;
|
|
9
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/utils/tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,SAAS,EACzC,WAAW,CAAC,EAAE,MAAM,GACnB,QAAQ,GAAG,SAAS,CAItB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the primary tag for an article.
|
|
3
|
+
*
|
|
4
|
+
* When tagTypeSlug is provided, finds the first tag whose tagType.slug matches.
|
|
5
|
+
* Falls back to tags[0] if no match or no slug given — preserving existing behaviour.
|
|
6
|
+
*/
|
|
7
|
+
export function getPrimaryTag(tags, tagTypeSlug) {
|
|
8
|
+
if (!tags?.length)
|
|
9
|
+
return undefined;
|
|
10
|
+
if (!tagTypeSlug)
|
|
11
|
+
return tags[0];
|
|
12
|
+
return tags.find((tag) => tag.tagType?.slug === tagTypeSlug) ?? tags[0];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/utils/tags.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAyC,EACzC,WAAoB;IAEpB,IAAI,CAAC,IAAI,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IACpC,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,WAAW,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
package/docs/llms.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @se-studio/contentful-rest-api — LLM Reference
|
|
2
|
+
|
|
3
|
+
Type-safe Contentful REST API client for Next.js App Router applications. Handles fetching, caching, rate limiting, and content conversion.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { coreGetContentfulConfig } from '@se-studio/contentful-rest-api';
|
|
9
|
+
|
|
10
|
+
// Reads CONTENTFUL_SPACE_ID, CONTENTFUL_ACCESS_TOKEN, CONTENTFUL_ENVIRONMENT from env
|
|
11
|
+
const config = coreGetContentfulConfig();
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or build manually:
|
|
15
|
+
```ts
|
|
16
|
+
import type { ContentfulConfig } from '@se-studio/contentful-rest-api';
|
|
17
|
+
|
|
18
|
+
const config: ContentfulConfig = {
|
|
19
|
+
spaceId: process.env.CONTENTFUL_SPACE_ID!,
|
|
20
|
+
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!, // delivery token
|
|
21
|
+
previewAccessToken: process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN, // optional
|
|
22
|
+
environment: process.env.CONTENTFUL_ENVIRONMENT ?? 'master',
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Primary Fetch Functions
|
|
27
|
+
|
|
28
|
+
All functions share the signature `fn(config, identifier, options?)`.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
contentfulPageRest,
|
|
33
|
+
contentfulArticleRest,
|
|
34
|
+
contentfulArticleTypeRest,
|
|
35
|
+
contentfulNavigationRest, // via contentfulAnyEntryRest
|
|
36
|
+
contentfulTagRest,
|
|
37
|
+
contentfulTagTypeRest,
|
|
38
|
+
contentfulPersonRest,
|
|
39
|
+
contentfulBannerRest,
|
|
40
|
+
contentfulTemplateRest,
|
|
41
|
+
contentfulComponentRest,
|
|
42
|
+
contentfulCustomTypeRest,
|
|
43
|
+
contentfulAssetRest,
|
|
44
|
+
contentfulAnyEntryRest, // generic fallback by entry ID
|
|
45
|
+
} from '@se-studio/contentful-rest-api';
|
|
46
|
+
|
|
47
|
+
// Fetch a page by slug
|
|
48
|
+
const page = await contentfulPageRest(config, 'home', {
|
|
49
|
+
preview: false,
|
|
50
|
+
cache: { tags: ['page#home'], revalidate: 3600 },
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Fetch an article by slug
|
|
54
|
+
const article = await contentfulArticleRest(config, 'my-article-slug', {
|
|
55
|
+
cache: { tags: ['article#my-article-slug'], revalidate: 3600 },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Fetch all links (for sitemaps / related content)
|
|
59
|
+
const allPageLinks = await contentfulAllPageLinks(config);
|
|
60
|
+
const allArticleLinks = await contentfulAllArticleLinks(config);
|
|
61
|
+
const allTagLinks = await contentfulAllTagLinks(config);
|
|
62
|
+
const allPersonLinks = await contentfulAllPersonLinks(config);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Sitemap Helpers
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import {
|
|
69
|
+
contentfulPageSitemapEntries,
|
|
70
|
+
contentfulArticleSitemapEntries,
|
|
71
|
+
contentfulArticleTypeSitemapEntries,
|
|
72
|
+
contentfulTagSitemapEntries,
|
|
73
|
+
contentfulPersonSitemapEntries,
|
|
74
|
+
getAllSitemapEntries,
|
|
75
|
+
createSitemapProvider,
|
|
76
|
+
} from '@se-studio/contentful-rest-api';
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## FetchOptions
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
interface FetchOptions {
|
|
83
|
+
preview?: boolean; // use preview API (default: false)
|
|
84
|
+
locale?: string; // Contentful locale (default: 'en-US')
|
|
85
|
+
cache?: {
|
|
86
|
+
tags?: string[]; // Next.js cache tags for revalidation
|
|
87
|
+
revalidate?: number; // seconds; 0 = no cache
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Cache Tags (for revalidation)
|
|
93
|
+
|
|
94
|
+
Use these tag helpers to generate consistent cache tag strings:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import {
|
|
98
|
+
pageTag, // pageTag('home') → 'page#home'
|
|
99
|
+
articleTag, // articleTag('slug') → 'article#slug'
|
|
100
|
+
articleTypeTag, // articleTypeTag('news') → 'article-type#news'
|
|
101
|
+
tagTag, // tagTag('slug') → 'tag#slug'
|
|
102
|
+
personTag,
|
|
103
|
+
pageVariantTag,
|
|
104
|
+
locationTag,
|
|
105
|
+
templateTag,
|
|
106
|
+
customTypeTag,
|
|
107
|
+
assetTag,
|
|
108
|
+
// Constants
|
|
109
|
+
PageTag, ArticleTag, NavigationTag, BannerTag, GlobalTag, AllTags,
|
|
110
|
+
} from '@se-studio/contentful-rest-api';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Converter Pattern
|
|
114
|
+
|
|
115
|
+
Used to extend how Contentful entries are transformed into typed models. You typically call `createBaseConverterContext()` and pass it via `buildFetchOptions`.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import {
|
|
119
|
+
createBaseConverterContext,
|
|
120
|
+
buildFetchOptions,
|
|
121
|
+
basePageConverter,
|
|
122
|
+
baseComponentConverter,
|
|
123
|
+
baseCollectionConverter,
|
|
124
|
+
} from '@se-studio/contentful-rest-api';
|
|
125
|
+
|
|
126
|
+
const context = createBaseConverterContext();
|
|
127
|
+
// extend context.resolvers if you need custom content types
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Base converters available:
|
|
131
|
+
- `basePageConverter` — converts page entries
|
|
132
|
+
- `baseComponentConverter` — converts component entries
|
|
133
|
+
- `baseCollectionConverter` — converts collection entries
|
|
134
|
+
- `baseExternalComponentConverter`
|
|
135
|
+
- `baseArticleConverter`, `baseArticleTypeConverter`
|
|
136
|
+
- `basePersonConverter`
|
|
137
|
+
- `baseTagConverter`, `baseTagTypeConverter`
|
|
138
|
+
- `baseBannerConverter`
|
|
139
|
+
|
|
140
|
+
## Preview
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { getPreviewEntryInfo } from '@se-studio/contentful-rest-api';
|
|
144
|
+
|
|
145
|
+
// Returns entry ID, content type, and field info for Contentful live preview
|
|
146
|
+
const info = await getPreviewEntryInfo(config, entryId);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Error Handling
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import {
|
|
153
|
+
isContentfulError,
|
|
154
|
+
isRateLimitError,
|
|
155
|
+
EntryNotFoundError,
|
|
156
|
+
AuthenticationError,
|
|
157
|
+
RateLimitError,
|
|
158
|
+
withRetry,
|
|
159
|
+
} from '@se-studio/contentful-rest-api';
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Rich Text
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import type { IContentfulRichText } from '@se-studio/contentful-rest-api';
|
|
166
|
+
// Use with core-ui's RTF component
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Primary Tag Selection
|
|
170
|
+
|
|
171
|
+
Articles have multiple tags. `getPrimaryTag` picks the right one by tagType slug instead of relying on array order.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { getPrimaryTag } from '@se-studio/contentful-rest-api';
|
|
175
|
+
|
|
176
|
+
// In app code — select primary tag for display or routing
|
|
177
|
+
const primaryTag = getPrimaryTag(article.tags, 'disease-area');
|
|
178
|
+
// Falls back to tags[0] if no match, or no tagTypeSlug given
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
To also fix the generated `article.href` URL, pass `primaryTagTypeSlug` when building the converter context:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
const context = createBaseConverterContext({
|
|
185
|
+
...config,
|
|
186
|
+
primaryTagTypeSlug: 'disease-area',
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`ITagLink` now carries `tagType?: { id, name, slug }` so tagType-based selection works without a full tag fetch.
|
|
191
|
+
|
|
192
|
+
## Utility Functions
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import {
|
|
196
|
+
getPrimaryTag, // select primary tag from article.tags by tagType slug
|
|
197
|
+
notEmpty, // array filter: arr.filter(notEmpty)
|
|
198
|
+
arrayOrUndefined, // returns array or undefined if empty
|
|
199
|
+
safeDate, // parse date string safely
|
|
200
|
+
isValidDate,
|
|
201
|
+
} from '@se-studio/contentful-rest-api';
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Important Constraints
|
|
205
|
+
|
|
206
|
+
- Always supply `spaceId`, `accessToken`, and `environment`.
|
|
207
|
+
- For Next.js: pass `cache.tags` and `cache.revalidate` so pages can be revalidated via Contentful webhooks.
|
|
208
|
+
- For preview mode, also supply `previewAccessToken` and pass `{ preview: true }` in options.
|
|
209
|
+
- `contentfulNavigationRest` is not a direct export — navigation is fetched via `contentfulAnyEntryRest` or via the app's `cms-server`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/contentful-rest-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.155",
|
|
4
4
|
"description": "Type-safe Contentful REST API client with caching and rate limiting for Next.js applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
-
"*.md"
|
|
26
|
+
"*.md",
|
|
27
|
+
"docs"
|
|
27
28
|
],
|
|
28
29
|
"keywords": [
|
|
29
30
|
"contentful",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"@contentful/rich-text-types": "^17.2.7",
|
|
51
52
|
"contentful": "^11.12.2",
|
|
52
53
|
"server-only": "0.0.1",
|
|
53
|
-
"@se-studio/core-data-types": "1.0.
|
|
54
|
+
"@se-studio/core-data-types": "1.0.148"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"next": ">=15.5.0"
|