@webiny/api-headless-cms-ddb-es
Version:
DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.
39 lines (37 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createOperatorPluginList = void 0;
var _apiElasticsearch = require("@webiny/api-elasticsearch");
const createOperatorPluginList = params => {
const {
plugins,
locale
} = params;
/**
* We always set the last one operator plugin added.
* This way user can override the plugins.
*/
return plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
const operator = plugin.getOperator();
/**
* We only allow the plugins which can pass the locale test.
* The default plugins always return true.
*/
if (plugin.isLocaleSupported(locale) === false) {
return acc;
}
/**
* We also only allow the override of the plugins if the new plugin is NOT a default one.
* If a user sets the plugin name ending with .default, we cannot do anything about it.
*/
if (!!acc[operator] && (plugin.name || "").match(/\.default$/)) {
return acc;
}
acc[operator] = plugin;
return acc;
}, {});
};
exports.createOperatorPluginList = createOperatorPluginList;
//# sourceMappingURL=operator.js.map