UNPKG

@botonic/plugin-contentful

Version:

## What Does This Plugin Do?

49 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_FALLBACK_CACHE_LIMIT_KB = exports.DEFAULT_CACHE_TTL_MS = exports.DEFAULT_TIMEOUT_MS = void 0; const tslib_1 = require("tslib"); const cms = tslib_1.__importStar(require("./cms")); const cms_1 = require("./cms"); const cms_contentful_1 = require("./contentful/cms-contentful"); const nlp_1 = require("./nlp"); const render_1 = require("./render"); const search_1 = require("./search"); exports.DEFAULT_TIMEOUT_MS = 30000; exports.DEFAULT_CACHE_TTL_MS = 10000; exports.DEFAULT_FALLBACK_CACHE_LIMIT_KB = 100 * 1024; class BotonicPluginContentful { constructor(opt) { const optionsAny = opt; if (optionsAny.cms) { this.cms = optionsAny.cms; } else { const contOptions = opt; const factory = contOptions.contentfulFactory || (o => { let cms = new cms_contentful_1.Contentful(o); if (contOptions.logCalls) { cms = new cms_1.LogCMS(cms, contOptions); } return cms; }); this.cms = factory(contOptions); } this.cms = new cms.ErrorReportingCMS(this.cms, opt.logger); this.renderer = opt.renderer || new render_1.BotonicMsgConverter(); if (opt.search) { this.search = opt.search; this.normalizer = opt.normalizer || new nlp_1.Normalizer(); } else { this.normalizer = opt.nlpOptions ? new nlp_1.Normalizer(opt.nlpOptions.blackList) : new nlp_1.Normalizer(); this.search = new search_1.Search(this.cms, this.normalizer, opt.keywordsOptions); } } pre(_r) { } post(_r) { } } exports.default = BotonicPluginContentful; //# sourceMappingURL=plugin.js.map