import { createFeature } from "@webiny/feature/api/index.js"; import { FilterUtilFeature } from "@webiny/db-dynamodb/feature/FilterUtil/feature.js"; import { CmsEntryOpenSearchUtilsFeature } from "@webiny/api-headless-cms-utils-os"; import { FilterRegistriesFeature } from "@webiny/api-headless-cms-storage"; import { CreateElasticsearchIndexTask } from "~/tasks/CreateElasticsearchIndexTask.js"; import { CmsEntitiesDbRegistryDecorator } from "~/registry/CmsEntitiesDbRegistryDecorator.js"; import { DdbEsGroupStorageOpsFeature } from "~/operations/group/feature.js"; import { DdbEsModelStorageOpsFeature } from "~/operations/model/feature.js"; import { DdbEsEntryStorageOpsFeature } from "~/operations/entry/feature.js"; /** * The DynamoDB+OpenSearch CMS storage of a tenant scope: the storage operations, the per-scope state * (the entry DataLoaders, the filter registries, the OpenSearch field indexes and model index cache), * the index creation task and the decorator that adds the CMS entities to the scope's `DbRegistry` * for the DDB to OpenSearch sync. They run on the tables and entities the root holds * (`HeadlessCmsDdbEsTablesFeature`) and the OpenSearch core. Registered in each scope on this storage, * so a scope on another storage gets none of them. */ export const HeadlessCmsDdbEsStorageFeature = createFeature({ name: "cms.storageOperations.openSearch.storage", register: container => { FilterUtilFeature.register(container); CmsEntryOpenSearchUtilsFeature.register(container); FilterRegistriesFeature.register(container); container.register(CreateElasticsearchIndexTask); // Adds the CMS entities to the scope's DbRegistry, for the DDB to OpenSearch sync. container.registerDecorator(CmsEntitiesDbRegistryDecorator); DdbEsGroupStorageOpsFeature.register(container); DdbEsModelStorageOpsFeature.register(container); DdbEsEntryStorageOpsFeature.register(container); } });