@webiny/api-headless-cms-ddb-es
Version:
DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.
41 lines (39 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createElasticsearchIndexesOnLocaleAfterCreate = void 0;
var _createElasticsearchIndex = require("../../elasticsearch/createElasticsearchIndex");
const createElasticsearchIndexesOnLocaleAfterCreate = async params => {
const {
context,
client,
plugins
} = params;
context.i18n.locales.onLocaleAfterCreate.subscribe(async ({
locale,
tenant
}) => {
/**
* Get all the code models and create the indexes for them.
*/
const models = await context.security.withoutAuthorization(async () => {
return (await context.cms.listModels()).map(model => {
return {
...model,
tenant,
locale: locale.code
};
});
});
for (const model of models) {
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
client,
plugins,
model
});
}
});
};
exports.createElasticsearchIndexesOnLocaleAfterCreate = createElasticsearchIndexesOnLocaleAfterCreate;
//# sourceMappingURL=indexes.js.map