UNPKG

@webiny/api-page-builder-so-ddb-es

Version:

The DynamoDB + Elasticsearch storage operations Webiny Page Builder API.

53 lines (51 loc) 1.67 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.configurations = void 0; var _error = _interopRequireDefault(require("@webiny/error")); var _apiElasticsearch = require("@webiny/api-elasticsearch"); var _plugins = require("./plugins"); const configurations = exports.configurations = { es: params => { const { tenant, locale } = params; if (!tenant) { throw new _error.default(`Missing "tenant" parameter when trying to create Elasticsearch index name.`, "TENANT_ERROR"); } const sharedIndex = (0, _apiElasticsearch.isSharedElasticsearchIndex)(); const tenantId = sharedIndex ? "root" : tenant; let localeCode = null; if (process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE === "true") { if (!locale) { throw new _error.default(`Missing "locale" parameter when trying to create Elasticsearch index name.`, "LOCALE_ERROR"); } localeCode = locale; } const index = [tenantId, localeCode, "page-builder"].filter(Boolean).join("-").toLowerCase(); const prefix = (0, _apiElasticsearch.getElasticsearchIndexPrefix)(); if (!prefix) { return { index }; } return { index: prefix + index }; }, indexSettings: ({ context, locale }) => { const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({ container: context.plugins, type: _plugins.PageElasticsearchIndexPlugin.type, locale }); return plugin ? plugin.body : {}; } }; //# sourceMappingURL=configurations.js.map