import {
  CustomerUserEmailVerification,
  CustomerUserPasswordReset,
  CustomerUserInvitation
} from "@open-mercato/core/modules/customer_accounts/data/entities";
const metadata = {
  queue: "customer-accounts-cleanup-tokens",
  id: "customer_accounts:cleanup-expired-tokens",
  concurrency: 1
};
async function handle(job, ctx) {
  const em = ctx.resolve("em");
  const now = /* @__PURE__ */ new Date();
  await em.nativeDelete(CustomerUserEmailVerification, {
    $or: [
      { expiresAt: { $lt: now }, usedAt: null },
      { usedAt: { $ne: null } }
    ]
  });
  await em.nativeDelete(CustomerUserPasswordReset, {
    $or: [
      { expiresAt: { $lt: now }, usedAt: null },
      { usedAt: { $ne: null } }
    ]
  });
  await em.nativeDelete(CustomerUserInvitation, {
    $or: [
      { expiresAt: { $lt: now }, acceptedAt: null, cancelledAt: null },
      { acceptedAt: { $ne: null } },
      { cancelledAt: { $ne: null } }
    ]
  });
}
export {
  handle as default,
  metadata
};
//# sourceMappingURL=cleanupExpiredTokens.js.map
