@se-studio/contentful-rest-api 1.0.35 → 1.0.37
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/index.d.ts +57 -42
- package/dist/index.js +389 -62
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBaseArticle, IBaseArticleType, BaseCollectionContent, IBaseCollection, IBaseComponent, IBaseCustomType, INavigationItem, IBasePage, IBaseTag, IInternalLink, IVisual,
|
|
1
|
+
import { IBasePerson, IBaseArticle, IBaseArticleType, BaseCollectionContent, IBaseCollection, IBaseComponent, IBaseCustomType, INavigationItem, IBasePage, IBaseTag, IInternalLink, IVisual, INavigation, IArticleLink, IArticleTypeLink, ITyped, ISvgImage, IResponsiveVisual } from '@se-studio/core-data-types';
|
|
2
2
|
import * as contentful from 'contentful';
|
|
3
3
|
import { EntrySkeletonType, EntryFieldTypes, Entry, Asset, UnresolvedLink } from 'contentful';
|
|
4
4
|
import { Document } from '@contentful/rich-text-types';
|
|
@@ -39,37 +39,9 @@ interface BaseMediaFields {
|
|
|
39
39
|
}
|
|
40
40
|
type BaseMediaSkeleton = EntrySkeletonType<BaseMediaFields, 'media'>;
|
|
41
41
|
|
|
42
|
-
interface BaseNavigationItemFields {
|
|
43
|
-
title: EntryFieldTypes.Symbol;
|
|
44
|
-
useTitle: EntryFieldTypes.Boolean;
|
|
45
|
-
navigationItems?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<BaseNavigationItemSkeleton>>;
|
|
46
|
-
text?: EntryFieldTypes.Symbol;
|
|
47
|
-
internal?: EntryFieldTypes.EntryLink<BaseLink>;
|
|
48
|
-
link?: EntryFieldTypes.Symbol;
|
|
49
|
-
isButton?: EntryFieldTypes.Boolean;
|
|
50
|
-
isOutlined?: EntryFieldTypes.Boolean;
|
|
51
|
-
backgroundColour?: EntryFieldTypes.Symbol<string>;
|
|
52
|
-
textColour?: EntryFieldTypes.Symbol<string>;
|
|
53
|
-
icon?: EntryFieldTypes.AssetLink;
|
|
54
|
-
mobileIcon?: EntryFieldTypes.AssetLink;
|
|
55
|
-
variant?: EntryFieldTypes.Symbol<string>;
|
|
56
|
-
size?: EntryFieldTypes.Symbol<string>;
|
|
57
|
-
longText?: EntryFieldTypes.RichText;
|
|
58
|
-
}
|
|
59
|
-
type BaseNavigationItemSkeleton = EntrySkeletonType<BaseNavigationItemFields, 'navigationItem'>;
|
|
60
|
-
|
|
61
|
-
interface BaseNavigationFields {
|
|
62
|
-
adminLabel: EntryFieldTypes.Symbol;
|
|
63
|
-
name: EntryFieldTypes.Symbol;
|
|
64
|
-
backgroundColour?: EntryFieldTypes.Symbol<string>;
|
|
65
|
-
textColour?: EntryFieldTypes.Symbol<string>;
|
|
66
|
-
entries?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<BaseNavigationItemSkeleton>>;
|
|
67
|
-
}
|
|
68
|
-
type BaseNavigationSkeleton = EntrySkeletonType<BaseNavigationFields, 'navigation'>;
|
|
69
|
-
|
|
70
42
|
interface BaseSchemaFields {
|
|
71
43
|
cmsLabel: EntryFieldTypes.Symbol;
|
|
72
|
-
markup
|
|
44
|
+
markup?: EntryFieldTypes.Text;
|
|
73
45
|
}
|
|
74
46
|
type BaseSchemaSkeleton = EntrySkeletonType<BaseSchemaFields, 'schema'>;
|
|
75
47
|
|
|
@@ -317,6 +289,37 @@ interface BasePageVariantFields {
|
|
|
317
289
|
}
|
|
318
290
|
type BasePageVariantSkeleton = EntrySkeletonType<BasePageVariantFields, 'pageVariant'>;
|
|
319
291
|
|
|
292
|
+
type BaseContent = BaseCollectionSkeleton | BaseComponentSkeleton | BaseExternalComponentSkeleton | BaseExternalVideoSkeleton | BaseMediaSkeleton | BasePersonSkeleton;
|
|
293
|
+
type BaseLink = BaseArticleSkeleton | BaseArticleTypeSkeleton | BaseLinkSkeleton | BasePageSkeleton | BasePageVariantSkeleton | BasePersonSkeleton | BaseTagSkeleton | BaseCustomTypeSkeleton;
|
|
294
|
+
|
|
295
|
+
interface BaseNavigationItemFields {
|
|
296
|
+
title: EntryFieldTypes.Symbol;
|
|
297
|
+
useTitle: EntryFieldTypes.Boolean;
|
|
298
|
+
navigationItems?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<BaseNavigationItemSkeleton>>;
|
|
299
|
+
text?: EntryFieldTypes.Symbol;
|
|
300
|
+
internal?: EntryFieldTypes.EntryLink<BaseLink>;
|
|
301
|
+
link?: EntryFieldTypes.Symbol;
|
|
302
|
+
isButton?: EntryFieldTypes.Boolean;
|
|
303
|
+
isOutlined?: EntryFieldTypes.Boolean;
|
|
304
|
+
backgroundColour?: EntryFieldTypes.Symbol<string>;
|
|
305
|
+
textColour?: EntryFieldTypes.Symbol<string>;
|
|
306
|
+
icon?: EntryFieldTypes.AssetLink;
|
|
307
|
+
mobileIcon?: EntryFieldTypes.AssetLink;
|
|
308
|
+
variant?: EntryFieldTypes.Symbol<string>;
|
|
309
|
+
size?: EntryFieldTypes.Symbol<string>;
|
|
310
|
+
longText?: EntryFieldTypes.RichText;
|
|
311
|
+
}
|
|
312
|
+
type BaseNavigationItemSkeleton = EntrySkeletonType<BaseNavigationItemFields, 'navigationItem'>;
|
|
313
|
+
|
|
314
|
+
interface BaseNavigationFields {
|
|
315
|
+
adminLabel: EntryFieldTypes.Symbol;
|
|
316
|
+
name: EntryFieldTypes.Symbol;
|
|
317
|
+
backgroundColour?: EntryFieldTypes.Symbol<string>;
|
|
318
|
+
textColour?: EntryFieldTypes.Symbol<string>;
|
|
319
|
+
entries?: EntryFieldTypes.Array<EntryFieldTypes.EntryLink<BaseNavigationItemSkeleton>>;
|
|
320
|
+
}
|
|
321
|
+
type BaseNavigationSkeleton = EntrySkeletonType<BaseNavigationFields, 'navigation'>;
|
|
322
|
+
|
|
320
323
|
interface BaseCustomTypeFields {
|
|
321
324
|
name: EntryFieldTypes.Symbol;
|
|
322
325
|
slug: EntryFieldTypes.Symbol;
|
|
@@ -340,8 +343,10 @@ interface BaseCustomTypeFields {
|
|
|
340
343
|
}
|
|
341
344
|
type BaseCustomTypeSkeleton = EntrySkeletonType<BaseCustomTypeFields, 'customType'>;
|
|
342
345
|
|
|
343
|
-
type
|
|
344
|
-
|
|
346
|
+
type IContentfulPerson = IBasePerson & {
|
|
347
|
+
bio?: IContentfulRichText | null;
|
|
348
|
+
};
|
|
349
|
+
declare function basePersonConverter(context: ConverterContext, entry: Entry<BasePersonSkeleton, DefaultChainModifier, string>, customTypeEntry?: Entry<BaseCustomTypeSkeleton, DefaultChainModifier, string>): IContentfulPerson;
|
|
345
350
|
|
|
346
351
|
interface ContentfulConfig {
|
|
347
352
|
spaceId: string;
|
|
@@ -378,7 +383,7 @@ interface CmsResponse<T> {
|
|
|
378
383
|
}
|
|
379
384
|
|
|
380
385
|
declare function baseArticleConverter(context: ConverterContext, entry: Entry<BaseArticleSkeleton, DefaultChainModifier, string>): IBaseArticle;
|
|
381
|
-
declare function baseArticleTypeConverter(context: ConverterContext, entry: Entry<BaseArticleTypeSkeleton, DefaultChainModifier, string>): IBaseArticleType;
|
|
386
|
+
declare function baseArticleTypeConverter(context: ConverterContext, entry: Entry<BaseArticleTypeSkeleton, DefaultChainModifier, string>, customTypeEntry?: Entry<BaseCustomTypeSkeleton, DefaultChainModifier, string>): IBaseArticleType;
|
|
382
387
|
|
|
383
388
|
type IContentfulCollection<TContents = BaseCollectionContent> = IBaseCollection<TContents> & {
|
|
384
389
|
body?: IContentfulRichText | null;
|
|
@@ -397,8 +402,10 @@ declare function baseCustomTypeConverter(context: ConverterContext, entry: Entry
|
|
|
397
402
|
declare function baseNavigationItemConverter(context: ConverterContext, entry: Entry<BaseNavigationItemSkeleton, DefaultChainModifier, string>): INavigationItem;
|
|
398
403
|
|
|
399
404
|
declare function basePageConverter(context: ConverterContext, entry: Entry<BasePageSkeleton, DefaultChainModifier, string>): IBasePage;
|
|
405
|
+
declare function calculatePageHref(slug: string): string;
|
|
406
|
+
declare function calculatePageVariantHref(slug: string): string;
|
|
400
407
|
|
|
401
|
-
declare function baseTagConverter(context: ConverterContext, entry: Entry<BaseTagSkeleton, DefaultChainModifier, string>): IBaseTag;
|
|
408
|
+
declare function baseTagConverter(context: ConverterContext, entry: Entry<BaseTagSkeleton, DefaultChainModifier, string>, customTypeEntry?: Entry<BaseCustomTypeSkeleton, DefaultChainModifier, string>): IBaseTag;
|
|
402
409
|
|
|
403
410
|
declare function lookupAsset(context: ConverterContext, asset: UnresolvedLink<'Asset'> | undefined): IVisual | undefined;
|
|
404
411
|
type ContentResolverFunction = (context: ConverterContext, entry: Entry<BaseContent, DefaultChainModifier, string>) => unknown;
|
|
@@ -424,6 +431,7 @@ type BaseConverterContext = {
|
|
|
424
431
|
articleResolver: typeof baseArticleConverter;
|
|
425
432
|
articleTypeResolver: typeof baseArticleTypeConverter;
|
|
426
433
|
tagResolver: typeof baseTagConverter;
|
|
434
|
+
personResolver: typeof basePersonConverter;
|
|
427
435
|
customTypeResolver: typeof baseCustomTypeConverter;
|
|
428
436
|
componentResolver: typeof baseComponentConverter;
|
|
429
437
|
collectionResolver: typeof baseCollectionConverter;
|
|
@@ -437,7 +445,10 @@ type ConverterContext = BaseConverterContext & {
|
|
|
437
445
|
|
|
438
446
|
declare function contentfulArticleRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, articleTypeSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseArticle | null>>;
|
|
439
447
|
|
|
440
|
-
|
|
448
|
+
interface ArticleTypeFetchOptions extends FetchOptions {
|
|
449
|
+
customType?: string;
|
|
450
|
+
}
|
|
451
|
+
declare function contentfulArticleTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: ArticleTypeFetchOptions): Promise<CmsResponse<IBaseArticleType | null>>;
|
|
441
452
|
|
|
442
453
|
interface ContentfulResponse<T = any> {
|
|
443
454
|
sys: {
|
|
@@ -513,14 +524,10 @@ interface DownloadRouteParams {
|
|
|
513
524
|
}
|
|
514
525
|
declare function createDownloadHandler(config: DownloadHandlerConfig): (_request: NextRequest, { params }: DownloadRouteParams) => Promise<Response>;
|
|
515
526
|
|
|
516
|
-
declare function createBaseConverterContext(): BaseConverterContext;
|
|
527
|
+
declare function createBaseConverterContext(urlCalculators: UrlCalculators): BaseConverterContext;
|
|
517
528
|
|
|
518
529
|
declare function contentfulCustomTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseCustomType | null>>;
|
|
519
530
|
|
|
520
|
-
type IContentfulPerson = IBasePerson & {
|
|
521
|
-
bio?: IContentfulRichText | null;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
531
|
type DefaultChainModifier = 'WITHOUT_LINK_RESOLUTION';
|
|
525
532
|
interface IContentfulRichText {
|
|
526
533
|
json: Document;
|
|
@@ -566,6 +573,11 @@ declare function contentfulAllArticleTypeLinks(context: BaseConverterContext, co
|
|
|
566
573
|
|
|
567
574
|
declare function contentfulPageRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: FetchOptions): Promise<CmsResponse<IBasePage | null>>;
|
|
568
575
|
|
|
576
|
+
interface PersonFetchOptions extends FetchOptions {
|
|
577
|
+
customType?: string;
|
|
578
|
+
}
|
|
579
|
+
declare function contentfulPersonRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: PersonFetchOptions): Promise<CmsResponse<IContentfulPerson | null>>;
|
|
580
|
+
|
|
569
581
|
type PreviewContentType = 'page' | 'pageVariant' | 'article' | 'articleType' | 'tag' | 'person' | 'customType';
|
|
570
582
|
interface PreviewEntryInfo {
|
|
571
583
|
contentType: PreviewContentType;
|
|
@@ -586,7 +598,10 @@ declare function contentfulPersonSitemapEntries(context: BaseConverterContext, c
|
|
|
586
598
|
declare function getAllSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig: SitemapConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
587
599
|
declare function createSitemapProvider(fetcher: (context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions) => Promise<CmsResponse<ISitemapEntry[]>>, sitemapConfig?: SitemapContentTypeConfig): SitemapEntryProvider;
|
|
588
600
|
|
|
589
|
-
|
|
601
|
+
interface TagFetchOptions extends FetchOptions {
|
|
602
|
+
customType?: string;
|
|
603
|
+
}
|
|
604
|
+
declare function contentfulTagRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: TagFetchOptions): Promise<CmsResponse<IBaseTag | null>>;
|
|
590
605
|
|
|
591
606
|
interface IFetchedTemplate {
|
|
592
607
|
id: string;
|
|
@@ -696,4 +711,4 @@ declare class RateLimiter {
|
|
|
696
711
|
getIntervalMs(): number;
|
|
697
712
|
}
|
|
698
713
|
|
|
699
|
-
export { AllTags, ArticleTag, ArticleTypeTag, AssetTag, AuthenticationError, BannerTag, type BaseConverterContext, type CmsError, type CmsResponse, type ContentResolverFunction, ContentfulFetchClient as ContentfulClient, type ContentfulConfig, ContentfulError, ContentfulFetchClient, type ConverterContext, CustomTypeTag, type DefaultChainModifier, type DownloadHandlerConfig, type DownloadRouteParams, EntryNotFoundError, type FetchOptions, GlobalTag, type IContentfulCollection, type IContentfulComponent, type IContentfulPerson, type IContentfulRichText, type IFetchedTemplate, type ISitemapEntry, LocationTag, NavigationTag, PageTag, PersonTag, type PreviewContentType, type PreviewEntryInfo, RateLimitError, RateLimiter, type RelatedArticlesOptions, type RetryConfig, type RevalidationConfig, type SitemapChangeFrequency, type SitemapConfig, type SitemapContentTypeConfig, type SitemapEntryProvider, TagTag, TemplateTag, type UrlCalculators, ValidationError, arrayOrUndefined, articleTag, articleTypeIndexTag, articleTypeTag, assetTag, basePageConverter, calculateBackoffDelay, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries, contentfulAssetRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTemplateRest, createBaseConverterContext, createContentfulClient, createContentfulPreviewClient, createDownloadHandler, createResponsiveVisual, createRevalidationHandler, createSitemapProvider, customTypeTag, filterRelatedArticles, getAllSitemapEntries, getCacheTags, getCacheTagsForPreview, getCacheTagsForProduction, getContentfulClient, getPreviewEntryInfo, getRetryAfter, isBrowserViewable, isContentfulError, isRateLimitError, isRetryableError, isValidDate, locationTag, lookupAsset, notEmpty, pageTag, personTag, resolveLink, resolveLinks, resolveRichTextDocument, revalidateSingleTag, revalidateTags, safeDate, tagTag, templateTag, withRetry };
|
|
714
|
+
export { AllTags, ArticleTag, type ArticleTypeFetchOptions, ArticleTypeTag, AssetTag, AuthenticationError, BannerTag, type BaseConverterContext, type CmsError, type CmsResponse, type ContentResolverFunction, ContentfulFetchClient as ContentfulClient, type ContentfulConfig, ContentfulError, ContentfulFetchClient, type ConverterContext, CustomTypeTag, type DefaultChainModifier, type DownloadHandlerConfig, type DownloadRouteParams, EntryNotFoundError, type FetchOptions, GlobalTag, type IContentfulCollection, type IContentfulComponent, type IContentfulPerson, type IContentfulRichText, type IFetchedTemplate, type ISitemapEntry, LocationTag, NavigationTag, PageTag, type PersonFetchOptions, PersonTag, type PreviewContentType, type PreviewEntryInfo, RateLimitError, RateLimiter, type RelatedArticlesOptions, type RetryConfig, type RevalidationConfig, type SitemapChangeFrequency, type SitemapConfig, type SitemapContentTypeConfig, type SitemapEntryProvider, type TagFetchOptions, TagTag, TemplateTag, type UrlCalculators, ValidationError, arrayOrUndefined, articleTag, articleTypeIndexTag, articleTypeTag, assetTag, basePageConverter, calculateBackoffDelay, calculatePageHref, calculatePageVariantHref, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries, contentfulAssetRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonRest, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTemplateRest, createBaseConverterContext, createContentfulClient, createContentfulPreviewClient, createDownloadHandler, createResponsiveVisual, createRevalidationHandler, createSitemapProvider, customTypeTag, filterRelatedArticles, getAllSitemapEntries, getCacheTags, getCacheTagsForPreview, getCacheTagsForProduction, getContentfulClient, getPreviewEntryInfo, getRetryAfter, isBrowserViewable, isContentfulError, isRateLimitError, isRetryableError, isValidDate, locationTag, lookupAsset, notEmpty, pageTag, personTag, resolveLink, resolveLinks, resolveRichTextDocument, revalidateSingleTag, revalidateTags, safeDate, tagTag, templateTag, withRetry };
|