UNPKG

@webiny/api-headless-cms-ddb-es

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

40 lines (38 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createElasticsearchIndex = void 0; var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin"); var _apiElasticsearch = require("@webiny/api-elasticsearch"); var _configurations = require("../configurations"); const createElasticsearchIndex = async params => { const { client, plugins, model } = params; const { index } = _configurations.configurations.es({ model }); await (0, _apiElasticsearch.createIndex)({ client, index, type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type, tenant: model.tenant, locale: model.locale, plugins, onExists: () => { console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`); }, onError: ex => { console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`); console.error(ex); return ex; } }); }; exports.createElasticsearchIndex = createElasticsearchIndex; //# sourceMappingURL=createElasticsearchIndex.js.map