import { reindexEntity } from "@open-mercato/core/modules/query_index/lib/reindexer";
import { E } from "../../../generated/entities.ids.generated.js";
function moduleEntityIds(modules) {
  const collected = [];
  for (const moduleId of modules) {
    const entries = E[moduleId];
    if (!entries) continue;
    for (const value of Object.values(entries)) {
      if (typeof value === "string") collected.push(value);
    }
  }
  return Array.from(new Set(collected));
}
async function reindexModules(em, modules, options = {}) {
  const entityIds = moduleEntityIds(modules);
  if (!entityIds.length) return;
  for (const entityType of entityIds) {
    options.onEntityStart?.(entityType);
    await reindexEntity(em, {
      entityType,
      tenantId: options.tenantId,
      organizationId: options.organizationId,
      force: true,
      vectorService: options.vectorService ?? void 0
    });
  }
}
export {
  moduleEntityIds,
  reindexModules
};
//# sourceMappingURL=reindex-helpers.js.map
