type ResourceLike = { metadata?: unknown } | null | undefined

export function getResourceLocationPathValues(resource: ResourceLike) {
  const metadata = (resource?.metadata ?? {}) as { locationPathValues?: unknown }
  if (!Array.isArray(metadata.locationPathValues)) return []
  return metadata.locationPathValues.filter((value): value is string => typeof value === "string")
}

export function getResourceLocationPathLabel(resource: ResourceLike) {
  const values = getResourceLocationPathValues(resource)
  return values.length > 0 ? values.join(" > ") : null
}
