import type { QueryParams } from "./request";

export function cleanQuery(query: QueryParams = {}) {
  return Object.fromEntries(
    Object.entries(query).filter(([, value]) => value !== undefined && value !== null && value !== "")
  );
}

export function toPageQuery({ page, pageSize, ...query }: QueryParams & { page: number; pageSize: number }) {
  return cleanQuery({
    ...query,
    page,
    page_size: pageSize
  });
}
