UNPKG

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

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

46 lines (44 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFieldPathFactory = void 0; const createFieldPathFactory = ({ plugins }) => { return params => { const { field, key, value, keyword } = params; const plugin = plugins[field.type]; let fieldPath = null; if (plugin) { fieldPath = plugin.createPath({ field: field.field, value, key }); } if (!fieldPath) { fieldPath = field.field.storageId; if (field.path) { fieldPath = typeof field.path === "function" ? field.path(value) : field.path; } } const result = []; if (!field.systemField) { result.push("values"); } result.push(...field.parents.map(p => p.storageId)); result.push(fieldPath); return { basePath: result.join("."), path: result.concat(keyword ? ["keyword"] : []).join(".") }; }; }; exports.createFieldPathFactory = createFieldPathFactory; //# sourceMappingURL=path.js.map