From 38ed8845e11f99d8fd1d0d99898cb1eb503764f0 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Thu, 2 May 2024 12:17:20 +0100 Subject: [PATCH] Support EcoEvoRxiv preprints Refs #290 --- src/CrossrefPreprint.ts | 3 ++- src/Preprint.ts | 5 ++++- src/ReviewRequest.ts | 1 + test/CrossrefPreprint.test.ts | 16 +++++++++++----- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/CrossrefPreprint.ts b/src/CrossrefPreprint.ts index f147bb9..3a7657f 100644 --- a/src/CrossrefPreprint.ts +++ b/src/CrossrefPreprint.ts @@ -8,7 +8,7 @@ export interface CrossrefPreprint { readonly authors: ReadonlyArray readonly doi: Doi.Doi readonly posted: Temporal.PlainDate - readonly server: 'biorxiv' | 'edarxiv' | 'medrxiv' | 'osf-preprints' | 'psyarxiv' | 'scielo' + readonly server: 'biorxiv' | 'ecoevorxiv' | 'edarxiv' | 'medrxiv' | 'osf-preprints' | 'psyarxiv' | 'scielo' readonly title: string } @@ -46,6 +46,7 @@ export const getPreprintFromCrossref = ( Match.when(['1590'], () => 'scielo' as const), Match.when(['31219', { 'group-title': 'Open Science Framework' }], () => 'osf-preprints' as const), Match.when(['31234', { 'group-title': 'PsyArXiv' }], () => 'psyarxiv' as const), + Match.when(['32942'], () => 'ecoevorxiv' as const), Match.when(['35542', { 'group-title': 'EdArXiv' }], () => 'edarxiv' as const), Match.either, Either.mapLeft(() => new GetPreprintFromCrossrefError({ message: 'Not from a supported server' })), diff --git a/src/Preprint.ts b/src/Preprint.ts index aa2a55d..701adb4 100644 --- a/src/Preprint.ts +++ b/src/Preprint.ts @@ -16,7 +16,10 @@ export const getPreprint: ( doi: Doi.Doi, ) => Effect.Effect = flow( Match.value, - Match.when(Doi.hasRegistrant('1101', '1590', '31219', '31234', '35542'), CrossrefPreprint.getPreprintFromCrossref), + Match.when( + Doi.hasRegistrant('1101', '1590', '31219', '31234', '32942', '35542'), + CrossrefPreprint.getPreprintFromCrossref, + ), Match.when(Doi.hasRegistrant('48550'), DatacitePreprint.getPreprintFromDatacite), Match.orElse(() => Effect.fail('Not from a supported server')), Effect.mapError(toGetPreprintError), diff --git a/src/ReviewRequest.ts b/src/ReviewRequest.ts index 649880e..a681fed 100644 --- a/src/ReviewRequest.ts +++ b/src/ReviewRequest.ts @@ -219,6 +219,7 @@ ${Array.match(preprint.authors, { Preprint server: """${Match.value(preprint.server).pipe( Match.when('arxiv', () => 'arXiv'), Match.when('biorxiv', () => 'bioRxiv'), + Match.when('ecoevorxiv', () => 'EcoEvoRxiv'), Match.when('edarxiv', () => 'EdArXiv'), Match.when('medrxiv', () => 'medRxiv'), Match.when('osf-preprints', () => 'OSF Preprints'), diff --git a/test/CrossrefPreprint.test.ts b/test/CrossrefPreprint.test.ts index 0450a4a..ab49e8a 100644 --- a/test/CrossrefPreprint.test.ts +++ b/test/CrossrefPreprint.test.ts @@ -40,6 +40,12 @@ describe('getPreprintFromCrossref', () => { fc.constant('PsyArXiv'), fc.constant('psyarxiv'), ), + fc.tuple( + fc.doi({ registrant: fc.constant('32942') }), + fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }), + fc.option(fc.string(), { nil: undefined }), + fc.constant('ecoevorxiv'), + ), fc.tuple( fc.doi({ registrant: fc.constant('35542') }), fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }), @@ -101,7 +107,7 @@ describe('getPreprintFromCrossref', () => { subtype: fc.constant('preprint'), }), fc.crossrefWork({ - DOI: fc.doi({ registrant: fc.constant('1590') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), title: fc.constant([]), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), @@ -154,7 +160,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.constant(undefined), - DOI: fc.doi({ registrant: fc.constant('1590') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), @@ -211,7 +217,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.string(), - DOI: fc.doi({ registrant: fc.constant('1590') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), published: fc.oneof(fc.plainYear(), fc.plainYearMonth()), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), @@ -272,7 +278,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.string(), - DOI: fc.doi({ registrant: fc.constant('1590') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), published: fc.constant(undefined), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), @@ -347,7 +353,7 @@ describe('getPreprintFromCrossref', () => { fc.doi(), fc.oneof( fc.crossrefWork({ - DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590'].includes(registrant)) }), + DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590', '32942'].includes(registrant)) }), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), }),