Skip to content

Function: getOpenAlexIDs() ​

getOpenAlexIDs(orcid, events): OpenAlexID[]

Defined in: packages/validate-openalex/src/events/getter.ts:78

Extract OpenAlex IDs for an author identified by an ORCID from a set of events.

This function:

  1. Filters events for accepted author affiliation entries whose id matches the provided orcid and collects their from values into affiliations.
  2. Filters events for accepted author display name alternatives entries whose id matches the provided orcid and collects their from values into display_name_alternatives.
  3. Computes the intersection of those two collections.
  4. If the intersection is non-empty, returns the result deduplicated and sorted via uniqueSorted. Otherwise, returns an empty array.

Notes:

  • Matching uses strict equality for id, entity, field, and status (case-sensitive).
  • Relies on the IEvent shape to contain id, entity, field, status, and from properties.
  • uniqueSorted is used to deduplicate and sort the intersection before returning.

Parameters ​

orcid ​

ORCID

The ORCID identifier for the author to look up.

events ​

IEvent[]

An array of events to search through.

Returns ​

OpenAlexID[]

An array of OpenAlex IDs (strings) that appear both as accepted affiliations and as accepted display name alternatives for the given author ORCID. Returns [] if none found.

Example ​

ts
// returns ['A1', 'A2'] if both appear in accepted affiliation and display_name_alternatives events
getOpenAlexIDs('0000-0001-2345-6789', events);