UNPKG

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

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

52 lines (49 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CmsElasticsearchModelFieldPlugin = void 0; var _plugins = require("@webiny/plugins"); /** * A plugin which allows you to map a custom GraphQL field to an Elasticsearch field. * * This is useful when you want to create a custom field in the CMS GraphQL Schema, and you want to map it to an Elasticsearch field. */ class CmsElasticsearchModelFieldPlugin extends _plugins.Plugin { static type = "headlessCms.elasticsearch.model.field"; get fieldType() { return this.field.fieldType; } get fieldId() { return this.field.fieldId; } get path() { return this.field.path; } get unmappedType() { return this.field.unmappedType; } get searchable() { return this.field.searchable; } get sortable() { return this.field.sortable; } get keyword() { return this.field.keyword; } constructor(field) { super(); this.field = field; } canBeApplied(modelId) { if (this.field.models?.include?.length) { return this.field.models.include.includes(modelId); } else if (this.field.models?.exclude?.length) { return this.field.models.exclude.includes(modelId) === false; } return true; } } exports.CmsElasticsearchModelFieldPlugin = CmsElasticsearchModelFieldPlugin; //# sourceMappingURL=CmsElasticsearchModelFieldPlugin.js.map