const metadata = {
  event: "customer_accounts.domain_mapping.*",
  persistent: false,
  id: "customer_accounts:invalidate-domain-cache"
};
async function handle(payload, ctx) {
  const data = payload ?? {};
  const hostname = typeof data.hostname === "string" ? data.hostname : null;
  const organizationId = typeof data.organizationId === "string" ? data.organizationId : null;
  let cache = null;
  try {
    cache = ctx.resolve("cache");
  } catch {
    return;
  }
  if (!cache) return;
  const tags = ["domain_routing"];
  if (hostname) tags.push(`domain_routing:${hostname}`);
  if (organizationId) tags.push(`domain_routing:org:${organizationId}`);
  try {
    await cache.deleteByTags(tags);
  } catch {
  }
}
export {
  handle as default,
  metadata
};
//# sourceMappingURL=invalidateDomainCache.js.map
