UNPKG

@botonic/plugin-contentful

Version:

## What Does This Plugin Do?

85 lines (84 loc) 2.68 kB
import * as cms from './cms'; import { KeywordsOptions, Locale, Normalizer, StemmingBlackList } from './nlp'; import { BotonicMsgConverter } from './render'; import { Search } from './search'; interface NlpOptions { blackList: { [locale: string]: StemmingBlackList[]; }; } interface OptionsBase { renderer?: BotonicMsgConverter; search?: Search; normalizer?: Normalizer; nlpOptions?: NlpOptions; keywordsOptions?: { [locale: string]: KeywordsOptions; }; logger?: (msg: string) => void; } export interface CmsOptions extends OptionsBase { cms?: cms.CMS; } export declare const DEFAULT_TIMEOUT_MS = 30000; export declare const DEFAULT_CACHE_TTL_MS = 10000; export declare const DEFAULT_FALLBACK_CACHE_LIMIT_KB: number; export interface ContentfulCredentials { spaceId: string; environment?: string; accessToken: string; } export interface ContentfulOptions extends OptionsBase, ContentfulCredentials { /** * does not work at least when there's no network during the first connection * Defaults to {@link DEFAULT_TIMEOUT_MS} */ timeoutMs?: number; /** * Contents are cached up to this amount of time. * Defaults to {@link DEFAULT_CACHE_TTL_MS} */ cacheTtlMs?: number; disableCache?: boolean; /** * By default, the result of the last delivery invocation will be cached * forever and will only be used when a delivery call with the same arguments * fail. */ disableFallbackCache?: boolean; /** * {@link DEFAULT_FALLBACK_CACHE_LIMIT_KB} by default */ fallbackCacheLimitKB?: number; contentfulFactory?: (opts: ContentfulOptions) => cms.CMS; /** For locales not supported by the CMS (eg. English on a non-English country) */ cmsLocale?: (locale?: Locale) => Locale | undefined; /** * If the delivery of an optional part of a content fails (eg. a referenced content or assert), * the flag defines whether the content should be partially delivered * or an error should be raised. * False by default */ resumeErrors?: boolean; logCalls?: boolean; contentModelsWithKeywords?: cms.TopContentType[]; } export default class BotonicPluginContentful { readonly cms: cms.CMS; readonly renderer: BotonicMsgConverter; readonly search: Search; readonly normalizer: Normalizer; constructor(opt: CmsOptions | ContentfulOptions); pre(_r: { input: any; session: any; lastRoutePath: any; }): void; post(_r: { input: any; session: any; lastRoutePath: any; response: any; }): void; } export {};