@se-studio/contentful-rest-api 1.0.17 → 1.0.19
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 +101 -42
- package/dist/index.js +997 -836
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IBaseArticle, IBaseArticleType, IBaseCollection, IBaseComponent, INavigationItem, IBasePage, IVisual, IInternalLink, INavigation, IPerson, IResponsiveVisual } from '@se-studio/core-data-types';
|
|
1
|
+
import { IBaseArticle, IBaseArticleType, BaseCollectionContent, IBaseCollection, IBaseComponent, IBaseCustomType, INavigationItem, IBasePage, IBaseTag, IInternalLink, IVisual, IBasePerson, INavigation, IArticleLink, IArticleTypeLink, ITyped, IResponsiveVisual } from '@se-studio/core-data-types';
|
|
3
2
|
import * as contentful from 'contentful';
|
|
4
3
|
import { EntrySkeletonType, EntryFieldTypes, Entry, UnresolvedLink } from 'contentful';
|
|
4
|
+
import { Document } from '@contentful/rich-text-types';
|
|
5
5
|
import { NextRequest, NextResponse } from 'next/server';
|
|
6
6
|
|
|
7
7
|
interface BaseExternalVideoFields {
|
|
@@ -377,17 +377,29 @@ interface CmsResponse<T> {
|
|
|
377
377
|
declare function baseArticleConverter(context: ConverterContext, entry: Entry<BaseArticleSkeleton, DefaultChainModifier, string>): IBaseArticle;
|
|
378
378
|
declare function baseArticleTypeConverter(context: ConverterContext, entry: Entry<BaseArticleTypeSkeleton, DefaultChainModifier, string>): IBaseArticleType;
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
type IContentfulCollection<TContents = BaseCollectionContent> = IBaseCollection<TContents> & {
|
|
381
|
+
body?: IContentfulRichText | null;
|
|
382
|
+
additionalCopy?: IContentfulRichText | null;
|
|
383
|
+
};
|
|
384
|
+
declare function baseCollectionConverter(context: ConverterContext, entry: Entry<BaseCollectionSkeleton, DefaultChainModifier, string>): IContentfulCollection;
|
|
385
|
+
|
|
386
|
+
type IContentfulComponent = IBaseComponent & {
|
|
387
|
+
body?: IContentfulRichText | null;
|
|
388
|
+
additionalCopy?: IContentfulRichText | null;
|
|
389
|
+
};
|
|
390
|
+
declare function baseComponentConverter(context: ConverterContext, entry: Entry<BaseComponentSkeleton, DefaultChainModifier, string>): IContentfulComponent;
|
|
381
391
|
|
|
382
|
-
declare function
|
|
392
|
+
declare function baseCustomTypeConverter(context: ConverterContext, entry: Entry<BaseCustomTypeSkeleton, DefaultChainModifier, string>): IBaseCustomType;
|
|
383
393
|
|
|
384
394
|
declare function baseNavigationItemConverter(context: ConverterContext, entry: Entry<BaseNavigationItemSkeleton, DefaultChainModifier, string>): INavigationItem;
|
|
385
395
|
|
|
386
396
|
declare function basePageConverter(context: ConverterContext, entry: Entry<BasePageSkeleton, DefaultChainModifier, string>): IBasePage;
|
|
387
397
|
|
|
398
|
+
declare function baseTagConverter(context: ConverterContext, entry: Entry<BaseTagSkeleton, DefaultChainModifier, string>): IBaseTag;
|
|
399
|
+
|
|
388
400
|
declare function lookupAsset(context: ConverterContext, asset: UnresolvedLink<'Asset'> | undefined): IVisual | undefined;
|
|
389
401
|
type ContentResolverFunction = (context: ConverterContext, entry: Entry<BaseContent, DefaultChainModifier, string>) => unknown;
|
|
390
|
-
type LinkResolverFunction = (context: ConverterContext, entry: Entry<BaseLink, DefaultChainModifier, string>) =>
|
|
402
|
+
type LinkResolverFunction<TResult extends IInternalLink = IInternalLink> = (context: ConverterContext, entry: Entry<BaseLink, DefaultChainModifier, string>) => TResult;
|
|
391
403
|
type LinkResolverMap = Map<string, LinkResolverFunction>;
|
|
392
404
|
type BaseConverterContext = {
|
|
393
405
|
videoPrefix: string;
|
|
@@ -397,6 +409,8 @@ type BaseConverterContext = {
|
|
|
397
409
|
pageResolver: typeof basePageConverter;
|
|
398
410
|
articleResolver: typeof baseArticleConverter;
|
|
399
411
|
articleTypeResolver: typeof baseArticleTypeConverter;
|
|
412
|
+
tagResolver: typeof baseTagConverter;
|
|
413
|
+
customTypeResolver: typeof baseCustomTypeConverter;
|
|
400
414
|
componentResolver: typeof baseComponentConverter;
|
|
401
415
|
collectionResolver: typeof baseCollectionConverter;
|
|
402
416
|
};
|
|
@@ -406,43 +420,13 @@ type ConverterContext = BaseConverterContext & {
|
|
|
406
420
|
errors: CmsError[];
|
|
407
421
|
};
|
|
408
422
|
|
|
409
|
-
type DefaultChainModifier = 'WITHOUT_LINK_RESOLUTION';
|
|
410
|
-
type ResolvedEntry = IBasePage | IBaseArticle | IBaseArticleType | INavigation | INavigationItem | IInternalLink | unknown | IPerson;
|
|
411
|
-
type PossibleResolvedEntry = {
|
|
412
|
-
id: string;
|
|
413
|
-
type: string;
|
|
414
|
-
entry: Entry<EntrySkeletonType, DefaultChainModifier, string>;
|
|
415
|
-
resolved?: ResolvedEntry;
|
|
416
|
-
};
|
|
417
|
-
declare function contentfulPageRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: FetchOptions): Promise<CmsResponse<IBasePage | null>>;
|
|
418
|
-
interface IContentfulRichText {
|
|
419
|
-
json: Document;
|
|
420
|
-
customStyles?: ReadonlyArray<string> | null;
|
|
421
|
-
}
|
|
422
|
-
declare function createBaseConverterContext(): BaseConverterContext;
|
|
423
423
|
declare function contentfulArticleRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, articleTypeSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseArticle | null>>;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
interface RelatedArticlesOptions {
|
|
431
|
-
articleTypeId?: string;
|
|
432
|
-
tagIds?: string[];
|
|
433
|
-
authorId?: string;
|
|
434
|
-
excludeIds?: string[];
|
|
435
|
-
before?: Date;
|
|
436
|
-
after?: Date;
|
|
437
|
-
count?: number;
|
|
438
|
-
}
|
|
439
|
-
declare function getAllArticlesForRelated(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IArticleLinkWithMetadata[]>>;
|
|
440
|
-
declare function contentfulAllPageLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
441
|
-
declare function contentfulAllArticleLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
442
|
-
declare function contentfulAllTagLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
443
|
-
declare function contentfulAllPersonLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
444
|
-
declare function contentfulAllArticleTypeLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
445
|
-
declare function filterRelatedArticles(articles: IArticleLinkWithMetadata[], options: RelatedArticlesOptions): IInternalLink[];
|
|
424
|
+
|
|
425
|
+
declare function contentfulArticleTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseArticleType | null>>;
|
|
426
|
+
|
|
427
|
+
declare function createBaseConverterContext(): BaseConverterContext;
|
|
428
|
+
|
|
429
|
+
declare function contentfulCustomTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseCustomType | null>>;
|
|
446
430
|
|
|
447
431
|
interface ContentfulResponse<T = any> {
|
|
448
432
|
sys: {
|
|
@@ -475,6 +459,80 @@ declare function createContentfulClient(config: ContentfulConfig): ContentfulFet
|
|
|
475
459
|
declare function createContentfulPreviewClient(config: ContentfulConfig): ContentfulFetchClient;
|
|
476
460
|
declare function getContentfulClient(config: ContentfulConfig, preview?: boolean): ContentfulFetchClient;
|
|
477
461
|
|
|
462
|
+
type IContentfulPerson = IBasePerson & {
|
|
463
|
+
bio?: IContentfulRichText | null;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
type DefaultChainModifier = 'WITHOUT_LINK_RESOLUTION';
|
|
467
|
+
interface IContentfulRichText {
|
|
468
|
+
json: Document;
|
|
469
|
+
customStyles?: ReadonlyArray<string> | null;
|
|
470
|
+
}
|
|
471
|
+
type SitemapChangeFrequency = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
472
|
+
interface ISitemapEntry {
|
|
473
|
+
url: string;
|
|
474
|
+
lastModified?: Date;
|
|
475
|
+
changeFrequency?: SitemapChangeFrequency;
|
|
476
|
+
priority?: number;
|
|
477
|
+
}
|
|
478
|
+
interface SitemapContentTypeConfig {
|
|
479
|
+
priority?: number;
|
|
480
|
+
changeFrequency?: SitemapChangeFrequency;
|
|
481
|
+
}
|
|
482
|
+
type SitemapEntryProvider = (context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions) => Promise<CmsResponse<ISitemapEntry[]>>;
|
|
483
|
+
interface SitemapConfig {
|
|
484
|
+
providers: SitemapEntryProvider[];
|
|
485
|
+
}
|
|
486
|
+
interface RelatedArticlesOptions {
|
|
487
|
+
excludeArticleIds?: string[];
|
|
488
|
+
articleTypeIds?: string[];
|
|
489
|
+
tagIds?: string[];
|
|
490
|
+
authorIds?: string[];
|
|
491
|
+
before?: Date;
|
|
492
|
+
after?: Date;
|
|
493
|
+
count?: number;
|
|
494
|
+
}
|
|
495
|
+
type ResolvedEntry = IBasePage | IBaseArticle | IBaseArticleType | IBaseTag | INavigation | INavigationItem | IInternalLink | unknown | IContentfulPerson;
|
|
496
|
+
type PossibleResolvedEntry = {
|
|
497
|
+
id: string;
|
|
498
|
+
type: string;
|
|
499
|
+
entry: Entry<EntrySkeletonType, DefaultChainModifier, string>;
|
|
500
|
+
resolved?: ResolvedEntry;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
declare function contentfulAllPageLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
504
|
+
declare function contentfulAllArticleLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IArticleLink[]>>;
|
|
505
|
+
declare function contentfulAllTagLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
506
|
+
declare function contentfulAllPersonLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IInternalLink[]>>;
|
|
507
|
+
declare function contentfulAllArticleTypeLinks(context: BaseConverterContext, config: ContentfulConfig, options?: FetchOptions): Promise<CmsResponse<IArticleTypeLink[]>>;
|
|
508
|
+
|
|
509
|
+
declare function contentfulPageRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: FetchOptions): Promise<CmsResponse<IBasePage | null>>;
|
|
510
|
+
|
|
511
|
+
declare function filterRelatedArticles(articles: IArticleLink[], options: RelatedArticlesOptions): IArticleLink[];
|
|
512
|
+
|
|
513
|
+
declare function contentfulPageSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
514
|
+
declare function contentfulArticleSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
515
|
+
declare function contentfulArticleTypeSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
516
|
+
declare function contentfulTagSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
517
|
+
declare function contentfulPersonSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
518
|
+
declare function getAllSitemapEntries(context: BaseConverterContext, config: ContentfulConfig, sitemapConfig: SitemapConfig, options?: FetchOptions): Promise<CmsResponse<ISitemapEntry[]>>;
|
|
519
|
+
declare function createSitemapProvider(fetcher: (context: BaseConverterContext, config: ContentfulConfig, sitemapConfig?: SitemapContentTypeConfig, options?: FetchOptions) => Promise<CmsResponse<ISitemapEntry[]>>, sitemapConfig?: SitemapContentTypeConfig): SitemapEntryProvider;
|
|
520
|
+
|
|
521
|
+
declare function contentfulTagRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: FetchOptions): Promise<CmsResponse<IBaseTag | null>>;
|
|
522
|
+
|
|
523
|
+
interface IFetchedTemplate {
|
|
524
|
+
id: string;
|
|
525
|
+
cmsLabel: string;
|
|
526
|
+
preContent: ReadonlyArray<ITyped>;
|
|
527
|
+
postContent: ReadonlyArray<ITyped>;
|
|
528
|
+
menu?: INavigation;
|
|
529
|
+
footer?: INavigation;
|
|
530
|
+
backgroundColour?: string;
|
|
531
|
+
textColour?: string;
|
|
532
|
+
stickyNav: boolean;
|
|
533
|
+
}
|
|
534
|
+
declare function contentfulTemplateRest(context: BaseConverterContext, config: ContentfulConfig, cmsLabel: string, options?: FetchOptions): Promise<CmsResponse<IFetchedTemplate | null>>;
|
|
535
|
+
|
|
478
536
|
declare function createResponsiveVisual(visual: IVisual | undefined, mobileVisual: IVisual | undefined, customSize?: number | null): IResponsiveVisual | undefined;
|
|
479
537
|
|
|
480
538
|
declare function resolveLink(context: ConverterContext, fromId: string, entry: UnresolvedLink<'Entry'>): IInternalLink;
|
|
@@ -510,6 +568,7 @@ declare function customTypeTag(slug: string): string;
|
|
|
510
568
|
declare function tagTag(slug: string): string;
|
|
511
569
|
declare function personTag(slug: string): string;
|
|
512
570
|
declare function assetTag(assetId: string): string;
|
|
571
|
+
declare function templateTag(label: string): string;
|
|
513
572
|
declare function locationTag(slug: string): string;
|
|
514
573
|
declare const AllTags: string[];
|
|
515
574
|
|
|
@@ -565,4 +624,4 @@ declare class RateLimiter {
|
|
|
565
624
|
getAvailableTokens(): number;
|
|
566
625
|
}
|
|
567
626
|
|
|
568
|
-
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, EntryNotFoundError, type FetchOptions, GlobalTag, type
|
|
627
|
+
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, EntryNotFoundError, type FetchOptions, GlobalTag, type IContentfulCollection, type IContentfulComponent, type IContentfulPerson, type IContentfulRichText, type IFetchedTemplate, type ISitemapEntry, LocationTag, NavigationTag, PageTag, PersonTag, RateLimitError, RateLimiter, type RelatedArticlesOptions, type RetryConfig, type RevalidationConfig, type SitemapChangeFrequency, type SitemapConfig, type SitemapContentTypeConfig, type SitemapEntryProvider, TagTag, TemplateTag, ValidationError, arrayOrUndefined, articleTag, articleTypeIndexTag, articleTypeTag, assetTag, basePageConverter, calculateBackoffDelay, contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulArticleRest, contentfulArticleSitemapEntries, contentfulArticleTypeRest, contentfulArticleTypeSitemapEntries, contentfulCustomTypeRest, contentfulPageRest, contentfulPageSitemapEntries, contentfulPersonSitemapEntries, contentfulTagRest, contentfulTagSitemapEntries, contentfulTemplateRest, createBaseConverterContext, createContentfulClient, createContentfulPreviewClient, createResponsiveVisual, createRevalidationHandler, createSitemapProvider, customTypeTag, filterRelatedArticles, getAllSitemapEntries, getCacheTags, getCacheTagsForPreview, getCacheTagsForProduction, getContentfulClient, getRetryAfter, isContentfulError, isRateLimitError, isRetryableError, isValidDate, locationTag, lookupAsset, notEmpty, pageTag, personTag, resolveLink, resolveLinks, resolveRichTextDocument, revalidateSingleTag, revalidateTags, safeDate, tagTag, templateTag, withRetry };
|