metadata: Deduplicate cachedWikidataEntities as scope metadata merges
The same entity can be reported in the cachedWikidataEntities metadata of different scopes of a single request. Here we deduplicate and also apply a list-length cap as cachedWikidataEntities gets merged.
We generalise the deduplication code that warnings already had. A new map, deduplicatedMetadataKeys_ specifies how to identify an entity and how many distinct items to keep. Warnings keep their behaviour exactly, now expressed through that map, and the approach allows the same code to handle de-duplication of cachedWikidataEntities.
MAX_REPORTED_CACHED_WIKIDATA_ENTITIES_ moves to src/utils.js, so that resolver code and scope-merging code read from the same place.
Bug: T433455