From 68ec4e5953010dad197b5cebed35e32c2d32fe52 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Wed, 10 Jul 2024 15:59:09 +0100 Subject: [PATCH] Support Preprints.org preprints Refs #290 --- src/CrossrefPreprint.ts | 3 +++ src/Preprint.ts | 2 +- src/ReviewRequest.ts | 1 + test/CrossrefPreprint.test.ts | 18 +++++++++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/CrossrefPreprint.ts b/src/CrossrefPreprint.ts index 29486a1..b2de478 100644 --- a/src/CrossrefPreprint.ts +++ b/src/CrossrefPreprint.ts @@ -15,6 +15,7 @@ export interface CrossrefPreprint { | 'edarxiv' | 'medrxiv' | 'osf-preprints' + | 'preprints.org' | 'psyarxiv' | 'scielo' | 'socarxiv' @@ -29,6 +30,7 @@ export const CrossrefPreprintServerSchema = Schema.Literal( 'edarxiv', 'medrxiv', 'osf-preprints', + 'preprints.org', 'psyarxiv', 'scielo', 'socarxiv', @@ -64,6 +66,7 @@ export const getPreprintFromCrossref = ( Match.when(['1101', { institution: [{ name: 'bioRxiv' }] }], () => 'biorxiv' as const), Match.when(['1101', { institution: [{ name: 'medRxiv' }] }], () => 'medrxiv' as const), Match.when(['1590'], () => 'scielo' as const), + Match.when(['20944'], () => 'preprints.org' 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(['31235', { 'group-title': 'SocArXiv' }], () => 'socarxiv' as const), diff --git a/src/Preprint.ts b/src/Preprint.ts index ded1bd0..4b01239 100644 --- a/src/Preprint.ts +++ b/src/Preprint.ts @@ -23,7 +23,7 @@ export const getPreprint: ( ) => Effect.Effect = flow( Match.value, Match.when( - Doi.hasRegistrant('1101', '1590', '31219', '31234', '31235', '32942', '35542'), + Doi.hasRegistrant('1101', '1590', '20944', '31219', '31234', '31235', '32942', '35542'), CrossrefPreprint.getPreprintFromCrossref, ), Match.when(Doi.hasRegistrant('48550'), DatacitePreprint.getPreprintFromDatacite), diff --git a/src/ReviewRequest.ts b/src/ReviewRequest.ts index 91d5103..5e59bac 100644 --- a/src/ReviewRequest.ts +++ b/src/ReviewRequest.ts @@ -223,6 +223,7 @@ Preprint server: """${Match.value(preprint.server).pipe( Match.when('edarxiv', () => 'EdArXiv'), Match.when('medrxiv', () => 'medRxiv'), Match.when('osf-preprints', () => 'OSF Preprints'), + Match.when('preprints.org', () => 'Preprints.org'), Match.when('psyarxiv', () => 'PsyArXiv'), Match.when('scielo', () => 'SciELO Preprints'), Match.when('socarxiv', () => 'SocArXiv'), diff --git a/test/CrossrefPreprint.test.ts b/test/CrossrefPreprint.test.ts index c4bd222..a15e779 100644 --- a/test/CrossrefPreprint.test.ts +++ b/test/CrossrefPreprint.test.ts @@ -34,6 +34,12 @@ describe('getPreprintFromCrossref', () => { fc.constant('Open Science Framework'), fc.constant('osf-preprints'), ), + fc.tuple( + fc.doi({ registrant: fc.constant('20944') }), + fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }), + fc.option(fc.string(), { nil: undefined }), + fc.constant('preprints.org'), + ), fc.tuple( fc.doi({ registrant: fc.constant('31234') }), fc.option(fc.array(fc.record({ name: fc.string() })), { nil: undefined }), @@ -113,7 +119,7 @@ describe('getPreprintFromCrossref', () => { subtype: fc.constant('preprint'), }), fc.crossrefWork({ - DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }), title: fc.constant([]), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), @@ -173,7 +179,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.constant(undefined), - DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), @@ -238,7 +244,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.string(), - DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }), published: fc.oneof(fc.plainYear(), fc.plainYearMonth()), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), @@ -308,7 +314,7 @@ describe('getPreprintFromCrossref', () => { }), fc.crossrefWork({ abstract: fc.string(), - DOI: fc.doi({ registrant: fc.constantFrom('1590', '32942') }), + DOI: fc.doi({ registrant: fc.constantFrom('1590', '20944', '32942') }), published: fc.constant(undefined), title: fc.nonEmptyArray(fc.string()), type: fc.constant('posted-content'), @@ -392,7 +398,9 @@ describe('getPreprintFromCrossref', () => { fc.doi(), fc.oneof( fc.crossrefWork({ - DOI: fc.doi({ registrant: fc.doiRegistrant().filter(registrant => !['1590', '32942'].includes(registrant)) }), + DOI: fc.doi({ + registrant: fc.doiRegistrant().filter(registrant => !['1590', '20944', '32942'].includes(registrant)), + }), type: fc.constant('posted-content'), subtype: fc.constant('preprint'), }),