@webiny/api-headless-cms-ddb-es
Version:
DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.
36 lines (35 loc) • 847 B
JavaScript
export const createFieldPathFactory = ({
valueSearchRegistry
}) => {
return params => {
const {
field,
key,
value,
keyword,
originalValue
} = params;
const search = valueSearchRegistry.get(field.type);
let fieldPath = null;
if (search) {
fieldPath = search.createPath({
field: field.field,
value,
key,
originalValue
});
}
if (!fieldPath) {
fieldPath = field.field.storageId;
if (field.path) {
fieldPath = typeof field.path === "function" ? field.path(value) : field.path;
}
}
const result = field.parents.map(p => p.storageId).concat([fieldPath]);
return {
basePath: result.join("."),
path: result.concat(keyword ? ["keyword"] : []).join(".")
};
};
};
//# sourceMappingURL=path.js.map