UNPKG

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

Version:

[![](https://img.shields.io/npm/dw/@webiny/api-form-builder-so-ddb-es.svg)](https://www.npmjs.com/package/@webiny/api-form-builder-so-ddb-es) [![](https://img.shields.io/npm/v/@webiny/api-form-builder-so-ddb-es.svg)](https://www.npmjs.com/package/@webiny

53 lines (51 loc) 1.66 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, "form-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.FormElasticsearchIndexPlugin.type, locale }); return plugin ? plugin.body : {}; } }; //# sourceMappingURL=configurations.js.map