UNPKG

@botonic/plugin-contentful

Version:

Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet

55 lines (54 loc) 2.63 kB
import * as contentful from 'contentful'; import { ContentId, ContentType, Context } from '../cms'; import { ContentfulOptions } from '../plugin'; import { ReducedClientApi } from './delivery/client-api'; import { DateRangeFields } from './delivery-utils'; import { SearchableByKeywordsFields } from './search/searchable-by'; /** * https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/ */ export interface DeliveryApi { getAsset(id: string, context: Context, query?: any): Promise<contentful.Asset>; getAssets(context: Context, query?: any): Promise<contentful.AssetCollection>; getEntry<T>(id: string, context: Context, query?: any): Promise<contentful.Entry<T>>; getEntries<T>(context: Context, query?: any): Promise<contentful.EntryCollection<T>>; getContentType(id: string): Promise<contentful.ContentType>; getOptions(): ContentfulOptions; } /** * Manages the {@link Context}, parses Content's Id and ContentType from the Contentful entries... */ export declare class AdaptorDeliveryApi implements DeliveryApi { readonly client: ReducedClientApi; readonly options: ContentfulOptions; constructor(client: ReducedClientApi, options: ContentfulOptions); getAsset(id: string, context: Context, query?: any): Promise<contentful.Asset>; getAssets(context: Context, query?: any): Promise<contentful.AssetCollection>; getEntry<T>(id: string, context: Context, query?: any): Promise<contentful.Entry<T>>; getEntries<T>(context: Context, query?: any): Promise<contentful.EntryCollection<T>>; getContentType(id: string): Promise<contentful.ContentType>; getOptions(): ContentfulOptions; private queryFromContext; } export interface ContentWithNameFields { name: string; } export interface CommonEntryFields extends ContentWithNameFields { shortText?: string; keywords?: string[]; searchableBy?: contentful.Entry<SearchableByKeywordsFields>[]; partitions?: string[]; dateRange?: contentful.Entry<DateRangeFields>; followup?: contentful.Entry<FollowUpFields>; } export type FollowUpFields = CommonEntryFields; export declare class ContentfulEntryUtils { static getContentId(entry: contentful.Entry<any>): ContentId; /** * Will be false for broken references, or when we have only fetched * the full Entry tree */ static isFullEntry(entry: contentful.Entry<any>): boolean; static getContentModel<T extends ContentType = ContentType>(entry: contentful.Entry<any>): T; } export declare function createContentfulClientApi(options: ContentfulOptions): contentful.ContentfulClientApi;