UNPKG

@citation-js/plugin-orcid

Version:
55 lines (49 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formats = exports.ref = void 0; var _core = require("@citation-js/core"); const ref = '@orcid'; exports.ref = ref; const formats = { '@orcid/id': { parseAsync(id) { const url = `https://pub.orcid.org/v3.0/${id}/works`; const headers = { accept: 'application/json' }; return _core.util.fetchFileAsync(url, { headers }); }, parseType: { dataType: 'String', predicate: /^\d{4}-\d{4}-\d{4}-\d{4}$/ } }, '@orcid/record': { parse(record) { const doi = record['external-ids']['external-id'].find(id => id['external-id-type'] === 'doi'); return doi ? doi['external-id-value'] : null; }, parseType: { dataType: 'SimpleObject', propertyConstraint: { props: ['last-modified-date', 'put-code'] } } }, '@orcid/records': { parse(records) { return records.group.map(record => record['work-summary'][0]); }, parseType: { dataType: 'SimpleObject', propertyConstraint: { props: ['last-modified-date', 'group'] } } } }; exports.formats = formats;