@webiny/api-headless-cms-ddb-es
Version:
DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.
24 lines (23 loc) • 805 B
JavaScript
import { OpenSearchQueryBuilderOperatorPlugin } from "@webiny/api-opensearch";
export const createOperatorPluginList = params => {
const {
plugins
} = params;
/**
* We always set the last one operator plugin added.
* This way user can override the plugins.
*/
return plugins.byType(OpenSearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
const operator = plugin.getOperator();
/**
* 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;
}, {});
};
//# sourceMappingURL=operator.js.map