import type { ListQuery } from '@platform-modules/content'

/** Stable JSON key for effect deps — query object identity is not stable across renders. */
export function stableSerializeQuery(query?: ListQuery): string {
  if (!query) return ''
  const keys = Object.keys(query).sort() as (keyof ListQuery)[]
  const sorted: Record<string, unknown> = {}
  for (const k of keys) {
    sorted[k] = query[k]
  }
  return JSON.stringify(sorted)
}
